app.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435
  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. //
  1836. //
  1837. //
  1838. //
  1839. //
  1840. //
  1841. //
  1842. //
  1843. /* harmony default export */ __webpack_exports__["default"] = ({
  1844. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1845. props: ['workOrder'],
  1846. data: function data() {
  1847. return {
  1848. data: JSON.parse(this.workOrder),
  1849. storeList: null
  1850. };
  1851. },
  1852. mounted: function mounted() {
  1853. var _this = this;
  1854. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1855. _this.data = JSON.parse(e.data);
  1856. });
  1857. axios.get('/api/stores').then(function (response) {
  1858. _this.storeList = new Map();
  1859. response.data.map(function (val) {
  1860. _this.storeList.set(val.storeid, val);
  1861. });
  1862. })["catch"](function (error) {
  1863. console.error(error);
  1864. });
  1865. },
  1866. methods: {
  1867. updateWorkOrder: function updateWorkOrder() {
  1868. axios.put('/api/workorders/' + this.data.woid, this.data).then(function (response) {})["catch"](function (error) {});
  1869. $('#workordereditModal').modal('hide');
  1870. }
  1871. }
  1872. });
  1873. /***/ }),
  1874. /***/ "./node_modules/base64-js/index.js":
  1875. /*!*****************************************!*\
  1876. !*** ./node_modules/base64-js/index.js ***!
  1877. \*****************************************/
  1878. /*! no static exports found */
  1879. /***/ (function(module, exports, __webpack_require__) {
  1880. "use strict";
  1881. exports.byteLength = byteLength
  1882. exports.toByteArray = toByteArray
  1883. exports.fromByteArray = fromByteArray
  1884. var lookup = []
  1885. var revLookup = []
  1886. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1887. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1888. for (var i = 0, len = code.length; i < len; ++i) {
  1889. lookup[i] = code[i]
  1890. revLookup[code.charCodeAt(i)] = i
  1891. }
  1892. // Support decoding URL-safe base64 strings, as Node.js does.
  1893. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1894. revLookup['-'.charCodeAt(0)] = 62
  1895. revLookup['_'.charCodeAt(0)] = 63
  1896. function getLens (b64) {
  1897. var len = b64.length
  1898. if (len % 4 > 0) {
  1899. throw new Error('Invalid string. Length must be a multiple of 4')
  1900. }
  1901. // Trim off extra bytes after placeholder bytes are found
  1902. // See: https://github.com/beatgammit/base64-js/issues/42
  1903. var validLen = b64.indexOf('=')
  1904. if (validLen === -1) validLen = len
  1905. var placeHoldersLen = validLen === len
  1906. ? 0
  1907. : 4 - (validLen % 4)
  1908. return [validLen, placeHoldersLen]
  1909. }
  1910. // base64 is 4/3 + up to two characters of the original data
  1911. function byteLength (b64) {
  1912. var lens = getLens(b64)
  1913. var validLen = lens[0]
  1914. var placeHoldersLen = lens[1]
  1915. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1916. }
  1917. function _byteLength (b64, validLen, placeHoldersLen) {
  1918. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1919. }
  1920. function toByteArray (b64) {
  1921. var tmp
  1922. var lens = getLens(b64)
  1923. var validLen = lens[0]
  1924. var placeHoldersLen = lens[1]
  1925. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1926. var curByte = 0
  1927. // if there are placeholders, only get up to the last complete 4 chars
  1928. var len = placeHoldersLen > 0
  1929. ? validLen - 4
  1930. : validLen
  1931. var i
  1932. for (i = 0; i < len; i += 4) {
  1933. tmp =
  1934. (revLookup[b64.charCodeAt(i)] << 18) |
  1935. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1936. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1937. revLookup[b64.charCodeAt(i + 3)]
  1938. arr[curByte++] = (tmp >> 16) & 0xFF
  1939. arr[curByte++] = (tmp >> 8) & 0xFF
  1940. arr[curByte++] = tmp & 0xFF
  1941. }
  1942. if (placeHoldersLen === 2) {
  1943. tmp =
  1944. (revLookup[b64.charCodeAt(i)] << 2) |
  1945. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1946. arr[curByte++] = tmp & 0xFF
  1947. }
  1948. if (placeHoldersLen === 1) {
  1949. tmp =
  1950. (revLookup[b64.charCodeAt(i)] << 10) |
  1951. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1952. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1953. arr[curByte++] = (tmp >> 8) & 0xFF
  1954. arr[curByte++] = tmp & 0xFF
  1955. }
  1956. return arr
  1957. }
  1958. function tripletToBase64 (num) {
  1959. return lookup[num >> 18 & 0x3F] +
  1960. lookup[num >> 12 & 0x3F] +
  1961. lookup[num >> 6 & 0x3F] +
  1962. lookup[num & 0x3F]
  1963. }
  1964. function encodeChunk (uint8, start, end) {
  1965. var tmp
  1966. var output = []
  1967. for (var i = start; i < end; i += 3) {
  1968. tmp =
  1969. ((uint8[i] << 16) & 0xFF0000) +
  1970. ((uint8[i + 1] << 8) & 0xFF00) +
  1971. (uint8[i + 2] & 0xFF)
  1972. output.push(tripletToBase64(tmp))
  1973. }
  1974. return output.join('')
  1975. }
  1976. function fromByteArray (uint8) {
  1977. var tmp
  1978. var len = uint8.length
  1979. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1980. var parts = []
  1981. var maxChunkLength = 16383 // must be multiple of 3
  1982. // go through the array every three bytes, we'll deal with trailing stuff later
  1983. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1984. parts.push(encodeChunk(
  1985. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1986. ))
  1987. }
  1988. // pad the end with zeros, but make sure to not forget the extra bytes
  1989. if (extraBytes === 1) {
  1990. tmp = uint8[len - 1]
  1991. parts.push(
  1992. lookup[tmp >> 2] +
  1993. lookup[(tmp << 4) & 0x3F] +
  1994. '=='
  1995. )
  1996. } else if (extraBytes === 2) {
  1997. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1998. parts.push(
  1999. lookup[tmp >> 10] +
  2000. lookup[(tmp >> 4) & 0x3F] +
  2001. lookup[(tmp << 2) & 0x3F] +
  2002. '='
  2003. )
  2004. }
  2005. return parts.join('')
  2006. }
  2007. /***/ }),
  2008. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  2009. /*!*****************************************************!*\
  2010. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  2011. \*****************************************************/
  2012. /*! no static exports found */
  2013. /***/ (function(module, exports, __webpack_require__) {
  2014. /*!
  2015. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  2016. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  2017. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2018. */
  2019. (function (global, factory) {
  2020. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  2021. undefined;
  2022. }(this, (function (exports, $, Popper) { 'use strict';
  2023. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  2024. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  2025. function _defineProperties(target, props) {
  2026. for (var i = 0; i < props.length; i++) {
  2027. var descriptor = props[i];
  2028. descriptor.enumerable = descriptor.enumerable || false;
  2029. descriptor.configurable = true;
  2030. if ("value" in descriptor) descriptor.writable = true;
  2031. Object.defineProperty(target, descriptor.key, descriptor);
  2032. }
  2033. }
  2034. function _createClass(Constructor, protoProps, staticProps) {
  2035. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  2036. if (staticProps) _defineProperties(Constructor, staticProps);
  2037. return Constructor;
  2038. }
  2039. function _defineProperty(obj, key, value) {
  2040. if (key in obj) {
  2041. Object.defineProperty(obj, key, {
  2042. value: value,
  2043. enumerable: true,
  2044. configurable: true,
  2045. writable: true
  2046. });
  2047. } else {
  2048. obj[key] = value;
  2049. }
  2050. return obj;
  2051. }
  2052. function ownKeys(object, enumerableOnly) {
  2053. var keys = Object.keys(object);
  2054. if (Object.getOwnPropertySymbols) {
  2055. var symbols = Object.getOwnPropertySymbols(object);
  2056. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  2057. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  2058. });
  2059. keys.push.apply(keys, symbols);
  2060. }
  2061. return keys;
  2062. }
  2063. function _objectSpread2(target) {
  2064. for (var i = 1; i < arguments.length; i++) {
  2065. var source = arguments[i] != null ? arguments[i] : {};
  2066. if (i % 2) {
  2067. ownKeys(Object(source), true).forEach(function (key) {
  2068. _defineProperty(target, key, source[key]);
  2069. });
  2070. } else if (Object.getOwnPropertyDescriptors) {
  2071. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  2072. } else {
  2073. ownKeys(Object(source)).forEach(function (key) {
  2074. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2075. });
  2076. }
  2077. }
  2078. return target;
  2079. }
  2080. function _inheritsLoose(subClass, superClass) {
  2081. subClass.prototype = Object.create(superClass.prototype);
  2082. subClass.prototype.constructor = subClass;
  2083. subClass.__proto__ = superClass;
  2084. }
  2085. /**
  2086. * --------------------------------------------------------------------------
  2087. * Bootstrap (v4.4.1): util.js
  2088. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2089. * --------------------------------------------------------------------------
  2090. */
  2091. /**
  2092. * ------------------------------------------------------------------------
  2093. * Private TransitionEnd Helpers
  2094. * ------------------------------------------------------------------------
  2095. */
  2096. var TRANSITION_END = 'transitionend';
  2097. var MAX_UID = 1000000;
  2098. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  2099. function toType(obj) {
  2100. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  2101. }
  2102. function getSpecialTransitionEndEvent() {
  2103. return {
  2104. bindType: TRANSITION_END,
  2105. delegateType: TRANSITION_END,
  2106. handle: function handle(event) {
  2107. if ($(event.target).is(this)) {
  2108. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2109. }
  2110. return undefined; // eslint-disable-line no-undefined
  2111. }
  2112. };
  2113. }
  2114. function transitionEndEmulator(duration) {
  2115. var _this = this;
  2116. var called = false;
  2117. $(this).one(Util.TRANSITION_END, function () {
  2118. called = true;
  2119. });
  2120. setTimeout(function () {
  2121. if (!called) {
  2122. Util.triggerTransitionEnd(_this);
  2123. }
  2124. }, duration);
  2125. return this;
  2126. }
  2127. function setTransitionEndSupport() {
  2128. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2129. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2130. }
  2131. /**
  2132. * --------------------------------------------------------------------------
  2133. * Public Util Api
  2134. * --------------------------------------------------------------------------
  2135. */
  2136. var Util = {
  2137. TRANSITION_END: 'bsTransitionEnd',
  2138. getUID: function getUID(prefix) {
  2139. do {
  2140. // eslint-disable-next-line no-bitwise
  2141. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2142. } while (document.getElementById(prefix));
  2143. return prefix;
  2144. },
  2145. getSelectorFromElement: function getSelectorFromElement(element) {
  2146. var selector = element.getAttribute('data-target');
  2147. if (!selector || selector === '#') {
  2148. var hrefAttr = element.getAttribute('href');
  2149. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2150. }
  2151. try {
  2152. return document.querySelector(selector) ? selector : null;
  2153. } catch (err) {
  2154. return null;
  2155. }
  2156. },
  2157. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2158. if (!element) {
  2159. return 0;
  2160. } // Get transition-duration of the element
  2161. var transitionDuration = $(element).css('transition-duration');
  2162. var transitionDelay = $(element).css('transition-delay');
  2163. var floatTransitionDuration = parseFloat(transitionDuration);
  2164. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2165. if (!floatTransitionDuration && !floatTransitionDelay) {
  2166. return 0;
  2167. } // If multiple durations are defined, take the first
  2168. transitionDuration = transitionDuration.split(',')[0];
  2169. transitionDelay = transitionDelay.split(',')[0];
  2170. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2171. },
  2172. reflow: function reflow(element) {
  2173. return element.offsetHeight;
  2174. },
  2175. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2176. $(element).trigger(TRANSITION_END);
  2177. },
  2178. // TODO: Remove in v5
  2179. supportsTransitionEnd: function supportsTransitionEnd() {
  2180. return Boolean(TRANSITION_END);
  2181. },
  2182. isElement: function isElement(obj) {
  2183. return (obj[0] || obj).nodeType;
  2184. },
  2185. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2186. for (var property in configTypes) {
  2187. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2188. var expectedTypes = configTypes[property];
  2189. var value = config[property];
  2190. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2191. if (!new RegExp(expectedTypes).test(valueType)) {
  2192. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2193. }
  2194. }
  2195. }
  2196. },
  2197. findShadowRoot: function findShadowRoot(element) {
  2198. if (!document.documentElement.attachShadow) {
  2199. return null;
  2200. } // Can find the shadow root otherwise it'll return the document
  2201. if (typeof element.getRootNode === 'function') {
  2202. var root = element.getRootNode();
  2203. return root instanceof ShadowRoot ? root : null;
  2204. }
  2205. if (element instanceof ShadowRoot) {
  2206. return element;
  2207. } // when we don't find a shadow root
  2208. if (!element.parentNode) {
  2209. return null;
  2210. }
  2211. return Util.findShadowRoot(element.parentNode);
  2212. },
  2213. jQueryDetection: function jQueryDetection() {
  2214. if (typeof $ === 'undefined') {
  2215. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2216. }
  2217. var version = $.fn.jquery.split(' ')[0].split('.');
  2218. var minMajor = 1;
  2219. var ltMajor = 2;
  2220. var minMinor = 9;
  2221. var minPatch = 1;
  2222. var maxMajor = 4;
  2223. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2224. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2225. }
  2226. }
  2227. };
  2228. Util.jQueryDetection();
  2229. setTransitionEndSupport();
  2230. /**
  2231. * ------------------------------------------------------------------------
  2232. * Constants
  2233. * ------------------------------------------------------------------------
  2234. */
  2235. var NAME = 'alert';
  2236. var VERSION = '4.4.1';
  2237. var DATA_KEY = 'bs.alert';
  2238. var EVENT_KEY = "." + DATA_KEY;
  2239. var DATA_API_KEY = '.data-api';
  2240. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2241. var Selector = {
  2242. DISMISS: '[data-dismiss="alert"]'
  2243. };
  2244. var Event = {
  2245. CLOSE: "close" + EVENT_KEY,
  2246. CLOSED: "closed" + EVENT_KEY,
  2247. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2248. };
  2249. var ClassName = {
  2250. ALERT: 'alert',
  2251. FADE: 'fade',
  2252. SHOW: 'show'
  2253. };
  2254. /**
  2255. * ------------------------------------------------------------------------
  2256. * Class Definition
  2257. * ------------------------------------------------------------------------
  2258. */
  2259. var Alert =
  2260. /*#__PURE__*/
  2261. function () {
  2262. function Alert(element) {
  2263. this._element = element;
  2264. } // Getters
  2265. var _proto = Alert.prototype;
  2266. // Public
  2267. _proto.close = function close(element) {
  2268. var rootElement = this._element;
  2269. if (element) {
  2270. rootElement = this._getRootElement(element);
  2271. }
  2272. var customEvent = this._triggerCloseEvent(rootElement);
  2273. if (customEvent.isDefaultPrevented()) {
  2274. return;
  2275. }
  2276. this._removeElement(rootElement);
  2277. };
  2278. _proto.dispose = function dispose() {
  2279. $.removeData(this._element, DATA_KEY);
  2280. this._element = null;
  2281. } // Private
  2282. ;
  2283. _proto._getRootElement = function _getRootElement(element) {
  2284. var selector = Util.getSelectorFromElement(element);
  2285. var parent = false;
  2286. if (selector) {
  2287. parent = document.querySelector(selector);
  2288. }
  2289. if (!parent) {
  2290. parent = $(element).closest("." + ClassName.ALERT)[0];
  2291. }
  2292. return parent;
  2293. };
  2294. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2295. var closeEvent = $.Event(Event.CLOSE);
  2296. $(element).trigger(closeEvent);
  2297. return closeEvent;
  2298. };
  2299. _proto._removeElement = function _removeElement(element) {
  2300. var _this = this;
  2301. $(element).removeClass(ClassName.SHOW);
  2302. if (!$(element).hasClass(ClassName.FADE)) {
  2303. this._destroyElement(element);
  2304. return;
  2305. }
  2306. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2307. $(element).one(Util.TRANSITION_END, function (event) {
  2308. return _this._destroyElement(element, event);
  2309. }).emulateTransitionEnd(transitionDuration);
  2310. };
  2311. _proto._destroyElement = function _destroyElement(element) {
  2312. $(element).detach().trigger(Event.CLOSED).remove();
  2313. } // Static
  2314. ;
  2315. Alert._jQueryInterface = function _jQueryInterface(config) {
  2316. return this.each(function () {
  2317. var $element = $(this);
  2318. var data = $element.data(DATA_KEY);
  2319. if (!data) {
  2320. data = new Alert(this);
  2321. $element.data(DATA_KEY, data);
  2322. }
  2323. if (config === 'close') {
  2324. data[config](this);
  2325. }
  2326. });
  2327. };
  2328. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2329. return function (event) {
  2330. if (event) {
  2331. event.preventDefault();
  2332. }
  2333. alertInstance.close(this);
  2334. };
  2335. };
  2336. _createClass(Alert, null, [{
  2337. key: "VERSION",
  2338. get: function get() {
  2339. return VERSION;
  2340. }
  2341. }]);
  2342. return Alert;
  2343. }();
  2344. /**
  2345. * ------------------------------------------------------------------------
  2346. * Data Api implementation
  2347. * ------------------------------------------------------------------------
  2348. */
  2349. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2350. /**
  2351. * ------------------------------------------------------------------------
  2352. * jQuery
  2353. * ------------------------------------------------------------------------
  2354. */
  2355. $.fn[NAME] = Alert._jQueryInterface;
  2356. $.fn[NAME].Constructor = Alert;
  2357. $.fn[NAME].noConflict = function () {
  2358. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2359. return Alert._jQueryInterface;
  2360. };
  2361. /**
  2362. * ------------------------------------------------------------------------
  2363. * Constants
  2364. * ------------------------------------------------------------------------
  2365. */
  2366. var NAME$1 = 'button';
  2367. var VERSION$1 = '4.4.1';
  2368. var DATA_KEY$1 = 'bs.button';
  2369. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2370. var DATA_API_KEY$1 = '.data-api';
  2371. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2372. var ClassName$1 = {
  2373. ACTIVE: 'active',
  2374. BUTTON: 'btn',
  2375. FOCUS: 'focus'
  2376. };
  2377. var Selector$1 = {
  2378. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2379. DATA_TOGGLES: '[data-toggle="buttons"]',
  2380. DATA_TOGGLE: '[data-toggle="button"]',
  2381. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2382. INPUT: 'input:not([type="hidden"])',
  2383. ACTIVE: '.active',
  2384. BUTTON: '.btn'
  2385. };
  2386. var Event$1 = {
  2387. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2388. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2389. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2390. };
  2391. /**
  2392. * ------------------------------------------------------------------------
  2393. * Class Definition
  2394. * ------------------------------------------------------------------------
  2395. */
  2396. var Button =
  2397. /*#__PURE__*/
  2398. function () {
  2399. function Button(element) {
  2400. this._element = element;
  2401. } // Getters
  2402. var _proto = Button.prototype;
  2403. // Public
  2404. _proto.toggle = function toggle() {
  2405. var triggerChangeEvent = true;
  2406. var addAriaPressed = true;
  2407. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2408. if (rootElement) {
  2409. var input = this._element.querySelector(Selector$1.INPUT);
  2410. if (input) {
  2411. if (input.type === 'radio') {
  2412. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2413. triggerChangeEvent = false;
  2414. } else {
  2415. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2416. if (activeElement) {
  2417. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2418. }
  2419. }
  2420. } else if (input.type === 'checkbox') {
  2421. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2422. triggerChangeEvent = false;
  2423. }
  2424. } else {
  2425. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2426. triggerChangeEvent = false;
  2427. }
  2428. if (triggerChangeEvent) {
  2429. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2430. $(input).trigger('change');
  2431. }
  2432. input.focus();
  2433. addAriaPressed = false;
  2434. }
  2435. }
  2436. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2437. if (addAriaPressed) {
  2438. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2439. }
  2440. if (triggerChangeEvent) {
  2441. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2442. }
  2443. }
  2444. };
  2445. _proto.dispose = function dispose() {
  2446. $.removeData(this._element, DATA_KEY$1);
  2447. this._element = null;
  2448. } // Static
  2449. ;
  2450. Button._jQueryInterface = function _jQueryInterface(config) {
  2451. return this.each(function () {
  2452. var data = $(this).data(DATA_KEY$1);
  2453. if (!data) {
  2454. data = new Button(this);
  2455. $(this).data(DATA_KEY$1, data);
  2456. }
  2457. if (config === 'toggle') {
  2458. data[config]();
  2459. }
  2460. });
  2461. };
  2462. _createClass(Button, null, [{
  2463. key: "VERSION",
  2464. get: function get() {
  2465. return VERSION$1;
  2466. }
  2467. }]);
  2468. return Button;
  2469. }();
  2470. /**
  2471. * ------------------------------------------------------------------------
  2472. * Data Api implementation
  2473. * ------------------------------------------------------------------------
  2474. */
  2475. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2476. var button = event.target;
  2477. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2478. button = $(button).closest(Selector$1.BUTTON)[0];
  2479. }
  2480. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2481. event.preventDefault(); // work around Firefox bug #1540995
  2482. } else {
  2483. var inputBtn = button.querySelector(Selector$1.INPUT);
  2484. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2485. event.preventDefault(); // work around Firefox bug #1540995
  2486. return;
  2487. }
  2488. Button._jQueryInterface.call($(button), 'toggle');
  2489. }
  2490. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2491. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2492. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2493. });
  2494. $(window).on(Event$1.LOAD_DATA_API, function () {
  2495. // ensure correct active class is set to match the controls' actual values/states
  2496. // find all checkboxes/readio buttons inside data-toggle groups
  2497. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2498. for (var i = 0, len = buttons.length; i < len; i++) {
  2499. var button = buttons[i];
  2500. var input = button.querySelector(Selector$1.INPUT);
  2501. if (input.checked || input.hasAttribute('checked')) {
  2502. button.classList.add(ClassName$1.ACTIVE);
  2503. } else {
  2504. button.classList.remove(ClassName$1.ACTIVE);
  2505. }
  2506. } // find all button toggles
  2507. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2508. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2509. var _button = buttons[_i];
  2510. if (_button.getAttribute('aria-pressed') === 'true') {
  2511. _button.classList.add(ClassName$1.ACTIVE);
  2512. } else {
  2513. _button.classList.remove(ClassName$1.ACTIVE);
  2514. }
  2515. }
  2516. });
  2517. /**
  2518. * ------------------------------------------------------------------------
  2519. * jQuery
  2520. * ------------------------------------------------------------------------
  2521. */
  2522. $.fn[NAME$1] = Button._jQueryInterface;
  2523. $.fn[NAME$1].Constructor = Button;
  2524. $.fn[NAME$1].noConflict = function () {
  2525. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2526. return Button._jQueryInterface;
  2527. };
  2528. /**
  2529. * ------------------------------------------------------------------------
  2530. * Constants
  2531. * ------------------------------------------------------------------------
  2532. */
  2533. var NAME$2 = 'carousel';
  2534. var VERSION$2 = '4.4.1';
  2535. var DATA_KEY$2 = 'bs.carousel';
  2536. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2537. var DATA_API_KEY$2 = '.data-api';
  2538. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2539. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2540. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2541. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2542. var SWIPE_THRESHOLD = 40;
  2543. var Default = {
  2544. interval: 5000,
  2545. keyboard: true,
  2546. slide: false,
  2547. pause: 'hover',
  2548. wrap: true,
  2549. touch: true
  2550. };
  2551. var DefaultType = {
  2552. interval: '(number|boolean)',
  2553. keyboard: 'boolean',
  2554. slide: '(boolean|string)',
  2555. pause: '(string|boolean)',
  2556. wrap: 'boolean',
  2557. touch: 'boolean'
  2558. };
  2559. var Direction = {
  2560. NEXT: 'next',
  2561. PREV: 'prev',
  2562. LEFT: 'left',
  2563. RIGHT: 'right'
  2564. };
  2565. var Event$2 = {
  2566. SLIDE: "slide" + EVENT_KEY$2,
  2567. SLID: "slid" + EVENT_KEY$2,
  2568. KEYDOWN: "keydown" + EVENT_KEY$2,
  2569. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2570. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2571. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2572. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2573. TOUCHEND: "touchend" + EVENT_KEY$2,
  2574. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2575. POINTERUP: "pointerup" + EVENT_KEY$2,
  2576. DRAG_START: "dragstart" + EVENT_KEY$2,
  2577. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2578. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2579. };
  2580. var ClassName$2 = {
  2581. CAROUSEL: 'carousel',
  2582. ACTIVE: 'active',
  2583. SLIDE: 'slide',
  2584. RIGHT: 'carousel-item-right',
  2585. LEFT: 'carousel-item-left',
  2586. NEXT: 'carousel-item-next',
  2587. PREV: 'carousel-item-prev',
  2588. ITEM: 'carousel-item',
  2589. POINTER_EVENT: 'pointer-event'
  2590. };
  2591. var Selector$2 = {
  2592. ACTIVE: '.active',
  2593. ACTIVE_ITEM: '.active.carousel-item',
  2594. ITEM: '.carousel-item',
  2595. ITEM_IMG: '.carousel-item img',
  2596. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2597. INDICATORS: '.carousel-indicators',
  2598. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2599. DATA_RIDE: '[data-ride="carousel"]'
  2600. };
  2601. var PointerType = {
  2602. TOUCH: 'touch',
  2603. PEN: 'pen'
  2604. };
  2605. /**
  2606. * ------------------------------------------------------------------------
  2607. * Class Definition
  2608. * ------------------------------------------------------------------------
  2609. */
  2610. var Carousel =
  2611. /*#__PURE__*/
  2612. function () {
  2613. function Carousel(element, config) {
  2614. this._items = null;
  2615. this._interval = null;
  2616. this._activeElement = null;
  2617. this._isPaused = false;
  2618. this._isSliding = false;
  2619. this.touchTimeout = null;
  2620. this.touchStartX = 0;
  2621. this.touchDeltaX = 0;
  2622. this._config = this._getConfig(config);
  2623. this._element = element;
  2624. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2625. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2626. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2627. this._addEventListeners();
  2628. } // Getters
  2629. var _proto = Carousel.prototype;
  2630. // Public
  2631. _proto.next = function next() {
  2632. if (!this._isSliding) {
  2633. this._slide(Direction.NEXT);
  2634. }
  2635. };
  2636. _proto.nextWhenVisible = function nextWhenVisible() {
  2637. // Don't call next when the page isn't visible
  2638. // or the carousel or its parent isn't visible
  2639. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2640. this.next();
  2641. }
  2642. };
  2643. _proto.prev = function prev() {
  2644. if (!this._isSliding) {
  2645. this._slide(Direction.PREV);
  2646. }
  2647. };
  2648. _proto.pause = function pause(event) {
  2649. if (!event) {
  2650. this._isPaused = true;
  2651. }
  2652. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2653. Util.triggerTransitionEnd(this._element);
  2654. this.cycle(true);
  2655. }
  2656. clearInterval(this._interval);
  2657. this._interval = null;
  2658. };
  2659. _proto.cycle = function cycle(event) {
  2660. if (!event) {
  2661. this._isPaused = false;
  2662. }
  2663. if (this._interval) {
  2664. clearInterval(this._interval);
  2665. this._interval = null;
  2666. }
  2667. if (this._config.interval && !this._isPaused) {
  2668. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2669. }
  2670. };
  2671. _proto.to = function to(index) {
  2672. var _this = this;
  2673. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2674. var activeIndex = this._getItemIndex(this._activeElement);
  2675. if (index > this._items.length - 1 || index < 0) {
  2676. return;
  2677. }
  2678. if (this._isSliding) {
  2679. $(this._element).one(Event$2.SLID, function () {
  2680. return _this.to(index);
  2681. });
  2682. return;
  2683. }
  2684. if (activeIndex === index) {
  2685. this.pause();
  2686. this.cycle();
  2687. return;
  2688. }
  2689. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2690. this._slide(direction, this._items[index]);
  2691. };
  2692. _proto.dispose = function dispose() {
  2693. $(this._element).off(EVENT_KEY$2);
  2694. $.removeData(this._element, DATA_KEY$2);
  2695. this._items = null;
  2696. this._config = null;
  2697. this._element = null;
  2698. this._interval = null;
  2699. this._isPaused = null;
  2700. this._isSliding = null;
  2701. this._activeElement = null;
  2702. this._indicatorsElement = null;
  2703. } // Private
  2704. ;
  2705. _proto._getConfig = function _getConfig(config) {
  2706. config = _objectSpread2({}, Default, {}, config);
  2707. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2708. return config;
  2709. };
  2710. _proto._handleSwipe = function _handleSwipe() {
  2711. var absDeltax = Math.abs(this.touchDeltaX);
  2712. if (absDeltax <= SWIPE_THRESHOLD) {
  2713. return;
  2714. }
  2715. var direction = absDeltax / this.touchDeltaX;
  2716. this.touchDeltaX = 0; // swipe left
  2717. if (direction > 0) {
  2718. this.prev();
  2719. } // swipe right
  2720. if (direction < 0) {
  2721. this.next();
  2722. }
  2723. };
  2724. _proto._addEventListeners = function _addEventListeners() {
  2725. var _this2 = this;
  2726. if (this._config.keyboard) {
  2727. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2728. return _this2._keydown(event);
  2729. });
  2730. }
  2731. if (this._config.pause === 'hover') {
  2732. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2733. return _this2.pause(event);
  2734. }).on(Event$2.MOUSELEAVE, function (event) {
  2735. return _this2.cycle(event);
  2736. });
  2737. }
  2738. if (this._config.touch) {
  2739. this._addTouchEventListeners();
  2740. }
  2741. };
  2742. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2743. var _this3 = this;
  2744. if (!this._touchSupported) {
  2745. return;
  2746. }
  2747. var start = function start(event) {
  2748. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2749. _this3.touchStartX = event.originalEvent.clientX;
  2750. } else if (!_this3._pointerEvent) {
  2751. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2752. }
  2753. };
  2754. var move = function move(event) {
  2755. // ensure swiping with one touch and not pinching
  2756. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2757. _this3.touchDeltaX = 0;
  2758. } else {
  2759. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2760. }
  2761. };
  2762. var end = function end(event) {
  2763. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2764. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2765. }
  2766. _this3._handleSwipe();
  2767. if (_this3._config.pause === 'hover') {
  2768. // If it's a touch-enabled device, mouseenter/leave are fired as
  2769. // part of the mouse compatibility events on first tap - the carousel
  2770. // would stop cycling until user tapped out of it;
  2771. // here, we listen for touchend, explicitly pause the carousel
  2772. // (as if it's the second time we tap on it, mouseenter compat event
  2773. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2774. // events to fire) we explicitly restart cycling
  2775. _this3.pause();
  2776. if (_this3.touchTimeout) {
  2777. clearTimeout(_this3.touchTimeout);
  2778. }
  2779. _this3.touchTimeout = setTimeout(function (event) {
  2780. return _this3.cycle(event);
  2781. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2782. }
  2783. };
  2784. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2785. return e.preventDefault();
  2786. });
  2787. if (this._pointerEvent) {
  2788. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2789. return start(event);
  2790. });
  2791. $(this._element).on(Event$2.POINTERUP, function (event) {
  2792. return end(event);
  2793. });
  2794. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2795. } else {
  2796. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2797. return start(event);
  2798. });
  2799. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2800. return move(event);
  2801. });
  2802. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2803. return end(event);
  2804. });
  2805. }
  2806. };
  2807. _proto._keydown = function _keydown(event) {
  2808. if (/input|textarea/i.test(event.target.tagName)) {
  2809. return;
  2810. }
  2811. switch (event.which) {
  2812. case ARROW_LEFT_KEYCODE:
  2813. event.preventDefault();
  2814. this.prev();
  2815. break;
  2816. case ARROW_RIGHT_KEYCODE:
  2817. event.preventDefault();
  2818. this.next();
  2819. break;
  2820. }
  2821. };
  2822. _proto._getItemIndex = function _getItemIndex(element) {
  2823. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2824. return this._items.indexOf(element);
  2825. };
  2826. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2827. var isNextDirection = direction === Direction.NEXT;
  2828. var isPrevDirection = direction === Direction.PREV;
  2829. var activeIndex = this._getItemIndex(activeElement);
  2830. var lastItemIndex = this._items.length - 1;
  2831. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2832. if (isGoingToWrap && !this._config.wrap) {
  2833. return activeElement;
  2834. }
  2835. var delta = direction === Direction.PREV ? -1 : 1;
  2836. var itemIndex = (activeIndex + delta) % this._items.length;
  2837. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2838. };
  2839. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2840. var targetIndex = this._getItemIndex(relatedTarget);
  2841. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2842. var slideEvent = $.Event(Event$2.SLIDE, {
  2843. relatedTarget: relatedTarget,
  2844. direction: eventDirectionName,
  2845. from: fromIndex,
  2846. to: targetIndex
  2847. });
  2848. $(this._element).trigger(slideEvent);
  2849. return slideEvent;
  2850. };
  2851. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2852. if (this._indicatorsElement) {
  2853. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2854. $(indicators).removeClass(ClassName$2.ACTIVE);
  2855. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2856. if (nextIndicator) {
  2857. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2858. }
  2859. }
  2860. };
  2861. _proto._slide = function _slide(direction, element) {
  2862. var _this4 = this;
  2863. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2864. var activeElementIndex = this._getItemIndex(activeElement);
  2865. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2866. var nextElementIndex = this._getItemIndex(nextElement);
  2867. var isCycling = Boolean(this._interval);
  2868. var directionalClassName;
  2869. var orderClassName;
  2870. var eventDirectionName;
  2871. if (direction === Direction.NEXT) {
  2872. directionalClassName = ClassName$2.LEFT;
  2873. orderClassName = ClassName$2.NEXT;
  2874. eventDirectionName = Direction.LEFT;
  2875. } else {
  2876. directionalClassName = ClassName$2.RIGHT;
  2877. orderClassName = ClassName$2.PREV;
  2878. eventDirectionName = Direction.RIGHT;
  2879. }
  2880. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2881. this._isSliding = false;
  2882. return;
  2883. }
  2884. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2885. if (slideEvent.isDefaultPrevented()) {
  2886. return;
  2887. }
  2888. if (!activeElement || !nextElement) {
  2889. // Some weirdness is happening, so we bail
  2890. return;
  2891. }
  2892. this._isSliding = true;
  2893. if (isCycling) {
  2894. this.pause();
  2895. }
  2896. this._setActiveIndicatorElement(nextElement);
  2897. var slidEvent = $.Event(Event$2.SLID, {
  2898. relatedTarget: nextElement,
  2899. direction: eventDirectionName,
  2900. from: activeElementIndex,
  2901. to: nextElementIndex
  2902. });
  2903. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2904. $(nextElement).addClass(orderClassName);
  2905. Util.reflow(nextElement);
  2906. $(activeElement).addClass(directionalClassName);
  2907. $(nextElement).addClass(directionalClassName);
  2908. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2909. if (nextElementInterval) {
  2910. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2911. this._config.interval = nextElementInterval;
  2912. } else {
  2913. this._config.interval = this._config.defaultInterval || this._config.interval;
  2914. }
  2915. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2916. $(activeElement).one(Util.TRANSITION_END, function () {
  2917. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2918. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2919. _this4._isSliding = false;
  2920. setTimeout(function () {
  2921. return $(_this4._element).trigger(slidEvent);
  2922. }, 0);
  2923. }).emulateTransitionEnd(transitionDuration);
  2924. } else {
  2925. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2926. $(nextElement).addClass(ClassName$2.ACTIVE);
  2927. this._isSliding = false;
  2928. $(this._element).trigger(slidEvent);
  2929. }
  2930. if (isCycling) {
  2931. this.cycle();
  2932. }
  2933. } // Static
  2934. ;
  2935. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2936. return this.each(function () {
  2937. var data = $(this).data(DATA_KEY$2);
  2938. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2939. if (typeof config === 'object') {
  2940. _config = _objectSpread2({}, _config, {}, config);
  2941. }
  2942. var action = typeof config === 'string' ? config : _config.slide;
  2943. if (!data) {
  2944. data = new Carousel(this, _config);
  2945. $(this).data(DATA_KEY$2, data);
  2946. }
  2947. if (typeof config === 'number') {
  2948. data.to(config);
  2949. } else if (typeof action === 'string') {
  2950. if (typeof data[action] === 'undefined') {
  2951. throw new TypeError("No method named \"" + action + "\"");
  2952. }
  2953. data[action]();
  2954. } else if (_config.interval && _config.ride) {
  2955. data.pause();
  2956. data.cycle();
  2957. }
  2958. });
  2959. };
  2960. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2961. var selector = Util.getSelectorFromElement(this);
  2962. if (!selector) {
  2963. return;
  2964. }
  2965. var target = $(selector)[0];
  2966. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2967. return;
  2968. }
  2969. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2970. var slideIndex = this.getAttribute('data-slide-to');
  2971. if (slideIndex) {
  2972. config.interval = false;
  2973. }
  2974. Carousel._jQueryInterface.call($(target), config);
  2975. if (slideIndex) {
  2976. $(target).data(DATA_KEY$2).to(slideIndex);
  2977. }
  2978. event.preventDefault();
  2979. };
  2980. _createClass(Carousel, null, [{
  2981. key: "VERSION",
  2982. get: function get() {
  2983. return VERSION$2;
  2984. }
  2985. }, {
  2986. key: "Default",
  2987. get: function get() {
  2988. return Default;
  2989. }
  2990. }]);
  2991. return Carousel;
  2992. }();
  2993. /**
  2994. * ------------------------------------------------------------------------
  2995. * Data Api implementation
  2996. * ------------------------------------------------------------------------
  2997. */
  2998. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2999. $(window).on(Event$2.LOAD_DATA_API, function () {
  3000. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  3001. for (var i = 0, len = carousels.length; i < len; i++) {
  3002. var $carousel = $(carousels[i]);
  3003. Carousel._jQueryInterface.call($carousel, $carousel.data());
  3004. }
  3005. });
  3006. /**
  3007. * ------------------------------------------------------------------------
  3008. * jQuery
  3009. * ------------------------------------------------------------------------
  3010. */
  3011. $.fn[NAME$2] = Carousel._jQueryInterface;
  3012. $.fn[NAME$2].Constructor = Carousel;
  3013. $.fn[NAME$2].noConflict = function () {
  3014. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  3015. return Carousel._jQueryInterface;
  3016. };
  3017. /**
  3018. * ------------------------------------------------------------------------
  3019. * Constants
  3020. * ------------------------------------------------------------------------
  3021. */
  3022. var NAME$3 = 'collapse';
  3023. var VERSION$3 = '4.4.1';
  3024. var DATA_KEY$3 = 'bs.collapse';
  3025. var EVENT_KEY$3 = "." + DATA_KEY$3;
  3026. var DATA_API_KEY$3 = '.data-api';
  3027. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  3028. var Default$1 = {
  3029. toggle: true,
  3030. parent: ''
  3031. };
  3032. var DefaultType$1 = {
  3033. toggle: 'boolean',
  3034. parent: '(string|element)'
  3035. };
  3036. var Event$3 = {
  3037. SHOW: "show" + EVENT_KEY$3,
  3038. SHOWN: "shown" + EVENT_KEY$3,
  3039. HIDE: "hide" + EVENT_KEY$3,
  3040. HIDDEN: "hidden" + EVENT_KEY$3,
  3041. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  3042. };
  3043. var ClassName$3 = {
  3044. SHOW: 'show',
  3045. COLLAPSE: 'collapse',
  3046. COLLAPSING: 'collapsing',
  3047. COLLAPSED: 'collapsed'
  3048. };
  3049. var Dimension = {
  3050. WIDTH: 'width',
  3051. HEIGHT: 'height'
  3052. };
  3053. var Selector$3 = {
  3054. ACTIVES: '.show, .collapsing',
  3055. DATA_TOGGLE: '[data-toggle="collapse"]'
  3056. };
  3057. /**
  3058. * ------------------------------------------------------------------------
  3059. * Class Definition
  3060. * ------------------------------------------------------------------------
  3061. */
  3062. var Collapse =
  3063. /*#__PURE__*/
  3064. function () {
  3065. function Collapse(element, config) {
  3066. this._isTransitioning = false;
  3067. this._element = element;
  3068. this._config = this._getConfig(config);
  3069. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  3070. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  3071. for (var i = 0, len = toggleList.length; i < len; i++) {
  3072. var elem = toggleList[i];
  3073. var selector = Util.getSelectorFromElement(elem);
  3074. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  3075. return foundElem === element;
  3076. });
  3077. if (selector !== null && filterElement.length > 0) {
  3078. this._selector = selector;
  3079. this._triggerArray.push(elem);
  3080. }
  3081. }
  3082. this._parent = this._config.parent ? this._getParent() : null;
  3083. if (!this._config.parent) {
  3084. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  3085. }
  3086. if (this._config.toggle) {
  3087. this.toggle();
  3088. }
  3089. } // Getters
  3090. var _proto = Collapse.prototype;
  3091. // Public
  3092. _proto.toggle = function toggle() {
  3093. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  3094. this.hide();
  3095. } else {
  3096. this.show();
  3097. }
  3098. };
  3099. _proto.show = function show() {
  3100. var _this = this;
  3101. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  3102. return;
  3103. }
  3104. var actives;
  3105. var activesData;
  3106. if (this._parent) {
  3107. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  3108. if (typeof _this._config.parent === 'string') {
  3109. return elem.getAttribute('data-parent') === _this._config.parent;
  3110. }
  3111. return elem.classList.contains(ClassName$3.COLLAPSE);
  3112. });
  3113. if (actives.length === 0) {
  3114. actives = null;
  3115. }
  3116. }
  3117. if (actives) {
  3118. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3119. if (activesData && activesData._isTransitioning) {
  3120. return;
  3121. }
  3122. }
  3123. var startEvent = $.Event(Event$3.SHOW);
  3124. $(this._element).trigger(startEvent);
  3125. if (startEvent.isDefaultPrevented()) {
  3126. return;
  3127. }
  3128. if (actives) {
  3129. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3130. if (!activesData) {
  3131. $(actives).data(DATA_KEY$3, null);
  3132. }
  3133. }
  3134. var dimension = this._getDimension();
  3135. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  3136. this._element.style[dimension] = 0;
  3137. if (this._triggerArray.length) {
  3138. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  3139. }
  3140. this.setTransitioning(true);
  3141. var complete = function complete() {
  3142. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  3143. _this._element.style[dimension] = '';
  3144. _this.setTransitioning(false);
  3145. $(_this._element).trigger(Event$3.SHOWN);
  3146. };
  3147. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3148. var scrollSize = "scroll" + capitalizedDimension;
  3149. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3150. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3151. this._element.style[dimension] = this._element[scrollSize] + "px";
  3152. };
  3153. _proto.hide = function hide() {
  3154. var _this2 = this;
  3155. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  3156. return;
  3157. }
  3158. var startEvent = $.Event(Event$3.HIDE);
  3159. $(this._element).trigger(startEvent);
  3160. if (startEvent.isDefaultPrevented()) {
  3161. return;
  3162. }
  3163. var dimension = this._getDimension();
  3164. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3165. Util.reflow(this._element);
  3166. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3167. var triggerArrayLength = this._triggerArray.length;
  3168. if (triggerArrayLength > 0) {
  3169. for (var i = 0; i < triggerArrayLength; i++) {
  3170. var trigger = this._triggerArray[i];
  3171. var selector = Util.getSelectorFromElement(trigger);
  3172. if (selector !== null) {
  3173. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3174. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3175. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3176. }
  3177. }
  3178. }
  3179. }
  3180. this.setTransitioning(true);
  3181. var complete = function complete() {
  3182. _this2.setTransitioning(false);
  3183. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3184. };
  3185. this._element.style[dimension] = '';
  3186. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3187. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3188. };
  3189. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3190. this._isTransitioning = isTransitioning;
  3191. };
  3192. _proto.dispose = function dispose() {
  3193. $.removeData(this._element, DATA_KEY$3);
  3194. this._config = null;
  3195. this._parent = null;
  3196. this._element = null;
  3197. this._triggerArray = null;
  3198. this._isTransitioning = null;
  3199. } // Private
  3200. ;
  3201. _proto._getConfig = function _getConfig(config) {
  3202. config = _objectSpread2({}, Default$1, {}, config);
  3203. config.toggle = Boolean(config.toggle); // Coerce string values
  3204. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3205. return config;
  3206. };
  3207. _proto._getDimension = function _getDimension() {
  3208. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3209. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3210. };
  3211. _proto._getParent = function _getParent() {
  3212. var _this3 = this;
  3213. var parent;
  3214. if (Util.isElement(this._config.parent)) {
  3215. parent = this._config.parent; // It's a jQuery object
  3216. if (typeof this._config.parent.jquery !== 'undefined') {
  3217. parent = this._config.parent[0];
  3218. }
  3219. } else {
  3220. parent = document.querySelector(this._config.parent);
  3221. }
  3222. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3223. var children = [].slice.call(parent.querySelectorAll(selector));
  3224. $(children).each(function (i, element) {
  3225. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3226. });
  3227. return parent;
  3228. };
  3229. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3230. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3231. if (triggerArray.length) {
  3232. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3233. }
  3234. } // Static
  3235. ;
  3236. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3237. var selector = Util.getSelectorFromElement(element);
  3238. return selector ? document.querySelector(selector) : null;
  3239. };
  3240. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3241. return this.each(function () {
  3242. var $this = $(this);
  3243. var data = $this.data(DATA_KEY$3);
  3244. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3245. if (!data && _config.toggle && /show|hide/.test(config)) {
  3246. _config.toggle = false;
  3247. }
  3248. if (!data) {
  3249. data = new Collapse(this, _config);
  3250. $this.data(DATA_KEY$3, data);
  3251. }
  3252. if (typeof config === 'string') {
  3253. if (typeof data[config] === 'undefined') {
  3254. throw new TypeError("No method named \"" + config + "\"");
  3255. }
  3256. data[config]();
  3257. }
  3258. });
  3259. };
  3260. _createClass(Collapse, null, [{
  3261. key: "VERSION",
  3262. get: function get() {
  3263. return VERSION$3;
  3264. }
  3265. }, {
  3266. key: "Default",
  3267. get: function get() {
  3268. return Default$1;
  3269. }
  3270. }]);
  3271. return Collapse;
  3272. }();
  3273. /**
  3274. * ------------------------------------------------------------------------
  3275. * Data Api implementation
  3276. * ------------------------------------------------------------------------
  3277. */
  3278. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3279. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3280. if (event.currentTarget.tagName === 'A') {
  3281. event.preventDefault();
  3282. }
  3283. var $trigger = $(this);
  3284. var selector = Util.getSelectorFromElement(this);
  3285. var selectors = [].slice.call(document.querySelectorAll(selector));
  3286. $(selectors).each(function () {
  3287. var $target = $(this);
  3288. var data = $target.data(DATA_KEY$3);
  3289. var config = data ? 'toggle' : $trigger.data();
  3290. Collapse._jQueryInterface.call($target, config);
  3291. });
  3292. });
  3293. /**
  3294. * ------------------------------------------------------------------------
  3295. * jQuery
  3296. * ------------------------------------------------------------------------
  3297. */
  3298. $.fn[NAME$3] = Collapse._jQueryInterface;
  3299. $.fn[NAME$3].Constructor = Collapse;
  3300. $.fn[NAME$3].noConflict = function () {
  3301. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3302. return Collapse._jQueryInterface;
  3303. };
  3304. /**
  3305. * ------------------------------------------------------------------------
  3306. * Constants
  3307. * ------------------------------------------------------------------------
  3308. */
  3309. var NAME$4 = 'dropdown';
  3310. var VERSION$4 = '4.4.1';
  3311. var DATA_KEY$4 = 'bs.dropdown';
  3312. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3313. var DATA_API_KEY$4 = '.data-api';
  3314. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3315. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3316. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3317. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3318. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3319. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3320. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3321. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3322. var Event$4 = {
  3323. HIDE: "hide" + EVENT_KEY$4,
  3324. HIDDEN: "hidden" + EVENT_KEY$4,
  3325. SHOW: "show" + EVENT_KEY$4,
  3326. SHOWN: "shown" + EVENT_KEY$4,
  3327. CLICK: "click" + EVENT_KEY$4,
  3328. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3329. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3330. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3331. };
  3332. var ClassName$4 = {
  3333. DISABLED: 'disabled',
  3334. SHOW: 'show',
  3335. DROPUP: 'dropup',
  3336. DROPRIGHT: 'dropright',
  3337. DROPLEFT: 'dropleft',
  3338. MENURIGHT: 'dropdown-menu-right',
  3339. MENULEFT: 'dropdown-menu-left',
  3340. POSITION_STATIC: 'position-static'
  3341. };
  3342. var Selector$4 = {
  3343. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3344. FORM_CHILD: '.dropdown form',
  3345. MENU: '.dropdown-menu',
  3346. NAVBAR_NAV: '.navbar-nav',
  3347. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3348. };
  3349. var AttachmentMap = {
  3350. TOP: 'top-start',
  3351. TOPEND: 'top-end',
  3352. BOTTOM: 'bottom-start',
  3353. BOTTOMEND: 'bottom-end',
  3354. RIGHT: 'right-start',
  3355. RIGHTEND: 'right-end',
  3356. LEFT: 'left-start',
  3357. LEFTEND: 'left-end'
  3358. };
  3359. var Default$2 = {
  3360. offset: 0,
  3361. flip: true,
  3362. boundary: 'scrollParent',
  3363. reference: 'toggle',
  3364. display: 'dynamic',
  3365. popperConfig: null
  3366. };
  3367. var DefaultType$2 = {
  3368. offset: '(number|string|function)',
  3369. flip: 'boolean',
  3370. boundary: '(string|element)',
  3371. reference: '(string|element)',
  3372. display: 'string',
  3373. popperConfig: '(null|object)'
  3374. };
  3375. /**
  3376. * ------------------------------------------------------------------------
  3377. * Class Definition
  3378. * ------------------------------------------------------------------------
  3379. */
  3380. var Dropdown =
  3381. /*#__PURE__*/
  3382. function () {
  3383. function Dropdown(element, config) {
  3384. this._element = element;
  3385. this._popper = null;
  3386. this._config = this._getConfig(config);
  3387. this._menu = this._getMenuElement();
  3388. this._inNavbar = this._detectNavbar();
  3389. this._addEventListeners();
  3390. } // Getters
  3391. var _proto = Dropdown.prototype;
  3392. // Public
  3393. _proto.toggle = function toggle() {
  3394. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3395. return;
  3396. }
  3397. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3398. Dropdown._clearMenus();
  3399. if (isActive) {
  3400. return;
  3401. }
  3402. this.show(true);
  3403. };
  3404. _proto.show = function show(usePopper) {
  3405. if (usePopper === void 0) {
  3406. usePopper = false;
  3407. }
  3408. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3409. return;
  3410. }
  3411. var relatedTarget = {
  3412. relatedTarget: this._element
  3413. };
  3414. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3415. var parent = Dropdown._getParentFromElement(this._element);
  3416. $(parent).trigger(showEvent);
  3417. if (showEvent.isDefaultPrevented()) {
  3418. return;
  3419. } // Disable totally Popper.js for Dropdown in Navbar
  3420. if (!this._inNavbar && usePopper) {
  3421. /**
  3422. * Check for Popper dependency
  3423. * Popper - https://popper.js.org
  3424. */
  3425. if (typeof Popper === 'undefined') {
  3426. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3427. }
  3428. var referenceElement = this._element;
  3429. if (this._config.reference === 'parent') {
  3430. referenceElement = parent;
  3431. } else if (Util.isElement(this._config.reference)) {
  3432. referenceElement = this._config.reference; // Check if it's jQuery element
  3433. if (typeof this._config.reference.jquery !== 'undefined') {
  3434. referenceElement = this._config.reference[0];
  3435. }
  3436. } // If boundary is not `scrollParent`, then set position to `static`
  3437. // to allow the menu to "escape" the scroll parent's boundaries
  3438. // https://github.com/twbs/bootstrap/issues/24251
  3439. if (this._config.boundary !== 'scrollParent') {
  3440. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3441. }
  3442. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3443. } // If this is a touch-enabled device we add extra
  3444. // empty mouseover listeners to the body's immediate children;
  3445. // only needed because of broken event delegation on iOS
  3446. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3447. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3448. $(document.body).children().on('mouseover', null, $.noop);
  3449. }
  3450. this._element.focus();
  3451. this._element.setAttribute('aria-expanded', true);
  3452. $(this._menu).toggleClass(ClassName$4.SHOW);
  3453. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3454. };
  3455. _proto.hide = function hide() {
  3456. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3457. return;
  3458. }
  3459. var relatedTarget = {
  3460. relatedTarget: this._element
  3461. };
  3462. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3463. var parent = Dropdown._getParentFromElement(this._element);
  3464. $(parent).trigger(hideEvent);
  3465. if (hideEvent.isDefaultPrevented()) {
  3466. return;
  3467. }
  3468. if (this._popper) {
  3469. this._popper.destroy();
  3470. }
  3471. $(this._menu).toggleClass(ClassName$4.SHOW);
  3472. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3473. };
  3474. _proto.dispose = function dispose() {
  3475. $.removeData(this._element, DATA_KEY$4);
  3476. $(this._element).off(EVENT_KEY$4);
  3477. this._element = null;
  3478. this._menu = null;
  3479. if (this._popper !== null) {
  3480. this._popper.destroy();
  3481. this._popper = null;
  3482. }
  3483. };
  3484. _proto.update = function update() {
  3485. this._inNavbar = this._detectNavbar();
  3486. if (this._popper !== null) {
  3487. this._popper.scheduleUpdate();
  3488. }
  3489. } // Private
  3490. ;
  3491. _proto._addEventListeners = function _addEventListeners() {
  3492. var _this = this;
  3493. $(this._element).on(Event$4.CLICK, function (event) {
  3494. event.preventDefault();
  3495. event.stopPropagation();
  3496. _this.toggle();
  3497. });
  3498. };
  3499. _proto._getConfig = function _getConfig(config) {
  3500. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3501. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3502. return config;
  3503. };
  3504. _proto._getMenuElement = function _getMenuElement() {
  3505. if (!this._menu) {
  3506. var parent = Dropdown._getParentFromElement(this._element);
  3507. if (parent) {
  3508. this._menu = parent.querySelector(Selector$4.MENU);
  3509. }
  3510. }
  3511. return this._menu;
  3512. };
  3513. _proto._getPlacement = function _getPlacement() {
  3514. var $parentDropdown = $(this._element.parentNode);
  3515. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3516. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3517. placement = AttachmentMap.TOP;
  3518. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3519. placement = AttachmentMap.TOPEND;
  3520. }
  3521. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3522. placement = AttachmentMap.RIGHT;
  3523. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3524. placement = AttachmentMap.LEFT;
  3525. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3526. placement = AttachmentMap.BOTTOMEND;
  3527. }
  3528. return placement;
  3529. };
  3530. _proto._detectNavbar = function _detectNavbar() {
  3531. return $(this._element).closest('.navbar').length > 0;
  3532. };
  3533. _proto._getOffset = function _getOffset() {
  3534. var _this2 = this;
  3535. var offset = {};
  3536. if (typeof this._config.offset === 'function') {
  3537. offset.fn = function (data) {
  3538. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3539. return data;
  3540. };
  3541. } else {
  3542. offset.offset = this._config.offset;
  3543. }
  3544. return offset;
  3545. };
  3546. _proto._getPopperConfig = function _getPopperConfig() {
  3547. var popperConfig = {
  3548. placement: this._getPlacement(),
  3549. modifiers: {
  3550. offset: this._getOffset(),
  3551. flip: {
  3552. enabled: this._config.flip
  3553. },
  3554. preventOverflow: {
  3555. boundariesElement: this._config.boundary
  3556. }
  3557. }
  3558. }; // Disable Popper.js if we have a static display
  3559. if (this._config.display === 'static') {
  3560. popperConfig.modifiers.applyStyle = {
  3561. enabled: false
  3562. };
  3563. }
  3564. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3565. } // Static
  3566. ;
  3567. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3568. return this.each(function () {
  3569. var data = $(this).data(DATA_KEY$4);
  3570. var _config = typeof config === 'object' ? config : null;
  3571. if (!data) {
  3572. data = new Dropdown(this, _config);
  3573. $(this).data(DATA_KEY$4, data);
  3574. }
  3575. if (typeof config === 'string') {
  3576. if (typeof data[config] === 'undefined') {
  3577. throw new TypeError("No method named \"" + config + "\"");
  3578. }
  3579. data[config]();
  3580. }
  3581. });
  3582. };
  3583. Dropdown._clearMenus = function _clearMenus(event) {
  3584. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3585. return;
  3586. }
  3587. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3588. for (var i = 0, len = toggles.length; i < len; i++) {
  3589. var parent = Dropdown._getParentFromElement(toggles[i]);
  3590. var context = $(toggles[i]).data(DATA_KEY$4);
  3591. var relatedTarget = {
  3592. relatedTarget: toggles[i]
  3593. };
  3594. if (event && event.type === 'click') {
  3595. relatedTarget.clickEvent = event;
  3596. }
  3597. if (!context) {
  3598. continue;
  3599. }
  3600. var dropdownMenu = context._menu;
  3601. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3602. continue;
  3603. }
  3604. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3605. continue;
  3606. }
  3607. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3608. $(parent).trigger(hideEvent);
  3609. if (hideEvent.isDefaultPrevented()) {
  3610. continue;
  3611. } // If this is a touch-enabled device we remove the extra
  3612. // empty mouseover listeners we added for iOS support
  3613. if ('ontouchstart' in document.documentElement) {
  3614. $(document.body).children().off('mouseover', null, $.noop);
  3615. }
  3616. toggles[i].setAttribute('aria-expanded', 'false');
  3617. if (context._popper) {
  3618. context._popper.destroy();
  3619. }
  3620. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3621. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3622. }
  3623. };
  3624. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3625. var parent;
  3626. var selector = Util.getSelectorFromElement(element);
  3627. if (selector) {
  3628. parent = document.querySelector(selector);
  3629. }
  3630. return parent || element.parentNode;
  3631. } // eslint-disable-next-line complexity
  3632. ;
  3633. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3634. // If not input/textarea:
  3635. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3636. // If input/textarea:
  3637. // - If space key => not a dropdown command
  3638. // - If key is other than escape
  3639. // - If key is not up or down => not a dropdown command
  3640. // - If trigger inside the menu => not a dropdown command
  3641. 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)) {
  3642. return;
  3643. }
  3644. event.preventDefault();
  3645. event.stopPropagation();
  3646. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3647. return;
  3648. }
  3649. var parent = Dropdown._getParentFromElement(this);
  3650. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3651. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3652. return;
  3653. }
  3654. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3655. if (event.which === ESCAPE_KEYCODE) {
  3656. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3657. $(toggle).trigger('focus');
  3658. }
  3659. $(this).trigger('click');
  3660. return;
  3661. }
  3662. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3663. return $(item).is(':visible');
  3664. });
  3665. if (items.length === 0) {
  3666. return;
  3667. }
  3668. var index = items.indexOf(event.target);
  3669. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3670. // Up
  3671. index--;
  3672. }
  3673. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3674. // Down
  3675. index++;
  3676. }
  3677. if (index < 0) {
  3678. index = 0;
  3679. }
  3680. items[index].focus();
  3681. };
  3682. _createClass(Dropdown, null, [{
  3683. key: "VERSION",
  3684. get: function get() {
  3685. return VERSION$4;
  3686. }
  3687. }, {
  3688. key: "Default",
  3689. get: function get() {
  3690. return Default$2;
  3691. }
  3692. }, {
  3693. key: "DefaultType",
  3694. get: function get() {
  3695. return DefaultType$2;
  3696. }
  3697. }]);
  3698. return Dropdown;
  3699. }();
  3700. /**
  3701. * ------------------------------------------------------------------------
  3702. * Data Api implementation
  3703. * ------------------------------------------------------------------------
  3704. */
  3705. $(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) {
  3706. event.preventDefault();
  3707. event.stopPropagation();
  3708. Dropdown._jQueryInterface.call($(this), 'toggle');
  3709. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3710. e.stopPropagation();
  3711. });
  3712. /**
  3713. * ------------------------------------------------------------------------
  3714. * jQuery
  3715. * ------------------------------------------------------------------------
  3716. */
  3717. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3718. $.fn[NAME$4].Constructor = Dropdown;
  3719. $.fn[NAME$4].noConflict = function () {
  3720. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3721. return Dropdown._jQueryInterface;
  3722. };
  3723. /**
  3724. * ------------------------------------------------------------------------
  3725. * Constants
  3726. * ------------------------------------------------------------------------
  3727. */
  3728. var NAME$5 = 'modal';
  3729. var VERSION$5 = '4.4.1';
  3730. var DATA_KEY$5 = 'bs.modal';
  3731. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3732. var DATA_API_KEY$5 = '.data-api';
  3733. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3734. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3735. var Default$3 = {
  3736. backdrop: true,
  3737. keyboard: true,
  3738. focus: true,
  3739. show: true
  3740. };
  3741. var DefaultType$3 = {
  3742. backdrop: '(boolean|string)',
  3743. keyboard: 'boolean',
  3744. focus: 'boolean',
  3745. show: 'boolean'
  3746. };
  3747. var Event$5 = {
  3748. HIDE: "hide" + EVENT_KEY$5,
  3749. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3750. HIDDEN: "hidden" + EVENT_KEY$5,
  3751. SHOW: "show" + EVENT_KEY$5,
  3752. SHOWN: "shown" + EVENT_KEY$5,
  3753. FOCUSIN: "focusin" + EVENT_KEY$5,
  3754. RESIZE: "resize" + EVENT_KEY$5,
  3755. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3756. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3757. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3758. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3759. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3760. };
  3761. var ClassName$5 = {
  3762. SCROLLABLE: 'modal-dialog-scrollable',
  3763. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3764. BACKDROP: 'modal-backdrop',
  3765. OPEN: 'modal-open',
  3766. FADE: 'fade',
  3767. SHOW: 'show',
  3768. STATIC: 'modal-static'
  3769. };
  3770. var Selector$5 = {
  3771. DIALOG: '.modal-dialog',
  3772. MODAL_BODY: '.modal-body',
  3773. DATA_TOGGLE: '[data-toggle="modal"]',
  3774. DATA_DISMISS: '[data-dismiss="modal"]',
  3775. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3776. STICKY_CONTENT: '.sticky-top'
  3777. };
  3778. /**
  3779. * ------------------------------------------------------------------------
  3780. * Class Definition
  3781. * ------------------------------------------------------------------------
  3782. */
  3783. var Modal =
  3784. /*#__PURE__*/
  3785. function () {
  3786. function Modal(element, config) {
  3787. this._config = this._getConfig(config);
  3788. this._element = element;
  3789. this._dialog = element.querySelector(Selector$5.DIALOG);
  3790. this._backdrop = null;
  3791. this._isShown = false;
  3792. this._isBodyOverflowing = false;
  3793. this._ignoreBackdropClick = false;
  3794. this._isTransitioning = false;
  3795. this._scrollbarWidth = 0;
  3796. } // Getters
  3797. var _proto = Modal.prototype;
  3798. // Public
  3799. _proto.toggle = function toggle(relatedTarget) {
  3800. return this._isShown ? this.hide() : this.show(relatedTarget);
  3801. };
  3802. _proto.show = function show(relatedTarget) {
  3803. var _this = this;
  3804. if (this._isShown || this._isTransitioning) {
  3805. return;
  3806. }
  3807. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3808. this._isTransitioning = true;
  3809. }
  3810. var showEvent = $.Event(Event$5.SHOW, {
  3811. relatedTarget: relatedTarget
  3812. });
  3813. $(this._element).trigger(showEvent);
  3814. if (this._isShown || showEvent.isDefaultPrevented()) {
  3815. return;
  3816. }
  3817. this._isShown = true;
  3818. this._checkScrollbar();
  3819. this._setScrollbar();
  3820. this._adjustDialog();
  3821. this._setEscapeEvent();
  3822. this._setResizeEvent();
  3823. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3824. return _this.hide(event);
  3825. });
  3826. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3827. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3828. if ($(event.target).is(_this._element)) {
  3829. _this._ignoreBackdropClick = true;
  3830. }
  3831. });
  3832. });
  3833. this._showBackdrop(function () {
  3834. return _this._showElement(relatedTarget);
  3835. });
  3836. };
  3837. _proto.hide = function hide(event) {
  3838. var _this2 = this;
  3839. if (event) {
  3840. event.preventDefault();
  3841. }
  3842. if (!this._isShown || this._isTransitioning) {
  3843. return;
  3844. }
  3845. var hideEvent = $.Event(Event$5.HIDE);
  3846. $(this._element).trigger(hideEvent);
  3847. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3848. return;
  3849. }
  3850. this._isShown = false;
  3851. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3852. if (transition) {
  3853. this._isTransitioning = true;
  3854. }
  3855. this._setEscapeEvent();
  3856. this._setResizeEvent();
  3857. $(document).off(Event$5.FOCUSIN);
  3858. $(this._element).removeClass(ClassName$5.SHOW);
  3859. $(this._element).off(Event$5.CLICK_DISMISS);
  3860. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3861. if (transition) {
  3862. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3863. $(this._element).one(Util.TRANSITION_END, function (event) {
  3864. return _this2._hideModal(event);
  3865. }).emulateTransitionEnd(transitionDuration);
  3866. } else {
  3867. this._hideModal();
  3868. }
  3869. };
  3870. _proto.dispose = function dispose() {
  3871. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3872. return $(htmlElement).off(EVENT_KEY$5);
  3873. });
  3874. /**
  3875. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3876. * Do not move `document` in `htmlElements` array
  3877. * It will remove `Event.CLICK_DATA_API` event that should remain
  3878. */
  3879. $(document).off(Event$5.FOCUSIN);
  3880. $.removeData(this._element, DATA_KEY$5);
  3881. this._config = null;
  3882. this._element = null;
  3883. this._dialog = null;
  3884. this._backdrop = null;
  3885. this._isShown = null;
  3886. this._isBodyOverflowing = null;
  3887. this._ignoreBackdropClick = null;
  3888. this._isTransitioning = null;
  3889. this._scrollbarWidth = null;
  3890. };
  3891. _proto.handleUpdate = function handleUpdate() {
  3892. this._adjustDialog();
  3893. } // Private
  3894. ;
  3895. _proto._getConfig = function _getConfig(config) {
  3896. config = _objectSpread2({}, Default$3, {}, config);
  3897. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3898. return config;
  3899. };
  3900. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3901. var _this3 = this;
  3902. if (this._config.backdrop === 'static') {
  3903. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3904. $(this._element).trigger(hideEventPrevented);
  3905. if (hideEventPrevented.defaultPrevented) {
  3906. return;
  3907. }
  3908. this._element.classList.add(ClassName$5.STATIC);
  3909. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3910. $(this._element).one(Util.TRANSITION_END, function () {
  3911. _this3._element.classList.remove(ClassName$5.STATIC);
  3912. }).emulateTransitionEnd(modalTransitionDuration);
  3913. this._element.focus();
  3914. } else {
  3915. this.hide();
  3916. }
  3917. };
  3918. _proto._showElement = function _showElement(relatedTarget) {
  3919. var _this4 = this;
  3920. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3921. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3922. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3923. // Don't move modal's DOM position
  3924. document.body.appendChild(this._element);
  3925. }
  3926. this._element.style.display = 'block';
  3927. this._element.removeAttribute('aria-hidden');
  3928. this._element.setAttribute('aria-modal', true);
  3929. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3930. modalBody.scrollTop = 0;
  3931. } else {
  3932. this._element.scrollTop = 0;
  3933. }
  3934. if (transition) {
  3935. Util.reflow(this._element);
  3936. }
  3937. $(this._element).addClass(ClassName$5.SHOW);
  3938. if (this._config.focus) {
  3939. this._enforceFocus();
  3940. }
  3941. var shownEvent = $.Event(Event$5.SHOWN, {
  3942. relatedTarget: relatedTarget
  3943. });
  3944. var transitionComplete = function transitionComplete() {
  3945. if (_this4._config.focus) {
  3946. _this4._element.focus();
  3947. }
  3948. _this4._isTransitioning = false;
  3949. $(_this4._element).trigger(shownEvent);
  3950. };
  3951. if (transition) {
  3952. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3953. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3954. } else {
  3955. transitionComplete();
  3956. }
  3957. };
  3958. _proto._enforceFocus = function _enforceFocus() {
  3959. var _this5 = this;
  3960. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3961. .on(Event$5.FOCUSIN, function (event) {
  3962. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3963. _this5._element.focus();
  3964. }
  3965. });
  3966. };
  3967. _proto._setEscapeEvent = function _setEscapeEvent() {
  3968. var _this6 = this;
  3969. if (this._isShown && this._config.keyboard) {
  3970. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3971. if (event.which === ESCAPE_KEYCODE$1) {
  3972. _this6._triggerBackdropTransition();
  3973. }
  3974. });
  3975. } else if (!this._isShown) {
  3976. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3977. }
  3978. };
  3979. _proto._setResizeEvent = function _setResizeEvent() {
  3980. var _this7 = this;
  3981. if (this._isShown) {
  3982. $(window).on(Event$5.RESIZE, function (event) {
  3983. return _this7.handleUpdate(event);
  3984. });
  3985. } else {
  3986. $(window).off(Event$5.RESIZE);
  3987. }
  3988. };
  3989. _proto._hideModal = function _hideModal() {
  3990. var _this8 = this;
  3991. this._element.style.display = 'none';
  3992. this._element.setAttribute('aria-hidden', true);
  3993. this._element.removeAttribute('aria-modal');
  3994. this._isTransitioning = false;
  3995. this._showBackdrop(function () {
  3996. $(document.body).removeClass(ClassName$5.OPEN);
  3997. _this8._resetAdjustments();
  3998. _this8._resetScrollbar();
  3999. $(_this8._element).trigger(Event$5.HIDDEN);
  4000. });
  4001. };
  4002. _proto._removeBackdrop = function _removeBackdrop() {
  4003. if (this._backdrop) {
  4004. $(this._backdrop).remove();
  4005. this._backdrop = null;
  4006. }
  4007. };
  4008. _proto._showBackdrop = function _showBackdrop(callback) {
  4009. var _this9 = this;
  4010. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  4011. if (this._isShown && this._config.backdrop) {
  4012. this._backdrop = document.createElement('div');
  4013. this._backdrop.className = ClassName$5.BACKDROP;
  4014. if (animate) {
  4015. this._backdrop.classList.add(animate);
  4016. }
  4017. $(this._backdrop).appendTo(document.body);
  4018. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  4019. if (_this9._ignoreBackdropClick) {
  4020. _this9._ignoreBackdropClick = false;
  4021. return;
  4022. }
  4023. if (event.target !== event.currentTarget) {
  4024. return;
  4025. }
  4026. _this9._triggerBackdropTransition();
  4027. });
  4028. if (animate) {
  4029. Util.reflow(this._backdrop);
  4030. }
  4031. $(this._backdrop).addClass(ClassName$5.SHOW);
  4032. if (!callback) {
  4033. return;
  4034. }
  4035. if (!animate) {
  4036. callback();
  4037. return;
  4038. }
  4039. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  4040. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  4041. } else if (!this._isShown && this._backdrop) {
  4042. $(this._backdrop).removeClass(ClassName$5.SHOW);
  4043. var callbackRemove = function callbackRemove() {
  4044. _this9._removeBackdrop();
  4045. if (callback) {
  4046. callback();
  4047. }
  4048. };
  4049. if ($(this._element).hasClass(ClassName$5.FADE)) {
  4050. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  4051. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  4052. } else {
  4053. callbackRemove();
  4054. }
  4055. } else if (callback) {
  4056. callback();
  4057. }
  4058. } // ----------------------------------------------------------------------
  4059. // the following methods are used to handle overflowing modals
  4060. // todo (fat): these should probably be refactored out of modal.js
  4061. // ----------------------------------------------------------------------
  4062. ;
  4063. _proto._adjustDialog = function _adjustDialog() {
  4064. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4065. if (!this._isBodyOverflowing && isModalOverflowing) {
  4066. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  4067. }
  4068. if (this._isBodyOverflowing && !isModalOverflowing) {
  4069. this._element.style.paddingRight = this._scrollbarWidth + "px";
  4070. }
  4071. };
  4072. _proto._resetAdjustments = function _resetAdjustments() {
  4073. this._element.style.paddingLeft = '';
  4074. this._element.style.paddingRight = '';
  4075. };
  4076. _proto._checkScrollbar = function _checkScrollbar() {
  4077. var rect = document.body.getBoundingClientRect();
  4078. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  4079. this._scrollbarWidth = this._getScrollbarWidth();
  4080. };
  4081. _proto._setScrollbar = function _setScrollbar() {
  4082. var _this10 = this;
  4083. if (this._isBodyOverflowing) {
  4084. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  4085. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  4086. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4087. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  4088. $(fixedContent).each(function (index, element) {
  4089. var actualPadding = element.style.paddingRight;
  4090. var calculatedPadding = $(element).css('padding-right');
  4091. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  4092. }); // Adjust sticky content margin
  4093. $(stickyContent).each(function (index, element) {
  4094. var actualMargin = element.style.marginRight;
  4095. var calculatedMargin = $(element).css('margin-right');
  4096. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  4097. }); // Adjust body padding
  4098. var actualPadding = document.body.style.paddingRight;
  4099. var calculatedPadding = $(document.body).css('padding-right');
  4100. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  4101. }
  4102. $(document.body).addClass(ClassName$5.OPEN);
  4103. };
  4104. _proto._resetScrollbar = function _resetScrollbar() {
  4105. // Restore fixed content padding
  4106. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4107. $(fixedContent).each(function (index, element) {
  4108. var padding = $(element).data('padding-right');
  4109. $(element).removeData('padding-right');
  4110. element.style.paddingRight = padding ? padding : '';
  4111. }); // Restore sticky content
  4112. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  4113. $(elements).each(function (index, element) {
  4114. var margin = $(element).data('margin-right');
  4115. if (typeof margin !== 'undefined') {
  4116. $(element).css('margin-right', margin).removeData('margin-right');
  4117. }
  4118. }); // Restore body padding
  4119. var padding = $(document.body).data('padding-right');
  4120. $(document.body).removeData('padding-right');
  4121. document.body.style.paddingRight = padding ? padding : '';
  4122. };
  4123. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4124. // thx d.walsh
  4125. var scrollDiv = document.createElement('div');
  4126. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  4127. document.body.appendChild(scrollDiv);
  4128. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4129. document.body.removeChild(scrollDiv);
  4130. return scrollbarWidth;
  4131. } // Static
  4132. ;
  4133. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4134. return this.each(function () {
  4135. var data = $(this).data(DATA_KEY$5);
  4136. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  4137. if (!data) {
  4138. data = new Modal(this, _config);
  4139. $(this).data(DATA_KEY$5, data);
  4140. }
  4141. if (typeof config === 'string') {
  4142. if (typeof data[config] === 'undefined') {
  4143. throw new TypeError("No method named \"" + config + "\"");
  4144. }
  4145. data[config](relatedTarget);
  4146. } else if (_config.show) {
  4147. data.show(relatedTarget);
  4148. }
  4149. });
  4150. };
  4151. _createClass(Modal, null, [{
  4152. key: "VERSION",
  4153. get: function get() {
  4154. return VERSION$5;
  4155. }
  4156. }, {
  4157. key: "Default",
  4158. get: function get() {
  4159. return Default$3;
  4160. }
  4161. }]);
  4162. return Modal;
  4163. }();
  4164. /**
  4165. * ------------------------------------------------------------------------
  4166. * Data Api implementation
  4167. * ------------------------------------------------------------------------
  4168. */
  4169. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4170. var _this11 = this;
  4171. var target;
  4172. var selector = Util.getSelectorFromElement(this);
  4173. if (selector) {
  4174. target = document.querySelector(selector);
  4175. }
  4176. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4177. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4178. event.preventDefault();
  4179. }
  4180. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4181. if (showEvent.isDefaultPrevented()) {
  4182. // Only register focus restorer if modal will actually get shown
  4183. return;
  4184. }
  4185. $target.one(Event$5.HIDDEN, function () {
  4186. if ($(_this11).is(':visible')) {
  4187. _this11.focus();
  4188. }
  4189. });
  4190. });
  4191. Modal._jQueryInterface.call($(target), config, this);
  4192. });
  4193. /**
  4194. * ------------------------------------------------------------------------
  4195. * jQuery
  4196. * ------------------------------------------------------------------------
  4197. */
  4198. $.fn[NAME$5] = Modal._jQueryInterface;
  4199. $.fn[NAME$5].Constructor = Modal;
  4200. $.fn[NAME$5].noConflict = function () {
  4201. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4202. return Modal._jQueryInterface;
  4203. };
  4204. /**
  4205. * --------------------------------------------------------------------------
  4206. * Bootstrap (v4.4.1): tools/sanitizer.js
  4207. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4208. * --------------------------------------------------------------------------
  4209. */
  4210. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4211. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4212. var DefaultWhitelist = {
  4213. // Global attributes allowed on any supplied element below.
  4214. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4215. a: ['target', 'href', 'title', 'rel'],
  4216. area: [],
  4217. b: [],
  4218. br: [],
  4219. col: [],
  4220. code: [],
  4221. div: [],
  4222. em: [],
  4223. hr: [],
  4224. h1: [],
  4225. h2: [],
  4226. h3: [],
  4227. h4: [],
  4228. h5: [],
  4229. h6: [],
  4230. i: [],
  4231. img: ['src', 'alt', 'title', 'width', 'height'],
  4232. li: [],
  4233. ol: [],
  4234. p: [],
  4235. pre: [],
  4236. s: [],
  4237. small: [],
  4238. span: [],
  4239. sub: [],
  4240. sup: [],
  4241. strong: [],
  4242. u: [],
  4243. ul: []
  4244. };
  4245. /**
  4246. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4247. *
  4248. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4249. */
  4250. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4251. /**
  4252. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4253. *
  4254. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4255. */
  4256. 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;
  4257. function allowedAttribute(attr, allowedAttributeList) {
  4258. var attrName = attr.nodeName.toLowerCase();
  4259. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4260. if (uriAttrs.indexOf(attrName) !== -1) {
  4261. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4262. }
  4263. return true;
  4264. }
  4265. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4266. return attrRegex instanceof RegExp;
  4267. }); // Check if a regular expression validates the attribute.
  4268. for (var i = 0, l = regExp.length; i < l; i++) {
  4269. if (attrName.match(regExp[i])) {
  4270. return true;
  4271. }
  4272. }
  4273. return false;
  4274. }
  4275. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4276. if (unsafeHtml.length === 0) {
  4277. return unsafeHtml;
  4278. }
  4279. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4280. return sanitizeFn(unsafeHtml);
  4281. }
  4282. var domParser = new window.DOMParser();
  4283. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4284. var whitelistKeys = Object.keys(whiteList);
  4285. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4286. var _loop = function _loop(i, len) {
  4287. var el = elements[i];
  4288. var elName = el.nodeName.toLowerCase();
  4289. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4290. el.parentNode.removeChild(el);
  4291. return "continue";
  4292. }
  4293. var attributeList = [].slice.call(el.attributes);
  4294. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4295. attributeList.forEach(function (attr) {
  4296. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4297. el.removeAttribute(attr.nodeName);
  4298. }
  4299. });
  4300. };
  4301. for (var i = 0, len = elements.length; i < len; i++) {
  4302. var _ret = _loop(i);
  4303. if (_ret === "continue") continue;
  4304. }
  4305. return createdDocument.body.innerHTML;
  4306. }
  4307. /**
  4308. * ------------------------------------------------------------------------
  4309. * Constants
  4310. * ------------------------------------------------------------------------
  4311. */
  4312. var NAME$6 = 'tooltip';
  4313. var VERSION$6 = '4.4.1';
  4314. var DATA_KEY$6 = 'bs.tooltip';
  4315. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4316. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4317. var CLASS_PREFIX = 'bs-tooltip';
  4318. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4319. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4320. var DefaultType$4 = {
  4321. animation: 'boolean',
  4322. template: 'string',
  4323. title: '(string|element|function)',
  4324. trigger: 'string',
  4325. delay: '(number|object)',
  4326. html: 'boolean',
  4327. selector: '(string|boolean)',
  4328. placement: '(string|function)',
  4329. offset: '(number|string|function)',
  4330. container: '(string|element|boolean)',
  4331. fallbackPlacement: '(string|array)',
  4332. boundary: '(string|element)',
  4333. sanitize: 'boolean',
  4334. sanitizeFn: '(null|function)',
  4335. whiteList: 'object',
  4336. popperConfig: '(null|object)'
  4337. };
  4338. var AttachmentMap$1 = {
  4339. AUTO: 'auto',
  4340. TOP: 'top',
  4341. RIGHT: 'right',
  4342. BOTTOM: 'bottom',
  4343. LEFT: 'left'
  4344. };
  4345. var Default$4 = {
  4346. animation: true,
  4347. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4348. trigger: 'hover focus',
  4349. title: '',
  4350. delay: 0,
  4351. html: false,
  4352. selector: false,
  4353. placement: 'top',
  4354. offset: 0,
  4355. container: false,
  4356. fallbackPlacement: 'flip',
  4357. boundary: 'scrollParent',
  4358. sanitize: true,
  4359. sanitizeFn: null,
  4360. whiteList: DefaultWhitelist,
  4361. popperConfig: null
  4362. };
  4363. var HoverState = {
  4364. SHOW: 'show',
  4365. OUT: 'out'
  4366. };
  4367. var Event$6 = {
  4368. HIDE: "hide" + EVENT_KEY$6,
  4369. HIDDEN: "hidden" + EVENT_KEY$6,
  4370. SHOW: "show" + EVENT_KEY$6,
  4371. SHOWN: "shown" + EVENT_KEY$6,
  4372. INSERTED: "inserted" + EVENT_KEY$6,
  4373. CLICK: "click" + EVENT_KEY$6,
  4374. FOCUSIN: "focusin" + EVENT_KEY$6,
  4375. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4376. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4377. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4378. };
  4379. var ClassName$6 = {
  4380. FADE: 'fade',
  4381. SHOW: 'show'
  4382. };
  4383. var Selector$6 = {
  4384. TOOLTIP: '.tooltip',
  4385. TOOLTIP_INNER: '.tooltip-inner',
  4386. ARROW: '.arrow'
  4387. };
  4388. var Trigger = {
  4389. HOVER: 'hover',
  4390. FOCUS: 'focus',
  4391. CLICK: 'click',
  4392. MANUAL: 'manual'
  4393. };
  4394. /**
  4395. * ------------------------------------------------------------------------
  4396. * Class Definition
  4397. * ------------------------------------------------------------------------
  4398. */
  4399. var Tooltip =
  4400. /*#__PURE__*/
  4401. function () {
  4402. function Tooltip(element, config) {
  4403. if (typeof Popper === 'undefined') {
  4404. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4405. } // private
  4406. this._isEnabled = true;
  4407. this._timeout = 0;
  4408. this._hoverState = '';
  4409. this._activeTrigger = {};
  4410. this._popper = null; // Protected
  4411. this.element = element;
  4412. this.config = this._getConfig(config);
  4413. this.tip = null;
  4414. this._setListeners();
  4415. } // Getters
  4416. var _proto = Tooltip.prototype;
  4417. // Public
  4418. _proto.enable = function enable() {
  4419. this._isEnabled = true;
  4420. };
  4421. _proto.disable = function disable() {
  4422. this._isEnabled = false;
  4423. };
  4424. _proto.toggleEnabled = function toggleEnabled() {
  4425. this._isEnabled = !this._isEnabled;
  4426. };
  4427. _proto.toggle = function toggle(event) {
  4428. if (!this._isEnabled) {
  4429. return;
  4430. }
  4431. if (event) {
  4432. var dataKey = this.constructor.DATA_KEY;
  4433. var context = $(event.currentTarget).data(dataKey);
  4434. if (!context) {
  4435. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4436. $(event.currentTarget).data(dataKey, context);
  4437. }
  4438. context._activeTrigger.click = !context._activeTrigger.click;
  4439. if (context._isWithActiveTrigger()) {
  4440. context._enter(null, context);
  4441. } else {
  4442. context._leave(null, context);
  4443. }
  4444. } else {
  4445. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4446. this._leave(null, this);
  4447. return;
  4448. }
  4449. this._enter(null, this);
  4450. }
  4451. };
  4452. _proto.dispose = function dispose() {
  4453. clearTimeout(this._timeout);
  4454. $.removeData(this.element, this.constructor.DATA_KEY);
  4455. $(this.element).off(this.constructor.EVENT_KEY);
  4456. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4457. if (this.tip) {
  4458. $(this.tip).remove();
  4459. }
  4460. this._isEnabled = null;
  4461. this._timeout = null;
  4462. this._hoverState = null;
  4463. this._activeTrigger = null;
  4464. if (this._popper) {
  4465. this._popper.destroy();
  4466. }
  4467. this._popper = null;
  4468. this.element = null;
  4469. this.config = null;
  4470. this.tip = null;
  4471. };
  4472. _proto.show = function show() {
  4473. var _this = this;
  4474. if ($(this.element).css('display') === 'none') {
  4475. throw new Error('Please use show on visible elements');
  4476. }
  4477. var showEvent = $.Event(this.constructor.Event.SHOW);
  4478. if (this.isWithContent() && this._isEnabled) {
  4479. $(this.element).trigger(showEvent);
  4480. var shadowRoot = Util.findShadowRoot(this.element);
  4481. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4482. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4483. return;
  4484. }
  4485. var tip = this.getTipElement();
  4486. var tipId = Util.getUID(this.constructor.NAME);
  4487. tip.setAttribute('id', tipId);
  4488. this.element.setAttribute('aria-describedby', tipId);
  4489. this.setContent();
  4490. if (this.config.animation) {
  4491. $(tip).addClass(ClassName$6.FADE);
  4492. }
  4493. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4494. var attachment = this._getAttachment(placement);
  4495. this.addAttachmentClass(attachment);
  4496. var container = this._getContainer();
  4497. $(tip).data(this.constructor.DATA_KEY, this);
  4498. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4499. $(tip).appendTo(container);
  4500. }
  4501. $(this.element).trigger(this.constructor.Event.INSERTED);
  4502. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4503. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4504. // empty mouseover listeners to the body's immediate children;
  4505. // only needed because of broken event delegation on iOS
  4506. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4507. if ('ontouchstart' in document.documentElement) {
  4508. $(document.body).children().on('mouseover', null, $.noop);
  4509. }
  4510. var complete = function complete() {
  4511. if (_this.config.animation) {
  4512. _this._fixTransition();
  4513. }
  4514. var prevHoverState = _this._hoverState;
  4515. _this._hoverState = null;
  4516. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4517. if (prevHoverState === HoverState.OUT) {
  4518. _this._leave(null, _this);
  4519. }
  4520. };
  4521. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4522. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4523. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4524. } else {
  4525. complete();
  4526. }
  4527. }
  4528. };
  4529. _proto.hide = function hide(callback) {
  4530. var _this2 = this;
  4531. var tip = this.getTipElement();
  4532. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4533. var complete = function complete() {
  4534. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4535. tip.parentNode.removeChild(tip);
  4536. }
  4537. _this2._cleanTipClass();
  4538. _this2.element.removeAttribute('aria-describedby');
  4539. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4540. if (_this2._popper !== null) {
  4541. _this2._popper.destroy();
  4542. }
  4543. if (callback) {
  4544. callback();
  4545. }
  4546. };
  4547. $(this.element).trigger(hideEvent);
  4548. if (hideEvent.isDefaultPrevented()) {
  4549. return;
  4550. }
  4551. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4552. // empty mouseover listeners we added for iOS support
  4553. if ('ontouchstart' in document.documentElement) {
  4554. $(document.body).children().off('mouseover', null, $.noop);
  4555. }
  4556. this._activeTrigger[Trigger.CLICK] = false;
  4557. this._activeTrigger[Trigger.FOCUS] = false;
  4558. this._activeTrigger[Trigger.HOVER] = false;
  4559. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4560. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4561. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4562. } else {
  4563. complete();
  4564. }
  4565. this._hoverState = '';
  4566. };
  4567. _proto.update = function update() {
  4568. if (this._popper !== null) {
  4569. this._popper.scheduleUpdate();
  4570. }
  4571. } // Protected
  4572. ;
  4573. _proto.isWithContent = function isWithContent() {
  4574. return Boolean(this.getTitle());
  4575. };
  4576. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4577. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4578. };
  4579. _proto.getTipElement = function getTipElement() {
  4580. this.tip = this.tip || $(this.config.template)[0];
  4581. return this.tip;
  4582. };
  4583. _proto.setContent = function setContent() {
  4584. var tip = this.getTipElement();
  4585. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4586. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4587. };
  4588. _proto.setElementContent = function setElementContent($element, content) {
  4589. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4590. // Content is a DOM node or a jQuery
  4591. if (this.config.html) {
  4592. if (!$(content).parent().is($element)) {
  4593. $element.empty().append(content);
  4594. }
  4595. } else {
  4596. $element.text($(content).text());
  4597. }
  4598. return;
  4599. }
  4600. if (this.config.html) {
  4601. if (this.config.sanitize) {
  4602. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4603. }
  4604. $element.html(content);
  4605. } else {
  4606. $element.text(content);
  4607. }
  4608. };
  4609. _proto.getTitle = function getTitle() {
  4610. var title = this.element.getAttribute('data-original-title');
  4611. if (!title) {
  4612. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4613. }
  4614. return title;
  4615. } // Private
  4616. ;
  4617. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4618. var _this3 = this;
  4619. var defaultBsConfig = {
  4620. placement: attachment,
  4621. modifiers: {
  4622. offset: this._getOffset(),
  4623. flip: {
  4624. behavior: this.config.fallbackPlacement
  4625. },
  4626. arrow: {
  4627. element: Selector$6.ARROW
  4628. },
  4629. preventOverflow: {
  4630. boundariesElement: this.config.boundary
  4631. }
  4632. },
  4633. onCreate: function onCreate(data) {
  4634. if (data.originalPlacement !== data.placement) {
  4635. _this3._handlePopperPlacementChange(data);
  4636. }
  4637. },
  4638. onUpdate: function onUpdate(data) {
  4639. return _this3._handlePopperPlacementChange(data);
  4640. }
  4641. };
  4642. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4643. };
  4644. _proto._getOffset = function _getOffset() {
  4645. var _this4 = this;
  4646. var offset = {};
  4647. if (typeof this.config.offset === 'function') {
  4648. offset.fn = function (data) {
  4649. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4650. return data;
  4651. };
  4652. } else {
  4653. offset.offset = this.config.offset;
  4654. }
  4655. return offset;
  4656. };
  4657. _proto._getContainer = function _getContainer() {
  4658. if (this.config.container === false) {
  4659. return document.body;
  4660. }
  4661. if (Util.isElement(this.config.container)) {
  4662. return $(this.config.container);
  4663. }
  4664. return $(document).find(this.config.container);
  4665. };
  4666. _proto._getAttachment = function _getAttachment(placement) {
  4667. return AttachmentMap$1[placement.toUpperCase()];
  4668. };
  4669. _proto._setListeners = function _setListeners() {
  4670. var _this5 = this;
  4671. var triggers = this.config.trigger.split(' ');
  4672. triggers.forEach(function (trigger) {
  4673. if (trigger === 'click') {
  4674. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4675. return _this5.toggle(event);
  4676. });
  4677. } else if (trigger !== Trigger.MANUAL) {
  4678. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4679. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4680. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4681. return _this5._enter(event);
  4682. }).on(eventOut, _this5.config.selector, function (event) {
  4683. return _this5._leave(event);
  4684. });
  4685. }
  4686. });
  4687. this._hideModalHandler = function () {
  4688. if (_this5.element) {
  4689. _this5.hide();
  4690. }
  4691. };
  4692. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4693. if (this.config.selector) {
  4694. this.config = _objectSpread2({}, this.config, {
  4695. trigger: 'manual',
  4696. selector: ''
  4697. });
  4698. } else {
  4699. this._fixTitle();
  4700. }
  4701. };
  4702. _proto._fixTitle = function _fixTitle() {
  4703. var titleType = typeof this.element.getAttribute('data-original-title');
  4704. if (this.element.getAttribute('title') || titleType !== 'string') {
  4705. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4706. this.element.setAttribute('title', '');
  4707. }
  4708. };
  4709. _proto._enter = function _enter(event, context) {
  4710. var dataKey = this.constructor.DATA_KEY;
  4711. context = context || $(event.currentTarget).data(dataKey);
  4712. if (!context) {
  4713. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4714. $(event.currentTarget).data(dataKey, context);
  4715. }
  4716. if (event) {
  4717. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4718. }
  4719. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4720. context._hoverState = HoverState.SHOW;
  4721. return;
  4722. }
  4723. clearTimeout(context._timeout);
  4724. context._hoverState = HoverState.SHOW;
  4725. if (!context.config.delay || !context.config.delay.show) {
  4726. context.show();
  4727. return;
  4728. }
  4729. context._timeout = setTimeout(function () {
  4730. if (context._hoverState === HoverState.SHOW) {
  4731. context.show();
  4732. }
  4733. }, context.config.delay.show);
  4734. };
  4735. _proto._leave = function _leave(event, context) {
  4736. var dataKey = this.constructor.DATA_KEY;
  4737. context = context || $(event.currentTarget).data(dataKey);
  4738. if (!context) {
  4739. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4740. $(event.currentTarget).data(dataKey, context);
  4741. }
  4742. if (event) {
  4743. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4744. }
  4745. if (context._isWithActiveTrigger()) {
  4746. return;
  4747. }
  4748. clearTimeout(context._timeout);
  4749. context._hoverState = HoverState.OUT;
  4750. if (!context.config.delay || !context.config.delay.hide) {
  4751. context.hide();
  4752. return;
  4753. }
  4754. context._timeout = setTimeout(function () {
  4755. if (context._hoverState === HoverState.OUT) {
  4756. context.hide();
  4757. }
  4758. }, context.config.delay.hide);
  4759. };
  4760. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4761. for (var trigger in this._activeTrigger) {
  4762. if (this._activeTrigger[trigger]) {
  4763. return true;
  4764. }
  4765. }
  4766. return false;
  4767. };
  4768. _proto._getConfig = function _getConfig(config) {
  4769. var dataAttributes = $(this.element).data();
  4770. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4771. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4772. delete dataAttributes[dataAttr];
  4773. }
  4774. });
  4775. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4776. if (typeof config.delay === 'number') {
  4777. config.delay = {
  4778. show: config.delay,
  4779. hide: config.delay
  4780. };
  4781. }
  4782. if (typeof config.title === 'number') {
  4783. config.title = config.title.toString();
  4784. }
  4785. if (typeof config.content === 'number') {
  4786. config.content = config.content.toString();
  4787. }
  4788. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4789. if (config.sanitize) {
  4790. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4791. }
  4792. return config;
  4793. };
  4794. _proto._getDelegateConfig = function _getDelegateConfig() {
  4795. var config = {};
  4796. if (this.config) {
  4797. for (var key in this.config) {
  4798. if (this.constructor.Default[key] !== this.config[key]) {
  4799. config[key] = this.config[key];
  4800. }
  4801. }
  4802. }
  4803. return config;
  4804. };
  4805. _proto._cleanTipClass = function _cleanTipClass() {
  4806. var $tip = $(this.getTipElement());
  4807. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4808. if (tabClass !== null && tabClass.length) {
  4809. $tip.removeClass(tabClass.join(''));
  4810. }
  4811. };
  4812. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4813. var popperInstance = popperData.instance;
  4814. this.tip = popperInstance.popper;
  4815. this._cleanTipClass();
  4816. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4817. };
  4818. _proto._fixTransition = function _fixTransition() {
  4819. var tip = this.getTipElement();
  4820. var initConfigAnimation = this.config.animation;
  4821. if (tip.getAttribute('x-placement') !== null) {
  4822. return;
  4823. }
  4824. $(tip).removeClass(ClassName$6.FADE);
  4825. this.config.animation = false;
  4826. this.hide();
  4827. this.show();
  4828. this.config.animation = initConfigAnimation;
  4829. } // Static
  4830. ;
  4831. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4832. return this.each(function () {
  4833. var data = $(this).data(DATA_KEY$6);
  4834. var _config = typeof config === 'object' && config;
  4835. if (!data && /dispose|hide/.test(config)) {
  4836. return;
  4837. }
  4838. if (!data) {
  4839. data = new Tooltip(this, _config);
  4840. $(this).data(DATA_KEY$6, data);
  4841. }
  4842. if (typeof config === 'string') {
  4843. if (typeof data[config] === 'undefined') {
  4844. throw new TypeError("No method named \"" + config + "\"");
  4845. }
  4846. data[config]();
  4847. }
  4848. });
  4849. };
  4850. _createClass(Tooltip, null, [{
  4851. key: "VERSION",
  4852. get: function get() {
  4853. return VERSION$6;
  4854. }
  4855. }, {
  4856. key: "Default",
  4857. get: function get() {
  4858. return Default$4;
  4859. }
  4860. }, {
  4861. key: "NAME",
  4862. get: function get() {
  4863. return NAME$6;
  4864. }
  4865. }, {
  4866. key: "DATA_KEY",
  4867. get: function get() {
  4868. return DATA_KEY$6;
  4869. }
  4870. }, {
  4871. key: "Event",
  4872. get: function get() {
  4873. return Event$6;
  4874. }
  4875. }, {
  4876. key: "EVENT_KEY",
  4877. get: function get() {
  4878. return EVENT_KEY$6;
  4879. }
  4880. }, {
  4881. key: "DefaultType",
  4882. get: function get() {
  4883. return DefaultType$4;
  4884. }
  4885. }]);
  4886. return Tooltip;
  4887. }();
  4888. /**
  4889. * ------------------------------------------------------------------------
  4890. * jQuery
  4891. * ------------------------------------------------------------------------
  4892. */
  4893. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4894. $.fn[NAME$6].Constructor = Tooltip;
  4895. $.fn[NAME$6].noConflict = function () {
  4896. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4897. return Tooltip._jQueryInterface;
  4898. };
  4899. /**
  4900. * ------------------------------------------------------------------------
  4901. * Constants
  4902. * ------------------------------------------------------------------------
  4903. */
  4904. var NAME$7 = 'popover';
  4905. var VERSION$7 = '4.4.1';
  4906. var DATA_KEY$7 = 'bs.popover';
  4907. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4908. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4909. var CLASS_PREFIX$1 = 'bs-popover';
  4910. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4911. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4912. placement: 'right',
  4913. trigger: 'click',
  4914. content: '',
  4915. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4916. });
  4917. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4918. content: '(string|element|function)'
  4919. });
  4920. var ClassName$7 = {
  4921. FADE: 'fade',
  4922. SHOW: 'show'
  4923. };
  4924. var Selector$7 = {
  4925. TITLE: '.popover-header',
  4926. CONTENT: '.popover-body'
  4927. };
  4928. var Event$7 = {
  4929. HIDE: "hide" + EVENT_KEY$7,
  4930. HIDDEN: "hidden" + EVENT_KEY$7,
  4931. SHOW: "show" + EVENT_KEY$7,
  4932. SHOWN: "shown" + EVENT_KEY$7,
  4933. INSERTED: "inserted" + EVENT_KEY$7,
  4934. CLICK: "click" + EVENT_KEY$7,
  4935. FOCUSIN: "focusin" + EVENT_KEY$7,
  4936. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4937. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4938. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4939. };
  4940. /**
  4941. * ------------------------------------------------------------------------
  4942. * Class Definition
  4943. * ------------------------------------------------------------------------
  4944. */
  4945. var Popover =
  4946. /*#__PURE__*/
  4947. function (_Tooltip) {
  4948. _inheritsLoose(Popover, _Tooltip);
  4949. function Popover() {
  4950. return _Tooltip.apply(this, arguments) || this;
  4951. }
  4952. var _proto = Popover.prototype;
  4953. // Overrides
  4954. _proto.isWithContent = function isWithContent() {
  4955. return this.getTitle() || this._getContent();
  4956. };
  4957. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4958. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4959. };
  4960. _proto.getTipElement = function getTipElement() {
  4961. this.tip = this.tip || $(this.config.template)[0];
  4962. return this.tip;
  4963. };
  4964. _proto.setContent = function setContent() {
  4965. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4966. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4967. var content = this._getContent();
  4968. if (typeof content === 'function') {
  4969. content = content.call(this.element);
  4970. }
  4971. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4972. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4973. } // Private
  4974. ;
  4975. _proto._getContent = function _getContent() {
  4976. return this.element.getAttribute('data-content') || this.config.content;
  4977. };
  4978. _proto._cleanTipClass = function _cleanTipClass() {
  4979. var $tip = $(this.getTipElement());
  4980. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4981. if (tabClass !== null && tabClass.length > 0) {
  4982. $tip.removeClass(tabClass.join(''));
  4983. }
  4984. } // Static
  4985. ;
  4986. Popover._jQueryInterface = function _jQueryInterface(config) {
  4987. return this.each(function () {
  4988. var data = $(this).data(DATA_KEY$7);
  4989. var _config = typeof config === 'object' ? config : null;
  4990. if (!data && /dispose|hide/.test(config)) {
  4991. return;
  4992. }
  4993. if (!data) {
  4994. data = new Popover(this, _config);
  4995. $(this).data(DATA_KEY$7, data);
  4996. }
  4997. if (typeof config === 'string') {
  4998. if (typeof data[config] === 'undefined') {
  4999. throw new TypeError("No method named \"" + config + "\"");
  5000. }
  5001. data[config]();
  5002. }
  5003. });
  5004. };
  5005. _createClass(Popover, null, [{
  5006. key: "VERSION",
  5007. // Getters
  5008. get: function get() {
  5009. return VERSION$7;
  5010. }
  5011. }, {
  5012. key: "Default",
  5013. get: function get() {
  5014. return Default$5;
  5015. }
  5016. }, {
  5017. key: "NAME",
  5018. get: function get() {
  5019. return NAME$7;
  5020. }
  5021. }, {
  5022. key: "DATA_KEY",
  5023. get: function get() {
  5024. return DATA_KEY$7;
  5025. }
  5026. }, {
  5027. key: "Event",
  5028. get: function get() {
  5029. return Event$7;
  5030. }
  5031. }, {
  5032. key: "EVENT_KEY",
  5033. get: function get() {
  5034. return EVENT_KEY$7;
  5035. }
  5036. }, {
  5037. key: "DefaultType",
  5038. get: function get() {
  5039. return DefaultType$5;
  5040. }
  5041. }]);
  5042. return Popover;
  5043. }(Tooltip);
  5044. /**
  5045. * ------------------------------------------------------------------------
  5046. * jQuery
  5047. * ------------------------------------------------------------------------
  5048. */
  5049. $.fn[NAME$7] = Popover._jQueryInterface;
  5050. $.fn[NAME$7].Constructor = Popover;
  5051. $.fn[NAME$7].noConflict = function () {
  5052. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  5053. return Popover._jQueryInterface;
  5054. };
  5055. /**
  5056. * ------------------------------------------------------------------------
  5057. * Constants
  5058. * ------------------------------------------------------------------------
  5059. */
  5060. var NAME$8 = 'scrollspy';
  5061. var VERSION$8 = '4.4.1';
  5062. var DATA_KEY$8 = 'bs.scrollspy';
  5063. var EVENT_KEY$8 = "." + DATA_KEY$8;
  5064. var DATA_API_KEY$6 = '.data-api';
  5065. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  5066. var Default$6 = {
  5067. offset: 10,
  5068. method: 'auto',
  5069. target: ''
  5070. };
  5071. var DefaultType$6 = {
  5072. offset: 'number',
  5073. method: 'string',
  5074. target: '(string|element)'
  5075. };
  5076. var Event$8 = {
  5077. ACTIVATE: "activate" + EVENT_KEY$8,
  5078. SCROLL: "scroll" + EVENT_KEY$8,
  5079. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  5080. };
  5081. var ClassName$8 = {
  5082. DROPDOWN_ITEM: 'dropdown-item',
  5083. DROPDOWN_MENU: 'dropdown-menu',
  5084. ACTIVE: 'active'
  5085. };
  5086. var Selector$8 = {
  5087. DATA_SPY: '[data-spy="scroll"]',
  5088. ACTIVE: '.active',
  5089. NAV_LIST_GROUP: '.nav, .list-group',
  5090. NAV_LINKS: '.nav-link',
  5091. NAV_ITEMS: '.nav-item',
  5092. LIST_ITEMS: '.list-group-item',
  5093. DROPDOWN: '.dropdown',
  5094. DROPDOWN_ITEMS: '.dropdown-item',
  5095. DROPDOWN_TOGGLE: '.dropdown-toggle'
  5096. };
  5097. var OffsetMethod = {
  5098. OFFSET: 'offset',
  5099. POSITION: 'position'
  5100. };
  5101. /**
  5102. * ------------------------------------------------------------------------
  5103. * Class Definition
  5104. * ------------------------------------------------------------------------
  5105. */
  5106. var ScrollSpy =
  5107. /*#__PURE__*/
  5108. function () {
  5109. function ScrollSpy(element, config) {
  5110. var _this = this;
  5111. this._element = element;
  5112. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5113. this._config = this._getConfig(config);
  5114. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  5115. this._offsets = [];
  5116. this._targets = [];
  5117. this._activeTarget = null;
  5118. this._scrollHeight = 0;
  5119. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  5120. return _this._process(event);
  5121. });
  5122. this.refresh();
  5123. this._process();
  5124. } // Getters
  5125. var _proto = ScrollSpy.prototype;
  5126. // Public
  5127. _proto.refresh = function refresh() {
  5128. var _this2 = this;
  5129. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  5130. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5131. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  5132. this._offsets = [];
  5133. this._targets = [];
  5134. this._scrollHeight = this._getScrollHeight();
  5135. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5136. targets.map(function (element) {
  5137. var target;
  5138. var targetSelector = Util.getSelectorFromElement(element);
  5139. if (targetSelector) {
  5140. target = document.querySelector(targetSelector);
  5141. }
  5142. if (target) {
  5143. var targetBCR = target.getBoundingClientRect();
  5144. if (targetBCR.width || targetBCR.height) {
  5145. // TODO (fat): remove sketch reliance on jQuery position/offset
  5146. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5147. }
  5148. }
  5149. return null;
  5150. }).filter(function (item) {
  5151. return item;
  5152. }).sort(function (a, b) {
  5153. return a[0] - b[0];
  5154. }).forEach(function (item) {
  5155. _this2._offsets.push(item[0]);
  5156. _this2._targets.push(item[1]);
  5157. });
  5158. };
  5159. _proto.dispose = function dispose() {
  5160. $.removeData(this._element, DATA_KEY$8);
  5161. $(this._scrollElement).off(EVENT_KEY$8);
  5162. this._element = null;
  5163. this._scrollElement = null;
  5164. this._config = null;
  5165. this._selector = null;
  5166. this._offsets = null;
  5167. this._targets = null;
  5168. this._activeTarget = null;
  5169. this._scrollHeight = null;
  5170. } // Private
  5171. ;
  5172. _proto._getConfig = function _getConfig(config) {
  5173. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5174. if (typeof config.target !== 'string') {
  5175. var id = $(config.target).attr('id');
  5176. if (!id) {
  5177. id = Util.getUID(NAME$8);
  5178. $(config.target).attr('id', id);
  5179. }
  5180. config.target = "#" + id;
  5181. }
  5182. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5183. return config;
  5184. };
  5185. _proto._getScrollTop = function _getScrollTop() {
  5186. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5187. };
  5188. _proto._getScrollHeight = function _getScrollHeight() {
  5189. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5190. };
  5191. _proto._getOffsetHeight = function _getOffsetHeight() {
  5192. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5193. };
  5194. _proto._process = function _process() {
  5195. var scrollTop = this._getScrollTop() + this._config.offset;
  5196. var scrollHeight = this._getScrollHeight();
  5197. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5198. if (this._scrollHeight !== scrollHeight) {
  5199. this.refresh();
  5200. }
  5201. if (scrollTop >= maxScroll) {
  5202. var target = this._targets[this._targets.length - 1];
  5203. if (this._activeTarget !== target) {
  5204. this._activate(target);
  5205. }
  5206. return;
  5207. }
  5208. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5209. this._activeTarget = null;
  5210. this._clear();
  5211. return;
  5212. }
  5213. var offsetLength = this._offsets.length;
  5214. for (var i = offsetLength; i--;) {
  5215. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5216. if (isActiveTarget) {
  5217. this._activate(this._targets[i]);
  5218. }
  5219. }
  5220. };
  5221. _proto._activate = function _activate(target) {
  5222. this._activeTarget = target;
  5223. this._clear();
  5224. var queries = this._selector.split(',').map(function (selector) {
  5225. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5226. });
  5227. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5228. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5229. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5230. $link.addClass(ClassName$8.ACTIVE);
  5231. } else {
  5232. // Set triggered link as active
  5233. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5234. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5235. $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
  5236. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5237. }
  5238. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5239. relatedTarget: target
  5240. });
  5241. };
  5242. _proto._clear = function _clear() {
  5243. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5244. return node.classList.contains(ClassName$8.ACTIVE);
  5245. }).forEach(function (node) {
  5246. return node.classList.remove(ClassName$8.ACTIVE);
  5247. });
  5248. } // Static
  5249. ;
  5250. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5251. return this.each(function () {
  5252. var data = $(this).data(DATA_KEY$8);
  5253. var _config = typeof config === 'object' && config;
  5254. if (!data) {
  5255. data = new ScrollSpy(this, _config);
  5256. $(this).data(DATA_KEY$8, data);
  5257. }
  5258. if (typeof config === 'string') {
  5259. if (typeof data[config] === 'undefined') {
  5260. throw new TypeError("No method named \"" + config + "\"");
  5261. }
  5262. data[config]();
  5263. }
  5264. });
  5265. };
  5266. _createClass(ScrollSpy, null, [{
  5267. key: "VERSION",
  5268. get: function get() {
  5269. return VERSION$8;
  5270. }
  5271. }, {
  5272. key: "Default",
  5273. get: function get() {
  5274. return Default$6;
  5275. }
  5276. }]);
  5277. return ScrollSpy;
  5278. }();
  5279. /**
  5280. * ------------------------------------------------------------------------
  5281. * Data Api implementation
  5282. * ------------------------------------------------------------------------
  5283. */
  5284. $(window).on(Event$8.LOAD_DATA_API, function () {
  5285. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5286. var scrollSpysLength = scrollSpys.length;
  5287. for (var i = scrollSpysLength; i--;) {
  5288. var $spy = $(scrollSpys[i]);
  5289. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5290. }
  5291. });
  5292. /**
  5293. * ------------------------------------------------------------------------
  5294. * jQuery
  5295. * ------------------------------------------------------------------------
  5296. */
  5297. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5298. $.fn[NAME$8].Constructor = ScrollSpy;
  5299. $.fn[NAME$8].noConflict = function () {
  5300. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5301. return ScrollSpy._jQueryInterface;
  5302. };
  5303. /**
  5304. * ------------------------------------------------------------------------
  5305. * Constants
  5306. * ------------------------------------------------------------------------
  5307. */
  5308. var NAME$9 = 'tab';
  5309. var VERSION$9 = '4.4.1';
  5310. var DATA_KEY$9 = 'bs.tab';
  5311. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5312. var DATA_API_KEY$7 = '.data-api';
  5313. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5314. var Event$9 = {
  5315. HIDE: "hide" + EVENT_KEY$9,
  5316. HIDDEN: "hidden" + EVENT_KEY$9,
  5317. SHOW: "show" + EVENT_KEY$9,
  5318. SHOWN: "shown" + EVENT_KEY$9,
  5319. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5320. };
  5321. var ClassName$9 = {
  5322. DROPDOWN_MENU: 'dropdown-menu',
  5323. ACTIVE: 'active',
  5324. DISABLED: 'disabled',
  5325. FADE: 'fade',
  5326. SHOW: 'show'
  5327. };
  5328. var Selector$9 = {
  5329. DROPDOWN: '.dropdown',
  5330. NAV_LIST_GROUP: '.nav, .list-group',
  5331. ACTIVE: '.active',
  5332. ACTIVE_UL: '> li > .active',
  5333. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5334. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5335. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5336. };
  5337. /**
  5338. * ------------------------------------------------------------------------
  5339. * Class Definition
  5340. * ------------------------------------------------------------------------
  5341. */
  5342. var Tab =
  5343. /*#__PURE__*/
  5344. function () {
  5345. function Tab(element) {
  5346. this._element = element;
  5347. } // Getters
  5348. var _proto = Tab.prototype;
  5349. // Public
  5350. _proto.show = function show() {
  5351. var _this = this;
  5352. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5353. return;
  5354. }
  5355. var target;
  5356. var previous;
  5357. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5358. var selector = Util.getSelectorFromElement(this._element);
  5359. if (listElement) {
  5360. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5361. previous = $.makeArray($(listElement).find(itemSelector));
  5362. previous = previous[previous.length - 1];
  5363. }
  5364. var hideEvent = $.Event(Event$9.HIDE, {
  5365. relatedTarget: this._element
  5366. });
  5367. var showEvent = $.Event(Event$9.SHOW, {
  5368. relatedTarget: previous
  5369. });
  5370. if (previous) {
  5371. $(previous).trigger(hideEvent);
  5372. }
  5373. $(this._element).trigger(showEvent);
  5374. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5375. return;
  5376. }
  5377. if (selector) {
  5378. target = document.querySelector(selector);
  5379. }
  5380. this._activate(this._element, listElement);
  5381. var complete = function complete() {
  5382. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5383. relatedTarget: _this._element
  5384. });
  5385. var shownEvent = $.Event(Event$9.SHOWN, {
  5386. relatedTarget: previous
  5387. });
  5388. $(previous).trigger(hiddenEvent);
  5389. $(_this._element).trigger(shownEvent);
  5390. };
  5391. if (target) {
  5392. this._activate(target, target.parentNode, complete);
  5393. } else {
  5394. complete();
  5395. }
  5396. };
  5397. _proto.dispose = function dispose() {
  5398. $.removeData(this._element, DATA_KEY$9);
  5399. this._element = null;
  5400. } // Private
  5401. ;
  5402. _proto._activate = function _activate(element, container, callback) {
  5403. var _this2 = this;
  5404. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5405. var active = activeElements[0];
  5406. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5407. var complete = function complete() {
  5408. return _this2._transitionComplete(element, active, callback);
  5409. };
  5410. if (active && isTransitioning) {
  5411. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5412. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5413. } else {
  5414. complete();
  5415. }
  5416. };
  5417. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5418. if (active) {
  5419. $(active).removeClass(ClassName$9.ACTIVE);
  5420. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5421. if (dropdownChild) {
  5422. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5423. }
  5424. if (active.getAttribute('role') === 'tab') {
  5425. active.setAttribute('aria-selected', false);
  5426. }
  5427. }
  5428. $(element).addClass(ClassName$9.ACTIVE);
  5429. if (element.getAttribute('role') === 'tab') {
  5430. element.setAttribute('aria-selected', true);
  5431. }
  5432. Util.reflow(element);
  5433. if (element.classList.contains(ClassName$9.FADE)) {
  5434. element.classList.add(ClassName$9.SHOW);
  5435. }
  5436. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5437. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5438. if (dropdownElement) {
  5439. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5440. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5441. }
  5442. element.setAttribute('aria-expanded', true);
  5443. }
  5444. if (callback) {
  5445. callback();
  5446. }
  5447. } // Static
  5448. ;
  5449. Tab._jQueryInterface = function _jQueryInterface(config) {
  5450. return this.each(function () {
  5451. var $this = $(this);
  5452. var data = $this.data(DATA_KEY$9);
  5453. if (!data) {
  5454. data = new Tab(this);
  5455. $this.data(DATA_KEY$9, data);
  5456. }
  5457. if (typeof config === 'string') {
  5458. if (typeof data[config] === 'undefined') {
  5459. throw new TypeError("No method named \"" + config + "\"");
  5460. }
  5461. data[config]();
  5462. }
  5463. });
  5464. };
  5465. _createClass(Tab, null, [{
  5466. key: "VERSION",
  5467. get: function get() {
  5468. return VERSION$9;
  5469. }
  5470. }]);
  5471. return Tab;
  5472. }();
  5473. /**
  5474. * ------------------------------------------------------------------------
  5475. * Data Api implementation
  5476. * ------------------------------------------------------------------------
  5477. */
  5478. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5479. event.preventDefault();
  5480. Tab._jQueryInterface.call($(this), 'show');
  5481. });
  5482. /**
  5483. * ------------------------------------------------------------------------
  5484. * jQuery
  5485. * ------------------------------------------------------------------------
  5486. */
  5487. $.fn[NAME$9] = Tab._jQueryInterface;
  5488. $.fn[NAME$9].Constructor = Tab;
  5489. $.fn[NAME$9].noConflict = function () {
  5490. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5491. return Tab._jQueryInterface;
  5492. };
  5493. /**
  5494. * ------------------------------------------------------------------------
  5495. * Constants
  5496. * ------------------------------------------------------------------------
  5497. */
  5498. var NAME$a = 'toast';
  5499. var VERSION$a = '4.4.1';
  5500. var DATA_KEY$a = 'bs.toast';
  5501. var EVENT_KEY$a = "." + DATA_KEY$a;
  5502. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5503. var Event$a = {
  5504. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5505. HIDE: "hide" + EVENT_KEY$a,
  5506. HIDDEN: "hidden" + EVENT_KEY$a,
  5507. SHOW: "show" + EVENT_KEY$a,
  5508. SHOWN: "shown" + EVENT_KEY$a
  5509. };
  5510. var ClassName$a = {
  5511. FADE: 'fade',
  5512. HIDE: 'hide',
  5513. SHOW: 'show',
  5514. SHOWING: 'showing'
  5515. };
  5516. var DefaultType$7 = {
  5517. animation: 'boolean',
  5518. autohide: 'boolean',
  5519. delay: 'number'
  5520. };
  5521. var Default$7 = {
  5522. animation: true,
  5523. autohide: true,
  5524. delay: 500
  5525. };
  5526. var Selector$a = {
  5527. DATA_DISMISS: '[data-dismiss="toast"]'
  5528. };
  5529. /**
  5530. * ------------------------------------------------------------------------
  5531. * Class Definition
  5532. * ------------------------------------------------------------------------
  5533. */
  5534. var Toast =
  5535. /*#__PURE__*/
  5536. function () {
  5537. function Toast(element, config) {
  5538. this._element = element;
  5539. this._config = this._getConfig(config);
  5540. this._timeout = null;
  5541. this._setListeners();
  5542. } // Getters
  5543. var _proto = Toast.prototype;
  5544. // Public
  5545. _proto.show = function show() {
  5546. var _this = this;
  5547. var showEvent = $.Event(Event$a.SHOW);
  5548. $(this._element).trigger(showEvent);
  5549. if (showEvent.isDefaultPrevented()) {
  5550. return;
  5551. }
  5552. if (this._config.animation) {
  5553. this._element.classList.add(ClassName$a.FADE);
  5554. }
  5555. var complete = function complete() {
  5556. _this._element.classList.remove(ClassName$a.SHOWING);
  5557. _this._element.classList.add(ClassName$a.SHOW);
  5558. $(_this._element).trigger(Event$a.SHOWN);
  5559. if (_this._config.autohide) {
  5560. _this._timeout = setTimeout(function () {
  5561. _this.hide();
  5562. }, _this._config.delay);
  5563. }
  5564. };
  5565. this._element.classList.remove(ClassName$a.HIDE);
  5566. Util.reflow(this._element);
  5567. this._element.classList.add(ClassName$a.SHOWING);
  5568. if (this._config.animation) {
  5569. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5570. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5571. } else {
  5572. complete();
  5573. }
  5574. };
  5575. _proto.hide = function hide() {
  5576. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5577. return;
  5578. }
  5579. var hideEvent = $.Event(Event$a.HIDE);
  5580. $(this._element).trigger(hideEvent);
  5581. if (hideEvent.isDefaultPrevented()) {
  5582. return;
  5583. }
  5584. this._close();
  5585. };
  5586. _proto.dispose = function dispose() {
  5587. clearTimeout(this._timeout);
  5588. this._timeout = null;
  5589. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5590. this._element.classList.remove(ClassName$a.SHOW);
  5591. }
  5592. $(this._element).off(Event$a.CLICK_DISMISS);
  5593. $.removeData(this._element, DATA_KEY$a);
  5594. this._element = null;
  5595. this._config = null;
  5596. } // Private
  5597. ;
  5598. _proto._getConfig = function _getConfig(config) {
  5599. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5600. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5601. return config;
  5602. };
  5603. _proto._setListeners = function _setListeners() {
  5604. var _this2 = this;
  5605. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5606. return _this2.hide();
  5607. });
  5608. };
  5609. _proto._close = function _close() {
  5610. var _this3 = this;
  5611. var complete = function complete() {
  5612. _this3._element.classList.add(ClassName$a.HIDE);
  5613. $(_this3._element).trigger(Event$a.HIDDEN);
  5614. };
  5615. this._element.classList.remove(ClassName$a.SHOW);
  5616. if (this._config.animation) {
  5617. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5618. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5619. } else {
  5620. complete();
  5621. }
  5622. } // Static
  5623. ;
  5624. Toast._jQueryInterface = function _jQueryInterface(config) {
  5625. return this.each(function () {
  5626. var $element = $(this);
  5627. var data = $element.data(DATA_KEY$a);
  5628. var _config = typeof config === 'object' && config;
  5629. if (!data) {
  5630. data = new Toast(this, _config);
  5631. $element.data(DATA_KEY$a, data);
  5632. }
  5633. if (typeof config === 'string') {
  5634. if (typeof data[config] === 'undefined') {
  5635. throw new TypeError("No method named \"" + config + "\"");
  5636. }
  5637. data[config](this);
  5638. }
  5639. });
  5640. };
  5641. _createClass(Toast, null, [{
  5642. key: "VERSION",
  5643. get: function get() {
  5644. return VERSION$a;
  5645. }
  5646. }, {
  5647. key: "DefaultType",
  5648. get: function get() {
  5649. return DefaultType$7;
  5650. }
  5651. }, {
  5652. key: "Default",
  5653. get: function get() {
  5654. return Default$7;
  5655. }
  5656. }]);
  5657. return Toast;
  5658. }();
  5659. /**
  5660. * ------------------------------------------------------------------------
  5661. * jQuery
  5662. * ------------------------------------------------------------------------
  5663. */
  5664. $.fn[NAME$a] = Toast._jQueryInterface;
  5665. $.fn[NAME$a].Constructor = Toast;
  5666. $.fn[NAME$a].noConflict = function () {
  5667. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5668. return Toast._jQueryInterface;
  5669. };
  5670. exports.Alert = Alert;
  5671. exports.Button = Button;
  5672. exports.Carousel = Carousel;
  5673. exports.Collapse = Collapse;
  5674. exports.Dropdown = Dropdown;
  5675. exports.Modal = Modal;
  5676. exports.Popover = Popover;
  5677. exports.Scrollspy = ScrollSpy;
  5678. exports.Tab = Tab;
  5679. exports.Toast = Toast;
  5680. exports.Tooltip = Tooltip;
  5681. exports.Util = Util;
  5682. Object.defineProperty(exports, '__esModule', { value: true });
  5683. })));
  5684. //# sourceMappingURL=bootstrap.js.map
  5685. /***/ }),
  5686. /***/ "./node_modules/buffer/index.js":
  5687. /*!**************************************!*\
  5688. !*** ./node_modules/buffer/index.js ***!
  5689. \**************************************/
  5690. /*! no static exports found */
  5691. /***/ (function(module, exports, __webpack_require__) {
  5692. "use strict";
  5693. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5694. * The buffer module from node.js, for the browser.
  5695. *
  5696. * @author Feross Aboukhadijeh <http://feross.org>
  5697. * @license MIT
  5698. */
  5699. /* eslint-disable no-proto */
  5700. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5701. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5702. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5703. exports.Buffer = Buffer
  5704. exports.SlowBuffer = SlowBuffer
  5705. exports.INSPECT_MAX_BYTES = 50
  5706. /**
  5707. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5708. * === true Use Uint8Array implementation (fastest)
  5709. * === false Use Object implementation (most compatible, even IE6)
  5710. *
  5711. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5712. * Opera 11.6+, iOS 4.2+.
  5713. *
  5714. * Due to various browser bugs, sometimes the Object implementation will be used even
  5715. * when the browser supports typed arrays.
  5716. *
  5717. * Note:
  5718. *
  5719. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5720. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5721. *
  5722. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5723. *
  5724. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5725. * incorrect length in some situations.
  5726. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5727. * get the Object implementation, which is slower but behaves correctly.
  5728. */
  5729. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5730. ? global.TYPED_ARRAY_SUPPORT
  5731. : typedArraySupport()
  5732. /*
  5733. * Export kMaxLength after typed array support is determined.
  5734. */
  5735. exports.kMaxLength = kMaxLength()
  5736. function typedArraySupport () {
  5737. try {
  5738. var arr = new Uint8Array(1)
  5739. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5740. return arr.foo() === 42 && // typed array instances can be augmented
  5741. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5742. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5743. } catch (e) {
  5744. return false
  5745. }
  5746. }
  5747. function kMaxLength () {
  5748. return Buffer.TYPED_ARRAY_SUPPORT
  5749. ? 0x7fffffff
  5750. : 0x3fffffff
  5751. }
  5752. function createBuffer (that, length) {
  5753. if (kMaxLength() < length) {
  5754. throw new RangeError('Invalid typed array length')
  5755. }
  5756. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5757. // Return an augmented `Uint8Array` instance, for best performance
  5758. that = new Uint8Array(length)
  5759. that.__proto__ = Buffer.prototype
  5760. } else {
  5761. // Fallback: Return an object instance of the Buffer class
  5762. if (that === null) {
  5763. that = new Buffer(length)
  5764. }
  5765. that.length = length
  5766. }
  5767. return that
  5768. }
  5769. /**
  5770. * The Buffer constructor returns instances of `Uint8Array` that have their
  5771. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5772. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5773. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5774. * returns a single octet.
  5775. *
  5776. * The `Uint8Array` prototype remains unmodified.
  5777. */
  5778. function Buffer (arg, encodingOrOffset, length) {
  5779. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5780. return new Buffer(arg, encodingOrOffset, length)
  5781. }
  5782. // Common case.
  5783. if (typeof arg === 'number') {
  5784. if (typeof encodingOrOffset === 'string') {
  5785. throw new Error(
  5786. 'If encoding is specified then the first argument must be a string'
  5787. )
  5788. }
  5789. return allocUnsafe(this, arg)
  5790. }
  5791. return from(this, arg, encodingOrOffset, length)
  5792. }
  5793. Buffer.poolSize = 8192 // not used by this implementation
  5794. // TODO: Legacy, not needed anymore. Remove in next major version.
  5795. Buffer._augment = function (arr) {
  5796. arr.__proto__ = Buffer.prototype
  5797. return arr
  5798. }
  5799. function from (that, value, encodingOrOffset, length) {
  5800. if (typeof value === 'number') {
  5801. throw new TypeError('"value" argument must not be a number')
  5802. }
  5803. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5804. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5805. }
  5806. if (typeof value === 'string') {
  5807. return fromString(that, value, encodingOrOffset)
  5808. }
  5809. return fromObject(that, value)
  5810. }
  5811. /**
  5812. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5813. * if value is a number.
  5814. * Buffer.from(str[, encoding])
  5815. * Buffer.from(array)
  5816. * Buffer.from(buffer)
  5817. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5818. **/
  5819. Buffer.from = function (value, encodingOrOffset, length) {
  5820. return from(null, value, encodingOrOffset, length)
  5821. }
  5822. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5823. Buffer.prototype.__proto__ = Uint8Array.prototype
  5824. Buffer.__proto__ = Uint8Array
  5825. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5826. Buffer[Symbol.species] === Buffer) {
  5827. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5828. Object.defineProperty(Buffer, Symbol.species, {
  5829. value: null,
  5830. configurable: true
  5831. })
  5832. }
  5833. }
  5834. function assertSize (size) {
  5835. if (typeof size !== 'number') {
  5836. throw new TypeError('"size" argument must be a number')
  5837. } else if (size < 0) {
  5838. throw new RangeError('"size" argument must not be negative')
  5839. }
  5840. }
  5841. function alloc (that, size, fill, encoding) {
  5842. assertSize(size)
  5843. if (size <= 0) {
  5844. return createBuffer(that, size)
  5845. }
  5846. if (fill !== undefined) {
  5847. // Only pay attention to encoding if it's a string. This
  5848. // prevents accidentally sending in a number that would
  5849. // be interpretted as a start offset.
  5850. return typeof encoding === 'string'
  5851. ? createBuffer(that, size).fill(fill, encoding)
  5852. : createBuffer(that, size).fill(fill)
  5853. }
  5854. return createBuffer(that, size)
  5855. }
  5856. /**
  5857. * Creates a new filled Buffer instance.
  5858. * alloc(size[, fill[, encoding]])
  5859. **/
  5860. Buffer.alloc = function (size, fill, encoding) {
  5861. return alloc(null, size, fill, encoding)
  5862. }
  5863. function allocUnsafe (that, size) {
  5864. assertSize(size)
  5865. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5866. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5867. for (var i = 0; i < size; ++i) {
  5868. that[i] = 0
  5869. }
  5870. }
  5871. return that
  5872. }
  5873. /**
  5874. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5875. * */
  5876. Buffer.allocUnsafe = function (size) {
  5877. return allocUnsafe(null, size)
  5878. }
  5879. /**
  5880. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5881. */
  5882. Buffer.allocUnsafeSlow = function (size) {
  5883. return allocUnsafe(null, size)
  5884. }
  5885. function fromString (that, string, encoding) {
  5886. if (typeof encoding !== 'string' || encoding === '') {
  5887. encoding = 'utf8'
  5888. }
  5889. if (!Buffer.isEncoding(encoding)) {
  5890. throw new TypeError('"encoding" must be a valid string encoding')
  5891. }
  5892. var length = byteLength(string, encoding) | 0
  5893. that = createBuffer(that, length)
  5894. var actual = that.write(string, encoding)
  5895. if (actual !== length) {
  5896. // Writing a hex string, for example, that contains invalid characters will
  5897. // cause everything after the first invalid character to be ignored. (e.g.
  5898. // 'abxxcd' will be treated as 'ab')
  5899. that = that.slice(0, actual)
  5900. }
  5901. return that
  5902. }
  5903. function fromArrayLike (that, array) {
  5904. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5905. that = createBuffer(that, length)
  5906. for (var i = 0; i < length; i += 1) {
  5907. that[i] = array[i] & 255
  5908. }
  5909. return that
  5910. }
  5911. function fromArrayBuffer (that, array, byteOffset, length) {
  5912. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5913. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5914. throw new RangeError('\'offset\' is out of bounds')
  5915. }
  5916. if (array.byteLength < byteOffset + (length || 0)) {
  5917. throw new RangeError('\'length\' is out of bounds')
  5918. }
  5919. if (byteOffset === undefined && length === undefined) {
  5920. array = new Uint8Array(array)
  5921. } else if (length === undefined) {
  5922. array = new Uint8Array(array, byteOffset)
  5923. } else {
  5924. array = new Uint8Array(array, byteOffset, length)
  5925. }
  5926. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5927. // Return an augmented `Uint8Array` instance, for best performance
  5928. that = array
  5929. that.__proto__ = Buffer.prototype
  5930. } else {
  5931. // Fallback: Return an object instance of the Buffer class
  5932. that = fromArrayLike(that, array)
  5933. }
  5934. return that
  5935. }
  5936. function fromObject (that, obj) {
  5937. if (Buffer.isBuffer(obj)) {
  5938. var len = checked(obj.length) | 0
  5939. that = createBuffer(that, len)
  5940. if (that.length === 0) {
  5941. return that
  5942. }
  5943. obj.copy(that, 0, 0, len)
  5944. return that
  5945. }
  5946. if (obj) {
  5947. if ((typeof ArrayBuffer !== 'undefined' &&
  5948. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5949. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5950. return createBuffer(that, 0)
  5951. }
  5952. return fromArrayLike(that, obj)
  5953. }
  5954. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5955. return fromArrayLike(that, obj.data)
  5956. }
  5957. }
  5958. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5959. }
  5960. function checked (length) {
  5961. // Note: cannot use `length < kMaxLength()` here because that fails when
  5962. // length is NaN (which is otherwise coerced to zero.)
  5963. if (length >= kMaxLength()) {
  5964. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5965. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5966. }
  5967. return length | 0
  5968. }
  5969. function SlowBuffer (length) {
  5970. if (+length != length) { // eslint-disable-line eqeqeq
  5971. length = 0
  5972. }
  5973. return Buffer.alloc(+length)
  5974. }
  5975. Buffer.isBuffer = function isBuffer (b) {
  5976. return !!(b != null && b._isBuffer)
  5977. }
  5978. Buffer.compare = function compare (a, b) {
  5979. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5980. throw new TypeError('Arguments must be Buffers')
  5981. }
  5982. if (a === b) return 0
  5983. var x = a.length
  5984. var y = b.length
  5985. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5986. if (a[i] !== b[i]) {
  5987. x = a[i]
  5988. y = b[i]
  5989. break
  5990. }
  5991. }
  5992. if (x < y) return -1
  5993. if (y < x) return 1
  5994. return 0
  5995. }
  5996. Buffer.isEncoding = function isEncoding (encoding) {
  5997. switch (String(encoding).toLowerCase()) {
  5998. case 'hex':
  5999. case 'utf8':
  6000. case 'utf-8':
  6001. case 'ascii':
  6002. case 'latin1':
  6003. case 'binary':
  6004. case 'base64':
  6005. case 'ucs2':
  6006. case 'ucs-2':
  6007. case 'utf16le':
  6008. case 'utf-16le':
  6009. return true
  6010. default:
  6011. return false
  6012. }
  6013. }
  6014. Buffer.concat = function concat (list, length) {
  6015. if (!isArray(list)) {
  6016. throw new TypeError('"list" argument must be an Array of Buffers')
  6017. }
  6018. if (list.length === 0) {
  6019. return Buffer.alloc(0)
  6020. }
  6021. var i
  6022. if (length === undefined) {
  6023. length = 0
  6024. for (i = 0; i < list.length; ++i) {
  6025. length += list[i].length
  6026. }
  6027. }
  6028. var buffer = Buffer.allocUnsafe(length)
  6029. var pos = 0
  6030. for (i = 0; i < list.length; ++i) {
  6031. var buf = list[i]
  6032. if (!Buffer.isBuffer(buf)) {
  6033. throw new TypeError('"list" argument must be an Array of Buffers')
  6034. }
  6035. buf.copy(buffer, pos)
  6036. pos += buf.length
  6037. }
  6038. return buffer
  6039. }
  6040. function byteLength (string, encoding) {
  6041. if (Buffer.isBuffer(string)) {
  6042. return string.length
  6043. }
  6044. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  6045. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  6046. return string.byteLength
  6047. }
  6048. if (typeof string !== 'string') {
  6049. string = '' + string
  6050. }
  6051. var len = string.length
  6052. if (len === 0) return 0
  6053. // Use a for loop to avoid recursion
  6054. var loweredCase = false
  6055. for (;;) {
  6056. switch (encoding) {
  6057. case 'ascii':
  6058. case 'latin1':
  6059. case 'binary':
  6060. return len
  6061. case 'utf8':
  6062. case 'utf-8':
  6063. case undefined:
  6064. return utf8ToBytes(string).length
  6065. case 'ucs2':
  6066. case 'ucs-2':
  6067. case 'utf16le':
  6068. case 'utf-16le':
  6069. return len * 2
  6070. case 'hex':
  6071. return len >>> 1
  6072. case 'base64':
  6073. return base64ToBytes(string).length
  6074. default:
  6075. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  6076. encoding = ('' + encoding).toLowerCase()
  6077. loweredCase = true
  6078. }
  6079. }
  6080. }
  6081. Buffer.byteLength = byteLength
  6082. function slowToString (encoding, start, end) {
  6083. var loweredCase = false
  6084. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6085. // property of a typed array.
  6086. // This behaves neither like String nor Uint8Array in that we set start/end
  6087. // to their upper/lower bounds if the value passed is out of range.
  6088. // undefined is handled specially as per ECMA-262 6th Edition,
  6089. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6090. if (start === undefined || start < 0) {
  6091. start = 0
  6092. }
  6093. // Return early if start > this.length. Done here to prevent potential uint32
  6094. // coercion fail below.
  6095. if (start > this.length) {
  6096. return ''
  6097. }
  6098. if (end === undefined || end > this.length) {
  6099. end = this.length
  6100. }
  6101. if (end <= 0) {
  6102. return ''
  6103. }
  6104. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6105. end >>>= 0
  6106. start >>>= 0
  6107. if (end <= start) {
  6108. return ''
  6109. }
  6110. if (!encoding) encoding = 'utf8'
  6111. while (true) {
  6112. switch (encoding) {
  6113. case 'hex':
  6114. return hexSlice(this, start, end)
  6115. case 'utf8':
  6116. case 'utf-8':
  6117. return utf8Slice(this, start, end)
  6118. case 'ascii':
  6119. return asciiSlice(this, start, end)
  6120. case 'latin1':
  6121. case 'binary':
  6122. return latin1Slice(this, start, end)
  6123. case 'base64':
  6124. return base64Slice(this, start, end)
  6125. case 'ucs2':
  6126. case 'ucs-2':
  6127. case 'utf16le':
  6128. case 'utf-16le':
  6129. return utf16leSlice(this, start, end)
  6130. default:
  6131. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6132. encoding = (encoding + '').toLowerCase()
  6133. loweredCase = true
  6134. }
  6135. }
  6136. }
  6137. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6138. // Buffer instances.
  6139. Buffer.prototype._isBuffer = true
  6140. function swap (b, n, m) {
  6141. var i = b[n]
  6142. b[n] = b[m]
  6143. b[m] = i
  6144. }
  6145. Buffer.prototype.swap16 = function swap16 () {
  6146. var len = this.length
  6147. if (len % 2 !== 0) {
  6148. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6149. }
  6150. for (var i = 0; i < len; i += 2) {
  6151. swap(this, i, i + 1)
  6152. }
  6153. return this
  6154. }
  6155. Buffer.prototype.swap32 = function swap32 () {
  6156. var len = this.length
  6157. if (len % 4 !== 0) {
  6158. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6159. }
  6160. for (var i = 0; i < len; i += 4) {
  6161. swap(this, i, i + 3)
  6162. swap(this, i + 1, i + 2)
  6163. }
  6164. return this
  6165. }
  6166. Buffer.prototype.swap64 = function swap64 () {
  6167. var len = this.length
  6168. if (len % 8 !== 0) {
  6169. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6170. }
  6171. for (var i = 0; i < len; i += 8) {
  6172. swap(this, i, i + 7)
  6173. swap(this, i + 1, i + 6)
  6174. swap(this, i + 2, i + 5)
  6175. swap(this, i + 3, i + 4)
  6176. }
  6177. return this
  6178. }
  6179. Buffer.prototype.toString = function toString () {
  6180. var length = this.length | 0
  6181. if (length === 0) return ''
  6182. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6183. return slowToString.apply(this, arguments)
  6184. }
  6185. Buffer.prototype.equals = function equals (b) {
  6186. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6187. if (this === b) return true
  6188. return Buffer.compare(this, b) === 0
  6189. }
  6190. Buffer.prototype.inspect = function inspect () {
  6191. var str = ''
  6192. var max = exports.INSPECT_MAX_BYTES
  6193. if (this.length > 0) {
  6194. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6195. if (this.length > max) str += ' ... '
  6196. }
  6197. return '<Buffer ' + str + '>'
  6198. }
  6199. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6200. if (!Buffer.isBuffer(target)) {
  6201. throw new TypeError('Argument must be a Buffer')
  6202. }
  6203. if (start === undefined) {
  6204. start = 0
  6205. }
  6206. if (end === undefined) {
  6207. end = target ? target.length : 0
  6208. }
  6209. if (thisStart === undefined) {
  6210. thisStart = 0
  6211. }
  6212. if (thisEnd === undefined) {
  6213. thisEnd = this.length
  6214. }
  6215. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6216. throw new RangeError('out of range index')
  6217. }
  6218. if (thisStart >= thisEnd && start >= end) {
  6219. return 0
  6220. }
  6221. if (thisStart >= thisEnd) {
  6222. return -1
  6223. }
  6224. if (start >= end) {
  6225. return 1
  6226. }
  6227. start >>>= 0
  6228. end >>>= 0
  6229. thisStart >>>= 0
  6230. thisEnd >>>= 0
  6231. if (this === target) return 0
  6232. var x = thisEnd - thisStart
  6233. var y = end - start
  6234. var len = Math.min(x, y)
  6235. var thisCopy = this.slice(thisStart, thisEnd)
  6236. var targetCopy = target.slice(start, end)
  6237. for (var i = 0; i < len; ++i) {
  6238. if (thisCopy[i] !== targetCopy[i]) {
  6239. x = thisCopy[i]
  6240. y = targetCopy[i]
  6241. break
  6242. }
  6243. }
  6244. if (x < y) return -1
  6245. if (y < x) return 1
  6246. return 0
  6247. }
  6248. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6249. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6250. //
  6251. // Arguments:
  6252. // - buffer - a Buffer to search
  6253. // - val - a string, Buffer, or number
  6254. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6255. // - encoding - an optional encoding, relevant is val is a string
  6256. // - dir - true for indexOf, false for lastIndexOf
  6257. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6258. // Empty buffer means no match
  6259. if (buffer.length === 0) return -1
  6260. // Normalize byteOffset
  6261. if (typeof byteOffset === 'string') {
  6262. encoding = byteOffset
  6263. byteOffset = 0
  6264. } else if (byteOffset > 0x7fffffff) {
  6265. byteOffset = 0x7fffffff
  6266. } else if (byteOffset < -0x80000000) {
  6267. byteOffset = -0x80000000
  6268. }
  6269. byteOffset = +byteOffset // Coerce to Number.
  6270. if (isNaN(byteOffset)) {
  6271. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6272. byteOffset = dir ? 0 : (buffer.length - 1)
  6273. }
  6274. // Normalize byteOffset: negative offsets start from the end of the buffer
  6275. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6276. if (byteOffset >= buffer.length) {
  6277. if (dir) return -1
  6278. else byteOffset = buffer.length - 1
  6279. } else if (byteOffset < 0) {
  6280. if (dir) byteOffset = 0
  6281. else return -1
  6282. }
  6283. // Normalize val
  6284. if (typeof val === 'string') {
  6285. val = Buffer.from(val, encoding)
  6286. }
  6287. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6288. if (Buffer.isBuffer(val)) {
  6289. // Special case: looking for empty string/buffer always fails
  6290. if (val.length === 0) {
  6291. return -1
  6292. }
  6293. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6294. } else if (typeof val === 'number') {
  6295. val = val & 0xFF // Search for a byte value [0-255]
  6296. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6297. typeof Uint8Array.prototype.indexOf === 'function') {
  6298. if (dir) {
  6299. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6300. } else {
  6301. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6302. }
  6303. }
  6304. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6305. }
  6306. throw new TypeError('val must be string, number or Buffer')
  6307. }
  6308. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6309. var indexSize = 1
  6310. var arrLength = arr.length
  6311. var valLength = val.length
  6312. if (encoding !== undefined) {
  6313. encoding = String(encoding).toLowerCase()
  6314. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6315. encoding === 'utf16le' || encoding === 'utf-16le') {
  6316. if (arr.length < 2 || val.length < 2) {
  6317. return -1
  6318. }
  6319. indexSize = 2
  6320. arrLength /= 2
  6321. valLength /= 2
  6322. byteOffset /= 2
  6323. }
  6324. }
  6325. function read (buf, i) {
  6326. if (indexSize === 1) {
  6327. return buf[i]
  6328. } else {
  6329. return buf.readUInt16BE(i * indexSize)
  6330. }
  6331. }
  6332. var i
  6333. if (dir) {
  6334. var foundIndex = -1
  6335. for (i = byteOffset; i < arrLength; i++) {
  6336. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6337. if (foundIndex === -1) foundIndex = i
  6338. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6339. } else {
  6340. if (foundIndex !== -1) i -= i - foundIndex
  6341. foundIndex = -1
  6342. }
  6343. }
  6344. } else {
  6345. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6346. for (i = byteOffset; i >= 0; i--) {
  6347. var found = true
  6348. for (var j = 0; j < valLength; j++) {
  6349. if (read(arr, i + j) !== read(val, j)) {
  6350. found = false
  6351. break
  6352. }
  6353. }
  6354. if (found) return i
  6355. }
  6356. }
  6357. return -1
  6358. }
  6359. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6360. return this.indexOf(val, byteOffset, encoding) !== -1
  6361. }
  6362. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6363. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6364. }
  6365. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6366. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6367. }
  6368. function hexWrite (buf, string, offset, length) {
  6369. offset = Number(offset) || 0
  6370. var remaining = buf.length - offset
  6371. if (!length) {
  6372. length = remaining
  6373. } else {
  6374. length = Number(length)
  6375. if (length > remaining) {
  6376. length = remaining
  6377. }
  6378. }
  6379. // must be an even number of digits
  6380. var strLen = string.length
  6381. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6382. if (length > strLen / 2) {
  6383. length = strLen / 2
  6384. }
  6385. for (var i = 0; i < length; ++i) {
  6386. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6387. if (isNaN(parsed)) return i
  6388. buf[offset + i] = parsed
  6389. }
  6390. return i
  6391. }
  6392. function utf8Write (buf, string, offset, length) {
  6393. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6394. }
  6395. function asciiWrite (buf, string, offset, length) {
  6396. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6397. }
  6398. function latin1Write (buf, string, offset, length) {
  6399. return asciiWrite(buf, string, offset, length)
  6400. }
  6401. function base64Write (buf, string, offset, length) {
  6402. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6403. }
  6404. function ucs2Write (buf, string, offset, length) {
  6405. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6406. }
  6407. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6408. // Buffer#write(string)
  6409. if (offset === undefined) {
  6410. encoding = 'utf8'
  6411. length = this.length
  6412. offset = 0
  6413. // Buffer#write(string, encoding)
  6414. } else if (length === undefined && typeof offset === 'string') {
  6415. encoding = offset
  6416. length = this.length
  6417. offset = 0
  6418. // Buffer#write(string, offset[, length][, encoding])
  6419. } else if (isFinite(offset)) {
  6420. offset = offset | 0
  6421. if (isFinite(length)) {
  6422. length = length | 0
  6423. if (encoding === undefined) encoding = 'utf8'
  6424. } else {
  6425. encoding = length
  6426. length = undefined
  6427. }
  6428. // legacy write(string, encoding, offset, length) - remove in v0.13
  6429. } else {
  6430. throw new Error(
  6431. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6432. )
  6433. }
  6434. var remaining = this.length - offset
  6435. if (length === undefined || length > remaining) length = remaining
  6436. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6437. throw new RangeError('Attempt to write outside buffer bounds')
  6438. }
  6439. if (!encoding) encoding = 'utf8'
  6440. var loweredCase = false
  6441. for (;;) {
  6442. switch (encoding) {
  6443. case 'hex':
  6444. return hexWrite(this, string, offset, length)
  6445. case 'utf8':
  6446. case 'utf-8':
  6447. return utf8Write(this, string, offset, length)
  6448. case 'ascii':
  6449. return asciiWrite(this, string, offset, length)
  6450. case 'latin1':
  6451. case 'binary':
  6452. return latin1Write(this, string, offset, length)
  6453. case 'base64':
  6454. // Warning: maxLength not taken into account in base64Write
  6455. return base64Write(this, string, offset, length)
  6456. case 'ucs2':
  6457. case 'ucs-2':
  6458. case 'utf16le':
  6459. case 'utf-16le':
  6460. return ucs2Write(this, string, offset, length)
  6461. default:
  6462. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6463. encoding = ('' + encoding).toLowerCase()
  6464. loweredCase = true
  6465. }
  6466. }
  6467. }
  6468. Buffer.prototype.toJSON = function toJSON () {
  6469. return {
  6470. type: 'Buffer',
  6471. data: Array.prototype.slice.call(this._arr || this, 0)
  6472. }
  6473. }
  6474. function base64Slice (buf, start, end) {
  6475. if (start === 0 && end === buf.length) {
  6476. return base64.fromByteArray(buf)
  6477. } else {
  6478. return base64.fromByteArray(buf.slice(start, end))
  6479. }
  6480. }
  6481. function utf8Slice (buf, start, end) {
  6482. end = Math.min(buf.length, end)
  6483. var res = []
  6484. var i = start
  6485. while (i < end) {
  6486. var firstByte = buf[i]
  6487. var codePoint = null
  6488. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6489. : (firstByte > 0xDF) ? 3
  6490. : (firstByte > 0xBF) ? 2
  6491. : 1
  6492. if (i + bytesPerSequence <= end) {
  6493. var secondByte, thirdByte, fourthByte, tempCodePoint
  6494. switch (bytesPerSequence) {
  6495. case 1:
  6496. if (firstByte < 0x80) {
  6497. codePoint = firstByte
  6498. }
  6499. break
  6500. case 2:
  6501. secondByte = buf[i + 1]
  6502. if ((secondByte & 0xC0) === 0x80) {
  6503. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6504. if (tempCodePoint > 0x7F) {
  6505. codePoint = tempCodePoint
  6506. }
  6507. }
  6508. break
  6509. case 3:
  6510. secondByte = buf[i + 1]
  6511. thirdByte = buf[i + 2]
  6512. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6513. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6514. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6515. codePoint = tempCodePoint
  6516. }
  6517. }
  6518. break
  6519. case 4:
  6520. secondByte = buf[i + 1]
  6521. thirdByte = buf[i + 2]
  6522. fourthByte = buf[i + 3]
  6523. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6524. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6525. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6526. codePoint = tempCodePoint
  6527. }
  6528. }
  6529. }
  6530. }
  6531. if (codePoint === null) {
  6532. // we did not generate a valid codePoint so insert a
  6533. // replacement char (U+FFFD) and advance only 1 byte
  6534. codePoint = 0xFFFD
  6535. bytesPerSequence = 1
  6536. } else if (codePoint > 0xFFFF) {
  6537. // encode to utf16 (surrogate pair dance)
  6538. codePoint -= 0x10000
  6539. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6540. codePoint = 0xDC00 | codePoint & 0x3FF
  6541. }
  6542. res.push(codePoint)
  6543. i += bytesPerSequence
  6544. }
  6545. return decodeCodePointsArray(res)
  6546. }
  6547. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6548. // the lowest limit is Chrome, with 0x10000 args.
  6549. // We go 1 magnitude less, for safety
  6550. var MAX_ARGUMENTS_LENGTH = 0x1000
  6551. function decodeCodePointsArray (codePoints) {
  6552. var len = codePoints.length
  6553. if (len <= MAX_ARGUMENTS_LENGTH) {
  6554. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6555. }
  6556. // Decode in chunks to avoid "call stack size exceeded".
  6557. var res = ''
  6558. var i = 0
  6559. while (i < len) {
  6560. res += String.fromCharCode.apply(
  6561. String,
  6562. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6563. )
  6564. }
  6565. return res
  6566. }
  6567. function asciiSlice (buf, start, end) {
  6568. var ret = ''
  6569. end = Math.min(buf.length, end)
  6570. for (var i = start; i < end; ++i) {
  6571. ret += String.fromCharCode(buf[i] & 0x7F)
  6572. }
  6573. return ret
  6574. }
  6575. function latin1Slice (buf, start, end) {
  6576. var ret = ''
  6577. end = Math.min(buf.length, end)
  6578. for (var i = start; i < end; ++i) {
  6579. ret += String.fromCharCode(buf[i])
  6580. }
  6581. return ret
  6582. }
  6583. function hexSlice (buf, start, end) {
  6584. var len = buf.length
  6585. if (!start || start < 0) start = 0
  6586. if (!end || end < 0 || end > len) end = len
  6587. var out = ''
  6588. for (var i = start; i < end; ++i) {
  6589. out += toHex(buf[i])
  6590. }
  6591. return out
  6592. }
  6593. function utf16leSlice (buf, start, end) {
  6594. var bytes = buf.slice(start, end)
  6595. var res = ''
  6596. for (var i = 0; i < bytes.length; i += 2) {
  6597. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6598. }
  6599. return res
  6600. }
  6601. Buffer.prototype.slice = function slice (start, end) {
  6602. var len = this.length
  6603. start = ~~start
  6604. end = end === undefined ? len : ~~end
  6605. if (start < 0) {
  6606. start += len
  6607. if (start < 0) start = 0
  6608. } else if (start > len) {
  6609. start = len
  6610. }
  6611. if (end < 0) {
  6612. end += len
  6613. if (end < 0) end = 0
  6614. } else if (end > len) {
  6615. end = len
  6616. }
  6617. if (end < start) end = start
  6618. var newBuf
  6619. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6620. newBuf = this.subarray(start, end)
  6621. newBuf.__proto__ = Buffer.prototype
  6622. } else {
  6623. var sliceLen = end - start
  6624. newBuf = new Buffer(sliceLen, undefined)
  6625. for (var i = 0; i < sliceLen; ++i) {
  6626. newBuf[i] = this[i + start]
  6627. }
  6628. }
  6629. return newBuf
  6630. }
  6631. /*
  6632. * Need to make sure that buffer isn't trying to write out of bounds.
  6633. */
  6634. function checkOffset (offset, ext, length) {
  6635. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6636. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6637. }
  6638. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6639. offset = offset | 0
  6640. byteLength = byteLength | 0
  6641. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6642. var val = this[offset]
  6643. var mul = 1
  6644. var i = 0
  6645. while (++i < byteLength && (mul *= 0x100)) {
  6646. val += this[offset + i] * mul
  6647. }
  6648. return val
  6649. }
  6650. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6651. offset = offset | 0
  6652. byteLength = byteLength | 0
  6653. if (!noAssert) {
  6654. checkOffset(offset, byteLength, this.length)
  6655. }
  6656. var val = this[offset + --byteLength]
  6657. var mul = 1
  6658. while (byteLength > 0 && (mul *= 0x100)) {
  6659. val += this[offset + --byteLength] * mul
  6660. }
  6661. return val
  6662. }
  6663. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6664. if (!noAssert) checkOffset(offset, 1, this.length)
  6665. return this[offset]
  6666. }
  6667. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6668. if (!noAssert) checkOffset(offset, 2, this.length)
  6669. return this[offset] | (this[offset + 1] << 8)
  6670. }
  6671. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6672. if (!noAssert) checkOffset(offset, 2, this.length)
  6673. return (this[offset] << 8) | this[offset + 1]
  6674. }
  6675. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6676. if (!noAssert) checkOffset(offset, 4, this.length)
  6677. return ((this[offset]) |
  6678. (this[offset + 1] << 8) |
  6679. (this[offset + 2] << 16)) +
  6680. (this[offset + 3] * 0x1000000)
  6681. }
  6682. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6683. if (!noAssert) checkOffset(offset, 4, this.length)
  6684. return (this[offset] * 0x1000000) +
  6685. ((this[offset + 1] << 16) |
  6686. (this[offset + 2] << 8) |
  6687. this[offset + 3])
  6688. }
  6689. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6690. offset = offset | 0
  6691. byteLength = byteLength | 0
  6692. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6693. var val = this[offset]
  6694. var mul = 1
  6695. var i = 0
  6696. while (++i < byteLength && (mul *= 0x100)) {
  6697. val += this[offset + i] * mul
  6698. }
  6699. mul *= 0x80
  6700. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6701. return val
  6702. }
  6703. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6704. offset = offset | 0
  6705. byteLength = byteLength | 0
  6706. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6707. var i = byteLength
  6708. var mul = 1
  6709. var val = this[offset + --i]
  6710. while (i > 0 && (mul *= 0x100)) {
  6711. val += this[offset + --i] * mul
  6712. }
  6713. mul *= 0x80
  6714. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6715. return val
  6716. }
  6717. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6718. if (!noAssert) checkOffset(offset, 1, this.length)
  6719. if (!(this[offset] & 0x80)) return (this[offset])
  6720. return ((0xff - this[offset] + 1) * -1)
  6721. }
  6722. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6723. if (!noAssert) checkOffset(offset, 2, this.length)
  6724. var val = this[offset] | (this[offset + 1] << 8)
  6725. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6726. }
  6727. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6728. if (!noAssert) checkOffset(offset, 2, this.length)
  6729. var val = this[offset + 1] | (this[offset] << 8)
  6730. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6731. }
  6732. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6733. if (!noAssert) checkOffset(offset, 4, this.length)
  6734. return (this[offset]) |
  6735. (this[offset + 1] << 8) |
  6736. (this[offset + 2] << 16) |
  6737. (this[offset + 3] << 24)
  6738. }
  6739. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6740. if (!noAssert) checkOffset(offset, 4, this.length)
  6741. return (this[offset] << 24) |
  6742. (this[offset + 1] << 16) |
  6743. (this[offset + 2] << 8) |
  6744. (this[offset + 3])
  6745. }
  6746. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6747. if (!noAssert) checkOffset(offset, 4, this.length)
  6748. return ieee754.read(this, offset, true, 23, 4)
  6749. }
  6750. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6751. if (!noAssert) checkOffset(offset, 4, this.length)
  6752. return ieee754.read(this, offset, false, 23, 4)
  6753. }
  6754. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6755. if (!noAssert) checkOffset(offset, 8, this.length)
  6756. return ieee754.read(this, offset, true, 52, 8)
  6757. }
  6758. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6759. if (!noAssert) checkOffset(offset, 8, this.length)
  6760. return ieee754.read(this, offset, false, 52, 8)
  6761. }
  6762. function checkInt (buf, value, offset, ext, max, min) {
  6763. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6764. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6765. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6766. }
  6767. Buffer.prototype.writeUIntLE = function writeUIntLE (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 mul = 1
  6776. var i = 0
  6777. this[offset] = value & 0xFF
  6778. while (++i < byteLength && (mul *= 0x100)) {
  6779. this[offset + i] = (value / mul) & 0xFF
  6780. }
  6781. return offset + byteLength
  6782. }
  6783. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6784. value = +value
  6785. offset = offset | 0
  6786. byteLength = byteLength | 0
  6787. if (!noAssert) {
  6788. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6789. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6790. }
  6791. var i = byteLength - 1
  6792. var mul = 1
  6793. this[offset + i] = value & 0xFF
  6794. while (--i >= 0 && (mul *= 0x100)) {
  6795. this[offset + i] = (value / mul) & 0xFF
  6796. }
  6797. return offset + byteLength
  6798. }
  6799. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6800. value = +value
  6801. offset = offset | 0
  6802. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6803. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6804. this[offset] = (value & 0xff)
  6805. return offset + 1
  6806. }
  6807. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6808. if (value < 0) value = 0xffff + value + 1
  6809. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6810. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6811. (littleEndian ? i : 1 - i) * 8
  6812. }
  6813. }
  6814. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6815. value = +value
  6816. offset = offset | 0
  6817. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6818. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6819. this[offset] = (value & 0xff)
  6820. this[offset + 1] = (value >>> 8)
  6821. } else {
  6822. objectWriteUInt16(this, value, offset, true)
  6823. }
  6824. return offset + 2
  6825. }
  6826. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6827. value = +value
  6828. offset = offset | 0
  6829. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6830. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6831. this[offset] = (value >>> 8)
  6832. this[offset + 1] = (value & 0xff)
  6833. } else {
  6834. objectWriteUInt16(this, value, offset, false)
  6835. }
  6836. return offset + 2
  6837. }
  6838. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6839. if (value < 0) value = 0xffffffff + value + 1
  6840. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6841. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6842. }
  6843. }
  6844. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6845. value = +value
  6846. offset = offset | 0
  6847. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6848. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6849. this[offset + 3] = (value >>> 24)
  6850. this[offset + 2] = (value >>> 16)
  6851. this[offset + 1] = (value >>> 8)
  6852. this[offset] = (value & 0xff)
  6853. } else {
  6854. objectWriteUInt32(this, value, offset, true)
  6855. }
  6856. return offset + 4
  6857. }
  6858. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6859. value = +value
  6860. offset = offset | 0
  6861. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6862. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6863. this[offset] = (value >>> 24)
  6864. this[offset + 1] = (value >>> 16)
  6865. this[offset + 2] = (value >>> 8)
  6866. this[offset + 3] = (value & 0xff)
  6867. } else {
  6868. objectWriteUInt32(this, value, offset, false)
  6869. }
  6870. return offset + 4
  6871. }
  6872. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6873. value = +value
  6874. offset = offset | 0
  6875. if (!noAssert) {
  6876. var limit = Math.pow(2, 8 * byteLength - 1)
  6877. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6878. }
  6879. var i = 0
  6880. var mul = 1
  6881. var sub = 0
  6882. this[offset] = value & 0xFF
  6883. while (++i < byteLength && (mul *= 0x100)) {
  6884. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6885. sub = 1
  6886. }
  6887. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6888. }
  6889. return offset + byteLength
  6890. }
  6891. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6892. value = +value
  6893. offset = offset | 0
  6894. if (!noAssert) {
  6895. var limit = Math.pow(2, 8 * byteLength - 1)
  6896. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6897. }
  6898. var i = byteLength - 1
  6899. var mul = 1
  6900. var sub = 0
  6901. this[offset + i] = value & 0xFF
  6902. while (--i >= 0 && (mul *= 0x100)) {
  6903. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6904. sub = 1
  6905. }
  6906. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6907. }
  6908. return offset + byteLength
  6909. }
  6910. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6911. value = +value
  6912. offset = offset | 0
  6913. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6914. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6915. if (value < 0) value = 0xff + value + 1
  6916. this[offset] = (value & 0xff)
  6917. return offset + 1
  6918. }
  6919. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6920. value = +value
  6921. offset = offset | 0
  6922. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6923. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6924. this[offset] = (value & 0xff)
  6925. this[offset + 1] = (value >>> 8)
  6926. } else {
  6927. objectWriteUInt16(this, value, offset, true)
  6928. }
  6929. return offset + 2
  6930. }
  6931. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6932. value = +value
  6933. offset = offset | 0
  6934. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6935. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6936. this[offset] = (value >>> 8)
  6937. this[offset + 1] = (value & 0xff)
  6938. } else {
  6939. objectWriteUInt16(this, value, offset, false)
  6940. }
  6941. return offset + 2
  6942. }
  6943. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6944. value = +value
  6945. offset = offset | 0
  6946. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6947. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6948. this[offset] = (value & 0xff)
  6949. this[offset + 1] = (value >>> 8)
  6950. this[offset + 2] = (value >>> 16)
  6951. this[offset + 3] = (value >>> 24)
  6952. } else {
  6953. objectWriteUInt32(this, value, offset, true)
  6954. }
  6955. return offset + 4
  6956. }
  6957. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6958. value = +value
  6959. offset = offset | 0
  6960. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6961. if (value < 0) value = 0xffffffff + value + 1
  6962. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6963. this[offset] = (value >>> 24)
  6964. this[offset + 1] = (value >>> 16)
  6965. this[offset + 2] = (value >>> 8)
  6966. this[offset + 3] = (value & 0xff)
  6967. } else {
  6968. objectWriteUInt32(this, value, offset, false)
  6969. }
  6970. return offset + 4
  6971. }
  6972. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6973. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6974. if (offset < 0) throw new RangeError('Index out of range')
  6975. }
  6976. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6977. if (!noAssert) {
  6978. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6979. }
  6980. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6981. return offset + 4
  6982. }
  6983. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6984. return writeFloat(this, value, offset, true, noAssert)
  6985. }
  6986. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6987. return writeFloat(this, value, offset, false, noAssert)
  6988. }
  6989. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6990. if (!noAssert) {
  6991. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6992. }
  6993. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6994. return offset + 8
  6995. }
  6996. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6997. return writeDouble(this, value, offset, true, noAssert)
  6998. }
  6999. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  7000. return writeDouble(this, value, offset, false, noAssert)
  7001. }
  7002. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  7003. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  7004. if (!start) start = 0
  7005. if (!end && end !== 0) end = this.length
  7006. if (targetStart >= target.length) targetStart = target.length
  7007. if (!targetStart) targetStart = 0
  7008. if (end > 0 && end < start) end = start
  7009. // Copy 0 bytes; we're done
  7010. if (end === start) return 0
  7011. if (target.length === 0 || this.length === 0) return 0
  7012. // Fatal error conditions
  7013. if (targetStart < 0) {
  7014. throw new RangeError('targetStart out of bounds')
  7015. }
  7016. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  7017. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  7018. // Are we oob?
  7019. if (end > this.length) end = this.length
  7020. if (target.length - targetStart < end - start) {
  7021. end = target.length - targetStart + start
  7022. }
  7023. var len = end - start
  7024. var i
  7025. if (this === target && start < targetStart && targetStart < end) {
  7026. // descending copy from end
  7027. for (i = len - 1; i >= 0; --i) {
  7028. target[i + targetStart] = this[i + start]
  7029. }
  7030. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  7031. // ascending copy from start
  7032. for (i = 0; i < len; ++i) {
  7033. target[i + targetStart] = this[i + start]
  7034. }
  7035. } else {
  7036. Uint8Array.prototype.set.call(
  7037. target,
  7038. this.subarray(start, start + len),
  7039. targetStart
  7040. )
  7041. }
  7042. return len
  7043. }
  7044. // Usage:
  7045. // buffer.fill(number[, offset[, end]])
  7046. // buffer.fill(buffer[, offset[, end]])
  7047. // buffer.fill(string[, offset[, end]][, encoding])
  7048. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  7049. // Handle string cases:
  7050. if (typeof val === 'string') {
  7051. if (typeof start === 'string') {
  7052. encoding = start
  7053. start = 0
  7054. end = this.length
  7055. } else if (typeof end === 'string') {
  7056. encoding = end
  7057. end = this.length
  7058. }
  7059. if (val.length === 1) {
  7060. var code = val.charCodeAt(0)
  7061. if (code < 256) {
  7062. val = code
  7063. }
  7064. }
  7065. if (encoding !== undefined && typeof encoding !== 'string') {
  7066. throw new TypeError('encoding must be a string')
  7067. }
  7068. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7069. throw new TypeError('Unknown encoding: ' + encoding)
  7070. }
  7071. } else if (typeof val === 'number') {
  7072. val = val & 255
  7073. }
  7074. // Invalid ranges are not set to a default, so can range check early.
  7075. if (start < 0 || this.length < start || this.length < end) {
  7076. throw new RangeError('Out of range index')
  7077. }
  7078. if (end <= start) {
  7079. return this
  7080. }
  7081. start = start >>> 0
  7082. end = end === undefined ? this.length : end >>> 0
  7083. if (!val) val = 0
  7084. var i
  7085. if (typeof val === 'number') {
  7086. for (i = start; i < end; ++i) {
  7087. this[i] = val
  7088. }
  7089. } else {
  7090. var bytes = Buffer.isBuffer(val)
  7091. ? val
  7092. : utf8ToBytes(new Buffer(val, encoding).toString())
  7093. var len = bytes.length
  7094. for (i = 0; i < end - start; ++i) {
  7095. this[i + start] = bytes[i % len]
  7096. }
  7097. }
  7098. return this
  7099. }
  7100. // HELPER FUNCTIONS
  7101. // ================
  7102. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  7103. function base64clean (str) {
  7104. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7105. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  7106. // Node converts strings with length < 2 to ''
  7107. if (str.length < 2) return ''
  7108. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7109. while (str.length % 4 !== 0) {
  7110. str = str + '='
  7111. }
  7112. return str
  7113. }
  7114. function stringtrim (str) {
  7115. if (str.trim) return str.trim()
  7116. return str.replace(/^\s+|\s+$/g, '')
  7117. }
  7118. function toHex (n) {
  7119. if (n < 16) return '0' + n.toString(16)
  7120. return n.toString(16)
  7121. }
  7122. function utf8ToBytes (string, units) {
  7123. units = units || Infinity
  7124. var codePoint
  7125. var length = string.length
  7126. var leadSurrogate = null
  7127. var bytes = []
  7128. for (var i = 0; i < length; ++i) {
  7129. codePoint = string.charCodeAt(i)
  7130. // is surrogate component
  7131. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7132. // last char was a lead
  7133. if (!leadSurrogate) {
  7134. // no lead yet
  7135. if (codePoint > 0xDBFF) {
  7136. // unexpected trail
  7137. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7138. continue
  7139. } else if (i + 1 === length) {
  7140. // unpaired lead
  7141. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7142. continue
  7143. }
  7144. // valid lead
  7145. leadSurrogate = codePoint
  7146. continue
  7147. }
  7148. // 2 leads in a row
  7149. if (codePoint < 0xDC00) {
  7150. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7151. leadSurrogate = codePoint
  7152. continue
  7153. }
  7154. // valid surrogate pair
  7155. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7156. } else if (leadSurrogate) {
  7157. // valid bmp char, but last char was a lead
  7158. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7159. }
  7160. leadSurrogate = null
  7161. // encode utf8
  7162. if (codePoint < 0x80) {
  7163. if ((units -= 1) < 0) break
  7164. bytes.push(codePoint)
  7165. } else if (codePoint < 0x800) {
  7166. if ((units -= 2) < 0) break
  7167. bytes.push(
  7168. codePoint >> 0x6 | 0xC0,
  7169. codePoint & 0x3F | 0x80
  7170. )
  7171. } else if (codePoint < 0x10000) {
  7172. if ((units -= 3) < 0) break
  7173. bytes.push(
  7174. codePoint >> 0xC | 0xE0,
  7175. codePoint >> 0x6 & 0x3F | 0x80,
  7176. codePoint & 0x3F | 0x80
  7177. )
  7178. } else if (codePoint < 0x110000) {
  7179. if ((units -= 4) < 0) break
  7180. bytes.push(
  7181. codePoint >> 0x12 | 0xF0,
  7182. codePoint >> 0xC & 0x3F | 0x80,
  7183. codePoint >> 0x6 & 0x3F | 0x80,
  7184. codePoint & 0x3F | 0x80
  7185. )
  7186. } else {
  7187. throw new Error('Invalid code point')
  7188. }
  7189. }
  7190. return bytes
  7191. }
  7192. function asciiToBytes (str) {
  7193. var byteArray = []
  7194. for (var i = 0; i < str.length; ++i) {
  7195. // Node's code seems to be doing this and not & 0x7F..
  7196. byteArray.push(str.charCodeAt(i) & 0xFF)
  7197. }
  7198. return byteArray
  7199. }
  7200. function utf16leToBytes (str, units) {
  7201. var c, hi, lo
  7202. var byteArray = []
  7203. for (var i = 0; i < str.length; ++i) {
  7204. if ((units -= 2) < 0) break
  7205. c = str.charCodeAt(i)
  7206. hi = c >> 8
  7207. lo = c % 256
  7208. byteArray.push(lo)
  7209. byteArray.push(hi)
  7210. }
  7211. return byteArray
  7212. }
  7213. function base64ToBytes (str) {
  7214. return base64.toByteArray(base64clean(str))
  7215. }
  7216. function blitBuffer (src, dst, offset, length) {
  7217. for (var i = 0; i < length; ++i) {
  7218. if ((i + offset >= dst.length) || (i >= src.length)) break
  7219. dst[i + offset] = src[i]
  7220. }
  7221. return i
  7222. }
  7223. function isnan (val) {
  7224. return val !== val // eslint-disable-line no-self-compare
  7225. }
  7226. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7227. /***/ }),
  7228. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7229. /*!**************************************************!*\
  7230. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7231. \**************************************************/
  7232. /*! no static exports found */
  7233. /***/ (function(module, exports, __webpack_require__) {
  7234. /*!
  7235. * clipboard.js v2.0.4
  7236. * https://zenorocha.github.io/clipboard.js
  7237. *
  7238. * Licensed MIT © Zeno Rocha
  7239. */
  7240. (function webpackUniversalModuleDefinition(root, factory) {
  7241. if(true)
  7242. module.exports = factory();
  7243. else {}
  7244. })(this, function() {
  7245. return /******/ (function(modules) { // webpackBootstrap
  7246. /******/ // The module cache
  7247. /******/ var installedModules = {};
  7248. /******/
  7249. /******/ // The require function
  7250. /******/ function __webpack_require__(moduleId) {
  7251. /******/
  7252. /******/ // Check if module is in cache
  7253. /******/ if(installedModules[moduleId]) {
  7254. /******/ return installedModules[moduleId].exports;
  7255. /******/ }
  7256. /******/ // Create a new module (and put it into the cache)
  7257. /******/ var module = installedModules[moduleId] = {
  7258. /******/ i: moduleId,
  7259. /******/ l: false,
  7260. /******/ exports: {}
  7261. /******/ };
  7262. /******/
  7263. /******/ // Execute the module function
  7264. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7265. /******/
  7266. /******/ // Flag the module as loaded
  7267. /******/ module.l = true;
  7268. /******/
  7269. /******/ // Return the exports of the module
  7270. /******/ return module.exports;
  7271. /******/ }
  7272. /******/
  7273. /******/
  7274. /******/ // expose the modules object (__webpack_modules__)
  7275. /******/ __webpack_require__.m = modules;
  7276. /******/
  7277. /******/ // expose the module cache
  7278. /******/ __webpack_require__.c = installedModules;
  7279. /******/
  7280. /******/ // define getter function for harmony exports
  7281. /******/ __webpack_require__.d = function(exports, name, getter) {
  7282. /******/ if(!__webpack_require__.o(exports, name)) {
  7283. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7284. /******/ }
  7285. /******/ };
  7286. /******/
  7287. /******/ // define __esModule on exports
  7288. /******/ __webpack_require__.r = function(exports) {
  7289. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7290. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7291. /******/ }
  7292. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7293. /******/ };
  7294. /******/
  7295. /******/ // create a fake namespace object
  7296. /******/ // mode & 1: value is a module id, require it
  7297. /******/ // mode & 2: merge all properties of value into the ns
  7298. /******/ // mode & 4: return value when already ns object
  7299. /******/ // mode & 8|1: behave like require
  7300. /******/ __webpack_require__.t = function(value, mode) {
  7301. /******/ if(mode & 1) value = __webpack_require__(value);
  7302. /******/ if(mode & 8) return value;
  7303. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7304. /******/ var ns = Object.create(null);
  7305. /******/ __webpack_require__.r(ns);
  7306. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7307. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7308. /******/ return ns;
  7309. /******/ };
  7310. /******/
  7311. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7312. /******/ __webpack_require__.n = function(module) {
  7313. /******/ var getter = module && module.__esModule ?
  7314. /******/ function getDefault() { return module['default']; } :
  7315. /******/ function getModuleExports() { return module; };
  7316. /******/ __webpack_require__.d(getter, 'a', getter);
  7317. /******/ return getter;
  7318. /******/ };
  7319. /******/
  7320. /******/ // Object.prototype.hasOwnProperty.call
  7321. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7322. /******/
  7323. /******/ // __webpack_public_path__
  7324. /******/ __webpack_require__.p = "";
  7325. /******/
  7326. /******/
  7327. /******/ // Load entry module and return exports
  7328. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7329. /******/ })
  7330. /************************************************************************/
  7331. /******/ ([
  7332. /* 0 */
  7333. /***/ (function(module, exports, __webpack_require__) {
  7334. "use strict";
  7335. 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; };
  7336. 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; }; }();
  7337. var _clipboardAction = __webpack_require__(1);
  7338. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7339. var _tinyEmitter = __webpack_require__(3);
  7340. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7341. var _goodListener = __webpack_require__(4);
  7342. var _goodListener2 = _interopRequireDefault(_goodListener);
  7343. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7344. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7345. 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; }
  7346. 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; }
  7347. /**
  7348. * Base class which takes one or more elements, adds event listeners to them,
  7349. * and instantiates a new `ClipboardAction` on each click.
  7350. */
  7351. var Clipboard = function (_Emitter) {
  7352. _inherits(Clipboard, _Emitter);
  7353. /**
  7354. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7355. * @param {Object} options
  7356. */
  7357. function Clipboard(trigger, options) {
  7358. _classCallCheck(this, Clipboard);
  7359. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7360. _this.resolveOptions(options);
  7361. _this.listenClick(trigger);
  7362. return _this;
  7363. }
  7364. /**
  7365. * Defines if attributes would be resolved using internal setter functions
  7366. * or custom functions that were passed in the constructor.
  7367. * @param {Object} options
  7368. */
  7369. _createClass(Clipboard, [{
  7370. key: 'resolveOptions',
  7371. value: function resolveOptions() {
  7372. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7373. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7374. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7375. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7376. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7377. }
  7378. /**
  7379. * Adds a click event listener to the passed trigger.
  7380. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7381. */
  7382. }, {
  7383. key: 'listenClick',
  7384. value: function listenClick(trigger) {
  7385. var _this2 = this;
  7386. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7387. return _this2.onClick(e);
  7388. });
  7389. }
  7390. /**
  7391. * Defines a new `ClipboardAction` on each click event.
  7392. * @param {Event} e
  7393. */
  7394. }, {
  7395. key: 'onClick',
  7396. value: function onClick(e) {
  7397. var trigger = e.delegateTarget || e.currentTarget;
  7398. if (this.clipboardAction) {
  7399. this.clipboardAction = null;
  7400. }
  7401. this.clipboardAction = new _clipboardAction2.default({
  7402. action: this.action(trigger),
  7403. target: this.target(trigger),
  7404. text: this.text(trigger),
  7405. container: this.container,
  7406. trigger: trigger,
  7407. emitter: this
  7408. });
  7409. }
  7410. /**
  7411. * Default `action` lookup function.
  7412. * @param {Element} trigger
  7413. */
  7414. }, {
  7415. key: 'defaultAction',
  7416. value: function defaultAction(trigger) {
  7417. return getAttributeValue('action', trigger);
  7418. }
  7419. /**
  7420. * Default `target` lookup function.
  7421. * @param {Element} trigger
  7422. */
  7423. }, {
  7424. key: 'defaultTarget',
  7425. value: function defaultTarget(trigger) {
  7426. var selector = getAttributeValue('target', trigger);
  7427. if (selector) {
  7428. return document.querySelector(selector);
  7429. }
  7430. }
  7431. /**
  7432. * Returns the support of the given action, or all actions if no action is
  7433. * given.
  7434. * @param {String} [action]
  7435. */
  7436. }, {
  7437. key: 'defaultText',
  7438. /**
  7439. * Default `text` lookup function.
  7440. * @param {Element} trigger
  7441. */
  7442. value: function defaultText(trigger) {
  7443. return getAttributeValue('text', trigger);
  7444. }
  7445. /**
  7446. * Destroy lifecycle.
  7447. */
  7448. }, {
  7449. key: 'destroy',
  7450. value: function destroy() {
  7451. this.listener.destroy();
  7452. if (this.clipboardAction) {
  7453. this.clipboardAction.destroy();
  7454. this.clipboardAction = null;
  7455. }
  7456. }
  7457. }], [{
  7458. key: 'isSupported',
  7459. value: function isSupported() {
  7460. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7461. var actions = typeof action === 'string' ? [action] : action;
  7462. var support = !!document.queryCommandSupported;
  7463. actions.forEach(function (action) {
  7464. support = support && !!document.queryCommandSupported(action);
  7465. });
  7466. return support;
  7467. }
  7468. }]);
  7469. return Clipboard;
  7470. }(_tinyEmitter2.default);
  7471. /**
  7472. * Helper function to retrieve attribute value.
  7473. * @param {String} suffix
  7474. * @param {Element} element
  7475. */
  7476. function getAttributeValue(suffix, element) {
  7477. var attribute = 'data-clipboard-' + suffix;
  7478. if (!element.hasAttribute(attribute)) {
  7479. return;
  7480. }
  7481. return element.getAttribute(attribute);
  7482. }
  7483. module.exports = Clipboard;
  7484. /***/ }),
  7485. /* 1 */
  7486. /***/ (function(module, exports, __webpack_require__) {
  7487. "use strict";
  7488. 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; };
  7489. 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; }; }();
  7490. var _select = __webpack_require__(2);
  7491. var _select2 = _interopRequireDefault(_select);
  7492. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7493. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7494. /**
  7495. * Inner class which performs selection from either `text` or `target`
  7496. * properties and then executes copy or cut operations.
  7497. */
  7498. var ClipboardAction = function () {
  7499. /**
  7500. * @param {Object} options
  7501. */
  7502. function ClipboardAction(options) {
  7503. _classCallCheck(this, ClipboardAction);
  7504. this.resolveOptions(options);
  7505. this.initSelection();
  7506. }
  7507. /**
  7508. * Defines base properties passed from constructor.
  7509. * @param {Object} options
  7510. */
  7511. _createClass(ClipboardAction, [{
  7512. key: 'resolveOptions',
  7513. value: function resolveOptions() {
  7514. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7515. this.action = options.action;
  7516. this.container = options.container;
  7517. this.emitter = options.emitter;
  7518. this.target = options.target;
  7519. this.text = options.text;
  7520. this.trigger = options.trigger;
  7521. this.selectedText = '';
  7522. }
  7523. /**
  7524. * Decides which selection strategy is going to be applied based
  7525. * on the existence of `text` and `target` properties.
  7526. */
  7527. }, {
  7528. key: 'initSelection',
  7529. value: function initSelection() {
  7530. if (this.text) {
  7531. this.selectFake();
  7532. } else if (this.target) {
  7533. this.selectTarget();
  7534. }
  7535. }
  7536. /**
  7537. * Creates a fake textarea element, sets its value from `text` property,
  7538. * and makes a selection on it.
  7539. */
  7540. }, {
  7541. key: 'selectFake',
  7542. value: function selectFake() {
  7543. var _this = this;
  7544. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7545. this.removeFake();
  7546. this.fakeHandlerCallback = function () {
  7547. return _this.removeFake();
  7548. };
  7549. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7550. this.fakeElem = document.createElement('textarea');
  7551. // Prevent zooming on iOS
  7552. this.fakeElem.style.fontSize = '12pt';
  7553. // Reset box model
  7554. this.fakeElem.style.border = '0';
  7555. this.fakeElem.style.padding = '0';
  7556. this.fakeElem.style.margin = '0';
  7557. // Move element out of screen horizontally
  7558. this.fakeElem.style.position = 'absolute';
  7559. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7560. // Move element to the same position vertically
  7561. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7562. this.fakeElem.style.top = yPosition + 'px';
  7563. this.fakeElem.setAttribute('readonly', '');
  7564. this.fakeElem.value = this.text;
  7565. this.container.appendChild(this.fakeElem);
  7566. this.selectedText = (0, _select2.default)(this.fakeElem);
  7567. this.copyText();
  7568. }
  7569. /**
  7570. * Only removes the fake element after another click event, that way
  7571. * a user can hit `Ctrl+C` to copy because selection still exists.
  7572. */
  7573. }, {
  7574. key: 'removeFake',
  7575. value: function removeFake() {
  7576. if (this.fakeHandler) {
  7577. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7578. this.fakeHandler = null;
  7579. this.fakeHandlerCallback = null;
  7580. }
  7581. if (this.fakeElem) {
  7582. this.container.removeChild(this.fakeElem);
  7583. this.fakeElem = null;
  7584. }
  7585. }
  7586. /**
  7587. * Selects the content from element passed on `target` property.
  7588. */
  7589. }, {
  7590. key: 'selectTarget',
  7591. value: function selectTarget() {
  7592. this.selectedText = (0, _select2.default)(this.target);
  7593. this.copyText();
  7594. }
  7595. /**
  7596. * Executes the copy operation based on the current selection.
  7597. */
  7598. }, {
  7599. key: 'copyText',
  7600. value: function copyText() {
  7601. var succeeded = void 0;
  7602. try {
  7603. succeeded = document.execCommand(this.action);
  7604. } catch (err) {
  7605. succeeded = false;
  7606. }
  7607. this.handleResult(succeeded);
  7608. }
  7609. /**
  7610. * Fires an event based on the copy operation result.
  7611. * @param {Boolean} succeeded
  7612. */
  7613. }, {
  7614. key: 'handleResult',
  7615. value: function handleResult(succeeded) {
  7616. this.emitter.emit(succeeded ? 'success' : 'error', {
  7617. action: this.action,
  7618. text: this.selectedText,
  7619. trigger: this.trigger,
  7620. clearSelection: this.clearSelection.bind(this)
  7621. });
  7622. }
  7623. /**
  7624. * Moves focus away from `target` and back to the trigger, removes current selection.
  7625. */
  7626. }, {
  7627. key: 'clearSelection',
  7628. value: function clearSelection() {
  7629. if (this.trigger) {
  7630. this.trigger.focus();
  7631. }
  7632. window.getSelection().removeAllRanges();
  7633. }
  7634. /**
  7635. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7636. * @param {String} action
  7637. */
  7638. }, {
  7639. key: 'destroy',
  7640. /**
  7641. * Destroy lifecycle.
  7642. */
  7643. value: function destroy() {
  7644. this.removeFake();
  7645. }
  7646. }, {
  7647. key: 'action',
  7648. set: function set() {
  7649. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7650. this._action = action;
  7651. if (this._action !== 'copy' && this._action !== 'cut') {
  7652. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7653. }
  7654. }
  7655. /**
  7656. * Gets the `action` property.
  7657. * @return {String}
  7658. */
  7659. ,
  7660. get: function get() {
  7661. return this._action;
  7662. }
  7663. /**
  7664. * Sets the `target` property using an element
  7665. * that will be have its content copied.
  7666. * @param {Element} target
  7667. */
  7668. }, {
  7669. key: 'target',
  7670. set: function set(target) {
  7671. if (target !== undefined) {
  7672. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7673. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7674. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7675. }
  7676. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7677. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7678. }
  7679. this._target = target;
  7680. } else {
  7681. throw new Error('Invalid "target" value, use a valid Element');
  7682. }
  7683. }
  7684. }
  7685. /**
  7686. * Gets the `target` property.
  7687. * @return {String|HTMLElement}
  7688. */
  7689. ,
  7690. get: function get() {
  7691. return this._target;
  7692. }
  7693. }]);
  7694. return ClipboardAction;
  7695. }();
  7696. module.exports = ClipboardAction;
  7697. /***/ }),
  7698. /* 2 */
  7699. /***/ (function(module, exports) {
  7700. function select(element) {
  7701. var selectedText;
  7702. if (element.nodeName === 'SELECT') {
  7703. element.focus();
  7704. selectedText = element.value;
  7705. }
  7706. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7707. var isReadOnly = element.hasAttribute('readonly');
  7708. if (!isReadOnly) {
  7709. element.setAttribute('readonly', '');
  7710. }
  7711. element.select();
  7712. element.setSelectionRange(0, element.value.length);
  7713. if (!isReadOnly) {
  7714. element.removeAttribute('readonly');
  7715. }
  7716. selectedText = element.value;
  7717. }
  7718. else {
  7719. if (element.hasAttribute('contenteditable')) {
  7720. element.focus();
  7721. }
  7722. var selection = window.getSelection();
  7723. var range = document.createRange();
  7724. range.selectNodeContents(element);
  7725. selection.removeAllRanges();
  7726. selection.addRange(range);
  7727. selectedText = selection.toString();
  7728. }
  7729. return selectedText;
  7730. }
  7731. module.exports = select;
  7732. /***/ }),
  7733. /* 3 */
  7734. /***/ (function(module, exports) {
  7735. function E () {
  7736. // Keep this empty so it's easier to inherit from
  7737. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7738. }
  7739. E.prototype = {
  7740. on: function (name, callback, ctx) {
  7741. var e = this.e || (this.e = {});
  7742. (e[name] || (e[name] = [])).push({
  7743. fn: callback,
  7744. ctx: ctx
  7745. });
  7746. return this;
  7747. },
  7748. once: function (name, callback, ctx) {
  7749. var self = this;
  7750. function listener () {
  7751. self.off(name, listener);
  7752. callback.apply(ctx, arguments);
  7753. };
  7754. listener._ = callback
  7755. return this.on(name, listener, ctx);
  7756. },
  7757. emit: function (name) {
  7758. var data = [].slice.call(arguments, 1);
  7759. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7760. var i = 0;
  7761. var len = evtArr.length;
  7762. for (i; i < len; i++) {
  7763. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7764. }
  7765. return this;
  7766. },
  7767. off: function (name, callback) {
  7768. var e = this.e || (this.e = {});
  7769. var evts = e[name];
  7770. var liveEvents = [];
  7771. if (evts && callback) {
  7772. for (var i = 0, len = evts.length; i < len; i++) {
  7773. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7774. liveEvents.push(evts[i]);
  7775. }
  7776. }
  7777. // Remove event from queue to prevent memory leak
  7778. // Suggested by https://github.com/lazd
  7779. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7780. (liveEvents.length)
  7781. ? e[name] = liveEvents
  7782. : delete e[name];
  7783. return this;
  7784. }
  7785. };
  7786. module.exports = E;
  7787. /***/ }),
  7788. /* 4 */
  7789. /***/ (function(module, exports, __webpack_require__) {
  7790. var is = __webpack_require__(5);
  7791. var delegate = __webpack_require__(6);
  7792. /**
  7793. * Validates all params and calls the right
  7794. * listener function based on its target type.
  7795. *
  7796. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7797. * @param {String} type
  7798. * @param {Function} callback
  7799. * @return {Object}
  7800. */
  7801. function listen(target, type, callback) {
  7802. if (!target && !type && !callback) {
  7803. throw new Error('Missing required arguments');
  7804. }
  7805. if (!is.string(type)) {
  7806. throw new TypeError('Second argument must be a String');
  7807. }
  7808. if (!is.fn(callback)) {
  7809. throw new TypeError('Third argument must be a Function');
  7810. }
  7811. if (is.node(target)) {
  7812. return listenNode(target, type, callback);
  7813. }
  7814. else if (is.nodeList(target)) {
  7815. return listenNodeList(target, type, callback);
  7816. }
  7817. else if (is.string(target)) {
  7818. return listenSelector(target, type, callback);
  7819. }
  7820. else {
  7821. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7822. }
  7823. }
  7824. /**
  7825. * Adds an event listener to a HTML element
  7826. * and returns a remove listener function.
  7827. *
  7828. * @param {HTMLElement} node
  7829. * @param {String} type
  7830. * @param {Function} callback
  7831. * @return {Object}
  7832. */
  7833. function listenNode(node, type, callback) {
  7834. node.addEventListener(type, callback);
  7835. return {
  7836. destroy: function() {
  7837. node.removeEventListener(type, callback);
  7838. }
  7839. }
  7840. }
  7841. /**
  7842. * Add an event listener to a list of HTML elements
  7843. * and returns a remove listener function.
  7844. *
  7845. * @param {NodeList|HTMLCollection} nodeList
  7846. * @param {String} type
  7847. * @param {Function} callback
  7848. * @return {Object}
  7849. */
  7850. function listenNodeList(nodeList, type, callback) {
  7851. Array.prototype.forEach.call(nodeList, function(node) {
  7852. node.addEventListener(type, callback);
  7853. });
  7854. return {
  7855. destroy: function() {
  7856. Array.prototype.forEach.call(nodeList, function(node) {
  7857. node.removeEventListener(type, callback);
  7858. });
  7859. }
  7860. }
  7861. }
  7862. /**
  7863. * Add an event listener to a selector
  7864. * and returns a remove listener function.
  7865. *
  7866. * @param {String} selector
  7867. * @param {String} type
  7868. * @param {Function} callback
  7869. * @return {Object}
  7870. */
  7871. function listenSelector(selector, type, callback) {
  7872. return delegate(document.body, selector, type, callback);
  7873. }
  7874. module.exports = listen;
  7875. /***/ }),
  7876. /* 5 */
  7877. /***/ (function(module, exports) {
  7878. /**
  7879. * Check if argument is a HTML element.
  7880. *
  7881. * @param {Object} value
  7882. * @return {Boolean}
  7883. */
  7884. exports.node = function(value) {
  7885. return value !== undefined
  7886. && value instanceof HTMLElement
  7887. && value.nodeType === 1;
  7888. };
  7889. /**
  7890. * Check if argument is a list of HTML elements.
  7891. *
  7892. * @param {Object} value
  7893. * @return {Boolean}
  7894. */
  7895. exports.nodeList = function(value) {
  7896. var type = Object.prototype.toString.call(value);
  7897. return value !== undefined
  7898. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7899. && ('length' in value)
  7900. && (value.length === 0 || exports.node(value[0]));
  7901. };
  7902. /**
  7903. * Check if argument is a string.
  7904. *
  7905. * @param {Object} value
  7906. * @return {Boolean}
  7907. */
  7908. exports.string = function(value) {
  7909. return typeof value === 'string'
  7910. || value instanceof String;
  7911. };
  7912. /**
  7913. * Check if argument is a function.
  7914. *
  7915. * @param {Object} value
  7916. * @return {Boolean}
  7917. */
  7918. exports.fn = function(value) {
  7919. var type = Object.prototype.toString.call(value);
  7920. return type === '[object Function]';
  7921. };
  7922. /***/ }),
  7923. /* 6 */
  7924. /***/ (function(module, exports, __webpack_require__) {
  7925. var closest = __webpack_require__(7);
  7926. /**
  7927. * Delegates event to a selector.
  7928. *
  7929. * @param {Element} element
  7930. * @param {String} selector
  7931. * @param {String} type
  7932. * @param {Function} callback
  7933. * @param {Boolean} useCapture
  7934. * @return {Object}
  7935. */
  7936. function _delegate(element, selector, type, callback, useCapture) {
  7937. var listenerFn = listener.apply(this, arguments);
  7938. element.addEventListener(type, listenerFn, useCapture);
  7939. return {
  7940. destroy: function() {
  7941. element.removeEventListener(type, listenerFn, useCapture);
  7942. }
  7943. }
  7944. }
  7945. /**
  7946. * Delegates event to a selector.
  7947. *
  7948. * @param {Element|String|Array} [elements]
  7949. * @param {String} selector
  7950. * @param {String} type
  7951. * @param {Function} callback
  7952. * @param {Boolean} useCapture
  7953. * @return {Object}
  7954. */
  7955. function delegate(elements, selector, type, callback, useCapture) {
  7956. // Handle the regular Element usage
  7957. if (typeof elements.addEventListener === 'function') {
  7958. return _delegate.apply(null, arguments);
  7959. }
  7960. // Handle Element-less usage, it defaults to global delegation
  7961. if (typeof type === 'function') {
  7962. // Use `document` as the first parameter, then apply arguments
  7963. // This is a short way to .unshift `arguments` without running into deoptimizations
  7964. return _delegate.bind(null, document).apply(null, arguments);
  7965. }
  7966. // Handle Selector-based usage
  7967. if (typeof elements === 'string') {
  7968. elements = document.querySelectorAll(elements);
  7969. }
  7970. // Handle Array-like based usage
  7971. return Array.prototype.map.call(elements, function (element) {
  7972. return _delegate(element, selector, type, callback, useCapture);
  7973. });
  7974. }
  7975. /**
  7976. * Finds closest match and invokes callback.
  7977. *
  7978. * @param {Element} element
  7979. * @param {String} selector
  7980. * @param {String} type
  7981. * @param {Function} callback
  7982. * @return {Function}
  7983. */
  7984. function listener(element, selector, type, callback) {
  7985. return function(e) {
  7986. e.delegateTarget = closest(e.target, selector);
  7987. if (e.delegateTarget) {
  7988. callback.call(element, e);
  7989. }
  7990. }
  7991. }
  7992. module.exports = delegate;
  7993. /***/ }),
  7994. /* 7 */
  7995. /***/ (function(module, exports) {
  7996. var DOCUMENT_NODE_TYPE = 9;
  7997. /**
  7998. * A polyfill for Element.matches()
  7999. */
  8000. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  8001. var proto = Element.prototype;
  8002. proto.matches = proto.matchesSelector ||
  8003. proto.mozMatchesSelector ||
  8004. proto.msMatchesSelector ||
  8005. proto.oMatchesSelector ||
  8006. proto.webkitMatchesSelector;
  8007. }
  8008. /**
  8009. * Finds the closest parent that matches a selector.
  8010. *
  8011. * @param {Element} element
  8012. * @param {String} selector
  8013. * @return {Function}
  8014. */
  8015. function closest (element, selector) {
  8016. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  8017. if (typeof element.matches === 'function' &&
  8018. element.matches(selector)) {
  8019. return element;
  8020. }
  8021. element = element.parentNode;
  8022. }
  8023. }
  8024. module.exports = closest;
  8025. /***/ })
  8026. /******/ ]);
  8027. });
  8028. /***/ }),
  8029. /***/ "./node_modules/ieee754/index.js":
  8030. /*!***************************************!*\
  8031. !*** ./node_modules/ieee754/index.js ***!
  8032. \***************************************/
  8033. /*! no static exports found */
  8034. /***/ (function(module, exports) {
  8035. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  8036. var e, m
  8037. var eLen = (nBytes * 8) - mLen - 1
  8038. var eMax = (1 << eLen) - 1
  8039. var eBias = eMax >> 1
  8040. var nBits = -7
  8041. var i = isLE ? (nBytes - 1) : 0
  8042. var d = isLE ? -1 : 1
  8043. var s = buffer[offset + i]
  8044. i += d
  8045. e = s & ((1 << (-nBits)) - 1)
  8046. s >>= (-nBits)
  8047. nBits += eLen
  8048. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8049. m = e & ((1 << (-nBits)) - 1)
  8050. e >>= (-nBits)
  8051. nBits += mLen
  8052. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  8053. if (e === 0) {
  8054. e = 1 - eBias
  8055. } else if (e === eMax) {
  8056. return m ? NaN : ((s ? -1 : 1) * Infinity)
  8057. } else {
  8058. m = m + Math.pow(2, mLen)
  8059. e = e - eBias
  8060. }
  8061. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  8062. }
  8063. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  8064. var e, m, c
  8065. var eLen = (nBytes * 8) - mLen - 1
  8066. var eMax = (1 << eLen) - 1
  8067. var eBias = eMax >> 1
  8068. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  8069. var i = isLE ? 0 : (nBytes - 1)
  8070. var d = isLE ? 1 : -1
  8071. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  8072. value = Math.abs(value)
  8073. if (isNaN(value) || value === Infinity) {
  8074. m = isNaN(value) ? 1 : 0
  8075. e = eMax
  8076. } else {
  8077. e = Math.floor(Math.log(value) / Math.LN2)
  8078. if (value * (c = Math.pow(2, -e)) < 1) {
  8079. e--
  8080. c *= 2
  8081. }
  8082. if (e + eBias >= 1) {
  8083. value += rt / c
  8084. } else {
  8085. value += rt * Math.pow(2, 1 - eBias)
  8086. }
  8087. if (value * c >= 2) {
  8088. e++
  8089. c /= 2
  8090. }
  8091. if (e + eBias >= eMax) {
  8092. m = 0
  8093. e = eMax
  8094. } else if (e + eBias >= 1) {
  8095. m = ((value * c) - 1) * Math.pow(2, mLen)
  8096. e = e + eBias
  8097. } else {
  8098. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  8099. e = 0
  8100. }
  8101. }
  8102. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  8103. e = (e << mLen) | m
  8104. eLen += mLen
  8105. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  8106. buffer[offset + i - d] |= s * 128
  8107. }
  8108. /***/ }),
  8109. /***/ "./node_modules/isarray/index.js":
  8110. /*!***************************************!*\
  8111. !*** ./node_modules/isarray/index.js ***!
  8112. \***************************************/
  8113. /*! no static exports found */
  8114. /***/ (function(module, exports) {
  8115. var toString = {}.toString;
  8116. module.exports = Array.isArray || function (arr) {
  8117. return toString.call(arr) == '[object Array]';
  8118. };
  8119. /***/ }),
  8120. /***/ "./node_modules/jquery/dist/jquery.js":
  8121. /*!********************************************!*\
  8122. !*** ./node_modules/jquery/dist/jquery.js ***!
  8123. \********************************************/
  8124. /*! no static exports found */
  8125. /***/ (function(module, exports, __webpack_require__) {
  8126. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8127. * jQuery JavaScript Library v3.4.1
  8128. * https://jquery.com/
  8129. *
  8130. * Includes Sizzle.js
  8131. * https://sizzlejs.com/
  8132. *
  8133. * Copyright JS Foundation and other contributors
  8134. * Released under the MIT license
  8135. * https://jquery.org/license
  8136. *
  8137. * Date: 2019-05-01T21:04Z
  8138. */
  8139. ( function( global, factory ) {
  8140. "use strict";
  8141. if ( true && typeof module.exports === "object" ) {
  8142. // For CommonJS and CommonJS-like environments where a proper `window`
  8143. // is present, execute the factory and get jQuery.
  8144. // For environments that do not have a `window` with a `document`
  8145. // (such as Node.js), expose a factory as module.exports.
  8146. // This accentuates the need for the creation of a real `window`.
  8147. // e.g. var jQuery = require("jquery")(window);
  8148. // See ticket #14549 for more info.
  8149. module.exports = global.document ?
  8150. factory( global, true ) :
  8151. function( w ) {
  8152. if ( !w.document ) {
  8153. throw new Error( "jQuery requires a window with a document" );
  8154. }
  8155. return factory( w );
  8156. };
  8157. } else {
  8158. factory( global );
  8159. }
  8160. // Pass this if window is not defined yet
  8161. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8162. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8163. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8164. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8165. // enough that all such attempts are guarded in a try block.
  8166. "use strict";
  8167. var arr = [];
  8168. var document = window.document;
  8169. var getProto = Object.getPrototypeOf;
  8170. var slice = arr.slice;
  8171. var concat = arr.concat;
  8172. var push = arr.push;
  8173. var indexOf = arr.indexOf;
  8174. var class2type = {};
  8175. var toString = class2type.toString;
  8176. var hasOwn = class2type.hasOwnProperty;
  8177. var fnToString = hasOwn.toString;
  8178. var ObjectFunctionString = fnToString.call( Object );
  8179. var support = {};
  8180. var isFunction = function isFunction( obj ) {
  8181. // Support: Chrome <=57, Firefox <=52
  8182. // In some browsers, typeof returns "function" for HTML <object> elements
  8183. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8184. // We don't want to classify *any* DOM node as a function.
  8185. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8186. };
  8187. var isWindow = function isWindow( obj ) {
  8188. return obj != null && obj === obj.window;
  8189. };
  8190. var preservedScriptAttributes = {
  8191. type: true,
  8192. src: true,
  8193. nonce: true,
  8194. noModule: true
  8195. };
  8196. function DOMEval( code, node, doc ) {
  8197. doc = doc || document;
  8198. var i, val,
  8199. script = doc.createElement( "script" );
  8200. script.text = code;
  8201. if ( node ) {
  8202. for ( i in preservedScriptAttributes ) {
  8203. // Support: Firefox 64+, Edge 18+
  8204. // Some browsers don't support the "nonce" property on scripts.
  8205. // On the other hand, just using `getAttribute` is not enough as
  8206. // the `nonce` attribute is reset to an empty string whenever it
  8207. // becomes browsing-context connected.
  8208. // See https://github.com/whatwg/html/issues/2369
  8209. // See https://html.spec.whatwg.org/#nonce-attributes
  8210. // The `node.getAttribute` check was added for the sake of
  8211. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8212. // via an object.
  8213. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8214. if ( val ) {
  8215. script.setAttribute( i, val );
  8216. }
  8217. }
  8218. }
  8219. doc.head.appendChild( script ).parentNode.removeChild( script );
  8220. }
  8221. function toType( obj ) {
  8222. if ( obj == null ) {
  8223. return obj + "";
  8224. }
  8225. // Support: Android <=2.3 only (functionish RegExp)
  8226. return typeof obj === "object" || typeof obj === "function" ?
  8227. class2type[ toString.call( obj ) ] || "object" :
  8228. typeof obj;
  8229. }
  8230. /* global Symbol */
  8231. // Defining this global in .eslintrc.json would create a danger of using the global
  8232. // unguarded in another place, it seems safer to define global only for this module
  8233. var
  8234. version = "3.4.1",
  8235. // Define a local copy of jQuery
  8236. jQuery = function( selector, context ) {
  8237. // The jQuery object is actually just the init constructor 'enhanced'
  8238. // Need init if jQuery is called (just allow error to be thrown if not included)
  8239. return new jQuery.fn.init( selector, context );
  8240. },
  8241. // Support: Android <=4.0 only
  8242. // Make sure we trim BOM and NBSP
  8243. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8244. jQuery.fn = jQuery.prototype = {
  8245. // The current version of jQuery being used
  8246. jquery: version,
  8247. constructor: jQuery,
  8248. // The default length of a jQuery object is 0
  8249. length: 0,
  8250. toArray: function() {
  8251. return slice.call( this );
  8252. },
  8253. // Get the Nth element in the matched element set OR
  8254. // Get the whole matched element set as a clean array
  8255. get: function( num ) {
  8256. // Return all the elements in a clean array
  8257. if ( num == null ) {
  8258. return slice.call( this );
  8259. }
  8260. // Return just the one element from the set
  8261. return num < 0 ? this[ num + this.length ] : this[ num ];
  8262. },
  8263. // Take an array of elements and push it onto the stack
  8264. // (returning the new matched element set)
  8265. pushStack: function( elems ) {
  8266. // Build a new jQuery matched element set
  8267. var ret = jQuery.merge( this.constructor(), elems );
  8268. // Add the old object onto the stack (as a reference)
  8269. ret.prevObject = this;
  8270. // Return the newly-formed element set
  8271. return ret;
  8272. },
  8273. // Execute a callback for every element in the matched set.
  8274. each: function( callback ) {
  8275. return jQuery.each( this, callback );
  8276. },
  8277. map: function( callback ) {
  8278. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8279. return callback.call( elem, i, elem );
  8280. } ) );
  8281. },
  8282. slice: function() {
  8283. return this.pushStack( slice.apply( this, arguments ) );
  8284. },
  8285. first: function() {
  8286. return this.eq( 0 );
  8287. },
  8288. last: function() {
  8289. return this.eq( -1 );
  8290. },
  8291. eq: function( i ) {
  8292. var len = this.length,
  8293. j = +i + ( i < 0 ? len : 0 );
  8294. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8295. },
  8296. end: function() {
  8297. return this.prevObject || this.constructor();
  8298. },
  8299. // For internal use only.
  8300. // Behaves like an Array's method, not like a jQuery method.
  8301. push: push,
  8302. sort: arr.sort,
  8303. splice: arr.splice
  8304. };
  8305. jQuery.extend = jQuery.fn.extend = function() {
  8306. var options, name, src, copy, copyIsArray, clone,
  8307. target = arguments[ 0 ] || {},
  8308. i = 1,
  8309. length = arguments.length,
  8310. deep = false;
  8311. // Handle a deep copy situation
  8312. if ( typeof target === "boolean" ) {
  8313. deep = target;
  8314. // Skip the boolean and the target
  8315. target = arguments[ i ] || {};
  8316. i++;
  8317. }
  8318. // Handle case when target is a string or something (possible in deep copy)
  8319. if ( typeof target !== "object" && !isFunction( target ) ) {
  8320. target = {};
  8321. }
  8322. // Extend jQuery itself if only one argument is passed
  8323. if ( i === length ) {
  8324. target = this;
  8325. i--;
  8326. }
  8327. for ( ; i < length; i++ ) {
  8328. // Only deal with non-null/undefined values
  8329. if ( ( options = arguments[ i ] ) != null ) {
  8330. // Extend the base object
  8331. for ( name in options ) {
  8332. copy = options[ name ];
  8333. // Prevent Object.prototype pollution
  8334. // Prevent never-ending loop
  8335. if ( name === "__proto__" || target === copy ) {
  8336. continue;
  8337. }
  8338. // Recurse if we're merging plain objects or arrays
  8339. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8340. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8341. src = target[ name ];
  8342. // Ensure proper type for the source value
  8343. if ( copyIsArray && !Array.isArray( src ) ) {
  8344. clone = [];
  8345. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8346. clone = {};
  8347. } else {
  8348. clone = src;
  8349. }
  8350. copyIsArray = false;
  8351. // Never move original objects, clone them
  8352. target[ name ] = jQuery.extend( deep, clone, copy );
  8353. // Don't bring in undefined values
  8354. } else if ( copy !== undefined ) {
  8355. target[ name ] = copy;
  8356. }
  8357. }
  8358. }
  8359. }
  8360. // Return the modified object
  8361. return target;
  8362. };
  8363. jQuery.extend( {
  8364. // Unique for each copy of jQuery on the page
  8365. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8366. // Assume jQuery is ready without the ready module
  8367. isReady: true,
  8368. error: function( msg ) {
  8369. throw new Error( msg );
  8370. },
  8371. noop: function() {},
  8372. isPlainObject: function( obj ) {
  8373. var proto, Ctor;
  8374. // Detect obvious negatives
  8375. // Use toString instead of jQuery.type to catch host objects
  8376. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8377. return false;
  8378. }
  8379. proto = getProto( obj );
  8380. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8381. if ( !proto ) {
  8382. return true;
  8383. }
  8384. // Objects with prototype are plain iff they were constructed by a global Object function
  8385. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8386. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8387. },
  8388. isEmptyObject: function( obj ) {
  8389. var name;
  8390. for ( name in obj ) {
  8391. return false;
  8392. }
  8393. return true;
  8394. },
  8395. // Evaluates a script in a global context
  8396. globalEval: function( code, options ) {
  8397. DOMEval( code, { nonce: options && options.nonce } );
  8398. },
  8399. each: function( obj, callback ) {
  8400. var length, i = 0;
  8401. if ( isArrayLike( obj ) ) {
  8402. length = obj.length;
  8403. for ( ; i < length; i++ ) {
  8404. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8405. break;
  8406. }
  8407. }
  8408. } else {
  8409. for ( i in obj ) {
  8410. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8411. break;
  8412. }
  8413. }
  8414. }
  8415. return obj;
  8416. },
  8417. // Support: Android <=4.0 only
  8418. trim: function( text ) {
  8419. return text == null ?
  8420. "" :
  8421. ( text + "" ).replace( rtrim, "" );
  8422. },
  8423. // results is for internal usage only
  8424. makeArray: function( arr, results ) {
  8425. var ret = results || [];
  8426. if ( arr != null ) {
  8427. if ( isArrayLike( Object( arr ) ) ) {
  8428. jQuery.merge( ret,
  8429. typeof arr === "string" ?
  8430. [ arr ] : arr
  8431. );
  8432. } else {
  8433. push.call( ret, arr );
  8434. }
  8435. }
  8436. return ret;
  8437. },
  8438. inArray: function( elem, arr, i ) {
  8439. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8440. },
  8441. // Support: Android <=4.0 only, PhantomJS 1 only
  8442. // push.apply(_, arraylike) throws on ancient WebKit
  8443. merge: function( first, second ) {
  8444. var len = +second.length,
  8445. j = 0,
  8446. i = first.length;
  8447. for ( ; j < len; j++ ) {
  8448. first[ i++ ] = second[ j ];
  8449. }
  8450. first.length = i;
  8451. return first;
  8452. },
  8453. grep: function( elems, callback, invert ) {
  8454. var callbackInverse,
  8455. matches = [],
  8456. i = 0,
  8457. length = elems.length,
  8458. callbackExpect = !invert;
  8459. // Go through the array, only saving the items
  8460. // that pass the validator function
  8461. for ( ; i < length; i++ ) {
  8462. callbackInverse = !callback( elems[ i ], i );
  8463. if ( callbackInverse !== callbackExpect ) {
  8464. matches.push( elems[ i ] );
  8465. }
  8466. }
  8467. return matches;
  8468. },
  8469. // arg is for internal usage only
  8470. map: function( elems, callback, arg ) {
  8471. var length, value,
  8472. i = 0,
  8473. ret = [];
  8474. // Go through the array, translating each of the items to their new values
  8475. if ( isArrayLike( elems ) ) {
  8476. length = elems.length;
  8477. for ( ; i < length; i++ ) {
  8478. value = callback( elems[ i ], i, arg );
  8479. if ( value != null ) {
  8480. ret.push( value );
  8481. }
  8482. }
  8483. // Go through every key on the object,
  8484. } else {
  8485. for ( i in elems ) {
  8486. value = callback( elems[ i ], i, arg );
  8487. if ( value != null ) {
  8488. ret.push( value );
  8489. }
  8490. }
  8491. }
  8492. // Flatten any nested arrays
  8493. return concat.apply( [], ret );
  8494. },
  8495. // A global GUID counter for objects
  8496. guid: 1,
  8497. // jQuery.support is not used in Core but other projects attach their
  8498. // properties to it so it needs to exist.
  8499. support: support
  8500. } );
  8501. if ( typeof Symbol === "function" ) {
  8502. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8503. }
  8504. // Populate the class2type map
  8505. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8506. function( i, name ) {
  8507. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8508. } );
  8509. function isArrayLike( obj ) {
  8510. // Support: real iOS 8.2 only (not reproducible in simulator)
  8511. // `in` check used to prevent JIT error (gh-2145)
  8512. // hasOwn isn't used here due to false negatives
  8513. // regarding Nodelist length in IE
  8514. var length = !!obj && "length" in obj && obj.length,
  8515. type = toType( obj );
  8516. if ( isFunction( obj ) || isWindow( obj ) ) {
  8517. return false;
  8518. }
  8519. return type === "array" || length === 0 ||
  8520. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8521. }
  8522. var Sizzle =
  8523. /*!
  8524. * Sizzle CSS Selector Engine v2.3.4
  8525. * https://sizzlejs.com/
  8526. *
  8527. * Copyright JS Foundation and other contributors
  8528. * Released under the MIT license
  8529. * https://js.foundation/
  8530. *
  8531. * Date: 2019-04-08
  8532. */
  8533. (function( window ) {
  8534. var i,
  8535. support,
  8536. Expr,
  8537. getText,
  8538. isXML,
  8539. tokenize,
  8540. compile,
  8541. select,
  8542. outermostContext,
  8543. sortInput,
  8544. hasDuplicate,
  8545. // Local document vars
  8546. setDocument,
  8547. document,
  8548. docElem,
  8549. documentIsHTML,
  8550. rbuggyQSA,
  8551. rbuggyMatches,
  8552. matches,
  8553. contains,
  8554. // Instance-specific data
  8555. expando = "sizzle" + 1 * new Date(),
  8556. preferredDoc = window.document,
  8557. dirruns = 0,
  8558. done = 0,
  8559. classCache = createCache(),
  8560. tokenCache = createCache(),
  8561. compilerCache = createCache(),
  8562. nonnativeSelectorCache = createCache(),
  8563. sortOrder = function( a, b ) {
  8564. if ( a === b ) {
  8565. hasDuplicate = true;
  8566. }
  8567. return 0;
  8568. },
  8569. // Instance methods
  8570. hasOwn = ({}).hasOwnProperty,
  8571. arr = [],
  8572. pop = arr.pop,
  8573. push_native = arr.push,
  8574. push = arr.push,
  8575. slice = arr.slice,
  8576. // Use a stripped-down indexOf as it's faster than native
  8577. // https://jsperf.com/thor-indexof-vs-for/5
  8578. indexOf = function( list, elem ) {
  8579. var i = 0,
  8580. len = list.length;
  8581. for ( ; i < len; i++ ) {
  8582. if ( list[i] === elem ) {
  8583. return i;
  8584. }
  8585. }
  8586. return -1;
  8587. },
  8588. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8589. // Regular expressions
  8590. // http://www.w3.org/TR/css3-selectors/#whitespace
  8591. whitespace = "[\\x20\\t\\r\\n\\f]",
  8592. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8593. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8594. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8595. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8596. // Operator (capture 2)
  8597. "*([*^$|!~]?=)" + whitespace +
  8598. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8599. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8600. "*\\]",
  8601. pseudos = ":(" + identifier + ")(?:\\((" +
  8602. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8603. // 1. quoted (capture 3; capture 4 or capture 5)
  8604. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8605. // 2. simple (capture 6)
  8606. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8607. // 3. anything else (capture 2)
  8608. ".*" +
  8609. ")\\)|)",
  8610. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8611. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8612. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8613. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8614. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8615. rdescend = new RegExp( whitespace + "|>" ),
  8616. rpseudo = new RegExp( pseudos ),
  8617. ridentifier = new RegExp( "^" + identifier + "$" ),
  8618. matchExpr = {
  8619. "ID": new RegExp( "^#(" + identifier + ")" ),
  8620. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8621. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8622. "ATTR": new RegExp( "^" + attributes ),
  8623. "PSEUDO": new RegExp( "^" + pseudos ),
  8624. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8625. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8626. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8627. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8628. // For use in libraries implementing .is()
  8629. // We use this for POS matching in `select`
  8630. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8631. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8632. },
  8633. rhtml = /HTML$/i,
  8634. rinputs = /^(?:input|select|textarea|button)$/i,
  8635. rheader = /^h\d$/i,
  8636. rnative = /^[^{]+\{\s*\[native \w/,
  8637. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8638. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8639. rsibling = /[+~]/,
  8640. // CSS escapes
  8641. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8642. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8643. funescape = function( _, escaped, escapedWhitespace ) {
  8644. var high = "0x" + escaped - 0x10000;
  8645. // NaN means non-codepoint
  8646. // Support: Firefox<24
  8647. // Workaround erroneous numeric interpretation of +"0x"
  8648. return high !== high || escapedWhitespace ?
  8649. escaped :
  8650. high < 0 ?
  8651. // BMP codepoint
  8652. String.fromCharCode( high + 0x10000 ) :
  8653. // Supplemental Plane codepoint (surrogate pair)
  8654. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8655. },
  8656. // CSS string/identifier serialization
  8657. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8658. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8659. fcssescape = function( ch, asCodePoint ) {
  8660. if ( asCodePoint ) {
  8661. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8662. if ( ch === "\0" ) {
  8663. return "\uFFFD";
  8664. }
  8665. // Control characters and (dependent upon position) numbers get escaped as code points
  8666. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8667. }
  8668. // Other potentially-special ASCII characters get backslash-escaped
  8669. return "\\" + ch;
  8670. },
  8671. // Used for iframes
  8672. // See setDocument()
  8673. // Removing the function wrapper causes a "Permission Denied"
  8674. // error in IE
  8675. unloadHandler = function() {
  8676. setDocument();
  8677. },
  8678. inDisabledFieldset = addCombinator(
  8679. function( elem ) {
  8680. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8681. },
  8682. { dir: "parentNode", next: "legend" }
  8683. );
  8684. // Optimize for push.apply( _, NodeList )
  8685. try {
  8686. push.apply(
  8687. (arr = slice.call( preferredDoc.childNodes )),
  8688. preferredDoc.childNodes
  8689. );
  8690. // Support: Android<4.0
  8691. // Detect silently failing push.apply
  8692. arr[ preferredDoc.childNodes.length ].nodeType;
  8693. } catch ( e ) {
  8694. push = { apply: arr.length ?
  8695. // Leverage slice if possible
  8696. function( target, els ) {
  8697. push_native.apply( target, slice.call(els) );
  8698. } :
  8699. // Support: IE<9
  8700. // Otherwise append directly
  8701. function( target, els ) {
  8702. var j = target.length,
  8703. i = 0;
  8704. // Can't trust NodeList.length
  8705. while ( (target[j++] = els[i++]) ) {}
  8706. target.length = j - 1;
  8707. }
  8708. };
  8709. }
  8710. function Sizzle( selector, context, results, seed ) {
  8711. var m, i, elem, nid, match, groups, newSelector,
  8712. newContext = context && context.ownerDocument,
  8713. // nodeType defaults to 9, since context defaults to document
  8714. nodeType = context ? context.nodeType : 9;
  8715. results = results || [];
  8716. // Return early from calls with invalid selector or context
  8717. if ( typeof selector !== "string" || !selector ||
  8718. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8719. return results;
  8720. }
  8721. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8722. if ( !seed ) {
  8723. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8724. setDocument( context );
  8725. }
  8726. context = context || document;
  8727. if ( documentIsHTML ) {
  8728. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8729. // (excepting DocumentFragment context, where the methods don't exist)
  8730. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8731. // ID selector
  8732. if ( (m = match[1]) ) {
  8733. // Document context
  8734. if ( nodeType === 9 ) {
  8735. if ( (elem = context.getElementById( m )) ) {
  8736. // Support: IE, Opera, Webkit
  8737. // TODO: identify versions
  8738. // getElementById can match elements by name instead of ID
  8739. if ( elem.id === m ) {
  8740. results.push( elem );
  8741. return results;
  8742. }
  8743. } else {
  8744. return results;
  8745. }
  8746. // Element context
  8747. } else {
  8748. // Support: IE, Opera, Webkit
  8749. // TODO: identify versions
  8750. // getElementById can match elements by name instead of ID
  8751. if ( newContext && (elem = newContext.getElementById( m )) &&
  8752. contains( context, elem ) &&
  8753. elem.id === m ) {
  8754. results.push( elem );
  8755. return results;
  8756. }
  8757. }
  8758. // Type selector
  8759. } else if ( match[2] ) {
  8760. push.apply( results, context.getElementsByTagName( selector ) );
  8761. return results;
  8762. // Class selector
  8763. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8764. context.getElementsByClassName ) {
  8765. push.apply( results, context.getElementsByClassName( m ) );
  8766. return results;
  8767. }
  8768. }
  8769. // Take advantage of querySelectorAll
  8770. if ( support.qsa &&
  8771. !nonnativeSelectorCache[ selector + " " ] &&
  8772. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8773. // Support: IE 8 only
  8774. // Exclude object elements
  8775. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8776. newSelector = selector;
  8777. newContext = context;
  8778. // qSA considers elements outside a scoping root when evaluating child or
  8779. // descendant combinators, which is not what we want.
  8780. // In such cases, we work around the behavior by prefixing every selector in the
  8781. // list with an ID selector referencing the scope context.
  8782. // Thanks to Andrew Dupont for this technique.
  8783. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8784. // Capture the context ID, setting it first if necessary
  8785. if ( (nid = context.getAttribute( "id" )) ) {
  8786. nid = nid.replace( rcssescape, fcssescape );
  8787. } else {
  8788. context.setAttribute( "id", (nid = expando) );
  8789. }
  8790. // Prefix every selector in the list
  8791. groups = tokenize( selector );
  8792. i = groups.length;
  8793. while ( i-- ) {
  8794. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8795. }
  8796. newSelector = groups.join( "," );
  8797. // Expand context for sibling selectors
  8798. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8799. context;
  8800. }
  8801. try {
  8802. push.apply( results,
  8803. newContext.querySelectorAll( newSelector )
  8804. );
  8805. return results;
  8806. } catch ( qsaError ) {
  8807. nonnativeSelectorCache( selector, true );
  8808. } finally {
  8809. if ( nid === expando ) {
  8810. context.removeAttribute( "id" );
  8811. }
  8812. }
  8813. }
  8814. }
  8815. }
  8816. // All others
  8817. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8818. }
  8819. /**
  8820. * Create key-value caches of limited size
  8821. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8822. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8823. * deleting the oldest entry
  8824. */
  8825. function createCache() {
  8826. var keys = [];
  8827. function cache( key, value ) {
  8828. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8829. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8830. // Only keep the most recent entries
  8831. delete cache[ keys.shift() ];
  8832. }
  8833. return (cache[ key + " " ] = value);
  8834. }
  8835. return cache;
  8836. }
  8837. /**
  8838. * Mark a function for special use by Sizzle
  8839. * @param {Function} fn The function to mark
  8840. */
  8841. function markFunction( fn ) {
  8842. fn[ expando ] = true;
  8843. return fn;
  8844. }
  8845. /**
  8846. * Support testing using an element
  8847. * @param {Function} fn Passed the created element and returns a boolean result
  8848. */
  8849. function assert( fn ) {
  8850. var el = document.createElement("fieldset");
  8851. try {
  8852. return !!fn( el );
  8853. } catch (e) {
  8854. return false;
  8855. } finally {
  8856. // Remove from its parent by default
  8857. if ( el.parentNode ) {
  8858. el.parentNode.removeChild( el );
  8859. }
  8860. // release memory in IE
  8861. el = null;
  8862. }
  8863. }
  8864. /**
  8865. * Adds the same handler for all of the specified attrs
  8866. * @param {String} attrs Pipe-separated list of attributes
  8867. * @param {Function} handler The method that will be applied
  8868. */
  8869. function addHandle( attrs, handler ) {
  8870. var arr = attrs.split("|"),
  8871. i = arr.length;
  8872. while ( i-- ) {
  8873. Expr.attrHandle[ arr[i] ] = handler;
  8874. }
  8875. }
  8876. /**
  8877. * Checks document order of two siblings
  8878. * @param {Element} a
  8879. * @param {Element} b
  8880. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8881. */
  8882. function siblingCheck( a, b ) {
  8883. var cur = b && a,
  8884. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8885. a.sourceIndex - b.sourceIndex;
  8886. // Use IE sourceIndex if available on both nodes
  8887. if ( diff ) {
  8888. return diff;
  8889. }
  8890. // Check if b follows a
  8891. if ( cur ) {
  8892. while ( (cur = cur.nextSibling) ) {
  8893. if ( cur === b ) {
  8894. return -1;
  8895. }
  8896. }
  8897. }
  8898. return a ? 1 : -1;
  8899. }
  8900. /**
  8901. * Returns a function to use in pseudos for input types
  8902. * @param {String} type
  8903. */
  8904. function createInputPseudo( type ) {
  8905. return function( elem ) {
  8906. var name = elem.nodeName.toLowerCase();
  8907. return name === "input" && elem.type === type;
  8908. };
  8909. }
  8910. /**
  8911. * Returns a function to use in pseudos for buttons
  8912. * @param {String} type
  8913. */
  8914. function createButtonPseudo( type ) {
  8915. return function( elem ) {
  8916. var name = elem.nodeName.toLowerCase();
  8917. return (name === "input" || name === "button") && elem.type === type;
  8918. };
  8919. }
  8920. /**
  8921. * Returns a function to use in pseudos for :enabled/:disabled
  8922. * @param {Boolean} disabled true for :disabled; false for :enabled
  8923. */
  8924. function createDisabledPseudo( disabled ) {
  8925. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8926. return function( elem ) {
  8927. // Only certain elements can match :enabled or :disabled
  8928. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8929. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8930. if ( "form" in elem ) {
  8931. // Check for inherited disabledness on relevant non-disabled elements:
  8932. // * listed form-associated elements in a disabled fieldset
  8933. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8934. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8935. // * option elements in a disabled optgroup
  8936. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8937. // All such elements have a "form" property.
  8938. if ( elem.parentNode && elem.disabled === false ) {
  8939. // Option elements defer to a parent optgroup if present
  8940. if ( "label" in elem ) {
  8941. if ( "label" in elem.parentNode ) {
  8942. return elem.parentNode.disabled === disabled;
  8943. } else {
  8944. return elem.disabled === disabled;
  8945. }
  8946. }
  8947. // Support: IE 6 - 11
  8948. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8949. return elem.isDisabled === disabled ||
  8950. // Where there is no isDisabled, check manually
  8951. /* jshint -W018 */
  8952. elem.isDisabled !== !disabled &&
  8953. inDisabledFieldset( elem ) === disabled;
  8954. }
  8955. return elem.disabled === disabled;
  8956. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8957. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8958. // even exist on them, let alone have a boolean value.
  8959. } else if ( "label" in elem ) {
  8960. return elem.disabled === disabled;
  8961. }
  8962. // Remaining elements are neither :enabled nor :disabled
  8963. return false;
  8964. };
  8965. }
  8966. /**
  8967. * Returns a function to use in pseudos for positionals
  8968. * @param {Function} fn
  8969. */
  8970. function createPositionalPseudo( fn ) {
  8971. return markFunction(function( argument ) {
  8972. argument = +argument;
  8973. return markFunction(function( seed, matches ) {
  8974. var j,
  8975. matchIndexes = fn( [], seed.length, argument ),
  8976. i = matchIndexes.length;
  8977. // Match elements found at the specified indexes
  8978. while ( i-- ) {
  8979. if ( seed[ (j = matchIndexes[i]) ] ) {
  8980. seed[j] = !(matches[j] = seed[j]);
  8981. }
  8982. }
  8983. });
  8984. });
  8985. }
  8986. /**
  8987. * Checks a node for validity as a Sizzle context
  8988. * @param {Element|Object=} context
  8989. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8990. */
  8991. function testContext( context ) {
  8992. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8993. }
  8994. // Expose support vars for convenience
  8995. support = Sizzle.support = {};
  8996. /**
  8997. * Detects XML nodes
  8998. * @param {Element|Object} elem An element or a document
  8999. * @returns {Boolean} True iff elem is a non-HTML XML node
  9000. */
  9001. isXML = Sizzle.isXML = function( elem ) {
  9002. var namespace = elem.namespaceURI,
  9003. docElem = (elem.ownerDocument || elem).documentElement;
  9004. // Support: IE <=8
  9005. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  9006. // https://bugs.jquery.com/ticket/4833
  9007. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  9008. };
  9009. /**
  9010. * Sets document-related variables once based on the current document
  9011. * @param {Element|Object} [doc] An element or document object to use to set the document
  9012. * @returns {Object} Returns the current document
  9013. */
  9014. setDocument = Sizzle.setDocument = function( node ) {
  9015. var hasCompare, subWindow,
  9016. doc = node ? node.ownerDocument || node : preferredDoc;
  9017. // Return early if doc is invalid or already selected
  9018. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  9019. return document;
  9020. }
  9021. // Update global variables
  9022. document = doc;
  9023. docElem = document.documentElement;
  9024. documentIsHTML = !isXML( document );
  9025. // Support: IE 9-11, Edge
  9026. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  9027. if ( preferredDoc !== document &&
  9028. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  9029. // Support: IE 11, Edge
  9030. if ( subWindow.addEventListener ) {
  9031. subWindow.addEventListener( "unload", unloadHandler, false );
  9032. // Support: IE 9 - 10 only
  9033. } else if ( subWindow.attachEvent ) {
  9034. subWindow.attachEvent( "onunload", unloadHandler );
  9035. }
  9036. }
  9037. /* Attributes
  9038. ---------------------------------------------------------------------- */
  9039. // Support: IE<8
  9040. // Verify that getAttribute really returns attributes and not properties
  9041. // (excepting IE8 booleans)
  9042. support.attributes = assert(function( el ) {
  9043. el.className = "i";
  9044. return !el.getAttribute("className");
  9045. });
  9046. /* getElement(s)By*
  9047. ---------------------------------------------------------------------- */
  9048. // Check if getElementsByTagName("*") returns only elements
  9049. support.getElementsByTagName = assert(function( el ) {
  9050. el.appendChild( document.createComment("") );
  9051. return !el.getElementsByTagName("*").length;
  9052. });
  9053. // Support: IE<9
  9054. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  9055. // Support: IE<10
  9056. // Check if getElementById returns elements by name
  9057. // The broken getElementById methods don't pick up programmatically-set names,
  9058. // so use a roundabout getElementsByName test
  9059. support.getById = assert(function( el ) {
  9060. docElem.appendChild( el ).id = expando;
  9061. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  9062. });
  9063. // ID filter and find
  9064. if ( support.getById ) {
  9065. Expr.filter["ID"] = function( id ) {
  9066. var attrId = id.replace( runescape, funescape );
  9067. return function( elem ) {
  9068. return elem.getAttribute("id") === attrId;
  9069. };
  9070. };
  9071. Expr.find["ID"] = function( id, context ) {
  9072. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9073. var elem = context.getElementById( id );
  9074. return elem ? [ elem ] : [];
  9075. }
  9076. };
  9077. } else {
  9078. Expr.filter["ID"] = function( id ) {
  9079. var attrId = id.replace( runescape, funescape );
  9080. return function( elem ) {
  9081. var node = typeof elem.getAttributeNode !== "undefined" &&
  9082. elem.getAttributeNode("id");
  9083. return node && node.value === attrId;
  9084. };
  9085. };
  9086. // Support: IE 6 - 7 only
  9087. // getElementById is not reliable as a find shortcut
  9088. Expr.find["ID"] = function( id, context ) {
  9089. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9090. var node, i, elems,
  9091. elem = context.getElementById( id );
  9092. if ( elem ) {
  9093. // Verify the id attribute
  9094. node = elem.getAttributeNode("id");
  9095. if ( node && node.value === id ) {
  9096. return [ elem ];
  9097. }
  9098. // Fall back on getElementsByName
  9099. elems = context.getElementsByName( id );
  9100. i = 0;
  9101. while ( (elem = elems[i++]) ) {
  9102. node = elem.getAttributeNode("id");
  9103. if ( node && node.value === id ) {
  9104. return [ elem ];
  9105. }
  9106. }
  9107. }
  9108. return [];
  9109. }
  9110. };
  9111. }
  9112. // Tag
  9113. Expr.find["TAG"] = support.getElementsByTagName ?
  9114. function( tag, context ) {
  9115. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9116. return context.getElementsByTagName( tag );
  9117. // DocumentFragment nodes don't have gEBTN
  9118. } else if ( support.qsa ) {
  9119. return context.querySelectorAll( tag );
  9120. }
  9121. } :
  9122. function( tag, context ) {
  9123. var elem,
  9124. tmp = [],
  9125. i = 0,
  9126. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9127. results = context.getElementsByTagName( tag );
  9128. // Filter out possible comments
  9129. if ( tag === "*" ) {
  9130. while ( (elem = results[i++]) ) {
  9131. if ( elem.nodeType === 1 ) {
  9132. tmp.push( elem );
  9133. }
  9134. }
  9135. return tmp;
  9136. }
  9137. return results;
  9138. };
  9139. // Class
  9140. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9141. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9142. return context.getElementsByClassName( className );
  9143. }
  9144. };
  9145. /* QSA/matchesSelector
  9146. ---------------------------------------------------------------------- */
  9147. // QSA and matchesSelector support
  9148. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9149. rbuggyMatches = [];
  9150. // qSa(:focus) reports false when true (Chrome 21)
  9151. // We allow this because of a bug in IE8/9 that throws an error
  9152. // whenever `document.activeElement` is accessed on an iframe
  9153. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9154. // See https://bugs.jquery.com/ticket/13378
  9155. rbuggyQSA = [];
  9156. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9157. // Build QSA regex
  9158. // Regex strategy adopted from Diego Perini
  9159. assert(function( el ) {
  9160. // Select is set to empty string on purpose
  9161. // This is to test IE's treatment of not explicitly
  9162. // setting a boolean content attribute,
  9163. // since its presence should be enough
  9164. // https://bugs.jquery.com/ticket/12359
  9165. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9166. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9167. "<option selected=''></option></select>";
  9168. // Support: IE8, Opera 11-12.16
  9169. // Nothing should be selected when empty strings follow ^= or $= or *=
  9170. // The test attribute must be unknown in Opera but "safe" for WinRT
  9171. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9172. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9173. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9174. }
  9175. // Support: IE8
  9176. // Boolean attributes and "value" are not treated correctly
  9177. if ( !el.querySelectorAll("[selected]").length ) {
  9178. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9179. }
  9180. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9181. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9182. rbuggyQSA.push("~=");
  9183. }
  9184. // Webkit/Opera - :checked should return selected option elements
  9185. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9186. // IE8 throws error here and will not see later tests
  9187. if ( !el.querySelectorAll(":checked").length ) {
  9188. rbuggyQSA.push(":checked");
  9189. }
  9190. // Support: Safari 8+, iOS 8+
  9191. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9192. // In-page `selector#id sibling-combinator selector` fails
  9193. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9194. rbuggyQSA.push(".#.+[+~]");
  9195. }
  9196. });
  9197. assert(function( el ) {
  9198. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9199. "<select disabled='disabled'><option/></select>";
  9200. // Support: Windows 8 Native Apps
  9201. // The type and name attributes are restricted during .innerHTML assignment
  9202. var input = document.createElement("input");
  9203. input.setAttribute( "type", "hidden" );
  9204. el.appendChild( input ).setAttribute( "name", "D" );
  9205. // Support: IE8
  9206. // Enforce case-sensitivity of name attribute
  9207. if ( el.querySelectorAll("[name=d]").length ) {
  9208. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9209. }
  9210. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9211. // IE8 throws error here and will not see later tests
  9212. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9213. rbuggyQSA.push( ":enabled", ":disabled" );
  9214. }
  9215. // Support: IE9-11+
  9216. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9217. docElem.appendChild( el ).disabled = true;
  9218. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9219. rbuggyQSA.push( ":enabled", ":disabled" );
  9220. }
  9221. // Opera 10-11 does not throw on post-comma invalid pseudos
  9222. el.querySelectorAll("*,:x");
  9223. rbuggyQSA.push(",.*:");
  9224. });
  9225. }
  9226. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9227. docElem.webkitMatchesSelector ||
  9228. docElem.mozMatchesSelector ||
  9229. docElem.oMatchesSelector ||
  9230. docElem.msMatchesSelector) )) ) {
  9231. assert(function( el ) {
  9232. // Check to see if it's possible to do matchesSelector
  9233. // on a disconnected node (IE 9)
  9234. support.disconnectedMatch = matches.call( el, "*" );
  9235. // This should fail with an exception
  9236. // Gecko does not error, returns false instead
  9237. matches.call( el, "[s!='']:x" );
  9238. rbuggyMatches.push( "!=", pseudos );
  9239. });
  9240. }
  9241. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9242. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9243. /* Contains
  9244. ---------------------------------------------------------------------- */
  9245. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9246. // Element contains another
  9247. // Purposefully self-exclusive
  9248. // As in, an element does not contain itself
  9249. contains = hasCompare || rnative.test( docElem.contains ) ?
  9250. function( a, b ) {
  9251. var adown = a.nodeType === 9 ? a.documentElement : a,
  9252. bup = b && b.parentNode;
  9253. return a === bup || !!( bup && bup.nodeType === 1 && (
  9254. adown.contains ?
  9255. adown.contains( bup ) :
  9256. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9257. ));
  9258. } :
  9259. function( a, b ) {
  9260. if ( b ) {
  9261. while ( (b = b.parentNode) ) {
  9262. if ( b === a ) {
  9263. return true;
  9264. }
  9265. }
  9266. }
  9267. return false;
  9268. };
  9269. /* Sorting
  9270. ---------------------------------------------------------------------- */
  9271. // Document order sorting
  9272. sortOrder = hasCompare ?
  9273. function( a, b ) {
  9274. // Flag for duplicate removal
  9275. if ( a === b ) {
  9276. hasDuplicate = true;
  9277. return 0;
  9278. }
  9279. // Sort on method existence if only one input has compareDocumentPosition
  9280. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9281. if ( compare ) {
  9282. return compare;
  9283. }
  9284. // Calculate position if both inputs belong to the same document
  9285. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9286. a.compareDocumentPosition( b ) :
  9287. // Otherwise we know they are disconnected
  9288. 1;
  9289. // Disconnected nodes
  9290. if ( compare & 1 ||
  9291. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9292. // Choose the first element that is related to our preferred document
  9293. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9294. return -1;
  9295. }
  9296. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9297. return 1;
  9298. }
  9299. // Maintain original order
  9300. return sortInput ?
  9301. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9302. 0;
  9303. }
  9304. return compare & 4 ? -1 : 1;
  9305. } :
  9306. function( a, b ) {
  9307. // Exit early if the nodes are identical
  9308. if ( a === b ) {
  9309. hasDuplicate = true;
  9310. return 0;
  9311. }
  9312. var cur,
  9313. i = 0,
  9314. aup = a.parentNode,
  9315. bup = b.parentNode,
  9316. ap = [ a ],
  9317. bp = [ b ];
  9318. // Parentless nodes are either documents or disconnected
  9319. if ( !aup || !bup ) {
  9320. return a === document ? -1 :
  9321. b === document ? 1 :
  9322. aup ? -1 :
  9323. bup ? 1 :
  9324. sortInput ?
  9325. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9326. 0;
  9327. // If the nodes are siblings, we can do a quick check
  9328. } else if ( aup === bup ) {
  9329. return siblingCheck( a, b );
  9330. }
  9331. // Otherwise we need full lists of their ancestors for comparison
  9332. cur = a;
  9333. while ( (cur = cur.parentNode) ) {
  9334. ap.unshift( cur );
  9335. }
  9336. cur = b;
  9337. while ( (cur = cur.parentNode) ) {
  9338. bp.unshift( cur );
  9339. }
  9340. // Walk down the tree looking for a discrepancy
  9341. while ( ap[i] === bp[i] ) {
  9342. i++;
  9343. }
  9344. return i ?
  9345. // Do a sibling check if the nodes have a common ancestor
  9346. siblingCheck( ap[i], bp[i] ) :
  9347. // Otherwise nodes in our document sort first
  9348. ap[i] === preferredDoc ? -1 :
  9349. bp[i] === preferredDoc ? 1 :
  9350. 0;
  9351. };
  9352. return document;
  9353. };
  9354. Sizzle.matches = function( expr, elements ) {
  9355. return Sizzle( expr, null, null, elements );
  9356. };
  9357. Sizzle.matchesSelector = function( elem, expr ) {
  9358. // Set document vars if needed
  9359. if ( ( elem.ownerDocument || elem ) !== document ) {
  9360. setDocument( elem );
  9361. }
  9362. if ( support.matchesSelector && documentIsHTML &&
  9363. !nonnativeSelectorCache[ expr + " " ] &&
  9364. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9365. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9366. try {
  9367. var ret = matches.call( elem, expr );
  9368. // IE 9's matchesSelector returns false on disconnected nodes
  9369. if ( ret || support.disconnectedMatch ||
  9370. // As well, disconnected nodes are said to be in a document
  9371. // fragment in IE 9
  9372. elem.document && elem.document.nodeType !== 11 ) {
  9373. return ret;
  9374. }
  9375. } catch (e) {
  9376. nonnativeSelectorCache( expr, true );
  9377. }
  9378. }
  9379. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9380. };
  9381. Sizzle.contains = function( context, elem ) {
  9382. // Set document vars if needed
  9383. if ( ( context.ownerDocument || context ) !== document ) {
  9384. setDocument( context );
  9385. }
  9386. return contains( context, elem );
  9387. };
  9388. Sizzle.attr = function( elem, name ) {
  9389. // Set document vars if needed
  9390. if ( ( elem.ownerDocument || elem ) !== document ) {
  9391. setDocument( elem );
  9392. }
  9393. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9394. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9395. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9396. fn( elem, name, !documentIsHTML ) :
  9397. undefined;
  9398. return val !== undefined ?
  9399. val :
  9400. support.attributes || !documentIsHTML ?
  9401. elem.getAttribute( name ) :
  9402. (val = elem.getAttributeNode(name)) && val.specified ?
  9403. val.value :
  9404. null;
  9405. };
  9406. Sizzle.escape = function( sel ) {
  9407. return (sel + "").replace( rcssescape, fcssescape );
  9408. };
  9409. Sizzle.error = function( msg ) {
  9410. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9411. };
  9412. /**
  9413. * Document sorting and removing duplicates
  9414. * @param {ArrayLike} results
  9415. */
  9416. Sizzle.uniqueSort = function( results ) {
  9417. var elem,
  9418. duplicates = [],
  9419. j = 0,
  9420. i = 0;
  9421. // Unless we *know* we can detect duplicates, assume their presence
  9422. hasDuplicate = !support.detectDuplicates;
  9423. sortInput = !support.sortStable && results.slice( 0 );
  9424. results.sort( sortOrder );
  9425. if ( hasDuplicate ) {
  9426. while ( (elem = results[i++]) ) {
  9427. if ( elem === results[ i ] ) {
  9428. j = duplicates.push( i );
  9429. }
  9430. }
  9431. while ( j-- ) {
  9432. results.splice( duplicates[ j ], 1 );
  9433. }
  9434. }
  9435. // Clear input after sorting to release objects
  9436. // See https://github.com/jquery/sizzle/pull/225
  9437. sortInput = null;
  9438. return results;
  9439. };
  9440. /**
  9441. * Utility function for retrieving the text value of an array of DOM nodes
  9442. * @param {Array|Element} elem
  9443. */
  9444. getText = Sizzle.getText = function( elem ) {
  9445. var node,
  9446. ret = "",
  9447. i = 0,
  9448. nodeType = elem.nodeType;
  9449. if ( !nodeType ) {
  9450. // If no nodeType, this is expected to be an array
  9451. while ( (node = elem[i++]) ) {
  9452. // Do not traverse comment nodes
  9453. ret += getText( node );
  9454. }
  9455. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9456. // Use textContent for elements
  9457. // innerText usage removed for consistency of new lines (jQuery #11153)
  9458. if ( typeof elem.textContent === "string" ) {
  9459. return elem.textContent;
  9460. } else {
  9461. // Traverse its children
  9462. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9463. ret += getText( elem );
  9464. }
  9465. }
  9466. } else if ( nodeType === 3 || nodeType === 4 ) {
  9467. return elem.nodeValue;
  9468. }
  9469. // Do not include comment or processing instruction nodes
  9470. return ret;
  9471. };
  9472. Expr = Sizzle.selectors = {
  9473. // Can be adjusted by the user
  9474. cacheLength: 50,
  9475. createPseudo: markFunction,
  9476. match: matchExpr,
  9477. attrHandle: {},
  9478. find: {},
  9479. relative: {
  9480. ">": { dir: "parentNode", first: true },
  9481. " ": { dir: "parentNode" },
  9482. "+": { dir: "previousSibling", first: true },
  9483. "~": { dir: "previousSibling" }
  9484. },
  9485. preFilter: {
  9486. "ATTR": function( match ) {
  9487. match[1] = match[1].replace( runescape, funescape );
  9488. // Move the given value to match[3] whether quoted or unquoted
  9489. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9490. if ( match[2] === "~=" ) {
  9491. match[3] = " " + match[3] + " ";
  9492. }
  9493. return match.slice( 0, 4 );
  9494. },
  9495. "CHILD": function( match ) {
  9496. /* matches from matchExpr["CHILD"]
  9497. 1 type (only|nth|...)
  9498. 2 what (child|of-type)
  9499. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9500. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9501. 5 sign of xn-component
  9502. 6 x of xn-component
  9503. 7 sign of y-component
  9504. 8 y of y-component
  9505. */
  9506. match[1] = match[1].toLowerCase();
  9507. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9508. // nth-* requires argument
  9509. if ( !match[3] ) {
  9510. Sizzle.error( match[0] );
  9511. }
  9512. // numeric x and y parameters for Expr.filter.CHILD
  9513. // remember that false/true cast respectively to 0/1
  9514. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9515. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9516. // other types prohibit arguments
  9517. } else if ( match[3] ) {
  9518. Sizzle.error( match[0] );
  9519. }
  9520. return match;
  9521. },
  9522. "PSEUDO": function( match ) {
  9523. var excess,
  9524. unquoted = !match[6] && match[2];
  9525. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9526. return null;
  9527. }
  9528. // Accept quoted arguments as-is
  9529. if ( match[3] ) {
  9530. match[2] = match[4] || match[5] || "";
  9531. // Strip excess characters from unquoted arguments
  9532. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9533. // Get excess from tokenize (recursively)
  9534. (excess = tokenize( unquoted, true )) &&
  9535. // advance to the next closing parenthesis
  9536. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9537. // excess is a negative index
  9538. match[0] = match[0].slice( 0, excess );
  9539. match[2] = unquoted.slice( 0, excess );
  9540. }
  9541. // Return only captures needed by the pseudo filter method (type and argument)
  9542. return match.slice( 0, 3 );
  9543. }
  9544. },
  9545. filter: {
  9546. "TAG": function( nodeNameSelector ) {
  9547. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9548. return nodeNameSelector === "*" ?
  9549. function() { return true; } :
  9550. function( elem ) {
  9551. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9552. };
  9553. },
  9554. "CLASS": function( className ) {
  9555. var pattern = classCache[ className + " " ];
  9556. return pattern ||
  9557. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9558. classCache( className, function( elem ) {
  9559. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9560. });
  9561. },
  9562. "ATTR": function( name, operator, check ) {
  9563. return function( elem ) {
  9564. var result = Sizzle.attr( elem, name );
  9565. if ( result == null ) {
  9566. return operator === "!=";
  9567. }
  9568. if ( !operator ) {
  9569. return true;
  9570. }
  9571. result += "";
  9572. return operator === "=" ? result === check :
  9573. operator === "!=" ? result !== check :
  9574. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9575. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9576. operator === "$=" ? check && result.slice( -check.length ) === check :
  9577. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9578. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9579. false;
  9580. };
  9581. },
  9582. "CHILD": function( type, what, argument, first, last ) {
  9583. var simple = type.slice( 0, 3 ) !== "nth",
  9584. forward = type.slice( -4 ) !== "last",
  9585. ofType = what === "of-type";
  9586. return first === 1 && last === 0 ?
  9587. // Shortcut for :nth-*(n)
  9588. function( elem ) {
  9589. return !!elem.parentNode;
  9590. } :
  9591. function( elem, context, xml ) {
  9592. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9593. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9594. parent = elem.parentNode,
  9595. name = ofType && elem.nodeName.toLowerCase(),
  9596. useCache = !xml && !ofType,
  9597. diff = false;
  9598. if ( parent ) {
  9599. // :(first|last|only)-(child|of-type)
  9600. if ( simple ) {
  9601. while ( dir ) {
  9602. node = elem;
  9603. while ( (node = node[ dir ]) ) {
  9604. if ( ofType ?
  9605. node.nodeName.toLowerCase() === name :
  9606. node.nodeType === 1 ) {
  9607. return false;
  9608. }
  9609. }
  9610. // Reverse direction for :only-* (if we haven't yet done so)
  9611. start = dir = type === "only" && !start && "nextSibling";
  9612. }
  9613. return true;
  9614. }
  9615. start = [ forward ? parent.firstChild : parent.lastChild ];
  9616. // non-xml :nth-child(...) stores cache data on `parent`
  9617. if ( forward && useCache ) {
  9618. // Seek `elem` from a previously-cached index
  9619. // ...in a gzip-friendly way
  9620. node = parent;
  9621. outerCache = node[ expando ] || (node[ expando ] = {});
  9622. // Support: IE <9 only
  9623. // Defend against cloned attroperties (jQuery gh-1709)
  9624. uniqueCache = outerCache[ node.uniqueID ] ||
  9625. (outerCache[ node.uniqueID ] = {});
  9626. cache = uniqueCache[ type ] || [];
  9627. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9628. diff = nodeIndex && cache[ 2 ];
  9629. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9630. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9631. // Fallback to seeking `elem` from the start
  9632. (diff = nodeIndex = 0) || start.pop()) ) {
  9633. // When found, cache indexes on `parent` and break
  9634. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9635. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9636. break;
  9637. }
  9638. }
  9639. } else {
  9640. // Use previously-cached element index if available
  9641. if ( useCache ) {
  9642. // ...in a gzip-friendly way
  9643. node = elem;
  9644. outerCache = node[ expando ] || (node[ expando ] = {});
  9645. // Support: IE <9 only
  9646. // Defend against cloned attroperties (jQuery gh-1709)
  9647. uniqueCache = outerCache[ node.uniqueID ] ||
  9648. (outerCache[ node.uniqueID ] = {});
  9649. cache = uniqueCache[ type ] || [];
  9650. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9651. diff = nodeIndex;
  9652. }
  9653. // xml :nth-child(...)
  9654. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9655. if ( diff === false ) {
  9656. // Use the same loop as above to seek `elem` from the start
  9657. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9658. (diff = nodeIndex = 0) || start.pop()) ) {
  9659. if ( ( ofType ?
  9660. node.nodeName.toLowerCase() === name :
  9661. node.nodeType === 1 ) &&
  9662. ++diff ) {
  9663. // Cache the index of each encountered element
  9664. if ( useCache ) {
  9665. outerCache = node[ expando ] || (node[ expando ] = {});
  9666. // Support: IE <9 only
  9667. // Defend against cloned attroperties (jQuery gh-1709)
  9668. uniqueCache = outerCache[ node.uniqueID ] ||
  9669. (outerCache[ node.uniqueID ] = {});
  9670. uniqueCache[ type ] = [ dirruns, diff ];
  9671. }
  9672. if ( node === elem ) {
  9673. break;
  9674. }
  9675. }
  9676. }
  9677. }
  9678. }
  9679. // Incorporate the offset, then check against cycle size
  9680. diff -= last;
  9681. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9682. }
  9683. };
  9684. },
  9685. "PSEUDO": function( pseudo, argument ) {
  9686. // pseudo-class names are case-insensitive
  9687. // http://www.w3.org/TR/selectors/#pseudo-classes
  9688. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9689. // Remember that setFilters inherits from pseudos
  9690. var args,
  9691. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9692. Sizzle.error( "unsupported pseudo: " + pseudo );
  9693. // The user may use createPseudo to indicate that
  9694. // arguments are needed to create the filter function
  9695. // just as Sizzle does
  9696. if ( fn[ expando ] ) {
  9697. return fn( argument );
  9698. }
  9699. // But maintain support for old signatures
  9700. if ( fn.length > 1 ) {
  9701. args = [ pseudo, pseudo, "", argument ];
  9702. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9703. markFunction(function( seed, matches ) {
  9704. var idx,
  9705. matched = fn( seed, argument ),
  9706. i = matched.length;
  9707. while ( i-- ) {
  9708. idx = indexOf( seed, matched[i] );
  9709. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9710. }
  9711. }) :
  9712. function( elem ) {
  9713. return fn( elem, 0, args );
  9714. };
  9715. }
  9716. return fn;
  9717. }
  9718. },
  9719. pseudos: {
  9720. // Potentially complex pseudos
  9721. "not": markFunction(function( selector ) {
  9722. // Trim the selector passed to compile
  9723. // to avoid treating leading and trailing
  9724. // spaces as combinators
  9725. var input = [],
  9726. results = [],
  9727. matcher = compile( selector.replace( rtrim, "$1" ) );
  9728. return matcher[ expando ] ?
  9729. markFunction(function( seed, matches, context, xml ) {
  9730. var elem,
  9731. unmatched = matcher( seed, null, xml, [] ),
  9732. i = seed.length;
  9733. // Match elements unmatched by `matcher`
  9734. while ( i-- ) {
  9735. if ( (elem = unmatched[i]) ) {
  9736. seed[i] = !(matches[i] = elem);
  9737. }
  9738. }
  9739. }) :
  9740. function( elem, context, xml ) {
  9741. input[0] = elem;
  9742. matcher( input, null, xml, results );
  9743. // Don't keep the element (issue #299)
  9744. input[0] = null;
  9745. return !results.pop();
  9746. };
  9747. }),
  9748. "has": markFunction(function( selector ) {
  9749. return function( elem ) {
  9750. return Sizzle( selector, elem ).length > 0;
  9751. };
  9752. }),
  9753. "contains": markFunction(function( text ) {
  9754. text = text.replace( runescape, funescape );
  9755. return function( elem ) {
  9756. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9757. };
  9758. }),
  9759. // "Whether an element is represented by a :lang() selector
  9760. // is based solely on the element's language value
  9761. // being equal to the identifier C,
  9762. // or beginning with the identifier C immediately followed by "-".
  9763. // The matching of C against the element's language value is performed case-insensitively.
  9764. // The identifier C does not have to be a valid language name."
  9765. // http://www.w3.org/TR/selectors/#lang-pseudo
  9766. "lang": markFunction( function( lang ) {
  9767. // lang value must be a valid identifier
  9768. if ( !ridentifier.test(lang || "") ) {
  9769. Sizzle.error( "unsupported lang: " + lang );
  9770. }
  9771. lang = lang.replace( runescape, funescape ).toLowerCase();
  9772. return function( elem ) {
  9773. var elemLang;
  9774. do {
  9775. if ( (elemLang = documentIsHTML ?
  9776. elem.lang :
  9777. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9778. elemLang = elemLang.toLowerCase();
  9779. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9780. }
  9781. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9782. return false;
  9783. };
  9784. }),
  9785. // Miscellaneous
  9786. "target": function( elem ) {
  9787. var hash = window.location && window.location.hash;
  9788. return hash && hash.slice( 1 ) === elem.id;
  9789. },
  9790. "root": function( elem ) {
  9791. return elem === docElem;
  9792. },
  9793. "focus": function( elem ) {
  9794. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9795. },
  9796. // Boolean properties
  9797. "enabled": createDisabledPseudo( false ),
  9798. "disabled": createDisabledPseudo( true ),
  9799. "checked": function( elem ) {
  9800. // In CSS3, :checked should return both checked and selected elements
  9801. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9802. var nodeName = elem.nodeName.toLowerCase();
  9803. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9804. },
  9805. "selected": function( elem ) {
  9806. // Accessing this property makes selected-by-default
  9807. // options in Safari work properly
  9808. if ( elem.parentNode ) {
  9809. elem.parentNode.selectedIndex;
  9810. }
  9811. return elem.selected === true;
  9812. },
  9813. // Contents
  9814. "empty": function( elem ) {
  9815. // http://www.w3.org/TR/selectors/#empty-pseudo
  9816. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9817. // but not by others (comment: 8; processing instruction: 7; etc.)
  9818. // nodeType < 6 works because attributes (2) do not appear as children
  9819. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9820. if ( elem.nodeType < 6 ) {
  9821. return false;
  9822. }
  9823. }
  9824. return true;
  9825. },
  9826. "parent": function( elem ) {
  9827. return !Expr.pseudos["empty"]( elem );
  9828. },
  9829. // Element/input types
  9830. "header": function( elem ) {
  9831. return rheader.test( elem.nodeName );
  9832. },
  9833. "input": function( elem ) {
  9834. return rinputs.test( elem.nodeName );
  9835. },
  9836. "button": function( elem ) {
  9837. var name = elem.nodeName.toLowerCase();
  9838. return name === "input" && elem.type === "button" || name === "button";
  9839. },
  9840. "text": function( elem ) {
  9841. var attr;
  9842. return elem.nodeName.toLowerCase() === "input" &&
  9843. elem.type === "text" &&
  9844. // Support: IE<8
  9845. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9846. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9847. },
  9848. // Position-in-collection
  9849. "first": createPositionalPseudo(function() {
  9850. return [ 0 ];
  9851. }),
  9852. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9853. return [ length - 1 ];
  9854. }),
  9855. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9856. return [ argument < 0 ? argument + length : argument ];
  9857. }),
  9858. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9859. var i = 0;
  9860. for ( ; i < length; i += 2 ) {
  9861. matchIndexes.push( i );
  9862. }
  9863. return matchIndexes;
  9864. }),
  9865. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9866. var i = 1;
  9867. for ( ; i < length; i += 2 ) {
  9868. matchIndexes.push( i );
  9869. }
  9870. return matchIndexes;
  9871. }),
  9872. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9873. var i = argument < 0 ?
  9874. argument + length :
  9875. argument > length ?
  9876. length :
  9877. argument;
  9878. for ( ; --i >= 0; ) {
  9879. matchIndexes.push( i );
  9880. }
  9881. return matchIndexes;
  9882. }),
  9883. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9884. var i = argument < 0 ? argument + length : argument;
  9885. for ( ; ++i < length; ) {
  9886. matchIndexes.push( i );
  9887. }
  9888. return matchIndexes;
  9889. })
  9890. }
  9891. };
  9892. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9893. // Add button/input type pseudos
  9894. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9895. Expr.pseudos[ i ] = createInputPseudo( i );
  9896. }
  9897. for ( i in { submit: true, reset: true } ) {
  9898. Expr.pseudos[ i ] = createButtonPseudo( i );
  9899. }
  9900. // Easy API for creating new setFilters
  9901. function setFilters() {}
  9902. setFilters.prototype = Expr.filters = Expr.pseudos;
  9903. Expr.setFilters = new setFilters();
  9904. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9905. var matched, match, tokens, type,
  9906. soFar, groups, preFilters,
  9907. cached = tokenCache[ selector + " " ];
  9908. if ( cached ) {
  9909. return parseOnly ? 0 : cached.slice( 0 );
  9910. }
  9911. soFar = selector;
  9912. groups = [];
  9913. preFilters = Expr.preFilter;
  9914. while ( soFar ) {
  9915. // Comma and first run
  9916. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9917. if ( match ) {
  9918. // Don't consume trailing commas as valid
  9919. soFar = soFar.slice( match[0].length ) || soFar;
  9920. }
  9921. groups.push( (tokens = []) );
  9922. }
  9923. matched = false;
  9924. // Combinators
  9925. if ( (match = rcombinators.exec( soFar )) ) {
  9926. matched = match.shift();
  9927. tokens.push({
  9928. value: matched,
  9929. // Cast descendant combinators to space
  9930. type: match[0].replace( rtrim, " " )
  9931. });
  9932. soFar = soFar.slice( matched.length );
  9933. }
  9934. // Filters
  9935. for ( type in Expr.filter ) {
  9936. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9937. (match = preFilters[ type ]( match ))) ) {
  9938. matched = match.shift();
  9939. tokens.push({
  9940. value: matched,
  9941. type: type,
  9942. matches: match
  9943. });
  9944. soFar = soFar.slice( matched.length );
  9945. }
  9946. }
  9947. if ( !matched ) {
  9948. break;
  9949. }
  9950. }
  9951. // Return the length of the invalid excess
  9952. // if we're just parsing
  9953. // Otherwise, throw an error or return tokens
  9954. return parseOnly ?
  9955. soFar.length :
  9956. soFar ?
  9957. Sizzle.error( selector ) :
  9958. // Cache the tokens
  9959. tokenCache( selector, groups ).slice( 0 );
  9960. };
  9961. function toSelector( tokens ) {
  9962. var i = 0,
  9963. len = tokens.length,
  9964. selector = "";
  9965. for ( ; i < len; i++ ) {
  9966. selector += tokens[i].value;
  9967. }
  9968. return selector;
  9969. }
  9970. function addCombinator( matcher, combinator, base ) {
  9971. var dir = combinator.dir,
  9972. skip = combinator.next,
  9973. key = skip || dir,
  9974. checkNonElements = base && key === "parentNode",
  9975. doneName = done++;
  9976. return combinator.first ?
  9977. // Check against closest ancestor/preceding element
  9978. function( elem, context, xml ) {
  9979. while ( (elem = elem[ dir ]) ) {
  9980. if ( elem.nodeType === 1 || checkNonElements ) {
  9981. return matcher( elem, context, xml );
  9982. }
  9983. }
  9984. return false;
  9985. } :
  9986. // Check against all ancestor/preceding elements
  9987. function( elem, context, xml ) {
  9988. var oldCache, uniqueCache, outerCache,
  9989. newCache = [ dirruns, doneName ];
  9990. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9991. if ( xml ) {
  9992. while ( (elem = elem[ dir ]) ) {
  9993. if ( elem.nodeType === 1 || checkNonElements ) {
  9994. if ( matcher( elem, context, xml ) ) {
  9995. return true;
  9996. }
  9997. }
  9998. }
  9999. } else {
  10000. while ( (elem = elem[ dir ]) ) {
  10001. if ( elem.nodeType === 1 || checkNonElements ) {
  10002. outerCache = elem[ expando ] || (elem[ expando ] = {});
  10003. // Support: IE <9 only
  10004. // Defend against cloned attroperties (jQuery gh-1709)
  10005. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  10006. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  10007. elem = elem[ dir ] || elem;
  10008. } else if ( (oldCache = uniqueCache[ key ]) &&
  10009. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  10010. // Assign to newCache so results back-propagate to previous elements
  10011. return (newCache[ 2 ] = oldCache[ 2 ]);
  10012. } else {
  10013. // Reuse newcache so results back-propagate to previous elements
  10014. uniqueCache[ key ] = newCache;
  10015. // A match means we're done; a fail means we have to keep checking
  10016. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  10017. return true;
  10018. }
  10019. }
  10020. }
  10021. }
  10022. }
  10023. return false;
  10024. };
  10025. }
  10026. function elementMatcher( matchers ) {
  10027. return matchers.length > 1 ?
  10028. function( elem, context, xml ) {
  10029. var i = matchers.length;
  10030. while ( i-- ) {
  10031. if ( !matchers[i]( elem, context, xml ) ) {
  10032. return false;
  10033. }
  10034. }
  10035. return true;
  10036. } :
  10037. matchers[0];
  10038. }
  10039. function multipleContexts( selector, contexts, results ) {
  10040. var i = 0,
  10041. len = contexts.length;
  10042. for ( ; i < len; i++ ) {
  10043. Sizzle( selector, contexts[i], results );
  10044. }
  10045. return results;
  10046. }
  10047. function condense( unmatched, map, filter, context, xml ) {
  10048. var elem,
  10049. newUnmatched = [],
  10050. i = 0,
  10051. len = unmatched.length,
  10052. mapped = map != null;
  10053. for ( ; i < len; i++ ) {
  10054. if ( (elem = unmatched[i]) ) {
  10055. if ( !filter || filter( elem, context, xml ) ) {
  10056. newUnmatched.push( elem );
  10057. if ( mapped ) {
  10058. map.push( i );
  10059. }
  10060. }
  10061. }
  10062. }
  10063. return newUnmatched;
  10064. }
  10065. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  10066. if ( postFilter && !postFilter[ expando ] ) {
  10067. postFilter = setMatcher( postFilter );
  10068. }
  10069. if ( postFinder && !postFinder[ expando ] ) {
  10070. postFinder = setMatcher( postFinder, postSelector );
  10071. }
  10072. return markFunction(function( seed, results, context, xml ) {
  10073. var temp, i, elem,
  10074. preMap = [],
  10075. postMap = [],
  10076. preexisting = results.length,
  10077. // Get initial elements from seed or context
  10078. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  10079. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  10080. matcherIn = preFilter && ( seed || !selector ) ?
  10081. condense( elems, preMap, preFilter, context, xml ) :
  10082. elems,
  10083. matcherOut = matcher ?
  10084. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  10085. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  10086. // ...intermediate processing is necessary
  10087. [] :
  10088. // ...otherwise use results directly
  10089. results :
  10090. matcherIn;
  10091. // Find primary matches
  10092. if ( matcher ) {
  10093. matcher( matcherIn, matcherOut, context, xml );
  10094. }
  10095. // Apply postFilter
  10096. if ( postFilter ) {
  10097. temp = condense( matcherOut, postMap );
  10098. postFilter( temp, [], context, xml );
  10099. // Un-match failing elements by moving them back to matcherIn
  10100. i = temp.length;
  10101. while ( i-- ) {
  10102. if ( (elem = temp[i]) ) {
  10103. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  10104. }
  10105. }
  10106. }
  10107. if ( seed ) {
  10108. if ( postFinder || preFilter ) {
  10109. if ( postFinder ) {
  10110. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10111. temp = [];
  10112. i = matcherOut.length;
  10113. while ( i-- ) {
  10114. if ( (elem = matcherOut[i]) ) {
  10115. // Restore matcherIn since elem is not yet a final match
  10116. temp.push( (matcherIn[i] = elem) );
  10117. }
  10118. }
  10119. postFinder( null, (matcherOut = []), temp, xml );
  10120. }
  10121. // Move matched elements from seed to results to keep them synchronized
  10122. i = matcherOut.length;
  10123. while ( i-- ) {
  10124. if ( (elem = matcherOut[i]) &&
  10125. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10126. seed[temp] = !(results[temp] = elem);
  10127. }
  10128. }
  10129. }
  10130. // Add elements to results, through postFinder if defined
  10131. } else {
  10132. matcherOut = condense(
  10133. matcherOut === results ?
  10134. matcherOut.splice( preexisting, matcherOut.length ) :
  10135. matcherOut
  10136. );
  10137. if ( postFinder ) {
  10138. postFinder( null, results, matcherOut, xml );
  10139. } else {
  10140. push.apply( results, matcherOut );
  10141. }
  10142. }
  10143. });
  10144. }
  10145. function matcherFromTokens( tokens ) {
  10146. var checkContext, matcher, j,
  10147. len = tokens.length,
  10148. leadingRelative = Expr.relative[ tokens[0].type ],
  10149. implicitRelative = leadingRelative || Expr.relative[" "],
  10150. i = leadingRelative ? 1 : 0,
  10151. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10152. matchContext = addCombinator( function( elem ) {
  10153. return elem === checkContext;
  10154. }, implicitRelative, true ),
  10155. matchAnyContext = addCombinator( function( elem ) {
  10156. return indexOf( checkContext, elem ) > -1;
  10157. }, implicitRelative, true ),
  10158. matchers = [ function( elem, context, xml ) {
  10159. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10160. (checkContext = context).nodeType ?
  10161. matchContext( elem, context, xml ) :
  10162. matchAnyContext( elem, context, xml ) );
  10163. // Avoid hanging onto element (issue #299)
  10164. checkContext = null;
  10165. return ret;
  10166. } ];
  10167. for ( ; i < len; i++ ) {
  10168. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10169. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10170. } else {
  10171. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10172. // Return special upon seeing a positional matcher
  10173. if ( matcher[ expando ] ) {
  10174. // Find the next relative operator (if any) for proper handling
  10175. j = ++i;
  10176. for ( ; j < len; j++ ) {
  10177. if ( Expr.relative[ tokens[j].type ] ) {
  10178. break;
  10179. }
  10180. }
  10181. return setMatcher(
  10182. i > 1 && elementMatcher( matchers ),
  10183. i > 1 && toSelector(
  10184. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10185. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10186. ).replace( rtrim, "$1" ),
  10187. matcher,
  10188. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10189. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10190. j < len && toSelector( tokens )
  10191. );
  10192. }
  10193. matchers.push( matcher );
  10194. }
  10195. }
  10196. return elementMatcher( matchers );
  10197. }
  10198. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10199. var bySet = setMatchers.length > 0,
  10200. byElement = elementMatchers.length > 0,
  10201. superMatcher = function( seed, context, xml, results, outermost ) {
  10202. var elem, j, matcher,
  10203. matchedCount = 0,
  10204. i = "0",
  10205. unmatched = seed && [],
  10206. setMatched = [],
  10207. contextBackup = outermostContext,
  10208. // We must always have either seed elements or outermost context
  10209. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10210. // Use integer dirruns iff this is the outermost matcher
  10211. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10212. len = elems.length;
  10213. if ( outermost ) {
  10214. outermostContext = context === document || context || outermost;
  10215. }
  10216. // Add elements passing elementMatchers directly to results
  10217. // Support: IE<9, Safari
  10218. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10219. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10220. if ( byElement && elem ) {
  10221. j = 0;
  10222. if ( !context && elem.ownerDocument !== document ) {
  10223. setDocument( elem );
  10224. xml = !documentIsHTML;
  10225. }
  10226. while ( (matcher = elementMatchers[j++]) ) {
  10227. if ( matcher( elem, context || document, xml) ) {
  10228. results.push( elem );
  10229. break;
  10230. }
  10231. }
  10232. if ( outermost ) {
  10233. dirruns = dirrunsUnique;
  10234. }
  10235. }
  10236. // Track unmatched elements for set filters
  10237. if ( bySet ) {
  10238. // They will have gone through all possible matchers
  10239. if ( (elem = !matcher && elem) ) {
  10240. matchedCount--;
  10241. }
  10242. // Lengthen the array for every element, matched or not
  10243. if ( seed ) {
  10244. unmatched.push( elem );
  10245. }
  10246. }
  10247. }
  10248. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10249. // makes the latter nonnegative.
  10250. matchedCount += i;
  10251. // Apply set filters to unmatched elements
  10252. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10253. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10254. // no element matchers and no seed.
  10255. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10256. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10257. // numerically zero.
  10258. if ( bySet && i !== matchedCount ) {
  10259. j = 0;
  10260. while ( (matcher = setMatchers[j++]) ) {
  10261. matcher( unmatched, setMatched, context, xml );
  10262. }
  10263. if ( seed ) {
  10264. // Reintegrate element matches to eliminate the need for sorting
  10265. if ( matchedCount > 0 ) {
  10266. while ( i-- ) {
  10267. if ( !(unmatched[i] || setMatched[i]) ) {
  10268. setMatched[i] = pop.call( results );
  10269. }
  10270. }
  10271. }
  10272. // Discard index placeholder values to get only actual matches
  10273. setMatched = condense( setMatched );
  10274. }
  10275. // Add matches to results
  10276. push.apply( results, setMatched );
  10277. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10278. if ( outermost && !seed && setMatched.length > 0 &&
  10279. ( matchedCount + setMatchers.length ) > 1 ) {
  10280. Sizzle.uniqueSort( results );
  10281. }
  10282. }
  10283. // Override manipulation of globals by nested matchers
  10284. if ( outermost ) {
  10285. dirruns = dirrunsUnique;
  10286. outermostContext = contextBackup;
  10287. }
  10288. return unmatched;
  10289. };
  10290. return bySet ?
  10291. markFunction( superMatcher ) :
  10292. superMatcher;
  10293. }
  10294. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10295. var i,
  10296. setMatchers = [],
  10297. elementMatchers = [],
  10298. cached = compilerCache[ selector + " " ];
  10299. if ( !cached ) {
  10300. // Generate a function of recursive functions that can be used to check each element
  10301. if ( !match ) {
  10302. match = tokenize( selector );
  10303. }
  10304. i = match.length;
  10305. while ( i-- ) {
  10306. cached = matcherFromTokens( match[i] );
  10307. if ( cached[ expando ] ) {
  10308. setMatchers.push( cached );
  10309. } else {
  10310. elementMatchers.push( cached );
  10311. }
  10312. }
  10313. // Cache the compiled function
  10314. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10315. // Save selector and tokenization
  10316. cached.selector = selector;
  10317. }
  10318. return cached;
  10319. };
  10320. /**
  10321. * A low-level selection function that works with Sizzle's compiled
  10322. * selector functions
  10323. * @param {String|Function} selector A selector or a pre-compiled
  10324. * selector function built with Sizzle.compile
  10325. * @param {Element} context
  10326. * @param {Array} [results]
  10327. * @param {Array} [seed] A set of elements to match against
  10328. */
  10329. select = Sizzle.select = function( selector, context, results, seed ) {
  10330. var i, tokens, token, type, find,
  10331. compiled = typeof selector === "function" && selector,
  10332. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10333. results = results || [];
  10334. // Try to minimize operations if there is only one selector in the list and no seed
  10335. // (the latter of which guarantees us context)
  10336. if ( match.length === 1 ) {
  10337. // Reduce context if the leading compound selector is an ID
  10338. tokens = match[0] = match[0].slice( 0 );
  10339. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10340. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10341. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10342. if ( !context ) {
  10343. return results;
  10344. // Precompiled matchers will still verify ancestry, so step up a level
  10345. } else if ( compiled ) {
  10346. context = context.parentNode;
  10347. }
  10348. selector = selector.slice( tokens.shift().value.length );
  10349. }
  10350. // Fetch a seed set for right-to-left matching
  10351. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10352. while ( i-- ) {
  10353. token = tokens[i];
  10354. // Abort if we hit a combinator
  10355. if ( Expr.relative[ (type = token.type) ] ) {
  10356. break;
  10357. }
  10358. if ( (find = Expr.find[ type ]) ) {
  10359. // Search, expanding context for leading sibling combinators
  10360. if ( (seed = find(
  10361. token.matches[0].replace( runescape, funescape ),
  10362. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10363. )) ) {
  10364. // If seed is empty or no tokens remain, we can return early
  10365. tokens.splice( i, 1 );
  10366. selector = seed.length && toSelector( tokens );
  10367. if ( !selector ) {
  10368. push.apply( results, seed );
  10369. return results;
  10370. }
  10371. break;
  10372. }
  10373. }
  10374. }
  10375. }
  10376. // Compile and execute a filtering function if one is not provided
  10377. // Provide `match` to avoid retokenization if we modified the selector above
  10378. ( compiled || compile( selector, match ) )(
  10379. seed,
  10380. context,
  10381. !documentIsHTML,
  10382. results,
  10383. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10384. );
  10385. return results;
  10386. };
  10387. // One-time assignments
  10388. // Sort stability
  10389. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10390. // Support: Chrome 14-35+
  10391. // Always assume duplicates if they aren't passed to the comparison function
  10392. support.detectDuplicates = !!hasDuplicate;
  10393. // Initialize against the default document
  10394. setDocument();
  10395. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10396. // Detached nodes confoundingly follow *each other*
  10397. support.sortDetached = assert(function( el ) {
  10398. // Should return 1, but returns 4 (following)
  10399. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10400. });
  10401. // Support: IE<8
  10402. // Prevent attribute/property "interpolation"
  10403. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10404. if ( !assert(function( el ) {
  10405. el.innerHTML = "<a href='#'></a>";
  10406. return el.firstChild.getAttribute("href") === "#" ;
  10407. }) ) {
  10408. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10409. if ( !isXML ) {
  10410. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10411. }
  10412. });
  10413. }
  10414. // Support: IE<9
  10415. // Use defaultValue in place of getAttribute("value")
  10416. if ( !support.attributes || !assert(function( el ) {
  10417. el.innerHTML = "<input/>";
  10418. el.firstChild.setAttribute( "value", "" );
  10419. return el.firstChild.getAttribute( "value" ) === "";
  10420. }) ) {
  10421. addHandle( "value", function( elem, name, isXML ) {
  10422. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10423. return elem.defaultValue;
  10424. }
  10425. });
  10426. }
  10427. // Support: IE<9
  10428. // Use getAttributeNode to fetch booleans when getAttribute lies
  10429. if ( !assert(function( el ) {
  10430. return el.getAttribute("disabled") == null;
  10431. }) ) {
  10432. addHandle( booleans, function( elem, name, isXML ) {
  10433. var val;
  10434. if ( !isXML ) {
  10435. return elem[ name ] === true ? name.toLowerCase() :
  10436. (val = elem.getAttributeNode( name )) && val.specified ?
  10437. val.value :
  10438. null;
  10439. }
  10440. });
  10441. }
  10442. return Sizzle;
  10443. })( window );
  10444. jQuery.find = Sizzle;
  10445. jQuery.expr = Sizzle.selectors;
  10446. // Deprecated
  10447. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10448. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10449. jQuery.text = Sizzle.getText;
  10450. jQuery.isXMLDoc = Sizzle.isXML;
  10451. jQuery.contains = Sizzle.contains;
  10452. jQuery.escapeSelector = Sizzle.escape;
  10453. var dir = function( elem, dir, until ) {
  10454. var matched = [],
  10455. truncate = until !== undefined;
  10456. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10457. if ( elem.nodeType === 1 ) {
  10458. if ( truncate && jQuery( elem ).is( until ) ) {
  10459. break;
  10460. }
  10461. matched.push( elem );
  10462. }
  10463. }
  10464. return matched;
  10465. };
  10466. var siblings = function( n, elem ) {
  10467. var matched = [];
  10468. for ( ; n; n = n.nextSibling ) {
  10469. if ( n.nodeType === 1 && n !== elem ) {
  10470. matched.push( n );
  10471. }
  10472. }
  10473. return matched;
  10474. };
  10475. var rneedsContext = jQuery.expr.match.needsContext;
  10476. function nodeName( elem, name ) {
  10477. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10478. };
  10479. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10480. // Implement the identical functionality for filter and not
  10481. function winnow( elements, qualifier, not ) {
  10482. if ( isFunction( qualifier ) ) {
  10483. return jQuery.grep( elements, function( elem, i ) {
  10484. return !!qualifier.call( elem, i, elem ) !== not;
  10485. } );
  10486. }
  10487. // Single element
  10488. if ( qualifier.nodeType ) {
  10489. return jQuery.grep( elements, function( elem ) {
  10490. return ( elem === qualifier ) !== not;
  10491. } );
  10492. }
  10493. // Arraylike of elements (jQuery, arguments, Array)
  10494. if ( typeof qualifier !== "string" ) {
  10495. return jQuery.grep( elements, function( elem ) {
  10496. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10497. } );
  10498. }
  10499. // Filtered directly for both simple and complex selectors
  10500. return jQuery.filter( qualifier, elements, not );
  10501. }
  10502. jQuery.filter = function( expr, elems, not ) {
  10503. var elem = elems[ 0 ];
  10504. if ( not ) {
  10505. expr = ":not(" + expr + ")";
  10506. }
  10507. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10508. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10509. }
  10510. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10511. return elem.nodeType === 1;
  10512. } ) );
  10513. };
  10514. jQuery.fn.extend( {
  10515. find: function( selector ) {
  10516. var i, ret,
  10517. len = this.length,
  10518. self = this;
  10519. if ( typeof selector !== "string" ) {
  10520. return this.pushStack( jQuery( selector ).filter( function() {
  10521. for ( i = 0; i < len; i++ ) {
  10522. if ( jQuery.contains( self[ i ], this ) ) {
  10523. return true;
  10524. }
  10525. }
  10526. } ) );
  10527. }
  10528. ret = this.pushStack( [] );
  10529. for ( i = 0; i < len; i++ ) {
  10530. jQuery.find( selector, self[ i ], ret );
  10531. }
  10532. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10533. },
  10534. filter: function( selector ) {
  10535. return this.pushStack( winnow( this, selector || [], false ) );
  10536. },
  10537. not: function( selector ) {
  10538. return this.pushStack( winnow( this, selector || [], true ) );
  10539. },
  10540. is: function( selector ) {
  10541. return !!winnow(
  10542. this,
  10543. // If this is a positional/relative selector, check membership in the returned set
  10544. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10545. typeof selector === "string" && rneedsContext.test( selector ) ?
  10546. jQuery( selector ) :
  10547. selector || [],
  10548. false
  10549. ).length;
  10550. }
  10551. } );
  10552. // Initialize a jQuery object
  10553. // A central reference to the root jQuery(document)
  10554. var rootjQuery,
  10555. // A simple way to check for HTML strings
  10556. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10557. // Strict HTML recognition (#11290: must start with <)
  10558. // Shortcut simple #id case for speed
  10559. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10560. init = jQuery.fn.init = function( selector, context, root ) {
  10561. var match, elem;
  10562. // HANDLE: $(""), $(null), $(undefined), $(false)
  10563. if ( !selector ) {
  10564. return this;
  10565. }
  10566. // Method init() accepts an alternate rootjQuery
  10567. // so migrate can support jQuery.sub (gh-2101)
  10568. root = root || rootjQuery;
  10569. // Handle HTML strings
  10570. if ( typeof selector === "string" ) {
  10571. if ( selector[ 0 ] === "<" &&
  10572. selector[ selector.length - 1 ] === ">" &&
  10573. selector.length >= 3 ) {
  10574. // Assume that strings that start and end with <> are HTML and skip the regex check
  10575. match = [ null, selector, null ];
  10576. } else {
  10577. match = rquickExpr.exec( selector );
  10578. }
  10579. // Match html or make sure no context is specified for #id
  10580. if ( match && ( match[ 1 ] || !context ) ) {
  10581. // HANDLE: $(html) -> $(array)
  10582. if ( match[ 1 ] ) {
  10583. context = context instanceof jQuery ? context[ 0 ] : context;
  10584. // Option to run scripts is true for back-compat
  10585. // Intentionally let the error be thrown if parseHTML is not present
  10586. jQuery.merge( this, jQuery.parseHTML(
  10587. match[ 1 ],
  10588. context && context.nodeType ? context.ownerDocument || context : document,
  10589. true
  10590. ) );
  10591. // HANDLE: $(html, props)
  10592. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10593. for ( match in context ) {
  10594. // Properties of context are called as methods if possible
  10595. if ( isFunction( this[ match ] ) ) {
  10596. this[ match ]( context[ match ] );
  10597. // ...and otherwise set as attributes
  10598. } else {
  10599. this.attr( match, context[ match ] );
  10600. }
  10601. }
  10602. }
  10603. return this;
  10604. // HANDLE: $(#id)
  10605. } else {
  10606. elem = document.getElementById( match[ 2 ] );
  10607. if ( elem ) {
  10608. // Inject the element directly into the jQuery object
  10609. this[ 0 ] = elem;
  10610. this.length = 1;
  10611. }
  10612. return this;
  10613. }
  10614. // HANDLE: $(expr, $(...))
  10615. } else if ( !context || context.jquery ) {
  10616. return ( context || root ).find( selector );
  10617. // HANDLE: $(expr, context)
  10618. // (which is just equivalent to: $(context).find(expr)
  10619. } else {
  10620. return this.constructor( context ).find( selector );
  10621. }
  10622. // HANDLE: $(DOMElement)
  10623. } else if ( selector.nodeType ) {
  10624. this[ 0 ] = selector;
  10625. this.length = 1;
  10626. return this;
  10627. // HANDLE: $(function)
  10628. // Shortcut for document ready
  10629. } else if ( isFunction( selector ) ) {
  10630. return root.ready !== undefined ?
  10631. root.ready( selector ) :
  10632. // Execute immediately if ready is not present
  10633. selector( jQuery );
  10634. }
  10635. return jQuery.makeArray( selector, this );
  10636. };
  10637. // Give the init function the jQuery prototype for later instantiation
  10638. init.prototype = jQuery.fn;
  10639. // Initialize central reference
  10640. rootjQuery = jQuery( document );
  10641. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10642. // Methods guaranteed to produce a unique set when starting from a unique set
  10643. guaranteedUnique = {
  10644. children: true,
  10645. contents: true,
  10646. next: true,
  10647. prev: true
  10648. };
  10649. jQuery.fn.extend( {
  10650. has: function( target ) {
  10651. var targets = jQuery( target, this ),
  10652. l = targets.length;
  10653. return this.filter( function() {
  10654. var i = 0;
  10655. for ( ; i < l; i++ ) {
  10656. if ( jQuery.contains( this, targets[ i ] ) ) {
  10657. return true;
  10658. }
  10659. }
  10660. } );
  10661. },
  10662. closest: function( selectors, context ) {
  10663. var cur,
  10664. i = 0,
  10665. l = this.length,
  10666. matched = [],
  10667. targets = typeof selectors !== "string" && jQuery( selectors );
  10668. // Positional selectors never match, since there's no _selection_ context
  10669. if ( !rneedsContext.test( selectors ) ) {
  10670. for ( ; i < l; i++ ) {
  10671. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10672. // Always skip document fragments
  10673. if ( cur.nodeType < 11 && ( targets ?
  10674. targets.index( cur ) > -1 :
  10675. // Don't pass non-elements to Sizzle
  10676. cur.nodeType === 1 &&
  10677. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10678. matched.push( cur );
  10679. break;
  10680. }
  10681. }
  10682. }
  10683. }
  10684. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10685. },
  10686. // Determine the position of an element within the set
  10687. index: function( elem ) {
  10688. // No argument, return index in parent
  10689. if ( !elem ) {
  10690. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10691. }
  10692. // Index in selector
  10693. if ( typeof elem === "string" ) {
  10694. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10695. }
  10696. // Locate the position of the desired element
  10697. return indexOf.call( this,
  10698. // If it receives a jQuery object, the first element is used
  10699. elem.jquery ? elem[ 0 ] : elem
  10700. );
  10701. },
  10702. add: function( selector, context ) {
  10703. return this.pushStack(
  10704. jQuery.uniqueSort(
  10705. jQuery.merge( this.get(), jQuery( selector, context ) )
  10706. )
  10707. );
  10708. },
  10709. addBack: function( selector ) {
  10710. return this.add( selector == null ?
  10711. this.prevObject : this.prevObject.filter( selector )
  10712. );
  10713. }
  10714. } );
  10715. function sibling( cur, dir ) {
  10716. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10717. return cur;
  10718. }
  10719. jQuery.each( {
  10720. parent: function( elem ) {
  10721. var parent = elem.parentNode;
  10722. return parent && parent.nodeType !== 11 ? parent : null;
  10723. },
  10724. parents: function( elem ) {
  10725. return dir( elem, "parentNode" );
  10726. },
  10727. parentsUntil: function( elem, i, until ) {
  10728. return dir( elem, "parentNode", until );
  10729. },
  10730. next: function( elem ) {
  10731. return sibling( elem, "nextSibling" );
  10732. },
  10733. prev: function( elem ) {
  10734. return sibling( elem, "previousSibling" );
  10735. },
  10736. nextAll: function( elem ) {
  10737. return dir( elem, "nextSibling" );
  10738. },
  10739. prevAll: function( elem ) {
  10740. return dir( elem, "previousSibling" );
  10741. },
  10742. nextUntil: function( elem, i, until ) {
  10743. return dir( elem, "nextSibling", until );
  10744. },
  10745. prevUntil: function( elem, i, until ) {
  10746. return dir( elem, "previousSibling", until );
  10747. },
  10748. siblings: function( elem ) {
  10749. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10750. },
  10751. children: function( elem ) {
  10752. return siblings( elem.firstChild );
  10753. },
  10754. contents: function( elem ) {
  10755. if ( typeof elem.contentDocument !== "undefined" ) {
  10756. return elem.contentDocument;
  10757. }
  10758. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10759. // Treat the template element as a regular one in browsers that
  10760. // don't support it.
  10761. if ( nodeName( elem, "template" ) ) {
  10762. elem = elem.content || elem;
  10763. }
  10764. return jQuery.merge( [], elem.childNodes );
  10765. }
  10766. }, function( name, fn ) {
  10767. jQuery.fn[ name ] = function( until, selector ) {
  10768. var matched = jQuery.map( this, fn, until );
  10769. if ( name.slice( -5 ) !== "Until" ) {
  10770. selector = until;
  10771. }
  10772. if ( selector && typeof selector === "string" ) {
  10773. matched = jQuery.filter( selector, matched );
  10774. }
  10775. if ( this.length > 1 ) {
  10776. // Remove duplicates
  10777. if ( !guaranteedUnique[ name ] ) {
  10778. jQuery.uniqueSort( matched );
  10779. }
  10780. // Reverse order for parents* and prev-derivatives
  10781. if ( rparentsprev.test( name ) ) {
  10782. matched.reverse();
  10783. }
  10784. }
  10785. return this.pushStack( matched );
  10786. };
  10787. } );
  10788. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10789. // Convert String-formatted options into Object-formatted ones
  10790. function createOptions( options ) {
  10791. var object = {};
  10792. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10793. object[ flag ] = true;
  10794. } );
  10795. return object;
  10796. }
  10797. /*
  10798. * Create a callback list using the following parameters:
  10799. *
  10800. * options: an optional list of space-separated options that will change how
  10801. * the callback list behaves or a more traditional option object
  10802. *
  10803. * By default a callback list will act like an event callback list and can be
  10804. * "fired" multiple times.
  10805. *
  10806. * Possible options:
  10807. *
  10808. * once: will ensure the callback list can only be fired once (like a Deferred)
  10809. *
  10810. * memory: will keep track of previous values and will call any callback added
  10811. * after the list has been fired right away with the latest "memorized"
  10812. * values (like a Deferred)
  10813. *
  10814. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10815. *
  10816. * stopOnFalse: interrupt callings when a callback returns false
  10817. *
  10818. */
  10819. jQuery.Callbacks = function( options ) {
  10820. // Convert options from String-formatted to Object-formatted if needed
  10821. // (we check in cache first)
  10822. options = typeof options === "string" ?
  10823. createOptions( options ) :
  10824. jQuery.extend( {}, options );
  10825. var // Flag to know if list is currently firing
  10826. firing,
  10827. // Last fire value for non-forgettable lists
  10828. memory,
  10829. // Flag to know if list was already fired
  10830. fired,
  10831. // Flag to prevent firing
  10832. locked,
  10833. // Actual callback list
  10834. list = [],
  10835. // Queue of execution data for repeatable lists
  10836. queue = [],
  10837. // Index of currently firing callback (modified by add/remove as needed)
  10838. firingIndex = -1,
  10839. // Fire callbacks
  10840. fire = function() {
  10841. // Enforce single-firing
  10842. locked = locked || options.once;
  10843. // Execute callbacks for all pending executions,
  10844. // respecting firingIndex overrides and runtime changes
  10845. fired = firing = true;
  10846. for ( ; queue.length; firingIndex = -1 ) {
  10847. memory = queue.shift();
  10848. while ( ++firingIndex < list.length ) {
  10849. // Run callback and check for early termination
  10850. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10851. options.stopOnFalse ) {
  10852. // Jump to end and forget the data so .add doesn't re-fire
  10853. firingIndex = list.length;
  10854. memory = false;
  10855. }
  10856. }
  10857. }
  10858. // Forget the data if we're done with it
  10859. if ( !options.memory ) {
  10860. memory = false;
  10861. }
  10862. firing = false;
  10863. // Clean up if we're done firing for good
  10864. if ( locked ) {
  10865. // Keep an empty list if we have data for future add calls
  10866. if ( memory ) {
  10867. list = [];
  10868. // Otherwise, this object is spent
  10869. } else {
  10870. list = "";
  10871. }
  10872. }
  10873. },
  10874. // Actual Callbacks object
  10875. self = {
  10876. // Add a callback or a collection of callbacks to the list
  10877. add: function() {
  10878. if ( list ) {
  10879. // If we have memory from a past run, we should fire after adding
  10880. if ( memory && !firing ) {
  10881. firingIndex = list.length - 1;
  10882. queue.push( memory );
  10883. }
  10884. ( function add( args ) {
  10885. jQuery.each( args, function( _, arg ) {
  10886. if ( isFunction( arg ) ) {
  10887. if ( !options.unique || !self.has( arg ) ) {
  10888. list.push( arg );
  10889. }
  10890. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10891. // Inspect recursively
  10892. add( arg );
  10893. }
  10894. } );
  10895. } )( arguments );
  10896. if ( memory && !firing ) {
  10897. fire();
  10898. }
  10899. }
  10900. return this;
  10901. },
  10902. // Remove a callback from the list
  10903. remove: function() {
  10904. jQuery.each( arguments, function( _, arg ) {
  10905. var index;
  10906. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10907. list.splice( index, 1 );
  10908. // Handle firing indexes
  10909. if ( index <= firingIndex ) {
  10910. firingIndex--;
  10911. }
  10912. }
  10913. } );
  10914. return this;
  10915. },
  10916. // Check if a given callback is in the list.
  10917. // If no argument is given, return whether or not list has callbacks attached.
  10918. has: function( fn ) {
  10919. return fn ?
  10920. jQuery.inArray( fn, list ) > -1 :
  10921. list.length > 0;
  10922. },
  10923. // Remove all callbacks from the list
  10924. empty: function() {
  10925. if ( list ) {
  10926. list = [];
  10927. }
  10928. return this;
  10929. },
  10930. // Disable .fire and .add
  10931. // Abort any current/pending executions
  10932. // Clear all callbacks and values
  10933. disable: function() {
  10934. locked = queue = [];
  10935. list = memory = "";
  10936. return this;
  10937. },
  10938. disabled: function() {
  10939. return !list;
  10940. },
  10941. // Disable .fire
  10942. // Also disable .add unless we have memory (since it would have no effect)
  10943. // Abort any pending executions
  10944. lock: function() {
  10945. locked = queue = [];
  10946. if ( !memory && !firing ) {
  10947. list = memory = "";
  10948. }
  10949. return this;
  10950. },
  10951. locked: function() {
  10952. return !!locked;
  10953. },
  10954. // Call all callbacks with the given context and arguments
  10955. fireWith: function( context, args ) {
  10956. if ( !locked ) {
  10957. args = args || [];
  10958. args = [ context, args.slice ? args.slice() : args ];
  10959. queue.push( args );
  10960. if ( !firing ) {
  10961. fire();
  10962. }
  10963. }
  10964. return this;
  10965. },
  10966. // Call all the callbacks with the given arguments
  10967. fire: function() {
  10968. self.fireWith( this, arguments );
  10969. return this;
  10970. },
  10971. // To know if the callbacks have already been called at least once
  10972. fired: function() {
  10973. return !!fired;
  10974. }
  10975. };
  10976. return self;
  10977. };
  10978. function Identity( v ) {
  10979. return v;
  10980. }
  10981. function Thrower( ex ) {
  10982. throw ex;
  10983. }
  10984. function adoptValue( value, resolve, reject, noValue ) {
  10985. var method;
  10986. try {
  10987. // Check for promise aspect first to privilege synchronous behavior
  10988. if ( value && isFunction( ( method = value.promise ) ) ) {
  10989. method.call( value ).done( resolve ).fail( reject );
  10990. // Other thenables
  10991. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10992. method.call( value, resolve, reject );
  10993. // Other non-thenables
  10994. } else {
  10995. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10996. // * false: [ value ].slice( 0 ) => resolve( value )
  10997. // * true: [ value ].slice( 1 ) => resolve()
  10998. resolve.apply( undefined, [ value ].slice( noValue ) );
  10999. }
  11000. // For Promises/A+, convert exceptions into rejections
  11001. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  11002. // Deferred#then to conditionally suppress rejection.
  11003. } catch ( value ) {
  11004. // Support: Android 4.0 only
  11005. // Strict mode functions invoked without .call/.apply get global-object context
  11006. reject.apply( undefined, [ value ] );
  11007. }
  11008. }
  11009. jQuery.extend( {
  11010. Deferred: function( func ) {
  11011. var tuples = [
  11012. // action, add listener, callbacks,
  11013. // ... .then handlers, argument index, [final state]
  11014. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  11015. jQuery.Callbacks( "memory" ), 2 ],
  11016. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  11017. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  11018. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  11019. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  11020. ],
  11021. state = "pending",
  11022. promise = {
  11023. state: function() {
  11024. return state;
  11025. },
  11026. always: function() {
  11027. deferred.done( arguments ).fail( arguments );
  11028. return this;
  11029. },
  11030. "catch": function( fn ) {
  11031. return promise.then( null, fn );
  11032. },
  11033. // Keep pipe for back-compat
  11034. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  11035. var fns = arguments;
  11036. return jQuery.Deferred( function( newDefer ) {
  11037. jQuery.each( tuples, function( i, tuple ) {
  11038. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  11039. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  11040. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  11041. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  11042. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  11043. deferred[ tuple[ 1 ] ]( function() {
  11044. var returned = fn && fn.apply( this, arguments );
  11045. if ( returned && isFunction( returned.promise ) ) {
  11046. returned.promise()
  11047. .progress( newDefer.notify )
  11048. .done( newDefer.resolve )
  11049. .fail( newDefer.reject );
  11050. } else {
  11051. newDefer[ tuple[ 0 ] + "With" ](
  11052. this,
  11053. fn ? [ returned ] : arguments
  11054. );
  11055. }
  11056. } );
  11057. } );
  11058. fns = null;
  11059. } ).promise();
  11060. },
  11061. then: function( onFulfilled, onRejected, onProgress ) {
  11062. var maxDepth = 0;
  11063. function resolve( depth, deferred, handler, special ) {
  11064. return function() {
  11065. var that = this,
  11066. args = arguments,
  11067. mightThrow = function() {
  11068. var returned, then;
  11069. // Support: Promises/A+ section 2.3.3.3.3
  11070. // https://promisesaplus.com/#point-59
  11071. // Ignore double-resolution attempts
  11072. if ( depth < maxDepth ) {
  11073. return;
  11074. }
  11075. returned = handler.apply( that, args );
  11076. // Support: Promises/A+ section 2.3.1
  11077. // https://promisesaplus.com/#point-48
  11078. if ( returned === deferred.promise() ) {
  11079. throw new TypeError( "Thenable self-resolution" );
  11080. }
  11081. // Support: Promises/A+ sections 2.3.3.1, 3.5
  11082. // https://promisesaplus.com/#point-54
  11083. // https://promisesaplus.com/#point-75
  11084. // Retrieve `then` only once
  11085. then = returned &&
  11086. // Support: Promises/A+ section 2.3.4
  11087. // https://promisesaplus.com/#point-64
  11088. // Only check objects and functions for thenability
  11089. ( typeof returned === "object" ||
  11090. typeof returned === "function" ) &&
  11091. returned.then;
  11092. // Handle a returned thenable
  11093. if ( isFunction( then ) ) {
  11094. // Special processors (notify) just wait for resolution
  11095. if ( special ) {
  11096. then.call(
  11097. returned,
  11098. resolve( maxDepth, deferred, Identity, special ),
  11099. resolve( maxDepth, deferred, Thrower, special )
  11100. );
  11101. // Normal processors (resolve) also hook into progress
  11102. } else {
  11103. // ...and disregard older resolution values
  11104. maxDepth++;
  11105. then.call(
  11106. returned,
  11107. resolve( maxDepth, deferred, Identity, special ),
  11108. resolve( maxDepth, deferred, Thrower, special ),
  11109. resolve( maxDepth, deferred, Identity,
  11110. deferred.notifyWith )
  11111. );
  11112. }
  11113. // Handle all other returned values
  11114. } else {
  11115. // Only substitute handlers pass on context
  11116. // and multiple values (non-spec behavior)
  11117. if ( handler !== Identity ) {
  11118. that = undefined;
  11119. args = [ returned ];
  11120. }
  11121. // Process the value(s)
  11122. // Default process is resolve
  11123. ( special || deferred.resolveWith )( that, args );
  11124. }
  11125. },
  11126. // Only normal processors (resolve) catch and reject exceptions
  11127. process = special ?
  11128. mightThrow :
  11129. function() {
  11130. try {
  11131. mightThrow();
  11132. } catch ( e ) {
  11133. if ( jQuery.Deferred.exceptionHook ) {
  11134. jQuery.Deferred.exceptionHook( e,
  11135. process.stackTrace );
  11136. }
  11137. // Support: Promises/A+ section 2.3.3.3.4.1
  11138. // https://promisesaplus.com/#point-61
  11139. // Ignore post-resolution exceptions
  11140. if ( depth + 1 >= maxDepth ) {
  11141. // Only substitute handlers pass on context
  11142. // and multiple values (non-spec behavior)
  11143. if ( handler !== Thrower ) {
  11144. that = undefined;
  11145. args = [ e ];
  11146. }
  11147. deferred.rejectWith( that, args );
  11148. }
  11149. }
  11150. };
  11151. // Support: Promises/A+ section 2.3.3.3.1
  11152. // https://promisesaplus.com/#point-57
  11153. // Re-resolve promises immediately to dodge false rejection from
  11154. // subsequent errors
  11155. if ( depth ) {
  11156. process();
  11157. } else {
  11158. // Call an optional hook to record the stack, in case of exception
  11159. // since it's otherwise lost when execution goes async
  11160. if ( jQuery.Deferred.getStackHook ) {
  11161. process.stackTrace = jQuery.Deferred.getStackHook();
  11162. }
  11163. window.setTimeout( process );
  11164. }
  11165. };
  11166. }
  11167. return jQuery.Deferred( function( newDefer ) {
  11168. // progress_handlers.add( ... )
  11169. tuples[ 0 ][ 3 ].add(
  11170. resolve(
  11171. 0,
  11172. newDefer,
  11173. isFunction( onProgress ) ?
  11174. onProgress :
  11175. Identity,
  11176. newDefer.notifyWith
  11177. )
  11178. );
  11179. // fulfilled_handlers.add( ... )
  11180. tuples[ 1 ][ 3 ].add(
  11181. resolve(
  11182. 0,
  11183. newDefer,
  11184. isFunction( onFulfilled ) ?
  11185. onFulfilled :
  11186. Identity
  11187. )
  11188. );
  11189. // rejected_handlers.add( ... )
  11190. tuples[ 2 ][ 3 ].add(
  11191. resolve(
  11192. 0,
  11193. newDefer,
  11194. isFunction( onRejected ) ?
  11195. onRejected :
  11196. Thrower
  11197. )
  11198. );
  11199. } ).promise();
  11200. },
  11201. // Get a promise for this deferred
  11202. // If obj is provided, the promise aspect is added to the object
  11203. promise: function( obj ) {
  11204. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11205. }
  11206. },
  11207. deferred = {};
  11208. // Add list-specific methods
  11209. jQuery.each( tuples, function( i, tuple ) {
  11210. var list = tuple[ 2 ],
  11211. stateString = tuple[ 5 ];
  11212. // promise.progress = list.add
  11213. // promise.done = list.add
  11214. // promise.fail = list.add
  11215. promise[ tuple[ 1 ] ] = list.add;
  11216. // Handle state
  11217. if ( stateString ) {
  11218. list.add(
  11219. function() {
  11220. // state = "resolved" (i.e., fulfilled)
  11221. // state = "rejected"
  11222. state = stateString;
  11223. },
  11224. // rejected_callbacks.disable
  11225. // fulfilled_callbacks.disable
  11226. tuples[ 3 - i ][ 2 ].disable,
  11227. // rejected_handlers.disable
  11228. // fulfilled_handlers.disable
  11229. tuples[ 3 - i ][ 3 ].disable,
  11230. // progress_callbacks.lock
  11231. tuples[ 0 ][ 2 ].lock,
  11232. // progress_handlers.lock
  11233. tuples[ 0 ][ 3 ].lock
  11234. );
  11235. }
  11236. // progress_handlers.fire
  11237. // fulfilled_handlers.fire
  11238. // rejected_handlers.fire
  11239. list.add( tuple[ 3 ].fire );
  11240. // deferred.notify = function() { deferred.notifyWith(...) }
  11241. // deferred.resolve = function() { deferred.resolveWith(...) }
  11242. // deferred.reject = function() { deferred.rejectWith(...) }
  11243. deferred[ tuple[ 0 ] ] = function() {
  11244. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11245. return this;
  11246. };
  11247. // deferred.notifyWith = list.fireWith
  11248. // deferred.resolveWith = list.fireWith
  11249. // deferred.rejectWith = list.fireWith
  11250. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11251. } );
  11252. // Make the deferred a promise
  11253. promise.promise( deferred );
  11254. // Call given func if any
  11255. if ( func ) {
  11256. func.call( deferred, deferred );
  11257. }
  11258. // All done!
  11259. return deferred;
  11260. },
  11261. // Deferred helper
  11262. when: function( singleValue ) {
  11263. var
  11264. // count of uncompleted subordinates
  11265. remaining = arguments.length,
  11266. // count of unprocessed arguments
  11267. i = remaining,
  11268. // subordinate fulfillment data
  11269. resolveContexts = Array( i ),
  11270. resolveValues = slice.call( arguments ),
  11271. // the master Deferred
  11272. master = jQuery.Deferred(),
  11273. // subordinate callback factory
  11274. updateFunc = function( i ) {
  11275. return function( value ) {
  11276. resolveContexts[ i ] = this;
  11277. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11278. if ( !( --remaining ) ) {
  11279. master.resolveWith( resolveContexts, resolveValues );
  11280. }
  11281. };
  11282. };
  11283. // Single- and empty arguments are adopted like Promise.resolve
  11284. if ( remaining <= 1 ) {
  11285. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11286. !remaining );
  11287. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11288. if ( master.state() === "pending" ||
  11289. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11290. return master.then();
  11291. }
  11292. }
  11293. // Multiple arguments are aggregated like Promise.all array elements
  11294. while ( i-- ) {
  11295. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11296. }
  11297. return master.promise();
  11298. }
  11299. } );
  11300. // These usually indicate a programmer mistake during development,
  11301. // warn about them ASAP rather than swallowing them by default.
  11302. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11303. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11304. // Support: IE 8 - 9 only
  11305. // Console exists when dev tools are open, which can happen at any time
  11306. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11307. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11308. }
  11309. };
  11310. jQuery.readyException = function( error ) {
  11311. window.setTimeout( function() {
  11312. throw error;
  11313. } );
  11314. };
  11315. // The deferred used on DOM ready
  11316. var readyList = jQuery.Deferred();
  11317. jQuery.fn.ready = function( fn ) {
  11318. readyList
  11319. .then( fn )
  11320. // Wrap jQuery.readyException in a function so that the lookup
  11321. // happens at the time of error handling instead of callback
  11322. // registration.
  11323. .catch( function( error ) {
  11324. jQuery.readyException( error );
  11325. } );
  11326. return this;
  11327. };
  11328. jQuery.extend( {
  11329. // Is the DOM ready to be used? Set to true once it occurs.
  11330. isReady: false,
  11331. // A counter to track how many items to wait for before
  11332. // the ready event fires. See #6781
  11333. readyWait: 1,
  11334. // Handle when the DOM is ready
  11335. ready: function( wait ) {
  11336. // Abort if there are pending holds or we're already ready
  11337. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11338. return;
  11339. }
  11340. // Remember that the DOM is ready
  11341. jQuery.isReady = true;
  11342. // If a normal DOM Ready event fired, decrement, and wait if need be
  11343. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11344. return;
  11345. }
  11346. // If there are functions bound, to execute
  11347. readyList.resolveWith( document, [ jQuery ] );
  11348. }
  11349. } );
  11350. jQuery.ready.then = readyList.then;
  11351. // The ready event handler and self cleanup method
  11352. function completed() {
  11353. document.removeEventListener( "DOMContentLoaded", completed );
  11354. window.removeEventListener( "load", completed );
  11355. jQuery.ready();
  11356. }
  11357. // Catch cases where $(document).ready() is called
  11358. // after the browser event has already occurred.
  11359. // Support: IE <=9 - 10 only
  11360. // Older IE sometimes signals "interactive" too soon
  11361. if ( document.readyState === "complete" ||
  11362. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11363. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11364. window.setTimeout( jQuery.ready );
  11365. } else {
  11366. // Use the handy event callback
  11367. document.addEventListener( "DOMContentLoaded", completed );
  11368. // A fallback to window.onload, that will always work
  11369. window.addEventListener( "load", completed );
  11370. }
  11371. // Multifunctional method to get and set values of a collection
  11372. // The value/s can optionally be executed if it's a function
  11373. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11374. var i = 0,
  11375. len = elems.length,
  11376. bulk = key == null;
  11377. // Sets many values
  11378. if ( toType( key ) === "object" ) {
  11379. chainable = true;
  11380. for ( i in key ) {
  11381. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11382. }
  11383. // Sets one value
  11384. } else if ( value !== undefined ) {
  11385. chainable = true;
  11386. if ( !isFunction( value ) ) {
  11387. raw = true;
  11388. }
  11389. if ( bulk ) {
  11390. // Bulk operations run against the entire set
  11391. if ( raw ) {
  11392. fn.call( elems, value );
  11393. fn = null;
  11394. // ...except when executing function values
  11395. } else {
  11396. bulk = fn;
  11397. fn = function( elem, key, value ) {
  11398. return bulk.call( jQuery( elem ), value );
  11399. };
  11400. }
  11401. }
  11402. if ( fn ) {
  11403. for ( ; i < len; i++ ) {
  11404. fn(
  11405. elems[ i ], key, raw ?
  11406. value :
  11407. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11408. );
  11409. }
  11410. }
  11411. }
  11412. if ( chainable ) {
  11413. return elems;
  11414. }
  11415. // Gets
  11416. if ( bulk ) {
  11417. return fn.call( elems );
  11418. }
  11419. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11420. };
  11421. // Matches dashed string for camelizing
  11422. var rmsPrefix = /^-ms-/,
  11423. rdashAlpha = /-([a-z])/g;
  11424. // Used by camelCase as callback to replace()
  11425. function fcamelCase( all, letter ) {
  11426. return letter.toUpperCase();
  11427. }
  11428. // Convert dashed to camelCase; used by the css and data modules
  11429. // Support: IE <=9 - 11, Edge 12 - 15
  11430. // Microsoft forgot to hump their vendor prefix (#9572)
  11431. function camelCase( string ) {
  11432. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11433. }
  11434. var acceptData = function( owner ) {
  11435. // Accepts only:
  11436. // - Node
  11437. // - Node.ELEMENT_NODE
  11438. // - Node.DOCUMENT_NODE
  11439. // - Object
  11440. // - Any
  11441. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11442. };
  11443. function Data() {
  11444. this.expando = jQuery.expando + Data.uid++;
  11445. }
  11446. Data.uid = 1;
  11447. Data.prototype = {
  11448. cache: function( owner ) {
  11449. // Check if the owner object already has a cache
  11450. var value = owner[ this.expando ];
  11451. // If not, create one
  11452. if ( !value ) {
  11453. value = {};
  11454. // We can accept data for non-element nodes in modern browsers,
  11455. // but we should not, see #8335.
  11456. // Always return an empty object.
  11457. if ( acceptData( owner ) ) {
  11458. // If it is a node unlikely to be stringify-ed or looped over
  11459. // use plain assignment
  11460. if ( owner.nodeType ) {
  11461. owner[ this.expando ] = value;
  11462. // Otherwise secure it in a non-enumerable property
  11463. // configurable must be true to allow the property to be
  11464. // deleted when data is removed
  11465. } else {
  11466. Object.defineProperty( owner, this.expando, {
  11467. value: value,
  11468. configurable: true
  11469. } );
  11470. }
  11471. }
  11472. }
  11473. return value;
  11474. },
  11475. set: function( owner, data, value ) {
  11476. var prop,
  11477. cache = this.cache( owner );
  11478. // Handle: [ owner, key, value ] args
  11479. // Always use camelCase key (gh-2257)
  11480. if ( typeof data === "string" ) {
  11481. cache[ camelCase( data ) ] = value;
  11482. // Handle: [ owner, { properties } ] args
  11483. } else {
  11484. // Copy the properties one-by-one to the cache object
  11485. for ( prop in data ) {
  11486. cache[ camelCase( prop ) ] = data[ prop ];
  11487. }
  11488. }
  11489. return cache;
  11490. },
  11491. get: function( owner, key ) {
  11492. return key === undefined ?
  11493. this.cache( owner ) :
  11494. // Always use camelCase key (gh-2257)
  11495. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11496. },
  11497. access: function( owner, key, value ) {
  11498. // In cases where either:
  11499. //
  11500. // 1. No key was specified
  11501. // 2. A string key was specified, but no value provided
  11502. //
  11503. // Take the "read" path and allow the get method to determine
  11504. // which value to return, respectively either:
  11505. //
  11506. // 1. The entire cache object
  11507. // 2. The data stored at the key
  11508. //
  11509. if ( key === undefined ||
  11510. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11511. return this.get( owner, key );
  11512. }
  11513. // When the key is not a string, or both a key and value
  11514. // are specified, set or extend (existing objects) with either:
  11515. //
  11516. // 1. An object of properties
  11517. // 2. A key and value
  11518. //
  11519. this.set( owner, key, value );
  11520. // Since the "set" path can have two possible entry points
  11521. // return the expected data based on which path was taken[*]
  11522. return value !== undefined ? value : key;
  11523. },
  11524. remove: function( owner, key ) {
  11525. var i,
  11526. cache = owner[ this.expando ];
  11527. if ( cache === undefined ) {
  11528. return;
  11529. }
  11530. if ( key !== undefined ) {
  11531. // Support array or space separated string of keys
  11532. if ( Array.isArray( key ) ) {
  11533. // If key is an array of keys...
  11534. // We always set camelCase keys, so remove that.
  11535. key = key.map( camelCase );
  11536. } else {
  11537. key = camelCase( key );
  11538. // If a key with the spaces exists, use it.
  11539. // Otherwise, create an array by matching non-whitespace
  11540. key = key in cache ?
  11541. [ key ] :
  11542. ( key.match( rnothtmlwhite ) || [] );
  11543. }
  11544. i = key.length;
  11545. while ( i-- ) {
  11546. delete cache[ key[ i ] ];
  11547. }
  11548. }
  11549. // Remove the expando if there's no more data
  11550. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11551. // Support: Chrome <=35 - 45
  11552. // Webkit & Blink performance suffers when deleting properties
  11553. // from DOM nodes, so set to undefined instead
  11554. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11555. if ( owner.nodeType ) {
  11556. owner[ this.expando ] = undefined;
  11557. } else {
  11558. delete owner[ this.expando ];
  11559. }
  11560. }
  11561. },
  11562. hasData: function( owner ) {
  11563. var cache = owner[ this.expando ];
  11564. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11565. }
  11566. };
  11567. var dataPriv = new Data();
  11568. var dataUser = new Data();
  11569. // Implementation Summary
  11570. //
  11571. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11572. // 2. Improve the module's maintainability by reducing the storage
  11573. // paths to a single mechanism.
  11574. // 3. Use the same single mechanism to support "private" and "user" data.
  11575. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11576. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11577. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11578. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11579. rmultiDash = /[A-Z]/g;
  11580. function getData( data ) {
  11581. if ( data === "true" ) {
  11582. return true;
  11583. }
  11584. if ( data === "false" ) {
  11585. return false;
  11586. }
  11587. if ( data === "null" ) {
  11588. return null;
  11589. }
  11590. // Only convert to a number if it doesn't change the string
  11591. if ( data === +data + "" ) {
  11592. return +data;
  11593. }
  11594. if ( rbrace.test( data ) ) {
  11595. return JSON.parse( data );
  11596. }
  11597. return data;
  11598. }
  11599. function dataAttr( elem, key, data ) {
  11600. var name;
  11601. // If nothing was found internally, try to fetch any
  11602. // data from the HTML5 data-* attribute
  11603. if ( data === undefined && elem.nodeType === 1 ) {
  11604. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11605. data = elem.getAttribute( name );
  11606. if ( typeof data === "string" ) {
  11607. try {
  11608. data = getData( data );
  11609. } catch ( e ) {}
  11610. // Make sure we set the data so it isn't changed later
  11611. dataUser.set( elem, key, data );
  11612. } else {
  11613. data = undefined;
  11614. }
  11615. }
  11616. return data;
  11617. }
  11618. jQuery.extend( {
  11619. hasData: function( elem ) {
  11620. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11621. },
  11622. data: function( elem, name, data ) {
  11623. return dataUser.access( elem, name, data );
  11624. },
  11625. removeData: function( elem, name ) {
  11626. dataUser.remove( elem, name );
  11627. },
  11628. // TODO: Now that all calls to _data and _removeData have been replaced
  11629. // with direct calls to dataPriv methods, these can be deprecated.
  11630. _data: function( elem, name, data ) {
  11631. return dataPriv.access( elem, name, data );
  11632. },
  11633. _removeData: function( elem, name ) {
  11634. dataPriv.remove( elem, name );
  11635. }
  11636. } );
  11637. jQuery.fn.extend( {
  11638. data: function( key, value ) {
  11639. var i, name, data,
  11640. elem = this[ 0 ],
  11641. attrs = elem && elem.attributes;
  11642. // Gets all values
  11643. if ( key === undefined ) {
  11644. if ( this.length ) {
  11645. data = dataUser.get( elem );
  11646. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11647. i = attrs.length;
  11648. while ( i-- ) {
  11649. // Support: IE 11 only
  11650. // The attrs elements can be null (#14894)
  11651. if ( attrs[ i ] ) {
  11652. name = attrs[ i ].name;
  11653. if ( name.indexOf( "data-" ) === 0 ) {
  11654. name = camelCase( name.slice( 5 ) );
  11655. dataAttr( elem, name, data[ name ] );
  11656. }
  11657. }
  11658. }
  11659. dataPriv.set( elem, "hasDataAttrs", true );
  11660. }
  11661. }
  11662. return data;
  11663. }
  11664. // Sets multiple values
  11665. if ( typeof key === "object" ) {
  11666. return this.each( function() {
  11667. dataUser.set( this, key );
  11668. } );
  11669. }
  11670. return access( this, function( value ) {
  11671. var data;
  11672. // The calling jQuery object (element matches) is not empty
  11673. // (and therefore has an element appears at this[ 0 ]) and the
  11674. // `value` parameter was not undefined. An empty jQuery object
  11675. // will result in `undefined` for elem = this[ 0 ] which will
  11676. // throw an exception if an attempt to read a data cache is made.
  11677. if ( elem && value === undefined ) {
  11678. // Attempt to get data from the cache
  11679. // The key will always be camelCased in Data
  11680. data = dataUser.get( elem, key );
  11681. if ( data !== undefined ) {
  11682. return data;
  11683. }
  11684. // Attempt to "discover" the data in
  11685. // HTML5 custom data-* attrs
  11686. data = dataAttr( elem, key );
  11687. if ( data !== undefined ) {
  11688. return data;
  11689. }
  11690. // We tried really hard, but the data doesn't exist.
  11691. return;
  11692. }
  11693. // Set the data...
  11694. this.each( function() {
  11695. // We always store the camelCased key
  11696. dataUser.set( this, key, value );
  11697. } );
  11698. }, null, value, arguments.length > 1, null, true );
  11699. },
  11700. removeData: function( key ) {
  11701. return this.each( function() {
  11702. dataUser.remove( this, key );
  11703. } );
  11704. }
  11705. } );
  11706. jQuery.extend( {
  11707. queue: function( elem, type, data ) {
  11708. var queue;
  11709. if ( elem ) {
  11710. type = ( type || "fx" ) + "queue";
  11711. queue = dataPriv.get( elem, type );
  11712. // Speed up dequeue by getting out quickly if this is just a lookup
  11713. if ( data ) {
  11714. if ( !queue || Array.isArray( data ) ) {
  11715. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11716. } else {
  11717. queue.push( data );
  11718. }
  11719. }
  11720. return queue || [];
  11721. }
  11722. },
  11723. dequeue: function( elem, type ) {
  11724. type = type || "fx";
  11725. var queue = jQuery.queue( elem, type ),
  11726. startLength = queue.length,
  11727. fn = queue.shift(),
  11728. hooks = jQuery._queueHooks( elem, type ),
  11729. next = function() {
  11730. jQuery.dequeue( elem, type );
  11731. };
  11732. // If the fx queue is dequeued, always remove the progress sentinel
  11733. if ( fn === "inprogress" ) {
  11734. fn = queue.shift();
  11735. startLength--;
  11736. }
  11737. if ( fn ) {
  11738. // Add a progress sentinel to prevent the fx queue from being
  11739. // automatically dequeued
  11740. if ( type === "fx" ) {
  11741. queue.unshift( "inprogress" );
  11742. }
  11743. // Clear up the last queue stop function
  11744. delete hooks.stop;
  11745. fn.call( elem, next, hooks );
  11746. }
  11747. if ( !startLength && hooks ) {
  11748. hooks.empty.fire();
  11749. }
  11750. },
  11751. // Not public - generate a queueHooks object, or return the current one
  11752. _queueHooks: function( elem, type ) {
  11753. var key = type + "queueHooks";
  11754. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11755. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11756. dataPriv.remove( elem, [ type + "queue", key ] );
  11757. } )
  11758. } );
  11759. }
  11760. } );
  11761. jQuery.fn.extend( {
  11762. queue: function( type, data ) {
  11763. var setter = 2;
  11764. if ( typeof type !== "string" ) {
  11765. data = type;
  11766. type = "fx";
  11767. setter--;
  11768. }
  11769. if ( arguments.length < setter ) {
  11770. return jQuery.queue( this[ 0 ], type );
  11771. }
  11772. return data === undefined ?
  11773. this :
  11774. this.each( function() {
  11775. var queue = jQuery.queue( this, type, data );
  11776. // Ensure a hooks for this queue
  11777. jQuery._queueHooks( this, type );
  11778. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11779. jQuery.dequeue( this, type );
  11780. }
  11781. } );
  11782. },
  11783. dequeue: function( type ) {
  11784. return this.each( function() {
  11785. jQuery.dequeue( this, type );
  11786. } );
  11787. },
  11788. clearQueue: function( type ) {
  11789. return this.queue( type || "fx", [] );
  11790. },
  11791. // Get a promise resolved when queues of a certain type
  11792. // are emptied (fx is the type by default)
  11793. promise: function( type, obj ) {
  11794. var tmp,
  11795. count = 1,
  11796. defer = jQuery.Deferred(),
  11797. elements = this,
  11798. i = this.length,
  11799. resolve = function() {
  11800. if ( !( --count ) ) {
  11801. defer.resolveWith( elements, [ elements ] );
  11802. }
  11803. };
  11804. if ( typeof type !== "string" ) {
  11805. obj = type;
  11806. type = undefined;
  11807. }
  11808. type = type || "fx";
  11809. while ( i-- ) {
  11810. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11811. if ( tmp && tmp.empty ) {
  11812. count++;
  11813. tmp.empty.add( resolve );
  11814. }
  11815. }
  11816. resolve();
  11817. return defer.promise( obj );
  11818. }
  11819. } );
  11820. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11821. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11822. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11823. var documentElement = document.documentElement;
  11824. var isAttached = function( elem ) {
  11825. return jQuery.contains( elem.ownerDocument, elem );
  11826. },
  11827. composed = { composed: true };
  11828. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11829. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11830. // Support: iOS 10.0-10.2 only
  11831. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11832. // leading to errors. We need to check for `getRootNode`.
  11833. if ( documentElement.getRootNode ) {
  11834. isAttached = function( elem ) {
  11835. return jQuery.contains( elem.ownerDocument, elem ) ||
  11836. elem.getRootNode( composed ) === elem.ownerDocument;
  11837. };
  11838. }
  11839. var isHiddenWithinTree = function( elem, el ) {
  11840. // isHiddenWithinTree might be called from jQuery#filter function;
  11841. // in that case, element will be second argument
  11842. elem = el || elem;
  11843. // Inline style trumps all
  11844. return elem.style.display === "none" ||
  11845. elem.style.display === "" &&
  11846. // Otherwise, check computed style
  11847. // Support: Firefox <=43 - 45
  11848. // Disconnected elements can have computed display: none, so first confirm that elem is
  11849. // in the document.
  11850. isAttached( elem ) &&
  11851. jQuery.css( elem, "display" ) === "none";
  11852. };
  11853. var swap = function( elem, options, callback, args ) {
  11854. var ret, name,
  11855. old = {};
  11856. // Remember the old values, and insert the new ones
  11857. for ( name in options ) {
  11858. old[ name ] = elem.style[ name ];
  11859. elem.style[ name ] = options[ name ];
  11860. }
  11861. ret = callback.apply( elem, args || [] );
  11862. // Revert the old values
  11863. for ( name in options ) {
  11864. elem.style[ name ] = old[ name ];
  11865. }
  11866. return ret;
  11867. };
  11868. function adjustCSS( elem, prop, valueParts, tween ) {
  11869. var adjusted, scale,
  11870. maxIterations = 20,
  11871. currentValue = tween ?
  11872. function() {
  11873. return tween.cur();
  11874. } :
  11875. function() {
  11876. return jQuery.css( elem, prop, "" );
  11877. },
  11878. initial = currentValue(),
  11879. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11880. // Starting value computation is required for potential unit mismatches
  11881. initialInUnit = elem.nodeType &&
  11882. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11883. rcssNum.exec( jQuery.css( elem, prop ) );
  11884. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11885. // Support: Firefox <=54
  11886. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11887. initial = initial / 2;
  11888. // Trust units reported by jQuery.css
  11889. unit = unit || initialInUnit[ 3 ];
  11890. // Iteratively approximate from a nonzero starting point
  11891. initialInUnit = +initial || 1;
  11892. while ( maxIterations-- ) {
  11893. // Evaluate and update our best guess (doubling guesses that zero out).
  11894. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11895. jQuery.style( elem, prop, initialInUnit + unit );
  11896. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11897. maxIterations = 0;
  11898. }
  11899. initialInUnit = initialInUnit / scale;
  11900. }
  11901. initialInUnit = initialInUnit * 2;
  11902. jQuery.style( elem, prop, initialInUnit + unit );
  11903. // Make sure we update the tween properties later on
  11904. valueParts = valueParts || [];
  11905. }
  11906. if ( valueParts ) {
  11907. initialInUnit = +initialInUnit || +initial || 0;
  11908. // Apply relative offset (+=/-=) if specified
  11909. adjusted = valueParts[ 1 ] ?
  11910. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11911. +valueParts[ 2 ];
  11912. if ( tween ) {
  11913. tween.unit = unit;
  11914. tween.start = initialInUnit;
  11915. tween.end = adjusted;
  11916. }
  11917. }
  11918. return adjusted;
  11919. }
  11920. var defaultDisplayMap = {};
  11921. function getDefaultDisplay( elem ) {
  11922. var temp,
  11923. doc = elem.ownerDocument,
  11924. nodeName = elem.nodeName,
  11925. display = defaultDisplayMap[ nodeName ];
  11926. if ( display ) {
  11927. return display;
  11928. }
  11929. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11930. display = jQuery.css( temp, "display" );
  11931. temp.parentNode.removeChild( temp );
  11932. if ( display === "none" ) {
  11933. display = "block";
  11934. }
  11935. defaultDisplayMap[ nodeName ] = display;
  11936. return display;
  11937. }
  11938. function showHide( elements, show ) {
  11939. var display, elem,
  11940. values = [],
  11941. index = 0,
  11942. length = elements.length;
  11943. // Determine new display value for elements that need to change
  11944. for ( ; index < length; index++ ) {
  11945. elem = elements[ index ];
  11946. if ( !elem.style ) {
  11947. continue;
  11948. }
  11949. display = elem.style.display;
  11950. if ( show ) {
  11951. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11952. // check is required in this first loop unless we have a nonempty display value (either
  11953. // inline or about-to-be-restored)
  11954. if ( display === "none" ) {
  11955. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11956. if ( !values[ index ] ) {
  11957. elem.style.display = "";
  11958. }
  11959. }
  11960. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11961. values[ index ] = getDefaultDisplay( elem );
  11962. }
  11963. } else {
  11964. if ( display !== "none" ) {
  11965. values[ index ] = "none";
  11966. // Remember what we're overwriting
  11967. dataPriv.set( elem, "display", display );
  11968. }
  11969. }
  11970. }
  11971. // Set the display of the elements in a second loop to avoid constant reflow
  11972. for ( index = 0; index < length; index++ ) {
  11973. if ( values[ index ] != null ) {
  11974. elements[ index ].style.display = values[ index ];
  11975. }
  11976. }
  11977. return elements;
  11978. }
  11979. jQuery.fn.extend( {
  11980. show: function() {
  11981. return showHide( this, true );
  11982. },
  11983. hide: function() {
  11984. return showHide( this );
  11985. },
  11986. toggle: function( state ) {
  11987. if ( typeof state === "boolean" ) {
  11988. return state ? this.show() : this.hide();
  11989. }
  11990. return this.each( function() {
  11991. if ( isHiddenWithinTree( this ) ) {
  11992. jQuery( this ).show();
  11993. } else {
  11994. jQuery( this ).hide();
  11995. }
  11996. } );
  11997. }
  11998. } );
  11999. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  12000. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  12001. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  12002. // We have to close these tags to support XHTML (#13200)
  12003. var wrapMap = {
  12004. // Support: IE <=9 only
  12005. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  12006. // XHTML parsers do not magically insert elements in the
  12007. // same way that tag soup parsers do. So we cannot shorten
  12008. // this by omitting <tbody> or other required elements.
  12009. thead: [ 1, "<table>", "</table>" ],
  12010. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  12011. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  12012. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  12013. _default: [ 0, "", "" ]
  12014. };
  12015. // Support: IE <=9 only
  12016. wrapMap.optgroup = wrapMap.option;
  12017. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  12018. wrapMap.th = wrapMap.td;
  12019. function getAll( context, tag ) {
  12020. // Support: IE <=9 - 11 only
  12021. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  12022. var ret;
  12023. if ( typeof context.getElementsByTagName !== "undefined" ) {
  12024. ret = context.getElementsByTagName( tag || "*" );
  12025. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  12026. ret = context.querySelectorAll( tag || "*" );
  12027. } else {
  12028. ret = [];
  12029. }
  12030. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  12031. return jQuery.merge( [ context ], ret );
  12032. }
  12033. return ret;
  12034. }
  12035. // Mark scripts as having already been evaluated
  12036. function setGlobalEval( elems, refElements ) {
  12037. var i = 0,
  12038. l = elems.length;
  12039. for ( ; i < l; i++ ) {
  12040. dataPriv.set(
  12041. elems[ i ],
  12042. "globalEval",
  12043. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  12044. );
  12045. }
  12046. }
  12047. var rhtml = /<|&#?\w+;/;
  12048. function buildFragment( elems, context, scripts, selection, ignored ) {
  12049. var elem, tmp, tag, wrap, attached, j,
  12050. fragment = context.createDocumentFragment(),
  12051. nodes = [],
  12052. i = 0,
  12053. l = elems.length;
  12054. for ( ; i < l; i++ ) {
  12055. elem = elems[ i ];
  12056. if ( elem || elem === 0 ) {
  12057. // Add nodes directly
  12058. if ( toType( elem ) === "object" ) {
  12059. // Support: Android <=4.0 only, PhantomJS 1 only
  12060. // push.apply(_, arraylike) throws on ancient WebKit
  12061. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  12062. // Convert non-html into a text node
  12063. } else if ( !rhtml.test( elem ) ) {
  12064. nodes.push( context.createTextNode( elem ) );
  12065. // Convert html into DOM nodes
  12066. } else {
  12067. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  12068. // Deserialize a standard representation
  12069. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  12070. wrap = wrapMap[ tag ] || wrapMap._default;
  12071. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  12072. // Descend through wrappers to the right content
  12073. j = wrap[ 0 ];
  12074. while ( j-- ) {
  12075. tmp = tmp.lastChild;
  12076. }
  12077. // Support: Android <=4.0 only, PhantomJS 1 only
  12078. // push.apply(_, arraylike) throws on ancient WebKit
  12079. jQuery.merge( nodes, tmp.childNodes );
  12080. // Remember the top-level container
  12081. tmp = fragment.firstChild;
  12082. // Ensure the created nodes are orphaned (#12392)
  12083. tmp.textContent = "";
  12084. }
  12085. }
  12086. }
  12087. // Remove wrapper from fragment
  12088. fragment.textContent = "";
  12089. i = 0;
  12090. while ( ( elem = nodes[ i++ ] ) ) {
  12091. // Skip elements already in the context collection (trac-4087)
  12092. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  12093. if ( ignored ) {
  12094. ignored.push( elem );
  12095. }
  12096. continue;
  12097. }
  12098. attached = isAttached( elem );
  12099. // Append to fragment
  12100. tmp = getAll( fragment.appendChild( elem ), "script" );
  12101. // Preserve script evaluation history
  12102. if ( attached ) {
  12103. setGlobalEval( tmp );
  12104. }
  12105. // Capture executables
  12106. if ( scripts ) {
  12107. j = 0;
  12108. while ( ( elem = tmp[ j++ ] ) ) {
  12109. if ( rscriptType.test( elem.type || "" ) ) {
  12110. scripts.push( elem );
  12111. }
  12112. }
  12113. }
  12114. }
  12115. return fragment;
  12116. }
  12117. ( function() {
  12118. var fragment = document.createDocumentFragment(),
  12119. div = fragment.appendChild( document.createElement( "div" ) ),
  12120. input = document.createElement( "input" );
  12121. // Support: Android 4.0 - 4.3 only
  12122. // Check state lost if the name is set (#11217)
  12123. // Support: Windows Web Apps (WWA)
  12124. // `name` and `type` must use .setAttribute for WWA (#14901)
  12125. input.setAttribute( "type", "radio" );
  12126. input.setAttribute( "checked", "checked" );
  12127. input.setAttribute( "name", "t" );
  12128. div.appendChild( input );
  12129. // Support: Android <=4.1 only
  12130. // Older WebKit doesn't clone checked state correctly in fragments
  12131. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12132. // Support: IE <=11 only
  12133. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12134. div.innerHTML = "<textarea>x</textarea>";
  12135. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12136. } )();
  12137. var
  12138. rkeyEvent = /^key/,
  12139. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12140. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12141. function returnTrue() {
  12142. return true;
  12143. }
  12144. function returnFalse() {
  12145. return false;
  12146. }
  12147. // Support: IE <=9 - 11+
  12148. // focus() and blur() are asynchronous, except when they are no-op.
  12149. // So expect focus to be synchronous when the element is already active,
  12150. // and blur to be synchronous when the element is not already active.
  12151. // (focus and blur are always synchronous in other supported browsers,
  12152. // this just defines when we can count on it).
  12153. function expectSync( elem, type ) {
  12154. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12155. }
  12156. // Support: IE <=9 only
  12157. // Accessing document.activeElement can throw unexpectedly
  12158. // https://bugs.jquery.com/ticket/13393
  12159. function safeActiveElement() {
  12160. try {
  12161. return document.activeElement;
  12162. } catch ( err ) { }
  12163. }
  12164. function on( elem, types, selector, data, fn, one ) {
  12165. var origFn, type;
  12166. // Types can be a map of types/handlers
  12167. if ( typeof types === "object" ) {
  12168. // ( types-Object, selector, data )
  12169. if ( typeof selector !== "string" ) {
  12170. // ( types-Object, data )
  12171. data = data || selector;
  12172. selector = undefined;
  12173. }
  12174. for ( type in types ) {
  12175. on( elem, type, selector, data, types[ type ], one );
  12176. }
  12177. return elem;
  12178. }
  12179. if ( data == null && fn == null ) {
  12180. // ( types, fn )
  12181. fn = selector;
  12182. data = selector = undefined;
  12183. } else if ( fn == null ) {
  12184. if ( typeof selector === "string" ) {
  12185. // ( types, selector, fn )
  12186. fn = data;
  12187. data = undefined;
  12188. } else {
  12189. // ( types, data, fn )
  12190. fn = data;
  12191. data = selector;
  12192. selector = undefined;
  12193. }
  12194. }
  12195. if ( fn === false ) {
  12196. fn = returnFalse;
  12197. } else if ( !fn ) {
  12198. return elem;
  12199. }
  12200. if ( one === 1 ) {
  12201. origFn = fn;
  12202. fn = function( event ) {
  12203. // Can use an empty set, since event contains the info
  12204. jQuery().off( event );
  12205. return origFn.apply( this, arguments );
  12206. };
  12207. // Use same guid so caller can remove using origFn
  12208. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12209. }
  12210. return elem.each( function() {
  12211. jQuery.event.add( this, types, fn, data, selector );
  12212. } );
  12213. }
  12214. /*
  12215. * Helper functions for managing events -- not part of the public interface.
  12216. * Props to Dean Edwards' addEvent library for many of the ideas.
  12217. */
  12218. jQuery.event = {
  12219. global: {},
  12220. add: function( elem, types, handler, data, selector ) {
  12221. var handleObjIn, eventHandle, tmp,
  12222. events, t, handleObj,
  12223. special, handlers, type, namespaces, origType,
  12224. elemData = dataPriv.get( elem );
  12225. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12226. if ( !elemData ) {
  12227. return;
  12228. }
  12229. // Caller can pass in an object of custom data in lieu of the handler
  12230. if ( handler.handler ) {
  12231. handleObjIn = handler;
  12232. handler = handleObjIn.handler;
  12233. selector = handleObjIn.selector;
  12234. }
  12235. // Ensure that invalid selectors throw exceptions at attach time
  12236. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12237. if ( selector ) {
  12238. jQuery.find.matchesSelector( documentElement, selector );
  12239. }
  12240. // Make sure that the handler has a unique ID, used to find/remove it later
  12241. if ( !handler.guid ) {
  12242. handler.guid = jQuery.guid++;
  12243. }
  12244. // Init the element's event structure and main handler, if this is the first
  12245. if ( !( events = elemData.events ) ) {
  12246. events = elemData.events = {};
  12247. }
  12248. if ( !( eventHandle = elemData.handle ) ) {
  12249. eventHandle = elemData.handle = function( e ) {
  12250. // Discard the second event of a jQuery.event.trigger() and
  12251. // when an event is called after a page has unloaded
  12252. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12253. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12254. };
  12255. }
  12256. // Handle multiple events separated by a space
  12257. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12258. t = types.length;
  12259. while ( t-- ) {
  12260. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12261. type = origType = tmp[ 1 ];
  12262. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12263. // There *must* be a type, no attaching namespace-only handlers
  12264. if ( !type ) {
  12265. continue;
  12266. }
  12267. // If event changes its type, use the special event handlers for the changed type
  12268. special = jQuery.event.special[ type ] || {};
  12269. // If selector defined, determine special event api type, otherwise given type
  12270. type = ( selector ? special.delegateType : special.bindType ) || type;
  12271. // Update special based on newly reset type
  12272. special = jQuery.event.special[ type ] || {};
  12273. // handleObj is passed to all event handlers
  12274. handleObj = jQuery.extend( {
  12275. type: type,
  12276. origType: origType,
  12277. data: data,
  12278. handler: handler,
  12279. guid: handler.guid,
  12280. selector: selector,
  12281. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12282. namespace: namespaces.join( "." )
  12283. }, handleObjIn );
  12284. // Init the event handler queue if we're the first
  12285. if ( !( handlers = events[ type ] ) ) {
  12286. handlers = events[ type ] = [];
  12287. handlers.delegateCount = 0;
  12288. // Only use addEventListener if the special events handler returns false
  12289. if ( !special.setup ||
  12290. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12291. if ( elem.addEventListener ) {
  12292. elem.addEventListener( type, eventHandle );
  12293. }
  12294. }
  12295. }
  12296. if ( special.add ) {
  12297. special.add.call( elem, handleObj );
  12298. if ( !handleObj.handler.guid ) {
  12299. handleObj.handler.guid = handler.guid;
  12300. }
  12301. }
  12302. // Add to the element's handler list, delegates in front
  12303. if ( selector ) {
  12304. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12305. } else {
  12306. handlers.push( handleObj );
  12307. }
  12308. // Keep track of which events have ever been used, for event optimization
  12309. jQuery.event.global[ type ] = true;
  12310. }
  12311. },
  12312. // Detach an event or set of events from an element
  12313. remove: function( elem, types, handler, selector, mappedTypes ) {
  12314. var j, origCount, tmp,
  12315. events, t, handleObj,
  12316. special, handlers, type, namespaces, origType,
  12317. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12318. if ( !elemData || !( events = elemData.events ) ) {
  12319. return;
  12320. }
  12321. // Once for each type.namespace in types; type may be omitted
  12322. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12323. t = types.length;
  12324. while ( t-- ) {
  12325. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12326. type = origType = tmp[ 1 ];
  12327. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12328. // Unbind all events (on this namespace, if provided) for the element
  12329. if ( !type ) {
  12330. for ( type in events ) {
  12331. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12332. }
  12333. continue;
  12334. }
  12335. special = jQuery.event.special[ type ] || {};
  12336. type = ( selector ? special.delegateType : special.bindType ) || type;
  12337. handlers = events[ type ] || [];
  12338. tmp = tmp[ 2 ] &&
  12339. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12340. // Remove matching events
  12341. origCount = j = handlers.length;
  12342. while ( j-- ) {
  12343. handleObj = handlers[ j ];
  12344. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12345. ( !handler || handler.guid === handleObj.guid ) &&
  12346. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12347. ( !selector || selector === handleObj.selector ||
  12348. selector === "**" && handleObj.selector ) ) {
  12349. handlers.splice( j, 1 );
  12350. if ( handleObj.selector ) {
  12351. handlers.delegateCount--;
  12352. }
  12353. if ( special.remove ) {
  12354. special.remove.call( elem, handleObj );
  12355. }
  12356. }
  12357. }
  12358. // Remove generic event handler if we removed something and no more handlers exist
  12359. // (avoids potential for endless recursion during removal of special event handlers)
  12360. if ( origCount && !handlers.length ) {
  12361. if ( !special.teardown ||
  12362. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12363. jQuery.removeEvent( elem, type, elemData.handle );
  12364. }
  12365. delete events[ type ];
  12366. }
  12367. }
  12368. // Remove data and the expando if it's no longer used
  12369. if ( jQuery.isEmptyObject( events ) ) {
  12370. dataPriv.remove( elem, "handle events" );
  12371. }
  12372. },
  12373. dispatch: function( nativeEvent ) {
  12374. // Make a writable jQuery.Event from the native event object
  12375. var event = jQuery.event.fix( nativeEvent );
  12376. var i, j, ret, matched, handleObj, handlerQueue,
  12377. args = new Array( arguments.length ),
  12378. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12379. special = jQuery.event.special[ event.type ] || {};
  12380. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12381. args[ 0 ] = event;
  12382. for ( i = 1; i < arguments.length; i++ ) {
  12383. args[ i ] = arguments[ i ];
  12384. }
  12385. event.delegateTarget = this;
  12386. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12387. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12388. return;
  12389. }
  12390. // Determine handlers
  12391. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12392. // Run delegates first; they may want to stop propagation beneath us
  12393. i = 0;
  12394. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12395. event.currentTarget = matched.elem;
  12396. j = 0;
  12397. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12398. !event.isImmediatePropagationStopped() ) {
  12399. // If the event is namespaced, then each handler is only invoked if it is
  12400. // specially universal or its namespaces are a superset of the event's.
  12401. if ( !event.rnamespace || handleObj.namespace === false ||
  12402. event.rnamespace.test( handleObj.namespace ) ) {
  12403. event.handleObj = handleObj;
  12404. event.data = handleObj.data;
  12405. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12406. handleObj.handler ).apply( matched.elem, args );
  12407. if ( ret !== undefined ) {
  12408. if ( ( event.result = ret ) === false ) {
  12409. event.preventDefault();
  12410. event.stopPropagation();
  12411. }
  12412. }
  12413. }
  12414. }
  12415. }
  12416. // Call the postDispatch hook for the mapped type
  12417. if ( special.postDispatch ) {
  12418. special.postDispatch.call( this, event );
  12419. }
  12420. return event.result;
  12421. },
  12422. handlers: function( event, handlers ) {
  12423. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12424. handlerQueue = [],
  12425. delegateCount = handlers.delegateCount,
  12426. cur = event.target;
  12427. // Find delegate handlers
  12428. if ( delegateCount &&
  12429. // Support: IE <=9
  12430. // Black-hole SVG <use> instance trees (trac-13180)
  12431. cur.nodeType &&
  12432. // Support: Firefox <=42
  12433. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12434. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12435. // Support: IE 11 only
  12436. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12437. !( event.type === "click" && event.button >= 1 ) ) {
  12438. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12439. // Don't check non-elements (#13208)
  12440. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12441. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12442. matchedHandlers = [];
  12443. matchedSelectors = {};
  12444. for ( i = 0; i < delegateCount; i++ ) {
  12445. handleObj = handlers[ i ];
  12446. // Don't conflict with Object.prototype properties (#13203)
  12447. sel = handleObj.selector + " ";
  12448. if ( matchedSelectors[ sel ] === undefined ) {
  12449. matchedSelectors[ sel ] = handleObj.needsContext ?
  12450. jQuery( sel, this ).index( cur ) > -1 :
  12451. jQuery.find( sel, this, null, [ cur ] ).length;
  12452. }
  12453. if ( matchedSelectors[ sel ] ) {
  12454. matchedHandlers.push( handleObj );
  12455. }
  12456. }
  12457. if ( matchedHandlers.length ) {
  12458. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12459. }
  12460. }
  12461. }
  12462. }
  12463. // Add the remaining (directly-bound) handlers
  12464. cur = this;
  12465. if ( delegateCount < handlers.length ) {
  12466. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12467. }
  12468. return handlerQueue;
  12469. },
  12470. addProp: function( name, hook ) {
  12471. Object.defineProperty( jQuery.Event.prototype, name, {
  12472. enumerable: true,
  12473. configurable: true,
  12474. get: isFunction( hook ) ?
  12475. function() {
  12476. if ( this.originalEvent ) {
  12477. return hook( this.originalEvent );
  12478. }
  12479. } :
  12480. function() {
  12481. if ( this.originalEvent ) {
  12482. return this.originalEvent[ name ];
  12483. }
  12484. },
  12485. set: function( value ) {
  12486. Object.defineProperty( this, name, {
  12487. enumerable: true,
  12488. configurable: true,
  12489. writable: true,
  12490. value: value
  12491. } );
  12492. }
  12493. } );
  12494. },
  12495. fix: function( originalEvent ) {
  12496. return originalEvent[ jQuery.expando ] ?
  12497. originalEvent :
  12498. new jQuery.Event( originalEvent );
  12499. },
  12500. special: {
  12501. load: {
  12502. // Prevent triggered image.load events from bubbling to window.load
  12503. noBubble: true
  12504. },
  12505. click: {
  12506. // Utilize native event to ensure correct state for checkable inputs
  12507. setup: function( data ) {
  12508. // For mutual compressibility with _default, replace `this` access with a local var.
  12509. // `|| data` is dead code meant only to preserve the variable through minification.
  12510. var el = this || data;
  12511. // Claim the first handler
  12512. if ( rcheckableType.test( el.type ) &&
  12513. el.click && nodeName( el, "input" ) ) {
  12514. // dataPriv.set( el, "click", ... )
  12515. leverageNative( el, "click", returnTrue );
  12516. }
  12517. // Return false to allow normal processing in the caller
  12518. return false;
  12519. },
  12520. trigger: function( data ) {
  12521. // For mutual compressibility with _default, replace `this` access with a local var.
  12522. // `|| data` is dead code meant only to preserve the variable through minification.
  12523. var el = this || data;
  12524. // Force setup before triggering a click
  12525. if ( rcheckableType.test( el.type ) &&
  12526. el.click && nodeName( el, "input" ) ) {
  12527. leverageNative( el, "click" );
  12528. }
  12529. // Return non-false to allow normal event-path propagation
  12530. return true;
  12531. },
  12532. // For cross-browser consistency, suppress native .click() on links
  12533. // Also prevent it if we're currently inside a leveraged native-event stack
  12534. _default: function( event ) {
  12535. var target = event.target;
  12536. return rcheckableType.test( target.type ) &&
  12537. target.click && nodeName( target, "input" ) &&
  12538. dataPriv.get( target, "click" ) ||
  12539. nodeName( target, "a" );
  12540. }
  12541. },
  12542. beforeunload: {
  12543. postDispatch: function( event ) {
  12544. // Support: Firefox 20+
  12545. // Firefox doesn't alert if the returnValue field is not set.
  12546. if ( event.result !== undefined && event.originalEvent ) {
  12547. event.originalEvent.returnValue = event.result;
  12548. }
  12549. }
  12550. }
  12551. }
  12552. };
  12553. // Ensure the presence of an event listener that handles manually-triggered
  12554. // synthetic events by interrupting progress until reinvoked in response to
  12555. // *native* events that it fires directly, ensuring that state changes have
  12556. // already occurred before other listeners are invoked.
  12557. function leverageNative( el, type, expectSync ) {
  12558. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12559. if ( !expectSync ) {
  12560. if ( dataPriv.get( el, type ) === undefined ) {
  12561. jQuery.event.add( el, type, returnTrue );
  12562. }
  12563. return;
  12564. }
  12565. // Register the controller as a special universal handler for all event namespaces
  12566. dataPriv.set( el, type, false );
  12567. jQuery.event.add( el, type, {
  12568. namespace: false,
  12569. handler: function( event ) {
  12570. var notAsync, result,
  12571. saved = dataPriv.get( this, type );
  12572. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12573. // Interrupt processing of the outer synthetic .trigger()ed event
  12574. // Saved data should be false in such cases, but might be a leftover capture object
  12575. // from an async native handler (gh-4350)
  12576. if ( !saved.length ) {
  12577. // Store arguments for use when handling the inner native event
  12578. // There will always be at least one argument (an event object), so this array
  12579. // will not be confused with a leftover capture object.
  12580. saved = slice.call( arguments );
  12581. dataPriv.set( this, type, saved );
  12582. // Trigger the native event and capture its result
  12583. // Support: IE <=9 - 11+
  12584. // focus() and blur() are asynchronous
  12585. notAsync = expectSync( this, type );
  12586. this[ type ]();
  12587. result = dataPriv.get( this, type );
  12588. if ( saved !== result || notAsync ) {
  12589. dataPriv.set( this, type, false );
  12590. } else {
  12591. result = {};
  12592. }
  12593. if ( saved !== result ) {
  12594. // Cancel the outer synthetic event
  12595. event.stopImmediatePropagation();
  12596. event.preventDefault();
  12597. return result.value;
  12598. }
  12599. // If this is an inner synthetic event for an event with a bubbling surrogate
  12600. // (focus or blur), assume that the surrogate already propagated from triggering the
  12601. // native event and prevent that from happening again here.
  12602. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12603. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12604. // less bad than duplication.
  12605. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12606. event.stopPropagation();
  12607. }
  12608. // If this is a native event triggered above, everything is now in order
  12609. // Fire an inner synthetic event with the original arguments
  12610. } else if ( saved.length ) {
  12611. // ...and capture the result
  12612. dataPriv.set( this, type, {
  12613. value: jQuery.event.trigger(
  12614. // Support: IE <=9 - 11+
  12615. // Extend with the prototype to reset the above stopImmediatePropagation()
  12616. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12617. saved.slice( 1 ),
  12618. this
  12619. )
  12620. } );
  12621. // Abort handling of the native event
  12622. event.stopImmediatePropagation();
  12623. }
  12624. }
  12625. } );
  12626. }
  12627. jQuery.removeEvent = function( elem, type, handle ) {
  12628. // This "if" is needed for plain objects
  12629. if ( elem.removeEventListener ) {
  12630. elem.removeEventListener( type, handle );
  12631. }
  12632. };
  12633. jQuery.Event = function( src, props ) {
  12634. // Allow instantiation without the 'new' keyword
  12635. if ( !( this instanceof jQuery.Event ) ) {
  12636. return new jQuery.Event( src, props );
  12637. }
  12638. // Event object
  12639. if ( src && src.type ) {
  12640. this.originalEvent = src;
  12641. this.type = src.type;
  12642. // Events bubbling up the document may have been marked as prevented
  12643. // by a handler lower down the tree; reflect the correct value.
  12644. this.isDefaultPrevented = src.defaultPrevented ||
  12645. src.defaultPrevented === undefined &&
  12646. // Support: Android <=2.3 only
  12647. src.returnValue === false ?
  12648. returnTrue :
  12649. returnFalse;
  12650. // Create target properties
  12651. // Support: Safari <=6 - 7 only
  12652. // Target should not be a text node (#504, #13143)
  12653. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12654. src.target.parentNode :
  12655. src.target;
  12656. this.currentTarget = src.currentTarget;
  12657. this.relatedTarget = src.relatedTarget;
  12658. // Event type
  12659. } else {
  12660. this.type = src;
  12661. }
  12662. // Put explicitly provided properties onto the event object
  12663. if ( props ) {
  12664. jQuery.extend( this, props );
  12665. }
  12666. // Create a timestamp if incoming event doesn't have one
  12667. this.timeStamp = src && src.timeStamp || Date.now();
  12668. // Mark it as fixed
  12669. this[ jQuery.expando ] = true;
  12670. };
  12671. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12672. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12673. jQuery.Event.prototype = {
  12674. constructor: jQuery.Event,
  12675. isDefaultPrevented: returnFalse,
  12676. isPropagationStopped: returnFalse,
  12677. isImmediatePropagationStopped: returnFalse,
  12678. isSimulated: false,
  12679. preventDefault: function() {
  12680. var e = this.originalEvent;
  12681. this.isDefaultPrevented = returnTrue;
  12682. if ( e && !this.isSimulated ) {
  12683. e.preventDefault();
  12684. }
  12685. },
  12686. stopPropagation: function() {
  12687. var e = this.originalEvent;
  12688. this.isPropagationStopped = returnTrue;
  12689. if ( e && !this.isSimulated ) {
  12690. e.stopPropagation();
  12691. }
  12692. },
  12693. stopImmediatePropagation: function() {
  12694. var e = this.originalEvent;
  12695. this.isImmediatePropagationStopped = returnTrue;
  12696. if ( e && !this.isSimulated ) {
  12697. e.stopImmediatePropagation();
  12698. }
  12699. this.stopPropagation();
  12700. }
  12701. };
  12702. // Includes all common event props including KeyEvent and MouseEvent specific props
  12703. jQuery.each( {
  12704. altKey: true,
  12705. bubbles: true,
  12706. cancelable: true,
  12707. changedTouches: true,
  12708. ctrlKey: true,
  12709. detail: true,
  12710. eventPhase: true,
  12711. metaKey: true,
  12712. pageX: true,
  12713. pageY: true,
  12714. shiftKey: true,
  12715. view: true,
  12716. "char": true,
  12717. code: true,
  12718. charCode: true,
  12719. key: true,
  12720. keyCode: true,
  12721. button: true,
  12722. buttons: true,
  12723. clientX: true,
  12724. clientY: true,
  12725. offsetX: true,
  12726. offsetY: true,
  12727. pointerId: true,
  12728. pointerType: true,
  12729. screenX: true,
  12730. screenY: true,
  12731. targetTouches: true,
  12732. toElement: true,
  12733. touches: true,
  12734. which: function( event ) {
  12735. var button = event.button;
  12736. // Add which for key events
  12737. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12738. return event.charCode != null ? event.charCode : event.keyCode;
  12739. }
  12740. // Add which for click: 1 === left; 2 === middle; 3 === right
  12741. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12742. if ( button & 1 ) {
  12743. return 1;
  12744. }
  12745. if ( button & 2 ) {
  12746. return 3;
  12747. }
  12748. if ( button & 4 ) {
  12749. return 2;
  12750. }
  12751. return 0;
  12752. }
  12753. return event.which;
  12754. }
  12755. }, jQuery.event.addProp );
  12756. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12757. jQuery.event.special[ type ] = {
  12758. // Utilize native event if possible so blur/focus sequence is correct
  12759. setup: function() {
  12760. // Claim the first handler
  12761. // dataPriv.set( this, "focus", ... )
  12762. // dataPriv.set( this, "blur", ... )
  12763. leverageNative( this, type, expectSync );
  12764. // Return false to allow normal processing in the caller
  12765. return false;
  12766. },
  12767. trigger: function() {
  12768. // Force setup before trigger
  12769. leverageNative( this, type );
  12770. // Return non-false to allow normal event-path propagation
  12771. return true;
  12772. },
  12773. delegateType: delegateType
  12774. };
  12775. } );
  12776. // Create mouseenter/leave events using mouseover/out and event-time checks
  12777. // so that event delegation works in jQuery.
  12778. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12779. //
  12780. // Support: Safari 7 only
  12781. // Safari sends mouseenter too often; see:
  12782. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12783. // for the description of the bug (it existed in older Chrome versions as well).
  12784. jQuery.each( {
  12785. mouseenter: "mouseover",
  12786. mouseleave: "mouseout",
  12787. pointerenter: "pointerover",
  12788. pointerleave: "pointerout"
  12789. }, function( orig, fix ) {
  12790. jQuery.event.special[ orig ] = {
  12791. delegateType: fix,
  12792. bindType: fix,
  12793. handle: function( event ) {
  12794. var ret,
  12795. target = this,
  12796. related = event.relatedTarget,
  12797. handleObj = event.handleObj;
  12798. // For mouseenter/leave call the handler if related is outside the target.
  12799. // NB: No relatedTarget if the mouse left/entered the browser window
  12800. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12801. event.type = handleObj.origType;
  12802. ret = handleObj.handler.apply( this, arguments );
  12803. event.type = fix;
  12804. }
  12805. return ret;
  12806. }
  12807. };
  12808. } );
  12809. jQuery.fn.extend( {
  12810. on: function( types, selector, data, fn ) {
  12811. return on( this, types, selector, data, fn );
  12812. },
  12813. one: function( types, selector, data, fn ) {
  12814. return on( this, types, selector, data, fn, 1 );
  12815. },
  12816. off: function( types, selector, fn ) {
  12817. var handleObj, type;
  12818. if ( types && types.preventDefault && types.handleObj ) {
  12819. // ( event ) dispatched jQuery.Event
  12820. handleObj = types.handleObj;
  12821. jQuery( types.delegateTarget ).off(
  12822. handleObj.namespace ?
  12823. handleObj.origType + "." + handleObj.namespace :
  12824. handleObj.origType,
  12825. handleObj.selector,
  12826. handleObj.handler
  12827. );
  12828. return this;
  12829. }
  12830. if ( typeof types === "object" ) {
  12831. // ( types-object [, selector] )
  12832. for ( type in types ) {
  12833. this.off( type, selector, types[ type ] );
  12834. }
  12835. return this;
  12836. }
  12837. if ( selector === false || typeof selector === "function" ) {
  12838. // ( types [, fn] )
  12839. fn = selector;
  12840. selector = undefined;
  12841. }
  12842. if ( fn === false ) {
  12843. fn = returnFalse;
  12844. }
  12845. return this.each( function() {
  12846. jQuery.event.remove( this, types, fn, selector );
  12847. } );
  12848. }
  12849. } );
  12850. var
  12851. /* eslint-disable max-len */
  12852. // See https://github.com/eslint/eslint/issues/3229
  12853. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12854. /* eslint-enable */
  12855. // Support: IE <=10 - 11, Edge 12 - 13 only
  12856. // In IE/Edge using regex groups here causes severe slowdowns.
  12857. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12858. rnoInnerhtml = /<script|<style|<link/i,
  12859. // checked="checked" or checked
  12860. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12861. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12862. // Prefer a tbody over its parent table for containing new rows
  12863. function manipulationTarget( elem, content ) {
  12864. if ( nodeName( elem, "table" ) &&
  12865. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12866. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12867. }
  12868. return elem;
  12869. }
  12870. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12871. function disableScript( elem ) {
  12872. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12873. return elem;
  12874. }
  12875. function restoreScript( elem ) {
  12876. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12877. elem.type = elem.type.slice( 5 );
  12878. } else {
  12879. elem.removeAttribute( "type" );
  12880. }
  12881. return elem;
  12882. }
  12883. function cloneCopyEvent( src, dest ) {
  12884. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12885. if ( dest.nodeType !== 1 ) {
  12886. return;
  12887. }
  12888. // 1. Copy private data: events, handlers, etc.
  12889. if ( dataPriv.hasData( src ) ) {
  12890. pdataOld = dataPriv.access( src );
  12891. pdataCur = dataPriv.set( dest, pdataOld );
  12892. events = pdataOld.events;
  12893. if ( events ) {
  12894. delete pdataCur.handle;
  12895. pdataCur.events = {};
  12896. for ( type in events ) {
  12897. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12898. jQuery.event.add( dest, type, events[ type ][ i ] );
  12899. }
  12900. }
  12901. }
  12902. }
  12903. // 2. Copy user data
  12904. if ( dataUser.hasData( src ) ) {
  12905. udataOld = dataUser.access( src );
  12906. udataCur = jQuery.extend( {}, udataOld );
  12907. dataUser.set( dest, udataCur );
  12908. }
  12909. }
  12910. // Fix IE bugs, see support tests
  12911. function fixInput( src, dest ) {
  12912. var nodeName = dest.nodeName.toLowerCase();
  12913. // Fails to persist the checked state of a cloned checkbox or radio button.
  12914. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12915. dest.checked = src.checked;
  12916. // Fails to return the selected option to the default selected state when cloning options
  12917. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12918. dest.defaultValue = src.defaultValue;
  12919. }
  12920. }
  12921. function domManip( collection, args, callback, ignored ) {
  12922. // Flatten any nested arrays
  12923. args = concat.apply( [], args );
  12924. var fragment, first, scripts, hasScripts, node, doc,
  12925. i = 0,
  12926. l = collection.length,
  12927. iNoClone = l - 1,
  12928. value = args[ 0 ],
  12929. valueIsFunction = isFunction( value );
  12930. // We can't cloneNode fragments that contain checked, in WebKit
  12931. if ( valueIsFunction ||
  12932. ( l > 1 && typeof value === "string" &&
  12933. !support.checkClone && rchecked.test( value ) ) ) {
  12934. return collection.each( function( index ) {
  12935. var self = collection.eq( index );
  12936. if ( valueIsFunction ) {
  12937. args[ 0 ] = value.call( this, index, self.html() );
  12938. }
  12939. domManip( self, args, callback, ignored );
  12940. } );
  12941. }
  12942. if ( l ) {
  12943. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12944. first = fragment.firstChild;
  12945. if ( fragment.childNodes.length === 1 ) {
  12946. fragment = first;
  12947. }
  12948. // Require either new content or an interest in ignored elements to invoke the callback
  12949. if ( first || ignored ) {
  12950. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12951. hasScripts = scripts.length;
  12952. // Use the original fragment for the last item
  12953. // instead of the first because it can end up
  12954. // being emptied incorrectly in certain situations (#8070).
  12955. for ( ; i < l; i++ ) {
  12956. node = fragment;
  12957. if ( i !== iNoClone ) {
  12958. node = jQuery.clone( node, true, true );
  12959. // Keep references to cloned scripts for later restoration
  12960. if ( hasScripts ) {
  12961. // Support: Android <=4.0 only, PhantomJS 1 only
  12962. // push.apply(_, arraylike) throws on ancient WebKit
  12963. jQuery.merge( scripts, getAll( node, "script" ) );
  12964. }
  12965. }
  12966. callback.call( collection[ i ], node, i );
  12967. }
  12968. if ( hasScripts ) {
  12969. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12970. // Reenable scripts
  12971. jQuery.map( scripts, restoreScript );
  12972. // Evaluate executable scripts on first document insertion
  12973. for ( i = 0; i < hasScripts; i++ ) {
  12974. node = scripts[ i ];
  12975. if ( rscriptType.test( node.type || "" ) &&
  12976. !dataPriv.access( node, "globalEval" ) &&
  12977. jQuery.contains( doc, node ) ) {
  12978. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12979. // Optional AJAX dependency, but won't run scripts if not present
  12980. if ( jQuery._evalUrl && !node.noModule ) {
  12981. jQuery._evalUrl( node.src, {
  12982. nonce: node.nonce || node.getAttribute( "nonce" )
  12983. } );
  12984. }
  12985. } else {
  12986. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12987. }
  12988. }
  12989. }
  12990. }
  12991. }
  12992. }
  12993. return collection;
  12994. }
  12995. function remove( elem, selector, keepData ) {
  12996. var node,
  12997. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12998. i = 0;
  12999. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  13000. if ( !keepData && node.nodeType === 1 ) {
  13001. jQuery.cleanData( getAll( node ) );
  13002. }
  13003. if ( node.parentNode ) {
  13004. if ( keepData && isAttached( node ) ) {
  13005. setGlobalEval( getAll( node, "script" ) );
  13006. }
  13007. node.parentNode.removeChild( node );
  13008. }
  13009. }
  13010. return elem;
  13011. }
  13012. jQuery.extend( {
  13013. htmlPrefilter: function( html ) {
  13014. return html.replace( rxhtmlTag, "<$1></$2>" );
  13015. },
  13016. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  13017. var i, l, srcElements, destElements,
  13018. clone = elem.cloneNode( true ),
  13019. inPage = isAttached( elem );
  13020. // Fix IE cloning issues
  13021. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  13022. !jQuery.isXMLDoc( elem ) ) {
  13023. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  13024. destElements = getAll( clone );
  13025. srcElements = getAll( elem );
  13026. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13027. fixInput( srcElements[ i ], destElements[ i ] );
  13028. }
  13029. }
  13030. // Copy the events from the original to the clone
  13031. if ( dataAndEvents ) {
  13032. if ( deepDataAndEvents ) {
  13033. srcElements = srcElements || getAll( elem );
  13034. destElements = destElements || getAll( clone );
  13035. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  13036. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  13037. }
  13038. } else {
  13039. cloneCopyEvent( elem, clone );
  13040. }
  13041. }
  13042. // Preserve script evaluation history
  13043. destElements = getAll( clone, "script" );
  13044. if ( destElements.length > 0 ) {
  13045. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  13046. }
  13047. // Return the cloned set
  13048. return clone;
  13049. },
  13050. cleanData: function( elems ) {
  13051. var data, elem, type,
  13052. special = jQuery.event.special,
  13053. i = 0;
  13054. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  13055. if ( acceptData( elem ) ) {
  13056. if ( ( data = elem[ dataPriv.expando ] ) ) {
  13057. if ( data.events ) {
  13058. for ( type in data.events ) {
  13059. if ( special[ type ] ) {
  13060. jQuery.event.remove( elem, type );
  13061. // This is a shortcut to avoid jQuery.event.remove's overhead
  13062. } else {
  13063. jQuery.removeEvent( elem, type, data.handle );
  13064. }
  13065. }
  13066. }
  13067. // Support: Chrome <=35 - 45+
  13068. // Assign undefined instead of using delete, see Data#remove
  13069. elem[ dataPriv.expando ] = undefined;
  13070. }
  13071. if ( elem[ dataUser.expando ] ) {
  13072. // Support: Chrome <=35 - 45+
  13073. // Assign undefined instead of using delete, see Data#remove
  13074. elem[ dataUser.expando ] = undefined;
  13075. }
  13076. }
  13077. }
  13078. }
  13079. } );
  13080. jQuery.fn.extend( {
  13081. detach: function( selector ) {
  13082. return remove( this, selector, true );
  13083. },
  13084. remove: function( selector ) {
  13085. return remove( this, selector );
  13086. },
  13087. text: function( value ) {
  13088. return access( this, function( value ) {
  13089. return value === undefined ?
  13090. jQuery.text( this ) :
  13091. this.empty().each( function() {
  13092. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13093. this.textContent = value;
  13094. }
  13095. } );
  13096. }, null, value, arguments.length );
  13097. },
  13098. append: function() {
  13099. return domManip( this, arguments, function( elem ) {
  13100. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13101. var target = manipulationTarget( this, elem );
  13102. target.appendChild( elem );
  13103. }
  13104. } );
  13105. },
  13106. prepend: function() {
  13107. return domManip( this, arguments, function( elem ) {
  13108. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13109. var target = manipulationTarget( this, elem );
  13110. target.insertBefore( elem, target.firstChild );
  13111. }
  13112. } );
  13113. },
  13114. before: function() {
  13115. return domManip( this, arguments, function( elem ) {
  13116. if ( this.parentNode ) {
  13117. this.parentNode.insertBefore( elem, this );
  13118. }
  13119. } );
  13120. },
  13121. after: function() {
  13122. return domManip( this, arguments, function( elem ) {
  13123. if ( this.parentNode ) {
  13124. this.parentNode.insertBefore( elem, this.nextSibling );
  13125. }
  13126. } );
  13127. },
  13128. empty: function() {
  13129. var elem,
  13130. i = 0;
  13131. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13132. if ( elem.nodeType === 1 ) {
  13133. // Prevent memory leaks
  13134. jQuery.cleanData( getAll( elem, false ) );
  13135. // Remove any remaining nodes
  13136. elem.textContent = "";
  13137. }
  13138. }
  13139. return this;
  13140. },
  13141. clone: function( dataAndEvents, deepDataAndEvents ) {
  13142. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13143. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13144. return this.map( function() {
  13145. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13146. } );
  13147. },
  13148. html: function( value ) {
  13149. return access( this, function( value ) {
  13150. var elem = this[ 0 ] || {},
  13151. i = 0,
  13152. l = this.length;
  13153. if ( value === undefined && elem.nodeType === 1 ) {
  13154. return elem.innerHTML;
  13155. }
  13156. // See if we can take a shortcut and just use innerHTML
  13157. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13158. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13159. value = jQuery.htmlPrefilter( value );
  13160. try {
  13161. for ( ; i < l; i++ ) {
  13162. elem = this[ i ] || {};
  13163. // Remove element nodes and prevent memory leaks
  13164. if ( elem.nodeType === 1 ) {
  13165. jQuery.cleanData( getAll( elem, false ) );
  13166. elem.innerHTML = value;
  13167. }
  13168. }
  13169. elem = 0;
  13170. // If using innerHTML throws an exception, use the fallback method
  13171. } catch ( e ) {}
  13172. }
  13173. if ( elem ) {
  13174. this.empty().append( value );
  13175. }
  13176. }, null, value, arguments.length );
  13177. },
  13178. replaceWith: function() {
  13179. var ignored = [];
  13180. // Make the changes, replacing each non-ignored context element with the new content
  13181. return domManip( this, arguments, function( elem ) {
  13182. var parent = this.parentNode;
  13183. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13184. jQuery.cleanData( getAll( this ) );
  13185. if ( parent ) {
  13186. parent.replaceChild( elem, this );
  13187. }
  13188. }
  13189. // Force callback invocation
  13190. }, ignored );
  13191. }
  13192. } );
  13193. jQuery.each( {
  13194. appendTo: "append",
  13195. prependTo: "prepend",
  13196. insertBefore: "before",
  13197. insertAfter: "after",
  13198. replaceAll: "replaceWith"
  13199. }, function( name, original ) {
  13200. jQuery.fn[ name ] = function( selector ) {
  13201. var elems,
  13202. ret = [],
  13203. insert = jQuery( selector ),
  13204. last = insert.length - 1,
  13205. i = 0;
  13206. for ( ; i <= last; i++ ) {
  13207. elems = i === last ? this : this.clone( true );
  13208. jQuery( insert[ i ] )[ original ]( elems );
  13209. // Support: Android <=4.0 only, PhantomJS 1 only
  13210. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13211. push.apply( ret, elems.get() );
  13212. }
  13213. return this.pushStack( ret );
  13214. };
  13215. } );
  13216. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13217. var getStyles = function( elem ) {
  13218. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13219. // IE throws on elements created in popups
  13220. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13221. var view = elem.ownerDocument.defaultView;
  13222. if ( !view || !view.opener ) {
  13223. view = window;
  13224. }
  13225. return view.getComputedStyle( elem );
  13226. };
  13227. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13228. ( function() {
  13229. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13230. // so they're executed at the same time to save the second computation.
  13231. function computeStyleTests() {
  13232. // This is a singleton, we need to execute it only once
  13233. if ( !div ) {
  13234. return;
  13235. }
  13236. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13237. "margin-top:1px;padding:0;border:0";
  13238. div.style.cssText =
  13239. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13240. "margin:auto;border:1px;padding:1px;" +
  13241. "width:60%;top:1%";
  13242. documentElement.appendChild( container ).appendChild( div );
  13243. var divStyle = window.getComputedStyle( div );
  13244. pixelPositionVal = divStyle.top !== "1%";
  13245. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13246. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13247. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13248. // Some styles come back with percentage values, even though they shouldn't
  13249. div.style.right = "60%";
  13250. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13251. // Support: IE 9 - 11 only
  13252. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13253. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13254. // Support: IE 9 only
  13255. // Detect overflow:scroll screwiness (gh-3699)
  13256. // Support: Chrome <=64
  13257. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13258. div.style.position = "absolute";
  13259. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13260. documentElement.removeChild( container );
  13261. // Nullify the div so it wouldn't be stored in the memory and
  13262. // it will also be a sign that checks already performed
  13263. div = null;
  13264. }
  13265. function roundPixelMeasures( measure ) {
  13266. return Math.round( parseFloat( measure ) );
  13267. }
  13268. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13269. reliableMarginLeftVal,
  13270. container = document.createElement( "div" ),
  13271. div = document.createElement( "div" );
  13272. // Finish early in limited (non-browser) environments
  13273. if ( !div.style ) {
  13274. return;
  13275. }
  13276. // Support: IE <=9 - 11 only
  13277. // Style of cloned element affects source element cloned (#8908)
  13278. div.style.backgroundClip = "content-box";
  13279. div.cloneNode( true ).style.backgroundClip = "";
  13280. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13281. jQuery.extend( support, {
  13282. boxSizingReliable: function() {
  13283. computeStyleTests();
  13284. return boxSizingReliableVal;
  13285. },
  13286. pixelBoxStyles: function() {
  13287. computeStyleTests();
  13288. return pixelBoxStylesVal;
  13289. },
  13290. pixelPosition: function() {
  13291. computeStyleTests();
  13292. return pixelPositionVal;
  13293. },
  13294. reliableMarginLeft: function() {
  13295. computeStyleTests();
  13296. return reliableMarginLeftVal;
  13297. },
  13298. scrollboxSize: function() {
  13299. computeStyleTests();
  13300. return scrollboxSizeVal;
  13301. }
  13302. } );
  13303. } )();
  13304. function curCSS( elem, name, computed ) {
  13305. var width, minWidth, maxWidth, ret,
  13306. // Support: Firefox 51+
  13307. // Retrieving style before computed somehow
  13308. // fixes an issue with getting wrong values
  13309. // on detached elements
  13310. style = elem.style;
  13311. computed = computed || getStyles( elem );
  13312. // getPropertyValue is needed for:
  13313. // .css('filter') (IE 9 only, #12537)
  13314. // .css('--customProperty) (#3144)
  13315. if ( computed ) {
  13316. ret = computed.getPropertyValue( name ) || computed[ name ];
  13317. if ( ret === "" && !isAttached( elem ) ) {
  13318. ret = jQuery.style( elem, name );
  13319. }
  13320. // A tribute to the "awesome hack by Dean Edwards"
  13321. // Android Browser returns percentage for some values,
  13322. // but width seems to be reliably pixels.
  13323. // This is against the CSSOM draft spec:
  13324. // https://drafts.csswg.org/cssom/#resolved-values
  13325. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13326. // Remember the original values
  13327. width = style.width;
  13328. minWidth = style.minWidth;
  13329. maxWidth = style.maxWidth;
  13330. // Put in the new values to get a computed value out
  13331. style.minWidth = style.maxWidth = style.width = ret;
  13332. ret = computed.width;
  13333. // Revert the changed values
  13334. style.width = width;
  13335. style.minWidth = minWidth;
  13336. style.maxWidth = maxWidth;
  13337. }
  13338. }
  13339. return ret !== undefined ?
  13340. // Support: IE <=9 - 11 only
  13341. // IE returns zIndex value as an integer.
  13342. ret + "" :
  13343. ret;
  13344. }
  13345. function addGetHookIf( conditionFn, hookFn ) {
  13346. // Define the hook, we'll check on the first run if it's really needed.
  13347. return {
  13348. get: function() {
  13349. if ( conditionFn() ) {
  13350. // Hook not needed (or it's not possible to use it due
  13351. // to missing dependency), remove it.
  13352. delete this.get;
  13353. return;
  13354. }
  13355. // Hook needed; redefine it so that the support test is not executed again.
  13356. return ( this.get = hookFn ).apply( this, arguments );
  13357. }
  13358. };
  13359. }
  13360. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13361. emptyStyle = document.createElement( "div" ).style,
  13362. vendorProps = {};
  13363. // Return a vendor-prefixed property or undefined
  13364. function vendorPropName( name ) {
  13365. // Check for vendor prefixed names
  13366. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13367. i = cssPrefixes.length;
  13368. while ( i-- ) {
  13369. name = cssPrefixes[ i ] + capName;
  13370. if ( name in emptyStyle ) {
  13371. return name;
  13372. }
  13373. }
  13374. }
  13375. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13376. function finalPropName( name ) {
  13377. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13378. if ( final ) {
  13379. return final;
  13380. }
  13381. if ( name in emptyStyle ) {
  13382. return name;
  13383. }
  13384. return vendorProps[ name ] = vendorPropName( name ) || name;
  13385. }
  13386. var
  13387. // Swappable if display is none or starts with table
  13388. // except "table", "table-cell", or "table-caption"
  13389. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13390. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13391. rcustomProp = /^--/,
  13392. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13393. cssNormalTransform = {
  13394. letterSpacing: "0",
  13395. fontWeight: "400"
  13396. };
  13397. function setPositiveNumber( elem, value, subtract ) {
  13398. // Any relative (+/-) values have already been
  13399. // normalized at this point
  13400. var matches = rcssNum.exec( value );
  13401. return matches ?
  13402. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13403. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13404. value;
  13405. }
  13406. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13407. var i = dimension === "width" ? 1 : 0,
  13408. extra = 0,
  13409. delta = 0;
  13410. // Adjustment may not be necessary
  13411. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13412. return 0;
  13413. }
  13414. for ( ; i < 4; i += 2 ) {
  13415. // Both box models exclude margin
  13416. if ( box === "margin" ) {
  13417. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13418. }
  13419. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13420. if ( !isBorderBox ) {
  13421. // Add padding
  13422. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13423. // For "border" or "margin", add border
  13424. if ( box !== "padding" ) {
  13425. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13426. // But still keep track of it otherwise
  13427. } else {
  13428. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13429. }
  13430. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13431. // "padding" or "margin"
  13432. } else {
  13433. // For "content", subtract padding
  13434. if ( box === "content" ) {
  13435. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13436. }
  13437. // For "content" or "padding", subtract border
  13438. if ( box !== "margin" ) {
  13439. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13440. }
  13441. }
  13442. }
  13443. // Account for positive content-box scroll gutter when requested by providing computedVal
  13444. if ( !isBorderBox && computedVal >= 0 ) {
  13445. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13446. // Assuming integer scroll gutter, subtract the rest and round down
  13447. delta += Math.max( 0, Math.ceil(
  13448. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13449. computedVal -
  13450. delta -
  13451. extra -
  13452. 0.5
  13453. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13454. // Use an explicit zero to avoid NaN (gh-3964)
  13455. ) ) || 0;
  13456. }
  13457. return delta;
  13458. }
  13459. function getWidthOrHeight( elem, dimension, extra ) {
  13460. // Start with computed style
  13461. var styles = getStyles( elem ),
  13462. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13463. // Fake content-box until we know it's needed to know the true value.
  13464. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13465. isBorderBox = boxSizingNeeded &&
  13466. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13467. valueIsBorderBox = isBorderBox,
  13468. val = curCSS( elem, dimension, styles ),
  13469. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13470. // Support: Firefox <=54
  13471. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13472. if ( rnumnonpx.test( val ) ) {
  13473. if ( !extra ) {
  13474. return val;
  13475. }
  13476. val = "auto";
  13477. }
  13478. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13479. // This happens for inline elements with no explicit setting (gh-3571)
  13480. // Support: Android <=4.1 - 4.3 only
  13481. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13482. // Support: IE 9-11 only
  13483. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13484. // We use getClientRects() to check for hidden/disconnected.
  13485. // In those cases, the computed value can be trusted to be border-box
  13486. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13487. val === "auto" ||
  13488. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13489. elem.getClientRects().length ) {
  13490. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13491. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13492. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13493. // retrieved value as a content box dimension.
  13494. valueIsBorderBox = offsetProp in elem;
  13495. if ( valueIsBorderBox ) {
  13496. val = elem[ offsetProp ];
  13497. }
  13498. }
  13499. // Normalize "" and auto
  13500. val = parseFloat( val ) || 0;
  13501. // Adjust for the element's box model
  13502. return ( val +
  13503. boxModelAdjustment(
  13504. elem,
  13505. dimension,
  13506. extra || ( isBorderBox ? "border" : "content" ),
  13507. valueIsBorderBox,
  13508. styles,
  13509. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13510. val
  13511. )
  13512. ) + "px";
  13513. }
  13514. jQuery.extend( {
  13515. // Add in style property hooks for overriding the default
  13516. // behavior of getting and setting a style property
  13517. cssHooks: {
  13518. opacity: {
  13519. get: function( elem, computed ) {
  13520. if ( computed ) {
  13521. // We should always get a number back from opacity
  13522. var ret = curCSS( elem, "opacity" );
  13523. return ret === "" ? "1" : ret;
  13524. }
  13525. }
  13526. }
  13527. },
  13528. // Don't automatically add "px" to these possibly-unitless properties
  13529. cssNumber: {
  13530. "animationIterationCount": true,
  13531. "columnCount": true,
  13532. "fillOpacity": true,
  13533. "flexGrow": true,
  13534. "flexShrink": true,
  13535. "fontWeight": true,
  13536. "gridArea": true,
  13537. "gridColumn": true,
  13538. "gridColumnEnd": true,
  13539. "gridColumnStart": true,
  13540. "gridRow": true,
  13541. "gridRowEnd": true,
  13542. "gridRowStart": true,
  13543. "lineHeight": true,
  13544. "opacity": true,
  13545. "order": true,
  13546. "orphans": true,
  13547. "widows": true,
  13548. "zIndex": true,
  13549. "zoom": true
  13550. },
  13551. // Add in properties whose names you wish to fix before
  13552. // setting or getting the value
  13553. cssProps: {},
  13554. // Get and set the style property on a DOM Node
  13555. style: function( elem, name, value, extra ) {
  13556. // Don't set styles on text and comment nodes
  13557. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13558. return;
  13559. }
  13560. // Make sure that we're working with the right name
  13561. var ret, type, hooks,
  13562. origName = camelCase( name ),
  13563. isCustomProp = rcustomProp.test( name ),
  13564. style = elem.style;
  13565. // Make sure that we're working with the right name. We don't
  13566. // want to query the value if it is a CSS custom property
  13567. // since they are user-defined.
  13568. if ( !isCustomProp ) {
  13569. name = finalPropName( origName );
  13570. }
  13571. // Gets hook for the prefixed version, then unprefixed version
  13572. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13573. // Check if we're setting a value
  13574. if ( value !== undefined ) {
  13575. type = typeof value;
  13576. // Convert "+=" or "-=" to relative numbers (#7345)
  13577. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13578. value = adjustCSS( elem, name, ret );
  13579. // Fixes bug #9237
  13580. type = "number";
  13581. }
  13582. // Make sure that null and NaN values aren't set (#7116)
  13583. if ( value == null || value !== value ) {
  13584. return;
  13585. }
  13586. // If a number was passed in, add the unit (except for certain CSS properties)
  13587. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13588. // "px" to a few hardcoded values.
  13589. if ( type === "number" && !isCustomProp ) {
  13590. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13591. }
  13592. // background-* props affect original clone's values
  13593. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13594. style[ name ] = "inherit";
  13595. }
  13596. // If a hook was provided, use that value, otherwise just set the specified value
  13597. if ( !hooks || !( "set" in hooks ) ||
  13598. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13599. if ( isCustomProp ) {
  13600. style.setProperty( name, value );
  13601. } else {
  13602. style[ name ] = value;
  13603. }
  13604. }
  13605. } else {
  13606. // If a hook was provided get the non-computed value from there
  13607. if ( hooks && "get" in hooks &&
  13608. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13609. return ret;
  13610. }
  13611. // Otherwise just get the value from the style object
  13612. return style[ name ];
  13613. }
  13614. },
  13615. css: function( elem, name, extra, styles ) {
  13616. var val, num, hooks,
  13617. origName = camelCase( name ),
  13618. isCustomProp = rcustomProp.test( name );
  13619. // Make sure that we're working with the right name. We don't
  13620. // want to modify the value if it is a CSS custom property
  13621. // since they are user-defined.
  13622. if ( !isCustomProp ) {
  13623. name = finalPropName( origName );
  13624. }
  13625. // Try prefixed name followed by the unprefixed name
  13626. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13627. // If a hook was provided get the computed value from there
  13628. if ( hooks && "get" in hooks ) {
  13629. val = hooks.get( elem, true, extra );
  13630. }
  13631. // Otherwise, if a way to get the computed value exists, use that
  13632. if ( val === undefined ) {
  13633. val = curCSS( elem, name, styles );
  13634. }
  13635. // Convert "normal" to computed value
  13636. if ( val === "normal" && name in cssNormalTransform ) {
  13637. val = cssNormalTransform[ name ];
  13638. }
  13639. // Make numeric if forced or a qualifier was provided and val looks numeric
  13640. if ( extra === "" || extra ) {
  13641. num = parseFloat( val );
  13642. return extra === true || isFinite( num ) ? num || 0 : val;
  13643. }
  13644. return val;
  13645. }
  13646. } );
  13647. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13648. jQuery.cssHooks[ dimension ] = {
  13649. get: function( elem, computed, extra ) {
  13650. if ( computed ) {
  13651. // Certain elements can have dimension info if we invisibly show them
  13652. // but it must have a current display style that would benefit
  13653. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13654. // Support: Safari 8+
  13655. // Table columns in Safari have non-zero offsetWidth & zero
  13656. // getBoundingClientRect().width unless display is changed.
  13657. // Support: IE <=11 only
  13658. // Running getBoundingClientRect on a disconnected node
  13659. // in IE throws an error.
  13660. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13661. swap( elem, cssShow, function() {
  13662. return getWidthOrHeight( elem, dimension, extra );
  13663. } ) :
  13664. getWidthOrHeight( elem, dimension, extra );
  13665. }
  13666. },
  13667. set: function( elem, value, extra ) {
  13668. var matches,
  13669. styles = getStyles( elem ),
  13670. // Only read styles.position if the test has a chance to fail
  13671. // to avoid forcing a reflow.
  13672. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13673. styles.position === "absolute",
  13674. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13675. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13676. isBorderBox = boxSizingNeeded &&
  13677. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13678. subtract = extra ?
  13679. boxModelAdjustment(
  13680. elem,
  13681. dimension,
  13682. extra,
  13683. isBorderBox,
  13684. styles
  13685. ) :
  13686. 0;
  13687. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13688. // faking a content-box to get border and padding (gh-3699)
  13689. if ( isBorderBox && scrollboxSizeBuggy ) {
  13690. subtract -= Math.ceil(
  13691. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13692. parseFloat( styles[ dimension ] ) -
  13693. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13694. 0.5
  13695. );
  13696. }
  13697. // Convert to pixels if value adjustment is needed
  13698. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13699. ( matches[ 3 ] || "px" ) !== "px" ) {
  13700. elem.style[ dimension ] = value;
  13701. value = jQuery.css( elem, dimension );
  13702. }
  13703. return setPositiveNumber( elem, value, subtract );
  13704. }
  13705. };
  13706. } );
  13707. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13708. function( elem, computed ) {
  13709. if ( computed ) {
  13710. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13711. elem.getBoundingClientRect().left -
  13712. swap( elem, { marginLeft: 0 }, function() {
  13713. return elem.getBoundingClientRect().left;
  13714. } )
  13715. ) + "px";
  13716. }
  13717. }
  13718. );
  13719. // These hooks are used by animate to expand properties
  13720. jQuery.each( {
  13721. margin: "",
  13722. padding: "",
  13723. border: "Width"
  13724. }, function( prefix, suffix ) {
  13725. jQuery.cssHooks[ prefix + suffix ] = {
  13726. expand: function( value ) {
  13727. var i = 0,
  13728. expanded = {},
  13729. // Assumes a single number if not a string
  13730. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13731. for ( ; i < 4; i++ ) {
  13732. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13733. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13734. }
  13735. return expanded;
  13736. }
  13737. };
  13738. if ( prefix !== "margin" ) {
  13739. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13740. }
  13741. } );
  13742. jQuery.fn.extend( {
  13743. css: function( name, value ) {
  13744. return access( this, function( elem, name, value ) {
  13745. var styles, len,
  13746. map = {},
  13747. i = 0;
  13748. if ( Array.isArray( name ) ) {
  13749. styles = getStyles( elem );
  13750. len = name.length;
  13751. for ( ; i < len; i++ ) {
  13752. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13753. }
  13754. return map;
  13755. }
  13756. return value !== undefined ?
  13757. jQuery.style( elem, name, value ) :
  13758. jQuery.css( elem, name );
  13759. }, name, value, arguments.length > 1 );
  13760. }
  13761. } );
  13762. function Tween( elem, options, prop, end, easing ) {
  13763. return new Tween.prototype.init( elem, options, prop, end, easing );
  13764. }
  13765. jQuery.Tween = Tween;
  13766. Tween.prototype = {
  13767. constructor: Tween,
  13768. init: function( elem, options, prop, end, easing, unit ) {
  13769. this.elem = elem;
  13770. this.prop = prop;
  13771. this.easing = easing || jQuery.easing._default;
  13772. this.options = options;
  13773. this.start = this.now = this.cur();
  13774. this.end = end;
  13775. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13776. },
  13777. cur: function() {
  13778. var hooks = Tween.propHooks[ this.prop ];
  13779. return hooks && hooks.get ?
  13780. hooks.get( this ) :
  13781. Tween.propHooks._default.get( this );
  13782. },
  13783. run: function( percent ) {
  13784. var eased,
  13785. hooks = Tween.propHooks[ this.prop ];
  13786. if ( this.options.duration ) {
  13787. this.pos = eased = jQuery.easing[ this.easing ](
  13788. percent, this.options.duration * percent, 0, 1, this.options.duration
  13789. );
  13790. } else {
  13791. this.pos = eased = percent;
  13792. }
  13793. this.now = ( this.end - this.start ) * eased + this.start;
  13794. if ( this.options.step ) {
  13795. this.options.step.call( this.elem, this.now, this );
  13796. }
  13797. if ( hooks && hooks.set ) {
  13798. hooks.set( this );
  13799. } else {
  13800. Tween.propHooks._default.set( this );
  13801. }
  13802. return this;
  13803. }
  13804. };
  13805. Tween.prototype.init.prototype = Tween.prototype;
  13806. Tween.propHooks = {
  13807. _default: {
  13808. get: function( tween ) {
  13809. var result;
  13810. // Use a property on the element directly when it is not a DOM element,
  13811. // or when there is no matching style property that exists.
  13812. if ( tween.elem.nodeType !== 1 ||
  13813. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13814. return tween.elem[ tween.prop ];
  13815. }
  13816. // Passing an empty string as a 3rd parameter to .css will automatically
  13817. // attempt a parseFloat and fallback to a string if the parse fails.
  13818. // Simple values such as "10px" are parsed to Float;
  13819. // complex values such as "rotate(1rad)" are returned as-is.
  13820. result = jQuery.css( tween.elem, tween.prop, "" );
  13821. // Empty strings, null, undefined and "auto" are converted to 0.
  13822. return !result || result === "auto" ? 0 : result;
  13823. },
  13824. set: function( tween ) {
  13825. // Use step hook for back compat.
  13826. // Use cssHook if its there.
  13827. // Use .style if available and use plain properties where available.
  13828. if ( jQuery.fx.step[ tween.prop ] ) {
  13829. jQuery.fx.step[ tween.prop ]( tween );
  13830. } else if ( tween.elem.nodeType === 1 && (
  13831. jQuery.cssHooks[ tween.prop ] ||
  13832. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13833. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13834. } else {
  13835. tween.elem[ tween.prop ] = tween.now;
  13836. }
  13837. }
  13838. }
  13839. };
  13840. // Support: IE <=9 only
  13841. // Panic based approach to setting things on disconnected nodes
  13842. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13843. set: function( tween ) {
  13844. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13845. tween.elem[ tween.prop ] = tween.now;
  13846. }
  13847. }
  13848. };
  13849. jQuery.easing = {
  13850. linear: function( p ) {
  13851. return p;
  13852. },
  13853. swing: function( p ) {
  13854. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13855. },
  13856. _default: "swing"
  13857. };
  13858. jQuery.fx = Tween.prototype.init;
  13859. // Back compat <1.8 extension point
  13860. jQuery.fx.step = {};
  13861. var
  13862. fxNow, inProgress,
  13863. rfxtypes = /^(?:toggle|show|hide)$/,
  13864. rrun = /queueHooks$/;
  13865. function schedule() {
  13866. if ( inProgress ) {
  13867. if ( document.hidden === false && window.requestAnimationFrame ) {
  13868. window.requestAnimationFrame( schedule );
  13869. } else {
  13870. window.setTimeout( schedule, jQuery.fx.interval );
  13871. }
  13872. jQuery.fx.tick();
  13873. }
  13874. }
  13875. // Animations created synchronously will run synchronously
  13876. function createFxNow() {
  13877. window.setTimeout( function() {
  13878. fxNow = undefined;
  13879. } );
  13880. return ( fxNow = Date.now() );
  13881. }
  13882. // Generate parameters to create a standard animation
  13883. function genFx( type, includeWidth ) {
  13884. var which,
  13885. i = 0,
  13886. attrs = { height: type };
  13887. // If we include width, step value is 1 to do all cssExpand values,
  13888. // otherwise step value is 2 to skip over Left and Right
  13889. includeWidth = includeWidth ? 1 : 0;
  13890. for ( ; i < 4; i += 2 - includeWidth ) {
  13891. which = cssExpand[ i ];
  13892. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13893. }
  13894. if ( includeWidth ) {
  13895. attrs.opacity = attrs.width = type;
  13896. }
  13897. return attrs;
  13898. }
  13899. function createTween( value, prop, animation ) {
  13900. var tween,
  13901. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13902. index = 0,
  13903. length = collection.length;
  13904. for ( ; index < length; index++ ) {
  13905. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13906. // We're done with this property
  13907. return tween;
  13908. }
  13909. }
  13910. }
  13911. function defaultPrefilter( elem, props, opts ) {
  13912. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13913. isBox = "width" in props || "height" in props,
  13914. anim = this,
  13915. orig = {},
  13916. style = elem.style,
  13917. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13918. dataShow = dataPriv.get( elem, "fxshow" );
  13919. // Queue-skipping animations hijack the fx hooks
  13920. if ( !opts.queue ) {
  13921. hooks = jQuery._queueHooks( elem, "fx" );
  13922. if ( hooks.unqueued == null ) {
  13923. hooks.unqueued = 0;
  13924. oldfire = hooks.empty.fire;
  13925. hooks.empty.fire = function() {
  13926. if ( !hooks.unqueued ) {
  13927. oldfire();
  13928. }
  13929. };
  13930. }
  13931. hooks.unqueued++;
  13932. anim.always( function() {
  13933. // Ensure the complete handler is called before this completes
  13934. anim.always( function() {
  13935. hooks.unqueued--;
  13936. if ( !jQuery.queue( elem, "fx" ).length ) {
  13937. hooks.empty.fire();
  13938. }
  13939. } );
  13940. } );
  13941. }
  13942. // Detect show/hide animations
  13943. for ( prop in props ) {
  13944. value = props[ prop ];
  13945. if ( rfxtypes.test( value ) ) {
  13946. delete props[ prop ];
  13947. toggle = toggle || value === "toggle";
  13948. if ( value === ( hidden ? "hide" : "show" ) ) {
  13949. // Pretend to be hidden if this is a "show" and
  13950. // there is still data from a stopped show/hide
  13951. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13952. hidden = true;
  13953. // Ignore all other no-op show/hide data
  13954. } else {
  13955. continue;
  13956. }
  13957. }
  13958. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13959. }
  13960. }
  13961. // Bail out if this is a no-op like .hide().hide()
  13962. propTween = !jQuery.isEmptyObject( props );
  13963. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13964. return;
  13965. }
  13966. // Restrict "overflow" and "display" styles during box animations
  13967. if ( isBox && elem.nodeType === 1 ) {
  13968. // Support: IE <=9 - 11, Edge 12 - 15
  13969. // Record all 3 overflow attributes because IE does not infer the shorthand
  13970. // from identically-valued overflowX and overflowY and Edge just mirrors
  13971. // the overflowX value there.
  13972. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13973. // Identify a display type, preferring old show/hide data over the CSS cascade
  13974. restoreDisplay = dataShow && dataShow.display;
  13975. if ( restoreDisplay == null ) {
  13976. restoreDisplay = dataPriv.get( elem, "display" );
  13977. }
  13978. display = jQuery.css( elem, "display" );
  13979. if ( display === "none" ) {
  13980. if ( restoreDisplay ) {
  13981. display = restoreDisplay;
  13982. } else {
  13983. // Get nonempty value(s) by temporarily forcing visibility
  13984. showHide( [ elem ], true );
  13985. restoreDisplay = elem.style.display || restoreDisplay;
  13986. display = jQuery.css( elem, "display" );
  13987. showHide( [ elem ] );
  13988. }
  13989. }
  13990. // Animate inline elements as inline-block
  13991. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13992. if ( jQuery.css( elem, "float" ) === "none" ) {
  13993. // Restore the original display value at the end of pure show/hide animations
  13994. if ( !propTween ) {
  13995. anim.done( function() {
  13996. style.display = restoreDisplay;
  13997. } );
  13998. if ( restoreDisplay == null ) {
  13999. display = style.display;
  14000. restoreDisplay = display === "none" ? "" : display;
  14001. }
  14002. }
  14003. style.display = "inline-block";
  14004. }
  14005. }
  14006. }
  14007. if ( opts.overflow ) {
  14008. style.overflow = "hidden";
  14009. anim.always( function() {
  14010. style.overflow = opts.overflow[ 0 ];
  14011. style.overflowX = opts.overflow[ 1 ];
  14012. style.overflowY = opts.overflow[ 2 ];
  14013. } );
  14014. }
  14015. // Implement show/hide animations
  14016. propTween = false;
  14017. for ( prop in orig ) {
  14018. // General show/hide setup for this element animation
  14019. if ( !propTween ) {
  14020. if ( dataShow ) {
  14021. if ( "hidden" in dataShow ) {
  14022. hidden = dataShow.hidden;
  14023. }
  14024. } else {
  14025. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  14026. }
  14027. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  14028. if ( toggle ) {
  14029. dataShow.hidden = !hidden;
  14030. }
  14031. // Show elements before animating them
  14032. if ( hidden ) {
  14033. showHide( [ elem ], true );
  14034. }
  14035. /* eslint-disable no-loop-func */
  14036. anim.done( function() {
  14037. /* eslint-enable no-loop-func */
  14038. // The final step of a "hide" animation is actually hiding the element
  14039. if ( !hidden ) {
  14040. showHide( [ elem ] );
  14041. }
  14042. dataPriv.remove( elem, "fxshow" );
  14043. for ( prop in orig ) {
  14044. jQuery.style( elem, prop, orig[ prop ] );
  14045. }
  14046. } );
  14047. }
  14048. // Per-property setup
  14049. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  14050. if ( !( prop in dataShow ) ) {
  14051. dataShow[ prop ] = propTween.start;
  14052. if ( hidden ) {
  14053. propTween.end = propTween.start;
  14054. propTween.start = 0;
  14055. }
  14056. }
  14057. }
  14058. }
  14059. function propFilter( props, specialEasing ) {
  14060. var index, name, easing, value, hooks;
  14061. // camelCase, specialEasing and expand cssHook pass
  14062. for ( index in props ) {
  14063. name = camelCase( index );
  14064. easing = specialEasing[ name ];
  14065. value = props[ index ];
  14066. if ( Array.isArray( value ) ) {
  14067. easing = value[ 1 ];
  14068. value = props[ index ] = value[ 0 ];
  14069. }
  14070. if ( index !== name ) {
  14071. props[ name ] = value;
  14072. delete props[ index ];
  14073. }
  14074. hooks = jQuery.cssHooks[ name ];
  14075. if ( hooks && "expand" in hooks ) {
  14076. value = hooks.expand( value );
  14077. delete props[ name ];
  14078. // Not quite $.extend, this won't overwrite existing keys.
  14079. // Reusing 'index' because we have the correct "name"
  14080. for ( index in value ) {
  14081. if ( !( index in props ) ) {
  14082. props[ index ] = value[ index ];
  14083. specialEasing[ index ] = easing;
  14084. }
  14085. }
  14086. } else {
  14087. specialEasing[ name ] = easing;
  14088. }
  14089. }
  14090. }
  14091. function Animation( elem, properties, options ) {
  14092. var result,
  14093. stopped,
  14094. index = 0,
  14095. length = Animation.prefilters.length,
  14096. deferred = jQuery.Deferred().always( function() {
  14097. // Don't match elem in the :animated selector
  14098. delete tick.elem;
  14099. } ),
  14100. tick = function() {
  14101. if ( stopped ) {
  14102. return false;
  14103. }
  14104. var currentTime = fxNow || createFxNow(),
  14105. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  14106. // Support: Android 2.3 only
  14107. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  14108. temp = remaining / animation.duration || 0,
  14109. percent = 1 - temp,
  14110. index = 0,
  14111. length = animation.tweens.length;
  14112. for ( ; index < length; index++ ) {
  14113. animation.tweens[ index ].run( percent );
  14114. }
  14115. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14116. // If there's more to do, yield
  14117. if ( percent < 1 && length ) {
  14118. return remaining;
  14119. }
  14120. // If this was an empty animation, synthesize a final progress notification
  14121. if ( !length ) {
  14122. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14123. }
  14124. // Resolve the animation and report its conclusion
  14125. deferred.resolveWith( elem, [ animation ] );
  14126. return false;
  14127. },
  14128. animation = deferred.promise( {
  14129. elem: elem,
  14130. props: jQuery.extend( {}, properties ),
  14131. opts: jQuery.extend( true, {
  14132. specialEasing: {},
  14133. easing: jQuery.easing._default
  14134. }, options ),
  14135. originalProperties: properties,
  14136. originalOptions: options,
  14137. startTime: fxNow || createFxNow(),
  14138. duration: options.duration,
  14139. tweens: [],
  14140. createTween: function( prop, end ) {
  14141. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14142. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14143. animation.tweens.push( tween );
  14144. return tween;
  14145. },
  14146. stop: function( gotoEnd ) {
  14147. var index = 0,
  14148. // If we are going to the end, we want to run all the tweens
  14149. // otherwise we skip this part
  14150. length = gotoEnd ? animation.tweens.length : 0;
  14151. if ( stopped ) {
  14152. return this;
  14153. }
  14154. stopped = true;
  14155. for ( ; index < length; index++ ) {
  14156. animation.tweens[ index ].run( 1 );
  14157. }
  14158. // Resolve when we played the last frame; otherwise, reject
  14159. if ( gotoEnd ) {
  14160. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14161. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14162. } else {
  14163. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14164. }
  14165. return this;
  14166. }
  14167. } ),
  14168. props = animation.props;
  14169. propFilter( props, animation.opts.specialEasing );
  14170. for ( ; index < length; index++ ) {
  14171. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14172. if ( result ) {
  14173. if ( isFunction( result.stop ) ) {
  14174. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14175. result.stop.bind( result );
  14176. }
  14177. return result;
  14178. }
  14179. }
  14180. jQuery.map( props, createTween, animation );
  14181. if ( isFunction( animation.opts.start ) ) {
  14182. animation.opts.start.call( elem, animation );
  14183. }
  14184. // Attach callbacks from options
  14185. animation
  14186. .progress( animation.opts.progress )
  14187. .done( animation.opts.done, animation.opts.complete )
  14188. .fail( animation.opts.fail )
  14189. .always( animation.opts.always );
  14190. jQuery.fx.timer(
  14191. jQuery.extend( tick, {
  14192. elem: elem,
  14193. anim: animation,
  14194. queue: animation.opts.queue
  14195. } )
  14196. );
  14197. return animation;
  14198. }
  14199. jQuery.Animation = jQuery.extend( Animation, {
  14200. tweeners: {
  14201. "*": [ function( prop, value ) {
  14202. var tween = this.createTween( prop, value );
  14203. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14204. return tween;
  14205. } ]
  14206. },
  14207. tweener: function( props, callback ) {
  14208. if ( isFunction( props ) ) {
  14209. callback = props;
  14210. props = [ "*" ];
  14211. } else {
  14212. props = props.match( rnothtmlwhite );
  14213. }
  14214. var prop,
  14215. index = 0,
  14216. length = props.length;
  14217. for ( ; index < length; index++ ) {
  14218. prop = props[ index ];
  14219. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14220. Animation.tweeners[ prop ].unshift( callback );
  14221. }
  14222. },
  14223. prefilters: [ defaultPrefilter ],
  14224. prefilter: function( callback, prepend ) {
  14225. if ( prepend ) {
  14226. Animation.prefilters.unshift( callback );
  14227. } else {
  14228. Animation.prefilters.push( callback );
  14229. }
  14230. }
  14231. } );
  14232. jQuery.speed = function( speed, easing, fn ) {
  14233. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14234. complete: fn || !fn && easing ||
  14235. isFunction( speed ) && speed,
  14236. duration: speed,
  14237. easing: fn && easing || easing && !isFunction( easing ) && easing
  14238. };
  14239. // Go to the end state if fx are off
  14240. if ( jQuery.fx.off ) {
  14241. opt.duration = 0;
  14242. } else {
  14243. if ( typeof opt.duration !== "number" ) {
  14244. if ( opt.duration in jQuery.fx.speeds ) {
  14245. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14246. } else {
  14247. opt.duration = jQuery.fx.speeds._default;
  14248. }
  14249. }
  14250. }
  14251. // Normalize opt.queue - true/undefined/null -> "fx"
  14252. if ( opt.queue == null || opt.queue === true ) {
  14253. opt.queue = "fx";
  14254. }
  14255. // Queueing
  14256. opt.old = opt.complete;
  14257. opt.complete = function() {
  14258. if ( isFunction( opt.old ) ) {
  14259. opt.old.call( this );
  14260. }
  14261. if ( opt.queue ) {
  14262. jQuery.dequeue( this, opt.queue );
  14263. }
  14264. };
  14265. return opt;
  14266. };
  14267. jQuery.fn.extend( {
  14268. fadeTo: function( speed, to, easing, callback ) {
  14269. // Show any hidden elements after setting opacity to 0
  14270. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14271. // Animate to the value specified
  14272. .end().animate( { opacity: to }, speed, easing, callback );
  14273. },
  14274. animate: function( prop, speed, easing, callback ) {
  14275. var empty = jQuery.isEmptyObject( prop ),
  14276. optall = jQuery.speed( speed, easing, callback ),
  14277. doAnimation = function() {
  14278. // Operate on a copy of prop so per-property easing won't be lost
  14279. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14280. // Empty animations, or finishing resolves immediately
  14281. if ( empty || dataPriv.get( this, "finish" ) ) {
  14282. anim.stop( true );
  14283. }
  14284. };
  14285. doAnimation.finish = doAnimation;
  14286. return empty || optall.queue === false ?
  14287. this.each( doAnimation ) :
  14288. this.queue( optall.queue, doAnimation );
  14289. },
  14290. stop: function( type, clearQueue, gotoEnd ) {
  14291. var stopQueue = function( hooks ) {
  14292. var stop = hooks.stop;
  14293. delete hooks.stop;
  14294. stop( gotoEnd );
  14295. };
  14296. if ( typeof type !== "string" ) {
  14297. gotoEnd = clearQueue;
  14298. clearQueue = type;
  14299. type = undefined;
  14300. }
  14301. if ( clearQueue && type !== false ) {
  14302. this.queue( type || "fx", [] );
  14303. }
  14304. return this.each( function() {
  14305. var dequeue = true,
  14306. index = type != null && type + "queueHooks",
  14307. timers = jQuery.timers,
  14308. data = dataPriv.get( this );
  14309. if ( index ) {
  14310. if ( data[ index ] && data[ index ].stop ) {
  14311. stopQueue( data[ index ] );
  14312. }
  14313. } else {
  14314. for ( index in data ) {
  14315. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14316. stopQueue( data[ index ] );
  14317. }
  14318. }
  14319. }
  14320. for ( index = timers.length; index--; ) {
  14321. if ( timers[ index ].elem === this &&
  14322. ( type == null || timers[ index ].queue === type ) ) {
  14323. timers[ index ].anim.stop( gotoEnd );
  14324. dequeue = false;
  14325. timers.splice( index, 1 );
  14326. }
  14327. }
  14328. // Start the next in the queue if the last step wasn't forced.
  14329. // Timers currently will call their complete callbacks, which
  14330. // will dequeue but only if they were gotoEnd.
  14331. if ( dequeue || !gotoEnd ) {
  14332. jQuery.dequeue( this, type );
  14333. }
  14334. } );
  14335. },
  14336. finish: function( type ) {
  14337. if ( type !== false ) {
  14338. type = type || "fx";
  14339. }
  14340. return this.each( function() {
  14341. var index,
  14342. data = dataPriv.get( this ),
  14343. queue = data[ type + "queue" ],
  14344. hooks = data[ type + "queueHooks" ],
  14345. timers = jQuery.timers,
  14346. length = queue ? queue.length : 0;
  14347. // Enable finishing flag on private data
  14348. data.finish = true;
  14349. // Empty the queue first
  14350. jQuery.queue( this, type, [] );
  14351. if ( hooks && hooks.stop ) {
  14352. hooks.stop.call( this, true );
  14353. }
  14354. // Look for any active animations, and finish them
  14355. for ( index = timers.length; index--; ) {
  14356. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14357. timers[ index ].anim.stop( true );
  14358. timers.splice( index, 1 );
  14359. }
  14360. }
  14361. // Look for any animations in the old queue and finish them
  14362. for ( index = 0; index < length; index++ ) {
  14363. if ( queue[ index ] && queue[ index ].finish ) {
  14364. queue[ index ].finish.call( this );
  14365. }
  14366. }
  14367. // Turn off finishing flag
  14368. delete data.finish;
  14369. } );
  14370. }
  14371. } );
  14372. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14373. var cssFn = jQuery.fn[ name ];
  14374. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14375. return speed == null || typeof speed === "boolean" ?
  14376. cssFn.apply( this, arguments ) :
  14377. this.animate( genFx( name, true ), speed, easing, callback );
  14378. };
  14379. } );
  14380. // Generate shortcuts for custom animations
  14381. jQuery.each( {
  14382. slideDown: genFx( "show" ),
  14383. slideUp: genFx( "hide" ),
  14384. slideToggle: genFx( "toggle" ),
  14385. fadeIn: { opacity: "show" },
  14386. fadeOut: { opacity: "hide" },
  14387. fadeToggle: { opacity: "toggle" }
  14388. }, function( name, props ) {
  14389. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14390. return this.animate( props, speed, easing, callback );
  14391. };
  14392. } );
  14393. jQuery.timers = [];
  14394. jQuery.fx.tick = function() {
  14395. var timer,
  14396. i = 0,
  14397. timers = jQuery.timers;
  14398. fxNow = Date.now();
  14399. for ( ; i < timers.length; i++ ) {
  14400. timer = timers[ i ];
  14401. // Run the timer and safely remove it when done (allowing for external removal)
  14402. if ( !timer() && timers[ i ] === timer ) {
  14403. timers.splice( i--, 1 );
  14404. }
  14405. }
  14406. if ( !timers.length ) {
  14407. jQuery.fx.stop();
  14408. }
  14409. fxNow = undefined;
  14410. };
  14411. jQuery.fx.timer = function( timer ) {
  14412. jQuery.timers.push( timer );
  14413. jQuery.fx.start();
  14414. };
  14415. jQuery.fx.interval = 13;
  14416. jQuery.fx.start = function() {
  14417. if ( inProgress ) {
  14418. return;
  14419. }
  14420. inProgress = true;
  14421. schedule();
  14422. };
  14423. jQuery.fx.stop = function() {
  14424. inProgress = null;
  14425. };
  14426. jQuery.fx.speeds = {
  14427. slow: 600,
  14428. fast: 200,
  14429. // Default speed
  14430. _default: 400
  14431. };
  14432. // Based off of the plugin by Clint Helfers, with permission.
  14433. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14434. jQuery.fn.delay = function( time, type ) {
  14435. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14436. type = type || "fx";
  14437. return this.queue( type, function( next, hooks ) {
  14438. var timeout = window.setTimeout( next, time );
  14439. hooks.stop = function() {
  14440. window.clearTimeout( timeout );
  14441. };
  14442. } );
  14443. };
  14444. ( function() {
  14445. var input = document.createElement( "input" ),
  14446. select = document.createElement( "select" ),
  14447. opt = select.appendChild( document.createElement( "option" ) );
  14448. input.type = "checkbox";
  14449. // Support: Android <=4.3 only
  14450. // Default value for a checkbox should be "on"
  14451. support.checkOn = input.value !== "";
  14452. // Support: IE <=11 only
  14453. // Must access selectedIndex to make default options select
  14454. support.optSelected = opt.selected;
  14455. // Support: IE <=11 only
  14456. // An input loses its value after becoming a radio
  14457. input = document.createElement( "input" );
  14458. input.value = "t";
  14459. input.type = "radio";
  14460. support.radioValue = input.value === "t";
  14461. } )();
  14462. var boolHook,
  14463. attrHandle = jQuery.expr.attrHandle;
  14464. jQuery.fn.extend( {
  14465. attr: function( name, value ) {
  14466. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14467. },
  14468. removeAttr: function( name ) {
  14469. return this.each( function() {
  14470. jQuery.removeAttr( this, name );
  14471. } );
  14472. }
  14473. } );
  14474. jQuery.extend( {
  14475. attr: function( elem, name, value ) {
  14476. var ret, hooks,
  14477. nType = elem.nodeType;
  14478. // Don't get/set attributes on text, comment and attribute nodes
  14479. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14480. return;
  14481. }
  14482. // Fallback to prop when attributes are not supported
  14483. if ( typeof elem.getAttribute === "undefined" ) {
  14484. return jQuery.prop( elem, name, value );
  14485. }
  14486. // Attribute hooks are determined by the lowercase version
  14487. // Grab necessary hook if one is defined
  14488. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14489. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14490. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14491. }
  14492. if ( value !== undefined ) {
  14493. if ( value === null ) {
  14494. jQuery.removeAttr( elem, name );
  14495. return;
  14496. }
  14497. if ( hooks && "set" in hooks &&
  14498. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14499. return ret;
  14500. }
  14501. elem.setAttribute( name, value + "" );
  14502. return value;
  14503. }
  14504. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14505. return ret;
  14506. }
  14507. ret = jQuery.find.attr( elem, name );
  14508. // Non-existent attributes return null, we normalize to undefined
  14509. return ret == null ? undefined : ret;
  14510. },
  14511. attrHooks: {
  14512. type: {
  14513. set: function( elem, value ) {
  14514. if ( !support.radioValue && value === "radio" &&
  14515. nodeName( elem, "input" ) ) {
  14516. var val = elem.value;
  14517. elem.setAttribute( "type", value );
  14518. if ( val ) {
  14519. elem.value = val;
  14520. }
  14521. return value;
  14522. }
  14523. }
  14524. }
  14525. },
  14526. removeAttr: function( elem, value ) {
  14527. var name,
  14528. i = 0,
  14529. // Attribute names can contain non-HTML whitespace characters
  14530. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14531. attrNames = value && value.match( rnothtmlwhite );
  14532. if ( attrNames && elem.nodeType === 1 ) {
  14533. while ( ( name = attrNames[ i++ ] ) ) {
  14534. elem.removeAttribute( name );
  14535. }
  14536. }
  14537. }
  14538. } );
  14539. // Hooks for boolean attributes
  14540. boolHook = {
  14541. set: function( elem, value, name ) {
  14542. if ( value === false ) {
  14543. // Remove boolean attributes when set to false
  14544. jQuery.removeAttr( elem, name );
  14545. } else {
  14546. elem.setAttribute( name, name );
  14547. }
  14548. return name;
  14549. }
  14550. };
  14551. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14552. var getter = attrHandle[ name ] || jQuery.find.attr;
  14553. attrHandle[ name ] = function( elem, name, isXML ) {
  14554. var ret, handle,
  14555. lowercaseName = name.toLowerCase();
  14556. if ( !isXML ) {
  14557. // Avoid an infinite loop by temporarily removing this function from the getter
  14558. handle = attrHandle[ lowercaseName ];
  14559. attrHandle[ lowercaseName ] = ret;
  14560. ret = getter( elem, name, isXML ) != null ?
  14561. lowercaseName :
  14562. null;
  14563. attrHandle[ lowercaseName ] = handle;
  14564. }
  14565. return ret;
  14566. };
  14567. } );
  14568. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14569. rclickable = /^(?:a|area)$/i;
  14570. jQuery.fn.extend( {
  14571. prop: function( name, value ) {
  14572. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14573. },
  14574. removeProp: function( name ) {
  14575. return this.each( function() {
  14576. delete this[ jQuery.propFix[ name ] || name ];
  14577. } );
  14578. }
  14579. } );
  14580. jQuery.extend( {
  14581. prop: function( elem, name, value ) {
  14582. var ret, hooks,
  14583. nType = elem.nodeType;
  14584. // Don't get/set properties on text, comment and attribute nodes
  14585. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14586. return;
  14587. }
  14588. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14589. // Fix name and attach hooks
  14590. name = jQuery.propFix[ name ] || name;
  14591. hooks = jQuery.propHooks[ name ];
  14592. }
  14593. if ( value !== undefined ) {
  14594. if ( hooks && "set" in hooks &&
  14595. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14596. return ret;
  14597. }
  14598. return ( elem[ name ] = value );
  14599. }
  14600. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14601. return ret;
  14602. }
  14603. return elem[ name ];
  14604. },
  14605. propHooks: {
  14606. tabIndex: {
  14607. get: function( elem ) {
  14608. // Support: IE <=9 - 11 only
  14609. // elem.tabIndex doesn't always return the
  14610. // correct value when it hasn't been explicitly set
  14611. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14612. // Use proper attribute retrieval(#12072)
  14613. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14614. if ( tabindex ) {
  14615. return parseInt( tabindex, 10 );
  14616. }
  14617. if (
  14618. rfocusable.test( elem.nodeName ) ||
  14619. rclickable.test( elem.nodeName ) &&
  14620. elem.href
  14621. ) {
  14622. return 0;
  14623. }
  14624. return -1;
  14625. }
  14626. }
  14627. },
  14628. propFix: {
  14629. "for": "htmlFor",
  14630. "class": "className"
  14631. }
  14632. } );
  14633. // Support: IE <=11 only
  14634. // Accessing the selectedIndex property
  14635. // forces the browser to respect setting selected
  14636. // on the option
  14637. // The getter ensures a default option is selected
  14638. // when in an optgroup
  14639. // eslint rule "no-unused-expressions" is disabled for this code
  14640. // since it considers such accessions noop
  14641. if ( !support.optSelected ) {
  14642. jQuery.propHooks.selected = {
  14643. get: function( elem ) {
  14644. /* eslint no-unused-expressions: "off" */
  14645. var parent = elem.parentNode;
  14646. if ( parent && parent.parentNode ) {
  14647. parent.parentNode.selectedIndex;
  14648. }
  14649. return null;
  14650. },
  14651. set: function( elem ) {
  14652. /* eslint no-unused-expressions: "off" */
  14653. var parent = elem.parentNode;
  14654. if ( parent ) {
  14655. parent.selectedIndex;
  14656. if ( parent.parentNode ) {
  14657. parent.parentNode.selectedIndex;
  14658. }
  14659. }
  14660. }
  14661. };
  14662. }
  14663. jQuery.each( [
  14664. "tabIndex",
  14665. "readOnly",
  14666. "maxLength",
  14667. "cellSpacing",
  14668. "cellPadding",
  14669. "rowSpan",
  14670. "colSpan",
  14671. "useMap",
  14672. "frameBorder",
  14673. "contentEditable"
  14674. ], function() {
  14675. jQuery.propFix[ this.toLowerCase() ] = this;
  14676. } );
  14677. // Strip and collapse whitespace according to HTML spec
  14678. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14679. function stripAndCollapse( value ) {
  14680. var tokens = value.match( rnothtmlwhite ) || [];
  14681. return tokens.join( " " );
  14682. }
  14683. function getClass( elem ) {
  14684. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14685. }
  14686. function classesToArray( value ) {
  14687. if ( Array.isArray( value ) ) {
  14688. return value;
  14689. }
  14690. if ( typeof value === "string" ) {
  14691. return value.match( rnothtmlwhite ) || [];
  14692. }
  14693. return [];
  14694. }
  14695. jQuery.fn.extend( {
  14696. addClass: function( value ) {
  14697. var classes, elem, cur, curValue, clazz, j, finalValue,
  14698. i = 0;
  14699. if ( isFunction( value ) ) {
  14700. return this.each( function( j ) {
  14701. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14702. } );
  14703. }
  14704. classes = classesToArray( value );
  14705. if ( classes.length ) {
  14706. while ( ( elem = this[ i++ ] ) ) {
  14707. curValue = getClass( elem );
  14708. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14709. if ( cur ) {
  14710. j = 0;
  14711. while ( ( clazz = classes[ j++ ] ) ) {
  14712. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14713. cur += clazz + " ";
  14714. }
  14715. }
  14716. // Only assign if different to avoid unneeded rendering.
  14717. finalValue = stripAndCollapse( cur );
  14718. if ( curValue !== finalValue ) {
  14719. elem.setAttribute( "class", finalValue );
  14720. }
  14721. }
  14722. }
  14723. }
  14724. return this;
  14725. },
  14726. removeClass: function( value ) {
  14727. var classes, elem, cur, curValue, clazz, j, finalValue,
  14728. i = 0;
  14729. if ( isFunction( value ) ) {
  14730. return this.each( function( j ) {
  14731. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14732. } );
  14733. }
  14734. if ( !arguments.length ) {
  14735. return this.attr( "class", "" );
  14736. }
  14737. classes = classesToArray( value );
  14738. if ( classes.length ) {
  14739. while ( ( elem = this[ i++ ] ) ) {
  14740. curValue = getClass( elem );
  14741. // This expression is here for better compressibility (see addClass)
  14742. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14743. if ( cur ) {
  14744. j = 0;
  14745. while ( ( clazz = classes[ j++ ] ) ) {
  14746. // Remove *all* instances
  14747. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14748. cur = cur.replace( " " + clazz + " ", " " );
  14749. }
  14750. }
  14751. // Only assign if different to avoid unneeded rendering.
  14752. finalValue = stripAndCollapse( cur );
  14753. if ( curValue !== finalValue ) {
  14754. elem.setAttribute( "class", finalValue );
  14755. }
  14756. }
  14757. }
  14758. }
  14759. return this;
  14760. },
  14761. toggleClass: function( value, stateVal ) {
  14762. var type = typeof value,
  14763. isValidValue = type === "string" || Array.isArray( value );
  14764. if ( typeof stateVal === "boolean" && isValidValue ) {
  14765. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14766. }
  14767. if ( isFunction( value ) ) {
  14768. return this.each( function( i ) {
  14769. jQuery( this ).toggleClass(
  14770. value.call( this, i, getClass( this ), stateVal ),
  14771. stateVal
  14772. );
  14773. } );
  14774. }
  14775. return this.each( function() {
  14776. var className, i, self, classNames;
  14777. if ( isValidValue ) {
  14778. // Toggle individual class names
  14779. i = 0;
  14780. self = jQuery( this );
  14781. classNames = classesToArray( value );
  14782. while ( ( className = classNames[ i++ ] ) ) {
  14783. // Check each className given, space separated list
  14784. if ( self.hasClass( className ) ) {
  14785. self.removeClass( className );
  14786. } else {
  14787. self.addClass( className );
  14788. }
  14789. }
  14790. // Toggle whole class name
  14791. } else if ( value === undefined || type === "boolean" ) {
  14792. className = getClass( this );
  14793. if ( className ) {
  14794. // Store className if set
  14795. dataPriv.set( this, "__className__", className );
  14796. }
  14797. // If the element has a class name or if we're passed `false`,
  14798. // then remove the whole classname (if there was one, the above saved it).
  14799. // Otherwise bring back whatever was previously saved (if anything),
  14800. // falling back to the empty string if nothing was stored.
  14801. if ( this.setAttribute ) {
  14802. this.setAttribute( "class",
  14803. className || value === false ?
  14804. "" :
  14805. dataPriv.get( this, "__className__" ) || ""
  14806. );
  14807. }
  14808. }
  14809. } );
  14810. },
  14811. hasClass: function( selector ) {
  14812. var className, elem,
  14813. i = 0;
  14814. className = " " + selector + " ";
  14815. while ( ( elem = this[ i++ ] ) ) {
  14816. if ( elem.nodeType === 1 &&
  14817. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14818. return true;
  14819. }
  14820. }
  14821. return false;
  14822. }
  14823. } );
  14824. var rreturn = /\r/g;
  14825. jQuery.fn.extend( {
  14826. val: function( value ) {
  14827. var hooks, ret, valueIsFunction,
  14828. elem = this[ 0 ];
  14829. if ( !arguments.length ) {
  14830. if ( elem ) {
  14831. hooks = jQuery.valHooks[ elem.type ] ||
  14832. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14833. if ( hooks &&
  14834. "get" in hooks &&
  14835. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14836. ) {
  14837. return ret;
  14838. }
  14839. ret = elem.value;
  14840. // Handle most common string cases
  14841. if ( typeof ret === "string" ) {
  14842. return ret.replace( rreturn, "" );
  14843. }
  14844. // Handle cases where value is null/undef or number
  14845. return ret == null ? "" : ret;
  14846. }
  14847. return;
  14848. }
  14849. valueIsFunction = isFunction( value );
  14850. return this.each( function( i ) {
  14851. var val;
  14852. if ( this.nodeType !== 1 ) {
  14853. return;
  14854. }
  14855. if ( valueIsFunction ) {
  14856. val = value.call( this, i, jQuery( this ).val() );
  14857. } else {
  14858. val = value;
  14859. }
  14860. // Treat null/undefined as ""; convert numbers to string
  14861. if ( val == null ) {
  14862. val = "";
  14863. } else if ( typeof val === "number" ) {
  14864. val += "";
  14865. } else if ( Array.isArray( val ) ) {
  14866. val = jQuery.map( val, function( value ) {
  14867. return value == null ? "" : value + "";
  14868. } );
  14869. }
  14870. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14871. // If set returns undefined, fall back to normal setting
  14872. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14873. this.value = val;
  14874. }
  14875. } );
  14876. }
  14877. } );
  14878. jQuery.extend( {
  14879. valHooks: {
  14880. option: {
  14881. get: function( elem ) {
  14882. var val = jQuery.find.attr( elem, "value" );
  14883. return val != null ?
  14884. val :
  14885. // Support: IE <=10 - 11 only
  14886. // option.text throws exceptions (#14686, #14858)
  14887. // Strip and collapse whitespace
  14888. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14889. stripAndCollapse( jQuery.text( elem ) );
  14890. }
  14891. },
  14892. select: {
  14893. get: function( elem ) {
  14894. var value, option, i,
  14895. options = elem.options,
  14896. index = elem.selectedIndex,
  14897. one = elem.type === "select-one",
  14898. values = one ? null : [],
  14899. max = one ? index + 1 : options.length;
  14900. if ( index < 0 ) {
  14901. i = max;
  14902. } else {
  14903. i = one ? index : 0;
  14904. }
  14905. // Loop through all the selected options
  14906. for ( ; i < max; i++ ) {
  14907. option = options[ i ];
  14908. // Support: IE <=9 only
  14909. // IE8-9 doesn't update selected after form reset (#2551)
  14910. if ( ( option.selected || i === index ) &&
  14911. // Don't return options that are disabled or in a disabled optgroup
  14912. !option.disabled &&
  14913. ( !option.parentNode.disabled ||
  14914. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14915. // Get the specific value for the option
  14916. value = jQuery( option ).val();
  14917. // We don't need an array for one selects
  14918. if ( one ) {
  14919. return value;
  14920. }
  14921. // Multi-Selects return an array
  14922. values.push( value );
  14923. }
  14924. }
  14925. return values;
  14926. },
  14927. set: function( elem, value ) {
  14928. var optionSet, option,
  14929. options = elem.options,
  14930. values = jQuery.makeArray( value ),
  14931. i = options.length;
  14932. while ( i-- ) {
  14933. option = options[ i ];
  14934. /* eslint-disable no-cond-assign */
  14935. if ( option.selected =
  14936. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14937. ) {
  14938. optionSet = true;
  14939. }
  14940. /* eslint-enable no-cond-assign */
  14941. }
  14942. // Force browsers to behave consistently when non-matching value is set
  14943. if ( !optionSet ) {
  14944. elem.selectedIndex = -1;
  14945. }
  14946. return values;
  14947. }
  14948. }
  14949. }
  14950. } );
  14951. // Radios and checkboxes getter/setter
  14952. jQuery.each( [ "radio", "checkbox" ], function() {
  14953. jQuery.valHooks[ this ] = {
  14954. set: function( elem, value ) {
  14955. if ( Array.isArray( value ) ) {
  14956. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14957. }
  14958. }
  14959. };
  14960. if ( !support.checkOn ) {
  14961. jQuery.valHooks[ this ].get = function( elem ) {
  14962. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14963. };
  14964. }
  14965. } );
  14966. // Return jQuery for attributes-only inclusion
  14967. support.focusin = "onfocusin" in window;
  14968. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14969. stopPropagationCallback = function( e ) {
  14970. e.stopPropagation();
  14971. };
  14972. jQuery.extend( jQuery.event, {
  14973. trigger: function( event, data, elem, onlyHandlers ) {
  14974. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14975. eventPath = [ elem || document ],
  14976. type = hasOwn.call( event, "type" ) ? event.type : event,
  14977. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14978. cur = lastElement = tmp = elem = elem || document;
  14979. // Don't do events on text and comment nodes
  14980. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14981. return;
  14982. }
  14983. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14984. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14985. return;
  14986. }
  14987. if ( type.indexOf( "." ) > -1 ) {
  14988. // Namespaced trigger; create a regexp to match event type in handle()
  14989. namespaces = type.split( "." );
  14990. type = namespaces.shift();
  14991. namespaces.sort();
  14992. }
  14993. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14994. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14995. event = event[ jQuery.expando ] ?
  14996. event :
  14997. new jQuery.Event( type, typeof event === "object" && event );
  14998. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14999. event.isTrigger = onlyHandlers ? 2 : 3;
  15000. event.namespace = namespaces.join( "." );
  15001. event.rnamespace = event.namespace ?
  15002. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  15003. null;
  15004. // Clean up the event in case it is being reused
  15005. event.result = undefined;
  15006. if ( !event.target ) {
  15007. event.target = elem;
  15008. }
  15009. // Clone any incoming data and prepend the event, creating the handler arg list
  15010. data = data == null ?
  15011. [ event ] :
  15012. jQuery.makeArray( data, [ event ] );
  15013. // Allow special events to draw outside the lines
  15014. special = jQuery.event.special[ type ] || {};
  15015. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  15016. return;
  15017. }
  15018. // Determine event propagation path in advance, per W3C events spec (#9951)
  15019. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  15020. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  15021. bubbleType = special.delegateType || type;
  15022. if ( !rfocusMorph.test( bubbleType + type ) ) {
  15023. cur = cur.parentNode;
  15024. }
  15025. for ( ; cur; cur = cur.parentNode ) {
  15026. eventPath.push( cur );
  15027. tmp = cur;
  15028. }
  15029. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  15030. if ( tmp === ( elem.ownerDocument || document ) ) {
  15031. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  15032. }
  15033. }
  15034. // Fire handlers on the event path
  15035. i = 0;
  15036. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  15037. lastElement = cur;
  15038. event.type = i > 1 ?
  15039. bubbleType :
  15040. special.bindType || type;
  15041. // jQuery handler
  15042. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  15043. dataPriv.get( cur, "handle" );
  15044. if ( handle ) {
  15045. handle.apply( cur, data );
  15046. }
  15047. // Native handler
  15048. handle = ontype && cur[ ontype ];
  15049. if ( handle && handle.apply && acceptData( cur ) ) {
  15050. event.result = handle.apply( cur, data );
  15051. if ( event.result === false ) {
  15052. event.preventDefault();
  15053. }
  15054. }
  15055. }
  15056. event.type = type;
  15057. // If nobody prevented the default action, do it now
  15058. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  15059. if ( ( !special._default ||
  15060. special._default.apply( eventPath.pop(), data ) === false ) &&
  15061. acceptData( elem ) ) {
  15062. // Call a native DOM method on the target with the same name as the event.
  15063. // Don't do default actions on window, that's where global variables be (#6170)
  15064. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  15065. // Don't re-trigger an onFOO event when we call its FOO() method
  15066. tmp = elem[ ontype ];
  15067. if ( tmp ) {
  15068. elem[ ontype ] = null;
  15069. }
  15070. // Prevent re-triggering of the same event, since we already bubbled it above
  15071. jQuery.event.triggered = type;
  15072. if ( event.isPropagationStopped() ) {
  15073. lastElement.addEventListener( type, stopPropagationCallback );
  15074. }
  15075. elem[ type ]();
  15076. if ( event.isPropagationStopped() ) {
  15077. lastElement.removeEventListener( type, stopPropagationCallback );
  15078. }
  15079. jQuery.event.triggered = undefined;
  15080. if ( tmp ) {
  15081. elem[ ontype ] = tmp;
  15082. }
  15083. }
  15084. }
  15085. }
  15086. return event.result;
  15087. },
  15088. // Piggyback on a donor event to simulate a different one
  15089. // Used only for `focus(in | out)` events
  15090. simulate: function( type, elem, event ) {
  15091. var e = jQuery.extend(
  15092. new jQuery.Event(),
  15093. event,
  15094. {
  15095. type: type,
  15096. isSimulated: true
  15097. }
  15098. );
  15099. jQuery.event.trigger( e, null, elem );
  15100. }
  15101. } );
  15102. jQuery.fn.extend( {
  15103. trigger: function( type, data ) {
  15104. return this.each( function() {
  15105. jQuery.event.trigger( type, data, this );
  15106. } );
  15107. },
  15108. triggerHandler: function( type, data ) {
  15109. var elem = this[ 0 ];
  15110. if ( elem ) {
  15111. return jQuery.event.trigger( type, data, elem, true );
  15112. }
  15113. }
  15114. } );
  15115. // Support: Firefox <=44
  15116. // Firefox doesn't have focus(in | out) events
  15117. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15118. //
  15119. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15120. // focus(in | out) events fire after focus & blur events,
  15121. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15122. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15123. if ( !support.focusin ) {
  15124. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15125. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15126. var handler = function( event ) {
  15127. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15128. };
  15129. jQuery.event.special[ fix ] = {
  15130. setup: function() {
  15131. var doc = this.ownerDocument || this,
  15132. attaches = dataPriv.access( doc, fix );
  15133. if ( !attaches ) {
  15134. doc.addEventListener( orig, handler, true );
  15135. }
  15136. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15137. },
  15138. teardown: function() {
  15139. var doc = this.ownerDocument || this,
  15140. attaches = dataPriv.access( doc, fix ) - 1;
  15141. if ( !attaches ) {
  15142. doc.removeEventListener( orig, handler, true );
  15143. dataPriv.remove( doc, fix );
  15144. } else {
  15145. dataPriv.access( doc, fix, attaches );
  15146. }
  15147. }
  15148. };
  15149. } );
  15150. }
  15151. var location = window.location;
  15152. var nonce = Date.now();
  15153. var rquery = ( /\?/ );
  15154. // Cross-browser xml parsing
  15155. jQuery.parseXML = function( data ) {
  15156. var xml;
  15157. if ( !data || typeof data !== "string" ) {
  15158. return null;
  15159. }
  15160. // Support: IE 9 - 11 only
  15161. // IE throws on parseFromString with invalid input.
  15162. try {
  15163. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15164. } catch ( e ) {
  15165. xml = undefined;
  15166. }
  15167. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15168. jQuery.error( "Invalid XML: " + data );
  15169. }
  15170. return xml;
  15171. };
  15172. var
  15173. rbracket = /\[\]$/,
  15174. rCRLF = /\r?\n/g,
  15175. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15176. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15177. function buildParams( prefix, obj, traditional, add ) {
  15178. var name;
  15179. if ( Array.isArray( obj ) ) {
  15180. // Serialize array item.
  15181. jQuery.each( obj, function( i, v ) {
  15182. if ( traditional || rbracket.test( prefix ) ) {
  15183. // Treat each array item as a scalar.
  15184. add( prefix, v );
  15185. } else {
  15186. // Item is non-scalar (array or object), encode its numeric index.
  15187. buildParams(
  15188. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15189. v,
  15190. traditional,
  15191. add
  15192. );
  15193. }
  15194. } );
  15195. } else if ( !traditional && toType( obj ) === "object" ) {
  15196. // Serialize object item.
  15197. for ( name in obj ) {
  15198. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15199. }
  15200. } else {
  15201. // Serialize scalar item.
  15202. add( prefix, obj );
  15203. }
  15204. }
  15205. // Serialize an array of form elements or a set of
  15206. // key/values into a query string
  15207. jQuery.param = function( a, traditional ) {
  15208. var prefix,
  15209. s = [],
  15210. add = function( key, valueOrFunction ) {
  15211. // If value is a function, invoke it and use its return value
  15212. var value = isFunction( valueOrFunction ) ?
  15213. valueOrFunction() :
  15214. valueOrFunction;
  15215. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15216. encodeURIComponent( value == null ? "" : value );
  15217. };
  15218. if ( a == null ) {
  15219. return "";
  15220. }
  15221. // If an array was passed in, assume that it is an array of form elements.
  15222. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15223. // Serialize the form elements
  15224. jQuery.each( a, function() {
  15225. add( this.name, this.value );
  15226. } );
  15227. } else {
  15228. // If traditional, encode the "old" way (the way 1.3.2 or older
  15229. // did it), otherwise encode params recursively.
  15230. for ( prefix in a ) {
  15231. buildParams( prefix, a[ prefix ], traditional, add );
  15232. }
  15233. }
  15234. // Return the resulting serialization
  15235. return s.join( "&" );
  15236. };
  15237. jQuery.fn.extend( {
  15238. serialize: function() {
  15239. return jQuery.param( this.serializeArray() );
  15240. },
  15241. serializeArray: function() {
  15242. return this.map( function() {
  15243. // Can add propHook for "elements" to filter or add form elements
  15244. var elements = jQuery.prop( this, "elements" );
  15245. return elements ? jQuery.makeArray( elements ) : this;
  15246. } )
  15247. .filter( function() {
  15248. var type = this.type;
  15249. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15250. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15251. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15252. ( this.checked || !rcheckableType.test( type ) );
  15253. } )
  15254. .map( function( i, elem ) {
  15255. var val = jQuery( this ).val();
  15256. if ( val == null ) {
  15257. return null;
  15258. }
  15259. if ( Array.isArray( val ) ) {
  15260. return jQuery.map( val, function( val ) {
  15261. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15262. } );
  15263. }
  15264. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15265. } ).get();
  15266. }
  15267. } );
  15268. var
  15269. r20 = /%20/g,
  15270. rhash = /#.*$/,
  15271. rantiCache = /([?&])_=[^&]*/,
  15272. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15273. // #7653, #8125, #8152: local protocol detection
  15274. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15275. rnoContent = /^(?:GET|HEAD)$/,
  15276. rprotocol = /^\/\//,
  15277. /* Prefilters
  15278. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15279. * 2) These are called:
  15280. * - BEFORE asking for a transport
  15281. * - AFTER param serialization (s.data is a string if s.processData is true)
  15282. * 3) key is the dataType
  15283. * 4) the catchall symbol "*" can be used
  15284. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15285. */
  15286. prefilters = {},
  15287. /* Transports bindings
  15288. * 1) key is the dataType
  15289. * 2) the catchall symbol "*" can be used
  15290. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15291. */
  15292. transports = {},
  15293. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15294. allTypes = "*/".concat( "*" ),
  15295. // Anchor tag for parsing the document origin
  15296. originAnchor = document.createElement( "a" );
  15297. originAnchor.href = location.href;
  15298. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15299. function addToPrefiltersOrTransports( structure ) {
  15300. // dataTypeExpression is optional and defaults to "*"
  15301. return function( dataTypeExpression, func ) {
  15302. if ( typeof dataTypeExpression !== "string" ) {
  15303. func = dataTypeExpression;
  15304. dataTypeExpression = "*";
  15305. }
  15306. var dataType,
  15307. i = 0,
  15308. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15309. if ( isFunction( func ) ) {
  15310. // For each dataType in the dataTypeExpression
  15311. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15312. // Prepend if requested
  15313. if ( dataType[ 0 ] === "+" ) {
  15314. dataType = dataType.slice( 1 ) || "*";
  15315. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15316. // Otherwise append
  15317. } else {
  15318. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15319. }
  15320. }
  15321. }
  15322. };
  15323. }
  15324. // Base inspection function for prefilters and transports
  15325. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15326. var inspected = {},
  15327. seekingTransport = ( structure === transports );
  15328. function inspect( dataType ) {
  15329. var selected;
  15330. inspected[ dataType ] = true;
  15331. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15332. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15333. if ( typeof dataTypeOrTransport === "string" &&
  15334. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15335. options.dataTypes.unshift( dataTypeOrTransport );
  15336. inspect( dataTypeOrTransport );
  15337. return false;
  15338. } else if ( seekingTransport ) {
  15339. return !( selected = dataTypeOrTransport );
  15340. }
  15341. } );
  15342. return selected;
  15343. }
  15344. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15345. }
  15346. // A special extend for ajax options
  15347. // that takes "flat" options (not to be deep extended)
  15348. // Fixes #9887
  15349. function ajaxExtend( target, src ) {
  15350. var key, deep,
  15351. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15352. for ( key in src ) {
  15353. if ( src[ key ] !== undefined ) {
  15354. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15355. }
  15356. }
  15357. if ( deep ) {
  15358. jQuery.extend( true, target, deep );
  15359. }
  15360. return target;
  15361. }
  15362. /* Handles responses to an ajax request:
  15363. * - finds the right dataType (mediates between content-type and expected dataType)
  15364. * - returns the corresponding response
  15365. */
  15366. function ajaxHandleResponses( s, jqXHR, responses ) {
  15367. var ct, type, finalDataType, firstDataType,
  15368. contents = s.contents,
  15369. dataTypes = s.dataTypes;
  15370. // Remove auto dataType and get content-type in the process
  15371. while ( dataTypes[ 0 ] === "*" ) {
  15372. dataTypes.shift();
  15373. if ( ct === undefined ) {
  15374. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15375. }
  15376. }
  15377. // Check if we're dealing with a known content-type
  15378. if ( ct ) {
  15379. for ( type in contents ) {
  15380. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15381. dataTypes.unshift( type );
  15382. break;
  15383. }
  15384. }
  15385. }
  15386. // Check to see if we have a response for the expected dataType
  15387. if ( dataTypes[ 0 ] in responses ) {
  15388. finalDataType = dataTypes[ 0 ];
  15389. } else {
  15390. // Try convertible dataTypes
  15391. for ( type in responses ) {
  15392. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15393. finalDataType = type;
  15394. break;
  15395. }
  15396. if ( !firstDataType ) {
  15397. firstDataType = type;
  15398. }
  15399. }
  15400. // Or just use first one
  15401. finalDataType = finalDataType || firstDataType;
  15402. }
  15403. // If we found a dataType
  15404. // We add the dataType to the list if needed
  15405. // and return the corresponding response
  15406. if ( finalDataType ) {
  15407. if ( finalDataType !== dataTypes[ 0 ] ) {
  15408. dataTypes.unshift( finalDataType );
  15409. }
  15410. return responses[ finalDataType ];
  15411. }
  15412. }
  15413. /* Chain conversions given the request and the original response
  15414. * Also sets the responseXXX fields on the jqXHR instance
  15415. */
  15416. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15417. var conv2, current, conv, tmp, prev,
  15418. converters = {},
  15419. // Work with a copy of dataTypes in case we need to modify it for conversion
  15420. dataTypes = s.dataTypes.slice();
  15421. // Create converters map with lowercased keys
  15422. if ( dataTypes[ 1 ] ) {
  15423. for ( conv in s.converters ) {
  15424. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15425. }
  15426. }
  15427. current = dataTypes.shift();
  15428. // Convert to each sequential dataType
  15429. while ( current ) {
  15430. if ( s.responseFields[ current ] ) {
  15431. jqXHR[ s.responseFields[ current ] ] = response;
  15432. }
  15433. // Apply the dataFilter if provided
  15434. if ( !prev && isSuccess && s.dataFilter ) {
  15435. response = s.dataFilter( response, s.dataType );
  15436. }
  15437. prev = current;
  15438. current = dataTypes.shift();
  15439. if ( current ) {
  15440. // There's only work to do if current dataType is non-auto
  15441. if ( current === "*" ) {
  15442. current = prev;
  15443. // Convert response if prev dataType is non-auto and differs from current
  15444. } else if ( prev !== "*" && prev !== current ) {
  15445. // Seek a direct converter
  15446. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15447. // If none found, seek a pair
  15448. if ( !conv ) {
  15449. for ( conv2 in converters ) {
  15450. // If conv2 outputs current
  15451. tmp = conv2.split( " " );
  15452. if ( tmp[ 1 ] === current ) {
  15453. // If prev can be converted to accepted input
  15454. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15455. converters[ "* " + tmp[ 0 ] ];
  15456. if ( conv ) {
  15457. // Condense equivalence converters
  15458. if ( conv === true ) {
  15459. conv = converters[ conv2 ];
  15460. // Otherwise, insert the intermediate dataType
  15461. } else if ( converters[ conv2 ] !== true ) {
  15462. current = tmp[ 0 ];
  15463. dataTypes.unshift( tmp[ 1 ] );
  15464. }
  15465. break;
  15466. }
  15467. }
  15468. }
  15469. }
  15470. // Apply converter (if not an equivalence)
  15471. if ( conv !== true ) {
  15472. // Unless errors are allowed to bubble, catch and return them
  15473. if ( conv && s.throws ) {
  15474. response = conv( response );
  15475. } else {
  15476. try {
  15477. response = conv( response );
  15478. } catch ( e ) {
  15479. return {
  15480. state: "parsererror",
  15481. error: conv ? e : "No conversion from " + prev + " to " + current
  15482. };
  15483. }
  15484. }
  15485. }
  15486. }
  15487. }
  15488. }
  15489. return { state: "success", data: response };
  15490. }
  15491. jQuery.extend( {
  15492. // Counter for holding the number of active queries
  15493. active: 0,
  15494. // Last-Modified header cache for next request
  15495. lastModified: {},
  15496. etag: {},
  15497. ajaxSettings: {
  15498. url: location.href,
  15499. type: "GET",
  15500. isLocal: rlocalProtocol.test( location.protocol ),
  15501. global: true,
  15502. processData: true,
  15503. async: true,
  15504. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15505. /*
  15506. timeout: 0,
  15507. data: null,
  15508. dataType: null,
  15509. username: null,
  15510. password: null,
  15511. cache: null,
  15512. throws: false,
  15513. traditional: false,
  15514. headers: {},
  15515. */
  15516. accepts: {
  15517. "*": allTypes,
  15518. text: "text/plain",
  15519. html: "text/html",
  15520. xml: "application/xml, text/xml",
  15521. json: "application/json, text/javascript"
  15522. },
  15523. contents: {
  15524. xml: /\bxml\b/,
  15525. html: /\bhtml/,
  15526. json: /\bjson\b/
  15527. },
  15528. responseFields: {
  15529. xml: "responseXML",
  15530. text: "responseText",
  15531. json: "responseJSON"
  15532. },
  15533. // Data converters
  15534. // Keys separate source (or catchall "*") and destination types with a single space
  15535. converters: {
  15536. // Convert anything to text
  15537. "* text": String,
  15538. // Text to html (true = no transformation)
  15539. "text html": true,
  15540. // Evaluate text as a json expression
  15541. "text json": JSON.parse,
  15542. // Parse text as xml
  15543. "text xml": jQuery.parseXML
  15544. },
  15545. // For options that shouldn't be deep extended:
  15546. // you can add your own custom options here if
  15547. // and when you create one that shouldn't be
  15548. // deep extended (see ajaxExtend)
  15549. flatOptions: {
  15550. url: true,
  15551. context: true
  15552. }
  15553. },
  15554. // Creates a full fledged settings object into target
  15555. // with both ajaxSettings and settings fields.
  15556. // If target is omitted, writes into ajaxSettings.
  15557. ajaxSetup: function( target, settings ) {
  15558. return settings ?
  15559. // Building a settings object
  15560. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15561. // Extending ajaxSettings
  15562. ajaxExtend( jQuery.ajaxSettings, target );
  15563. },
  15564. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15565. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15566. // Main method
  15567. ajax: function( url, options ) {
  15568. // If url is an object, simulate pre-1.5 signature
  15569. if ( typeof url === "object" ) {
  15570. options = url;
  15571. url = undefined;
  15572. }
  15573. // Force options to be an object
  15574. options = options || {};
  15575. var transport,
  15576. // URL without anti-cache param
  15577. cacheURL,
  15578. // Response headers
  15579. responseHeadersString,
  15580. responseHeaders,
  15581. // timeout handle
  15582. timeoutTimer,
  15583. // Url cleanup var
  15584. urlAnchor,
  15585. // Request state (becomes false upon send and true upon completion)
  15586. completed,
  15587. // To know if global events are to be dispatched
  15588. fireGlobals,
  15589. // Loop variable
  15590. i,
  15591. // uncached part of the url
  15592. uncached,
  15593. // Create the final options object
  15594. s = jQuery.ajaxSetup( {}, options ),
  15595. // Callbacks context
  15596. callbackContext = s.context || s,
  15597. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15598. globalEventContext = s.context &&
  15599. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15600. jQuery( callbackContext ) :
  15601. jQuery.event,
  15602. // Deferreds
  15603. deferred = jQuery.Deferred(),
  15604. completeDeferred = jQuery.Callbacks( "once memory" ),
  15605. // Status-dependent callbacks
  15606. statusCode = s.statusCode || {},
  15607. // Headers (they are sent all at once)
  15608. requestHeaders = {},
  15609. requestHeadersNames = {},
  15610. // Default abort message
  15611. strAbort = "canceled",
  15612. // Fake xhr
  15613. jqXHR = {
  15614. readyState: 0,
  15615. // Builds headers hashtable if needed
  15616. getResponseHeader: function( key ) {
  15617. var match;
  15618. if ( completed ) {
  15619. if ( !responseHeaders ) {
  15620. responseHeaders = {};
  15621. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15622. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15623. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15624. .concat( match[ 2 ] );
  15625. }
  15626. }
  15627. match = responseHeaders[ key.toLowerCase() + " " ];
  15628. }
  15629. return match == null ? null : match.join( ", " );
  15630. },
  15631. // Raw string
  15632. getAllResponseHeaders: function() {
  15633. return completed ? responseHeadersString : null;
  15634. },
  15635. // Caches the header
  15636. setRequestHeader: function( name, value ) {
  15637. if ( completed == null ) {
  15638. name = requestHeadersNames[ name.toLowerCase() ] =
  15639. requestHeadersNames[ name.toLowerCase() ] || name;
  15640. requestHeaders[ name ] = value;
  15641. }
  15642. return this;
  15643. },
  15644. // Overrides response content-type header
  15645. overrideMimeType: function( type ) {
  15646. if ( completed == null ) {
  15647. s.mimeType = type;
  15648. }
  15649. return this;
  15650. },
  15651. // Status-dependent callbacks
  15652. statusCode: function( map ) {
  15653. var code;
  15654. if ( map ) {
  15655. if ( completed ) {
  15656. // Execute the appropriate callbacks
  15657. jqXHR.always( map[ jqXHR.status ] );
  15658. } else {
  15659. // Lazy-add the new callbacks in a way that preserves old ones
  15660. for ( code in map ) {
  15661. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15662. }
  15663. }
  15664. }
  15665. return this;
  15666. },
  15667. // Cancel the request
  15668. abort: function( statusText ) {
  15669. var finalText = statusText || strAbort;
  15670. if ( transport ) {
  15671. transport.abort( finalText );
  15672. }
  15673. done( 0, finalText );
  15674. return this;
  15675. }
  15676. };
  15677. // Attach deferreds
  15678. deferred.promise( jqXHR );
  15679. // Add protocol if not provided (prefilters might expect it)
  15680. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15681. // We also use the url parameter if available
  15682. s.url = ( ( url || s.url || location.href ) + "" )
  15683. .replace( rprotocol, location.protocol + "//" );
  15684. // Alias method option to type as per ticket #12004
  15685. s.type = options.method || options.type || s.method || s.type;
  15686. // Extract dataTypes list
  15687. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15688. // A cross-domain request is in order when the origin doesn't match the current origin.
  15689. if ( s.crossDomain == null ) {
  15690. urlAnchor = document.createElement( "a" );
  15691. // Support: IE <=8 - 11, Edge 12 - 15
  15692. // IE throws exception on accessing the href property if url is malformed,
  15693. // e.g. http://example.com:80x/
  15694. try {
  15695. urlAnchor.href = s.url;
  15696. // Support: IE <=8 - 11 only
  15697. // Anchor's host property isn't correctly set when s.url is relative
  15698. urlAnchor.href = urlAnchor.href;
  15699. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15700. urlAnchor.protocol + "//" + urlAnchor.host;
  15701. } catch ( e ) {
  15702. // If there is an error parsing the URL, assume it is crossDomain,
  15703. // it can be rejected by the transport if it is invalid
  15704. s.crossDomain = true;
  15705. }
  15706. }
  15707. // Convert data if not already a string
  15708. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15709. s.data = jQuery.param( s.data, s.traditional );
  15710. }
  15711. // Apply prefilters
  15712. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15713. // If request was aborted inside a prefilter, stop there
  15714. if ( completed ) {
  15715. return jqXHR;
  15716. }
  15717. // We can fire global events as of now if asked to
  15718. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15719. fireGlobals = jQuery.event && s.global;
  15720. // Watch for a new set of requests
  15721. if ( fireGlobals && jQuery.active++ === 0 ) {
  15722. jQuery.event.trigger( "ajaxStart" );
  15723. }
  15724. // Uppercase the type
  15725. s.type = s.type.toUpperCase();
  15726. // Determine if request has content
  15727. s.hasContent = !rnoContent.test( s.type );
  15728. // Save the URL in case we're toying with the If-Modified-Since
  15729. // and/or If-None-Match header later on
  15730. // Remove hash to simplify url manipulation
  15731. cacheURL = s.url.replace( rhash, "" );
  15732. // More options handling for requests with no content
  15733. if ( !s.hasContent ) {
  15734. // Remember the hash so we can put it back
  15735. uncached = s.url.slice( cacheURL.length );
  15736. // If data is available and should be processed, append data to url
  15737. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15738. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15739. // #9682: remove data so that it's not used in an eventual retry
  15740. delete s.data;
  15741. }
  15742. // Add or update anti-cache param if needed
  15743. if ( s.cache === false ) {
  15744. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15745. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15746. }
  15747. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15748. s.url = cacheURL + uncached;
  15749. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15750. } else if ( s.data && s.processData &&
  15751. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15752. s.data = s.data.replace( r20, "+" );
  15753. }
  15754. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15755. if ( s.ifModified ) {
  15756. if ( jQuery.lastModified[ cacheURL ] ) {
  15757. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15758. }
  15759. if ( jQuery.etag[ cacheURL ] ) {
  15760. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15761. }
  15762. }
  15763. // Set the correct header, if data is being sent
  15764. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15765. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15766. }
  15767. // Set the Accepts header for the server, depending on the dataType
  15768. jqXHR.setRequestHeader(
  15769. "Accept",
  15770. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15771. s.accepts[ s.dataTypes[ 0 ] ] +
  15772. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15773. s.accepts[ "*" ]
  15774. );
  15775. // Check for headers option
  15776. for ( i in s.headers ) {
  15777. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15778. }
  15779. // Allow custom headers/mimetypes and early abort
  15780. if ( s.beforeSend &&
  15781. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15782. // Abort if not done already and return
  15783. return jqXHR.abort();
  15784. }
  15785. // Aborting is no longer a cancellation
  15786. strAbort = "abort";
  15787. // Install callbacks on deferreds
  15788. completeDeferred.add( s.complete );
  15789. jqXHR.done( s.success );
  15790. jqXHR.fail( s.error );
  15791. // Get transport
  15792. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15793. // If no transport, we auto-abort
  15794. if ( !transport ) {
  15795. done( -1, "No Transport" );
  15796. } else {
  15797. jqXHR.readyState = 1;
  15798. // Send global event
  15799. if ( fireGlobals ) {
  15800. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15801. }
  15802. // If request was aborted inside ajaxSend, stop there
  15803. if ( completed ) {
  15804. return jqXHR;
  15805. }
  15806. // Timeout
  15807. if ( s.async && s.timeout > 0 ) {
  15808. timeoutTimer = window.setTimeout( function() {
  15809. jqXHR.abort( "timeout" );
  15810. }, s.timeout );
  15811. }
  15812. try {
  15813. completed = false;
  15814. transport.send( requestHeaders, done );
  15815. } catch ( e ) {
  15816. // Rethrow post-completion exceptions
  15817. if ( completed ) {
  15818. throw e;
  15819. }
  15820. // Propagate others as results
  15821. done( -1, e );
  15822. }
  15823. }
  15824. // Callback for when everything is done
  15825. function done( status, nativeStatusText, responses, headers ) {
  15826. var isSuccess, success, error, response, modified,
  15827. statusText = nativeStatusText;
  15828. // Ignore repeat invocations
  15829. if ( completed ) {
  15830. return;
  15831. }
  15832. completed = true;
  15833. // Clear timeout if it exists
  15834. if ( timeoutTimer ) {
  15835. window.clearTimeout( timeoutTimer );
  15836. }
  15837. // Dereference transport for early garbage collection
  15838. // (no matter how long the jqXHR object will be used)
  15839. transport = undefined;
  15840. // Cache response headers
  15841. responseHeadersString = headers || "";
  15842. // Set readyState
  15843. jqXHR.readyState = status > 0 ? 4 : 0;
  15844. // Determine if successful
  15845. isSuccess = status >= 200 && status < 300 || status === 304;
  15846. // Get response data
  15847. if ( responses ) {
  15848. response = ajaxHandleResponses( s, jqXHR, responses );
  15849. }
  15850. // Convert no matter what (that way responseXXX fields are always set)
  15851. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15852. // If successful, handle type chaining
  15853. if ( isSuccess ) {
  15854. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15855. if ( s.ifModified ) {
  15856. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15857. if ( modified ) {
  15858. jQuery.lastModified[ cacheURL ] = modified;
  15859. }
  15860. modified = jqXHR.getResponseHeader( "etag" );
  15861. if ( modified ) {
  15862. jQuery.etag[ cacheURL ] = modified;
  15863. }
  15864. }
  15865. // if no content
  15866. if ( status === 204 || s.type === "HEAD" ) {
  15867. statusText = "nocontent";
  15868. // if not modified
  15869. } else if ( status === 304 ) {
  15870. statusText = "notmodified";
  15871. // If we have data, let's convert it
  15872. } else {
  15873. statusText = response.state;
  15874. success = response.data;
  15875. error = response.error;
  15876. isSuccess = !error;
  15877. }
  15878. } else {
  15879. // Extract error from statusText and normalize for non-aborts
  15880. error = statusText;
  15881. if ( status || !statusText ) {
  15882. statusText = "error";
  15883. if ( status < 0 ) {
  15884. status = 0;
  15885. }
  15886. }
  15887. }
  15888. // Set data for the fake xhr object
  15889. jqXHR.status = status;
  15890. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15891. // Success/Error
  15892. if ( isSuccess ) {
  15893. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15894. } else {
  15895. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15896. }
  15897. // Status-dependent callbacks
  15898. jqXHR.statusCode( statusCode );
  15899. statusCode = undefined;
  15900. if ( fireGlobals ) {
  15901. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15902. [ jqXHR, s, isSuccess ? success : error ] );
  15903. }
  15904. // Complete
  15905. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15906. if ( fireGlobals ) {
  15907. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15908. // Handle the global AJAX counter
  15909. if ( !( --jQuery.active ) ) {
  15910. jQuery.event.trigger( "ajaxStop" );
  15911. }
  15912. }
  15913. }
  15914. return jqXHR;
  15915. },
  15916. getJSON: function( url, data, callback ) {
  15917. return jQuery.get( url, data, callback, "json" );
  15918. },
  15919. getScript: function( url, callback ) {
  15920. return jQuery.get( url, undefined, callback, "script" );
  15921. }
  15922. } );
  15923. jQuery.each( [ "get", "post" ], function( i, method ) {
  15924. jQuery[ method ] = function( url, data, callback, type ) {
  15925. // Shift arguments if data argument was omitted
  15926. if ( isFunction( data ) ) {
  15927. type = type || callback;
  15928. callback = data;
  15929. data = undefined;
  15930. }
  15931. // The url can be an options object (which then must have .url)
  15932. return jQuery.ajax( jQuery.extend( {
  15933. url: url,
  15934. type: method,
  15935. dataType: type,
  15936. data: data,
  15937. success: callback
  15938. }, jQuery.isPlainObject( url ) && url ) );
  15939. };
  15940. } );
  15941. jQuery._evalUrl = function( url, options ) {
  15942. return jQuery.ajax( {
  15943. url: url,
  15944. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15945. type: "GET",
  15946. dataType: "script",
  15947. cache: true,
  15948. async: false,
  15949. global: false,
  15950. // Only evaluate the response if it is successful (gh-4126)
  15951. // dataFilter is not invoked for failure responses, so using it instead
  15952. // of the default converter is kludgy but it works.
  15953. converters: {
  15954. "text script": function() {}
  15955. },
  15956. dataFilter: function( response ) {
  15957. jQuery.globalEval( response, options );
  15958. }
  15959. } );
  15960. };
  15961. jQuery.fn.extend( {
  15962. wrapAll: function( html ) {
  15963. var wrap;
  15964. if ( this[ 0 ] ) {
  15965. if ( isFunction( html ) ) {
  15966. html = html.call( this[ 0 ] );
  15967. }
  15968. // The elements to wrap the target around
  15969. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15970. if ( this[ 0 ].parentNode ) {
  15971. wrap.insertBefore( this[ 0 ] );
  15972. }
  15973. wrap.map( function() {
  15974. var elem = this;
  15975. while ( elem.firstElementChild ) {
  15976. elem = elem.firstElementChild;
  15977. }
  15978. return elem;
  15979. } ).append( this );
  15980. }
  15981. return this;
  15982. },
  15983. wrapInner: function( html ) {
  15984. if ( isFunction( html ) ) {
  15985. return this.each( function( i ) {
  15986. jQuery( this ).wrapInner( html.call( this, i ) );
  15987. } );
  15988. }
  15989. return this.each( function() {
  15990. var self = jQuery( this ),
  15991. contents = self.contents();
  15992. if ( contents.length ) {
  15993. contents.wrapAll( html );
  15994. } else {
  15995. self.append( html );
  15996. }
  15997. } );
  15998. },
  15999. wrap: function( html ) {
  16000. var htmlIsFunction = isFunction( html );
  16001. return this.each( function( i ) {
  16002. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  16003. } );
  16004. },
  16005. unwrap: function( selector ) {
  16006. this.parent( selector ).not( "body" ).each( function() {
  16007. jQuery( this ).replaceWith( this.childNodes );
  16008. } );
  16009. return this;
  16010. }
  16011. } );
  16012. jQuery.expr.pseudos.hidden = function( elem ) {
  16013. return !jQuery.expr.pseudos.visible( elem );
  16014. };
  16015. jQuery.expr.pseudos.visible = function( elem ) {
  16016. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  16017. };
  16018. jQuery.ajaxSettings.xhr = function() {
  16019. try {
  16020. return new window.XMLHttpRequest();
  16021. } catch ( e ) {}
  16022. };
  16023. var xhrSuccessStatus = {
  16024. // File protocol always yields status code 0, assume 200
  16025. 0: 200,
  16026. // Support: IE <=9 only
  16027. // #1450: sometimes IE returns 1223 when it should be 204
  16028. 1223: 204
  16029. },
  16030. xhrSupported = jQuery.ajaxSettings.xhr();
  16031. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  16032. support.ajax = xhrSupported = !!xhrSupported;
  16033. jQuery.ajaxTransport( function( options ) {
  16034. var callback, errorCallback;
  16035. // Cross domain only allowed if supported through XMLHttpRequest
  16036. if ( support.cors || xhrSupported && !options.crossDomain ) {
  16037. return {
  16038. send: function( headers, complete ) {
  16039. var i,
  16040. xhr = options.xhr();
  16041. xhr.open(
  16042. options.type,
  16043. options.url,
  16044. options.async,
  16045. options.username,
  16046. options.password
  16047. );
  16048. // Apply custom fields if provided
  16049. if ( options.xhrFields ) {
  16050. for ( i in options.xhrFields ) {
  16051. xhr[ i ] = options.xhrFields[ i ];
  16052. }
  16053. }
  16054. // Override mime type if needed
  16055. if ( options.mimeType && xhr.overrideMimeType ) {
  16056. xhr.overrideMimeType( options.mimeType );
  16057. }
  16058. // X-Requested-With header
  16059. // For cross-domain requests, seeing as conditions for a preflight are
  16060. // akin to a jigsaw puzzle, we simply never set it to be sure.
  16061. // (it can always be set on a per-request basis or even using ajaxSetup)
  16062. // For same-domain requests, won't change header if already provided.
  16063. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  16064. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  16065. }
  16066. // Set headers
  16067. for ( i in headers ) {
  16068. xhr.setRequestHeader( i, headers[ i ] );
  16069. }
  16070. // Callback
  16071. callback = function( type ) {
  16072. return function() {
  16073. if ( callback ) {
  16074. callback = errorCallback = xhr.onload =
  16075. xhr.onerror = xhr.onabort = xhr.ontimeout =
  16076. xhr.onreadystatechange = null;
  16077. if ( type === "abort" ) {
  16078. xhr.abort();
  16079. } else if ( type === "error" ) {
  16080. // Support: IE <=9 only
  16081. // On a manual native abort, IE9 throws
  16082. // errors on any property access that is not readyState
  16083. if ( typeof xhr.status !== "number" ) {
  16084. complete( 0, "error" );
  16085. } else {
  16086. complete(
  16087. // File: protocol always yields status 0; see #8605, #14207
  16088. xhr.status,
  16089. xhr.statusText
  16090. );
  16091. }
  16092. } else {
  16093. complete(
  16094. xhrSuccessStatus[ xhr.status ] || xhr.status,
  16095. xhr.statusText,
  16096. // Support: IE <=9 only
  16097. // IE9 has no XHR2 but throws on binary (trac-11426)
  16098. // For XHR2 non-text, let the caller handle it (gh-2498)
  16099. ( xhr.responseType || "text" ) !== "text" ||
  16100. typeof xhr.responseText !== "string" ?
  16101. { binary: xhr.response } :
  16102. { text: xhr.responseText },
  16103. xhr.getAllResponseHeaders()
  16104. );
  16105. }
  16106. }
  16107. };
  16108. };
  16109. // Listen to events
  16110. xhr.onload = callback();
  16111. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16112. // Support: IE 9 only
  16113. // Use onreadystatechange to replace onabort
  16114. // to handle uncaught aborts
  16115. if ( xhr.onabort !== undefined ) {
  16116. xhr.onabort = errorCallback;
  16117. } else {
  16118. xhr.onreadystatechange = function() {
  16119. // Check readyState before timeout as it changes
  16120. if ( xhr.readyState === 4 ) {
  16121. // Allow onerror to be called first,
  16122. // but that will not handle a native abort
  16123. // Also, save errorCallback to a variable
  16124. // as xhr.onerror cannot be accessed
  16125. window.setTimeout( function() {
  16126. if ( callback ) {
  16127. errorCallback();
  16128. }
  16129. } );
  16130. }
  16131. };
  16132. }
  16133. // Create the abort callback
  16134. callback = callback( "abort" );
  16135. try {
  16136. // Do send the request (this may raise an exception)
  16137. xhr.send( options.hasContent && options.data || null );
  16138. } catch ( e ) {
  16139. // #14683: Only rethrow if this hasn't been notified as an error yet
  16140. if ( callback ) {
  16141. throw e;
  16142. }
  16143. }
  16144. },
  16145. abort: function() {
  16146. if ( callback ) {
  16147. callback();
  16148. }
  16149. }
  16150. };
  16151. }
  16152. } );
  16153. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16154. jQuery.ajaxPrefilter( function( s ) {
  16155. if ( s.crossDomain ) {
  16156. s.contents.script = false;
  16157. }
  16158. } );
  16159. // Install script dataType
  16160. jQuery.ajaxSetup( {
  16161. accepts: {
  16162. script: "text/javascript, application/javascript, " +
  16163. "application/ecmascript, application/x-ecmascript"
  16164. },
  16165. contents: {
  16166. script: /\b(?:java|ecma)script\b/
  16167. },
  16168. converters: {
  16169. "text script": function( text ) {
  16170. jQuery.globalEval( text );
  16171. return text;
  16172. }
  16173. }
  16174. } );
  16175. // Handle cache's special case and crossDomain
  16176. jQuery.ajaxPrefilter( "script", function( s ) {
  16177. if ( s.cache === undefined ) {
  16178. s.cache = false;
  16179. }
  16180. if ( s.crossDomain ) {
  16181. s.type = "GET";
  16182. }
  16183. } );
  16184. // Bind script tag hack transport
  16185. jQuery.ajaxTransport( "script", function( s ) {
  16186. // This transport only deals with cross domain or forced-by-attrs requests
  16187. if ( s.crossDomain || s.scriptAttrs ) {
  16188. var script, callback;
  16189. return {
  16190. send: function( _, complete ) {
  16191. script = jQuery( "<script>" )
  16192. .attr( s.scriptAttrs || {} )
  16193. .prop( { charset: s.scriptCharset, src: s.url } )
  16194. .on( "load error", callback = function( evt ) {
  16195. script.remove();
  16196. callback = null;
  16197. if ( evt ) {
  16198. complete( evt.type === "error" ? 404 : 200, evt.type );
  16199. }
  16200. } );
  16201. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16202. document.head.appendChild( script[ 0 ] );
  16203. },
  16204. abort: function() {
  16205. if ( callback ) {
  16206. callback();
  16207. }
  16208. }
  16209. };
  16210. }
  16211. } );
  16212. var oldCallbacks = [],
  16213. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16214. // Default jsonp settings
  16215. jQuery.ajaxSetup( {
  16216. jsonp: "callback",
  16217. jsonpCallback: function() {
  16218. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16219. this[ callback ] = true;
  16220. return callback;
  16221. }
  16222. } );
  16223. // Detect, normalize options and install callbacks for jsonp requests
  16224. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16225. var callbackName, overwritten, responseContainer,
  16226. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16227. "url" :
  16228. typeof s.data === "string" &&
  16229. ( s.contentType || "" )
  16230. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16231. rjsonp.test( s.data ) && "data"
  16232. );
  16233. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16234. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16235. // Get callback name, remembering preexisting value associated with it
  16236. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16237. s.jsonpCallback() :
  16238. s.jsonpCallback;
  16239. // Insert callback into url or form data
  16240. if ( jsonProp ) {
  16241. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16242. } else if ( s.jsonp !== false ) {
  16243. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16244. }
  16245. // Use data converter to retrieve json after script execution
  16246. s.converters[ "script json" ] = function() {
  16247. if ( !responseContainer ) {
  16248. jQuery.error( callbackName + " was not called" );
  16249. }
  16250. return responseContainer[ 0 ];
  16251. };
  16252. // Force json dataType
  16253. s.dataTypes[ 0 ] = "json";
  16254. // Install callback
  16255. overwritten = window[ callbackName ];
  16256. window[ callbackName ] = function() {
  16257. responseContainer = arguments;
  16258. };
  16259. // Clean-up function (fires after converters)
  16260. jqXHR.always( function() {
  16261. // If previous value didn't exist - remove it
  16262. if ( overwritten === undefined ) {
  16263. jQuery( window ).removeProp( callbackName );
  16264. // Otherwise restore preexisting value
  16265. } else {
  16266. window[ callbackName ] = overwritten;
  16267. }
  16268. // Save back as free
  16269. if ( s[ callbackName ] ) {
  16270. // Make sure that re-using the options doesn't screw things around
  16271. s.jsonpCallback = originalSettings.jsonpCallback;
  16272. // Save the callback name for future use
  16273. oldCallbacks.push( callbackName );
  16274. }
  16275. // Call if it was a function and we have a response
  16276. if ( responseContainer && isFunction( overwritten ) ) {
  16277. overwritten( responseContainer[ 0 ] );
  16278. }
  16279. responseContainer = overwritten = undefined;
  16280. } );
  16281. // Delegate to script
  16282. return "script";
  16283. }
  16284. } );
  16285. // Support: Safari 8 only
  16286. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16287. // collapse sibling forms: the second one becomes a child of the first one.
  16288. // Because of that, this security measure has to be disabled in Safari 8.
  16289. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16290. support.createHTMLDocument = ( function() {
  16291. var body = document.implementation.createHTMLDocument( "" ).body;
  16292. body.innerHTML = "<form></form><form></form>";
  16293. return body.childNodes.length === 2;
  16294. } )();
  16295. // Argument "data" should be string of html
  16296. // context (optional): If specified, the fragment will be created in this context,
  16297. // defaults to document
  16298. // keepScripts (optional): If true, will include scripts passed in the html string
  16299. jQuery.parseHTML = function( data, context, keepScripts ) {
  16300. if ( typeof data !== "string" ) {
  16301. return [];
  16302. }
  16303. if ( typeof context === "boolean" ) {
  16304. keepScripts = context;
  16305. context = false;
  16306. }
  16307. var base, parsed, scripts;
  16308. if ( !context ) {
  16309. // Stop scripts or inline event handlers from being executed immediately
  16310. // by using document.implementation
  16311. if ( support.createHTMLDocument ) {
  16312. context = document.implementation.createHTMLDocument( "" );
  16313. // Set the base href for the created document
  16314. // so any parsed elements with URLs
  16315. // are based on the document's URL (gh-2965)
  16316. base = context.createElement( "base" );
  16317. base.href = document.location.href;
  16318. context.head.appendChild( base );
  16319. } else {
  16320. context = document;
  16321. }
  16322. }
  16323. parsed = rsingleTag.exec( data );
  16324. scripts = !keepScripts && [];
  16325. // Single tag
  16326. if ( parsed ) {
  16327. return [ context.createElement( parsed[ 1 ] ) ];
  16328. }
  16329. parsed = buildFragment( [ data ], context, scripts );
  16330. if ( scripts && scripts.length ) {
  16331. jQuery( scripts ).remove();
  16332. }
  16333. return jQuery.merge( [], parsed.childNodes );
  16334. };
  16335. /**
  16336. * Load a url into a page
  16337. */
  16338. jQuery.fn.load = function( url, params, callback ) {
  16339. var selector, type, response,
  16340. self = this,
  16341. off = url.indexOf( " " );
  16342. if ( off > -1 ) {
  16343. selector = stripAndCollapse( url.slice( off ) );
  16344. url = url.slice( 0, off );
  16345. }
  16346. // If it's a function
  16347. if ( isFunction( params ) ) {
  16348. // We assume that it's the callback
  16349. callback = params;
  16350. params = undefined;
  16351. // Otherwise, build a param string
  16352. } else if ( params && typeof params === "object" ) {
  16353. type = "POST";
  16354. }
  16355. // If we have elements to modify, make the request
  16356. if ( self.length > 0 ) {
  16357. jQuery.ajax( {
  16358. url: url,
  16359. // If "type" variable is undefined, then "GET" method will be used.
  16360. // Make value of this field explicit since
  16361. // user can override it through ajaxSetup method
  16362. type: type || "GET",
  16363. dataType: "html",
  16364. data: params
  16365. } ).done( function( responseText ) {
  16366. // Save response for use in complete callback
  16367. response = arguments;
  16368. self.html( selector ?
  16369. // If a selector was specified, locate the right elements in a dummy div
  16370. // Exclude scripts to avoid IE 'Permission Denied' errors
  16371. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16372. // Otherwise use the full result
  16373. responseText );
  16374. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16375. // but they are ignored because response was set above.
  16376. // If it fails, this function gets "jqXHR", "status", "error"
  16377. } ).always( callback && function( jqXHR, status ) {
  16378. self.each( function() {
  16379. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16380. } );
  16381. } );
  16382. }
  16383. return this;
  16384. };
  16385. // Attach a bunch of functions for handling common AJAX events
  16386. jQuery.each( [
  16387. "ajaxStart",
  16388. "ajaxStop",
  16389. "ajaxComplete",
  16390. "ajaxError",
  16391. "ajaxSuccess",
  16392. "ajaxSend"
  16393. ], function( i, type ) {
  16394. jQuery.fn[ type ] = function( fn ) {
  16395. return this.on( type, fn );
  16396. };
  16397. } );
  16398. jQuery.expr.pseudos.animated = function( elem ) {
  16399. return jQuery.grep( jQuery.timers, function( fn ) {
  16400. return elem === fn.elem;
  16401. } ).length;
  16402. };
  16403. jQuery.offset = {
  16404. setOffset: function( elem, options, i ) {
  16405. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16406. position = jQuery.css( elem, "position" ),
  16407. curElem = jQuery( elem ),
  16408. props = {};
  16409. // Set position first, in-case top/left are set even on static elem
  16410. if ( position === "static" ) {
  16411. elem.style.position = "relative";
  16412. }
  16413. curOffset = curElem.offset();
  16414. curCSSTop = jQuery.css( elem, "top" );
  16415. curCSSLeft = jQuery.css( elem, "left" );
  16416. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16417. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16418. // Need to be able to calculate position if either
  16419. // top or left is auto and position is either absolute or fixed
  16420. if ( calculatePosition ) {
  16421. curPosition = curElem.position();
  16422. curTop = curPosition.top;
  16423. curLeft = curPosition.left;
  16424. } else {
  16425. curTop = parseFloat( curCSSTop ) || 0;
  16426. curLeft = parseFloat( curCSSLeft ) || 0;
  16427. }
  16428. if ( isFunction( options ) ) {
  16429. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16430. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16431. }
  16432. if ( options.top != null ) {
  16433. props.top = ( options.top - curOffset.top ) + curTop;
  16434. }
  16435. if ( options.left != null ) {
  16436. props.left = ( options.left - curOffset.left ) + curLeft;
  16437. }
  16438. if ( "using" in options ) {
  16439. options.using.call( elem, props );
  16440. } else {
  16441. curElem.css( props );
  16442. }
  16443. }
  16444. };
  16445. jQuery.fn.extend( {
  16446. // offset() relates an element's border box to the document origin
  16447. offset: function( options ) {
  16448. // Preserve chaining for setter
  16449. if ( arguments.length ) {
  16450. return options === undefined ?
  16451. this :
  16452. this.each( function( i ) {
  16453. jQuery.offset.setOffset( this, options, i );
  16454. } );
  16455. }
  16456. var rect, win,
  16457. elem = this[ 0 ];
  16458. if ( !elem ) {
  16459. return;
  16460. }
  16461. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16462. // Support: IE <=11 only
  16463. // Running getBoundingClientRect on a
  16464. // disconnected node in IE throws an error
  16465. if ( !elem.getClientRects().length ) {
  16466. return { top: 0, left: 0 };
  16467. }
  16468. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16469. rect = elem.getBoundingClientRect();
  16470. win = elem.ownerDocument.defaultView;
  16471. return {
  16472. top: rect.top + win.pageYOffset,
  16473. left: rect.left + win.pageXOffset
  16474. };
  16475. },
  16476. // position() relates an element's margin box to its offset parent's padding box
  16477. // This corresponds to the behavior of CSS absolute positioning
  16478. position: function() {
  16479. if ( !this[ 0 ] ) {
  16480. return;
  16481. }
  16482. var offsetParent, offset, doc,
  16483. elem = this[ 0 ],
  16484. parentOffset = { top: 0, left: 0 };
  16485. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16486. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16487. // Assume position:fixed implies availability of getBoundingClientRect
  16488. offset = elem.getBoundingClientRect();
  16489. } else {
  16490. offset = this.offset();
  16491. // Account for the *real* offset parent, which can be the document or its root element
  16492. // when a statically positioned element is identified
  16493. doc = elem.ownerDocument;
  16494. offsetParent = elem.offsetParent || doc.documentElement;
  16495. while ( offsetParent &&
  16496. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16497. jQuery.css( offsetParent, "position" ) === "static" ) {
  16498. offsetParent = offsetParent.parentNode;
  16499. }
  16500. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16501. // Incorporate borders into its offset, since they are outside its content origin
  16502. parentOffset = jQuery( offsetParent ).offset();
  16503. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16504. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16505. }
  16506. }
  16507. // Subtract parent offsets and element margins
  16508. return {
  16509. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16510. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16511. };
  16512. },
  16513. // This method will return documentElement in the following cases:
  16514. // 1) For the element inside the iframe without offsetParent, this method will return
  16515. // documentElement of the parent window
  16516. // 2) For the hidden or detached element
  16517. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16518. //
  16519. // but those exceptions were never presented as a real life use-cases
  16520. // and might be considered as more preferable results.
  16521. //
  16522. // This logic, however, is not guaranteed and can change at any point in the future
  16523. offsetParent: function() {
  16524. return this.map( function() {
  16525. var offsetParent = this.offsetParent;
  16526. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16527. offsetParent = offsetParent.offsetParent;
  16528. }
  16529. return offsetParent || documentElement;
  16530. } );
  16531. }
  16532. } );
  16533. // Create scrollLeft and scrollTop methods
  16534. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16535. var top = "pageYOffset" === prop;
  16536. jQuery.fn[ method ] = function( val ) {
  16537. return access( this, function( elem, method, val ) {
  16538. // Coalesce documents and windows
  16539. var win;
  16540. if ( isWindow( elem ) ) {
  16541. win = elem;
  16542. } else if ( elem.nodeType === 9 ) {
  16543. win = elem.defaultView;
  16544. }
  16545. if ( val === undefined ) {
  16546. return win ? win[ prop ] : elem[ method ];
  16547. }
  16548. if ( win ) {
  16549. win.scrollTo(
  16550. !top ? val : win.pageXOffset,
  16551. top ? val : win.pageYOffset
  16552. );
  16553. } else {
  16554. elem[ method ] = val;
  16555. }
  16556. }, method, val, arguments.length );
  16557. };
  16558. } );
  16559. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16560. // Add the top/left cssHooks using jQuery.fn.position
  16561. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16562. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16563. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16564. // rather than make the css module depend on the offset module, just check for it here
  16565. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16566. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16567. function( elem, computed ) {
  16568. if ( computed ) {
  16569. computed = curCSS( elem, prop );
  16570. // If curCSS returns percentage, fallback to offset
  16571. return rnumnonpx.test( computed ) ?
  16572. jQuery( elem ).position()[ prop ] + "px" :
  16573. computed;
  16574. }
  16575. }
  16576. );
  16577. } );
  16578. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16579. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16580. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16581. function( defaultExtra, funcName ) {
  16582. // Margin is only for outerHeight, outerWidth
  16583. jQuery.fn[ funcName ] = function( margin, value ) {
  16584. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16585. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16586. return access( this, function( elem, type, value ) {
  16587. var doc;
  16588. if ( isWindow( elem ) ) {
  16589. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16590. return funcName.indexOf( "outer" ) === 0 ?
  16591. elem[ "inner" + name ] :
  16592. elem.document.documentElement[ "client" + name ];
  16593. }
  16594. // Get document width or height
  16595. if ( elem.nodeType === 9 ) {
  16596. doc = elem.documentElement;
  16597. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16598. // whichever is greatest
  16599. return Math.max(
  16600. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16601. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16602. doc[ "client" + name ]
  16603. );
  16604. }
  16605. return value === undefined ?
  16606. // Get width or height on the element, requesting but not forcing parseFloat
  16607. jQuery.css( elem, type, extra ) :
  16608. // Set width or height on the element
  16609. jQuery.style( elem, type, value, extra );
  16610. }, type, chainable ? margin : undefined, chainable );
  16611. };
  16612. } );
  16613. } );
  16614. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16615. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16616. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16617. function( i, name ) {
  16618. // Handle event binding
  16619. jQuery.fn[ name ] = function( data, fn ) {
  16620. return arguments.length > 0 ?
  16621. this.on( name, null, data, fn ) :
  16622. this.trigger( name );
  16623. };
  16624. } );
  16625. jQuery.fn.extend( {
  16626. hover: function( fnOver, fnOut ) {
  16627. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16628. }
  16629. } );
  16630. jQuery.fn.extend( {
  16631. bind: function( types, data, fn ) {
  16632. return this.on( types, null, data, fn );
  16633. },
  16634. unbind: function( types, fn ) {
  16635. return this.off( types, null, fn );
  16636. },
  16637. delegate: function( selector, types, data, fn ) {
  16638. return this.on( types, selector, data, fn );
  16639. },
  16640. undelegate: function( selector, types, fn ) {
  16641. // ( namespace ) or ( selector, types [, fn] )
  16642. return arguments.length === 1 ?
  16643. this.off( selector, "**" ) :
  16644. this.off( types, selector || "**", fn );
  16645. }
  16646. } );
  16647. // Bind a function to a context, optionally partially applying any
  16648. // arguments.
  16649. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16650. // However, it is not slated for removal any time soon
  16651. jQuery.proxy = function( fn, context ) {
  16652. var tmp, args, proxy;
  16653. if ( typeof context === "string" ) {
  16654. tmp = fn[ context ];
  16655. context = fn;
  16656. fn = tmp;
  16657. }
  16658. // Quick check to determine if target is callable, in the spec
  16659. // this throws a TypeError, but we will just return undefined.
  16660. if ( !isFunction( fn ) ) {
  16661. return undefined;
  16662. }
  16663. // Simulated bind
  16664. args = slice.call( arguments, 2 );
  16665. proxy = function() {
  16666. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16667. };
  16668. // Set the guid of unique handler to the same of original handler, so it can be removed
  16669. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16670. return proxy;
  16671. };
  16672. jQuery.holdReady = function( hold ) {
  16673. if ( hold ) {
  16674. jQuery.readyWait++;
  16675. } else {
  16676. jQuery.ready( true );
  16677. }
  16678. };
  16679. jQuery.isArray = Array.isArray;
  16680. jQuery.parseJSON = JSON.parse;
  16681. jQuery.nodeName = nodeName;
  16682. jQuery.isFunction = isFunction;
  16683. jQuery.isWindow = isWindow;
  16684. jQuery.camelCase = camelCase;
  16685. jQuery.type = toType;
  16686. jQuery.now = Date.now;
  16687. jQuery.isNumeric = function( obj ) {
  16688. // As of jQuery 3.0, isNumeric is limited to
  16689. // strings and numbers (primitives or objects)
  16690. // that can be coerced to finite numbers (gh-2662)
  16691. var type = jQuery.type( obj );
  16692. return ( type === "number" || type === "string" ) &&
  16693. // parseFloat NaNs numeric-cast false positives ("")
  16694. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16695. // subtraction forces infinities to NaN
  16696. !isNaN( obj - parseFloat( obj ) );
  16697. };
  16698. // Register as a named AMD module, since jQuery can be concatenated with other
  16699. // files that may use define, but not via a proper concatenation script that
  16700. // understands anonymous AMD modules. A named AMD is safest and most robust
  16701. // way to register. Lowercase jquery is used because AMD module names are
  16702. // derived from file names, and jQuery is normally delivered in a lowercase
  16703. // file name. Do this after creating the global so that if an AMD module wants
  16704. // to call noConflict to hide this version of jQuery, it will work.
  16705. // Note that for maximum portability, libraries that are not jQuery should
  16706. // declare themselves as anonymous modules, and avoid setting a global if an
  16707. // AMD loader is present. jQuery is a special case. For more information, see
  16708. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16709. if ( true ) {
  16710. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16711. return jQuery;
  16712. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16713. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16714. }
  16715. var
  16716. // Map over jQuery in case of overwrite
  16717. _jQuery = window.jQuery,
  16718. // Map over the $ in case of overwrite
  16719. _$ = window.$;
  16720. jQuery.noConflict = function( deep ) {
  16721. if ( window.$ === jQuery ) {
  16722. window.$ = _$;
  16723. }
  16724. if ( deep && window.jQuery === jQuery ) {
  16725. window.jQuery = _jQuery;
  16726. }
  16727. return jQuery;
  16728. };
  16729. // Expose jQuery and $ identifiers, even in AMD
  16730. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16731. // and CommonJS for browser emulators (#13566)
  16732. if ( !noGlobal ) {
  16733. window.jQuery = window.$ = jQuery;
  16734. }
  16735. return jQuery;
  16736. } );
  16737. /***/ }),
  16738. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16739. /*!************************************************!*\
  16740. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16741. \************************************************/
  16742. /*! exports provided: default */
  16743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16744. "use strict";
  16745. __webpack_require__.r(__webpack_exports__);
  16746. var classCallCheck = function (instance, Constructor) {
  16747. if (!(instance instanceof Constructor)) {
  16748. throw new TypeError("Cannot call a class as a function");
  16749. }
  16750. };
  16751. var createClass = function () {
  16752. function defineProperties(target, props) {
  16753. for (var i = 0; i < props.length; i++) {
  16754. var descriptor = props[i];
  16755. descriptor.enumerable = descriptor.enumerable || false;
  16756. descriptor.configurable = true;
  16757. if ("value" in descriptor) descriptor.writable = true;
  16758. Object.defineProperty(target, descriptor.key, descriptor);
  16759. }
  16760. }
  16761. return function (Constructor, protoProps, staticProps) {
  16762. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16763. if (staticProps) defineProperties(Constructor, staticProps);
  16764. return Constructor;
  16765. };
  16766. }();
  16767. var _extends = Object.assign || function (target) {
  16768. for (var i = 1; i < arguments.length; i++) {
  16769. var source = arguments[i];
  16770. for (var key in source) {
  16771. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16772. target[key] = source[key];
  16773. }
  16774. }
  16775. }
  16776. return target;
  16777. };
  16778. var inherits = function (subClass, superClass) {
  16779. if (typeof superClass !== "function" && superClass !== null) {
  16780. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16781. }
  16782. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16783. constructor: {
  16784. value: subClass,
  16785. enumerable: false,
  16786. writable: true,
  16787. configurable: true
  16788. }
  16789. });
  16790. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16791. };
  16792. var possibleConstructorReturn = function (self, call) {
  16793. if (!self) {
  16794. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16795. }
  16796. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16797. };
  16798. var Connector = function () {
  16799. /**
  16800. * Create a new class instance.
  16801. */
  16802. function Connector(options) {
  16803. classCallCheck(this, Connector);
  16804. /**
  16805. * Default connector options.
  16806. */
  16807. this._defaultOptions = {
  16808. auth: {
  16809. headers: {}
  16810. },
  16811. authEndpoint: '/broadcasting/auth',
  16812. broadcaster: 'pusher',
  16813. csrfToken: null,
  16814. host: null,
  16815. key: null,
  16816. namespace: 'App.Events'
  16817. };
  16818. this.setOptions(options);
  16819. this.connect();
  16820. }
  16821. /**
  16822. * Merge the custom options with the defaults.
  16823. */
  16824. createClass(Connector, [{
  16825. key: 'setOptions',
  16826. value: function setOptions(options) {
  16827. this.options = _extends(this._defaultOptions, options);
  16828. if (this.csrfToken()) {
  16829. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16830. }
  16831. return options;
  16832. }
  16833. /**
  16834. * Extract the CSRF token from the page.
  16835. */
  16836. }, {
  16837. key: 'csrfToken',
  16838. value: function csrfToken() {
  16839. var selector = void 0;
  16840. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16841. return window['Laravel'].csrfToken;
  16842. } else if (this.options.csrfToken) {
  16843. return this.options.csrfToken;
  16844. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16845. return selector.getAttribute('content');
  16846. }
  16847. return null;
  16848. }
  16849. }]);
  16850. return Connector;
  16851. }();
  16852. /**
  16853. * This class represents a basic channel.
  16854. */
  16855. var Channel = function () {
  16856. function Channel() {
  16857. classCallCheck(this, Channel);
  16858. }
  16859. createClass(Channel, [{
  16860. key: 'listenForWhisper',
  16861. /**
  16862. * Listen for a whisper event on the channel instance.
  16863. */
  16864. value: function listenForWhisper(event, callback) {
  16865. return this.listen('.client-' + event, callback);
  16866. }
  16867. /**
  16868. * Listen for an event on the channel instance.
  16869. */
  16870. }, {
  16871. key: 'notification',
  16872. value: function notification(callback) {
  16873. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16874. }
  16875. /**
  16876. * Stop listening for a whispser event on the channel instance.
  16877. */
  16878. }, {
  16879. key: 'stopListeningForWhisper',
  16880. value: function stopListeningForWhisper(event) {
  16881. return this.stopListening('.client-' + event);
  16882. }
  16883. }]);
  16884. return Channel;
  16885. }();
  16886. /**
  16887. * Event name formatter
  16888. */
  16889. var EventFormatter = function () {
  16890. /**
  16891. * Create a new class instance.
  16892. */
  16893. function EventFormatter(namespace) {
  16894. classCallCheck(this, EventFormatter);
  16895. this.setNamespace(namespace);
  16896. }
  16897. /**
  16898. * Format the given event name.
  16899. */
  16900. createClass(EventFormatter, [{
  16901. key: 'format',
  16902. value: function format(event) {
  16903. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16904. return event.substr(1);
  16905. } else if (this.namespace) {
  16906. event = this.namespace + '.' + event;
  16907. }
  16908. return event.replace(/\./g, '\\');
  16909. }
  16910. /**
  16911. * Set the event namespace.
  16912. */
  16913. }, {
  16914. key: 'setNamespace',
  16915. value: function setNamespace(value) {
  16916. this.namespace = value;
  16917. }
  16918. }]);
  16919. return EventFormatter;
  16920. }();
  16921. /**
  16922. * This class represents a Pusher channel.
  16923. */
  16924. var PusherChannel = function (_Channel) {
  16925. inherits(PusherChannel, _Channel);
  16926. /**
  16927. * Create a new class instance.
  16928. */
  16929. function PusherChannel(pusher, name, options) {
  16930. classCallCheck(this, PusherChannel);
  16931. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16932. _this.name = name;
  16933. _this.pusher = pusher;
  16934. _this.options = options;
  16935. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16936. _this.subscribe();
  16937. return _this;
  16938. }
  16939. /**
  16940. * Subscribe to a Pusher channel.
  16941. */
  16942. createClass(PusherChannel, [{
  16943. key: 'subscribe',
  16944. value: function subscribe() {
  16945. this.subscription = this.pusher.subscribe(this.name);
  16946. }
  16947. /**
  16948. * Unsubscribe from a Pusher channel.
  16949. */
  16950. }, {
  16951. key: 'unsubscribe',
  16952. value: function unsubscribe() {
  16953. this.pusher.unsubscribe(this.name);
  16954. }
  16955. /**
  16956. * Listen for an event on the channel instance.
  16957. */
  16958. }, {
  16959. key: 'listen',
  16960. value: function listen(event, callback) {
  16961. this.on(this.eventFormatter.format(event), callback);
  16962. return this;
  16963. }
  16964. /**
  16965. * Stop listening for an event on the channel instance.
  16966. */
  16967. }, {
  16968. key: 'stopListening',
  16969. value: function stopListening(event) {
  16970. this.subscription.unbind(this.eventFormatter.format(event));
  16971. return this;
  16972. }
  16973. /**
  16974. * Bind a channel to an event.
  16975. */
  16976. }, {
  16977. key: 'on',
  16978. value: function on(event, callback) {
  16979. this.subscription.bind(event, callback);
  16980. return this;
  16981. }
  16982. }]);
  16983. return PusherChannel;
  16984. }(Channel);
  16985. /**
  16986. * This class represents a Pusher private channel.
  16987. */
  16988. var PusherPrivateChannel = function (_PusherChannel) {
  16989. inherits(PusherPrivateChannel, _PusherChannel);
  16990. function PusherPrivateChannel() {
  16991. classCallCheck(this, PusherPrivateChannel);
  16992. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16993. }
  16994. createClass(PusherPrivateChannel, [{
  16995. key: 'whisper',
  16996. /**
  16997. * Trigger client event on the channel.
  16998. */
  16999. value: function whisper(eventName, data) {
  17000. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  17001. return this;
  17002. }
  17003. }]);
  17004. return PusherPrivateChannel;
  17005. }(PusherChannel);
  17006. /**
  17007. * This class represents a Pusher presence channel.
  17008. */
  17009. var PusherPresenceChannel = function (_PusherChannel) {
  17010. inherits(PusherPresenceChannel, _PusherChannel);
  17011. function PusherPresenceChannel() {
  17012. classCallCheck(this, PusherPresenceChannel);
  17013. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  17014. }
  17015. createClass(PusherPresenceChannel, [{
  17016. key: 'here',
  17017. /**
  17018. * Register a callback to be called anytime the member list changes.
  17019. */
  17020. value: function here(callback) {
  17021. this.on('pusher:subscription_succeeded', function (data) {
  17022. callback(Object.keys(data.members).map(function (k) {
  17023. return data.members[k];
  17024. }));
  17025. });
  17026. return this;
  17027. }
  17028. /**
  17029. * Listen for someone joining the channel.
  17030. */
  17031. }, {
  17032. key: 'joining',
  17033. value: function joining(callback) {
  17034. this.on('pusher:member_added', function (member) {
  17035. callback(member.info);
  17036. });
  17037. return this;
  17038. }
  17039. /**
  17040. * Listen for someone leaving the channel.
  17041. */
  17042. }, {
  17043. key: 'leaving',
  17044. value: function leaving(callback) {
  17045. this.on('pusher:member_removed', function (member) {
  17046. callback(member.info);
  17047. });
  17048. return this;
  17049. }
  17050. /**
  17051. * Trigger client event on the channel.
  17052. */
  17053. }, {
  17054. key: 'whisper',
  17055. value: function whisper(eventName, data) {
  17056. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  17057. return this;
  17058. }
  17059. }]);
  17060. return PusherPresenceChannel;
  17061. }(PusherChannel);
  17062. /**
  17063. * This class represents a Socket.io channel.
  17064. */
  17065. var SocketIoChannel = function (_Channel) {
  17066. inherits(SocketIoChannel, _Channel);
  17067. /**
  17068. * Create a new class instance.
  17069. */
  17070. function SocketIoChannel(socket, name, options) {
  17071. classCallCheck(this, SocketIoChannel);
  17072. /**
  17073. * The event callbacks applied to the channel.
  17074. */
  17075. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  17076. _this.events = {};
  17077. _this.name = name;
  17078. _this.socket = socket;
  17079. _this.options = options;
  17080. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  17081. _this.subscribe();
  17082. _this.configureReconnector();
  17083. return _this;
  17084. }
  17085. /**
  17086. * Subscribe to a Socket.io channel.
  17087. */
  17088. createClass(SocketIoChannel, [{
  17089. key: 'subscribe',
  17090. value: function subscribe() {
  17091. this.socket.emit('subscribe', {
  17092. channel: this.name,
  17093. auth: this.options.auth || {}
  17094. });
  17095. }
  17096. /**
  17097. * Unsubscribe from channel and ubind event callbacks.
  17098. */
  17099. }, {
  17100. key: 'unsubscribe',
  17101. value: function unsubscribe() {
  17102. this.unbind();
  17103. this.socket.emit('unsubscribe', {
  17104. channel: this.name,
  17105. auth: this.options.auth || {}
  17106. });
  17107. }
  17108. /**
  17109. * Listen for an event on the channel instance.
  17110. */
  17111. }, {
  17112. key: 'listen',
  17113. value: function listen(event, callback) {
  17114. this.on(this.eventFormatter.format(event), callback);
  17115. return this;
  17116. }
  17117. /**
  17118. * Stop listening for an event on the channel instance.
  17119. */
  17120. }, {
  17121. key: 'stopListening',
  17122. value: function stopListening(event) {
  17123. var name = this.eventFormatter.format(event);
  17124. this.socket.removeListener(name);
  17125. delete this.events[name];
  17126. return this;
  17127. }
  17128. /**
  17129. * Bind the channel's socket to an event and store the callback.
  17130. */
  17131. }, {
  17132. key: 'on',
  17133. value: function on(event, callback) {
  17134. var _this2 = this;
  17135. var listener = function listener(channel, data) {
  17136. if (_this2.name == channel) {
  17137. callback(data);
  17138. }
  17139. };
  17140. this.socket.on(event, listener);
  17141. this.bind(event, listener);
  17142. }
  17143. /**
  17144. * Attach a 'reconnect' listener and bind the event.
  17145. */
  17146. }, {
  17147. key: 'configureReconnector',
  17148. value: function configureReconnector() {
  17149. var _this3 = this;
  17150. var listener = function listener() {
  17151. _this3.subscribe();
  17152. };
  17153. this.socket.on('reconnect', listener);
  17154. this.bind('reconnect', listener);
  17155. }
  17156. /**
  17157. * Bind the channel's socket to an event and store the callback.
  17158. */
  17159. }, {
  17160. key: 'bind',
  17161. value: function bind(event, callback) {
  17162. this.events[event] = this.events[event] || [];
  17163. this.events[event].push(callback);
  17164. }
  17165. /**
  17166. * Unbind the channel's socket from all stored event callbacks.
  17167. */
  17168. }, {
  17169. key: 'unbind',
  17170. value: function unbind() {
  17171. var _this4 = this;
  17172. Object.keys(this.events).forEach(function (event) {
  17173. _this4.events[event].forEach(function (callback) {
  17174. _this4.socket.removeListener(event, callback);
  17175. });
  17176. delete _this4.events[event];
  17177. });
  17178. }
  17179. }]);
  17180. return SocketIoChannel;
  17181. }(Channel);
  17182. /**
  17183. * This class represents a Socket.io presence channel.
  17184. */
  17185. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17186. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17187. function SocketIoPrivateChannel() {
  17188. classCallCheck(this, SocketIoPrivateChannel);
  17189. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17190. }
  17191. createClass(SocketIoPrivateChannel, [{
  17192. key: 'whisper',
  17193. /**
  17194. * Trigger client event on the channel.
  17195. */
  17196. value: function whisper(eventName, data) {
  17197. this.socket.emit('client event', {
  17198. channel: this.name,
  17199. event: 'client-' + eventName,
  17200. data: data
  17201. });
  17202. return this;
  17203. }
  17204. }]);
  17205. return SocketIoPrivateChannel;
  17206. }(SocketIoChannel);
  17207. /**
  17208. * This class represents a Socket.io presence channel.
  17209. */
  17210. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17211. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17212. function SocketIoPresenceChannel() {
  17213. classCallCheck(this, SocketIoPresenceChannel);
  17214. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17215. }
  17216. createClass(SocketIoPresenceChannel, [{
  17217. key: 'here',
  17218. /**
  17219. * Register a callback to be called anytime the member list changes.
  17220. */
  17221. value: function here(callback) {
  17222. this.on('presence:subscribed', function (members) {
  17223. callback(members.map(function (m) {
  17224. return m.user_info;
  17225. }));
  17226. });
  17227. return this;
  17228. }
  17229. /**
  17230. * Listen for someone joining the channel.
  17231. */
  17232. }, {
  17233. key: 'joining',
  17234. value: function joining(callback) {
  17235. this.on('presence:joining', function (member) {
  17236. return callback(member.user_info);
  17237. });
  17238. return this;
  17239. }
  17240. /**
  17241. * Listen for someone leaving the channel.
  17242. */
  17243. }, {
  17244. key: 'leaving',
  17245. value: function leaving(callback) {
  17246. this.on('presence:leaving', function (member) {
  17247. return callback(member.user_info);
  17248. });
  17249. return this;
  17250. }
  17251. }]);
  17252. return SocketIoPresenceChannel;
  17253. }(SocketIoPrivateChannel);
  17254. /**
  17255. * This class represents a null channel.
  17256. */
  17257. var NullChannel = function (_Channel) {
  17258. inherits(NullChannel, _Channel);
  17259. function NullChannel() {
  17260. classCallCheck(this, NullChannel);
  17261. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17262. }
  17263. createClass(NullChannel, [{
  17264. key: 'subscribe',
  17265. /**
  17266. * Subscribe to a channel.
  17267. */
  17268. value: function subscribe() {}
  17269. //
  17270. /**
  17271. * Unsubscribe from a channel.
  17272. */
  17273. }, {
  17274. key: 'unsubscribe',
  17275. value: function unsubscribe() {}
  17276. //
  17277. /**
  17278. * Listen for an event on the channel instance.
  17279. */
  17280. }, {
  17281. key: 'listen',
  17282. value: function listen(event, callback) {
  17283. return this;
  17284. }
  17285. /**
  17286. * Stop listening for an event on the channel instance.
  17287. */
  17288. }, {
  17289. key: 'stopListening',
  17290. value: function stopListening(event) {
  17291. return this;
  17292. }
  17293. /**
  17294. * Bind a channel to an event.
  17295. */
  17296. }, {
  17297. key: 'on',
  17298. value: function on(event, callback) {
  17299. return this;
  17300. }
  17301. }]);
  17302. return NullChannel;
  17303. }(Channel);
  17304. /**
  17305. * This class represents a null private channel.
  17306. */
  17307. var NullPrivateChannel = function (_NullChannel) {
  17308. inherits(NullPrivateChannel, _NullChannel);
  17309. function NullPrivateChannel() {
  17310. classCallCheck(this, NullPrivateChannel);
  17311. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17312. }
  17313. createClass(NullPrivateChannel, [{
  17314. key: 'whisper',
  17315. /**
  17316. * Trigger client event on the channel.
  17317. */
  17318. value: function whisper(eventName, data) {
  17319. return this;
  17320. }
  17321. }]);
  17322. return NullPrivateChannel;
  17323. }(NullChannel);
  17324. /**
  17325. * This class represents a null presence channel.
  17326. */
  17327. var NullPresenceChannel = function (_NullChannel) {
  17328. inherits(NullPresenceChannel, _NullChannel);
  17329. function NullPresenceChannel() {
  17330. classCallCheck(this, NullPresenceChannel);
  17331. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17332. }
  17333. createClass(NullPresenceChannel, [{
  17334. key: 'here',
  17335. /**
  17336. * Register a callback to be called anytime the member list changes.
  17337. */
  17338. value: function here(callback) {
  17339. return this;
  17340. }
  17341. /**
  17342. * Listen for someone joining the channel.
  17343. */
  17344. }, {
  17345. key: 'joining',
  17346. value: function joining(callback) {
  17347. return this;
  17348. }
  17349. /**
  17350. * Listen for someone leaving the channel.
  17351. */
  17352. }, {
  17353. key: 'leaving',
  17354. value: function leaving(callback) {
  17355. return this;
  17356. }
  17357. /**
  17358. * Trigger client event on the channel.
  17359. */
  17360. }, {
  17361. key: 'whisper',
  17362. value: function whisper(eventName, data) {
  17363. return this;
  17364. }
  17365. }]);
  17366. return NullPresenceChannel;
  17367. }(NullChannel);
  17368. /**
  17369. * This class creates a connector to Pusher.
  17370. */
  17371. var PusherConnector = function (_Connector) {
  17372. inherits(PusherConnector, _Connector);
  17373. function PusherConnector() {
  17374. classCallCheck(this, PusherConnector);
  17375. /**
  17376. * All of the subscribed channel names.
  17377. */
  17378. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17379. _this.channels = {};
  17380. return _this;
  17381. }
  17382. /**
  17383. * Create a fresh Pusher connection.
  17384. */
  17385. createClass(PusherConnector, [{
  17386. key: 'connect',
  17387. value: function connect() {
  17388. if (typeof this.options.client !== 'undefined') {
  17389. this.pusher = this.options.client;
  17390. } else {
  17391. this.pusher = new Pusher(this.options.key, this.options);
  17392. }
  17393. }
  17394. /**
  17395. * Listen for an event on a channel instance.
  17396. */
  17397. }, {
  17398. key: 'listen',
  17399. value: function listen(name, event, callback) {
  17400. return this.channel(name).listen(event, callback);
  17401. }
  17402. /**
  17403. * Get a channel instance by name.
  17404. */
  17405. }, {
  17406. key: 'channel',
  17407. value: function channel(name) {
  17408. if (!this.channels[name]) {
  17409. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17410. }
  17411. return this.channels[name];
  17412. }
  17413. /**
  17414. * Get a private channel instance by name.
  17415. */
  17416. }, {
  17417. key: 'privateChannel',
  17418. value: function privateChannel(name) {
  17419. if (!this.channels['private-' + name]) {
  17420. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17421. }
  17422. return this.channels['private-' + name];
  17423. }
  17424. /**
  17425. * Get a presence channel instance by name.
  17426. */
  17427. }, {
  17428. key: 'presenceChannel',
  17429. value: function presenceChannel(name) {
  17430. if (!this.channels['presence-' + name]) {
  17431. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17432. }
  17433. return this.channels['presence-' + name];
  17434. }
  17435. /**
  17436. * Leave the given channel, as well as its private and presence variants.
  17437. */
  17438. }, {
  17439. key: 'leave',
  17440. value: function leave(name) {
  17441. var _this2 = this;
  17442. var channels = [name, 'private-' + name, 'presence-' + name];
  17443. channels.forEach(function (name, index) {
  17444. _this2.leaveChannel(name);
  17445. });
  17446. }
  17447. /**
  17448. * Leave the given channel.
  17449. */
  17450. }, {
  17451. key: 'leaveChannel',
  17452. value: function leaveChannel(name) {
  17453. if (this.channels[name]) {
  17454. this.channels[name].unsubscribe();
  17455. delete this.channels[name];
  17456. }
  17457. }
  17458. /**
  17459. * Get the socket ID for the connection.
  17460. */
  17461. }, {
  17462. key: 'socketId',
  17463. value: function socketId() {
  17464. return this.pusher.connection.socket_id;
  17465. }
  17466. /**
  17467. * Disconnect Pusher connection.
  17468. */
  17469. }, {
  17470. key: 'disconnect',
  17471. value: function disconnect() {
  17472. this.pusher.disconnect();
  17473. }
  17474. }]);
  17475. return PusherConnector;
  17476. }(Connector);
  17477. /**
  17478. * This class creates a connnector to a Socket.io server.
  17479. */
  17480. var SocketIoConnector = function (_Connector) {
  17481. inherits(SocketIoConnector, _Connector);
  17482. function SocketIoConnector() {
  17483. classCallCheck(this, SocketIoConnector);
  17484. /**
  17485. * All of the subscribed channel names.
  17486. */
  17487. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17488. _this.channels = {};
  17489. return _this;
  17490. }
  17491. /**
  17492. * Create a fresh Socket.io connection.
  17493. */
  17494. createClass(SocketIoConnector, [{
  17495. key: 'connect',
  17496. value: function connect() {
  17497. var io = this.getSocketIO();
  17498. this.socket = io(this.options.host, this.options);
  17499. return this.socket;
  17500. }
  17501. /**
  17502. * Get socket.io module from global scope or options.
  17503. */
  17504. }, {
  17505. key: 'getSocketIO',
  17506. value: function getSocketIO() {
  17507. if (typeof this.options.client !== 'undefined') {
  17508. return this.options.client;
  17509. }
  17510. if (typeof io !== 'undefined') {
  17511. return io;
  17512. }
  17513. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17514. }
  17515. /**
  17516. * Listen for an event on a channel instance.
  17517. */
  17518. }, {
  17519. key: 'listen',
  17520. value: function listen(name, event, callback) {
  17521. return this.channel(name).listen(event, callback);
  17522. }
  17523. /**
  17524. * Get a channel instance by name.
  17525. */
  17526. }, {
  17527. key: 'channel',
  17528. value: function channel(name) {
  17529. if (!this.channels[name]) {
  17530. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17531. }
  17532. return this.channels[name];
  17533. }
  17534. /**
  17535. * Get a private channel instance by name.
  17536. */
  17537. }, {
  17538. key: 'privateChannel',
  17539. value: function privateChannel(name) {
  17540. if (!this.channels['private-' + name]) {
  17541. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17542. }
  17543. return this.channels['private-' + name];
  17544. }
  17545. /**
  17546. * Get a presence channel instance by name.
  17547. */
  17548. }, {
  17549. key: 'presenceChannel',
  17550. value: function presenceChannel(name) {
  17551. if (!this.channels['presence-' + name]) {
  17552. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17553. }
  17554. return this.channels['presence-' + name];
  17555. }
  17556. /**
  17557. * Leave the given channel, as well as its private and presence variants.
  17558. */
  17559. }, {
  17560. key: 'leave',
  17561. value: function leave(name) {
  17562. var _this2 = this;
  17563. var channels = [name, 'private-' + name, 'presence-' + name];
  17564. channels.forEach(function (name) {
  17565. _this2.leaveChannel(name);
  17566. });
  17567. }
  17568. /**
  17569. * Leave the given channel.
  17570. */
  17571. }, {
  17572. key: 'leaveChannel',
  17573. value: function leaveChannel(name) {
  17574. if (this.channels[name]) {
  17575. this.channels[name].unsubscribe();
  17576. delete this.channels[name];
  17577. }
  17578. }
  17579. /**
  17580. * Get the socket ID for the connection.
  17581. */
  17582. }, {
  17583. key: 'socketId',
  17584. value: function socketId() {
  17585. return this.socket.id;
  17586. }
  17587. /**
  17588. * Disconnect Socketio connection.
  17589. */
  17590. }, {
  17591. key: 'disconnect',
  17592. value: function disconnect() {
  17593. this.socket.disconnect();
  17594. }
  17595. }]);
  17596. return SocketIoConnector;
  17597. }(Connector);
  17598. /**
  17599. * This class creates a null connector.
  17600. */
  17601. var NullConnector = function (_Connector) {
  17602. inherits(NullConnector, _Connector);
  17603. function NullConnector() {
  17604. classCallCheck(this, NullConnector);
  17605. /**
  17606. * All of the subscribed channel names.
  17607. */
  17608. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17609. _this.channels = {};
  17610. return _this;
  17611. }
  17612. /**
  17613. * Create a fresh connection.
  17614. */
  17615. createClass(NullConnector, [{
  17616. key: 'connect',
  17617. value: function connect() {}
  17618. //
  17619. /**
  17620. * Listen for an event on a channel instance.
  17621. */
  17622. }, {
  17623. key: 'listen',
  17624. value: function listen(name, event, callback) {
  17625. return new NullChannel();
  17626. }
  17627. /**
  17628. * Get a channel instance by name.
  17629. */
  17630. }, {
  17631. key: 'channel',
  17632. value: function channel(name) {
  17633. return new NullChannel();
  17634. }
  17635. /**
  17636. * Get a private channel instance by name.
  17637. */
  17638. }, {
  17639. key: 'privateChannel',
  17640. value: function privateChannel(name) {
  17641. return new NullPrivateChannel();
  17642. }
  17643. /**
  17644. * Get a presence channel instance by name.
  17645. */
  17646. }, {
  17647. key: 'presenceChannel',
  17648. value: function presenceChannel(name) {
  17649. return new NullPresenceChannel();
  17650. }
  17651. /**
  17652. * Leave the given channel, as well as its private and presence variants.
  17653. */
  17654. }, {
  17655. key: 'leave',
  17656. value: function leave(name) {}
  17657. //
  17658. /**
  17659. * Leave the given channel.
  17660. */
  17661. }, {
  17662. key: 'leaveChannel',
  17663. value: function leaveChannel(name) {}
  17664. //
  17665. /**
  17666. * Get the socket ID for the connection.
  17667. */
  17668. }, {
  17669. key: 'socketId',
  17670. value: function socketId() {
  17671. return 'fake-socket-id';
  17672. }
  17673. /**
  17674. * Disconnect the connection.
  17675. */
  17676. }, {
  17677. key: 'disconnect',
  17678. value: function disconnect() {
  17679. //
  17680. }
  17681. }]);
  17682. return NullConnector;
  17683. }(Connector);
  17684. /**
  17685. * This class is the primary API for interacting with broadcasting.
  17686. */
  17687. var Echo = function () {
  17688. /**
  17689. * Create a new class instance.
  17690. */
  17691. function Echo(options) {
  17692. classCallCheck(this, Echo);
  17693. this.options = options;
  17694. this.connect();
  17695. if (!this.options.withoutInterceptors) {
  17696. this.registerInterceptors();
  17697. }
  17698. }
  17699. /**
  17700. * Get a channel instance by name.
  17701. */
  17702. createClass(Echo, [{
  17703. key: 'channel',
  17704. value: function channel(_channel) {
  17705. return this.connector.channel(_channel);
  17706. }
  17707. /**
  17708. * Create a new connection.
  17709. */
  17710. }, {
  17711. key: 'connect',
  17712. value: function connect() {
  17713. if (this.options.broadcaster == 'pusher') {
  17714. this.connector = new PusherConnector(this.options);
  17715. } else if (this.options.broadcaster == 'socket.io') {
  17716. this.connector = new SocketIoConnector(this.options);
  17717. } else if (this.options.broadcaster == 'null') {
  17718. this.connector = new NullConnector(this.options);
  17719. } else if (typeof this.options.broadcaster == 'function') {
  17720. this.connector = new this.options.broadcaster(this.options);
  17721. }
  17722. }
  17723. /**
  17724. * Disconnect from the Echo server.
  17725. */
  17726. }, {
  17727. key: 'disconnect',
  17728. value: function disconnect() {
  17729. this.connector.disconnect();
  17730. }
  17731. /**
  17732. * Get a presence channel instance by name.
  17733. */
  17734. }, {
  17735. key: 'join',
  17736. value: function join(channel) {
  17737. return this.connector.presenceChannel(channel);
  17738. }
  17739. /**
  17740. * Leave the given channel, as well as its private and presence variants.
  17741. */
  17742. }, {
  17743. key: 'leave',
  17744. value: function leave(channel) {
  17745. this.connector.leave(channel);
  17746. }
  17747. /**
  17748. * Leave the given channel.
  17749. */
  17750. }, {
  17751. key: 'leaveChannel',
  17752. value: function leaveChannel(channel) {
  17753. this.connector.leaveChannel(channel);
  17754. }
  17755. /**
  17756. * Listen for an event on a channel instance.
  17757. */
  17758. }, {
  17759. key: 'listen',
  17760. value: function listen(channel, event, callback) {
  17761. return this.connector.listen(channel, event, callback);
  17762. }
  17763. /**
  17764. * Get a private channel instance by name.
  17765. */
  17766. }, {
  17767. key: 'private',
  17768. value: function _private(channel) {
  17769. return this.connector.privateChannel(channel);
  17770. }
  17771. /**
  17772. * Get the Socket ID for the connection.
  17773. */
  17774. }, {
  17775. key: 'socketId',
  17776. value: function socketId() {
  17777. return this.connector.socketId();
  17778. }
  17779. /**
  17780. * Register 3rd party request interceptiors. These are used to automatically
  17781. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17782. */
  17783. }, {
  17784. key: 'registerInterceptors',
  17785. value: function registerInterceptors() {
  17786. if (typeof Vue === 'function' && Vue.http) {
  17787. this.registerVueRequestInterceptor();
  17788. }
  17789. if (typeof axios === 'function') {
  17790. this.registerAxiosRequestInterceptor();
  17791. }
  17792. if (typeof jQuery === 'function') {
  17793. this.registerjQueryAjaxSetup();
  17794. }
  17795. }
  17796. /**
  17797. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17798. */
  17799. }, {
  17800. key: 'registerVueRequestInterceptor',
  17801. value: function registerVueRequestInterceptor() {
  17802. var _this = this;
  17803. Vue.http.interceptors.push(function (request, next) {
  17804. if (_this.socketId()) {
  17805. request.headers.set('X-Socket-ID', _this.socketId());
  17806. }
  17807. next();
  17808. });
  17809. }
  17810. /**
  17811. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17812. */
  17813. }, {
  17814. key: 'registerAxiosRequestInterceptor',
  17815. value: function registerAxiosRequestInterceptor() {
  17816. var _this2 = this;
  17817. axios.interceptors.request.use(function (config) {
  17818. if (_this2.socketId()) {
  17819. config.headers['X-Socket-Id'] = _this2.socketId();
  17820. }
  17821. return config;
  17822. });
  17823. }
  17824. /**
  17825. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17826. */
  17827. }, {
  17828. key: 'registerjQueryAjaxSetup',
  17829. value: function registerjQueryAjaxSetup() {
  17830. var _this3 = this;
  17831. if (typeof jQuery.ajax != 'undefined') {
  17832. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17833. if (_this3.socketId()) {
  17834. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17835. }
  17836. });
  17837. }
  17838. }
  17839. }]);
  17840. return Echo;
  17841. }();
  17842. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17843. /***/ }),
  17844. /***/ "./node_modules/lodash/lodash.js":
  17845. /*!***************************************!*\
  17846. !*** ./node_modules/lodash/lodash.js ***!
  17847. \***************************************/
  17848. /*! no static exports found */
  17849. /***/ (function(module, exports, __webpack_require__) {
  17850. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17851. * @license
  17852. * Lodash <https://lodash.com/>
  17853. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17854. * Released under MIT license <https://lodash.com/license>
  17855. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17856. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17857. */
  17858. ;(function() {
  17859. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17860. var undefined;
  17861. /** Used as the semantic version number. */
  17862. var VERSION = '4.17.15';
  17863. /** Used as the size to enable large array optimizations. */
  17864. var LARGE_ARRAY_SIZE = 200;
  17865. /** Error message constants. */
  17866. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17867. FUNC_ERROR_TEXT = 'Expected a function';
  17868. /** Used to stand-in for `undefined` hash values. */
  17869. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17870. /** Used as the maximum memoize cache size. */
  17871. var MAX_MEMOIZE_SIZE = 500;
  17872. /** Used as the internal argument placeholder. */
  17873. var PLACEHOLDER = '__lodash_placeholder__';
  17874. /** Used to compose bitmasks for cloning. */
  17875. var CLONE_DEEP_FLAG = 1,
  17876. CLONE_FLAT_FLAG = 2,
  17877. CLONE_SYMBOLS_FLAG = 4;
  17878. /** Used to compose bitmasks for value comparisons. */
  17879. var COMPARE_PARTIAL_FLAG = 1,
  17880. COMPARE_UNORDERED_FLAG = 2;
  17881. /** Used to compose bitmasks for function metadata. */
  17882. var WRAP_BIND_FLAG = 1,
  17883. WRAP_BIND_KEY_FLAG = 2,
  17884. WRAP_CURRY_BOUND_FLAG = 4,
  17885. WRAP_CURRY_FLAG = 8,
  17886. WRAP_CURRY_RIGHT_FLAG = 16,
  17887. WRAP_PARTIAL_FLAG = 32,
  17888. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17889. WRAP_ARY_FLAG = 128,
  17890. WRAP_REARG_FLAG = 256,
  17891. WRAP_FLIP_FLAG = 512;
  17892. /** Used as default options for `_.truncate`. */
  17893. var DEFAULT_TRUNC_LENGTH = 30,
  17894. DEFAULT_TRUNC_OMISSION = '...';
  17895. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17896. var HOT_COUNT = 800,
  17897. HOT_SPAN = 16;
  17898. /** Used to indicate the type of lazy iteratees. */
  17899. var LAZY_FILTER_FLAG = 1,
  17900. LAZY_MAP_FLAG = 2,
  17901. LAZY_WHILE_FLAG = 3;
  17902. /** Used as references for various `Number` constants. */
  17903. var INFINITY = 1 / 0,
  17904. MAX_SAFE_INTEGER = 9007199254740991,
  17905. MAX_INTEGER = 1.7976931348623157e+308,
  17906. NAN = 0 / 0;
  17907. /** Used as references for the maximum length and index of an array. */
  17908. var MAX_ARRAY_LENGTH = 4294967295,
  17909. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17910. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17911. /** Used to associate wrap methods with their bit flags. */
  17912. var wrapFlags = [
  17913. ['ary', WRAP_ARY_FLAG],
  17914. ['bind', WRAP_BIND_FLAG],
  17915. ['bindKey', WRAP_BIND_KEY_FLAG],
  17916. ['curry', WRAP_CURRY_FLAG],
  17917. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17918. ['flip', WRAP_FLIP_FLAG],
  17919. ['partial', WRAP_PARTIAL_FLAG],
  17920. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17921. ['rearg', WRAP_REARG_FLAG]
  17922. ];
  17923. /** `Object#toString` result references. */
  17924. var argsTag = '[object Arguments]',
  17925. arrayTag = '[object Array]',
  17926. asyncTag = '[object AsyncFunction]',
  17927. boolTag = '[object Boolean]',
  17928. dateTag = '[object Date]',
  17929. domExcTag = '[object DOMException]',
  17930. errorTag = '[object Error]',
  17931. funcTag = '[object Function]',
  17932. genTag = '[object GeneratorFunction]',
  17933. mapTag = '[object Map]',
  17934. numberTag = '[object Number]',
  17935. nullTag = '[object Null]',
  17936. objectTag = '[object Object]',
  17937. promiseTag = '[object Promise]',
  17938. proxyTag = '[object Proxy]',
  17939. regexpTag = '[object RegExp]',
  17940. setTag = '[object Set]',
  17941. stringTag = '[object String]',
  17942. symbolTag = '[object Symbol]',
  17943. undefinedTag = '[object Undefined]',
  17944. weakMapTag = '[object WeakMap]',
  17945. weakSetTag = '[object WeakSet]';
  17946. var arrayBufferTag = '[object ArrayBuffer]',
  17947. dataViewTag = '[object DataView]',
  17948. float32Tag = '[object Float32Array]',
  17949. float64Tag = '[object Float64Array]',
  17950. int8Tag = '[object Int8Array]',
  17951. int16Tag = '[object Int16Array]',
  17952. int32Tag = '[object Int32Array]',
  17953. uint8Tag = '[object Uint8Array]',
  17954. uint8ClampedTag = '[object Uint8ClampedArray]',
  17955. uint16Tag = '[object Uint16Array]',
  17956. uint32Tag = '[object Uint32Array]';
  17957. /** Used to match empty string literals in compiled template source. */
  17958. var reEmptyStringLeading = /\b__p \+= '';/g,
  17959. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17960. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17961. /** Used to match HTML entities and HTML characters. */
  17962. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17963. reUnescapedHtml = /[&<>"']/g,
  17964. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17965. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17966. /** Used to match template delimiters. */
  17967. var reEscape = /<%-([\s\S]+?)%>/g,
  17968. reEvaluate = /<%([\s\S]+?)%>/g,
  17969. reInterpolate = /<%=([\s\S]+?)%>/g;
  17970. /** Used to match property names within property paths. */
  17971. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17972. reIsPlainProp = /^\w*$/,
  17973. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17974. /**
  17975. * Used to match `RegExp`
  17976. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17977. */
  17978. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17979. reHasRegExpChar = RegExp(reRegExpChar.source);
  17980. /** Used to match leading and trailing whitespace. */
  17981. var reTrim = /^\s+|\s+$/g,
  17982. reTrimStart = /^\s+/,
  17983. reTrimEnd = /\s+$/;
  17984. /** Used to match wrap detail comments. */
  17985. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17986. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17987. reSplitDetails = /,? & /;
  17988. /** Used to match words composed of alphanumeric characters. */
  17989. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17990. /** Used to match backslashes in property paths. */
  17991. var reEscapeChar = /\\(\\)?/g;
  17992. /**
  17993. * Used to match
  17994. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17995. */
  17996. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17997. /** Used to match `RegExp` flags from their coerced string values. */
  17998. var reFlags = /\w*$/;
  17999. /** Used to detect bad signed hexadecimal string values. */
  18000. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  18001. /** Used to detect binary string values. */
  18002. var reIsBinary = /^0b[01]+$/i;
  18003. /** Used to detect host constructors (Safari). */
  18004. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  18005. /** Used to detect octal string values. */
  18006. var reIsOctal = /^0o[0-7]+$/i;
  18007. /** Used to detect unsigned integer values. */
  18008. var reIsUint = /^(?:0|[1-9]\d*)$/;
  18009. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  18010. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  18011. /** Used to ensure capturing order of template delimiters. */
  18012. var reNoMatch = /($^)/;
  18013. /** Used to match unescaped characters in compiled string literals. */
  18014. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  18015. /** Used to compose unicode character classes. */
  18016. var rsAstralRange = '\\ud800-\\udfff',
  18017. rsComboMarksRange = '\\u0300-\\u036f',
  18018. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  18019. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  18020. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  18021. rsDingbatRange = '\\u2700-\\u27bf',
  18022. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  18023. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  18024. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  18025. rsPunctuationRange = '\\u2000-\\u206f',
  18026. 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',
  18027. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  18028. rsVarRange = '\\ufe0e\\ufe0f',
  18029. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  18030. /** Used to compose unicode capture groups. */
  18031. var rsApos = "['\u2019]",
  18032. rsAstral = '[' + rsAstralRange + ']',
  18033. rsBreak = '[' + rsBreakRange + ']',
  18034. rsCombo = '[' + rsComboRange + ']',
  18035. rsDigits = '\\d+',
  18036. rsDingbat = '[' + rsDingbatRange + ']',
  18037. rsLower = '[' + rsLowerRange + ']',
  18038. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  18039. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  18040. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  18041. rsNonAstral = '[^' + rsAstralRange + ']',
  18042. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  18043. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  18044. rsUpper = '[' + rsUpperRange + ']',
  18045. rsZWJ = '\\u200d';
  18046. /** Used to compose unicode regexes. */
  18047. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  18048. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  18049. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  18050. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  18051. reOptMod = rsModifier + '?',
  18052. rsOptVar = '[' + rsVarRange + ']?',
  18053. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  18054. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  18055. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  18056. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  18057. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  18058. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  18059. /** Used to match apostrophes. */
  18060. var reApos = RegExp(rsApos, 'g');
  18061. /**
  18062. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  18063. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  18064. */
  18065. var reComboMark = RegExp(rsCombo, 'g');
  18066. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  18067. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  18068. /** Used to match complex or compound words. */
  18069. var reUnicodeWord = RegExp([
  18070. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  18071. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  18072. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  18073. rsUpper + '+' + rsOptContrUpper,
  18074. rsOrdUpper,
  18075. rsOrdLower,
  18076. rsDigits,
  18077. rsEmoji
  18078. ].join('|'), 'g');
  18079. /** 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/). */
  18080. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  18081. /** Used to detect strings that need a more robust regexp to match words. */
  18082. 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 ]/;
  18083. /** Used to assign default `context` object properties. */
  18084. var contextProps = [
  18085. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  18086. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  18087. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  18088. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  18089. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  18090. ];
  18091. /** Used to make template sourceURLs easier to identify. */
  18092. var templateCounter = -1;
  18093. /** Used to identify `toStringTag` values of typed arrays. */
  18094. var typedArrayTags = {};
  18095. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  18096. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  18097. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  18098. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  18099. typedArrayTags[uint32Tag] = true;
  18100. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  18101. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  18102. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  18103. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  18104. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  18105. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  18106. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  18107. typedArrayTags[weakMapTag] = false;
  18108. /** Used to identify `toStringTag` values supported by `_.clone`. */
  18109. var cloneableTags = {};
  18110. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18111. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18112. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18113. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18114. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18115. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18116. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18117. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18118. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18119. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18120. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18121. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18122. cloneableTags[weakMapTag] = false;
  18123. /** Used to map Latin Unicode letters to basic Latin letters. */
  18124. var deburredLetters = {
  18125. // Latin-1 Supplement block.
  18126. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18127. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18128. '\xc7': 'C', '\xe7': 'c',
  18129. '\xd0': 'D', '\xf0': 'd',
  18130. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18131. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18132. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18133. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18134. '\xd1': 'N', '\xf1': 'n',
  18135. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18136. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18137. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18138. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18139. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18140. '\xc6': 'Ae', '\xe6': 'ae',
  18141. '\xde': 'Th', '\xfe': 'th',
  18142. '\xdf': 'ss',
  18143. // Latin Extended-A block.
  18144. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18145. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18146. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18147. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18148. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18149. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18150. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18151. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18152. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18153. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18154. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18155. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18156. '\u0134': 'J', '\u0135': 'j',
  18157. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18158. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18159. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18160. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18161. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18162. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18163. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18164. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18165. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18166. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18167. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18168. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18169. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18170. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18171. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18172. '\u0174': 'W', '\u0175': 'w',
  18173. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18174. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18175. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18176. '\u0132': 'IJ', '\u0133': 'ij',
  18177. '\u0152': 'Oe', '\u0153': 'oe',
  18178. '\u0149': "'n", '\u017f': 's'
  18179. };
  18180. /** Used to map characters to HTML entities. */
  18181. var htmlEscapes = {
  18182. '&': '&amp;',
  18183. '<': '&lt;',
  18184. '>': '&gt;',
  18185. '"': '&quot;',
  18186. "'": '&#39;'
  18187. };
  18188. /** Used to map HTML entities to characters. */
  18189. var htmlUnescapes = {
  18190. '&amp;': '&',
  18191. '&lt;': '<',
  18192. '&gt;': '>',
  18193. '&quot;': '"',
  18194. '&#39;': "'"
  18195. };
  18196. /** Used to escape characters for inclusion in compiled string literals. */
  18197. var stringEscapes = {
  18198. '\\': '\\',
  18199. "'": "'",
  18200. '\n': 'n',
  18201. '\r': 'r',
  18202. '\u2028': 'u2028',
  18203. '\u2029': 'u2029'
  18204. };
  18205. /** Built-in method references without a dependency on `root`. */
  18206. var freeParseFloat = parseFloat,
  18207. freeParseInt = parseInt;
  18208. /** Detect free variable `global` from Node.js. */
  18209. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18210. /** Detect free variable `self`. */
  18211. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18212. /** Used as a reference to the global object. */
  18213. var root = freeGlobal || freeSelf || Function('return this')();
  18214. /** Detect free variable `exports`. */
  18215. var freeExports = true && exports && !exports.nodeType && exports;
  18216. /** Detect free variable `module`. */
  18217. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18218. /** Detect the popular CommonJS extension `module.exports`. */
  18219. var moduleExports = freeModule && freeModule.exports === freeExports;
  18220. /** Detect free variable `process` from Node.js. */
  18221. var freeProcess = moduleExports && freeGlobal.process;
  18222. /** Used to access faster Node.js helpers. */
  18223. var nodeUtil = (function() {
  18224. try {
  18225. // Use `util.types` for Node.js 10+.
  18226. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18227. if (types) {
  18228. return types;
  18229. }
  18230. // Legacy `process.binding('util')` for Node.js < 10.
  18231. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18232. } catch (e) {}
  18233. }());
  18234. /* Node.js helper references. */
  18235. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18236. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18237. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18238. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18239. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18240. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18241. /*--------------------------------------------------------------------------*/
  18242. /**
  18243. * A faster alternative to `Function#apply`, this function invokes `func`
  18244. * with the `this` binding of `thisArg` and the arguments of `args`.
  18245. *
  18246. * @private
  18247. * @param {Function} func The function to invoke.
  18248. * @param {*} thisArg The `this` binding of `func`.
  18249. * @param {Array} args The arguments to invoke `func` with.
  18250. * @returns {*} Returns the result of `func`.
  18251. */
  18252. function apply(func, thisArg, args) {
  18253. switch (args.length) {
  18254. case 0: return func.call(thisArg);
  18255. case 1: return func.call(thisArg, args[0]);
  18256. case 2: return func.call(thisArg, args[0], args[1]);
  18257. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18258. }
  18259. return func.apply(thisArg, args);
  18260. }
  18261. /**
  18262. * A specialized version of `baseAggregator` for arrays.
  18263. *
  18264. * @private
  18265. * @param {Array} [array] The array to iterate over.
  18266. * @param {Function} setter The function to set `accumulator` values.
  18267. * @param {Function} iteratee The iteratee to transform keys.
  18268. * @param {Object} accumulator The initial aggregated object.
  18269. * @returns {Function} Returns `accumulator`.
  18270. */
  18271. function arrayAggregator(array, setter, iteratee, accumulator) {
  18272. var index = -1,
  18273. length = array == null ? 0 : array.length;
  18274. while (++index < length) {
  18275. var value = array[index];
  18276. setter(accumulator, value, iteratee(value), array);
  18277. }
  18278. return accumulator;
  18279. }
  18280. /**
  18281. * A specialized version of `_.forEach` for arrays without support for
  18282. * iteratee shorthands.
  18283. *
  18284. * @private
  18285. * @param {Array} [array] The array to iterate over.
  18286. * @param {Function} iteratee The function invoked per iteration.
  18287. * @returns {Array} Returns `array`.
  18288. */
  18289. function arrayEach(array, iteratee) {
  18290. var index = -1,
  18291. length = array == null ? 0 : array.length;
  18292. while (++index < length) {
  18293. if (iteratee(array[index], index, array) === false) {
  18294. break;
  18295. }
  18296. }
  18297. return array;
  18298. }
  18299. /**
  18300. * A specialized version of `_.forEachRight` for arrays without support for
  18301. * iteratee shorthands.
  18302. *
  18303. * @private
  18304. * @param {Array} [array] The array to iterate over.
  18305. * @param {Function} iteratee The function invoked per iteration.
  18306. * @returns {Array} Returns `array`.
  18307. */
  18308. function arrayEachRight(array, iteratee) {
  18309. var length = array == null ? 0 : array.length;
  18310. while (length--) {
  18311. if (iteratee(array[length], length, array) === false) {
  18312. break;
  18313. }
  18314. }
  18315. return array;
  18316. }
  18317. /**
  18318. * A specialized version of `_.every` for arrays without support for
  18319. * iteratee shorthands.
  18320. *
  18321. * @private
  18322. * @param {Array} [array] The array to iterate over.
  18323. * @param {Function} predicate The function invoked per iteration.
  18324. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18325. * else `false`.
  18326. */
  18327. function arrayEvery(array, predicate) {
  18328. var index = -1,
  18329. length = array == null ? 0 : array.length;
  18330. while (++index < length) {
  18331. if (!predicate(array[index], index, array)) {
  18332. return false;
  18333. }
  18334. }
  18335. return true;
  18336. }
  18337. /**
  18338. * A specialized version of `_.filter` for arrays without support for
  18339. * iteratee shorthands.
  18340. *
  18341. * @private
  18342. * @param {Array} [array] The array to iterate over.
  18343. * @param {Function} predicate The function invoked per iteration.
  18344. * @returns {Array} Returns the new filtered array.
  18345. */
  18346. function arrayFilter(array, predicate) {
  18347. var index = -1,
  18348. length = array == null ? 0 : array.length,
  18349. resIndex = 0,
  18350. result = [];
  18351. while (++index < length) {
  18352. var value = array[index];
  18353. if (predicate(value, index, array)) {
  18354. result[resIndex++] = value;
  18355. }
  18356. }
  18357. return result;
  18358. }
  18359. /**
  18360. * A specialized version of `_.includes` for arrays without support for
  18361. * specifying an index to search from.
  18362. *
  18363. * @private
  18364. * @param {Array} [array] The array to inspect.
  18365. * @param {*} target The value to search for.
  18366. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18367. */
  18368. function arrayIncludes(array, value) {
  18369. var length = array == null ? 0 : array.length;
  18370. return !!length && baseIndexOf(array, value, 0) > -1;
  18371. }
  18372. /**
  18373. * This function is like `arrayIncludes` except that it accepts a comparator.
  18374. *
  18375. * @private
  18376. * @param {Array} [array] The array to inspect.
  18377. * @param {*} target The value to search for.
  18378. * @param {Function} comparator The comparator invoked per element.
  18379. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18380. */
  18381. function arrayIncludesWith(array, value, comparator) {
  18382. var index = -1,
  18383. length = array == null ? 0 : array.length;
  18384. while (++index < length) {
  18385. if (comparator(value, array[index])) {
  18386. return true;
  18387. }
  18388. }
  18389. return false;
  18390. }
  18391. /**
  18392. * A specialized version of `_.map` for arrays without support for iteratee
  18393. * shorthands.
  18394. *
  18395. * @private
  18396. * @param {Array} [array] The array to iterate over.
  18397. * @param {Function} iteratee The function invoked per iteration.
  18398. * @returns {Array} Returns the new mapped array.
  18399. */
  18400. function arrayMap(array, iteratee) {
  18401. var index = -1,
  18402. length = array == null ? 0 : array.length,
  18403. result = Array(length);
  18404. while (++index < length) {
  18405. result[index] = iteratee(array[index], index, array);
  18406. }
  18407. return result;
  18408. }
  18409. /**
  18410. * Appends the elements of `values` to `array`.
  18411. *
  18412. * @private
  18413. * @param {Array} array The array to modify.
  18414. * @param {Array} values The values to append.
  18415. * @returns {Array} Returns `array`.
  18416. */
  18417. function arrayPush(array, values) {
  18418. var index = -1,
  18419. length = values.length,
  18420. offset = array.length;
  18421. while (++index < length) {
  18422. array[offset + index] = values[index];
  18423. }
  18424. return array;
  18425. }
  18426. /**
  18427. * A specialized version of `_.reduce` for arrays without support for
  18428. * iteratee shorthands.
  18429. *
  18430. * @private
  18431. * @param {Array} [array] The array to iterate over.
  18432. * @param {Function} iteratee The function invoked per iteration.
  18433. * @param {*} [accumulator] The initial value.
  18434. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18435. * the initial value.
  18436. * @returns {*} Returns the accumulated value.
  18437. */
  18438. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18439. var index = -1,
  18440. length = array == null ? 0 : array.length;
  18441. if (initAccum && length) {
  18442. accumulator = array[++index];
  18443. }
  18444. while (++index < length) {
  18445. accumulator = iteratee(accumulator, array[index], index, array);
  18446. }
  18447. return accumulator;
  18448. }
  18449. /**
  18450. * A specialized version of `_.reduceRight` for arrays without support for
  18451. * iteratee shorthands.
  18452. *
  18453. * @private
  18454. * @param {Array} [array] The array to iterate over.
  18455. * @param {Function} iteratee The function invoked per iteration.
  18456. * @param {*} [accumulator] The initial value.
  18457. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18458. * the initial value.
  18459. * @returns {*} Returns the accumulated value.
  18460. */
  18461. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18462. var length = array == null ? 0 : array.length;
  18463. if (initAccum && length) {
  18464. accumulator = array[--length];
  18465. }
  18466. while (length--) {
  18467. accumulator = iteratee(accumulator, array[length], length, array);
  18468. }
  18469. return accumulator;
  18470. }
  18471. /**
  18472. * A specialized version of `_.some` for arrays without support for iteratee
  18473. * shorthands.
  18474. *
  18475. * @private
  18476. * @param {Array} [array] The array to iterate over.
  18477. * @param {Function} predicate The function invoked per iteration.
  18478. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18479. * else `false`.
  18480. */
  18481. function arraySome(array, predicate) {
  18482. var index = -1,
  18483. length = array == null ? 0 : array.length;
  18484. while (++index < length) {
  18485. if (predicate(array[index], index, array)) {
  18486. return true;
  18487. }
  18488. }
  18489. return false;
  18490. }
  18491. /**
  18492. * Gets the size of an ASCII `string`.
  18493. *
  18494. * @private
  18495. * @param {string} string The string inspect.
  18496. * @returns {number} Returns the string size.
  18497. */
  18498. var asciiSize = baseProperty('length');
  18499. /**
  18500. * Converts an ASCII `string` to an array.
  18501. *
  18502. * @private
  18503. * @param {string} string The string to convert.
  18504. * @returns {Array} Returns the converted array.
  18505. */
  18506. function asciiToArray(string) {
  18507. return string.split('');
  18508. }
  18509. /**
  18510. * Splits an ASCII `string` into an array of its words.
  18511. *
  18512. * @private
  18513. * @param {string} The string to inspect.
  18514. * @returns {Array} Returns the words of `string`.
  18515. */
  18516. function asciiWords(string) {
  18517. return string.match(reAsciiWord) || [];
  18518. }
  18519. /**
  18520. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18521. * without support for iteratee shorthands, which iterates over `collection`
  18522. * using `eachFunc`.
  18523. *
  18524. * @private
  18525. * @param {Array|Object} collection The collection to inspect.
  18526. * @param {Function} predicate The function invoked per iteration.
  18527. * @param {Function} eachFunc The function to iterate over `collection`.
  18528. * @returns {*} Returns the found element or its key, else `undefined`.
  18529. */
  18530. function baseFindKey(collection, predicate, eachFunc) {
  18531. var result;
  18532. eachFunc(collection, function(value, key, collection) {
  18533. if (predicate(value, key, collection)) {
  18534. result = key;
  18535. return false;
  18536. }
  18537. });
  18538. return result;
  18539. }
  18540. /**
  18541. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18542. * support for iteratee shorthands.
  18543. *
  18544. * @private
  18545. * @param {Array} array The array to inspect.
  18546. * @param {Function} predicate The function invoked per iteration.
  18547. * @param {number} fromIndex The index to search from.
  18548. * @param {boolean} [fromRight] Specify iterating from right to left.
  18549. * @returns {number} Returns the index of the matched value, else `-1`.
  18550. */
  18551. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18552. var length = array.length,
  18553. index = fromIndex + (fromRight ? 1 : -1);
  18554. while ((fromRight ? index-- : ++index < length)) {
  18555. if (predicate(array[index], index, array)) {
  18556. return index;
  18557. }
  18558. }
  18559. return -1;
  18560. }
  18561. /**
  18562. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18563. *
  18564. * @private
  18565. * @param {Array} array The array to inspect.
  18566. * @param {*} value The value to search for.
  18567. * @param {number} fromIndex The index to search from.
  18568. * @returns {number} Returns the index of the matched value, else `-1`.
  18569. */
  18570. function baseIndexOf(array, value, fromIndex) {
  18571. return value === value
  18572. ? strictIndexOf(array, value, fromIndex)
  18573. : baseFindIndex(array, baseIsNaN, fromIndex);
  18574. }
  18575. /**
  18576. * This function is like `baseIndexOf` except that it accepts a comparator.
  18577. *
  18578. * @private
  18579. * @param {Array} array The array to inspect.
  18580. * @param {*} value The value to search for.
  18581. * @param {number} fromIndex The index to search from.
  18582. * @param {Function} comparator The comparator invoked per element.
  18583. * @returns {number} Returns the index of the matched value, else `-1`.
  18584. */
  18585. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18586. var index = fromIndex - 1,
  18587. length = array.length;
  18588. while (++index < length) {
  18589. if (comparator(array[index], value)) {
  18590. return index;
  18591. }
  18592. }
  18593. return -1;
  18594. }
  18595. /**
  18596. * The base implementation of `_.isNaN` without support for number objects.
  18597. *
  18598. * @private
  18599. * @param {*} value The value to check.
  18600. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18601. */
  18602. function baseIsNaN(value) {
  18603. return value !== value;
  18604. }
  18605. /**
  18606. * The base implementation of `_.mean` and `_.meanBy` without support for
  18607. * iteratee shorthands.
  18608. *
  18609. * @private
  18610. * @param {Array} array The array to iterate over.
  18611. * @param {Function} iteratee The function invoked per iteration.
  18612. * @returns {number} Returns the mean.
  18613. */
  18614. function baseMean(array, iteratee) {
  18615. var length = array == null ? 0 : array.length;
  18616. return length ? (baseSum(array, iteratee) / length) : NAN;
  18617. }
  18618. /**
  18619. * The base implementation of `_.property` without support for deep paths.
  18620. *
  18621. * @private
  18622. * @param {string} key The key of the property to get.
  18623. * @returns {Function} Returns the new accessor function.
  18624. */
  18625. function baseProperty(key) {
  18626. return function(object) {
  18627. return object == null ? undefined : object[key];
  18628. };
  18629. }
  18630. /**
  18631. * The base implementation of `_.propertyOf` without support for deep paths.
  18632. *
  18633. * @private
  18634. * @param {Object} object The object to query.
  18635. * @returns {Function} Returns the new accessor function.
  18636. */
  18637. function basePropertyOf(object) {
  18638. return function(key) {
  18639. return object == null ? undefined : object[key];
  18640. };
  18641. }
  18642. /**
  18643. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18644. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18645. *
  18646. * @private
  18647. * @param {Array|Object} collection The collection to iterate over.
  18648. * @param {Function} iteratee The function invoked per iteration.
  18649. * @param {*} accumulator The initial value.
  18650. * @param {boolean} initAccum Specify using the first or last element of
  18651. * `collection` as the initial value.
  18652. * @param {Function} eachFunc The function to iterate over `collection`.
  18653. * @returns {*} Returns the accumulated value.
  18654. */
  18655. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18656. eachFunc(collection, function(value, index, collection) {
  18657. accumulator = initAccum
  18658. ? (initAccum = false, value)
  18659. : iteratee(accumulator, value, index, collection);
  18660. });
  18661. return accumulator;
  18662. }
  18663. /**
  18664. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18665. * sort order of `array` and replaces criteria objects with their corresponding
  18666. * values.
  18667. *
  18668. * @private
  18669. * @param {Array} array The array to sort.
  18670. * @param {Function} comparer The function to define sort order.
  18671. * @returns {Array} Returns `array`.
  18672. */
  18673. function baseSortBy(array, comparer) {
  18674. var length = array.length;
  18675. array.sort(comparer);
  18676. while (length--) {
  18677. array[length] = array[length].value;
  18678. }
  18679. return array;
  18680. }
  18681. /**
  18682. * The base implementation of `_.sum` and `_.sumBy` without support for
  18683. * iteratee shorthands.
  18684. *
  18685. * @private
  18686. * @param {Array} array The array to iterate over.
  18687. * @param {Function} iteratee The function invoked per iteration.
  18688. * @returns {number} Returns the sum.
  18689. */
  18690. function baseSum(array, iteratee) {
  18691. var result,
  18692. index = -1,
  18693. length = array.length;
  18694. while (++index < length) {
  18695. var current = iteratee(array[index]);
  18696. if (current !== undefined) {
  18697. result = result === undefined ? current : (result + current);
  18698. }
  18699. }
  18700. return result;
  18701. }
  18702. /**
  18703. * The base implementation of `_.times` without support for iteratee shorthands
  18704. * or max array length checks.
  18705. *
  18706. * @private
  18707. * @param {number} n The number of times to invoke `iteratee`.
  18708. * @param {Function} iteratee The function invoked per iteration.
  18709. * @returns {Array} Returns the array of results.
  18710. */
  18711. function baseTimes(n, iteratee) {
  18712. var index = -1,
  18713. result = Array(n);
  18714. while (++index < n) {
  18715. result[index] = iteratee(index);
  18716. }
  18717. return result;
  18718. }
  18719. /**
  18720. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18721. * of key-value pairs for `object` corresponding to the property names of `props`.
  18722. *
  18723. * @private
  18724. * @param {Object} object The object to query.
  18725. * @param {Array} props The property names to get values for.
  18726. * @returns {Object} Returns the key-value pairs.
  18727. */
  18728. function baseToPairs(object, props) {
  18729. return arrayMap(props, function(key) {
  18730. return [key, object[key]];
  18731. });
  18732. }
  18733. /**
  18734. * The base implementation of `_.unary` without support for storing metadata.
  18735. *
  18736. * @private
  18737. * @param {Function} func The function to cap arguments for.
  18738. * @returns {Function} Returns the new capped function.
  18739. */
  18740. function baseUnary(func) {
  18741. return function(value) {
  18742. return func(value);
  18743. };
  18744. }
  18745. /**
  18746. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18747. * array of `object` property values corresponding to the property names
  18748. * of `props`.
  18749. *
  18750. * @private
  18751. * @param {Object} object The object to query.
  18752. * @param {Array} props The property names to get values for.
  18753. * @returns {Object} Returns the array of property values.
  18754. */
  18755. function baseValues(object, props) {
  18756. return arrayMap(props, function(key) {
  18757. return object[key];
  18758. });
  18759. }
  18760. /**
  18761. * Checks if a `cache` value for `key` exists.
  18762. *
  18763. * @private
  18764. * @param {Object} cache The cache to query.
  18765. * @param {string} key The key of the entry to check.
  18766. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18767. */
  18768. function cacheHas(cache, key) {
  18769. return cache.has(key);
  18770. }
  18771. /**
  18772. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18773. * that is not found in the character symbols.
  18774. *
  18775. * @private
  18776. * @param {Array} strSymbols The string symbols to inspect.
  18777. * @param {Array} chrSymbols The character symbols to find.
  18778. * @returns {number} Returns the index of the first unmatched string symbol.
  18779. */
  18780. function charsStartIndex(strSymbols, chrSymbols) {
  18781. var index = -1,
  18782. length = strSymbols.length;
  18783. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18784. return index;
  18785. }
  18786. /**
  18787. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18788. * that is not found in the character symbols.
  18789. *
  18790. * @private
  18791. * @param {Array} strSymbols The string symbols to inspect.
  18792. * @param {Array} chrSymbols The character symbols to find.
  18793. * @returns {number} Returns the index of the last unmatched string symbol.
  18794. */
  18795. function charsEndIndex(strSymbols, chrSymbols) {
  18796. var index = strSymbols.length;
  18797. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18798. return index;
  18799. }
  18800. /**
  18801. * Gets the number of `placeholder` occurrences in `array`.
  18802. *
  18803. * @private
  18804. * @param {Array} array The array to inspect.
  18805. * @param {*} placeholder The placeholder to search for.
  18806. * @returns {number} Returns the placeholder count.
  18807. */
  18808. function countHolders(array, placeholder) {
  18809. var length = array.length,
  18810. result = 0;
  18811. while (length--) {
  18812. if (array[length] === placeholder) {
  18813. ++result;
  18814. }
  18815. }
  18816. return result;
  18817. }
  18818. /**
  18819. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18820. * letters to basic Latin letters.
  18821. *
  18822. * @private
  18823. * @param {string} letter The matched letter to deburr.
  18824. * @returns {string} Returns the deburred letter.
  18825. */
  18826. var deburrLetter = basePropertyOf(deburredLetters);
  18827. /**
  18828. * Used by `_.escape` to convert characters to HTML entities.
  18829. *
  18830. * @private
  18831. * @param {string} chr The matched character to escape.
  18832. * @returns {string} Returns the escaped character.
  18833. */
  18834. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18835. /**
  18836. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18837. *
  18838. * @private
  18839. * @param {string} chr The matched character to escape.
  18840. * @returns {string} Returns the escaped character.
  18841. */
  18842. function escapeStringChar(chr) {
  18843. return '\\' + stringEscapes[chr];
  18844. }
  18845. /**
  18846. * Gets the value at `key` of `object`.
  18847. *
  18848. * @private
  18849. * @param {Object} [object] The object to query.
  18850. * @param {string} key The key of the property to get.
  18851. * @returns {*} Returns the property value.
  18852. */
  18853. function getValue(object, key) {
  18854. return object == null ? undefined : object[key];
  18855. }
  18856. /**
  18857. * Checks if `string` contains Unicode symbols.
  18858. *
  18859. * @private
  18860. * @param {string} string The string to inspect.
  18861. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18862. */
  18863. function hasUnicode(string) {
  18864. return reHasUnicode.test(string);
  18865. }
  18866. /**
  18867. * Checks if `string` contains a word composed of Unicode symbols.
  18868. *
  18869. * @private
  18870. * @param {string} string The string to inspect.
  18871. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18872. */
  18873. function hasUnicodeWord(string) {
  18874. return reHasUnicodeWord.test(string);
  18875. }
  18876. /**
  18877. * Converts `iterator` to an array.
  18878. *
  18879. * @private
  18880. * @param {Object} iterator The iterator to convert.
  18881. * @returns {Array} Returns the converted array.
  18882. */
  18883. function iteratorToArray(iterator) {
  18884. var data,
  18885. result = [];
  18886. while (!(data = iterator.next()).done) {
  18887. result.push(data.value);
  18888. }
  18889. return result;
  18890. }
  18891. /**
  18892. * Converts `map` to its key-value pairs.
  18893. *
  18894. * @private
  18895. * @param {Object} map The map to convert.
  18896. * @returns {Array} Returns the key-value pairs.
  18897. */
  18898. function mapToArray(map) {
  18899. var index = -1,
  18900. result = Array(map.size);
  18901. map.forEach(function(value, key) {
  18902. result[++index] = [key, value];
  18903. });
  18904. return result;
  18905. }
  18906. /**
  18907. * Creates a unary function that invokes `func` with its argument transformed.
  18908. *
  18909. * @private
  18910. * @param {Function} func The function to wrap.
  18911. * @param {Function} transform The argument transform.
  18912. * @returns {Function} Returns the new function.
  18913. */
  18914. function overArg(func, transform) {
  18915. return function(arg) {
  18916. return func(transform(arg));
  18917. };
  18918. }
  18919. /**
  18920. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18921. * and returns an array of their indexes.
  18922. *
  18923. * @private
  18924. * @param {Array} array The array to modify.
  18925. * @param {*} placeholder The placeholder to replace.
  18926. * @returns {Array} Returns the new array of placeholder indexes.
  18927. */
  18928. function replaceHolders(array, placeholder) {
  18929. var index = -1,
  18930. length = array.length,
  18931. resIndex = 0,
  18932. result = [];
  18933. while (++index < length) {
  18934. var value = array[index];
  18935. if (value === placeholder || value === PLACEHOLDER) {
  18936. array[index] = PLACEHOLDER;
  18937. result[resIndex++] = index;
  18938. }
  18939. }
  18940. return result;
  18941. }
  18942. /**
  18943. * Converts `set` to an array of its values.
  18944. *
  18945. * @private
  18946. * @param {Object} set The set to convert.
  18947. * @returns {Array} Returns the values.
  18948. */
  18949. function setToArray(set) {
  18950. var index = -1,
  18951. result = Array(set.size);
  18952. set.forEach(function(value) {
  18953. result[++index] = value;
  18954. });
  18955. return result;
  18956. }
  18957. /**
  18958. * Converts `set` to its value-value pairs.
  18959. *
  18960. * @private
  18961. * @param {Object} set The set to convert.
  18962. * @returns {Array} Returns the value-value pairs.
  18963. */
  18964. function setToPairs(set) {
  18965. var index = -1,
  18966. result = Array(set.size);
  18967. set.forEach(function(value) {
  18968. result[++index] = [value, value];
  18969. });
  18970. return result;
  18971. }
  18972. /**
  18973. * A specialized version of `_.indexOf` which performs strict equality
  18974. * comparisons of values, i.e. `===`.
  18975. *
  18976. * @private
  18977. * @param {Array} array The array to inspect.
  18978. * @param {*} value The value to search for.
  18979. * @param {number} fromIndex The index to search from.
  18980. * @returns {number} Returns the index of the matched value, else `-1`.
  18981. */
  18982. function strictIndexOf(array, value, fromIndex) {
  18983. var index = fromIndex - 1,
  18984. length = array.length;
  18985. while (++index < length) {
  18986. if (array[index] === value) {
  18987. return index;
  18988. }
  18989. }
  18990. return -1;
  18991. }
  18992. /**
  18993. * A specialized version of `_.lastIndexOf` which performs strict equality
  18994. * comparisons of values, i.e. `===`.
  18995. *
  18996. * @private
  18997. * @param {Array} array The array to inspect.
  18998. * @param {*} value The value to search for.
  18999. * @param {number} fromIndex The index to search from.
  19000. * @returns {number} Returns the index of the matched value, else `-1`.
  19001. */
  19002. function strictLastIndexOf(array, value, fromIndex) {
  19003. var index = fromIndex + 1;
  19004. while (index--) {
  19005. if (array[index] === value) {
  19006. return index;
  19007. }
  19008. }
  19009. return index;
  19010. }
  19011. /**
  19012. * Gets the number of symbols in `string`.
  19013. *
  19014. * @private
  19015. * @param {string} string The string to inspect.
  19016. * @returns {number} Returns the string size.
  19017. */
  19018. function stringSize(string) {
  19019. return hasUnicode(string)
  19020. ? unicodeSize(string)
  19021. : asciiSize(string);
  19022. }
  19023. /**
  19024. * Converts `string` to an array.
  19025. *
  19026. * @private
  19027. * @param {string} string The string to convert.
  19028. * @returns {Array} Returns the converted array.
  19029. */
  19030. function stringToArray(string) {
  19031. return hasUnicode(string)
  19032. ? unicodeToArray(string)
  19033. : asciiToArray(string);
  19034. }
  19035. /**
  19036. * Used by `_.unescape` to convert HTML entities to characters.
  19037. *
  19038. * @private
  19039. * @param {string} chr The matched character to unescape.
  19040. * @returns {string} Returns the unescaped character.
  19041. */
  19042. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  19043. /**
  19044. * Gets the size of a Unicode `string`.
  19045. *
  19046. * @private
  19047. * @param {string} string The string inspect.
  19048. * @returns {number} Returns the string size.
  19049. */
  19050. function unicodeSize(string) {
  19051. var result = reUnicode.lastIndex = 0;
  19052. while (reUnicode.test(string)) {
  19053. ++result;
  19054. }
  19055. return result;
  19056. }
  19057. /**
  19058. * Converts a Unicode `string` to an array.
  19059. *
  19060. * @private
  19061. * @param {string} string The string to convert.
  19062. * @returns {Array} Returns the converted array.
  19063. */
  19064. function unicodeToArray(string) {
  19065. return string.match(reUnicode) || [];
  19066. }
  19067. /**
  19068. * Splits a Unicode `string` into an array of its words.
  19069. *
  19070. * @private
  19071. * @param {string} The string to inspect.
  19072. * @returns {Array} Returns the words of `string`.
  19073. */
  19074. function unicodeWords(string) {
  19075. return string.match(reUnicodeWord) || [];
  19076. }
  19077. /*--------------------------------------------------------------------------*/
  19078. /**
  19079. * Create a new pristine `lodash` function using the `context` object.
  19080. *
  19081. * @static
  19082. * @memberOf _
  19083. * @since 1.1.0
  19084. * @category Util
  19085. * @param {Object} [context=root] The context object.
  19086. * @returns {Function} Returns a new `lodash` function.
  19087. * @example
  19088. *
  19089. * _.mixin({ 'foo': _.constant('foo') });
  19090. *
  19091. * var lodash = _.runInContext();
  19092. * lodash.mixin({ 'bar': lodash.constant('bar') });
  19093. *
  19094. * _.isFunction(_.foo);
  19095. * // => true
  19096. * _.isFunction(_.bar);
  19097. * // => false
  19098. *
  19099. * lodash.isFunction(lodash.foo);
  19100. * // => false
  19101. * lodash.isFunction(lodash.bar);
  19102. * // => true
  19103. *
  19104. * // Create a suped-up `defer` in Node.js.
  19105. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  19106. */
  19107. var runInContext = (function runInContext(context) {
  19108. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  19109. /** Built-in constructor references. */
  19110. var Array = context.Array,
  19111. Date = context.Date,
  19112. Error = context.Error,
  19113. Function = context.Function,
  19114. Math = context.Math,
  19115. Object = context.Object,
  19116. RegExp = context.RegExp,
  19117. String = context.String,
  19118. TypeError = context.TypeError;
  19119. /** Used for built-in method references. */
  19120. var arrayProto = Array.prototype,
  19121. funcProto = Function.prototype,
  19122. objectProto = Object.prototype;
  19123. /** Used to detect overreaching core-js shims. */
  19124. var coreJsData = context['__core-js_shared__'];
  19125. /** Used to resolve the decompiled source of functions. */
  19126. var funcToString = funcProto.toString;
  19127. /** Used to check objects for own properties. */
  19128. var hasOwnProperty = objectProto.hasOwnProperty;
  19129. /** Used to generate unique IDs. */
  19130. var idCounter = 0;
  19131. /** Used to detect methods masquerading as native. */
  19132. var maskSrcKey = (function() {
  19133. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19134. return uid ? ('Symbol(src)_1.' + uid) : '';
  19135. }());
  19136. /**
  19137. * Used to resolve the
  19138. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19139. * of values.
  19140. */
  19141. var nativeObjectToString = objectProto.toString;
  19142. /** Used to infer the `Object` constructor. */
  19143. var objectCtorString = funcToString.call(Object);
  19144. /** Used to restore the original `_` reference in `_.noConflict`. */
  19145. var oldDash = root._;
  19146. /** Used to detect if a method is native. */
  19147. var reIsNative = RegExp('^' +
  19148. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19149. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19150. );
  19151. /** Built-in value references. */
  19152. var Buffer = moduleExports ? context.Buffer : undefined,
  19153. Symbol = context.Symbol,
  19154. Uint8Array = context.Uint8Array,
  19155. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19156. getPrototype = overArg(Object.getPrototypeOf, Object),
  19157. objectCreate = Object.create,
  19158. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19159. splice = arrayProto.splice,
  19160. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19161. symIterator = Symbol ? Symbol.iterator : undefined,
  19162. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19163. var defineProperty = (function() {
  19164. try {
  19165. var func = getNative(Object, 'defineProperty');
  19166. func({}, '', {});
  19167. return func;
  19168. } catch (e) {}
  19169. }());
  19170. /** Mocked built-ins. */
  19171. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19172. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19173. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19174. /* Built-in method references for those with the same name as other `lodash` methods. */
  19175. var nativeCeil = Math.ceil,
  19176. nativeFloor = Math.floor,
  19177. nativeGetSymbols = Object.getOwnPropertySymbols,
  19178. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19179. nativeIsFinite = context.isFinite,
  19180. nativeJoin = arrayProto.join,
  19181. nativeKeys = overArg(Object.keys, Object),
  19182. nativeMax = Math.max,
  19183. nativeMin = Math.min,
  19184. nativeNow = Date.now,
  19185. nativeParseInt = context.parseInt,
  19186. nativeRandom = Math.random,
  19187. nativeReverse = arrayProto.reverse;
  19188. /* Built-in method references that are verified to be native. */
  19189. var DataView = getNative(context, 'DataView'),
  19190. Map = getNative(context, 'Map'),
  19191. Promise = getNative(context, 'Promise'),
  19192. Set = getNative(context, 'Set'),
  19193. WeakMap = getNative(context, 'WeakMap'),
  19194. nativeCreate = getNative(Object, 'create');
  19195. /** Used to store function metadata. */
  19196. var metaMap = WeakMap && new WeakMap;
  19197. /** Used to lookup unminified function names. */
  19198. var realNames = {};
  19199. /** Used to detect maps, sets, and weakmaps. */
  19200. var dataViewCtorString = toSource(DataView),
  19201. mapCtorString = toSource(Map),
  19202. promiseCtorString = toSource(Promise),
  19203. setCtorString = toSource(Set),
  19204. weakMapCtorString = toSource(WeakMap);
  19205. /** Used to convert symbols to primitives and strings. */
  19206. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19207. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19208. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19209. /*------------------------------------------------------------------------*/
  19210. /**
  19211. * Creates a `lodash` object which wraps `value` to enable implicit method
  19212. * chain sequences. Methods that operate on and return arrays, collections,
  19213. * and functions can be chained together. Methods that retrieve a single value
  19214. * or may return a primitive value will automatically end the chain sequence
  19215. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19216. * with `_#value`.
  19217. *
  19218. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19219. * enabled using `_.chain`.
  19220. *
  19221. * The execution of chained methods is lazy, that is, it's deferred until
  19222. * `_#value` is implicitly or explicitly called.
  19223. *
  19224. * Lazy evaluation allows several methods to support shortcut fusion.
  19225. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19226. * the creation of intermediate arrays and can greatly reduce the number of
  19227. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19228. * fusion if the section is applied to an array and iteratees accept only
  19229. * one argument. The heuristic for whether a section qualifies for shortcut
  19230. * fusion is subject to change.
  19231. *
  19232. * Chaining is supported in custom builds as long as the `_#value` method is
  19233. * directly or indirectly included in the build.
  19234. *
  19235. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19236. *
  19237. * The wrapper `Array` methods are:
  19238. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19239. *
  19240. * The wrapper `String` methods are:
  19241. * `replace` and `split`
  19242. *
  19243. * The wrapper methods that support shortcut fusion are:
  19244. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19245. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19246. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19247. *
  19248. * The chainable wrapper methods are:
  19249. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19250. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19251. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19252. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19253. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19254. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19255. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19256. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19257. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19258. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19259. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19260. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19261. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19262. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19263. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19264. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19265. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19266. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19267. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19268. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19269. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19270. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19271. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19272. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19273. *
  19274. * The wrapper methods that are **not** chainable by default are:
  19275. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19276. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19277. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19278. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19279. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19280. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19281. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19282. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19283. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19284. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19285. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19286. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19287. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19288. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19289. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19290. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19291. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19292. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19293. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19294. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19295. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19296. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19297. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19298. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19299. * `upperFirst`, `value`, and `words`
  19300. *
  19301. * @name _
  19302. * @constructor
  19303. * @category Seq
  19304. * @param {*} value The value to wrap in a `lodash` instance.
  19305. * @returns {Object} Returns the new `lodash` wrapper instance.
  19306. * @example
  19307. *
  19308. * function square(n) {
  19309. * return n * n;
  19310. * }
  19311. *
  19312. * var wrapped = _([1, 2, 3]);
  19313. *
  19314. * // Returns an unwrapped value.
  19315. * wrapped.reduce(_.add);
  19316. * // => 6
  19317. *
  19318. * // Returns a wrapped value.
  19319. * var squares = wrapped.map(square);
  19320. *
  19321. * _.isArray(squares);
  19322. * // => false
  19323. *
  19324. * _.isArray(squares.value());
  19325. * // => true
  19326. */
  19327. function lodash(value) {
  19328. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19329. if (value instanceof LodashWrapper) {
  19330. return value;
  19331. }
  19332. if (hasOwnProperty.call(value, '__wrapped__')) {
  19333. return wrapperClone(value);
  19334. }
  19335. }
  19336. return new LodashWrapper(value);
  19337. }
  19338. /**
  19339. * The base implementation of `_.create` without support for assigning
  19340. * properties to the created object.
  19341. *
  19342. * @private
  19343. * @param {Object} proto The object to inherit from.
  19344. * @returns {Object} Returns the new object.
  19345. */
  19346. var baseCreate = (function() {
  19347. function object() {}
  19348. return function(proto) {
  19349. if (!isObject(proto)) {
  19350. return {};
  19351. }
  19352. if (objectCreate) {
  19353. return objectCreate(proto);
  19354. }
  19355. object.prototype = proto;
  19356. var result = new object;
  19357. object.prototype = undefined;
  19358. return result;
  19359. };
  19360. }());
  19361. /**
  19362. * The function whose prototype chain sequence wrappers inherit from.
  19363. *
  19364. * @private
  19365. */
  19366. function baseLodash() {
  19367. // No operation performed.
  19368. }
  19369. /**
  19370. * The base constructor for creating `lodash` wrapper objects.
  19371. *
  19372. * @private
  19373. * @param {*} value The value to wrap.
  19374. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19375. */
  19376. function LodashWrapper(value, chainAll) {
  19377. this.__wrapped__ = value;
  19378. this.__actions__ = [];
  19379. this.__chain__ = !!chainAll;
  19380. this.__index__ = 0;
  19381. this.__values__ = undefined;
  19382. }
  19383. /**
  19384. * By default, the template delimiters used by lodash are like those in
  19385. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19386. * following template settings to use alternative delimiters.
  19387. *
  19388. * @static
  19389. * @memberOf _
  19390. * @type {Object}
  19391. */
  19392. lodash.templateSettings = {
  19393. /**
  19394. * Used to detect `data` property values to be HTML-escaped.
  19395. *
  19396. * @memberOf _.templateSettings
  19397. * @type {RegExp}
  19398. */
  19399. 'escape': reEscape,
  19400. /**
  19401. * Used to detect code to be evaluated.
  19402. *
  19403. * @memberOf _.templateSettings
  19404. * @type {RegExp}
  19405. */
  19406. 'evaluate': reEvaluate,
  19407. /**
  19408. * Used to detect `data` property values to inject.
  19409. *
  19410. * @memberOf _.templateSettings
  19411. * @type {RegExp}
  19412. */
  19413. 'interpolate': reInterpolate,
  19414. /**
  19415. * Used to reference the data object in the template text.
  19416. *
  19417. * @memberOf _.templateSettings
  19418. * @type {string}
  19419. */
  19420. 'variable': '',
  19421. /**
  19422. * Used to import variables into the compiled template.
  19423. *
  19424. * @memberOf _.templateSettings
  19425. * @type {Object}
  19426. */
  19427. 'imports': {
  19428. /**
  19429. * A reference to the `lodash` function.
  19430. *
  19431. * @memberOf _.templateSettings.imports
  19432. * @type {Function}
  19433. */
  19434. '_': lodash
  19435. }
  19436. };
  19437. // Ensure wrappers are instances of `baseLodash`.
  19438. lodash.prototype = baseLodash.prototype;
  19439. lodash.prototype.constructor = lodash;
  19440. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19441. LodashWrapper.prototype.constructor = LodashWrapper;
  19442. /*------------------------------------------------------------------------*/
  19443. /**
  19444. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19445. *
  19446. * @private
  19447. * @constructor
  19448. * @param {*} value The value to wrap.
  19449. */
  19450. function LazyWrapper(value) {
  19451. this.__wrapped__ = value;
  19452. this.__actions__ = [];
  19453. this.__dir__ = 1;
  19454. this.__filtered__ = false;
  19455. this.__iteratees__ = [];
  19456. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19457. this.__views__ = [];
  19458. }
  19459. /**
  19460. * Creates a clone of the lazy wrapper object.
  19461. *
  19462. * @private
  19463. * @name clone
  19464. * @memberOf LazyWrapper
  19465. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19466. */
  19467. function lazyClone() {
  19468. var result = new LazyWrapper(this.__wrapped__);
  19469. result.__actions__ = copyArray(this.__actions__);
  19470. result.__dir__ = this.__dir__;
  19471. result.__filtered__ = this.__filtered__;
  19472. result.__iteratees__ = copyArray(this.__iteratees__);
  19473. result.__takeCount__ = this.__takeCount__;
  19474. result.__views__ = copyArray(this.__views__);
  19475. return result;
  19476. }
  19477. /**
  19478. * Reverses the direction of lazy iteration.
  19479. *
  19480. * @private
  19481. * @name reverse
  19482. * @memberOf LazyWrapper
  19483. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19484. */
  19485. function lazyReverse() {
  19486. if (this.__filtered__) {
  19487. var result = new LazyWrapper(this);
  19488. result.__dir__ = -1;
  19489. result.__filtered__ = true;
  19490. } else {
  19491. result = this.clone();
  19492. result.__dir__ *= -1;
  19493. }
  19494. return result;
  19495. }
  19496. /**
  19497. * Extracts the unwrapped value from its lazy wrapper.
  19498. *
  19499. * @private
  19500. * @name value
  19501. * @memberOf LazyWrapper
  19502. * @returns {*} Returns the unwrapped value.
  19503. */
  19504. function lazyValue() {
  19505. var array = this.__wrapped__.value(),
  19506. dir = this.__dir__,
  19507. isArr = isArray(array),
  19508. isRight = dir < 0,
  19509. arrLength = isArr ? array.length : 0,
  19510. view = getView(0, arrLength, this.__views__),
  19511. start = view.start,
  19512. end = view.end,
  19513. length = end - start,
  19514. index = isRight ? end : (start - 1),
  19515. iteratees = this.__iteratees__,
  19516. iterLength = iteratees.length,
  19517. resIndex = 0,
  19518. takeCount = nativeMin(length, this.__takeCount__);
  19519. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19520. return baseWrapperValue(array, this.__actions__);
  19521. }
  19522. var result = [];
  19523. outer:
  19524. while (length-- && resIndex < takeCount) {
  19525. index += dir;
  19526. var iterIndex = -1,
  19527. value = array[index];
  19528. while (++iterIndex < iterLength) {
  19529. var data = iteratees[iterIndex],
  19530. iteratee = data.iteratee,
  19531. type = data.type,
  19532. computed = iteratee(value);
  19533. if (type == LAZY_MAP_FLAG) {
  19534. value = computed;
  19535. } else if (!computed) {
  19536. if (type == LAZY_FILTER_FLAG) {
  19537. continue outer;
  19538. } else {
  19539. break outer;
  19540. }
  19541. }
  19542. }
  19543. result[resIndex++] = value;
  19544. }
  19545. return result;
  19546. }
  19547. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19548. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19549. LazyWrapper.prototype.constructor = LazyWrapper;
  19550. /*------------------------------------------------------------------------*/
  19551. /**
  19552. * Creates a hash object.
  19553. *
  19554. * @private
  19555. * @constructor
  19556. * @param {Array} [entries] The key-value pairs to cache.
  19557. */
  19558. function Hash(entries) {
  19559. var index = -1,
  19560. length = entries == null ? 0 : entries.length;
  19561. this.clear();
  19562. while (++index < length) {
  19563. var entry = entries[index];
  19564. this.set(entry[0], entry[1]);
  19565. }
  19566. }
  19567. /**
  19568. * Removes all key-value entries from the hash.
  19569. *
  19570. * @private
  19571. * @name clear
  19572. * @memberOf Hash
  19573. */
  19574. function hashClear() {
  19575. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19576. this.size = 0;
  19577. }
  19578. /**
  19579. * Removes `key` and its value from the hash.
  19580. *
  19581. * @private
  19582. * @name delete
  19583. * @memberOf Hash
  19584. * @param {Object} hash The hash to modify.
  19585. * @param {string} key The key of the value to remove.
  19586. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19587. */
  19588. function hashDelete(key) {
  19589. var result = this.has(key) && delete this.__data__[key];
  19590. this.size -= result ? 1 : 0;
  19591. return result;
  19592. }
  19593. /**
  19594. * Gets the hash value for `key`.
  19595. *
  19596. * @private
  19597. * @name get
  19598. * @memberOf Hash
  19599. * @param {string} key The key of the value to get.
  19600. * @returns {*} Returns the entry value.
  19601. */
  19602. function hashGet(key) {
  19603. var data = this.__data__;
  19604. if (nativeCreate) {
  19605. var result = data[key];
  19606. return result === HASH_UNDEFINED ? undefined : result;
  19607. }
  19608. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19609. }
  19610. /**
  19611. * Checks if a hash value for `key` exists.
  19612. *
  19613. * @private
  19614. * @name has
  19615. * @memberOf Hash
  19616. * @param {string} key The key of the entry to check.
  19617. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19618. */
  19619. function hashHas(key) {
  19620. var data = this.__data__;
  19621. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19622. }
  19623. /**
  19624. * Sets the hash `key` to `value`.
  19625. *
  19626. * @private
  19627. * @name set
  19628. * @memberOf Hash
  19629. * @param {string} key The key of the value to set.
  19630. * @param {*} value The value to set.
  19631. * @returns {Object} Returns the hash instance.
  19632. */
  19633. function hashSet(key, value) {
  19634. var data = this.__data__;
  19635. this.size += this.has(key) ? 0 : 1;
  19636. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19637. return this;
  19638. }
  19639. // Add methods to `Hash`.
  19640. Hash.prototype.clear = hashClear;
  19641. Hash.prototype['delete'] = hashDelete;
  19642. Hash.prototype.get = hashGet;
  19643. Hash.prototype.has = hashHas;
  19644. Hash.prototype.set = hashSet;
  19645. /*------------------------------------------------------------------------*/
  19646. /**
  19647. * Creates an list cache object.
  19648. *
  19649. * @private
  19650. * @constructor
  19651. * @param {Array} [entries] The key-value pairs to cache.
  19652. */
  19653. function ListCache(entries) {
  19654. var index = -1,
  19655. length = entries == null ? 0 : entries.length;
  19656. this.clear();
  19657. while (++index < length) {
  19658. var entry = entries[index];
  19659. this.set(entry[0], entry[1]);
  19660. }
  19661. }
  19662. /**
  19663. * Removes all key-value entries from the list cache.
  19664. *
  19665. * @private
  19666. * @name clear
  19667. * @memberOf ListCache
  19668. */
  19669. function listCacheClear() {
  19670. this.__data__ = [];
  19671. this.size = 0;
  19672. }
  19673. /**
  19674. * Removes `key` and its value from the list cache.
  19675. *
  19676. * @private
  19677. * @name delete
  19678. * @memberOf ListCache
  19679. * @param {string} key The key of the value to remove.
  19680. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19681. */
  19682. function listCacheDelete(key) {
  19683. var data = this.__data__,
  19684. index = assocIndexOf(data, key);
  19685. if (index < 0) {
  19686. return false;
  19687. }
  19688. var lastIndex = data.length - 1;
  19689. if (index == lastIndex) {
  19690. data.pop();
  19691. } else {
  19692. splice.call(data, index, 1);
  19693. }
  19694. --this.size;
  19695. return true;
  19696. }
  19697. /**
  19698. * Gets the list cache value for `key`.
  19699. *
  19700. * @private
  19701. * @name get
  19702. * @memberOf ListCache
  19703. * @param {string} key The key of the value to get.
  19704. * @returns {*} Returns the entry value.
  19705. */
  19706. function listCacheGet(key) {
  19707. var data = this.__data__,
  19708. index = assocIndexOf(data, key);
  19709. return index < 0 ? undefined : data[index][1];
  19710. }
  19711. /**
  19712. * Checks if a list cache value for `key` exists.
  19713. *
  19714. * @private
  19715. * @name has
  19716. * @memberOf ListCache
  19717. * @param {string} key The key of the entry to check.
  19718. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19719. */
  19720. function listCacheHas(key) {
  19721. return assocIndexOf(this.__data__, key) > -1;
  19722. }
  19723. /**
  19724. * Sets the list cache `key` to `value`.
  19725. *
  19726. * @private
  19727. * @name set
  19728. * @memberOf ListCache
  19729. * @param {string} key The key of the value to set.
  19730. * @param {*} value The value to set.
  19731. * @returns {Object} Returns the list cache instance.
  19732. */
  19733. function listCacheSet(key, value) {
  19734. var data = this.__data__,
  19735. index = assocIndexOf(data, key);
  19736. if (index < 0) {
  19737. ++this.size;
  19738. data.push([key, value]);
  19739. } else {
  19740. data[index][1] = value;
  19741. }
  19742. return this;
  19743. }
  19744. // Add methods to `ListCache`.
  19745. ListCache.prototype.clear = listCacheClear;
  19746. ListCache.prototype['delete'] = listCacheDelete;
  19747. ListCache.prototype.get = listCacheGet;
  19748. ListCache.prototype.has = listCacheHas;
  19749. ListCache.prototype.set = listCacheSet;
  19750. /*------------------------------------------------------------------------*/
  19751. /**
  19752. * Creates a map cache object to store key-value pairs.
  19753. *
  19754. * @private
  19755. * @constructor
  19756. * @param {Array} [entries] The key-value pairs to cache.
  19757. */
  19758. function MapCache(entries) {
  19759. var index = -1,
  19760. length = entries == null ? 0 : entries.length;
  19761. this.clear();
  19762. while (++index < length) {
  19763. var entry = entries[index];
  19764. this.set(entry[0], entry[1]);
  19765. }
  19766. }
  19767. /**
  19768. * Removes all key-value entries from the map.
  19769. *
  19770. * @private
  19771. * @name clear
  19772. * @memberOf MapCache
  19773. */
  19774. function mapCacheClear() {
  19775. this.size = 0;
  19776. this.__data__ = {
  19777. 'hash': new Hash,
  19778. 'map': new (Map || ListCache),
  19779. 'string': new Hash
  19780. };
  19781. }
  19782. /**
  19783. * Removes `key` and its value from the map.
  19784. *
  19785. * @private
  19786. * @name delete
  19787. * @memberOf MapCache
  19788. * @param {string} key The key of the value to remove.
  19789. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19790. */
  19791. function mapCacheDelete(key) {
  19792. var result = getMapData(this, key)['delete'](key);
  19793. this.size -= result ? 1 : 0;
  19794. return result;
  19795. }
  19796. /**
  19797. * Gets the map value for `key`.
  19798. *
  19799. * @private
  19800. * @name get
  19801. * @memberOf MapCache
  19802. * @param {string} key The key of the value to get.
  19803. * @returns {*} Returns the entry value.
  19804. */
  19805. function mapCacheGet(key) {
  19806. return getMapData(this, key).get(key);
  19807. }
  19808. /**
  19809. * Checks if a map value for `key` exists.
  19810. *
  19811. * @private
  19812. * @name has
  19813. * @memberOf MapCache
  19814. * @param {string} key The key of the entry to check.
  19815. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19816. */
  19817. function mapCacheHas(key) {
  19818. return getMapData(this, key).has(key);
  19819. }
  19820. /**
  19821. * Sets the map `key` to `value`.
  19822. *
  19823. * @private
  19824. * @name set
  19825. * @memberOf MapCache
  19826. * @param {string} key The key of the value to set.
  19827. * @param {*} value The value to set.
  19828. * @returns {Object} Returns the map cache instance.
  19829. */
  19830. function mapCacheSet(key, value) {
  19831. var data = getMapData(this, key),
  19832. size = data.size;
  19833. data.set(key, value);
  19834. this.size += data.size == size ? 0 : 1;
  19835. return this;
  19836. }
  19837. // Add methods to `MapCache`.
  19838. MapCache.prototype.clear = mapCacheClear;
  19839. MapCache.prototype['delete'] = mapCacheDelete;
  19840. MapCache.prototype.get = mapCacheGet;
  19841. MapCache.prototype.has = mapCacheHas;
  19842. MapCache.prototype.set = mapCacheSet;
  19843. /*------------------------------------------------------------------------*/
  19844. /**
  19845. *
  19846. * Creates an array cache object to store unique values.
  19847. *
  19848. * @private
  19849. * @constructor
  19850. * @param {Array} [values] The values to cache.
  19851. */
  19852. function SetCache(values) {
  19853. var index = -1,
  19854. length = values == null ? 0 : values.length;
  19855. this.__data__ = new MapCache;
  19856. while (++index < length) {
  19857. this.add(values[index]);
  19858. }
  19859. }
  19860. /**
  19861. * Adds `value` to the array cache.
  19862. *
  19863. * @private
  19864. * @name add
  19865. * @memberOf SetCache
  19866. * @alias push
  19867. * @param {*} value The value to cache.
  19868. * @returns {Object} Returns the cache instance.
  19869. */
  19870. function setCacheAdd(value) {
  19871. this.__data__.set(value, HASH_UNDEFINED);
  19872. return this;
  19873. }
  19874. /**
  19875. * Checks if `value` is in the array cache.
  19876. *
  19877. * @private
  19878. * @name has
  19879. * @memberOf SetCache
  19880. * @param {*} value The value to search for.
  19881. * @returns {number} Returns `true` if `value` is found, else `false`.
  19882. */
  19883. function setCacheHas(value) {
  19884. return this.__data__.has(value);
  19885. }
  19886. // Add methods to `SetCache`.
  19887. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19888. SetCache.prototype.has = setCacheHas;
  19889. /*------------------------------------------------------------------------*/
  19890. /**
  19891. * Creates a stack cache object to store key-value pairs.
  19892. *
  19893. * @private
  19894. * @constructor
  19895. * @param {Array} [entries] The key-value pairs to cache.
  19896. */
  19897. function Stack(entries) {
  19898. var data = this.__data__ = new ListCache(entries);
  19899. this.size = data.size;
  19900. }
  19901. /**
  19902. * Removes all key-value entries from the stack.
  19903. *
  19904. * @private
  19905. * @name clear
  19906. * @memberOf Stack
  19907. */
  19908. function stackClear() {
  19909. this.__data__ = new ListCache;
  19910. this.size = 0;
  19911. }
  19912. /**
  19913. * Removes `key` and its value from the stack.
  19914. *
  19915. * @private
  19916. * @name delete
  19917. * @memberOf Stack
  19918. * @param {string} key The key of the value to remove.
  19919. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19920. */
  19921. function stackDelete(key) {
  19922. var data = this.__data__,
  19923. result = data['delete'](key);
  19924. this.size = data.size;
  19925. return result;
  19926. }
  19927. /**
  19928. * Gets the stack value for `key`.
  19929. *
  19930. * @private
  19931. * @name get
  19932. * @memberOf Stack
  19933. * @param {string} key The key of the value to get.
  19934. * @returns {*} Returns the entry value.
  19935. */
  19936. function stackGet(key) {
  19937. return this.__data__.get(key);
  19938. }
  19939. /**
  19940. * Checks if a stack value for `key` exists.
  19941. *
  19942. * @private
  19943. * @name has
  19944. * @memberOf Stack
  19945. * @param {string} key The key of the entry to check.
  19946. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19947. */
  19948. function stackHas(key) {
  19949. return this.__data__.has(key);
  19950. }
  19951. /**
  19952. * Sets the stack `key` to `value`.
  19953. *
  19954. * @private
  19955. * @name set
  19956. * @memberOf Stack
  19957. * @param {string} key The key of the value to set.
  19958. * @param {*} value The value to set.
  19959. * @returns {Object} Returns the stack cache instance.
  19960. */
  19961. function stackSet(key, value) {
  19962. var data = this.__data__;
  19963. if (data instanceof ListCache) {
  19964. var pairs = data.__data__;
  19965. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19966. pairs.push([key, value]);
  19967. this.size = ++data.size;
  19968. return this;
  19969. }
  19970. data = this.__data__ = new MapCache(pairs);
  19971. }
  19972. data.set(key, value);
  19973. this.size = data.size;
  19974. return this;
  19975. }
  19976. // Add methods to `Stack`.
  19977. Stack.prototype.clear = stackClear;
  19978. Stack.prototype['delete'] = stackDelete;
  19979. Stack.prototype.get = stackGet;
  19980. Stack.prototype.has = stackHas;
  19981. Stack.prototype.set = stackSet;
  19982. /*------------------------------------------------------------------------*/
  19983. /**
  19984. * Creates an array of the enumerable property names of the array-like `value`.
  19985. *
  19986. * @private
  19987. * @param {*} value The value to query.
  19988. * @param {boolean} inherited Specify returning inherited property names.
  19989. * @returns {Array} Returns the array of property names.
  19990. */
  19991. function arrayLikeKeys(value, inherited) {
  19992. var isArr = isArray(value),
  19993. isArg = !isArr && isArguments(value),
  19994. isBuff = !isArr && !isArg && isBuffer(value),
  19995. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19996. skipIndexes = isArr || isArg || isBuff || isType,
  19997. result = skipIndexes ? baseTimes(value.length, String) : [],
  19998. length = result.length;
  19999. for (var key in value) {
  20000. if ((inherited || hasOwnProperty.call(value, key)) &&
  20001. !(skipIndexes && (
  20002. // Safari 9 has enumerable `arguments.length` in strict mode.
  20003. key == 'length' ||
  20004. // Node.js 0.10 has enumerable non-index properties on buffers.
  20005. (isBuff && (key == 'offset' || key == 'parent')) ||
  20006. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  20007. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  20008. // Skip index properties.
  20009. isIndex(key, length)
  20010. ))) {
  20011. result.push(key);
  20012. }
  20013. }
  20014. return result;
  20015. }
  20016. /**
  20017. * A specialized version of `_.sample` for arrays.
  20018. *
  20019. * @private
  20020. * @param {Array} array The array to sample.
  20021. * @returns {*} Returns the random element.
  20022. */
  20023. function arraySample(array) {
  20024. var length = array.length;
  20025. return length ? array[baseRandom(0, length - 1)] : undefined;
  20026. }
  20027. /**
  20028. * A specialized version of `_.sampleSize` for arrays.
  20029. *
  20030. * @private
  20031. * @param {Array} array The array to sample.
  20032. * @param {number} n The number of elements to sample.
  20033. * @returns {Array} Returns the random elements.
  20034. */
  20035. function arraySampleSize(array, n) {
  20036. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  20037. }
  20038. /**
  20039. * A specialized version of `_.shuffle` for arrays.
  20040. *
  20041. * @private
  20042. * @param {Array} array The array to shuffle.
  20043. * @returns {Array} Returns the new shuffled array.
  20044. */
  20045. function arrayShuffle(array) {
  20046. return shuffleSelf(copyArray(array));
  20047. }
  20048. /**
  20049. * This function is like `assignValue` except that it doesn't assign
  20050. * `undefined` values.
  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 assignMergeValue(object, key, value) {
  20058. if ((value !== undefined && !eq(object[key], value)) ||
  20059. (value === undefined && !(key in object))) {
  20060. baseAssignValue(object, key, value);
  20061. }
  20062. }
  20063. /**
  20064. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  20065. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20066. * for equality comparisons.
  20067. *
  20068. * @private
  20069. * @param {Object} object The object to modify.
  20070. * @param {string} key The key of the property to assign.
  20071. * @param {*} value The value to assign.
  20072. */
  20073. function assignValue(object, key, value) {
  20074. var objValue = object[key];
  20075. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  20076. (value === undefined && !(key in object))) {
  20077. baseAssignValue(object, key, value);
  20078. }
  20079. }
  20080. /**
  20081. * Gets the index at which the `key` is found in `array` of key-value pairs.
  20082. *
  20083. * @private
  20084. * @param {Array} array The array to inspect.
  20085. * @param {*} key The key to search for.
  20086. * @returns {number} Returns the index of the matched value, else `-1`.
  20087. */
  20088. function assocIndexOf(array, key) {
  20089. var length = array.length;
  20090. while (length--) {
  20091. if (eq(array[length][0], key)) {
  20092. return length;
  20093. }
  20094. }
  20095. return -1;
  20096. }
  20097. /**
  20098. * Aggregates elements of `collection` on `accumulator` with keys transformed
  20099. * by `iteratee` and values set by `setter`.
  20100. *
  20101. * @private
  20102. * @param {Array|Object} collection The collection to iterate over.
  20103. * @param {Function} setter The function to set `accumulator` values.
  20104. * @param {Function} iteratee The iteratee to transform keys.
  20105. * @param {Object} accumulator The initial aggregated object.
  20106. * @returns {Function} Returns `accumulator`.
  20107. */
  20108. function baseAggregator(collection, setter, iteratee, accumulator) {
  20109. baseEach(collection, function(value, key, collection) {
  20110. setter(accumulator, value, iteratee(value), collection);
  20111. });
  20112. return accumulator;
  20113. }
  20114. /**
  20115. * The base implementation of `_.assign` without support for multiple sources
  20116. * or `customizer` functions.
  20117. *
  20118. * @private
  20119. * @param {Object} object The destination object.
  20120. * @param {Object} source The source object.
  20121. * @returns {Object} Returns `object`.
  20122. */
  20123. function baseAssign(object, source) {
  20124. return object && copyObject(source, keys(source), object);
  20125. }
  20126. /**
  20127. * The base implementation of `_.assignIn` without support for multiple sources
  20128. * or `customizer` functions.
  20129. *
  20130. * @private
  20131. * @param {Object} object The destination object.
  20132. * @param {Object} source The source object.
  20133. * @returns {Object} Returns `object`.
  20134. */
  20135. function baseAssignIn(object, source) {
  20136. return object && copyObject(source, keysIn(source), object);
  20137. }
  20138. /**
  20139. * The base implementation of `assignValue` and `assignMergeValue` without
  20140. * value checks.
  20141. *
  20142. * @private
  20143. * @param {Object} object The object to modify.
  20144. * @param {string} key The key of the property to assign.
  20145. * @param {*} value The value to assign.
  20146. */
  20147. function baseAssignValue(object, key, value) {
  20148. if (key == '__proto__' && defineProperty) {
  20149. defineProperty(object, key, {
  20150. 'configurable': true,
  20151. 'enumerable': true,
  20152. 'value': value,
  20153. 'writable': true
  20154. });
  20155. } else {
  20156. object[key] = value;
  20157. }
  20158. }
  20159. /**
  20160. * The base implementation of `_.at` without support for individual paths.
  20161. *
  20162. * @private
  20163. * @param {Object} object The object to iterate over.
  20164. * @param {string[]} paths The property paths to pick.
  20165. * @returns {Array} Returns the picked elements.
  20166. */
  20167. function baseAt(object, paths) {
  20168. var index = -1,
  20169. length = paths.length,
  20170. result = Array(length),
  20171. skip = object == null;
  20172. while (++index < length) {
  20173. result[index] = skip ? undefined : get(object, paths[index]);
  20174. }
  20175. return result;
  20176. }
  20177. /**
  20178. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20179. *
  20180. * @private
  20181. * @param {number} number The number to clamp.
  20182. * @param {number} [lower] The lower bound.
  20183. * @param {number} upper The upper bound.
  20184. * @returns {number} Returns the clamped number.
  20185. */
  20186. function baseClamp(number, lower, upper) {
  20187. if (number === number) {
  20188. if (upper !== undefined) {
  20189. number = number <= upper ? number : upper;
  20190. }
  20191. if (lower !== undefined) {
  20192. number = number >= lower ? number : lower;
  20193. }
  20194. }
  20195. return number;
  20196. }
  20197. /**
  20198. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20199. * traversed objects.
  20200. *
  20201. * @private
  20202. * @param {*} value The value to clone.
  20203. * @param {boolean} bitmask The bitmask flags.
  20204. * 1 - Deep clone
  20205. * 2 - Flatten inherited properties
  20206. * 4 - Clone symbols
  20207. * @param {Function} [customizer] The function to customize cloning.
  20208. * @param {string} [key] The key of `value`.
  20209. * @param {Object} [object] The parent object of `value`.
  20210. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20211. * @returns {*} Returns the cloned value.
  20212. */
  20213. function baseClone(value, bitmask, customizer, key, object, stack) {
  20214. var result,
  20215. isDeep = bitmask & CLONE_DEEP_FLAG,
  20216. isFlat = bitmask & CLONE_FLAT_FLAG,
  20217. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20218. if (customizer) {
  20219. result = object ? customizer(value, key, object, stack) : customizer(value);
  20220. }
  20221. if (result !== undefined) {
  20222. return result;
  20223. }
  20224. if (!isObject(value)) {
  20225. return value;
  20226. }
  20227. var isArr = isArray(value);
  20228. if (isArr) {
  20229. result = initCloneArray(value);
  20230. if (!isDeep) {
  20231. return copyArray(value, result);
  20232. }
  20233. } else {
  20234. var tag = getTag(value),
  20235. isFunc = tag == funcTag || tag == genTag;
  20236. if (isBuffer(value)) {
  20237. return cloneBuffer(value, isDeep);
  20238. }
  20239. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20240. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20241. if (!isDeep) {
  20242. return isFlat
  20243. ? copySymbolsIn(value, baseAssignIn(result, value))
  20244. : copySymbols(value, baseAssign(result, value));
  20245. }
  20246. } else {
  20247. if (!cloneableTags[tag]) {
  20248. return object ? value : {};
  20249. }
  20250. result = initCloneByTag(value, tag, isDeep);
  20251. }
  20252. }
  20253. // Check for circular references and return its corresponding clone.
  20254. stack || (stack = new Stack);
  20255. var stacked = stack.get(value);
  20256. if (stacked) {
  20257. return stacked;
  20258. }
  20259. stack.set(value, result);
  20260. if (isSet(value)) {
  20261. value.forEach(function(subValue) {
  20262. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20263. });
  20264. } else if (isMap(value)) {
  20265. value.forEach(function(subValue, key) {
  20266. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20267. });
  20268. }
  20269. var keysFunc = isFull
  20270. ? (isFlat ? getAllKeysIn : getAllKeys)
  20271. : (isFlat ? keysIn : keys);
  20272. var props = isArr ? undefined : keysFunc(value);
  20273. arrayEach(props || value, function(subValue, key) {
  20274. if (props) {
  20275. key = subValue;
  20276. subValue = value[key];
  20277. }
  20278. // Recursively populate clone (susceptible to call stack limits).
  20279. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20280. });
  20281. return result;
  20282. }
  20283. /**
  20284. * The base implementation of `_.conforms` which doesn't clone `source`.
  20285. *
  20286. * @private
  20287. * @param {Object} source The object of property predicates to conform to.
  20288. * @returns {Function} Returns the new spec function.
  20289. */
  20290. function baseConforms(source) {
  20291. var props = keys(source);
  20292. return function(object) {
  20293. return baseConformsTo(object, source, props);
  20294. };
  20295. }
  20296. /**
  20297. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20298. *
  20299. * @private
  20300. * @param {Object} object The object to inspect.
  20301. * @param {Object} source The object of property predicates to conform to.
  20302. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20303. */
  20304. function baseConformsTo(object, source, props) {
  20305. var length = props.length;
  20306. if (object == null) {
  20307. return !length;
  20308. }
  20309. object = Object(object);
  20310. while (length--) {
  20311. var key = props[length],
  20312. predicate = source[key],
  20313. value = object[key];
  20314. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20315. return false;
  20316. }
  20317. }
  20318. return true;
  20319. }
  20320. /**
  20321. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20322. * to provide to `func`.
  20323. *
  20324. * @private
  20325. * @param {Function} func The function to delay.
  20326. * @param {number} wait The number of milliseconds to delay invocation.
  20327. * @param {Array} args The arguments to provide to `func`.
  20328. * @returns {number|Object} Returns the timer id or timeout object.
  20329. */
  20330. function baseDelay(func, wait, args) {
  20331. if (typeof func != 'function') {
  20332. throw new TypeError(FUNC_ERROR_TEXT);
  20333. }
  20334. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20335. }
  20336. /**
  20337. * The base implementation of methods like `_.difference` without support
  20338. * for excluding multiple arrays or iteratee shorthands.
  20339. *
  20340. * @private
  20341. * @param {Array} array The array to inspect.
  20342. * @param {Array} values The values to exclude.
  20343. * @param {Function} [iteratee] The iteratee invoked per element.
  20344. * @param {Function} [comparator] The comparator invoked per element.
  20345. * @returns {Array} Returns the new array of filtered values.
  20346. */
  20347. function baseDifference(array, values, iteratee, comparator) {
  20348. var index = -1,
  20349. includes = arrayIncludes,
  20350. isCommon = true,
  20351. length = array.length,
  20352. result = [],
  20353. valuesLength = values.length;
  20354. if (!length) {
  20355. return result;
  20356. }
  20357. if (iteratee) {
  20358. values = arrayMap(values, baseUnary(iteratee));
  20359. }
  20360. if (comparator) {
  20361. includes = arrayIncludesWith;
  20362. isCommon = false;
  20363. }
  20364. else if (values.length >= LARGE_ARRAY_SIZE) {
  20365. includes = cacheHas;
  20366. isCommon = false;
  20367. values = new SetCache(values);
  20368. }
  20369. outer:
  20370. while (++index < length) {
  20371. var value = array[index],
  20372. computed = iteratee == null ? value : iteratee(value);
  20373. value = (comparator || value !== 0) ? value : 0;
  20374. if (isCommon && computed === computed) {
  20375. var valuesIndex = valuesLength;
  20376. while (valuesIndex--) {
  20377. if (values[valuesIndex] === computed) {
  20378. continue outer;
  20379. }
  20380. }
  20381. result.push(value);
  20382. }
  20383. else if (!includes(values, computed, comparator)) {
  20384. result.push(value);
  20385. }
  20386. }
  20387. return result;
  20388. }
  20389. /**
  20390. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20391. *
  20392. * @private
  20393. * @param {Array|Object} collection The collection to iterate over.
  20394. * @param {Function} iteratee The function invoked per iteration.
  20395. * @returns {Array|Object} Returns `collection`.
  20396. */
  20397. var baseEach = createBaseEach(baseForOwn);
  20398. /**
  20399. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20400. *
  20401. * @private
  20402. * @param {Array|Object} collection The collection to iterate over.
  20403. * @param {Function} iteratee The function invoked per iteration.
  20404. * @returns {Array|Object} Returns `collection`.
  20405. */
  20406. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20407. /**
  20408. * The base implementation of `_.every` without support for iteratee shorthands.
  20409. *
  20410. * @private
  20411. * @param {Array|Object} collection The collection to iterate over.
  20412. * @param {Function} predicate The function invoked per iteration.
  20413. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20414. * else `false`
  20415. */
  20416. function baseEvery(collection, predicate) {
  20417. var result = true;
  20418. baseEach(collection, function(value, index, collection) {
  20419. result = !!predicate(value, index, collection);
  20420. return result;
  20421. });
  20422. return result;
  20423. }
  20424. /**
  20425. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20426. * `comparator` to determine the extremum value.
  20427. *
  20428. * @private
  20429. * @param {Array} array The array to iterate over.
  20430. * @param {Function} iteratee The iteratee invoked per iteration.
  20431. * @param {Function} comparator The comparator used to compare values.
  20432. * @returns {*} Returns the extremum value.
  20433. */
  20434. function baseExtremum(array, iteratee, comparator) {
  20435. var index = -1,
  20436. length = array.length;
  20437. while (++index < length) {
  20438. var value = array[index],
  20439. current = iteratee(value);
  20440. if (current != null && (computed === undefined
  20441. ? (current === current && !isSymbol(current))
  20442. : comparator(current, computed)
  20443. )) {
  20444. var computed = current,
  20445. result = value;
  20446. }
  20447. }
  20448. return result;
  20449. }
  20450. /**
  20451. * The base implementation of `_.fill` without an iteratee call guard.
  20452. *
  20453. * @private
  20454. * @param {Array} array The array to fill.
  20455. * @param {*} value The value to fill `array` with.
  20456. * @param {number} [start=0] The start position.
  20457. * @param {number} [end=array.length] The end position.
  20458. * @returns {Array} Returns `array`.
  20459. */
  20460. function baseFill(array, value, start, end) {
  20461. var length = array.length;
  20462. start = toInteger(start);
  20463. if (start < 0) {
  20464. start = -start > length ? 0 : (length + start);
  20465. }
  20466. end = (end === undefined || end > length) ? length : toInteger(end);
  20467. if (end < 0) {
  20468. end += length;
  20469. }
  20470. end = start > end ? 0 : toLength(end);
  20471. while (start < end) {
  20472. array[start++] = value;
  20473. }
  20474. return array;
  20475. }
  20476. /**
  20477. * The base implementation of `_.filter` without support for iteratee shorthands.
  20478. *
  20479. * @private
  20480. * @param {Array|Object} collection The collection to iterate over.
  20481. * @param {Function} predicate The function invoked per iteration.
  20482. * @returns {Array} Returns the new filtered array.
  20483. */
  20484. function baseFilter(collection, predicate) {
  20485. var result = [];
  20486. baseEach(collection, function(value, index, collection) {
  20487. if (predicate(value, index, collection)) {
  20488. result.push(value);
  20489. }
  20490. });
  20491. return result;
  20492. }
  20493. /**
  20494. * The base implementation of `_.flatten` with support for restricting flattening.
  20495. *
  20496. * @private
  20497. * @param {Array} array The array to flatten.
  20498. * @param {number} depth The maximum recursion depth.
  20499. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20500. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20501. * @param {Array} [result=[]] The initial result value.
  20502. * @returns {Array} Returns the new flattened array.
  20503. */
  20504. function baseFlatten(array, depth, predicate, isStrict, result) {
  20505. var index = -1,
  20506. length = array.length;
  20507. predicate || (predicate = isFlattenable);
  20508. result || (result = []);
  20509. while (++index < length) {
  20510. var value = array[index];
  20511. if (depth > 0 && predicate(value)) {
  20512. if (depth > 1) {
  20513. // Recursively flatten arrays (susceptible to call stack limits).
  20514. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20515. } else {
  20516. arrayPush(result, value);
  20517. }
  20518. } else if (!isStrict) {
  20519. result[result.length] = value;
  20520. }
  20521. }
  20522. return result;
  20523. }
  20524. /**
  20525. * The base implementation of `baseForOwn` which iterates over `object`
  20526. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20527. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20528. *
  20529. * @private
  20530. * @param {Object} object The object to iterate over.
  20531. * @param {Function} iteratee The function invoked per iteration.
  20532. * @param {Function} keysFunc The function to get the keys of `object`.
  20533. * @returns {Object} Returns `object`.
  20534. */
  20535. var baseFor = createBaseFor();
  20536. /**
  20537. * This function is like `baseFor` except that it iterates over properties
  20538. * in the opposite order.
  20539. *
  20540. * @private
  20541. * @param {Object} object The object to iterate over.
  20542. * @param {Function} iteratee The function invoked per iteration.
  20543. * @param {Function} keysFunc The function to get the keys of `object`.
  20544. * @returns {Object} Returns `object`.
  20545. */
  20546. var baseForRight = createBaseFor(true);
  20547. /**
  20548. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20549. *
  20550. * @private
  20551. * @param {Object} object The object to iterate over.
  20552. * @param {Function} iteratee The function invoked per iteration.
  20553. * @returns {Object} Returns `object`.
  20554. */
  20555. function baseForOwn(object, iteratee) {
  20556. return object && baseFor(object, iteratee, keys);
  20557. }
  20558. /**
  20559. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20560. *
  20561. * @private
  20562. * @param {Object} object The object to iterate over.
  20563. * @param {Function} iteratee The function invoked per iteration.
  20564. * @returns {Object} Returns `object`.
  20565. */
  20566. function baseForOwnRight(object, iteratee) {
  20567. return object && baseForRight(object, iteratee, keys);
  20568. }
  20569. /**
  20570. * The base implementation of `_.functions` which creates an array of
  20571. * `object` function property names filtered from `props`.
  20572. *
  20573. * @private
  20574. * @param {Object} object The object to inspect.
  20575. * @param {Array} props The property names to filter.
  20576. * @returns {Array} Returns the function names.
  20577. */
  20578. function baseFunctions(object, props) {
  20579. return arrayFilter(props, function(key) {
  20580. return isFunction(object[key]);
  20581. });
  20582. }
  20583. /**
  20584. * The base implementation of `_.get` without support for default values.
  20585. *
  20586. * @private
  20587. * @param {Object} object The object to query.
  20588. * @param {Array|string} path The path of the property to get.
  20589. * @returns {*} Returns the resolved value.
  20590. */
  20591. function baseGet(object, path) {
  20592. path = castPath(path, object);
  20593. var index = 0,
  20594. length = path.length;
  20595. while (object != null && index < length) {
  20596. object = object[toKey(path[index++])];
  20597. }
  20598. return (index && index == length) ? object : undefined;
  20599. }
  20600. /**
  20601. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20602. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20603. * symbols of `object`.
  20604. *
  20605. * @private
  20606. * @param {Object} object The object to query.
  20607. * @param {Function} keysFunc The function to get the keys of `object`.
  20608. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20609. * @returns {Array} Returns the array of property names and symbols.
  20610. */
  20611. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20612. var result = keysFunc(object);
  20613. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20614. }
  20615. /**
  20616. * The base implementation of `getTag` without fallbacks for buggy environments.
  20617. *
  20618. * @private
  20619. * @param {*} value The value to query.
  20620. * @returns {string} Returns the `toStringTag`.
  20621. */
  20622. function baseGetTag(value) {
  20623. if (value == null) {
  20624. return value === undefined ? undefinedTag : nullTag;
  20625. }
  20626. return (symToStringTag && symToStringTag in Object(value))
  20627. ? getRawTag(value)
  20628. : objectToString(value);
  20629. }
  20630. /**
  20631. * The base implementation of `_.gt` which doesn't coerce arguments.
  20632. *
  20633. * @private
  20634. * @param {*} value The value to compare.
  20635. * @param {*} other The other value to compare.
  20636. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20637. * else `false`.
  20638. */
  20639. function baseGt(value, other) {
  20640. return value > other;
  20641. }
  20642. /**
  20643. * The base implementation of `_.has` without support for deep paths.
  20644. *
  20645. * @private
  20646. * @param {Object} [object] The object to query.
  20647. * @param {Array|string} key The key to check.
  20648. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20649. */
  20650. function baseHas(object, key) {
  20651. return object != null && hasOwnProperty.call(object, key);
  20652. }
  20653. /**
  20654. * The base implementation of `_.hasIn` without support for deep paths.
  20655. *
  20656. * @private
  20657. * @param {Object} [object] The object to query.
  20658. * @param {Array|string} key The key to check.
  20659. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20660. */
  20661. function baseHasIn(object, key) {
  20662. return object != null && key in Object(object);
  20663. }
  20664. /**
  20665. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20666. *
  20667. * @private
  20668. * @param {number} number The number to check.
  20669. * @param {number} start The start of the range.
  20670. * @param {number} end The end of the range.
  20671. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20672. */
  20673. function baseInRange(number, start, end) {
  20674. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20675. }
  20676. /**
  20677. * The base implementation of methods like `_.intersection`, without support
  20678. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20679. *
  20680. * @private
  20681. * @param {Array} arrays The arrays to inspect.
  20682. * @param {Function} [iteratee] The iteratee invoked per element.
  20683. * @param {Function} [comparator] The comparator invoked per element.
  20684. * @returns {Array} Returns the new array of shared values.
  20685. */
  20686. function baseIntersection(arrays, iteratee, comparator) {
  20687. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20688. length = arrays[0].length,
  20689. othLength = arrays.length,
  20690. othIndex = othLength,
  20691. caches = Array(othLength),
  20692. maxLength = Infinity,
  20693. result = [];
  20694. while (othIndex--) {
  20695. var array = arrays[othIndex];
  20696. if (othIndex && iteratee) {
  20697. array = arrayMap(array, baseUnary(iteratee));
  20698. }
  20699. maxLength = nativeMin(array.length, maxLength);
  20700. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20701. ? new SetCache(othIndex && array)
  20702. : undefined;
  20703. }
  20704. array = arrays[0];
  20705. var index = -1,
  20706. seen = caches[0];
  20707. outer:
  20708. while (++index < length && result.length < maxLength) {
  20709. var value = array[index],
  20710. computed = iteratee ? iteratee(value) : value;
  20711. value = (comparator || value !== 0) ? value : 0;
  20712. if (!(seen
  20713. ? cacheHas(seen, computed)
  20714. : includes(result, computed, comparator)
  20715. )) {
  20716. othIndex = othLength;
  20717. while (--othIndex) {
  20718. var cache = caches[othIndex];
  20719. if (!(cache
  20720. ? cacheHas(cache, computed)
  20721. : includes(arrays[othIndex], computed, comparator))
  20722. ) {
  20723. continue outer;
  20724. }
  20725. }
  20726. if (seen) {
  20727. seen.push(computed);
  20728. }
  20729. result.push(value);
  20730. }
  20731. }
  20732. return result;
  20733. }
  20734. /**
  20735. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20736. * `object` with values transformed by `iteratee` and set by `setter`.
  20737. *
  20738. * @private
  20739. * @param {Object} object The object to iterate over.
  20740. * @param {Function} setter The function to set `accumulator` values.
  20741. * @param {Function} iteratee The iteratee to transform values.
  20742. * @param {Object} accumulator The initial inverted object.
  20743. * @returns {Function} Returns `accumulator`.
  20744. */
  20745. function baseInverter(object, setter, iteratee, accumulator) {
  20746. baseForOwn(object, function(value, key, object) {
  20747. setter(accumulator, iteratee(value), key, object);
  20748. });
  20749. return accumulator;
  20750. }
  20751. /**
  20752. * The base implementation of `_.invoke` without support for individual
  20753. * method arguments.
  20754. *
  20755. * @private
  20756. * @param {Object} object The object to query.
  20757. * @param {Array|string} path The path of the method to invoke.
  20758. * @param {Array} args The arguments to invoke the method with.
  20759. * @returns {*} Returns the result of the invoked method.
  20760. */
  20761. function baseInvoke(object, path, args) {
  20762. path = castPath(path, object);
  20763. object = parent(object, path);
  20764. var func = object == null ? object : object[toKey(last(path))];
  20765. return func == null ? undefined : apply(func, object, args);
  20766. }
  20767. /**
  20768. * The base implementation of `_.isArguments`.
  20769. *
  20770. * @private
  20771. * @param {*} value The value to check.
  20772. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20773. */
  20774. function baseIsArguments(value) {
  20775. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20776. }
  20777. /**
  20778. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20779. *
  20780. * @private
  20781. * @param {*} value The value to check.
  20782. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20783. */
  20784. function baseIsArrayBuffer(value) {
  20785. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20786. }
  20787. /**
  20788. * The base implementation of `_.isDate` without Node.js optimizations.
  20789. *
  20790. * @private
  20791. * @param {*} value The value to check.
  20792. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20793. */
  20794. function baseIsDate(value) {
  20795. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20796. }
  20797. /**
  20798. * The base implementation of `_.isEqual` which supports partial comparisons
  20799. * and tracks traversed objects.
  20800. *
  20801. * @private
  20802. * @param {*} value The value to compare.
  20803. * @param {*} other The other value to compare.
  20804. * @param {boolean} bitmask The bitmask flags.
  20805. * 1 - Unordered comparison
  20806. * 2 - Partial comparison
  20807. * @param {Function} [customizer] The function to customize comparisons.
  20808. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20809. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20810. */
  20811. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20812. if (value === other) {
  20813. return true;
  20814. }
  20815. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20816. return value !== value && other !== other;
  20817. }
  20818. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20819. }
  20820. /**
  20821. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20822. * deep comparisons and tracks traversed objects enabling objects with circular
  20823. * references to be compared.
  20824. *
  20825. * @private
  20826. * @param {Object} object The object to compare.
  20827. * @param {Object} other The other object to compare.
  20828. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20829. * @param {Function} customizer The function to customize comparisons.
  20830. * @param {Function} equalFunc The function to determine equivalents of values.
  20831. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20832. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20833. */
  20834. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20835. var objIsArr = isArray(object),
  20836. othIsArr = isArray(other),
  20837. objTag = objIsArr ? arrayTag : getTag(object),
  20838. othTag = othIsArr ? arrayTag : getTag(other);
  20839. objTag = objTag == argsTag ? objectTag : objTag;
  20840. othTag = othTag == argsTag ? objectTag : othTag;
  20841. var objIsObj = objTag == objectTag,
  20842. othIsObj = othTag == objectTag,
  20843. isSameTag = objTag == othTag;
  20844. if (isSameTag && isBuffer(object)) {
  20845. if (!isBuffer(other)) {
  20846. return false;
  20847. }
  20848. objIsArr = true;
  20849. objIsObj = false;
  20850. }
  20851. if (isSameTag && !objIsObj) {
  20852. stack || (stack = new Stack);
  20853. return (objIsArr || isTypedArray(object))
  20854. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20855. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20856. }
  20857. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20858. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20859. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20860. if (objIsWrapped || othIsWrapped) {
  20861. var objUnwrapped = objIsWrapped ? object.value() : object,
  20862. othUnwrapped = othIsWrapped ? other.value() : other;
  20863. stack || (stack = new Stack);
  20864. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20865. }
  20866. }
  20867. if (!isSameTag) {
  20868. return false;
  20869. }
  20870. stack || (stack = new Stack);
  20871. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20872. }
  20873. /**
  20874. * The base implementation of `_.isMap` without Node.js optimizations.
  20875. *
  20876. * @private
  20877. * @param {*} value The value to check.
  20878. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20879. */
  20880. function baseIsMap(value) {
  20881. return isObjectLike(value) && getTag(value) == mapTag;
  20882. }
  20883. /**
  20884. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20885. *
  20886. * @private
  20887. * @param {Object} object The object to inspect.
  20888. * @param {Object} source The object of property values to match.
  20889. * @param {Array} matchData The property names, values, and compare flags to match.
  20890. * @param {Function} [customizer] The function to customize comparisons.
  20891. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20892. */
  20893. function baseIsMatch(object, source, matchData, customizer) {
  20894. var index = matchData.length,
  20895. length = index,
  20896. noCustomizer = !customizer;
  20897. if (object == null) {
  20898. return !length;
  20899. }
  20900. object = Object(object);
  20901. while (index--) {
  20902. var data = matchData[index];
  20903. if ((noCustomizer && data[2])
  20904. ? data[1] !== object[data[0]]
  20905. : !(data[0] in object)
  20906. ) {
  20907. return false;
  20908. }
  20909. }
  20910. while (++index < length) {
  20911. data = matchData[index];
  20912. var key = data[0],
  20913. objValue = object[key],
  20914. srcValue = data[1];
  20915. if (noCustomizer && data[2]) {
  20916. if (objValue === undefined && !(key in object)) {
  20917. return false;
  20918. }
  20919. } else {
  20920. var stack = new Stack;
  20921. if (customizer) {
  20922. var result = customizer(objValue, srcValue, key, object, source, stack);
  20923. }
  20924. if (!(result === undefined
  20925. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20926. : result
  20927. )) {
  20928. return false;
  20929. }
  20930. }
  20931. }
  20932. return true;
  20933. }
  20934. /**
  20935. * The base implementation of `_.isNative` without bad shim checks.
  20936. *
  20937. * @private
  20938. * @param {*} value The value to check.
  20939. * @returns {boolean} Returns `true` if `value` is a native function,
  20940. * else `false`.
  20941. */
  20942. function baseIsNative(value) {
  20943. if (!isObject(value) || isMasked(value)) {
  20944. return false;
  20945. }
  20946. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20947. return pattern.test(toSource(value));
  20948. }
  20949. /**
  20950. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20951. *
  20952. * @private
  20953. * @param {*} value The value to check.
  20954. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20955. */
  20956. function baseIsRegExp(value) {
  20957. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20958. }
  20959. /**
  20960. * The base implementation of `_.isSet` without Node.js optimizations.
  20961. *
  20962. * @private
  20963. * @param {*} value The value to check.
  20964. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20965. */
  20966. function baseIsSet(value) {
  20967. return isObjectLike(value) && getTag(value) == setTag;
  20968. }
  20969. /**
  20970. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20971. *
  20972. * @private
  20973. * @param {*} value The value to check.
  20974. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20975. */
  20976. function baseIsTypedArray(value) {
  20977. return isObjectLike(value) &&
  20978. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20979. }
  20980. /**
  20981. * The base implementation of `_.iteratee`.
  20982. *
  20983. * @private
  20984. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20985. * @returns {Function} Returns the iteratee.
  20986. */
  20987. function baseIteratee(value) {
  20988. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20989. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20990. if (typeof value == 'function') {
  20991. return value;
  20992. }
  20993. if (value == null) {
  20994. return identity;
  20995. }
  20996. if (typeof value == 'object') {
  20997. return isArray(value)
  20998. ? baseMatchesProperty(value[0], value[1])
  20999. : baseMatches(value);
  21000. }
  21001. return property(value);
  21002. }
  21003. /**
  21004. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  21005. *
  21006. * @private
  21007. * @param {Object} object The object to query.
  21008. * @returns {Array} Returns the array of property names.
  21009. */
  21010. function baseKeys(object) {
  21011. if (!isPrototype(object)) {
  21012. return nativeKeys(object);
  21013. }
  21014. var result = [];
  21015. for (var key in Object(object)) {
  21016. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  21017. result.push(key);
  21018. }
  21019. }
  21020. return result;
  21021. }
  21022. /**
  21023. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  21024. *
  21025. * @private
  21026. * @param {Object} object The object to query.
  21027. * @returns {Array} Returns the array of property names.
  21028. */
  21029. function baseKeysIn(object) {
  21030. if (!isObject(object)) {
  21031. return nativeKeysIn(object);
  21032. }
  21033. var isProto = isPrototype(object),
  21034. result = [];
  21035. for (var key in object) {
  21036. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  21037. result.push(key);
  21038. }
  21039. }
  21040. return result;
  21041. }
  21042. /**
  21043. * The base implementation of `_.lt` which doesn't coerce arguments.
  21044. *
  21045. * @private
  21046. * @param {*} value The value to compare.
  21047. * @param {*} other The other value to compare.
  21048. * @returns {boolean} Returns `true` if `value` is less than `other`,
  21049. * else `false`.
  21050. */
  21051. function baseLt(value, other) {
  21052. return value < other;
  21053. }
  21054. /**
  21055. * The base implementation of `_.map` without support for iteratee shorthands.
  21056. *
  21057. * @private
  21058. * @param {Array|Object} collection The collection to iterate over.
  21059. * @param {Function} iteratee The function invoked per iteration.
  21060. * @returns {Array} Returns the new mapped array.
  21061. */
  21062. function baseMap(collection, iteratee) {
  21063. var index = -1,
  21064. result = isArrayLike(collection) ? Array(collection.length) : [];
  21065. baseEach(collection, function(value, key, collection) {
  21066. result[++index] = iteratee(value, key, collection);
  21067. });
  21068. return result;
  21069. }
  21070. /**
  21071. * The base implementation of `_.matches` which doesn't clone `source`.
  21072. *
  21073. * @private
  21074. * @param {Object} source The object of property values to match.
  21075. * @returns {Function} Returns the new spec function.
  21076. */
  21077. function baseMatches(source) {
  21078. var matchData = getMatchData(source);
  21079. if (matchData.length == 1 && matchData[0][2]) {
  21080. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  21081. }
  21082. return function(object) {
  21083. return object === source || baseIsMatch(object, source, matchData);
  21084. };
  21085. }
  21086. /**
  21087. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  21088. *
  21089. * @private
  21090. * @param {string} path The path of the property to get.
  21091. * @param {*} srcValue The value to match.
  21092. * @returns {Function} Returns the new spec function.
  21093. */
  21094. function baseMatchesProperty(path, srcValue) {
  21095. if (isKey(path) && isStrictComparable(srcValue)) {
  21096. return matchesStrictComparable(toKey(path), srcValue);
  21097. }
  21098. return function(object) {
  21099. var objValue = get(object, path);
  21100. return (objValue === undefined && objValue === srcValue)
  21101. ? hasIn(object, path)
  21102. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  21103. };
  21104. }
  21105. /**
  21106. * The base implementation of `_.merge` without support for multiple sources.
  21107. *
  21108. * @private
  21109. * @param {Object} object The destination object.
  21110. * @param {Object} source The source object.
  21111. * @param {number} srcIndex The index of `source`.
  21112. * @param {Function} [customizer] The function to customize merged values.
  21113. * @param {Object} [stack] Tracks traversed source values and their merged
  21114. * counterparts.
  21115. */
  21116. function baseMerge(object, source, srcIndex, customizer, stack) {
  21117. if (object === source) {
  21118. return;
  21119. }
  21120. baseFor(source, function(srcValue, key) {
  21121. stack || (stack = new Stack);
  21122. if (isObject(srcValue)) {
  21123. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21124. }
  21125. else {
  21126. var newValue = customizer
  21127. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21128. : undefined;
  21129. if (newValue === undefined) {
  21130. newValue = srcValue;
  21131. }
  21132. assignMergeValue(object, key, newValue);
  21133. }
  21134. }, keysIn);
  21135. }
  21136. /**
  21137. * A specialized version of `baseMerge` for arrays and objects which performs
  21138. * deep merges and tracks traversed objects enabling objects with circular
  21139. * references to be merged.
  21140. *
  21141. * @private
  21142. * @param {Object} object The destination object.
  21143. * @param {Object} source The source object.
  21144. * @param {string} key The key of the value to merge.
  21145. * @param {number} srcIndex The index of `source`.
  21146. * @param {Function} mergeFunc The function to merge values.
  21147. * @param {Function} [customizer] The function to customize assigned values.
  21148. * @param {Object} [stack] Tracks traversed source values and their merged
  21149. * counterparts.
  21150. */
  21151. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21152. var objValue = safeGet(object, key),
  21153. srcValue = safeGet(source, key),
  21154. stacked = stack.get(srcValue);
  21155. if (stacked) {
  21156. assignMergeValue(object, key, stacked);
  21157. return;
  21158. }
  21159. var newValue = customizer
  21160. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21161. : undefined;
  21162. var isCommon = newValue === undefined;
  21163. if (isCommon) {
  21164. var isArr = isArray(srcValue),
  21165. isBuff = !isArr && isBuffer(srcValue),
  21166. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21167. newValue = srcValue;
  21168. if (isArr || isBuff || isTyped) {
  21169. if (isArray(objValue)) {
  21170. newValue = objValue;
  21171. }
  21172. else if (isArrayLikeObject(objValue)) {
  21173. newValue = copyArray(objValue);
  21174. }
  21175. else if (isBuff) {
  21176. isCommon = false;
  21177. newValue = cloneBuffer(srcValue, true);
  21178. }
  21179. else if (isTyped) {
  21180. isCommon = false;
  21181. newValue = cloneTypedArray(srcValue, true);
  21182. }
  21183. else {
  21184. newValue = [];
  21185. }
  21186. }
  21187. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21188. newValue = objValue;
  21189. if (isArguments(objValue)) {
  21190. newValue = toPlainObject(objValue);
  21191. }
  21192. else if (!isObject(objValue) || isFunction(objValue)) {
  21193. newValue = initCloneObject(srcValue);
  21194. }
  21195. }
  21196. else {
  21197. isCommon = false;
  21198. }
  21199. }
  21200. if (isCommon) {
  21201. // Recursively merge objects and arrays (susceptible to call stack limits).
  21202. stack.set(srcValue, newValue);
  21203. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21204. stack['delete'](srcValue);
  21205. }
  21206. assignMergeValue(object, key, newValue);
  21207. }
  21208. /**
  21209. * The base implementation of `_.nth` which doesn't coerce arguments.
  21210. *
  21211. * @private
  21212. * @param {Array} array The array to query.
  21213. * @param {number} n The index of the element to return.
  21214. * @returns {*} Returns the nth element of `array`.
  21215. */
  21216. function baseNth(array, n) {
  21217. var length = array.length;
  21218. if (!length) {
  21219. return;
  21220. }
  21221. n += n < 0 ? length : 0;
  21222. return isIndex(n, length) ? array[n] : undefined;
  21223. }
  21224. /**
  21225. * The base implementation of `_.orderBy` without param guards.
  21226. *
  21227. * @private
  21228. * @param {Array|Object} collection The collection to iterate over.
  21229. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21230. * @param {string[]} orders The sort orders of `iteratees`.
  21231. * @returns {Array} Returns the new sorted array.
  21232. */
  21233. function baseOrderBy(collection, iteratees, orders) {
  21234. var index = -1;
  21235. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21236. var result = baseMap(collection, function(value, key, collection) {
  21237. var criteria = arrayMap(iteratees, function(iteratee) {
  21238. return iteratee(value);
  21239. });
  21240. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21241. });
  21242. return baseSortBy(result, function(object, other) {
  21243. return compareMultiple(object, other, orders);
  21244. });
  21245. }
  21246. /**
  21247. * The base implementation of `_.pick` without support for individual
  21248. * property identifiers.
  21249. *
  21250. * @private
  21251. * @param {Object} object The source object.
  21252. * @param {string[]} paths The property paths to pick.
  21253. * @returns {Object} Returns the new object.
  21254. */
  21255. function basePick(object, paths) {
  21256. return basePickBy(object, paths, function(value, path) {
  21257. return hasIn(object, path);
  21258. });
  21259. }
  21260. /**
  21261. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21262. *
  21263. * @private
  21264. * @param {Object} object The source object.
  21265. * @param {string[]} paths The property paths to pick.
  21266. * @param {Function} predicate The function invoked per property.
  21267. * @returns {Object} Returns the new object.
  21268. */
  21269. function basePickBy(object, paths, predicate) {
  21270. var index = -1,
  21271. length = paths.length,
  21272. result = {};
  21273. while (++index < length) {
  21274. var path = paths[index],
  21275. value = baseGet(object, path);
  21276. if (predicate(value, path)) {
  21277. baseSet(result, castPath(path, object), value);
  21278. }
  21279. }
  21280. return result;
  21281. }
  21282. /**
  21283. * A specialized version of `baseProperty` which supports deep paths.
  21284. *
  21285. * @private
  21286. * @param {Array|string} path The path of the property to get.
  21287. * @returns {Function} Returns the new accessor function.
  21288. */
  21289. function basePropertyDeep(path) {
  21290. return function(object) {
  21291. return baseGet(object, path);
  21292. };
  21293. }
  21294. /**
  21295. * The base implementation of `_.pullAllBy` without support for iteratee
  21296. * shorthands.
  21297. *
  21298. * @private
  21299. * @param {Array} array The array to modify.
  21300. * @param {Array} values The values to remove.
  21301. * @param {Function} [iteratee] The iteratee invoked per element.
  21302. * @param {Function} [comparator] The comparator invoked per element.
  21303. * @returns {Array} Returns `array`.
  21304. */
  21305. function basePullAll(array, values, iteratee, comparator) {
  21306. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21307. index = -1,
  21308. length = values.length,
  21309. seen = array;
  21310. if (array === values) {
  21311. values = copyArray(values);
  21312. }
  21313. if (iteratee) {
  21314. seen = arrayMap(array, baseUnary(iteratee));
  21315. }
  21316. while (++index < length) {
  21317. var fromIndex = 0,
  21318. value = values[index],
  21319. computed = iteratee ? iteratee(value) : value;
  21320. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21321. if (seen !== array) {
  21322. splice.call(seen, fromIndex, 1);
  21323. }
  21324. splice.call(array, fromIndex, 1);
  21325. }
  21326. }
  21327. return array;
  21328. }
  21329. /**
  21330. * The base implementation of `_.pullAt` without support for individual
  21331. * indexes or capturing the removed elements.
  21332. *
  21333. * @private
  21334. * @param {Array} array The array to modify.
  21335. * @param {number[]} indexes The indexes of elements to remove.
  21336. * @returns {Array} Returns `array`.
  21337. */
  21338. function basePullAt(array, indexes) {
  21339. var length = array ? indexes.length : 0,
  21340. lastIndex = length - 1;
  21341. while (length--) {
  21342. var index = indexes[length];
  21343. if (length == lastIndex || index !== previous) {
  21344. var previous = index;
  21345. if (isIndex(index)) {
  21346. splice.call(array, index, 1);
  21347. } else {
  21348. baseUnset(array, index);
  21349. }
  21350. }
  21351. }
  21352. return array;
  21353. }
  21354. /**
  21355. * The base implementation of `_.random` without support for returning
  21356. * floating-point numbers.
  21357. *
  21358. * @private
  21359. * @param {number} lower The lower bound.
  21360. * @param {number} upper The upper bound.
  21361. * @returns {number} Returns the random number.
  21362. */
  21363. function baseRandom(lower, upper) {
  21364. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21365. }
  21366. /**
  21367. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21368. * coerce arguments.
  21369. *
  21370. * @private
  21371. * @param {number} start The start of the range.
  21372. * @param {number} end The end of the range.
  21373. * @param {number} step The value to increment or decrement by.
  21374. * @param {boolean} [fromRight] Specify iterating from right to left.
  21375. * @returns {Array} Returns the range of numbers.
  21376. */
  21377. function baseRange(start, end, step, fromRight) {
  21378. var index = -1,
  21379. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21380. result = Array(length);
  21381. while (length--) {
  21382. result[fromRight ? length : ++index] = start;
  21383. start += step;
  21384. }
  21385. return result;
  21386. }
  21387. /**
  21388. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21389. *
  21390. * @private
  21391. * @param {string} string The string to repeat.
  21392. * @param {number} n The number of times to repeat the string.
  21393. * @returns {string} Returns the repeated string.
  21394. */
  21395. function baseRepeat(string, n) {
  21396. var result = '';
  21397. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21398. return result;
  21399. }
  21400. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21401. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21402. do {
  21403. if (n % 2) {
  21404. result += string;
  21405. }
  21406. n = nativeFloor(n / 2);
  21407. if (n) {
  21408. string += string;
  21409. }
  21410. } while (n);
  21411. return result;
  21412. }
  21413. /**
  21414. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21415. *
  21416. * @private
  21417. * @param {Function} func The function to apply a rest parameter to.
  21418. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21419. * @returns {Function} Returns the new function.
  21420. */
  21421. function baseRest(func, start) {
  21422. return setToString(overRest(func, start, identity), func + '');
  21423. }
  21424. /**
  21425. * The base implementation of `_.sample`.
  21426. *
  21427. * @private
  21428. * @param {Array|Object} collection The collection to sample.
  21429. * @returns {*} Returns the random element.
  21430. */
  21431. function baseSample(collection) {
  21432. return arraySample(values(collection));
  21433. }
  21434. /**
  21435. * The base implementation of `_.sampleSize` without param guards.
  21436. *
  21437. * @private
  21438. * @param {Array|Object} collection The collection to sample.
  21439. * @param {number} n The number of elements to sample.
  21440. * @returns {Array} Returns the random elements.
  21441. */
  21442. function baseSampleSize(collection, n) {
  21443. var array = values(collection);
  21444. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21445. }
  21446. /**
  21447. * The base implementation of `_.set`.
  21448. *
  21449. * @private
  21450. * @param {Object} object The object to modify.
  21451. * @param {Array|string} path The path of the property to set.
  21452. * @param {*} value The value to set.
  21453. * @param {Function} [customizer] The function to customize path creation.
  21454. * @returns {Object} Returns `object`.
  21455. */
  21456. function baseSet(object, path, value, customizer) {
  21457. if (!isObject(object)) {
  21458. return object;
  21459. }
  21460. path = castPath(path, object);
  21461. var index = -1,
  21462. length = path.length,
  21463. lastIndex = length - 1,
  21464. nested = object;
  21465. while (nested != null && ++index < length) {
  21466. var key = toKey(path[index]),
  21467. newValue = value;
  21468. if (index != lastIndex) {
  21469. var objValue = nested[key];
  21470. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21471. if (newValue === undefined) {
  21472. newValue = isObject(objValue)
  21473. ? objValue
  21474. : (isIndex(path[index + 1]) ? [] : {});
  21475. }
  21476. }
  21477. assignValue(nested, key, newValue);
  21478. nested = nested[key];
  21479. }
  21480. return object;
  21481. }
  21482. /**
  21483. * The base implementation of `setData` without support for hot loop shorting.
  21484. *
  21485. * @private
  21486. * @param {Function} func The function to associate metadata with.
  21487. * @param {*} data The metadata.
  21488. * @returns {Function} Returns `func`.
  21489. */
  21490. var baseSetData = !metaMap ? identity : function(func, data) {
  21491. metaMap.set(func, data);
  21492. return func;
  21493. };
  21494. /**
  21495. * The base implementation of `setToString` without support for hot loop shorting.
  21496. *
  21497. * @private
  21498. * @param {Function} func The function to modify.
  21499. * @param {Function} string The `toString` result.
  21500. * @returns {Function} Returns `func`.
  21501. */
  21502. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21503. return defineProperty(func, 'toString', {
  21504. 'configurable': true,
  21505. 'enumerable': false,
  21506. 'value': constant(string),
  21507. 'writable': true
  21508. });
  21509. };
  21510. /**
  21511. * The base implementation of `_.shuffle`.
  21512. *
  21513. * @private
  21514. * @param {Array|Object} collection The collection to shuffle.
  21515. * @returns {Array} Returns the new shuffled array.
  21516. */
  21517. function baseShuffle(collection) {
  21518. return shuffleSelf(values(collection));
  21519. }
  21520. /**
  21521. * The base implementation of `_.slice` without an iteratee call guard.
  21522. *
  21523. * @private
  21524. * @param {Array} array The array to slice.
  21525. * @param {number} [start=0] The start position.
  21526. * @param {number} [end=array.length] The end position.
  21527. * @returns {Array} Returns the slice of `array`.
  21528. */
  21529. function baseSlice(array, start, end) {
  21530. var index = -1,
  21531. length = array.length;
  21532. if (start < 0) {
  21533. start = -start > length ? 0 : (length + start);
  21534. }
  21535. end = end > length ? length : end;
  21536. if (end < 0) {
  21537. end += length;
  21538. }
  21539. length = start > end ? 0 : ((end - start) >>> 0);
  21540. start >>>= 0;
  21541. var result = Array(length);
  21542. while (++index < length) {
  21543. result[index] = array[index + start];
  21544. }
  21545. return result;
  21546. }
  21547. /**
  21548. * The base implementation of `_.some` without support for iteratee shorthands.
  21549. *
  21550. * @private
  21551. * @param {Array|Object} collection The collection to iterate over.
  21552. * @param {Function} predicate The function invoked per iteration.
  21553. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21554. * else `false`.
  21555. */
  21556. function baseSome(collection, predicate) {
  21557. var result;
  21558. baseEach(collection, function(value, index, collection) {
  21559. result = predicate(value, index, collection);
  21560. return !result;
  21561. });
  21562. return !!result;
  21563. }
  21564. /**
  21565. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21566. * performs a binary search of `array` to determine the index at which `value`
  21567. * should be inserted into `array` in order to maintain its sort order.
  21568. *
  21569. * @private
  21570. * @param {Array} array The sorted array to inspect.
  21571. * @param {*} value The value to evaluate.
  21572. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21573. * @returns {number} Returns the index at which `value` should be inserted
  21574. * into `array`.
  21575. */
  21576. function baseSortedIndex(array, value, retHighest) {
  21577. var low = 0,
  21578. high = array == null ? low : array.length;
  21579. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21580. while (low < high) {
  21581. var mid = (low + high) >>> 1,
  21582. computed = array[mid];
  21583. if (computed !== null && !isSymbol(computed) &&
  21584. (retHighest ? (computed <= value) : (computed < value))) {
  21585. low = mid + 1;
  21586. } else {
  21587. high = mid;
  21588. }
  21589. }
  21590. return high;
  21591. }
  21592. return baseSortedIndexBy(array, value, identity, retHighest);
  21593. }
  21594. /**
  21595. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21596. * which invokes `iteratee` for `value` and each element of `array` to compute
  21597. * their sort ranking. The iteratee is invoked with one argument; (value).
  21598. *
  21599. * @private
  21600. * @param {Array} array The sorted array to inspect.
  21601. * @param {*} value The value to evaluate.
  21602. * @param {Function} iteratee The iteratee invoked per element.
  21603. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21604. * @returns {number} Returns the index at which `value` should be inserted
  21605. * into `array`.
  21606. */
  21607. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21608. value = iteratee(value);
  21609. var low = 0,
  21610. high = array == null ? 0 : array.length,
  21611. valIsNaN = value !== value,
  21612. valIsNull = value === null,
  21613. valIsSymbol = isSymbol(value),
  21614. valIsUndefined = value === undefined;
  21615. while (low < high) {
  21616. var mid = nativeFloor((low + high) / 2),
  21617. computed = iteratee(array[mid]),
  21618. othIsDefined = computed !== undefined,
  21619. othIsNull = computed === null,
  21620. othIsReflexive = computed === computed,
  21621. othIsSymbol = isSymbol(computed);
  21622. if (valIsNaN) {
  21623. var setLow = retHighest || othIsReflexive;
  21624. } else if (valIsUndefined) {
  21625. setLow = othIsReflexive && (retHighest || othIsDefined);
  21626. } else if (valIsNull) {
  21627. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21628. } else if (valIsSymbol) {
  21629. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21630. } else if (othIsNull || othIsSymbol) {
  21631. setLow = false;
  21632. } else {
  21633. setLow = retHighest ? (computed <= value) : (computed < value);
  21634. }
  21635. if (setLow) {
  21636. low = mid + 1;
  21637. } else {
  21638. high = mid;
  21639. }
  21640. }
  21641. return nativeMin(high, MAX_ARRAY_INDEX);
  21642. }
  21643. /**
  21644. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21645. * support for iteratee shorthands.
  21646. *
  21647. * @private
  21648. * @param {Array} array The array to inspect.
  21649. * @param {Function} [iteratee] The iteratee invoked per element.
  21650. * @returns {Array} Returns the new duplicate free array.
  21651. */
  21652. function baseSortedUniq(array, iteratee) {
  21653. var index = -1,
  21654. length = array.length,
  21655. resIndex = 0,
  21656. result = [];
  21657. while (++index < length) {
  21658. var value = array[index],
  21659. computed = iteratee ? iteratee(value) : value;
  21660. if (!index || !eq(computed, seen)) {
  21661. var seen = computed;
  21662. result[resIndex++] = value === 0 ? 0 : value;
  21663. }
  21664. }
  21665. return result;
  21666. }
  21667. /**
  21668. * The base implementation of `_.toNumber` which doesn't ensure correct
  21669. * conversions of binary, hexadecimal, or octal string values.
  21670. *
  21671. * @private
  21672. * @param {*} value The value to process.
  21673. * @returns {number} Returns the number.
  21674. */
  21675. function baseToNumber(value) {
  21676. if (typeof value == 'number') {
  21677. return value;
  21678. }
  21679. if (isSymbol(value)) {
  21680. return NAN;
  21681. }
  21682. return +value;
  21683. }
  21684. /**
  21685. * The base implementation of `_.toString` which doesn't convert nullish
  21686. * values to empty strings.
  21687. *
  21688. * @private
  21689. * @param {*} value The value to process.
  21690. * @returns {string} Returns the string.
  21691. */
  21692. function baseToString(value) {
  21693. // Exit early for strings to avoid a performance hit in some environments.
  21694. if (typeof value == 'string') {
  21695. return value;
  21696. }
  21697. if (isArray(value)) {
  21698. // Recursively convert values (susceptible to call stack limits).
  21699. return arrayMap(value, baseToString) + '';
  21700. }
  21701. if (isSymbol(value)) {
  21702. return symbolToString ? symbolToString.call(value) : '';
  21703. }
  21704. var result = (value + '');
  21705. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21706. }
  21707. /**
  21708. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21709. *
  21710. * @private
  21711. * @param {Array} array The array to inspect.
  21712. * @param {Function} [iteratee] The iteratee invoked per element.
  21713. * @param {Function} [comparator] The comparator invoked per element.
  21714. * @returns {Array} Returns the new duplicate free array.
  21715. */
  21716. function baseUniq(array, iteratee, comparator) {
  21717. var index = -1,
  21718. includes = arrayIncludes,
  21719. length = array.length,
  21720. isCommon = true,
  21721. result = [],
  21722. seen = result;
  21723. if (comparator) {
  21724. isCommon = false;
  21725. includes = arrayIncludesWith;
  21726. }
  21727. else if (length >= LARGE_ARRAY_SIZE) {
  21728. var set = iteratee ? null : createSet(array);
  21729. if (set) {
  21730. return setToArray(set);
  21731. }
  21732. isCommon = false;
  21733. includes = cacheHas;
  21734. seen = new SetCache;
  21735. }
  21736. else {
  21737. seen = iteratee ? [] : result;
  21738. }
  21739. outer:
  21740. while (++index < length) {
  21741. var value = array[index],
  21742. computed = iteratee ? iteratee(value) : value;
  21743. value = (comparator || value !== 0) ? value : 0;
  21744. if (isCommon && computed === computed) {
  21745. var seenIndex = seen.length;
  21746. while (seenIndex--) {
  21747. if (seen[seenIndex] === computed) {
  21748. continue outer;
  21749. }
  21750. }
  21751. if (iteratee) {
  21752. seen.push(computed);
  21753. }
  21754. result.push(value);
  21755. }
  21756. else if (!includes(seen, computed, comparator)) {
  21757. if (seen !== result) {
  21758. seen.push(computed);
  21759. }
  21760. result.push(value);
  21761. }
  21762. }
  21763. return result;
  21764. }
  21765. /**
  21766. * The base implementation of `_.unset`.
  21767. *
  21768. * @private
  21769. * @param {Object} object The object to modify.
  21770. * @param {Array|string} path The property path to unset.
  21771. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21772. */
  21773. function baseUnset(object, path) {
  21774. path = castPath(path, object);
  21775. object = parent(object, path);
  21776. return object == null || delete object[toKey(last(path))];
  21777. }
  21778. /**
  21779. * The base implementation of `_.update`.
  21780. *
  21781. * @private
  21782. * @param {Object} object The object to modify.
  21783. * @param {Array|string} path The path of the property to update.
  21784. * @param {Function} updater The function to produce the updated value.
  21785. * @param {Function} [customizer] The function to customize path creation.
  21786. * @returns {Object} Returns `object`.
  21787. */
  21788. function baseUpdate(object, path, updater, customizer) {
  21789. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21790. }
  21791. /**
  21792. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21793. * without support for iteratee shorthands.
  21794. *
  21795. * @private
  21796. * @param {Array} array The array to query.
  21797. * @param {Function} predicate The function invoked per iteration.
  21798. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21799. * @param {boolean} [fromRight] Specify iterating from right to left.
  21800. * @returns {Array} Returns the slice of `array`.
  21801. */
  21802. function baseWhile(array, predicate, isDrop, fromRight) {
  21803. var length = array.length,
  21804. index = fromRight ? length : -1;
  21805. while ((fromRight ? index-- : ++index < length) &&
  21806. predicate(array[index], index, array)) {}
  21807. return isDrop
  21808. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21809. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21810. }
  21811. /**
  21812. * The base implementation of `wrapperValue` which returns the result of
  21813. * performing a sequence of actions on the unwrapped `value`, where each
  21814. * successive action is supplied the return value of the previous.
  21815. *
  21816. * @private
  21817. * @param {*} value The unwrapped value.
  21818. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21819. * @returns {*} Returns the resolved value.
  21820. */
  21821. function baseWrapperValue(value, actions) {
  21822. var result = value;
  21823. if (result instanceof LazyWrapper) {
  21824. result = result.value();
  21825. }
  21826. return arrayReduce(actions, function(result, action) {
  21827. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21828. }, result);
  21829. }
  21830. /**
  21831. * The base implementation of methods like `_.xor`, without support for
  21832. * iteratee shorthands, that accepts an array of arrays to inspect.
  21833. *
  21834. * @private
  21835. * @param {Array} arrays The arrays to inspect.
  21836. * @param {Function} [iteratee] The iteratee invoked per element.
  21837. * @param {Function} [comparator] The comparator invoked per element.
  21838. * @returns {Array} Returns the new array of values.
  21839. */
  21840. function baseXor(arrays, iteratee, comparator) {
  21841. var length = arrays.length;
  21842. if (length < 2) {
  21843. return length ? baseUniq(arrays[0]) : [];
  21844. }
  21845. var index = -1,
  21846. result = Array(length);
  21847. while (++index < length) {
  21848. var array = arrays[index],
  21849. othIndex = -1;
  21850. while (++othIndex < length) {
  21851. if (othIndex != index) {
  21852. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21853. }
  21854. }
  21855. }
  21856. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21857. }
  21858. /**
  21859. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21860. *
  21861. * @private
  21862. * @param {Array} props The property identifiers.
  21863. * @param {Array} values The property values.
  21864. * @param {Function} assignFunc The function to assign values.
  21865. * @returns {Object} Returns the new object.
  21866. */
  21867. function baseZipObject(props, values, assignFunc) {
  21868. var index = -1,
  21869. length = props.length,
  21870. valsLength = values.length,
  21871. result = {};
  21872. while (++index < length) {
  21873. var value = index < valsLength ? values[index] : undefined;
  21874. assignFunc(result, props[index], value);
  21875. }
  21876. return result;
  21877. }
  21878. /**
  21879. * Casts `value` to an empty array if it's not an array like object.
  21880. *
  21881. * @private
  21882. * @param {*} value The value to inspect.
  21883. * @returns {Array|Object} Returns the cast array-like object.
  21884. */
  21885. function castArrayLikeObject(value) {
  21886. return isArrayLikeObject(value) ? value : [];
  21887. }
  21888. /**
  21889. * Casts `value` to `identity` if it's not a function.
  21890. *
  21891. * @private
  21892. * @param {*} value The value to inspect.
  21893. * @returns {Function} Returns cast function.
  21894. */
  21895. function castFunction(value) {
  21896. return typeof value == 'function' ? value : identity;
  21897. }
  21898. /**
  21899. * Casts `value` to a path array if it's not one.
  21900. *
  21901. * @private
  21902. * @param {*} value The value to inspect.
  21903. * @param {Object} [object] The object to query keys on.
  21904. * @returns {Array} Returns the cast property path array.
  21905. */
  21906. function castPath(value, object) {
  21907. if (isArray(value)) {
  21908. return value;
  21909. }
  21910. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21911. }
  21912. /**
  21913. * A `baseRest` alias which can be replaced with `identity` by module
  21914. * replacement plugins.
  21915. *
  21916. * @private
  21917. * @type {Function}
  21918. * @param {Function} func The function to apply a rest parameter to.
  21919. * @returns {Function} Returns the new function.
  21920. */
  21921. var castRest = baseRest;
  21922. /**
  21923. * Casts `array` to a slice if it's needed.
  21924. *
  21925. * @private
  21926. * @param {Array} array The array to inspect.
  21927. * @param {number} start The start position.
  21928. * @param {number} [end=array.length] The end position.
  21929. * @returns {Array} Returns the cast slice.
  21930. */
  21931. function castSlice(array, start, end) {
  21932. var length = array.length;
  21933. end = end === undefined ? length : end;
  21934. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21935. }
  21936. /**
  21937. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21938. *
  21939. * @private
  21940. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21941. */
  21942. var clearTimeout = ctxClearTimeout || function(id) {
  21943. return root.clearTimeout(id);
  21944. };
  21945. /**
  21946. * Creates a clone of `buffer`.
  21947. *
  21948. * @private
  21949. * @param {Buffer} buffer The buffer to clone.
  21950. * @param {boolean} [isDeep] Specify a deep clone.
  21951. * @returns {Buffer} Returns the cloned buffer.
  21952. */
  21953. function cloneBuffer(buffer, isDeep) {
  21954. if (isDeep) {
  21955. return buffer.slice();
  21956. }
  21957. var length = buffer.length,
  21958. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21959. buffer.copy(result);
  21960. return result;
  21961. }
  21962. /**
  21963. * Creates a clone of `arrayBuffer`.
  21964. *
  21965. * @private
  21966. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21967. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21968. */
  21969. function cloneArrayBuffer(arrayBuffer) {
  21970. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21971. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21972. return result;
  21973. }
  21974. /**
  21975. * Creates a clone of `dataView`.
  21976. *
  21977. * @private
  21978. * @param {Object} dataView The data view to clone.
  21979. * @param {boolean} [isDeep] Specify a deep clone.
  21980. * @returns {Object} Returns the cloned data view.
  21981. */
  21982. function cloneDataView(dataView, isDeep) {
  21983. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21984. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21985. }
  21986. /**
  21987. * Creates a clone of `regexp`.
  21988. *
  21989. * @private
  21990. * @param {Object} regexp The regexp to clone.
  21991. * @returns {Object} Returns the cloned regexp.
  21992. */
  21993. function cloneRegExp(regexp) {
  21994. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21995. result.lastIndex = regexp.lastIndex;
  21996. return result;
  21997. }
  21998. /**
  21999. * Creates a clone of the `symbol` object.
  22000. *
  22001. * @private
  22002. * @param {Object} symbol The symbol object to clone.
  22003. * @returns {Object} Returns the cloned symbol object.
  22004. */
  22005. function cloneSymbol(symbol) {
  22006. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  22007. }
  22008. /**
  22009. * Creates a clone of `typedArray`.
  22010. *
  22011. * @private
  22012. * @param {Object} typedArray The typed array to clone.
  22013. * @param {boolean} [isDeep] Specify a deep clone.
  22014. * @returns {Object} Returns the cloned typed array.
  22015. */
  22016. function cloneTypedArray(typedArray, isDeep) {
  22017. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  22018. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  22019. }
  22020. /**
  22021. * Compares values to sort them in ascending order.
  22022. *
  22023. * @private
  22024. * @param {*} value The value to compare.
  22025. * @param {*} other The other value to compare.
  22026. * @returns {number} Returns the sort order indicator for `value`.
  22027. */
  22028. function compareAscending(value, other) {
  22029. if (value !== other) {
  22030. var valIsDefined = value !== undefined,
  22031. valIsNull = value === null,
  22032. valIsReflexive = value === value,
  22033. valIsSymbol = isSymbol(value);
  22034. var othIsDefined = other !== undefined,
  22035. othIsNull = other === null,
  22036. othIsReflexive = other === other,
  22037. othIsSymbol = isSymbol(other);
  22038. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  22039. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  22040. (valIsNull && othIsDefined && othIsReflexive) ||
  22041. (!valIsDefined && othIsReflexive) ||
  22042. !valIsReflexive) {
  22043. return 1;
  22044. }
  22045. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  22046. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  22047. (othIsNull && valIsDefined && valIsReflexive) ||
  22048. (!othIsDefined && valIsReflexive) ||
  22049. !othIsReflexive) {
  22050. return -1;
  22051. }
  22052. }
  22053. return 0;
  22054. }
  22055. /**
  22056. * Used by `_.orderBy` to compare multiple properties of a value to another
  22057. * and stable sort them.
  22058. *
  22059. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  22060. * specify an order of "desc" for descending or "asc" for ascending sort order
  22061. * of corresponding values.
  22062. *
  22063. * @private
  22064. * @param {Object} object The object to compare.
  22065. * @param {Object} other The other object to compare.
  22066. * @param {boolean[]|string[]} orders The order to sort by for each property.
  22067. * @returns {number} Returns the sort order indicator for `object`.
  22068. */
  22069. function compareMultiple(object, other, orders) {
  22070. var index = -1,
  22071. objCriteria = object.criteria,
  22072. othCriteria = other.criteria,
  22073. length = objCriteria.length,
  22074. ordersLength = orders.length;
  22075. while (++index < length) {
  22076. var result = compareAscending(objCriteria[index], othCriteria[index]);
  22077. if (result) {
  22078. if (index >= ordersLength) {
  22079. return result;
  22080. }
  22081. var order = orders[index];
  22082. return result * (order == 'desc' ? -1 : 1);
  22083. }
  22084. }
  22085. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  22086. // that causes it, under certain circumstances, to provide the same value for
  22087. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  22088. // for more details.
  22089. //
  22090. // This also ensures a stable sort in V8 and other engines.
  22091. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  22092. return object.index - other.index;
  22093. }
  22094. /**
  22095. * Creates an array that is the composition of partially applied arguments,
  22096. * placeholders, and provided arguments into a single array of arguments.
  22097. *
  22098. * @private
  22099. * @param {Array} args The provided arguments.
  22100. * @param {Array} partials The arguments to prepend to those provided.
  22101. * @param {Array} holders The `partials` placeholder indexes.
  22102. * @params {boolean} [isCurried] Specify composing for a curried function.
  22103. * @returns {Array} Returns the new array of composed arguments.
  22104. */
  22105. function composeArgs(args, partials, holders, isCurried) {
  22106. var argsIndex = -1,
  22107. argsLength = args.length,
  22108. holdersLength = holders.length,
  22109. leftIndex = -1,
  22110. leftLength = partials.length,
  22111. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22112. result = Array(leftLength + rangeLength),
  22113. isUncurried = !isCurried;
  22114. while (++leftIndex < leftLength) {
  22115. result[leftIndex] = partials[leftIndex];
  22116. }
  22117. while (++argsIndex < holdersLength) {
  22118. if (isUncurried || argsIndex < argsLength) {
  22119. result[holders[argsIndex]] = args[argsIndex];
  22120. }
  22121. }
  22122. while (rangeLength--) {
  22123. result[leftIndex++] = args[argsIndex++];
  22124. }
  22125. return result;
  22126. }
  22127. /**
  22128. * This function is like `composeArgs` except that the arguments composition
  22129. * is tailored for `_.partialRight`.
  22130. *
  22131. * @private
  22132. * @param {Array} args The provided arguments.
  22133. * @param {Array} partials The arguments to append to those provided.
  22134. * @param {Array} holders The `partials` placeholder indexes.
  22135. * @params {boolean} [isCurried] Specify composing for a curried function.
  22136. * @returns {Array} Returns the new array of composed arguments.
  22137. */
  22138. function composeArgsRight(args, partials, holders, isCurried) {
  22139. var argsIndex = -1,
  22140. argsLength = args.length,
  22141. holdersIndex = -1,
  22142. holdersLength = holders.length,
  22143. rightIndex = -1,
  22144. rightLength = partials.length,
  22145. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22146. result = Array(rangeLength + rightLength),
  22147. isUncurried = !isCurried;
  22148. while (++argsIndex < rangeLength) {
  22149. result[argsIndex] = args[argsIndex];
  22150. }
  22151. var offset = argsIndex;
  22152. while (++rightIndex < rightLength) {
  22153. result[offset + rightIndex] = partials[rightIndex];
  22154. }
  22155. while (++holdersIndex < holdersLength) {
  22156. if (isUncurried || argsIndex < argsLength) {
  22157. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22158. }
  22159. }
  22160. return result;
  22161. }
  22162. /**
  22163. * Copies the values of `source` to `array`.
  22164. *
  22165. * @private
  22166. * @param {Array} source The array to copy values from.
  22167. * @param {Array} [array=[]] The array to copy values to.
  22168. * @returns {Array} Returns `array`.
  22169. */
  22170. function copyArray(source, array) {
  22171. var index = -1,
  22172. length = source.length;
  22173. array || (array = Array(length));
  22174. while (++index < length) {
  22175. array[index] = source[index];
  22176. }
  22177. return array;
  22178. }
  22179. /**
  22180. * Copies properties of `source` to `object`.
  22181. *
  22182. * @private
  22183. * @param {Object} source The object to copy properties from.
  22184. * @param {Array} props The property identifiers to copy.
  22185. * @param {Object} [object={}] The object to copy properties to.
  22186. * @param {Function} [customizer] The function to customize copied values.
  22187. * @returns {Object} Returns `object`.
  22188. */
  22189. function copyObject(source, props, object, customizer) {
  22190. var isNew = !object;
  22191. object || (object = {});
  22192. var index = -1,
  22193. length = props.length;
  22194. while (++index < length) {
  22195. var key = props[index];
  22196. var newValue = customizer
  22197. ? customizer(object[key], source[key], key, object, source)
  22198. : undefined;
  22199. if (newValue === undefined) {
  22200. newValue = source[key];
  22201. }
  22202. if (isNew) {
  22203. baseAssignValue(object, key, newValue);
  22204. } else {
  22205. assignValue(object, key, newValue);
  22206. }
  22207. }
  22208. return object;
  22209. }
  22210. /**
  22211. * Copies own symbols of `source` to `object`.
  22212. *
  22213. * @private
  22214. * @param {Object} source The object to copy symbols from.
  22215. * @param {Object} [object={}] The object to copy symbols to.
  22216. * @returns {Object} Returns `object`.
  22217. */
  22218. function copySymbols(source, object) {
  22219. return copyObject(source, getSymbols(source), object);
  22220. }
  22221. /**
  22222. * Copies own and inherited symbols of `source` to `object`.
  22223. *
  22224. * @private
  22225. * @param {Object} source The object to copy symbols from.
  22226. * @param {Object} [object={}] The object to copy symbols to.
  22227. * @returns {Object} Returns `object`.
  22228. */
  22229. function copySymbolsIn(source, object) {
  22230. return copyObject(source, getSymbolsIn(source), object);
  22231. }
  22232. /**
  22233. * Creates a function like `_.groupBy`.
  22234. *
  22235. * @private
  22236. * @param {Function} setter The function to set accumulator values.
  22237. * @param {Function} [initializer] The accumulator object initializer.
  22238. * @returns {Function} Returns the new aggregator function.
  22239. */
  22240. function createAggregator(setter, initializer) {
  22241. return function(collection, iteratee) {
  22242. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22243. accumulator = initializer ? initializer() : {};
  22244. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22245. };
  22246. }
  22247. /**
  22248. * Creates a function like `_.assign`.
  22249. *
  22250. * @private
  22251. * @param {Function} assigner The function to assign values.
  22252. * @returns {Function} Returns the new assigner function.
  22253. */
  22254. function createAssigner(assigner) {
  22255. return baseRest(function(object, sources) {
  22256. var index = -1,
  22257. length = sources.length,
  22258. customizer = length > 1 ? sources[length - 1] : undefined,
  22259. guard = length > 2 ? sources[2] : undefined;
  22260. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22261. ? (length--, customizer)
  22262. : undefined;
  22263. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22264. customizer = length < 3 ? undefined : customizer;
  22265. length = 1;
  22266. }
  22267. object = Object(object);
  22268. while (++index < length) {
  22269. var source = sources[index];
  22270. if (source) {
  22271. assigner(object, source, index, customizer);
  22272. }
  22273. }
  22274. return object;
  22275. });
  22276. }
  22277. /**
  22278. * Creates a `baseEach` or `baseEachRight` function.
  22279. *
  22280. * @private
  22281. * @param {Function} eachFunc The function to iterate over a collection.
  22282. * @param {boolean} [fromRight] Specify iterating from right to left.
  22283. * @returns {Function} Returns the new base function.
  22284. */
  22285. function createBaseEach(eachFunc, fromRight) {
  22286. return function(collection, iteratee) {
  22287. if (collection == null) {
  22288. return collection;
  22289. }
  22290. if (!isArrayLike(collection)) {
  22291. return eachFunc(collection, iteratee);
  22292. }
  22293. var length = collection.length,
  22294. index = fromRight ? length : -1,
  22295. iterable = Object(collection);
  22296. while ((fromRight ? index-- : ++index < length)) {
  22297. if (iteratee(iterable[index], index, iterable) === false) {
  22298. break;
  22299. }
  22300. }
  22301. return collection;
  22302. };
  22303. }
  22304. /**
  22305. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22306. *
  22307. * @private
  22308. * @param {boolean} [fromRight] Specify iterating from right to left.
  22309. * @returns {Function} Returns the new base function.
  22310. */
  22311. function createBaseFor(fromRight) {
  22312. return function(object, iteratee, keysFunc) {
  22313. var index = -1,
  22314. iterable = Object(object),
  22315. props = keysFunc(object),
  22316. length = props.length;
  22317. while (length--) {
  22318. var key = props[fromRight ? length : ++index];
  22319. if (iteratee(iterable[key], key, iterable) === false) {
  22320. break;
  22321. }
  22322. }
  22323. return object;
  22324. };
  22325. }
  22326. /**
  22327. * Creates a function that wraps `func` to invoke it with the optional `this`
  22328. * binding of `thisArg`.
  22329. *
  22330. * @private
  22331. * @param {Function} func The function to wrap.
  22332. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22333. * @param {*} [thisArg] The `this` binding of `func`.
  22334. * @returns {Function} Returns the new wrapped function.
  22335. */
  22336. function createBind(func, bitmask, thisArg) {
  22337. var isBind = bitmask & WRAP_BIND_FLAG,
  22338. Ctor = createCtor(func);
  22339. function wrapper() {
  22340. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22341. return fn.apply(isBind ? thisArg : this, arguments);
  22342. }
  22343. return wrapper;
  22344. }
  22345. /**
  22346. * Creates a function like `_.lowerFirst`.
  22347. *
  22348. * @private
  22349. * @param {string} methodName The name of the `String` case method to use.
  22350. * @returns {Function} Returns the new case function.
  22351. */
  22352. function createCaseFirst(methodName) {
  22353. return function(string) {
  22354. string = toString(string);
  22355. var strSymbols = hasUnicode(string)
  22356. ? stringToArray(string)
  22357. : undefined;
  22358. var chr = strSymbols
  22359. ? strSymbols[0]
  22360. : string.charAt(0);
  22361. var trailing = strSymbols
  22362. ? castSlice(strSymbols, 1).join('')
  22363. : string.slice(1);
  22364. return chr[methodName]() + trailing;
  22365. };
  22366. }
  22367. /**
  22368. * Creates a function like `_.camelCase`.
  22369. *
  22370. * @private
  22371. * @param {Function} callback The function to combine each word.
  22372. * @returns {Function} Returns the new compounder function.
  22373. */
  22374. function createCompounder(callback) {
  22375. return function(string) {
  22376. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22377. };
  22378. }
  22379. /**
  22380. * Creates a function that produces an instance of `Ctor` regardless of
  22381. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22382. *
  22383. * @private
  22384. * @param {Function} Ctor The constructor to wrap.
  22385. * @returns {Function} Returns the new wrapped function.
  22386. */
  22387. function createCtor(Ctor) {
  22388. return function() {
  22389. // Use a `switch` statement to work with class constructors. See
  22390. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22391. // for more details.
  22392. var args = arguments;
  22393. switch (args.length) {
  22394. case 0: return new Ctor;
  22395. case 1: return new Ctor(args[0]);
  22396. case 2: return new Ctor(args[0], args[1]);
  22397. case 3: return new Ctor(args[0], args[1], args[2]);
  22398. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22399. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22400. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22401. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22402. }
  22403. var thisBinding = baseCreate(Ctor.prototype),
  22404. result = Ctor.apply(thisBinding, args);
  22405. // Mimic the constructor's `return` behavior.
  22406. // See https://es5.github.io/#x13.2.2 for more details.
  22407. return isObject(result) ? result : thisBinding;
  22408. };
  22409. }
  22410. /**
  22411. * Creates a function that wraps `func` to enable currying.
  22412. *
  22413. * @private
  22414. * @param {Function} func The function to wrap.
  22415. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22416. * @param {number} arity The arity of `func`.
  22417. * @returns {Function} Returns the new wrapped function.
  22418. */
  22419. function createCurry(func, bitmask, arity) {
  22420. var Ctor = createCtor(func);
  22421. function wrapper() {
  22422. var length = arguments.length,
  22423. args = Array(length),
  22424. index = length,
  22425. placeholder = getHolder(wrapper);
  22426. while (index--) {
  22427. args[index] = arguments[index];
  22428. }
  22429. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22430. ? []
  22431. : replaceHolders(args, placeholder);
  22432. length -= holders.length;
  22433. if (length < arity) {
  22434. return createRecurry(
  22435. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22436. args, holders, undefined, undefined, arity - length);
  22437. }
  22438. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22439. return apply(fn, this, args);
  22440. }
  22441. return wrapper;
  22442. }
  22443. /**
  22444. * Creates a `_.find` or `_.findLast` function.
  22445. *
  22446. * @private
  22447. * @param {Function} findIndexFunc The function to find the collection index.
  22448. * @returns {Function} Returns the new find function.
  22449. */
  22450. function createFind(findIndexFunc) {
  22451. return function(collection, predicate, fromIndex) {
  22452. var iterable = Object(collection);
  22453. if (!isArrayLike(collection)) {
  22454. var iteratee = getIteratee(predicate, 3);
  22455. collection = keys(collection);
  22456. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22457. }
  22458. var index = findIndexFunc(collection, predicate, fromIndex);
  22459. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22460. };
  22461. }
  22462. /**
  22463. * Creates a `_.flow` or `_.flowRight` function.
  22464. *
  22465. * @private
  22466. * @param {boolean} [fromRight] Specify iterating from right to left.
  22467. * @returns {Function} Returns the new flow function.
  22468. */
  22469. function createFlow(fromRight) {
  22470. return flatRest(function(funcs) {
  22471. var length = funcs.length,
  22472. index = length,
  22473. prereq = LodashWrapper.prototype.thru;
  22474. if (fromRight) {
  22475. funcs.reverse();
  22476. }
  22477. while (index--) {
  22478. var func = funcs[index];
  22479. if (typeof func != 'function') {
  22480. throw new TypeError(FUNC_ERROR_TEXT);
  22481. }
  22482. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22483. var wrapper = new LodashWrapper([], true);
  22484. }
  22485. }
  22486. index = wrapper ? index : length;
  22487. while (++index < length) {
  22488. func = funcs[index];
  22489. var funcName = getFuncName(func),
  22490. data = funcName == 'wrapper' ? getData(func) : undefined;
  22491. if (data && isLaziable(data[0]) &&
  22492. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22493. !data[4].length && data[9] == 1
  22494. ) {
  22495. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22496. } else {
  22497. wrapper = (func.length == 1 && isLaziable(func))
  22498. ? wrapper[funcName]()
  22499. : wrapper.thru(func);
  22500. }
  22501. }
  22502. return function() {
  22503. var args = arguments,
  22504. value = args[0];
  22505. if (wrapper && args.length == 1 && isArray(value)) {
  22506. return wrapper.plant(value).value();
  22507. }
  22508. var index = 0,
  22509. result = length ? funcs[index].apply(this, args) : value;
  22510. while (++index < length) {
  22511. result = funcs[index].call(this, result);
  22512. }
  22513. return result;
  22514. };
  22515. });
  22516. }
  22517. /**
  22518. * Creates a function that wraps `func` to invoke it with optional `this`
  22519. * binding of `thisArg`, partial application, and currying.
  22520. *
  22521. * @private
  22522. * @param {Function|string} func The function or method name to wrap.
  22523. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22524. * @param {*} [thisArg] The `this` binding of `func`.
  22525. * @param {Array} [partials] The arguments to prepend to those provided to
  22526. * the new function.
  22527. * @param {Array} [holders] The `partials` placeholder indexes.
  22528. * @param {Array} [partialsRight] The arguments to append to those provided
  22529. * to the new function.
  22530. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22531. * @param {Array} [argPos] The argument positions of the new function.
  22532. * @param {number} [ary] The arity cap of `func`.
  22533. * @param {number} [arity] The arity of `func`.
  22534. * @returns {Function} Returns the new wrapped function.
  22535. */
  22536. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22537. var isAry = bitmask & WRAP_ARY_FLAG,
  22538. isBind = bitmask & WRAP_BIND_FLAG,
  22539. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22540. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22541. isFlip = bitmask & WRAP_FLIP_FLAG,
  22542. Ctor = isBindKey ? undefined : createCtor(func);
  22543. function wrapper() {
  22544. var length = arguments.length,
  22545. args = Array(length),
  22546. index = length;
  22547. while (index--) {
  22548. args[index] = arguments[index];
  22549. }
  22550. if (isCurried) {
  22551. var placeholder = getHolder(wrapper),
  22552. holdersCount = countHolders(args, placeholder);
  22553. }
  22554. if (partials) {
  22555. args = composeArgs(args, partials, holders, isCurried);
  22556. }
  22557. if (partialsRight) {
  22558. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22559. }
  22560. length -= holdersCount;
  22561. if (isCurried && length < arity) {
  22562. var newHolders = replaceHolders(args, placeholder);
  22563. return createRecurry(
  22564. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22565. args, newHolders, argPos, ary, arity - length
  22566. );
  22567. }
  22568. var thisBinding = isBind ? thisArg : this,
  22569. fn = isBindKey ? thisBinding[func] : func;
  22570. length = args.length;
  22571. if (argPos) {
  22572. args = reorder(args, argPos);
  22573. } else if (isFlip && length > 1) {
  22574. args.reverse();
  22575. }
  22576. if (isAry && ary < length) {
  22577. args.length = ary;
  22578. }
  22579. if (this && this !== root && this instanceof wrapper) {
  22580. fn = Ctor || createCtor(fn);
  22581. }
  22582. return fn.apply(thisBinding, args);
  22583. }
  22584. return wrapper;
  22585. }
  22586. /**
  22587. * Creates a function like `_.invertBy`.
  22588. *
  22589. * @private
  22590. * @param {Function} setter The function to set accumulator values.
  22591. * @param {Function} toIteratee The function to resolve iteratees.
  22592. * @returns {Function} Returns the new inverter function.
  22593. */
  22594. function createInverter(setter, toIteratee) {
  22595. return function(object, iteratee) {
  22596. return baseInverter(object, setter, toIteratee(iteratee), {});
  22597. };
  22598. }
  22599. /**
  22600. * Creates a function that performs a mathematical operation on two values.
  22601. *
  22602. * @private
  22603. * @param {Function} operator The function to perform the operation.
  22604. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22605. * @returns {Function} Returns the new mathematical operation function.
  22606. */
  22607. function createMathOperation(operator, defaultValue) {
  22608. return function(value, other) {
  22609. var result;
  22610. if (value === undefined && other === undefined) {
  22611. return defaultValue;
  22612. }
  22613. if (value !== undefined) {
  22614. result = value;
  22615. }
  22616. if (other !== undefined) {
  22617. if (result === undefined) {
  22618. return other;
  22619. }
  22620. if (typeof value == 'string' || typeof other == 'string') {
  22621. value = baseToString(value);
  22622. other = baseToString(other);
  22623. } else {
  22624. value = baseToNumber(value);
  22625. other = baseToNumber(other);
  22626. }
  22627. result = operator(value, other);
  22628. }
  22629. return result;
  22630. };
  22631. }
  22632. /**
  22633. * Creates a function like `_.over`.
  22634. *
  22635. * @private
  22636. * @param {Function} arrayFunc The function to iterate over iteratees.
  22637. * @returns {Function} Returns the new over function.
  22638. */
  22639. function createOver(arrayFunc) {
  22640. return flatRest(function(iteratees) {
  22641. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22642. return baseRest(function(args) {
  22643. var thisArg = this;
  22644. return arrayFunc(iteratees, function(iteratee) {
  22645. return apply(iteratee, thisArg, args);
  22646. });
  22647. });
  22648. });
  22649. }
  22650. /**
  22651. * Creates the padding for `string` based on `length`. The `chars` string
  22652. * is truncated if the number of characters exceeds `length`.
  22653. *
  22654. * @private
  22655. * @param {number} length The padding length.
  22656. * @param {string} [chars=' '] The string used as padding.
  22657. * @returns {string} Returns the padding for `string`.
  22658. */
  22659. function createPadding(length, chars) {
  22660. chars = chars === undefined ? ' ' : baseToString(chars);
  22661. var charsLength = chars.length;
  22662. if (charsLength < 2) {
  22663. return charsLength ? baseRepeat(chars, length) : chars;
  22664. }
  22665. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22666. return hasUnicode(chars)
  22667. ? castSlice(stringToArray(result), 0, length).join('')
  22668. : result.slice(0, length);
  22669. }
  22670. /**
  22671. * Creates a function that wraps `func` to invoke it with the `this` binding
  22672. * of `thisArg` and `partials` prepended to the arguments it receives.
  22673. *
  22674. * @private
  22675. * @param {Function} func The function to wrap.
  22676. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22677. * @param {*} thisArg The `this` binding of `func`.
  22678. * @param {Array} partials The arguments to prepend to those provided to
  22679. * the new function.
  22680. * @returns {Function} Returns the new wrapped function.
  22681. */
  22682. function createPartial(func, bitmask, thisArg, partials) {
  22683. var isBind = bitmask & WRAP_BIND_FLAG,
  22684. Ctor = createCtor(func);
  22685. function wrapper() {
  22686. var argsIndex = -1,
  22687. argsLength = arguments.length,
  22688. leftIndex = -1,
  22689. leftLength = partials.length,
  22690. args = Array(leftLength + argsLength),
  22691. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22692. while (++leftIndex < leftLength) {
  22693. args[leftIndex] = partials[leftIndex];
  22694. }
  22695. while (argsLength--) {
  22696. args[leftIndex++] = arguments[++argsIndex];
  22697. }
  22698. return apply(fn, isBind ? thisArg : this, args);
  22699. }
  22700. return wrapper;
  22701. }
  22702. /**
  22703. * Creates a `_.range` or `_.rangeRight` function.
  22704. *
  22705. * @private
  22706. * @param {boolean} [fromRight] Specify iterating from right to left.
  22707. * @returns {Function} Returns the new range function.
  22708. */
  22709. function createRange(fromRight) {
  22710. return function(start, end, step) {
  22711. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22712. end = step = undefined;
  22713. }
  22714. // Ensure the sign of `-0` is preserved.
  22715. start = toFinite(start);
  22716. if (end === undefined) {
  22717. end = start;
  22718. start = 0;
  22719. } else {
  22720. end = toFinite(end);
  22721. }
  22722. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22723. return baseRange(start, end, step, fromRight);
  22724. };
  22725. }
  22726. /**
  22727. * Creates a function that performs a relational operation on two values.
  22728. *
  22729. * @private
  22730. * @param {Function} operator The function to perform the operation.
  22731. * @returns {Function} Returns the new relational operation function.
  22732. */
  22733. function createRelationalOperation(operator) {
  22734. return function(value, other) {
  22735. if (!(typeof value == 'string' && typeof other == 'string')) {
  22736. value = toNumber(value);
  22737. other = toNumber(other);
  22738. }
  22739. return operator(value, other);
  22740. };
  22741. }
  22742. /**
  22743. * Creates a function that wraps `func` to continue currying.
  22744. *
  22745. * @private
  22746. * @param {Function} func The function to wrap.
  22747. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22748. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22749. * @param {*} placeholder The placeholder value.
  22750. * @param {*} [thisArg] The `this` binding of `func`.
  22751. * @param {Array} [partials] The arguments to prepend to those provided to
  22752. * the new function.
  22753. * @param {Array} [holders] The `partials` placeholder indexes.
  22754. * @param {Array} [argPos] The argument positions of the new function.
  22755. * @param {number} [ary] The arity cap of `func`.
  22756. * @param {number} [arity] The arity of `func`.
  22757. * @returns {Function} Returns the new wrapped function.
  22758. */
  22759. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22760. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22761. newHolders = isCurry ? holders : undefined,
  22762. newHoldersRight = isCurry ? undefined : holders,
  22763. newPartials = isCurry ? partials : undefined,
  22764. newPartialsRight = isCurry ? undefined : partials;
  22765. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22766. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22767. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22768. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22769. }
  22770. var newData = [
  22771. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22772. newHoldersRight, argPos, ary, arity
  22773. ];
  22774. var result = wrapFunc.apply(undefined, newData);
  22775. if (isLaziable(func)) {
  22776. setData(result, newData);
  22777. }
  22778. result.placeholder = placeholder;
  22779. return setWrapToString(result, func, bitmask);
  22780. }
  22781. /**
  22782. * Creates a function like `_.round`.
  22783. *
  22784. * @private
  22785. * @param {string} methodName The name of the `Math` method to use when rounding.
  22786. * @returns {Function} Returns the new round function.
  22787. */
  22788. function createRound(methodName) {
  22789. var func = Math[methodName];
  22790. return function(number, precision) {
  22791. number = toNumber(number);
  22792. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22793. if (precision && nativeIsFinite(number)) {
  22794. // Shift with exponential notation to avoid floating-point issues.
  22795. // See [MDN](https://mdn.io/round#Examples) for more details.
  22796. var pair = (toString(number) + 'e').split('e'),
  22797. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22798. pair = (toString(value) + 'e').split('e');
  22799. return +(pair[0] + 'e' + (+pair[1] - precision));
  22800. }
  22801. return func(number);
  22802. };
  22803. }
  22804. /**
  22805. * Creates a set object of `values`.
  22806. *
  22807. * @private
  22808. * @param {Array} values The values to add to the set.
  22809. * @returns {Object} Returns the new set.
  22810. */
  22811. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22812. return new Set(values);
  22813. };
  22814. /**
  22815. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22816. *
  22817. * @private
  22818. * @param {Function} keysFunc The function to get the keys of a given object.
  22819. * @returns {Function} Returns the new pairs function.
  22820. */
  22821. function createToPairs(keysFunc) {
  22822. return function(object) {
  22823. var tag = getTag(object);
  22824. if (tag == mapTag) {
  22825. return mapToArray(object);
  22826. }
  22827. if (tag == setTag) {
  22828. return setToPairs(object);
  22829. }
  22830. return baseToPairs(object, keysFunc(object));
  22831. };
  22832. }
  22833. /**
  22834. * Creates a function that either curries or invokes `func` with optional
  22835. * `this` binding and partially applied arguments.
  22836. *
  22837. * @private
  22838. * @param {Function|string} func The function or method name to wrap.
  22839. * @param {number} bitmask The bitmask flags.
  22840. * 1 - `_.bind`
  22841. * 2 - `_.bindKey`
  22842. * 4 - `_.curry` or `_.curryRight` of a bound function
  22843. * 8 - `_.curry`
  22844. * 16 - `_.curryRight`
  22845. * 32 - `_.partial`
  22846. * 64 - `_.partialRight`
  22847. * 128 - `_.rearg`
  22848. * 256 - `_.ary`
  22849. * 512 - `_.flip`
  22850. * @param {*} [thisArg] The `this` binding of `func`.
  22851. * @param {Array} [partials] The arguments to be partially applied.
  22852. * @param {Array} [holders] The `partials` placeholder indexes.
  22853. * @param {Array} [argPos] The argument positions of the new function.
  22854. * @param {number} [ary] The arity cap of `func`.
  22855. * @param {number} [arity] The arity of `func`.
  22856. * @returns {Function} Returns the new wrapped function.
  22857. */
  22858. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22859. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22860. if (!isBindKey && typeof func != 'function') {
  22861. throw new TypeError(FUNC_ERROR_TEXT);
  22862. }
  22863. var length = partials ? partials.length : 0;
  22864. if (!length) {
  22865. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22866. partials = holders = undefined;
  22867. }
  22868. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22869. arity = arity === undefined ? arity : toInteger(arity);
  22870. length -= holders ? holders.length : 0;
  22871. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22872. var partialsRight = partials,
  22873. holdersRight = holders;
  22874. partials = holders = undefined;
  22875. }
  22876. var data = isBindKey ? undefined : getData(func);
  22877. var newData = [
  22878. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22879. argPos, ary, arity
  22880. ];
  22881. if (data) {
  22882. mergeData(newData, data);
  22883. }
  22884. func = newData[0];
  22885. bitmask = newData[1];
  22886. thisArg = newData[2];
  22887. partials = newData[3];
  22888. holders = newData[4];
  22889. arity = newData[9] = newData[9] === undefined
  22890. ? (isBindKey ? 0 : func.length)
  22891. : nativeMax(newData[9] - length, 0);
  22892. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22893. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22894. }
  22895. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22896. var result = createBind(func, bitmask, thisArg);
  22897. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22898. result = createCurry(func, bitmask, arity);
  22899. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22900. result = createPartial(func, bitmask, thisArg, partials);
  22901. } else {
  22902. result = createHybrid.apply(undefined, newData);
  22903. }
  22904. var setter = data ? baseSetData : setData;
  22905. return setWrapToString(setter(result, newData), func, bitmask);
  22906. }
  22907. /**
  22908. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22909. * of source objects to the destination object for all destination properties
  22910. * that resolve to `undefined`.
  22911. *
  22912. * @private
  22913. * @param {*} objValue The destination value.
  22914. * @param {*} srcValue The source value.
  22915. * @param {string} key The key of the property to assign.
  22916. * @param {Object} object The parent object of `objValue`.
  22917. * @returns {*} Returns the value to assign.
  22918. */
  22919. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22920. if (objValue === undefined ||
  22921. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22922. return srcValue;
  22923. }
  22924. return objValue;
  22925. }
  22926. /**
  22927. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22928. * objects into destination objects that are passed thru.
  22929. *
  22930. * @private
  22931. * @param {*} objValue The destination value.
  22932. * @param {*} srcValue The source value.
  22933. * @param {string} key The key of the property to merge.
  22934. * @param {Object} object The parent object of `objValue`.
  22935. * @param {Object} source The parent object of `srcValue`.
  22936. * @param {Object} [stack] Tracks traversed source values and their merged
  22937. * counterparts.
  22938. * @returns {*} Returns the value to assign.
  22939. */
  22940. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22941. if (isObject(objValue) && isObject(srcValue)) {
  22942. // Recursively merge objects and arrays (susceptible to call stack limits).
  22943. stack.set(srcValue, objValue);
  22944. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22945. stack['delete'](srcValue);
  22946. }
  22947. return objValue;
  22948. }
  22949. /**
  22950. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22951. * objects.
  22952. *
  22953. * @private
  22954. * @param {*} value The value to inspect.
  22955. * @param {string} key The key of the property to inspect.
  22956. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22957. */
  22958. function customOmitClone(value) {
  22959. return isPlainObject(value) ? undefined : value;
  22960. }
  22961. /**
  22962. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22963. * partial deep comparisons.
  22964. *
  22965. * @private
  22966. * @param {Array} array The array to compare.
  22967. * @param {Array} other The other array to compare.
  22968. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22969. * @param {Function} customizer The function to customize comparisons.
  22970. * @param {Function} equalFunc The function to determine equivalents of values.
  22971. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22972. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22973. */
  22974. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22975. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22976. arrLength = array.length,
  22977. othLength = other.length;
  22978. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22979. return false;
  22980. }
  22981. // Assume cyclic values are equal.
  22982. var stacked = stack.get(array);
  22983. if (stacked && stack.get(other)) {
  22984. return stacked == other;
  22985. }
  22986. var index = -1,
  22987. result = true,
  22988. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22989. stack.set(array, other);
  22990. stack.set(other, array);
  22991. // Ignore non-index properties.
  22992. while (++index < arrLength) {
  22993. var arrValue = array[index],
  22994. othValue = other[index];
  22995. if (customizer) {
  22996. var compared = isPartial
  22997. ? customizer(othValue, arrValue, index, other, array, stack)
  22998. : customizer(arrValue, othValue, index, array, other, stack);
  22999. }
  23000. if (compared !== undefined) {
  23001. if (compared) {
  23002. continue;
  23003. }
  23004. result = false;
  23005. break;
  23006. }
  23007. // Recursively compare arrays (susceptible to call stack limits).
  23008. if (seen) {
  23009. if (!arraySome(other, function(othValue, othIndex) {
  23010. if (!cacheHas(seen, othIndex) &&
  23011. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  23012. return seen.push(othIndex);
  23013. }
  23014. })) {
  23015. result = false;
  23016. break;
  23017. }
  23018. } else if (!(
  23019. arrValue === othValue ||
  23020. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  23021. )) {
  23022. result = false;
  23023. break;
  23024. }
  23025. }
  23026. stack['delete'](array);
  23027. stack['delete'](other);
  23028. return result;
  23029. }
  23030. /**
  23031. * A specialized version of `baseIsEqualDeep` for comparing objects of
  23032. * the same `toStringTag`.
  23033. *
  23034. * **Note:** This function only supports comparing values with tags of
  23035. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  23036. *
  23037. * @private
  23038. * @param {Object} object The object to compare.
  23039. * @param {Object} other The other object to compare.
  23040. * @param {string} tag The `toStringTag` of the objects to compare.
  23041. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23042. * @param {Function} customizer The function to customize comparisons.
  23043. * @param {Function} equalFunc The function to determine equivalents of values.
  23044. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23045. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23046. */
  23047. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  23048. switch (tag) {
  23049. case dataViewTag:
  23050. if ((object.byteLength != other.byteLength) ||
  23051. (object.byteOffset != other.byteOffset)) {
  23052. return false;
  23053. }
  23054. object = object.buffer;
  23055. other = other.buffer;
  23056. case arrayBufferTag:
  23057. if ((object.byteLength != other.byteLength) ||
  23058. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  23059. return false;
  23060. }
  23061. return true;
  23062. case boolTag:
  23063. case dateTag:
  23064. case numberTag:
  23065. // Coerce booleans to `1` or `0` and dates to milliseconds.
  23066. // Invalid dates are coerced to `NaN`.
  23067. return eq(+object, +other);
  23068. case errorTag:
  23069. return object.name == other.name && object.message == other.message;
  23070. case regexpTag:
  23071. case stringTag:
  23072. // Coerce regexes to strings and treat strings, primitives and objects,
  23073. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  23074. // for more details.
  23075. return object == (other + '');
  23076. case mapTag:
  23077. var convert = mapToArray;
  23078. case setTag:
  23079. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  23080. convert || (convert = setToArray);
  23081. if (object.size != other.size && !isPartial) {
  23082. return false;
  23083. }
  23084. // Assume cyclic values are equal.
  23085. var stacked = stack.get(object);
  23086. if (stacked) {
  23087. return stacked == other;
  23088. }
  23089. bitmask |= COMPARE_UNORDERED_FLAG;
  23090. // Recursively compare objects (susceptible to call stack limits).
  23091. stack.set(object, other);
  23092. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  23093. stack['delete'](object);
  23094. return result;
  23095. case symbolTag:
  23096. if (symbolValueOf) {
  23097. return symbolValueOf.call(object) == symbolValueOf.call(other);
  23098. }
  23099. }
  23100. return false;
  23101. }
  23102. /**
  23103. * A specialized version of `baseIsEqualDeep` for objects with support for
  23104. * partial deep comparisons.
  23105. *
  23106. * @private
  23107. * @param {Object} object The object to compare.
  23108. * @param {Object} other The other object to compare.
  23109. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23110. * @param {Function} customizer The function to customize comparisons.
  23111. * @param {Function} equalFunc The function to determine equivalents of values.
  23112. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23113. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23114. */
  23115. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23116. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23117. objProps = getAllKeys(object),
  23118. objLength = objProps.length,
  23119. othProps = getAllKeys(other),
  23120. othLength = othProps.length;
  23121. if (objLength != othLength && !isPartial) {
  23122. return false;
  23123. }
  23124. var index = objLength;
  23125. while (index--) {
  23126. var key = objProps[index];
  23127. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23128. return false;
  23129. }
  23130. }
  23131. // Assume cyclic values are equal.
  23132. var stacked = stack.get(object);
  23133. if (stacked && stack.get(other)) {
  23134. return stacked == other;
  23135. }
  23136. var result = true;
  23137. stack.set(object, other);
  23138. stack.set(other, object);
  23139. var skipCtor = isPartial;
  23140. while (++index < objLength) {
  23141. key = objProps[index];
  23142. var objValue = object[key],
  23143. othValue = other[key];
  23144. if (customizer) {
  23145. var compared = isPartial
  23146. ? customizer(othValue, objValue, key, other, object, stack)
  23147. : customizer(objValue, othValue, key, object, other, stack);
  23148. }
  23149. // Recursively compare objects (susceptible to call stack limits).
  23150. if (!(compared === undefined
  23151. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23152. : compared
  23153. )) {
  23154. result = false;
  23155. break;
  23156. }
  23157. skipCtor || (skipCtor = key == 'constructor');
  23158. }
  23159. if (result && !skipCtor) {
  23160. var objCtor = object.constructor,
  23161. othCtor = other.constructor;
  23162. // Non `Object` object instances with different constructors are not equal.
  23163. if (objCtor != othCtor &&
  23164. ('constructor' in object && 'constructor' in other) &&
  23165. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23166. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23167. result = false;
  23168. }
  23169. }
  23170. stack['delete'](object);
  23171. stack['delete'](other);
  23172. return result;
  23173. }
  23174. /**
  23175. * A specialized version of `baseRest` which flattens the rest array.
  23176. *
  23177. * @private
  23178. * @param {Function} func The function to apply a rest parameter to.
  23179. * @returns {Function} Returns the new function.
  23180. */
  23181. function flatRest(func) {
  23182. return setToString(overRest(func, undefined, flatten), func + '');
  23183. }
  23184. /**
  23185. * Creates an array of own enumerable property names and symbols of `object`.
  23186. *
  23187. * @private
  23188. * @param {Object} object The object to query.
  23189. * @returns {Array} Returns the array of property names and symbols.
  23190. */
  23191. function getAllKeys(object) {
  23192. return baseGetAllKeys(object, keys, getSymbols);
  23193. }
  23194. /**
  23195. * Creates an array of own and inherited enumerable property names and
  23196. * symbols of `object`.
  23197. *
  23198. * @private
  23199. * @param {Object} object The object to query.
  23200. * @returns {Array} Returns the array of property names and symbols.
  23201. */
  23202. function getAllKeysIn(object) {
  23203. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23204. }
  23205. /**
  23206. * Gets metadata for `func`.
  23207. *
  23208. * @private
  23209. * @param {Function} func The function to query.
  23210. * @returns {*} Returns the metadata for `func`.
  23211. */
  23212. var getData = !metaMap ? noop : function(func) {
  23213. return metaMap.get(func);
  23214. };
  23215. /**
  23216. * Gets the name of `func`.
  23217. *
  23218. * @private
  23219. * @param {Function} func The function to query.
  23220. * @returns {string} Returns the function name.
  23221. */
  23222. function getFuncName(func) {
  23223. var result = (func.name + ''),
  23224. array = realNames[result],
  23225. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23226. while (length--) {
  23227. var data = array[length],
  23228. otherFunc = data.func;
  23229. if (otherFunc == null || otherFunc == func) {
  23230. return data.name;
  23231. }
  23232. }
  23233. return result;
  23234. }
  23235. /**
  23236. * Gets the argument placeholder value for `func`.
  23237. *
  23238. * @private
  23239. * @param {Function} func The function to inspect.
  23240. * @returns {*} Returns the placeholder value.
  23241. */
  23242. function getHolder(func) {
  23243. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23244. return object.placeholder;
  23245. }
  23246. /**
  23247. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23248. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23249. * If arguments are provided, the chosen function is invoked with them and
  23250. * its result is returned.
  23251. *
  23252. * @private
  23253. * @param {*} [value] The value to convert to an iteratee.
  23254. * @param {number} [arity] The arity of the created iteratee.
  23255. * @returns {Function} Returns the chosen function or its result.
  23256. */
  23257. function getIteratee() {
  23258. var result = lodash.iteratee || iteratee;
  23259. result = result === iteratee ? baseIteratee : result;
  23260. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23261. }
  23262. /**
  23263. * Gets the data for `map`.
  23264. *
  23265. * @private
  23266. * @param {Object} map The map to query.
  23267. * @param {string} key The reference key.
  23268. * @returns {*} Returns the map data.
  23269. */
  23270. function getMapData(map, key) {
  23271. var data = map.__data__;
  23272. return isKeyable(key)
  23273. ? data[typeof key == 'string' ? 'string' : 'hash']
  23274. : data.map;
  23275. }
  23276. /**
  23277. * Gets the property names, values, and compare flags of `object`.
  23278. *
  23279. * @private
  23280. * @param {Object} object The object to query.
  23281. * @returns {Array} Returns the match data of `object`.
  23282. */
  23283. function getMatchData(object) {
  23284. var result = keys(object),
  23285. length = result.length;
  23286. while (length--) {
  23287. var key = result[length],
  23288. value = object[key];
  23289. result[length] = [key, value, isStrictComparable(value)];
  23290. }
  23291. return result;
  23292. }
  23293. /**
  23294. * Gets the native function at `key` of `object`.
  23295. *
  23296. * @private
  23297. * @param {Object} object The object to query.
  23298. * @param {string} key The key of the method to get.
  23299. * @returns {*} Returns the function if it's native, else `undefined`.
  23300. */
  23301. function getNative(object, key) {
  23302. var value = getValue(object, key);
  23303. return baseIsNative(value) ? value : undefined;
  23304. }
  23305. /**
  23306. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23307. *
  23308. * @private
  23309. * @param {*} value The value to query.
  23310. * @returns {string} Returns the raw `toStringTag`.
  23311. */
  23312. function getRawTag(value) {
  23313. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23314. tag = value[symToStringTag];
  23315. try {
  23316. value[symToStringTag] = undefined;
  23317. var unmasked = true;
  23318. } catch (e) {}
  23319. var result = nativeObjectToString.call(value);
  23320. if (unmasked) {
  23321. if (isOwn) {
  23322. value[symToStringTag] = tag;
  23323. } else {
  23324. delete value[symToStringTag];
  23325. }
  23326. }
  23327. return result;
  23328. }
  23329. /**
  23330. * Creates an array of the own 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 getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23337. if (object == null) {
  23338. return [];
  23339. }
  23340. object = Object(object);
  23341. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23342. return propertyIsEnumerable.call(object, symbol);
  23343. });
  23344. };
  23345. /**
  23346. * Creates an array of the own and inherited enumerable symbols of `object`.
  23347. *
  23348. * @private
  23349. * @param {Object} object The object to query.
  23350. * @returns {Array} Returns the array of symbols.
  23351. */
  23352. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23353. var result = [];
  23354. while (object) {
  23355. arrayPush(result, getSymbols(object));
  23356. object = getPrototype(object);
  23357. }
  23358. return result;
  23359. };
  23360. /**
  23361. * Gets the `toStringTag` of `value`.
  23362. *
  23363. * @private
  23364. * @param {*} value The value to query.
  23365. * @returns {string} Returns the `toStringTag`.
  23366. */
  23367. var getTag = baseGetTag;
  23368. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23369. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23370. (Map && getTag(new Map) != mapTag) ||
  23371. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23372. (Set && getTag(new Set) != setTag) ||
  23373. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23374. getTag = function(value) {
  23375. var result = baseGetTag(value),
  23376. Ctor = result == objectTag ? value.constructor : undefined,
  23377. ctorString = Ctor ? toSource(Ctor) : '';
  23378. if (ctorString) {
  23379. switch (ctorString) {
  23380. case dataViewCtorString: return dataViewTag;
  23381. case mapCtorString: return mapTag;
  23382. case promiseCtorString: return promiseTag;
  23383. case setCtorString: return setTag;
  23384. case weakMapCtorString: return weakMapTag;
  23385. }
  23386. }
  23387. return result;
  23388. };
  23389. }
  23390. /**
  23391. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23392. *
  23393. * @private
  23394. * @param {number} start The start of the view.
  23395. * @param {number} end The end of the view.
  23396. * @param {Array} transforms The transformations to apply to the view.
  23397. * @returns {Object} Returns an object containing the `start` and `end`
  23398. * positions of the view.
  23399. */
  23400. function getView(start, end, transforms) {
  23401. var index = -1,
  23402. length = transforms.length;
  23403. while (++index < length) {
  23404. var data = transforms[index],
  23405. size = data.size;
  23406. switch (data.type) {
  23407. case 'drop': start += size; break;
  23408. case 'dropRight': end -= size; break;
  23409. case 'take': end = nativeMin(end, start + size); break;
  23410. case 'takeRight': start = nativeMax(start, end - size); break;
  23411. }
  23412. }
  23413. return { 'start': start, 'end': end };
  23414. }
  23415. /**
  23416. * Extracts wrapper details from the `source` body comment.
  23417. *
  23418. * @private
  23419. * @param {string} source The source to inspect.
  23420. * @returns {Array} Returns the wrapper details.
  23421. */
  23422. function getWrapDetails(source) {
  23423. var match = source.match(reWrapDetails);
  23424. return match ? match[1].split(reSplitDetails) : [];
  23425. }
  23426. /**
  23427. * Checks if `path` exists on `object`.
  23428. *
  23429. * @private
  23430. * @param {Object} object The object to query.
  23431. * @param {Array|string} path The path to check.
  23432. * @param {Function} hasFunc The function to check properties.
  23433. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23434. */
  23435. function hasPath(object, path, hasFunc) {
  23436. path = castPath(path, object);
  23437. var index = -1,
  23438. length = path.length,
  23439. result = false;
  23440. while (++index < length) {
  23441. var key = toKey(path[index]);
  23442. if (!(result = object != null && hasFunc(object, key))) {
  23443. break;
  23444. }
  23445. object = object[key];
  23446. }
  23447. if (result || ++index != length) {
  23448. return result;
  23449. }
  23450. length = object == null ? 0 : object.length;
  23451. return !!length && isLength(length) && isIndex(key, length) &&
  23452. (isArray(object) || isArguments(object));
  23453. }
  23454. /**
  23455. * Initializes an array clone.
  23456. *
  23457. * @private
  23458. * @param {Array} array The array to clone.
  23459. * @returns {Array} Returns the initialized clone.
  23460. */
  23461. function initCloneArray(array) {
  23462. var length = array.length,
  23463. result = new array.constructor(length);
  23464. // Add properties assigned by `RegExp#exec`.
  23465. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23466. result.index = array.index;
  23467. result.input = array.input;
  23468. }
  23469. return result;
  23470. }
  23471. /**
  23472. * Initializes an object clone.
  23473. *
  23474. * @private
  23475. * @param {Object} object The object to clone.
  23476. * @returns {Object} Returns the initialized clone.
  23477. */
  23478. function initCloneObject(object) {
  23479. return (typeof object.constructor == 'function' && !isPrototype(object))
  23480. ? baseCreate(getPrototype(object))
  23481. : {};
  23482. }
  23483. /**
  23484. * Initializes an object clone based on its `toStringTag`.
  23485. *
  23486. * **Note:** This function only supports cloning values with tags of
  23487. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23488. *
  23489. * @private
  23490. * @param {Object} object The object to clone.
  23491. * @param {string} tag The `toStringTag` of the object to clone.
  23492. * @param {boolean} [isDeep] Specify a deep clone.
  23493. * @returns {Object} Returns the initialized clone.
  23494. */
  23495. function initCloneByTag(object, tag, isDeep) {
  23496. var Ctor = object.constructor;
  23497. switch (tag) {
  23498. case arrayBufferTag:
  23499. return cloneArrayBuffer(object);
  23500. case boolTag:
  23501. case dateTag:
  23502. return new Ctor(+object);
  23503. case dataViewTag:
  23504. return cloneDataView(object, isDeep);
  23505. case float32Tag: case float64Tag:
  23506. case int8Tag: case int16Tag: case int32Tag:
  23507. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23508. return cloneTypedArray(object, isDeep);
  23509. case mapTag:
  23510. return new Ctor;
  23511. case numberTag:
  23512. case stringTag:
  23513. return new Ctor(object);
  23514. case regexpTag:
  23515. return cloneRegExp(object);
  23516. case setTag:
  23517. return new Ctor;
  23518. case symbolTag:
  23519. return cloneSymbol(object);
  23520. }
  23521. }
  23522. /**
  23523. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23524. *
  23525. * @private
  23526. * @param {string} source The source to modify.
  23527. * @returns {Array} details The details to insert.
  23528. * @returns {string} Returns the modified source.
  23529. */
  23530. function insertWrapDetails(source, details) {
  23531. var length = details.length;
  23532. if (!length) {
  23533. return source;
  23534. }
  23535. var lastIndex = length - 1;
  23536. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23537. details = details.join(length > 2 ? ', ' : ' ');
  23538. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23539. }
  23540. /**
  23541. * Checks if `value` is a flattenable `arguments` object or array.
  23542. *
  23543. * @private
  23544. * @param {*} value The value to check.
  23545. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23546. */
  23547. function isFlattenable(value) {
  23548. return isArray(value) || isArguments(value) ||
  23549. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23550. }
  23551. /**
  23552. * Checks if `value` is a valid array-like index.
  23553. *
  23554. * @private
  23555. * @param {*} value The value to check.
  23556. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23557. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23558. */
  23559. function isIndex(value, length) {
  23560. var type = typeof value;
  23561. length = length == null ? MAX_SAFE_INTEGER : length;
  23562. return !!length &&
  23563. (type == 'number' ||
  23564. (type != 'symbol' && reIsUint.test(value))) &&
  23565. (value > -1 && value % 1 == 0 && value < length);
  23566. }
  23567. /**
  23568. * Checks if the given arguments are from an iteratee call.
  23569. *
  23570. * @private
  23571. * @param {*} value The potential iteratee value argument.
  23572. * @param {*} index The potential iteratee index or key argument.
  23573. * @param {*} object The potential iteratee object argument.
  23574. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23575. * else `false`.
  23576. */
  23577. function isIterateeCall(value, index, object) {
  23578. if (!isObject(object)) {
  23579. return false;
  23580. }
  23581. var type = typeof index;
  23582. if (type == 'number'
  23583. ? (isArrayLike(object) && isIndex(index, object.length))
  23584. : (type == 'string' && index in object)
  23585. ) {
  23586. return eq(object[index], value);
  23587. }
  23588. return false;
  23589. }
  23590. /**
  23591. * Checks if `value` is a property name and not a property path.
  23592. *
  23593. * @private
  23594. * @param {*} value The value to check.
  23595. * @param {Object} [object] The object to query keys on.
  23596. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23597. */
  23598. function isKey(value, object) {
  23599. if (isArray(value)) {
  23600. return false;
  23601. }
  23602. var type = typeof value;
  23603. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23604. value == null || isSymbol(value)) {
  23605. return true;
  23606. }
  23607. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23608. (object != null && value in Object(object));
  23609. }
  23610. /**
  23611. * Checks if `value` is suitable for use as unique object key.
  23612. *
  23613. * @private
  23614. * @param {*} value The value to check.
  23615. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23616. */
  23617. function isKeyable(value) {
  23618. var type = typeof value;
  23619. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23620. ? (value !== '__proto__')
  23621. : (value === null);
  23622. }
  23623. /**
  23624. * Checks if `func` has a lazy counterpart.
  23625. *
  23626. * @private
  23627. * @param {Function} func The function to check.
  23628. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23629. * else `false`.
  23630. */
  23631. function isLaziable(func) {
  23632. var funcName = getFuncName(func),
  23633. other = lodash[funcName];
  23634. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23635. return false;
  23636. }
  23637. if (func === other) {
  23638. return true;
  23639. }
  23640. var data = getData(other);
  23641. return !!data && func === data[0];
  23642. }
  23643. /**
  23644. * Checks if `func` has its source masked.
  23645. *
  23646. * @private
  23647. * @param {Function} func The function to check.
  23648. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23649. */
  23650. function isMasked(func) {
  23651. return !!maskSrcKey && (maskSrcKey in func);
  23652. }
  23653. /**
  23654. * Checks if `func` is capable of being masked.
  23655. *
  23656. * @private
  23657. * @param {*} value The value to check.
  23658. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23659. */
  23660. var isMaskable = coreJsData ? isFunction : stubFalse;
  23661. /**
  23662. * Checks if `value` is likely a prototype object.
  23663. *
  23664. * @private
  23665. * @param {*} value The value to check.
  23666. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23667. */
  23668. function isPrototype(value) {
  23669. var Ctor = value && value.constructor,
  23670. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23671. return value === proto;
  23672. }
  23673. /**
  23674. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23675. *
  23676. * @private
  23677. * @param {*} value The value to check.
  23678. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23679. * equality comparisons, else `false`.
  23680. */
  23681. function isStrictComparable(value) {
  23682. return value === value && !isObject(value);
  23683. }
  23684. /**
  23685. * A specialized version of `matchesProperty` for source values suitable
  23686. * for strict equality comparisons, i.e. `===`.
  23687. *
  23688. * @private
  23689. * @param {string} key The key of the property to get.
  23690. * @param {*} srcValue The value to match.
  23691. * @returns {Function} Returns the new spec function.
  23692. */
  23693. function matchesStrictComparable(key, srcValue) {
  23694. return function(object) {
  23695. if (object == null) {
  23696. return false;
  23697. }
  23698. return object[key] === srcValue &&
  23699. (srcValue !== undefined || (key in Object(object)));
  23700. };
  23701. }
  23702. /**
  23703. * A specialized version of `_.memoize` which clears the memoized function's
  23704. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23705. *
  23706. * @private
  23707. * @param {Function} func The function to have its output memoized.
  23708. * @returns {Function} Returns the new memoized function.
  23709. */
  23710. function memoizeCapped(func) {
  23711. var result = memoize(func, function(key) {
  23712. if (cache.size === MAX_MEMOIZE_SIZE) {
  23713. cache.clear();
  23714. }
  23715. return key;
  23716. });
  23717. var cache = result.cache;
  23718. return result;
  23719. }
  23720. /**
  23721. * Merges the function metadata of `source` into `data`.
  23722. *
  23723. * Merging metadata reduces the number of wrappers used to invoke a function.
  23724. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23725. * may be applied regardless of execution order. Methods like `_.ary` and
  23726. * `_.rearg` modify function arguments, making the order in which they are
  23727. * executed important, preventing the merging of metadata. However, we make
  23728. * an exception for a safe combined case where curried functions have `_.ary`
  23729. * and or `_.rearg` applied.
  23730. *
  23731. * @private
  23732. * @param {Array} data The destination metadata.
  23733. * @param {Array} source The source metadata.
  23734. * @returns {Array} Returns `data`.
  23735. */
  23736. function mergeData(data, source) {
  23737. var bitmask = data[1],
  23738. srcBitmask = source[1],
  23739. newBitmask = bitmask | srcBitmask,
  23740. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23741. var isCombo =
  23742. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23743. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23744. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23745. // Exit early if metadata can't be merged.
  23746. if (!(isCommon || isCombo)) {
  23747. return data;
  23748. }
  23749. // Use source `thisArg` if available.
  23750. if (srcBitmask & WRAP_BIND_FLAG) {
  23751. data[2] = source[2];
  23752. // Set when currying a bound function.
  23753. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23754. }
  23755. // Compose partial arguments.
  23756. var value = source[3];
  23757. if (value) {
  23758. var partials = data[3];
  23759. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23760. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23761. }
  23762. // Compose partial right arguments.
  23763. value = source[5];
  23764. if (value) {
  23765. partials = data[5];
  23766. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23767. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23768. }
  23769. // Use source `argPos` if available.
  23770. value = source[7];
  23771. if (value) {
  23772. data[7] = value;
  23773. }
  23774. // Use source `ary` if it's smaller.
  23775. if (srcBitmask & WRAP_ARY_FLAG) {
  23776. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23777. }
  23778. // Use source `arity` if one is not provided.
  23779. if (data[9] == null) {
  23780. data[9] = source[9];
  23781. }
  23782. // Use source `func` and merge bitmasks.
  23783. data[0] = source[0];
  23784. data[1] = newBitmask;
  23785. return data;
  23786. }
  23787. /**
  23788. * This function is like
  23789. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23790. * except that it includes inherited enumerable properties.
  23791. *
  23792. * @private
  23793. * @param {Object} object The object to query.
  23794. * @returns {Array} Returns the array of property names.
  23795. */
  23796. function nativeKeysIn(object) {
  23797. var result = [];
  23798. if (object != null) {
  23799. for (var key in Object(object)) {
  23800. result.push(key);
  23801. }
  23802. }
  23803. return result;
  23804. }
  23805. /**
  23806. * Converts `value` to a string using `Object.prototype.toString`.
  23807. *
  23808. * @private
  23809. * @param {*} value The value to convert.
  23810. * @returns {string} Returns the converted string.
  23811. */
  23812. function objectToString(value) {
  23813. return nativeObjectToString.call(value);
  23814. }
  23815. /**
  23816. * A specialized version of `baseRest` which transforms the rest array.
  23817. *
  23818. * @private
  23819. * @param {Function} func The function to apply a rest parameter to.
  23820. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23821. * @param {Function} transform The rest array transform.
  23822. * @returns {Function} Returns the new function.
  23823. */
  23824. function overRest(func, start, transform) {
  23825. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23826. return function() {
  23827. var args = arguments,
  23828. index = -1,
  23829. length = nativeMax(args.length - start, 0),
  23830. array = Array(length);
  23831. while (++index < length) {
  23832. array[index] = args[start + index];
  23833. }
  23834. index = -1;
  23835. var otherArgs = Array(start + 1);
  23836. while (++index < start) {
  23837. otherArgs[index] = args[index];
  23838. }
  23839. otherArgs[start] = transform(array);
  23840. return apply(func, this, otherArgs);
  23841. };
  23842. }
  23843. /**
  23844. * Gets the parent value at `path` of `object`.
  23845. *
  23846. * @private
  23847. * @param {Object} object The object to query.
  23848. * @param {Array} path The path to get the parent value of.
  23849. * @returns {*} Returns the parent value.
  23850. */
  23851. function parent(object, path) {
  23852. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23853. }
  23854. /**
  23855. * Reorder `array` according to the specified indexes where the element at
  23856. * the first index is assigned as the first element, the element at
  23857. * the second index is assigned as the second element, and so on.
  23858. *
  23859. * @private
  23860. * @param {Array} array The array to reorder.
  23861. * @param {Array} indexes The arranged array indexes.
  23862. * @returns {Array} Returns `array`.
  23863. */
  23864. function reorder(array, indexes) {
  23865. var arrLength = array.length,
  23866. length = nativeMin(indexes.length, arrLength),
  23867. oldArray = copyArray(array);
  23868. while (length--) {
  23869. var index = indexes[length];
  23870. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23871. }
  23872. return array;
  23873. }
  23874. /**
  23875. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23876. *
  23877. * @private
  23878. * @param {Object} object The object to query.
  23879. * @param {string} key The key of the property to get.
  23880. * @returns {*} Returns the property value.
  23881. */
  23882. function safeGet(object, key) {
  23883. if (key === 'constructor' && typeof object[key] === 'function') {
  23884. return;
  23885. }
  23886. if (key == '__proto__') {
  23887. return;
  23888. }
  23889. return object[key];
  23890. }
  23891. /**
  23892. * Sets metadata for `func`.
  23893. *
  23894. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23895. * period of time, it will trip its breaker and transition to an identity
  23896. * function to avoid garbage collection pauses in V8. See
  23897. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23898. * for more details.
  23899. *
  23900. * @private
  23901. * @param {Function} func The function to associate metadata with.
  23902. * @param {*} data The metadata.
  23903. * @returns {Function} Returns `func`.
  23904. */
  23905. var setData = shortOut(baseSetData);
  23906. /**
  23907. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23908. *
  23909. * @private
  23910. * @param {Function} func The function to delay.
  23911. * @param {number} wait The number of milliseconds to delay invocation.
  23912. * @returns {number|Object} Returns the timer id or timeout object.
  23913. */
  23914. var setTimeout = ctxSetTimeout || function(func, wait) {
  23915. return root.setTimeout(func, wait);
  23916. };
  23917. /**
  23918. * Sets the `toString` method of `func` to return `string`.
  23919. *
  23920. * @private
  23921. * @param {Function} func The function to modify.
  23922. * @param {Function} string The `toString` result.
  23923. * @returns {Function} Returns `func`.
  23924. */
  23925. var setToString = shortOut(baseSetToString);
  23926. /**
  23927. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23928. * with wrapper details in a comment at the top of the source body.
  23929. *
  23930. * @private
  23931. * @param {Function} wrapper The function to modify.
  23932. * @param {Function} reference The reference function.
  23933. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23934. * @returns {Function} Returns `wrapper`.
  23935. */
  23936. function setWrapToString(wrapper, reference, bitmask) {
  23937. var source = (reference + '');
  23938. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23939. }
  23940. /**
  23941. * Creates a function that'll short out and invoke `identity` instead
  23942. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23943. * milliseconds.
  23944. *
  23945. * @private
  23946. * @param {Function} func The function to restrict.
  23947. * @returns {Function} Returns the new shortable function.
  23948. */
  23949. function shortOut(func) {
  23950. var count = 0,
  23951. lastCalled = 0;
  23952. return function() {
  23953. var stamp = nativeNow(),
  23954. remaining = HOT_SPAN - (stamp - lastCalled);
  23955. lastCalled = stamp;
  23956. if (remaining > 0) {
  23957. if (++count >= HOT_COUNT) {
  23958. return arguments[0];
  23959. }
  23960. } else {
  23961. count = 0;
  23962. }
  23963. return func.apply(undefined, arguments);
  23964. };
  23965. }
  23966. /**
  23967. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23968. *
  23969. * @private
  23970. * @param {Array} array The array to shuffle.
  23971. * @param {number} [size=array.length] The size of `array`.
  23972. * @returns {Array} Returns `array`.
  23973. */
  23974. function shuffleSelf(array, size) {
  23975. var index = -1,
  23976. length = array.length,
  23977. lastIndex = length - 1;
  23978. size = size === undefined ? length : size;
  23979. while (++index < size) {
  23980. var rand = baseRandom(index, lastIndex),
  23981. value = array[rand];
  23982. array[rand] = array[index];
  23983. array[index] = value;
  23984. }
  23985. array.length = size;
  23986. return array;
  23987. }
  23988. /**
  23989. * Converts `string` to a property path array.
  23990. *
  23991. * @private
  23992. * @param {string} string The string to convert.
  23993. * @returns {Array} Returns the property path array.
  23994. */
  23995. var stringToPath = memoizeCapped(function(string) {
  23996. var result = [];
  23997. if (string.charCodeAt(0) === 46 /* . */) {
  23998. result.push('');
  23999. }
  24000. string.replace(rePropName, function(match, number, quote, subString) {
  24001. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  24002. });
  24003. return result;
  24004. });
  24005. /**
  24006. * Converts `value` to a string key if it's not a string or symbol.
  24007. *
  24008. * @private
  24009. * @param {*} value The value to inspect.
  24010. * @returns {string|symbol} Returns the key.
  24011. */
  24012. function toKey(value) {
  24013. if (typeof value == 'string' || isSymbol(value)) {
  24014. return value;
  24015. }
  24016. var result = (value + '');
  24017. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  24018. }
  24019. /**
  24020. * Converts `func` to its source code.
  24021. *
  24022. * @private
  24023. * @param {Function} func The function to convert.
  24024. * @returns {string} Returns the source code.
  24025. */
  24026. function toSource(func) {
  24027. if (func != null) {
  24028. try {
  24029. return funcToString.call(func);
  24030. } catch (e) {}
  24031. try {
  24032. return (func + '');
  24033. } catch (e) {}
  24034. }
  24035. return '';
  24036. }
  24037. /**
  24038. * Updates wrapper `details` based on `bitmask` flags.
  24039. *
  24040. * @private
  24041. * @returns {Array} details The details to modify.
  24042. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  24043. * @returns {Array} Returns `details`.
  24044. */
  24045. function updateWrapDetails(details, bitmask) {
  24046. arrayEach(wrapFlags, function(pair) {
  24047. var value = '_.' + pair[0];
  24048. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  24049. details.push(value);
  24050. }
  24051. });
  24052. return details.sort();
  24053. }
  24054. /**
  24055. * Creates a clone of `wrapper`.
  24056. *
  24057. * @private
  24058. * @param {Object} wrapper The wrapper to clone.
  24059. * @returns {Object} Returns the cloned wrapper.
  24060. */
  24061. function wrapperClone(wrapper) {
  24062. if (wrapper instanceof LazyWrapper) {
  24063. return wrapper.clone();
  24064. }
  24065. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  24066. result.__actions__ = copyArray(wrapper.__actions__);
  24067. result.__index__ = wrapper.__index__;
  24068. result.__values__ = wrapper.__values__;
  24069. return result;
  24070. }
  24071. /*------------------------------------------------------------------------*/
  24072. /**
  24073. * Creates an array of elements split into groups the length of `size`.
  24074. * If `array` can't be split evenly, the final chunk will be the remaining
  24075. * elements.
  24076. *
  24077. * @static
  24078. * @memberOf _
  24079. * @since 3.0.0
  24080. * @category Array
  24081. * @param {Array} array The array to process.
  24082. * @param {number} [size=1] The length of each chunk
  24083. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24084. * @returns {Array} Returns the new array of chunks.
  24085. * @example
  24086. *
  24087. * _.chunk(['a', 'b', 'c', 'd'], 2);
  24088. * // => [['a', 'b'], ['c', 'd']]
  24089. *
  24090. * _.chunk(['a', 'b', 'c', 'd'], 3);
  24091. * // => [['a', 'b', 'c'], ['d']]
  24092. */
  24093. function chunk(array, size, guard) {
  24094. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  24095. size = 1;
  24096. } else {
  24097. size = nativeMax(toInteger(size), 0);
  24098. }
  24099. var length = array == null ? 0 : array.length;
  24100. if (!length || size < 1) {
  24101. return [];
  24102. }
  24103. var index = 0,
  24104. resIndex = 0,
  24105. result = Array(nativeCeil(length / size));
  24106. while (index < length) {
  24107. result[resIndex++] = baseSlice(array, index, (index += size));
  24108. }
  24109. return result;
  24110. }
  24111. /**
  24112. * Creates an array with all falsey values removed. The values `false`, `null`,
  24113. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24114. *
  24115. * @static
  24116. * @memberOf _
  24117. * @since 0.1.0
  24118. * @category Array
  24119. * @param {Array} array The array to compact.
  24120. * @returns {Array} Returns the new array of filtered values.
  24121. * @example
  24122. *
  24123. * _.compact([0, 1, false, 2, '', 3]);
  24124. * // => [1, 2, 3]
  24125. */
  24126. function compact(array) {
  24127. var index = -1,
  24128. length = array == null ? 0 : array.length,
  24129. resIndex = 0,
  24130. result = [];
  24131. while (++index < length) {
  24132. var value = array[index];
  24133. if (value) {
  24134. result[resIndex++] = value;
  24135. }
  24136. }
  24137. return result;
  24138. }
  24139. /**
  24140. * Creates a new array concatenating `array` with any additional arrays
  24141. * and/or values.
  24142. *
  24143. * @static
  24144. * @memberOf _
  24145. * @since 4.0.0
  24146. * @category Array
  24147. * @param {Array} array The array to concatenate.
  24148. * @param {...*} [values] The values to concatenate.
  24149. * @returns {Array} Returns the new concatenated array.
  24150. * @example
  24151. *
  24152. * var array = [1];
  24153. * var other = _.concat(array, 2, [3], [[4]]);
  24154. *
  24155. * console.log(other);
  24156. * // => [1, 2, 3, [4]]
  24157. *
  24158. * console.log(array);
  24159. * // => [1]
  24160. */
  24161. function concat() {
  24162. var length = arguments.length;
  24163. if (!length) {
  24164. return [];
  24165. }
  24166. var args = Array(length - 1),
  24167. array = arguments[0],
  24168. index = length;
  24169. while (index--) {
  24170. args[index - 1] = arguments[index];
  24171. }
  24172. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24173. }
  24174. /**
  24175. * Creates an array of `array` values not included in the other given arrays
  24176. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24177. * for equality comparisons. The order and references of result values are
  24178. * determined by the first array.
  24179. *
  24180. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24181. *
  24182. * @static
  24183. * @memberOf _
  24184. * @since 0.1.0
  24185. * @category Array
  24186. * @param {Array} array The array to inspect.
  24187. * @param {...Array} [values] The values to exclude.
  24188. * @returns {Array} Returns the new array of filtered values.
  24189. * @see _.without, _.xor
  24190. * @example
  24191. *
  24192. * _.difference([2, 1], [2, 3]);
  24193. * // => [1]
  24194. */
  24195. var difference = baseRest(function(array, values) {
  24196. return isArrayLikeObject(array)
  24197. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24198. : [];
  24199. });
  24200. /**
  24201. * This method is like `_.difference` except that it accepts `iteratee` which
  24202. * is invoked for each element of `array` and `values` to generate the criterion
  24203. * by which they're compared. The order and references of result values are
  24204. * determined by the first array. The iteratee is invoked with one argument:
  24205. * (value).
  24206. *
  24207. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24208. *
  24209. * @static
  24210. * @memberOf _
  24211. * @since 4.0.0
  24212. * @category Array
  24213. * @param {Array} array The array to inspect.
  24214. * @param {...Array} [values] The values to exclude.
  24215. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24216. * @returns {Array} Returns the new array of filtered values.
  24217. * @example
  24218. *
  24219. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24220. * // => [1.2]
  24221. *
  24222. * // The `_.property` iteratee shorthand.
  24223. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24224. * // => [{ 'x': 2 }]
  24225. */
  24226. var differenceBy = baseRest(function(array, values) {
  24227. var iteratee = last(values);
  24228. if (isArrayLikeObject(iteratee)) {
  24229. iteratee = undefined;
  24230. }
  24231. return isArrayLikeObject(array)
  24232. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24233. : [];
  24234. });
  24235. /**
  24236. * This method is like `_.difference` except that it accepts `comparator`
  24237. * which is invoked to compare elements of `array` to `values`. The order and
  24238. * references of result values are determined by the first array. The comparator
  24239. * is invoked with two arguments: (arrVal, othVal).
  24240. *
  24241. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24242. *
  24243. * @static
  24244. * @memberOf _
  24245. * @since 4.0.0
  24246. * @category Array
  24247. * @param {Array} array The array to inspect.
  24248. * @param {...Array} [values] The values to exclude.
  24249. * @param {Function} [comparator] The comparator invoked per element.
  24250. * @returns {Array} Returns the new array of filtered values.
  24251. * @example
  24252. *
  24253. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24254. *
  24255. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24256. * // => [{ 'x': 2, 'y': 1 }]
  24257. */
  24258. var differenceWith = baseRest(function(array, values) {
  24259. var comparator = last(values);
  24260. if (isArrayLikeObject(comparator)) {
  24261. comparator = undefined;
  24262. }
  24263. return isArrayLikeObject(array)
  24264. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24265. : [];
  24266. });
  24267. /**
  24268. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24269. *
  24270. * @static
  24271. * @memberOf _
  24272. * @since 0.5.0
  24273. * @category Array
  24274. * @param {Array} array The array to query.
  24275. * @param {number} [n=1] The number of elements to drop.
  24276. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24277. * @returns {Array} Returns the slice of `array`.
  24278. * @example
  24279. *
  24280. * _.drop([1, 2, 3]);
  24281. * // => [2, 3]
  24282. *
  24283. * _.drop([1, 2, 3], 2);
  24284. * // => [3]
  24285. *
  24286. * _.drop([1, 2, 3], 5);
  24287. * // => []
  24288. *
  24289. * _.drop([1, 2, 3], 0);
  24290. * // => [1, 2, 3]
  24291. */
  24292. function drop(array, n, guard) {
  24293. var length = array == null ? 0 : array.length;
  24294. if (!length) {
  24295. return [];
  24296. }
  24297. n = (guard || n === undefined) ? 1 : toInteger(n);
  24298. return baseSlice(array, n < 0 ? 0 : n, length);
  24299. }
  24300. /**
  24301. * Creates a slice of `array` with `n` elements dropped from the end.
  24302. *
  24303. * @static
  24304. * @memberOf _
  24305. * @since 3.0.0
  24306. * @category Array
  24307. * @param {Array} array The array to query.
  24308. * @param {number} [n=1] The number of elements to drop.
  24309. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24310. * @returns {Array} Returns the slice of `array`.
  24311. * @example
  24312. *
  24313. * _.dropRight([1, 2, 3]);
  24314. * // => [1, 2]
  24315. *
  24316. * _.dropRight([1, 2, 3], 2);
  24317. * // => [1]
  24318. *
  24319. * _.dropRight([1, 2, 3], 5);
  24320. * // => []
  24321. *
  24322. * _.dropRight([1, 2, 3], 0);
  24323. * // => [1, 2, 3]
  24324. */
  24325. function dropRight(array, n, guard) {
  24326. var length = array == null ? 0 : array.length;
  24327. if (!length) {
  24328. return [];
  24329. }
  24330. n = (guard || n === undefined) ? 1 : toInteger(n);
  24331. n = length - n;
  24332. return baseSlice(array, 0, n < 0 ? 0 : n);
  24333. }
  24334. /**
  24335. * Creates a slice of `array` excluding elements dropped from the end.
  24336. * Elements are dropped until `predicate` returns falsey. The predicate is
  24337. * invoked with three arguments: (value, index, array).
  24338. *
  24339. * @static
  24340. * @memberOf _
  24341. * @since 3.0.0
  24342. * @category Array
  24343. * @param {Array} array The array to query.
  24344. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24345. * @returns {Array} Returns the slice of `array`.
  24346. * @example
  24347. *
  24348. * var users = [
  24349. * { 'user': 'barney', 'active': true },
  24350. * { 'user': 'fred', 'active': false },
  24351. * { 'user': 'pebbles', 'active': false }
  24352. * ];
  24353. *
  24354. * _.dropRightWhile(users, function(o) { return !o.active; });
  24355. * // => objects for ['barney']
  24356. *
  24357. * // The `_.matches` iteratee shorthand.
  24358. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24359. * // => objects for ['barney', 'fred']
  24360. *
  24361. * // The `_.matchesProperty` iteratee shorthand.
  24362. * _.dropRightWhile(users, ['active', false]);
  24363. * // => objects for ['barney']
  24364. *
  24365. * // The `_.property` iteratee shorthand.
  24366. * _.dropRightWhile(users, 'active');
  24367. * // => objects for ['barney', 'fred', 'pebbles']
  24368. */
  24369. function dropRightWhile(array, predicate) {
  24370. return (array && array.length)
  24371. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24372. : [];
  24373. }
  24374. /**
  24375. * Creates a slice of `array` excluding elements dropped from the beginning.
  24376. * Elements are dropped until `predicate` returns falsey. The predicate is
  24377. * invoked with three arguments: (value, index, array).
  24378. *
  24379. * @static
  24380. * @memberOf _
  24381. * @since 3.0.0
  24382. * @category Array
  24383. * @param {Array} array The array to query.
  24384. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24385. * @returns {Array} Returns the slice of `array`.
  24386. * @example
  24387. *
  24388. * var users = [
  24389. * { 'user': 'barney', 'active': false },
  24390. * { 'user': 'fred', 'active': false },
  24391. * { 'user': 'pebbles', 'active': true }
  24392. * ];
  24393. *
  24394. * _.dropWhile(users, function(o) { return !o.active; });
  24395. * // => objects for ['pebbles']
  24396. *
  24397. * // The `_.matches` iteratee shorthand.
  24398. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24399. * // => objects for ['fred', 'pebbles']
  24400. *
  24401. * // The `_.matchesProperty` iteratee shorthand.
  24402. * _.dropWhile(users, ['active', false]);
  24403. * // => objects for ['pebbles']
  24404. *
  24405. * // The `_.property` iteratee shorthand.
  24406. * _.dropWhile(users, 'active');
  24407. * // => objects for ['barney', 'fred', 'pebbles']
  24408. */
  24409. function dropWhile(array, predicate) {
  24410. return (array && array.length)
  24411. ? baseWhile(array, getIteratee(predicate, 3), true)
  24412. : [];
  24413. }
  24414. /**
  24415. * Fills elements of `array` with `value` from `start` up to, but not
  24416. * including, `end`.
  24417. *
  24418. * **Note:** This method mutates `array`.
  24419. *
  24420. * @static
  24421. * @memberOf _
  24422. * @since 3.2.0
  24423. * @category Array
  24424. * @param {Array} array The array to fill.
  24425. * @param {*} value The value to fill `array` with.
  24426. * @param {number} [start=0] The start position.
  24427. * @param {number} [end=array.length] The end position.
  24428. * @returns {Array} Returns `array`.
  24429. * @example
  24430. *
  24431. * var array = [1, 2, 3];
  24432. *
  24433. * _.fill(array, 'a');
  24434. * console.log(array);
  24435. * // => ['a', 'a', 'a']
  24436. *
  24437. * _.fill(Array(3), 2);
  24438. * // => [2, 2, 2]
  24439. *
  24440. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24441. * // => [4, '*', '*', 10]
  24442. */
  24443. function fill(array, value, start, end) {
  24444. var length = array == null ? 0 : array.length;
  24445. if (!length) {
  24446. return [];
  24447. }
  24448. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24449. start = 0;
  24450. end = length;
  24451. }
  24452. return baseFill(array, value, start, end);
  24453. }
  24454. /**
  24455. * This method is like `_.find` except that it returns the index of the first
  24456. * element `predicate` returns truthy for instead of the element itself.
  24457. *
  24458. * @static
  24459. * @memberOf _
  24460. * @since 1.1.0
  24461. * @category Array
  24462. * @param {Array} array The array to inspect.
  24463. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24464. * @param {number} [fromIndex=0] The index to search from.
  24465. * @returns {number} Returns the index of the found element, else `-1`.
  24466. * @example
  24467. *
  24468. * var users = [
  24469. * { 'user': 'barney', 'active': false },
  24470. * { 'user': 'fred', 'active': false },
  24471. * { 'user': 'pebbles', 'active': true }
  24472. * ];
  24473. *
  24474. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24475. * // => 0
  24476. *
  24477. * // The `_.matches` iteratee shorthand.
  24478. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24479. * // => 1
  24480. *
  24481. * // The `_.matchesProperty` iteratee shorthand.
  24482. * _.findIndex(users, ['active', false]);
  24483. * // => 0
  24484. *
  24485. * // The `_.property` iteratee shorthand.
  24486. * _.findIndex(users, 'active');
  24487. * // => 2
  24488. */
  24489. function findIndex(array, predicate, fromIndex) {
  24490. var length = array == null ? 0 : array.length;
  24491. if (!length) {
  24492. return -1;
  24493. }
  24494. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24495. if (index < 0) {
  24496. index = nativeMax(length + index, 0);
  24497. }
  24498. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24499. }
  24500. /**
  24501. * This method is like `_.findIndex` except that it iterates over elements
  24502. * of `collection` from right to left.
  24503. *
  24504. * @static
  24505. * @memberOf _
  24506. * @since 2.0.0
  24507. * @category Array
  24508. * @param {Array} array The array to inspect.
  24509. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24510. * @param {number} [fromIndex=array.length-1] The index to search from.
  24511. * @returns {number} Returns the index of the found element, else `-1`.
  24512. * @example
  24513. *
  24514. * var users = [
  24515. * { 'user': 'barney', 'active': true },
  24516. * { 'user': 'fred', 'active': false },
  24517. * { 'user': 'pebbles', 'active': false }
  24518. * ];
  24519. *
  24520. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24521. * // => 2
  24522. *
  24523. * // The `_.matches` iteratee shorthand.
  24524. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24525. * // => 0
  24526. *
  24527. * // The `_.matchesProperty` iteratee shorthand.
  24528. * _.findLastIndex(users, ['active', false]);
  24529. * // => 2
  24530. *
  24531. * // The `_.property` iteratee shorthand.
  24532. * _.findLastIndex(users, 'active');
  24533. * // => 0
  24534. */
  24535. function findLastIndex(array, predicate, fromIndex) {
  24536. var length = array == null ? 0 : array.length;
  24537. if (!length) {
  24538. return -1;
  24539. }
  24540. var index = length - 1;
  24541. if (fromIndex !== undefined) {
  24542. index = toInteger(fromIndex);
  24543. index = fromIndex < 0
  24544. ? nativeMax(length + index, 0)
  24545. : nativeMin(index, length - 1);
  24546. }
  24547. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24548. }
  24549. /**
  24550. * Flattens `array` a single level deep.
  24551. *
  24552. * @static
  24553. * @memberOf _
  24554. * @since 0.1.0
  24555. * @category Array
  24556. * @param {Array} array The array to flatten.
  24557. * @returns {Array} Returns the new flattened array.
  24558. * @example
  24559. *
  24560. * _.flatten([1, [2, [3, [4]], 5]]);
  24561. * // => [1, 2, [3, [4]], 5]
  24562. */
  24563. function flatten(array) {
  24564. var length = array == null ? 0 : array.length;
  24565. return length ? baseFlatten(array, 1) : [];
  24566. }
  24567. /**
  24568. * Recursively flattens `array`.
  24569. *
  24570. * @static
  24571. * @memberOf _
  24572. * @since 3.0.0
  24573. * @category Array
  24574. * @param {Array} array The array to flatten.
  24575. * @returns {Array} Returns the new flattened array.
  24576. * @example
  24577. *
  24578. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24579. * // => [1, 2, 3, 4, 5]
  24580. */
  24581. function flattenDeep(array) {
  24582. var length = array == null ? 0 : array.length;
  24583. return length ? baseFlatten(array, INFINITY) : [];
  24584. }
  24585. /**
  24586. * Recursively flatten `array` up to `depth` times.
  24587. *
  24588. * @static
  24589. * @memberOf _
  24590. * @since 4.4.0
  24591. * @category Array
  24592. * @param {Array} array The array to flatten.
  24593. * @param {number} [depth=1] The maximum recursion depth.
  24594. * @returns {Array} Returns the new flattened array.
  24595. * @example
  24596. *
  24597. * var array = [1, [2, [3, [4]], 5]];
  24598. *
  24599. * _.flattenDepth(array, 1);
  24600. * // => [1, 2, [3, [4]], 5]
  24601. *
  24602. * _.flattenDepth(array, 2);
  24603. * // => [1, 2, 3, [4], 5]
  24604. */
  24605. function flattenDepth(array, depth) {
  24606. var length = array == null ? 0 : array.length;
  24607. if (!length) {
  24608. return [];
  24609. }
  24610. depth = depth === undefined ? 1 : toInteger(depth);
  24611. return baseFlatten(array, depth);
  24612. }
  24613. /**
  24614. * The inverse of `_.toPairs`; this method returns an object composed
  24615. * from key-value `pairs`.
  24616. *
  24617. * @static
  24618. * @memberOf _
  24619. * @since 4.0.0
  24620. * @category Array
  24621. * @param {Array} pairs The key-value pairs.
  24622. * @returns {Object} Returns the new object.
  24623. * @example
  24624. *
  24625. * _.fromPairs([['a', 1], ['b', 2]]);
  24626. * // => { 'a': 1, 'b': 2 }
  24627. */
  24628. function fromPairs(pairs) {
  24629. var index = -1,
  24630. length = pairs == null ? 0 : pairs.length,
  24631. result = {};
  24632. while (++index < length) {
  24633. var pair = pairs[index];
  24634. result[pair[0]] = pair[1];
  24635. }
  24636. return result;
  24637. }
  24638. /**
  24639. * Gets the first element of `array`.
  24640. *
  24641. * @static
  24642. * @memberOf _
  24643. * @since 0.1.0
  24644. * @alias first
  24645. * @category Array
  24646. * @param {Array} array The array to query.
  24647. * @returns {*} Returns the first element of `array`.
  24648. * @example
  24649. *
  24650. * _.head([1, 2, 3]);
  24651. * // => 1
  24652. *
  24653. * _.head([]);
  24654. * // => undefined
  24655. */
  24656. function head(array) {
  24657. return (array && array.length) ? array[0] : undefined;
  24658. }
  24659. /**
  24660. * Gets the index at which the first occurrence of `value` is found in `array`
  24661. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24662. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24663. * offset from the end of `array`.
  24664. *
  24665. * @static
  24666. * @memberOf _
  24667. * @since 0.1.0
  24668. * @category Array
  24669. * @param {Array} array The array to inspect.
  24670. * @param {*} value The value to search for.
  24671. * @param {number} [fromIndex=0] The index to search from.
  24672. * @returns {number} Returns the index of the matched value, else `-1`.
  24673. * @example
  24674. *
  24675. * _.indexOf([1, 2, 1, 2], 2);
  24676. * // => 1
  24677. *
  24678. * // Search from the `fromIndex`.
  24679. * _.indexOf([1, 2, 1, 2], 2, 2);
  24680. * // => 3
  24681. */
  24682. function indexOf(array, value, fromIndex) {
  24683. var length = array == null ? 0 : array.length;
  24684. if (!length) {
  24685. return -1;
  24686. }
  24687. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24688. if (index < 0) {
  24689. index = nativeMax(length + index, 0);
  24690. }
  24691. return baseIndexOf(array, value, index);
  24692. }
  24693. /**
  24694. * Gets all but the last element of `array`.
  24695. *
  24696. * @static
  24697. * @memberOf _
  24698. * @since 0.1.0
  24699. * @category Array
  24700. * @param {Array} array The array to query.
  24701. * @returns {Array} Returns the slice of `array`.
  24702. * @example
  24703. *
  24704. * _.initial([1, 2, 3]);
  24705. * // => [1, 2]
  24706. */
  24707. function initial(array) {
  24708. var length = array == null ? 0 : array.length;
  24709. return length ? baseSlice(array, 0, -1) : [];
  24710. }
  24711. /**
  24712. * Creates an array of unique values that are included in all given arrays
  24713. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24714. * for equality comparisons. The order and references of result values are
  24715. * determined by the first array.
  24716. *
  24717. * @static
  24718. * @memberOf _
  24719. * @since 0.1.0
  24720. * @category Array
  24721. * @param {...Array} [arrays] The arrays to inspect.
  24722. * @returns {Array} Returns the new array of intersecting values.
  24723. * @example
  24724. *
  24725. * _.intersection([2, 1], [2, 3]);
  24726. * // => [2]
  24727. */
  24728. var intersection = baseRest(function(arrays) {
  24729. var mapped = arrayMap(arrays, castArrayLikeObject);
  24730. return (mapped.length && mapped[0] === arrays[0])
  24731. ? baseIntersection(mapped)
  24732. : [];
  24733. });
  24734. /**
  24735. * This method is like `_.intersection` except that it accepts `iteratee`
  24736. * which is invoked for each element of each `arrays` to generate the criterion
  24737. * by which they're compared. The order and references of result values are
  24738. * determined by the first array. The iteratee is invoked with one argument:
  24739. * (value).
  24740. *
  24741. * @static
  24742. * @memberOf _
  24743. * @since 4.0.0
  24744. * @category Array
  24745. * @param {...Array} [arrays] The arrays to inspect.
  24746. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24747. * @returns {Array} Returns the new array of intersecting values.
  24748. * @example
  24749. *
  24750. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24751. * // => [2.1]
  24752. *
  24753. * // The `_.property` iteratee shorthand.
  24754. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24755. * // => [{ 'x': 1 }]
  24756. */
  24757. var intersectionBy = baseRest(function(arrays) {
  24758. var iteratee = last(arrays),
  24759. mapped = arrayMap(arrays, castArrayLikeObject);
  24760. if (iteratee === last(mapped)) {
  24761. iteratee = undefined;
  24762. } else {
  24763. mapped.pop();
  24764. }
  24765. return (mapped.length && mapped[0] === arrays[0])
  24766. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24767. : [];
  24768. });
  24769. /**
  24770. * This method is like `_.intersection` except that it accepts `comparator`
  24771. * which is invoked to compare elements of `arrays`. The order and references
  24772. * of result values are determined by the first array. The comparator is
  24773. * invoked with two arguments: (arrVal, othVal).
  24774. *
  24775. * @static
  24776. * @memberOf _
  24777. * @since 4.0.0
  24778. * @category Array
  24779. * @param {...Array} [arrays] The arrays to inspect.
  24780. * @param {Function} [comparator] The comparator invoked per element.
  24781. * @returns {Array} Returns the new array of intersecting values.
  24782. * @example
  24783. *
  24784. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24785. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24786. *
  24787. * _.intersectionWith(objects, others, _.isEqual);
  24788. * // => [{ 'x': 1, 'y': 2 }]
  24789. */
  24790. var intersectionWith = baseRest(function(arrays) {
  24791. var comparator = last(arrays),
  24792. mapped = arrayMap(arrays, castArrayLikeObject);
  24793. comparator = typeof comparator == 'function' ? comparator : undefined;
  24794. if (comparator) {
  24795. mapped.pop();
  24796. }
  24797. return (mapped.length && mapped[0] === arrays[0])
  24798. ? baseIntersection(mapped, undefined, comparator)
  24799. : [];
  24800. });
  24801. /**
  24802. * Converts all elements in `array` into a string separated by `separator`.
  24803. *
  24804. * @static
  24805. * @memberOf _
  24806. * @since 4.0.0
  24807. * @category Array
  24808. * @param {Array} array The array to convert.
  24809. * @param {string} [separator=','] The element separator.
  24810. * @returns {string} Returns the joined string.
  24811. * @example
  24812. *
  24813. * _.join(['a', 'b', 'c'], '~');
  24814. * // => 'a~b~c'
  24815. */
  24816. function join(array, separator) {
  24817. return array == null ? '' : nativeJoin.call(array, separator);
  24818. }
  24819. /**
  24820. * Gets the last element of `array`.
  24821. *
  24822. * @static
  24823. * @memberOf _
  24824. * @since 0.1.0
  24825. * @category Array
  24826. * @param {Array} array The array to query.
  24827. * @returns {*} Returns the last element of `array`.
  24828. * @example
  24829. *
  24830. * _.last([1, 2, 3]);
  24831. * // => 3
  24832. */
  24833. function last(array) {
  24834. var length = array == null ? 0 : array.length;
  24835. return length ? array[length - 1] : undefined;
  24836. }
  24837. /**
  24838. * This method is like `_.indexOf` except that it iterates over elements of
  24839. * `array` from right to left.
  24840. *
  24841. * @static
  24842. * @memberOf _
  24843. * @since 0.1.0
  24844. * @category Array
  24845. * @param {Array} array The array to inspect.
  24846. * @param {*} value The value to search for.
  24847. * @param {number} [fromIndex=array.length-1] The index to search from.
  24848. * @returns {number} Returns the index of the matched value, else `-1`.
  24849. * @example
  24850. *
  24851. * _.lastIndexOf([1, 2, 1, 2], 2);
  24852. * // => 3
  24853. *
  24854. * // Search from the `fromIndex`.
  24855. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24856. * // => 1
  24857. */
  24858. function lastIndexOf(array, value, fromIndex) {
  24859. var length = array == null ? 0 : array.length;
  24860. if (!length) {
  24861. return -1;
  24862. }
  24863. var index = length;
  24864. if (fromIndex !== undefined) {
  24865. index = toInteger(fromIndex);
  24866. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24867. }
  24868. return value === value
  24869. ? strictLastIndexOf(array, value, index)
  24870. : baseFindIndex(array, baseIsNaN, index, true);
  24871. }
  24872. /**
  24873. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24874. * element from the end is returned.
  24875. *
  24876. * @static
  24877. * @memberOf _
  24878. * @since 4.11.0
  24879. * @category Array
  24880. * @param {Array} array The array to query.
  24881. * @param {number} [n=0] The index of the element to return.
  24882. * @returns {*} Returns the nth element of `array`.
  24883. * @example
  24884. *
  24885. * var array = ['a', 'b', 'c', 'd'];
  24886. *
  24887. * _.nth(array, 1);
  24888. * // => 'b'
  24889. *
  24890. * _.nth(array, -2);
  24891. * // => 'c';
  24892. */
  24893. function nth(array, n) {
  24894. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24895. }
  24896. /**
  24897. * Removes all given values from `array` using
  24898. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24899. * for equality comparisons.
  24900. *
  24901. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24902. * to remove elements from an array by predicate.
  24903. *
  24904. * @static
  24905. * @memberOf _
  24906. * @since 2.0.0
  24907. * @category Array
  24908. * @param {Array} array The array to modify.
  24909. * @param {...*} [values] The values to remove.
  24910. * @returns {Array} Returns `array`.
  24911. * @example
  24912. *
  24913. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24914. *
  24915. * _.pull(array, 'a', 'c');
  24916. * console.log(array);
  24917. * // => ['b', 'b']
  24918. */
  24919. var pull = baseRest(pullAll);
  24920. /**
  24921. * This method is like `_.pull` except that it accepts an array of values to remove.
  24922. *
  24923. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24924. *
  24925. * @static
  24926. * @memberOf _
  24927. * @since 4.0.0
  24928. * @category Array
  24929. * @param {Array} array The array to modify.
  24930. * @param {Array} values The values to remove.
  24931. * @returns {Array} Returns `array`.
  24932. * @example
  24933. *
  24934. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24935. *
  24936. * _.pullAll(array, ['a', 'c']);
  24937. * console.log(array);
  24938. * // => ['b', 'b']
  24939. */
  24940. function pullAll(array, values) {
  24941. return (array && array.length && values && values.length)
  24942. ? basePullAll(array, values)
  24943. : array;
  24944. }
  24945. /**
  24946. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24947. * invoked for each element of `array` and `values` to generate the criterion
  24948. * by which they're compared. The iteratee is invoked with one argument: (value).
  24949. *
  24950. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24951. *
  24952. * @static
  24953. * @memberOf _
  24954. * @since 4.0.0
  24955. * @category Array
  24956. * @param {Array} array The array to modify.
  24957. * @param {Array} values The values to remove.
  24958. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24959. * @returns {Array} Returns `array`.
  24960. * @example
  24961. *
  24962. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24963. *
  24964. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24965. * console.log(array);
  24966. * // => [{ 'x': 2 }]
  24967. */
  24968. function pullAllBy(array, values, iteratee) {
  24969. return (array && array.length && values && values.length)
  24970. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24971. : array;
  24972. }
  24973. /**
  24974. * This method is like `_.pullAll` except that it accepts `comparator` which
  24975. * is invoked to compare elements of `array` to `values`. The comparator is
  24976. * invoked with two arguments: (arrVal, othVal).
  24977. *
  24978. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24979. *
  24980. * @static
  24981. * @memberOf _
  24982. * @since 4.6.0
  24983. * @category Array
  24984. * @param {Array} array The array to modify.
  24985. * @param {Array} values The values to remove.
  24986. * @param {Function} [comparator] The comparator invoked per element.
  24987. * @returns {Array} Returns `array`.
  24988. * @example
  24989. *
  24990. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24991. *
  24992. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24993. * console.log(array);
  24994. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24995. */
  24996. function pullAllWith(array, values, comparator) {
  24997. return (array && array.length && values && values.length)
  24998. ? basePullAll(array, values, undefined, comparator)
  24999. : array;
  25000. }
  25001. /**
  25002. * Removes elements from `array` corresponding to `indexes` and returns an
  25003. * array of removed elements.
  25004. *
  25005. * **Note:** Unlike `_.at`, this method mutates `array`.
  25006. *
  25007. * @static
  25008. * @memberOf _
  25009. * @since 3.0.0
  25010. * @category Array
  25011. * @param {Array} array The array to modify.
  25012. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  25013. * @returns {Array} Returns the new array of removed elements.
  25014. * @example
  25015. *
  25016. * var array = ['a', 'b', 'c', 'd'];
  25017. * var pulled = _.pullAt(array, [1, 3]);
  25018. *
  25019. * console.log(array);
  25020. * // => ['a', 'c']
  25021. *
  25022. * console.log(pulled);
  25023. * // => ['b', 'd']
  25024. */
  25025. var pullAt = flatRest(function(array, indexes) {
  25026. var length = array == null ? 0 : array.length,
  25027. result = baseAt(array, indexes);
  25028. basePullAt(array, arrayMap(indexes, function(index) {
  25029. return isIndex(index, length) ? +index : index;
  25030. }).sort(compareAscending));
  25031. return result;
  25032. });
  25033. /**
  25034. * Removes all elements from `array` that `predicate` returns truthy for
  25035. * and returns an array of the removed elements. The predicate is invoked
  25036. * with three arguments: (value, index, array).
  25037. *
  25038. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  25039. * to pull elements from an array by value.
  25040. *
  25041. * @static
  25042. * @memberOf _
  25043. * @since 2.0.0
  25044. * @category Array
  25045. * @param {Array} array The array to modify.
  25046. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25047. * @returns {Array} Returns the new array of removed elements.
  25048. * @example
  25049. *
  25050. * var array = [1, 2, 3, 4];
  25051. * var evens = _.remove(array, function(n) {
  25052. * return n % 2 == 0;
  25053. * });
  25054. *
  25055. * console.log(array);
  25056. * // => [1, 3]
  25057. *
  25058. * console.log(evens);
  25059. * // => [2, 4]
  25060. */
  25061. function remove(array, predicate) {
  25062. var result = [];
  25063. if (!(array && array.length)) {
  25064. return result;
  25065. }
  25066. var index = -1,
  25067. indexes = [],
  25068. length = array.length;
  25069. predicate = getIteratee(predicate, 3);
  25070. while (++index < length) {
  25071. var value = array[index];
  25072. if (predicate(value, index, array)) {
  25073. result.push(value);
  25074. indexes.push(index);
  25075. }
  25076. }
  25077. basePullAt(array, indexes);
  25078. return result;
  25079. }
  25080. /**
  25081. * Reverses `array` so that the first element becomes the last, the second
  25082. * element becomes the second to last, and so on.
  25083. *
  25084. * **Note:** This method mutates `array` and is based on
  25085. * [`Array#reverse`](https://mdn.io/Array/reverse).
  25086. *
  25087. * @static
  25088. * @memberOf _
  25089. * @since 4.0.0
  25090. * @category Array
  25091. * @param {Array} array The array to modify.
  25092. * @returns {Array} Returns `array`.
  25093. * @example
  25094. *
  25095. * var array = [1, 2, 3];
  25096. *
  25097. * _.reverse(array);
  25098. * // => [3, 2, 1]
  25099. *
  25100. * console.log(array);
  25101. * // => [3, 2, 1]
  25102. */
  25103. function reverse(array) {
  25104. return array == null ? array : nativeReverse.call(array);
  25105. }
  25106. /**
  25107. * Creates a slice of `array` from `start` up to, but not including, `end`.
  25108. *
  25109. * **Note:** This method is used instead of
  25110. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25111. * returned.
  25112. *
  25113. * @static
  25114. * @memberOf _
  25115. * @since 3.0.0
  25116. * @category Array
  25117. * @param {Array} array The array to slice.
  25118. * @param {number} [start=0] The start position.
  25119. * @param {number} [end=array.length] The end position.
  25120. * @returns {Array} Returns the slice of `array`.
  25121. */
  25122. function slice(array, start, end) {
  25123. var length = array == null ? 0 : array.length;
  25124. if (!length) {
  25125. return [];
  25126. }
  25127. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25128. start = 0;
  25129. end = length;
  25130. }
  25131. else {
  25132. start = start == null ? 0 : toInteger(start);
  25133. end = end === undefined ? length : toInteger(end);
  25134. }
  25135. return baseSlice(array, start, end);
  25136. }
  25137. /**
  25138. * Uses a binary search to determine the lowest index at which `value`
  25139. * should be inserted into `array` in order to maintain its sort order.
  25140. *
  25141. * @static
  25142. * @memberOf _
  25143. * @since 0.1.0
  25144. * @category Array
  25145. * @param {Array} array The sorted array to inspect.
  25146. * @param {*} value The value to evaluate.
  25147. * @returns {number} Returns the index at which `value` should be inserted
  25148. * into `array`.
  25149. * @example
  25150. *
  25151. * _.sortedIndex([30, 50], 40);
  25152. * // => 1
  25153. */
  25154. function sortedIndex(array, value) {
  25155. return baseSortedIndex(array, value);
  25156. }
  25157. /**
  25158. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25159. * which is invoked for `value` and each element of `array` to compute their
  25160. * sort ranking. The iteratee is invoked with one argument: (value).
  25161. *
  25162. * @static
  25163. * @memberOf _
  25164. * @since 4.0.0
  25165. * @category Array
  25166. * @param {Array} array The sorted array to inspect.
  25167. * @param {*} value The value to evaluate.
  25168. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25169. * @returns {number} Returns the index at which `value` should be inserted
  25170. * into `array`.
  25171. * @example
  25172. *
  25173. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25174. *
  25175. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25176. * // => 0
  25177. *
  25178. * // The `_.property` iteratee shorthand.
  25179. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25180. * // => 0
  25181. */
  25182. function sortedIndexBy(array, value, iteratee) {
  25183. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25184. }
  25185. /**
  25186. * This method is like `_.indexOf` except that it performs a binary
  25187. * search on a sorted `array`.
  25188. *
  25189. * @static
  25190. * @memberOf _
  25191. * @since 4.0.0
  25192. * @category Array
  25193. * @param {Array} array The array to inspect.
  25194. * @param {*} value The value to search for.
  25195. * @returns {number} Returns the index of the matched value, else `-1`.
  25196. * @example
  25197. *
  25198. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25199. * // => 1
  25200. */
  25201. function sortedIndexOf(array, value) {
  25202. var length = array == null ? 0 : array.length;
  25203. if (length) {
  25204. var index = baseSortedIndex(array, value);
  25205. if (index < length && eq(array[index], value)) {
  25206. return index;
  25207. }
  25208. }
  25209. return -1;
  25210. }
  25211. /**
  25212. * This method is like `_.sortedIndex` except that it returns the highest
  25213. * index at which `value` should be inserted into `array` in order to
  25214. * maintain its sort order.
  25215. *
  25216. * @static
  25217. * @memberOf _
  25218. * @since 3.0.0
  25219. * @category Array
  25220. * @param {Array} array The sorted array to inspect.
  25221. * @param {*} value The value to evaluate.
  25222. * @returns {number} Returns the index at which `value` should be inserted
  25223. * into `array`.
  25224. * @example
  25225. *
  25226. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25227. * // => 4
  25228. */
  25229. function sortedLastIndex(array, value) {
  25230. return baseSortedIndex(array, value, true);
  25231. }
  25232. /**
  25233. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25234. * which is invoked for `value` and each element of `array` to compute their
  25235. * sort ranking. The iteratee is invoked with one argument: (value).
  25236. *
  25237. * @static
  25238. * @memberOf _
  25239. * @since 4.0.0
  25240. * @category Array
  25241. * @param {Array} array The sorted array to inspect.
  25242. * @param {*} value The value to evaluate.
  25243. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25244. * @returns {number} Returns the index at which `value` should be inserted
  25245. * into `array`.
  25246. * @example
  25247. *
  25248. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25249. *
  25250. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25251. * // => 1
  25252. *
  25253. * // The `_.property` iteratee shorthand.
  25254. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25255. * // => 1
  25256. */
  25257. function sortedLastIndexBy(array, value, iteratee) {
  25258. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25259. }
  25260. /**
  25261. * This method is like `_.lastIndexOf` except that it performs a binary
  25262. * search on a sorted `array`.
  25263. *
  25264. * @static
  25265. * @memberOf _
  25266. * @since 4.0.0
  25267. * @category Array
  25268. * @param {Array} array The array to inspect.
  25269. * @param {*} value The value to search for.
  25270. * @returns {number} Returns the index of the matched value, else `-1`.
  25271. * @example
  25272. *
  25273. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25274. * // => 3
  25275. */
  25276. function sortedLastIndexOf(array, value) {
  25277. var length = array == null ? 0 : array.length;
  25278. if (length) {
  25279. var index = baseSortedIndex(array, value, true) - 1;
  25280. if (eq(array[index], value)) {
  25281. return index;
  25282. }
  25283. }
  25284. return -1;
  25285. }
  25286. /**
  25287. * This method is like `_.uniq` except that it's designed and optimized
  25288. * for sorted arrays.
  25289. *
  25290. * @static
  25291. * @memberOf _
  25292. * @since 4.0.0
  25293. * @category Array
  25294. * @param {Array} array The array to inspect.
  25295. * @returns {Array} Returns the new duplicate free array.
  25296. * @example
  25297. *
  25298. * _.sortedUniq([1, 1, 2]);
  25299. * // => [1, 2]
  25300. */
  25301. function sortedUniq(array) {
  25302. return (array && array.length)
  25303. ? baseSortedUniq(array)
  25304. : [];
  25305. }
  25306. /**
  25307. * This method is like `_.uniqBy` except that it's designed and optimized
  25308. * for sorted arrays.
  25309. *
  25310. * @static
  25311. * @memberOf _
  25312. * @since 4.0.0
  25313. * @category Array
  25314. * @param {Array} array The array to inspect.
  25315. * @param {Function} [iteratee] The iteratee invoked per element.
  25316. * @returns {Array} Returns the new duplicate free array.
  25317. * @example
  25318. *
  25319. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25320. * // => [1.1, 2.3]
  25321. */
  25322. function sortedUniqBy(array, iteratee) {
  25323. return (array && array.length)
  25324. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25325. : [];
  25326. }
  25327. /**
  25328. * Gets all but the first element of `array`.
  25329. *
  25330. * @static
  25331. * @memberOf _
  25332. * @since 4.0.0
  25333. * @category Array
  25334. * @param {Array} array The array to query.
  25335. * @returns {Array} Returns the slice of `array`.
  25336. * @example
  25337. *
  25338. * _.tail([1, 2, 3]);
  25339. * // => [2, 3]
  25340. */
  25341. function tail(array) {
  25342. var length = array == null ? 0 : array.length;
  25343. return length ? baseSlice(array, 1, length) : [];
  25344. }
  25345. /**
  25346. * Creates a slice of `array` with `n` elements taken from the beginning.
  25347. *
  25348. * @static
  25349. * @memberOf _
  25350. * @since 0.1.0
  25351. * @category Array
  25352. * @param {Array} array The array to query.
  25353. * @param {number} [n=1] The number of elements to take.
  25354. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25355. * @returns {Array} Returns the slice of `array`.
  25356. * @example
  25357. *
  25358. * _.take([1, 2, 3]);
  25359. * // => [1]
  25360. *
  25361. * _.take([1, 2, 3], 2);
  25362. * // => [1, 2]
  25363. *
  25364. * _.take([1, 2, 3], 5);
  25365. * // => [1, 2, 3]
  25366. *
  25367. * _.take([1, 2, 3], 0);
  25368. * // => []
  25369. */
  25370. function take(array, n, guard) {
  25371. if (!(array && array.length)) {
  25372. return [];
  25373. }
  25374. n = (guard || n === undefined) ? 1 : toInteger(n);
  25375. return baseSlice(array, 0, n < 0 ? 0 : n);
  25376. }
  25377. /**
  25378. * Creates a slice of `array` with `n` elements taken from the end.
  25379. *
  25380. * @static
  25381. * @memberOf _
  25382. * @since 3.0.0
  25383. * @category Array
  25384. * @param {Array} array The array to query.
  25385. * @param {number} [n=1] The number of elements to take.
  25386. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25387. * @returns {Array} Returns the slice of `array`.
  25388. * @example
  25389. *
  25390. * _.takeRight([1, 2, 3]);
  25391. * // => [3]
  25392. *
  25393. * _.takeRight([1, 2, 3], 2);
  25394. * // => [2, 3]
  25395. *
  25396. * _.takeRight([1, 2, 3], 5);
  25397. * // => [1, 2, 3]
  25398. *
  25399. * _.takeRight([1, 2, 3], 0);
  25400. * // => []
  25401. */
  25402. function takeRight(array, n, guard) {
  25403. var length = array == null ? 0 : array.length;
  25404. if (!length) {
  25405. return [];
  25406. }
  25407. n = (guard || n === undefined) ? 1 : toInteger(n);
  25408. n = length - n;
  25409. return baseSlice(array, n < 0 ? 0 : n, length);
  25410. }
  25411. /**
  25412. * Creates a slice of `array` with elements taken from the end. Elements are
  25413. * taken until `predicate` returns falsey. The predicate is invoked with
  25414. * three arguments: (value, index, array).
  25415. *
  25416. * @static
  25417. * @memberOf _
  25418. * @since 3.0.0
  25419. * @category Array
  25420. * @param {Array} array The array to query.
  25421. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25422. * @returns {Array} Returns the slice of `array`.
  25423. * @example
  25424. *
  25425. * var users = [
  25426. * { 'user': 'barney', 'active': true },
  25427. * { 'user': 'fred', 'active': false },
  25428. * { 'user': 'pebbles', 'active': false }
  25429. * ];
  25430. *
  25431. * _.takeRightWhile(users, function(o) { return !o.active; });
  25432. * // => objects for ['fred', 'pebbles']
  25433. *
  25434. * // The `_.matches` iteratee shorthand.
  25435. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25436. * // => objects for ['pebbles']
  25437. *
  25438. * // The `_.matchesProperty` iteratee shorthand.
  25439. * _.takeRightWhile(users, ['active', false]);
  25440. * // => objects for ['fred', 'pebbles']
  25441. *
  25442. * // The `_.property` iteratee shorthand.
  25443. * _.takeRightWhile(users, 'active');
  25444. * // => []
  25445. */
  25446. function takeRightWhile(array, predicate) {
  25447. return (array && array.length)
  25448. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25449. : [];
  25450. }
  25451. /**
  25452. * Creates a slice of `array` with elements taken from the beginning. Elements
  25453. * are taken until `predicate` returns falsey. The predicate is invoked with
  25454. * three arguments: (value, index, array).
  25455. *
  25456. * @static
  25457. * @memberOf _
  25458. * @since 3.0.0
  25459. * @category Array
  25460. * @param {Array} array The array to query.
  25461. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25462. * @returns {Array} Returns the slice of `array`.
  25463. * @example
  25464. *
  25465. * var users = [
  25466. * { 'user': 'barney', 'active': false },
  25467. * { 'user': 'fred', 'active': false },
  25468. * { 'user': 'pebbles', 'active': true }
  25469. * ];
  25470. *
  25471. * _.takeWhile(users, function(o) { return !o.active; });
  25472. * // => objects for ['barney', 'fred']
  25473. *
  25474. * // The `_.matches` iteratee shorthand.
  25475. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25476. * // => objects for ['barney']
  25477. *
  25478. * // The `_.matchesProperty` iteratee shorthand.
  25479. * _.takeWhile(users, ['active', false]);
  25480. * // => objects for ['barney', 'fred']
  25481. *
  25482. * // The `_.property` iteratee shorthand.
  25483. * _.takeWhile(users, 'active');
  25484. * // => []
  25485. */
  25486. function takeWhile(array, predicate) {
  25487. return (array && array.length)
  25488. ? baseWhile(array, getIteratee(predicate, 3))
  25489. : [];
  25490. }
  25491. /**
  25492. * Creates an array of unique values, in order, from all given arrays using
  25493. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25494. * for equality comparisons.
  25495. *
  25496. * @static
  25497. * @memberOf _
  25498. * @since 0.1.0
  25499. * @category Array
  25500. * @param {...Array} [arrays] The arrays to inspect.
  25501. * @returns {Array} Returns the new array of combined values.
  25502. * @example
  25503. *
  25504. * _.union([2], [1, 2]);
  25505. * // => [2, 1]
  25506. */
  25507. var union = baseRest(function(arrays) {
  25508. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25509. });
  25510. /**
  25511. * This method is like `_.union` except that it accepts `iteratee` which is
  25512. * invoked for each element of each `arrays` to generate the criterion by
  25513. * which uniqueness is computed. Result values are chosen from the first
  25514. * array in which the value occurs. The iteratee is invoked with one argument:
  25515. * (value).
  25516. *
  25517. * @static
  25518. * @memberOf _
  25519. * @since 4.0.0
  25520. * @category Array
  25521. * @param {...Array} [arrays] The arrays to inspect.
  25522. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25523. * @returns {Array} Returns the new array of combined values.
  25524. * @example
  25525. *
  25526. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25527. * // => [2.1, 1.2]
  25528. *
  25529. * // The `_.property` iteratee shorthand.
  25530. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25531. * // => [{ 'x': 1 }, { 'x': 2 }]
  25532. */
  25533. var unionBy = baseRest(function(arrays) {
  25534. var iteratee = last(arrays);
  25535. if (isArrayLikeObject(iteratee)) {
  25536. iteratee = undefined;
  25537. }
  25538. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25539. });
  25540. /**
  25541. * This method is like `_.union` except that it accepts `comparator` which
  25542. * is invoked to compare elements of `arrays`. Result values are chosen from
  25543. * the first array in which the value occurs. The comparator is invoked
  25544. * with two arguments: (arrVal, othVal).
  25545. *
  25546. * @static
  25547. * @memberOf _
  25548. * @since 4.0.0
  25549. * @category Array
  25550. * @param {...Array} [arrays] The arrays to inspect.
  25551. * @param {Function} [comparator] The comparator invoked per element.
  25552. * @returns {Array} Returns the new array of combined values.
  25553. * @example
  25554. *
  25555. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25556. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25557. *
  25558. * _.unionWith(objects, others, _.isEqual);
  25559. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25560. */
  25561. var unionWith = baseRest(function(arrays) {
  25562. var comparator = last(arrays);
  25563. comparator = typeof comparator == 'function' ? comparator : undefined;
  25564. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25565. });
  25566. /**
  25567. * Creates a duplicate-free version of an array, using
  25568. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25569. * for equality comparisons, in which only the first occurrence of each element
  25570. * is kept. The order of result values is determined by the order they occur
  25571. * in the array.
  25572. *
  25573. * @static
  25574. * @memberOf _
  25575. * @since 0.1.0
  25576. * @category Array
  25577. * @param {Array} array The array to inspect.
  25578. * @returns {Array} Returns the new duplicate free array.
  25579. * @example
  25580. *
  25581. * _.uniq([2, 1, 2]);
  25582. * // => [2, 1]
  25583. */
  25584. function uniq(array) {
  25585. return (array && array.length) ? baseUniq(array) : [];
  25586. }
  25587. /**
  25588. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25589. * invoked for each element in `array` to generate the criterion by which
  25590. * uniqueness is computed. The order of result values is determined by the
  25591. * order they occur in the array. The iteratee is invoked with one argument:
  25592. * (value).
  25593. *
  25594. * @static
  25595. * @memberOf _
  25596. * @since 4.0.0
  25597. * @category Array
  25598. * @param {Array} array The array to inspect.
  25599. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25600. * @returns {Array} Returns the new duplicate free array.
  25601. * @example
  25602. *
  25603. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25604. * // => [2.1, 1.2]
  25605. *
  25606. * // The `_.property` iteratee shorthand.
  25607. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25608. * // => [{ 'x': 1 }, { 'x': 2 }]
  25609. */
  25610. function uniqBy(array, iteratee) {
  25611. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25612. }
  25613. /**
  25614. * This method is like `_.uniq` except that it accepts `comparator` which
  25615. * is invoked to compare elements of `array`. The order of result values is
  25616. * determined by the order they occur in the array.The comparator is invoked
  25617. * with two arguments: (arrVal, othVal).
  25618. *
  25619. * @static
  25620. * @memberOf _
  25621. * @since 4.0.0
  25622. * @category Array
  25623. * @param {Array} array The array to inspect.
  25624. * @param {Function} [comparator] The comparator invoked per element.
  25625. * @returns {Array} Returns the new duplicate free array.
  25626. * @example
  25627. *
  25628. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25629. *
  25630. * _.uniqWith(objects, _.isEqual);
  25631. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25632. */
  25633. function uniqWith(array, comparator) {
  25634. comparator = typeof comparator == 'function' ? comparator : undefined;
  25635. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25636. }
  25637. /**
  25638. * This method is like `_.zip` except that it accepts an array of grouped
  25639. * elements and creates an array regrouping the elements to their pre-zip
  25640. * configuration.
  25641. *
  25642. * @static
  25643. * @memberOf _
  25644. * @since 1.2.0
  25645. * @category Array
  25646. * @param {Array} array The array of grouped elements to process.
  25647. * @returns {Array} Returns the new array of regrouped elements.
  25648. * @example
  25649. *
  25650. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25651. * // => [['a', 1, true], ['b', 2, false]]
  25652. *
  25653. * _.unzip(zipped);
  25654. * // => [['a', 'b'], [1, 2], [true, false]]
  25655. */
  25656. function unzip(array) {
  25657. if (!(array && array.length)) {
  25658. return [];
  25659. }
  25660. var length = 0;
  25661. array = arrayFilter(array, function(group) {
  25662. if (isArrayLikeObject(group)) {
  25663. length = nativeMax(group.length, length);
  25664. return true;
  25665. }
  25666. });
  25667. return baseTimes(length, function(index) {
  25668. return arrayMap(array, baseProperty(index));
  25669. });
  25670. }
  25671. /**
  25672. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25673. * how regrouped values should be combined. The iteratee is invoked with the
  25674. * elements of each group: (...group).
  25675. *
  25676. * @static
  25677. * @memberOf _
  25678. * @since 3.8.0
  25679. * @category Array
  25680. * @param {Array} array The array of grouped elements to process.
  25681. * @param {Function} [iteratee=_.identity] The function to combine
  25682. * regrouped values.
  25683. * @returns {Array} Returns the new array of regrouped elements.
  25684. * @example
  25685. *
  25686. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25687. * // => [[1, 10, 100], [2, 20, 200]]
  25688. *
  25689. * _.unzipWith(zipped, _.add);
  25690. * // => [3, 30, 300]
  25691. */
  25692. function unzipWith(array, iteratee) {
  25693. if (!(array && array.length)) {
  25694. return [];
  25695. }
  25696. var result = unzip(array);
  25697. if (iteratee == null) {
  25698. return result;
  25699. }
  25700. return arrayMap(result, function(group) {
  25701. return apply(iteratee, undefined, group);
  25702. });
  25703. }
  25704. /**
  25705. * Creates an array excluding all given values using
  25706. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25707. * for equality comparisons.
  25708. *
  25709. * **Note:** Unlike `_.pull`, this method returns a new array.
  25710. *
  25711. * @static
  25712. * @memberOf _
  25713. * @since 0.1.0
  25714. * @category Array
  25715. * @param {Array} array The array to inspect.
  25716. * @param {...*} [values] The values to exclude.
  25717. * @returns {Array} Returns the new array of filtered values.
  25718. * @see _.difference, _.xor
  25719. * @example
  25720. *
  25721. * _.without([2, 1, 2, 3], 1, 2);
  25722. * // => [3]
  25723. */
  25724. var without = baseRest(function(array, values) {
  25725. return isArrayLikeObject(array)
  25726. ? baseDifference(array, values)
  25727. : [];
  25728. });
  25729. /**
  25730. * Creates an array of unique values that is the
  25731. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25732. * of the given arrays. The order of result values is determined by the order
  25733. * they occur in the arrays.
  25734. *
  25735. * @static
  25736. * @memberOf _
  25737. * @since 2.4.0
  25738. * @category Array
  25739. * @param {...Array} [arrays] The arrays to inspect.
  25740. * @returns {Array} Returns the new array of filtered values.
  25741. * @see _.difference, _.without
  25742. * @example
  25743. *
  25744. * _.xor([2, 1], [2, 3]);
  25745. * // => [1, 3]
  25746. */
  25747. var xor = baseRest(function(arrays) {
  25748. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25749. });
  25750. /**
  25751. * This method is like `_.xor` except that it accepts `iteratee` which is
  25752. * invoked for each element of each `arrays` to generate the criterion by
  25753. * which by which they're compared. The order of result values is determined
  25754. * by the order they occur in the arrays. The iteratee is invoked with one
  25755. * argument: (value).
  25756. *
  25757. * @static
  25758. * @memberOf _
  25759. * @since 4.0.0
  25760. * @category Array
  25761. * @param {...Array} [arrays] The arrays to inspect.
  25762. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25763. * @returns {Array} Returns the new array of filtered values.
  25764. * @example
  25765. *
  25766. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25767. * // => [1.2, 3.4]
  25768. *
  25769. * // The `_.property` iteratee shorthand.
  25770. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25771. * // => [{ 'x': 2 }]
  25772. */
  25773. var xorBy = baseRest(function(arrays) {
  25774. var iteratee = last(arrays);
  25775. if (isArrayLikeObject(iteratee)) {
  25776. iteratee = undefined;
  25777. }
  25778. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25779. });
  25780. /**
  25781. * This method is like `_.xor` except that it accepts `comparator` which is
  25782. * invoked to compare elements of `arrays`. The order of result values is
  25783. * determined by the order they occur in the arrays. The comparator is invoked
  25784. * with two arguments: (arrVal, othVal).
  25785. *
  25786. * @static
  25787. * @memberOf _
  25788. * @since 4.0.0
  25789. * @category Array
  25790. * @param {...Array} [arrays] The arrays to inspect.
  25791. * @param {Function} [comparator] The comparator invoked per element.
  25792. * @returns {Array} Returns the new array of filtered values.
  25793. * @example
  25794. *
  25795. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25796. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25797. *
  25798. * _.xorWith(objects, others, _.isEqual);
  25799. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25800. */
  25801. var xorWith = baseRest(function(arrays) {
  25802. var comparator = last(arrays);
  25803. comparator = typeof comparator == 'function' ? comparator : undefined;
  25804. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25805. });
  25806. /**
  25807. * Creates an array of grouped elements, the first of which contains the
  25808. * first elements of the given arrays, the second of which contains the
  25809. * second elements of the given arrays, and so on.
  25810. *
  25811. * @static
  25812. * @memberOf _
  25813. * @since 0.1.0
  25814. * @category Array
  25815. * @param {...Array} [arrays] The arrays to process.
  25816. * @returns {Array} Returns the new array of grouped elements.
  25817. * @example
  25818. *
  25819. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25820. * // => [['a', 1, true], ['b', 2, false]]
  25821. */
  25822. var zip = baseRest(unzip);
  25823. /**
  25824. * This method is like `_.fromPairs` except that it accepts two arrays,
  25825. * one of property identifiers and one of corresponding values.
  25826. *
  25827. * @static
  25828. * @memberOf _
  25829. * @since 0.4.0
  25830. * @category Array
  25831. * @param {Array} [props=[]] The property identifiers.
  25832. * @param {Array} [values=[]] The property values.
  25833. * @returns {Object} Returns the new object.
  25834. * @example
  25835. *
  25836. * _.zipObject(['a', 'b'], [1, 2]);
  25837. * // => { 'a': 1, 'b': 2 }
  25838. */
  25839. function zipObject(props, values) {
  25840. return baseZipObject(props || [], values || [], assignValue);
  25841. }
  25842. /**
  25843. * This method is like `_.zipObject` except that it supports property paths.
  25844. *
  25845. * @static
  25846. * @memberOf _
  25847. * @since 4.1.0
  25848. * @category Array
  25849. * @param {Array} [props=[]] The property identifiers.
  25850. * @param {Array} [values=[]] The property values.
  25851. * @returns {Object} Returns the new object.
  25852. * @example
  25853. *
  25854. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25855. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25856. */
  25857. function zipObjectDeep(props, values) {
  25858. return baseZipObject(props || [], values || [], baseSet);
  25859. }
  25860. /**
  25861. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25862. * how grouped values should be combined. The iteratee is invoked with the
  25863. * elements of each group: (...group).
  25864. *
  25865. * @static
  25866. * @memberOf _
  25867. * @since 3.8.0
  25868. * @category Array
  25869. * @param {...Array} [arrays] The arrays to process.
  25870. * @param {Function} [iteratee=_.identity] The function to combine
  25871. * grouped values.
  25872. * @returns {Array} Returns the new array of grouped elements.
  25873. * @example
  25874. *
  25875. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25876. * return a + b + c;
  25877. * });
  25878. * // => [111, 222]
  25879. */
  25880. var zipWith = baseRest(function(arrays) {
  25881. var length = arrays.length,
  25882. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25883. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25884. return unzipWith(arrays, iteratee);
  25885. });
  25886. /*------------------------------------------------------------------------*/
  25887. /**
  25888. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25889. * chain sequences enabled. The result of such sequences must be unwrapped
  25890. * with `_#value`.
  25891. *
  25892. * @static
  25893. * @memberOf _
  25894. * @since 1.3.0
  25895. * @category Seq
  25896. * @param {*} value The value to wrap.
  25897. * @returns {Object} Returns the new `lodash` wrapper instance.
  25898. * @example
  25899. *
  25900. * var users = [
  25901. * { 'user': 'barney', 'age': 36 },
  25902. * { 'user': 'fred', 'age': 40 },
  25903. * { 'user': 'pebbles', 'age': 1 }
  25904. * ];
  25905. *
  25906. * var youngest = _
  25907. * .chain(users)
  25908. * .sortBy('age')
  25909. * .map(function(o) {
  25910. * return o.user + ' is ' + o.age;
  25911. * })
  25912. * .head()
  25913. * .value();
  25914. * // => 'pebbles is 1'
  25915. */
  25916. function chain(value) {
  25917. var result = lodash(value);
  25918. result.__chain__ = true;
  25919. return result;
  25920. }
  25921. /**
  25922. * This method invokes `interceptor` and returns `value`. The interceptor
  25923. * is invoked with one argument; (value). The purpose of this method is to
  25924. * "tap into" a method chain sequence in order to modify intermediate results.
  25925. *
  25926. * @static
  25927. * @memberOf _
  25928. * @since 0.1.0
  25929. * @category Seq
  25930. * @param {*} value The value to provide to `interceptor`.
  25931. * @param {Function} interceptor The function to invoke.
  25932. * @returns {*} Returns `value`.
  25933. * @example
  25934. *
  25935. * _([1, 2, 3])
  25936. * .tap(function(array) {
  25937. * // Mutate input array.
  25938. * array.pop();
  25939. * })
  25940. * .reverse()
  25941. * .value();
  25942. * // => [2, 1]
  25943. */
  25944. function tap(value, interceptor) {
  25945. interceptor(value);
  25946. return value;
  25947. }
  25948. /**
  25949. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25950. * The purpose of this method is to "pass thru" values replacing intermediate
  25951. * results in a method chain sequence.
  25952. *
  25953. * @static
  25954. * @memberOf _
  25955. * @since 3.0.0
  25956. * @category Seq
  25957. * @param {*} value The value to provide to `interceptor`.
  25958. * @param {Function} interceptor The function to invoke.
  25959. * @returns {*} Returns the result of `interceptor`.
  25960. * @example
  25961. *
  25962. * _(' abc ')
  25963. * .chain()
  25964. * .trim()
  25965. * .thru(function(value) {
  25966. * return [value];
  25967. * })
  25968. * .value();
  25969. * // => ['abc']
  25970. */
  25971. function thru(value, interceptor) {
  25972. return interceptor(value);
  25973. }
  25974. /**
  25975. * This method is the wrapper version of `_.at`.
  25976. *
  25977. * @name at
  25978. * @memberOf _
  25979. * @since 1.0.0
  25980. * @category Seq
  25981. * @param {...(string|string[])} [paths] The property paths to pick.
  25982. * @returns {Object} Returns the new `lodash` wrapper instance.
  25983. * @example
  25984. *
  25985. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25986. *
  25987. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25988. * // => [3, 4]
  25989. */
  25990. var wrapperAt = flatRest(function(paths) {
  25991. var length = paths.length,
  25992. start = length ? paths[0] : 0,
  25993. value = this.__wrapped__,
  25994. interceptor = function(object) { return baseAt(object, paths); };
  25995. if (length > 1 || this.__actions__.length ||
  25996. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25997. return this.thru(interceptor);
  25998. }
  25999. value = value.slice(start, +start + (length ? 1 : 0));
  26000. value.__actions__.push({
  26001. 'func': thru,
  26002. 'args': [interceptor],
  26003. 'thisArg': undefined
  26004. });
  26005. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  26006. if (length && !array.length) {
  26007. array.push(undefined);
  26008. }
  26009. return array;
  26010. });
  26011. });
  26012. /**
  26013. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  26014. *
  26015. * @name chain
  26016. * @memberOf _
  26017. * @since 0.1.0
  26018. * @category Seq
  26019. * @returns {Object} Returns the new `lodash` wrapper instance.
  26020. * @example
  26021. *
  26022. * var users = [
  26023. * { 'user': 'barney', 'age': 36 },
  26024. * { 'user': 'fred', 'age': 40 }
  26025. * ];
  26026. *
  26027. * // A sequence without explicit chaining.
  26028. * _(users).head();
  26029. * // => { 'user': 'barney', 'age': 36 }
  26030. *
  26031. * // A sequence with explicit chaining.
  26032. * _(users)
  26033. * .chain()
  26034. * .head()
  26035. * .pick('user')
  26036. * .value();
  26037. * // => { 'user': 'barney' }
  26038. */
  26039. function wrapperChain() {
  26040. return chain(this);
  26041. }
  26042. /**
  26043. * Executes the chain sequence and returns the wrapped result.
  26044. *
  26045. * @name commit
  26046. * @memberOf _
  26047. * @since 3.2.0
  26048. * @category Seq
  26049. * @returns {Object} Returns the new `lodash` wrapper instance.
  26050. * @example
  26051. *
  26052. * var array = [1, 2];
  26053. * var wrapped = _(array).push(3);
  26054. *
  26055. * console.log(array);
  26056. * // => [1, 2]
  26057. *
  26058. * wrapped = wrapped.commit();
  26059. * console.log(array);
  26060. * // => [1, 2, 3]
  26061. *
  26062. * wrapped.last();
  26063. * // => 3
  26064. *
  26065. * console.log(array);
  26066. * // => [1, 2, 3]
  26067. */
  26068. function wrapperCommit() {
  26069. return new LodashWrapper(this.value(), this.__chain__);
  26070. }
  26071. /**
  26072. * Gets the next value on a wrapped object following the
  26073. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  26074. *
  26075. * @name next
  26076. * @memberOf _
  26077. * @since 4.0.0
  26078. * @category Seq
  26079. * @returns {Object} Returns the next iterator value.
  26080. * @example
  26081. *
  26082. * var wrapped = _([1, 2]);
  26083. *
  26084. * wrapped.next();
  26085. * // => { 'done': false, 'value': 1 }
  26086. *
  26087. * wrapped.next();
  26088. * // => { 'done': false, 'value': 2 }
  26089. *
  26090. * wrapped.next();
  26091. * // => { 'done': true, 'value': undefined }
  26092. */
  26093. function wrapperNext() {
  26094. if (this.__values__ === undefined) {
  26095. this.__values__ = toArray(this.value());
  26096. }
  26097. var done = this.__index__ >= this.__values__.length,
  26098. value = done ? undefined : this.__values__[this.__index__++];
  26099. return { 'done': done, 'value': value };
  26100. }
  26101. /**
  26102. * Enables the wrapper to be iterable.
  26103. *
  26104. * @name Symbol.iterator
  26105. * @memberOf _
  26106. * @since 4.0.0
  26107. * @category Seq
  26108. * @returns {Object} Returns the wrapper object.
  26109. * @example
  26110. *
  26111. * var wrapped = _([1, 2]);
  26112. *
  26113. * wrapped[Symbol.iterator]() === wrapped;
  26114. * // => true
  26115. *
  26116. * Array.from(wrapped);
  26117. * // => [1, 2]
  26118. */
  26119. function wrapperToIterator() {
  26120. return this;
  26121. }
  26122. /**
  26123. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26124. *
  26125. * @name plant
  26126. * @memberOf _
  26127. * @since 3.2.0
  26128. * @category Seq
  26129. * @param {*} value The value to plant.
  26130. * @returns {Object} Returns the new `lodash` wrapper instance.
  26131. * @example
  26132. *
  26133. * function square(n) {
  26134. * return n * n;
  26135. * }
  26136. *
  26137. * var wrapped = _([1, 2]).map(square);
  26138. * var other = wrapped.plant([3, 4]);
  26139. *
  26140. * other.value();
  26141. * // => [9, 16]
  26142. *
  26143. * wrapped.value();
  26144. * // => [1, 4]
  26145. */
  26146. function wrapperPlant(value) {
  26147. var result,
  26148. parent = this;
  26149. while (parent instanceof baseLodash) {
  26150. var clone = wrapperClone(parent);
  26151. clone.__index__ = 0;
  26152. clone.__values__ = undefined;
  26153. if (result) {
  26154. previous.__wrapped__ = clone;
  26155. } else {
  26156. result = clone;
  26157. }
  26158. var previous = clone;
  26159. parent = parent.__wrapped__;
  26160. }
  26161. previous.__wrapped__ = value;
  26162. return result;
  26163. }
  26164. /**
  26165. * This method is the wrapper version of `_.reverse`.
  26166. *
  26167. * **Note:** This method mutates the wrapped array.
  26168. *
  26169. * @name reverse
  26170. * @memberOf _
  26171. * @since 0.1.0
  26172. * @category Seq
  26173. * @returns {Object} Returns the new `lodash` wrapper instance.
  26174. * @example
  26175. *
  26176. * var array = [1, 2, 3];
  26177. *
  26178. * _(array).reverse().value()
  26179. * // => [3, 2, 1]
  26180. *
  26181. * console.log(array);
  26182. * // => [3, 2, 1]
  26183. */
  26184. function wrapperReverse() {
  26185. var value = this.__wrapped__;
  26186. if (value instanceof LazyWrapper) {
  26187. var wrapped = value;
  26188. if (this.__actions__.length) {
  26189. wrapped = new LazyWrapper(this);
  26190. }
  26191. wrapped = wrapped.reverse();
  26192. wrapped.__actions__.push({
  26193. 'func': thru,
  26194. 'args': [reverse],
  26195. 'thisArg': undefined
  26196. });
  26197. return new LodashWrapper(wrapped, this.__chain__);
  26198. }
  26199. return this.thru(reverse);
  26200. }
  26201. /**
  26202. * Executes the chain sequence to resolve the unwrapped value.
  26203. *
  26204. * @name value
  26205. * @memberOf _
  26206. * @since 0.1.0
  26207. * @alias toJSON, valueOf
  26208. * @category Seq
  26209. * @returns {*} Returns the resolved unwrapped value.
  26210. * @example
  26211. *
  26212. * _([1, 2, 3]).value();
  26213. * // => [1, 2, 3]
  26214. */
  26215. function wrapperValue() {
  26216. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26217. }
  26218. /*------------------------------------------------------------------------*/
  26219. /**
  26220. * Creates an object composed of keys generated from the results of running
  26221. * each element of `collection` thru `iteratee`. The corresponding value of
  26222. * each key is the number of times the key was returned by `iteratee`. The
  26223. * iteratee is invoked with one argument: (value).
  26224. *
  26225. * @static
  26226. * @memberOf _
  26227. * @since 0.5.0
  26228. * @category Collection
  26229. * @param {Array|Object} collection The collection to iterate over.
  26230. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26231. * @returns {Object} Returns the composed aggregate object.
  26232. * @example
  26233. *
  26234. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26235. * // => { '4': 1, '6': 2 }
  26236. *
  26237. * // The `_.property` iteratee shorthand.
  26238. * _.countBy(['one', 'two', 'three'], 'length');
  26239. * // => { '3': 2, '5': 1 }
  26240. */
  26241. var countBy = createAggregator(function(result, value, key) {
  26242. if (hasOwnProperty.call(result, key)) {
  26243. ++result[key];
  26244. } else {
  26245. baseAssignValue(result, key, 1);
  26246. }
  26247. });
  26248. /**
  26249. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26250. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26251. * invoked with three arguments: (value, index|key, collection).
  26252. *
  26253. * **Note:** This method returns `true` for
  26254. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26255. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26256. * elements of empty collections.
  26257. *
  26258. * @static
  26259. * @memberOf _
  26260. * @since 0.1.0
  26261. * @category Collection
  26262. * @param {Array|Object} collection The collection to iterate over.
  26263. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26264. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26265. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26266. * else `false`.
  26267. * @example
  26268. *
  26269. * _.every([true, 1, null, 'yes'], Boolean);
  26270. * // => false
  26271. *
  26272. * var users = [
  26273. * { 'user': 'barney', 'age': 36, 'active': false },
  26274. * { 'user': 'fred', 'age': 40, 'active': false }
  26275. * ];
  26276. *
  26277. * // The `_.matches` iteratee shorthand.
  26278. * _.every(users, { 'user': 'barney', 'active': false });
  26279. * // => false
  26280. *
  26281. * // The `_.matchesProperty` iteratee shorthand.
  26282. * _.every(users, ['active', false]);
  26283. * // => true
  26284. *
  26285. * // The `_.property` iteratee shorthand.
  26286. * _.every(users, 'active');
  26287. * // => false
  26288. */
  26289. function every(collection, predicate, guard) {
  26290. var func = isArray(collection) ? arrayEvery : baseEvery;
  26291. if (guard && isIterateeCall(collection, predicate, guard)) {
  26292. predicate = undefined;
  26293. }
  26294. return func(collection, getIteratee(predicate, 3));
  26295. }
  26296. /**
  26297. * Iterates over elements of `collection`, returning an array of all elements
  26298. * `predicate` returns truthy for. The predicate is invoked with three
  26299. * arguments: (value, index|key, collection).
  26300. *
  26301. * **Note:** Unlike `_.remove`, this method returns a new array.
  26302. *
  26303. * @static
  26304. * @memberOf _
  26305. * @since 0.1.0
  26306. * @category Collection
  26307. * @param {Array|Object} collection The collection to iterate over.
  26308. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26309. * @returns {Array} Returns the new filtered array.
  26310. * @see _.reject
  26311. * @example
  26312. *
  26313. * var users = [
  26314. * { 'user': 'barney', 'age': 36, 'active': true },
  26315. * { 'user': 'fred', 'age': 40, 'active': false }
  26316. * ];
  26317. *
  26318. * _.filter(users, function(o) { return !o.active; });
  26319. * // => objects for ['fred']
  26320. *
  26321. * // The `_.matches` iteratee shorthand.
  26322. * _.filter(users, { 'age': 36, 'active': true });
  26323. * // => objects for ['barney']
  26324. *
  26325. * // The `_.matchesProperty` iteratee shorthand.
  26326. * _.filter(users, ['active', false]);
  26327. * // => objects for ['fred']
  26328. *
  26329. * // The `_.property` iteratee shorthand.
  26330. * _.filter(users, 'active');
  26331. * // => objects for ['barney']
  26332. */
  26333. function filter(collection, predicate) {
  26334. var func = isArray(collection) ? arrayFilter : baseFilter;
  26335. return func(collection, getIteratee(predicate, 3));
  26336. }
  26337. /**
  26338. * Iterates over elements of `collection`, returning the first element
  26339. * `predicate` returns truthy for. The predicate is invoked with three
  26340. * arguments: (value, index|key, collection).
  26341. *
  26342. * @static
  26343. * @memberOf _
  26344. * @since 0.1.0
  26345. * @category Collection
  26346. * @param {Array|Object} collection The collection to inspect.
  26347. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26348. * @param {number} [fromIndex=0] The index to search from.
  26349. * @returns {*} Returns the matched element, else `undefined`.
  26350. * @example
  26351. *
  26352. * var users = [
  26353. * { 'user': 'barney', 'age': 36, 'active': true },
  26354. * { 'user': 'fred', 'age': 40, 'active': false },
  26355. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26356. * ];
  26357. *
  26358. * _.find(users, function(o) { return o.age < 40; });
  26359. * // => object for 'barney'
  26360. *
  26361. * // The `_.matches` iteratee shorthand.
  26362. * _.find(users, { 'age': 1, 'active': true });
  26363. * // => object for 'pebbles'
  26364. *
  26365. * // The `_.matchesProperty` iteratee shorthand.
  26366. * _.find(users, ['active', false]);
  26367. * // => object for 'fred'
  26368. *
  26369. * // The `_.property` iteratee shorthand.
  26370. * _.find(users, 'active');
  26371. * // => object for 'barney'
  26372. */
  26373. var find = createFind(findIndex);
  26374. /**
  26375. * This method is like `_.find` except that it iterates over elements of
  26376. * `collection` from right to left.
  26377. *
  26378. * @static
  26379. * @memberOf _
  26380. * @since 2.0.0
  26381. * @category Collection
  26382. * @param {Array|Object} collection The collection to inspect.
  26383. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26384. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26385. * @returns {*} Returns the matched element, else `undefined`.
  26386. * @example
  26387. *
  26388. * _.findLast([1, 2, 3, 4], function(n) {
  26389. * return n % 2 == 1;
  26390. * });
  26391. * // => 3
  26392. */
  26393. var findLast = createFind(findLastIndex);
  26394. /**
  26395. * Creates a flattened array of values by running each element in `collection`
  26396. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26397. * with three arguments: (value, index|key, collection).
  26398. *
  26399. * @static
  26400. * @memberOf _
  26401. * @since 4.0.0
  26402. * @category Collection
  26403. * @param {Array|Object} collection The collection to iterate over.
  26404. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26405. * @returns {Array} Returns the new flattened array.
  26406. * @example
  26407. *
  26408. * function duplicate(n) {
  26409. * return [n, n];
  26410. * }
  26411. *
  26412. * _.flatMap([1, 2], duplicate);
  26413. * // => [1, 1, 2, 2]
  26414. */
  26415. function flatMap(collection, iteratee) {
  26416. return baseFlatten(map(collection, iteratee), 1);
  26417. }
  26418. /**
  26419. * This method is like `_.flatMap` except that it recursively flattens the
  26420. * mapped results.
  26421. *
  26422. * @static
  26423. * @memberOf _
  26424. * @since 4.7.0
  26425. * @category Collection
  26426. * @param {Array|Object} collection The collection to iterate over.
  26427. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26428. * @returns {Array} Returns the new flattened array.
  26429. * @example
  26430. *
  26431. * function duplicate(n) {
  26432. * return [[[n, n]]];
  26433. * }
  26434. *
  26435. * _.flatMapDeep([1, 2], duplicate);
  26436. * // => [1, 1, 2, 2]
  26437. */
  26438. function flatMapDeep(collection, iteratee) {
  26439. return baseFlatten(map(collection, iteratee), INFINITY);
  26440. }
  26441. /**
  26442. * This method is like `_.flatMap` except that it recursively flattens the
  26443. * mapped results up to `depth` times.
  26444. *
  26445. * @static
  26446. * @memberOf _
  26447. * @since 4.7.0
  26448. * @category Collection
  26449. * @param {Array|Object} collection The collection to iterate over.
  26450. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26451. * @param {number} [depth=1] The maximum recursion depth.
  26452. * @returns {Array} Returns the new flattened array.
  26453. * @example
  26454. *
  26455. * function duplicate(n) {
  26456. * return [[[n, n]]];
  26457. * }
  26458. *
  26459. * _.flatMapDepth([1, 2], duplicate, 2);
  26460. * // => [[1, 1], [2, 2]]
  26461. */
  26462. function flatMapDepth(collection, iteratee, depth) {
  26463. depth = depth === undefined ? 1 : toInteger(depth);
  26464. return baseFlatten(map(collection, iteratee), depth);
  26465. }
  26466. /**
  26467. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26468. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26469. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26470. *
  26471. * **Note:** As with other "Collections" methods, objects with a "length"
  26472. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26473. * or `_.forOwn` for object iteration.
  26474. *
  26475. * @static
  26476. * @memberOf _
  26477. * @since 0.1.0
  26478. * @alias each
  26479. * @category Collection
  26480. * @param {Array|Object} collection The collection to iterate over.
  26481. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26482. * @returns {Array|Object} Returns `collection`.
  26483. * @see _.forEachRight
  26484. * @example
  26485. *
  26486. * _.forEach([1, 2], function(value) {
  26487. * console.log(value);
  26488. * });
  26489. * // => Logs `1` then `2`.
  26490. *
  26491. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26492. * console.log(key);
  26493. * });
  26494. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26495. */
  26496. function forEach(collection, iteratee) {
  26497. var func = isArray(collection) ? arrayEach : baseEach;
  26498. return func(collection, getIteratee(iteratee, 3));
  26499. }
  26500. /**
  26501. * This method is like `_.forEach` except that it iterates over elements of
  26502. * `collection` from right to left.
  26503. *
  26504. * @static
  26505. * @memberOf _
  26506. * @since 2.0.0
  26507. * @alias eachRight
  26508. * @category Collection
  26509. * @param {Array|Object} collection The collection to iterate over.
  26510. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26511. * @returns {Array|Object} Returns `collection`.
  26512. * @see _.forEach
  26513. * @example
  26514. *
  26515. * _.forEachRight([1, 2], function(value) {
  26516. * console.log(value);
  26517. * });
  26518. * // => Logs `2` then `1`.
  26519. */
  26520. function forEachRight(collection, iteratee) {
  26521. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26522. return func(collection, getIteratee(iteratee, 3));
  26523. }
  26524. /**
  26525. * Creates an object composed of keys generated from the results of running
  26526. * each element of `collection` thru `iteratee`. The order of grouped values
  26527. * is determined by the order they occur in `collection`. The corresponding
  26528. * value of each key is an array of elements responsible for generating the
  26529. * key. The iteratee is invoked with one argument: (value).
  26530. *
  26531. * @static
  26532. * @memberOf _
  26533. * @since 0.1.0
  26534. * @category Collection
  26535. * @param {Array|Object} collection The collection to iterate over.
  26536. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26537. * @returns {Object} Returns the composed aggregate object.
  26538. * @example
  26539. *
  26540. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26541. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26542. *
  26543. * // The `_.property` iteratee shorthand.
  26544. * _.groupBy(['one', 'two', 'three'], 'length');
  26545. * // => { '3': ['one', 'two'], '5': ['three'] }
  26546. */
  26547. var groupBy = createAggregator(function(result, value, key) {
  26548. if (hasOwnProperty.call(result, key)) {
  26549. result[key].push(value);
  26550. } else {
  26551. baseAssignValue(result, key, [value]);
  26552. }
  26553. });
  26554. /**
  26555. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26556. * checked for a substring of `value`, otherwise
  26557. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26558. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26559. * the offset from the end of `collection`.
  26560. *
  26561. * @static
  26562. * @memberOf _
  26563. * @since 0.1.0
  26564. * @category Collection
  26565. * @param {Array|Object|string} collection The collection to inspect.
  26566. * @param {*} value The value to search for.
  26567. * @param {number} [fromIndex=0] The index to search from.
  26568. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26569. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26570. * @example
  26571. *
  26572. * _.includes([1, 2, 3], 1);
  26573. * // => true
  26574. *
  26575. * _.includes([1, 2, 3], 1, 2);
  26576. * // => false
  26577. *
  26578. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26579. * // => true
  26580. *
  26581. * _.includes('abcd', 'bc');
  26582. * // => true
  26583. */
  26584. function includes(collection, value, fromIndex, guard) {
  26585. collection = isArrayLike(collection) ? collection : values(collection);
  26586. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26587. var length = collection.length;
  26588. if (fromIndex < 0) {
  26589. fromIndex = nativeMax(length + fromIndex, 0);
  26590. }
  26591. return isString(collection)
  26592. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26593. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26594. }
  26595. /**
  26596. * Invokes the method at `path` of each element in `collection`, returning
  26597. * an array of the results of each invoked method. Any additional arguments
  26598. * are provided to each invoked method. If `path` is a function, it's invoked
  26599. * for, and `this` bound to, each element in `collection`.
  26600. *
  26601. * @static
  26602. * @memberOf _
  26603. * @since 4.0.0
  26604. * @category Collection
  26605. * @param {Array|Object} collection The collection to iterate over.
  26606. * @param {Array|Function|string} path The path of the method to invoke or
  26607. * the function invoked per iteration.
  26608. * @param {...*} [args] The arguments to invoke each method with.
  26609. * @returns {Array} Returns the array of results.
  26610. * @example
  26611. *
  26612. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26613. * // => [[1, 5, 7], [1, 2, 3]]
  26614. *
  26615. * _.invokeMap([123, 456], String.prototype.split, '');
  26616. * // => [['1', '2', '3'], ['4', '5', '6']]
  26617. */
  26618. var invokeMap = baseRest(function(collection, path, args) {
  26619. var index = -1,
  26620. isFunc = typeof path == 'function',
  26621. result = isArrayLike(collection) ? Array(collection.length) : [];
  26622. baseEach(collection, function(value) {
  26623. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26624. });
  26625. return result;
  26626. });
  26627. /**
  26628. * Creates an object composed of keys generated from the results of running
  26629. * each element of `collection` thru `iteratee`. The corresponding value of
  26630. * each key is the last element responsible for generating the key. The
  26631. * iteratee is invoked with one argument: (value).
  26632. *
  26633. * @static
  26634. * @memberOf _
  26635. * @since 4.0.0
  26636. * @category Collection
  26637. * @param {Array|Object} collection The collection to iterate over.
  26638. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26639. * @returns {Object} Returns the composed aggregate object.
  26640. * @example
  26641. *
  26642. * var array = [
  26643. * { 'dir': 'left', 'code': 97 },
  26644. * { 'dir': 'right', 'code': 100 }
  26645. * ];
  26646. *
  26647. * _.keyBy(array, function(o) {
  26648. * return String.fromCharCode(o.code);
  26649. * });
  26650. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26651. *
  26652. * _.keyBy(array, 'dir');
  26653. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26654. */
  26655. var keyBy = createAggregator(function(result, value, key) {
  26656. baseAssignValue(result, key, value);
  26657. });
  26658. /**
  26659. * Creates an array of values by running each element in `collection` thru
  26660. * `iteratee`. The iteratee is invoked with three arguments:
  26661. * (value, index|key, collection).
  26662. *
  26663. * Many lodash methods are guarded to work as iteratees for methods like
  26664. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26665. *
  26666. * The guarded methods are:
  26667. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26668. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26669. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26670. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26671. *
  26672. * @static
  26673. * @memberOf _
  26674. * @since 0.1.0
  26675. * @category Collection
  26676. * @param {Array|Object} collection The collection to iterate over.
  26677. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26678. * @returns {Array} Returns the new mapped array.
  26679. * @example
  26680. *
  26681. * function square(n) {
  26682. * return n * n;
  26683. * }
  26684. *
  26685. * _.map([4, 8], square);
  26686. * // => [16, 64]
  26687. *
  26688. * _.map({ 'a': 4, 'b': 8 }, square);
  26689. * // => [16, 64] (iteration order is not guaranteed)
  26690. *
  26691. * var users = [
  26692. * { 'user': 'barney' },
  26693. * { 'user': 'fred' }
  26694. * ];
  26695. *
  26696. * // The `_.property` iteratee shorthand.
  26697. * _.map(users, 'user');
  26698. * // => ['barney', 'fred']
  26699. */
  26700. function map(collection, iteratee) {
  26701. var func = isArray(collection) ? arrayMap : baseMap;
  26702. return func(collection, getIteratee(iteratee, 3));
  26703. }
  26704. /**
  26705. * This method is like `_.sortBy` except that it allows specifying the sort
  26706. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26707. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26708. * descending or "asc" for ascending sort order of corresponding values.
  26709. *
  26710. * @static
  26711. * @memberOf _
  26712. * @since 4.0.0
  26713. * @category Collection
  26714. * @param {Array|Object} collection The collection to iterate over.
  26715. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26716. * The iteratees to sort by.
  26717. * @param {string[]} [orders] The sort orders of `iteratees`.
  26718. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26719. * @returns {Array} Returns the new sorted array.
  26720. * @example
  26721. *
  26722. * var users = [
  26723. * { 'user': 'fred', 'age': 48 },
  26724. * { 'user': 'barney', 'age': 34 },
  26725. * { 'user': 'fred', 'age': 40 },
  26726. * { 'user': 'barney', 'age': 36 }
  26727. * ];
  26728. *
  26729. * // Sort by `user` in ascending order and by `age` in descending order.
  26730. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26731. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26732. */
  26733. function orderBy(collection, iteratees, orders, guard) {
  26734. if (collection == null) {
  26735. return [];
  26736. }
  26737. if (!isArray(iteratees)) {
  26738. iteratees = iteratees == null ? [] : [iteratees];
  26739. }
  26740. orders = guard ? undefined : orders;
  26741. if (!isArray(orders)) {
  26742. orders = orders == null ? [] : [orders];
  26743. }
  26744. return baseOrderBy(collection, iteratees, orders);
  26745. }
  26746. /**
  26747. * Creates an array of elements split into two groups, the first of which
  26748. * contains elements `predicate` returns truthy for, the second of which
  26749. * contains elements `predicate` returns falsey for. The predicate is
  26750. * invoked with one argument: (value).
  26751. *
  26752. * @static
  26753. * @memberOf _
  26754. * @since 3.0.0
  26755. * @category Collection
  26756. * @param {Array|Object} collection The collection to iterate over.
  26757. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26758. * @returns {Array} Returns the array of grouped elements.
  26759. * @example
  26760. *
  26761. * var users = [
  26762. * { 'user': 'barney', 'age': 36, 'active': false },
  26763. * { 'user': 'fred', 'age': 40, 'active': true },
  26764. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26765. * ];
  26766. *
  26767. * _.partition(users, function(o) { return o.active; });
  26768. * // => objects for [['fred'], ['barney', 'pebbles']]
  26769. *
  26770. * // The `_.matches` iteratee shorthand.
  26771. * _.partition(users, { 'age': 1, 'active': false });
  26772. * // => objects for [['pebbles'], ['barney', 'fred']]
  26773. *
  26774. * // The `_.matchesProperty` iteratee shorthand.
  26775. * _.partition(users, ['active', false]);
  26776. * // => objects for [['barney', 'pebbles'], ['fred']]
  26777. *
  26778. * // The `_.property` iteratee shorthand.
  26779. * _.partition(users, 'active');
  26780. * // => objects for [['fred'], ['barney', 'pebbles']]
  26781. */
  26782. var partition = createAggregator(function(result, value, key) {
  26783. result[key ? 0 : 1].push(value);
  26784. }, function() { return [[], []]; });
  26785. /**
  26786. * Reduces `collection` to a value which is the accumulated result of running
  26787. * each element in `collection` thru `iteratee`, where each successive
  26788. * invocation is supplied the return value of the previous. If `accumulator`
  26789. * is not given, the first element of `collection` is used as the initial
  26790. * value. The iteratee is invoked with four arguments:
  26791. * (accumulator, value, index|key, collection).
  26792. *
  26793. * Many lodash methods are guarded to work as iteratees for methods like
  26794. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26795. *
  26796. * The guarded methods are:
  26797. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26798. * and `sortBy`
  26799. *
  26800. * @static
  26801. * @memberOf _
  26802. * @since 0.1.0
  26803. * @category Collection
  26804. * @param {Array|Object} collection The collection to iterate over.
  26805. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26806. * @param {*} [accumulator] The initial value.
  26807. * @returns {*} Returns the accumulated value.
  26808. * @see _.reduceRight
  26809. * @example
  26810. *
  26811. * _.reduce([1, 2], function(sum, n) {
  26812. * return sum + n;
  26813. * }, 0);
  26814. * // => 3
  26815. *
  26816. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26817. * (result[value] || (result[value] = [])).push(key);
  26818. * return result;
  26819. * }, {});
  26820. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26821. */
  26822. function reduce(collection, iteratee, accumulator) {
  26823. var func = isArray(collection) ? arrayReduce : baseReduce,
  26824. initAccum = arguments.length < 3;
  26825. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26826. }
  26827. /**
  26828. * This method is like `_.reduce` except that it iterates over elements of
  26829. * `collection` from right to left.
  26830. *
  26831. * @static
  26832. * @memberOf _
  26833. * @since 0.1.0
  26834. * @category Collection
  26835. * @param {Array|Object} collection The collection to iterate over.
  26836. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26837. * @param {*} [accumulator] The initial value.
  26838. * @returns {*} Returns the accumulated value.
  26839. * @see _.reduce
  26840. * @example
  26841. *
  26842. * var array = [[0, 1], [2, 3], [4, 5]];
  26843. *
  26844. * _.reduceRight(array, function(flattened, other) {
  26845. * return flattened.concat(other);
  26846. * }, []);
  26847. * // => [4, 5, 2, 3, 0, 1]
  26848. */
  26849. function reduceRight(collection, iteratee, accumulator) {
  26850. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26851. initAccum = arguments.length < 3;
  26852. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26853. }
  26854. /**
  26855. * The opposite of `_.filter`; this method returns the elements of `collection`
  26856. * that `predicate` does **not** return truthy for.
  26857. *
  26858. * @static
  26859. * @memberOf _
  26860. * @since 0.1.0
  26861. * @category Collection
  26862. * @param {Array|Object} collection The collection to iterate over.
  26863. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26864. * @returns {Array} Returns the new filtered array.
  26865. * @see _.filter
  26866. * @example
  26867. *
  26868. * var users = [
  26869. * { 'user': 'barney', 'age': 36, 'active': false },
  26870. * { 'user': 'fred', 'age': 40, 'active': true }
  26871. * ];
  26872. *
  26873. * _.reject(users, function(o) { return !o.active; });
  26874. * // => objects for ['fred']
  26875. *
  26876. * // The `_.matches` iteratee shorthand.
  26877. * _.reject(users, { 'age': 40, 'active': true });
  26878. * // => objects for ['barney']
  26879. *
  26880. * // The `_.matchesProperty` iteratee shorthand.
  26881. * _.reject(users, ['active', false]);
  26882. * // => objects for ['fred']
  26883. *
  26884. * // The `_.property` iteratee shorthand.
  26885. * _.reject(users, 'active');
  26886. * // => objects for ['barney']
  26887. */
  26888. function reject(collection, predicate) {
  26889. var func = isArray(collection) ? arrayFilter : baseFilter;
  26890. return func(collection, negate(getIteratee(predicate, 3)));
  26891. }
  26892. /**
  26893. * Gets a random element from `collection`.
  26894. *
  26895. * @static
  26896. * @memberOf _
  26897. * @since 2.0.0
  26898. * @category Collection
  26899. * @param {Array|Object} collection The collection to sample.
  26900. * @returns {*} Returns the random element.
  26901. * @example
  26902. *
  26903. * _.sample([1, 2, 3, 4]);
  26904. * // => 2
  26905. */
  26906. function sample(collection) {
  26907. var func = isArray(collection) ? arraySample : baseSample;
  26908. return func(collection);
  26909. }
  26910. /**
  26911. * Gets `n` random elements at unique keys from `collection` up to the
  26912. * size of `collection`.
  26913. *
  26914. * @static
  26915. * @memberOf _
  26916. * @since 4.0.0
  26917. * @category Collection
  26918. * @param {Array|Object} collection The collection to sample.
  26919. * @param {number} [n=1] The number of elements to sample.
  26920. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26921. * @returns {Array} Returns the random elements.
  26922. * @example
  26923. *
  26924. * _.sampleSize([1, 2, 3], 2);
  26925. * // => [3, 1]
  26926. *
  26927. * _.sampleSize([1, 2, 3], 4);
  26928. * // => [2, 3, 1]
  26929. */
  26930. function sampleSize(collection, n, guard) {
  26931. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26932. n = 1;
  26933. } else {
  26934. n = toInteger(n);
  26935. }
  26936. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26937. return func(collection, n);
  26938. }
  26939. /**
  26940. * Creates an array of shuffled values, using a version of the
  26941. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26942. *
  26943. * @static
  26944. * @memberOf _
  26945. * @since 0.1.0
  26946. * @category Collection
  26947. * @param {Array|Object} collection The collection to shuffle.
  26948. * @returns {Array} Returns the new shuffled array.
  26949. * @example
  26950. *
  26951. * _.shuffle([1, 2, 3, 4]);
  26952. * // => [4, 1, 3, 2]
  26953. */
  26954. function shuffle(collection) {
  26955. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26956. return func(collection);
  26957. }
  26958. /**
  26959. * Gets the size of `collection` by returning its length for array-like
  26960. * values or the number of own enumerable string keyed properties for objects.
  26961. *
  26962. * @static
  26963. * @memberOf _
  26964. * @since 0.1.0
  26965. * @category Collection
  26966. * @param {Array|Object|string} collection The collection to inspect.
  26967. * @returns {number} Returns the collection size.
  26968. * @example
  26969. *
  26970. * _.size([1, 2, 3]);
  26971. * // => 3
  26972. *
  26973. * _.size({ 'a': 1, 'b': 2 });
  26974. * // => 2
  26975. *
  26976. * _.size('pebbles');
  26977. * // => 7
  26978. */
  26979. function size(collection) {
  26980. if (collection == null) {
  26981. return 0;
  26982. }
  26983. if (isArrayLike(collection)) {
  26984. return isString(collection) ? stringSize(collection) : collection.length;
  26985. }
  26986. var tag = getTag(collection);
  26987. if (tag == mapTag || tag == setTag) {
  26988. return collection.size;
  26989. }
  26990. return baseKeys(collection).length;
  26991. }
  26992. /**
  26993. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26994. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26995. * invoked with three arguments: (value, index|key, collection).
  26996. *
  26997. * @static
  26998. * @memberOf _
  26999. * @since 0.1.0
  27000. * @category Collection
  27001. * @param {Array|Object} collection The collection to iterate over.
  27002. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27003. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27004. * @returns {boolean} Returns `true` if any element passes the predicate check,
  27005. * else `false`.
  27006. * @example
  27007. *
  27008. * _.some([null, 0, 'yes', false], Boolean);
  27009. * // => true
  27010. *
  27011. * var users = [
  27012. * { 'user': 'barney', 'active': true },
  27013. * { 'user': 'fred', 'active': false }
  27014. * ];
  27015. *
  27016. * // The `_.matches` iteratee shorthand.
  27017. * _.some(users, { 'user': 'barney', 'active': false });
  27018. * // => false
  27019. *
  27020. * // The `_.matchesProperty` iteratee shorthand.
  27021. * _.some(users, ['active', false]);
  27022. * // => true
  27023. *
  27024. * // The `_.property` iteratee shorthand.
  27025. * _.some(users, 'active');
  27026. * // => true
  27027. */
  27028. function some(collection, predicate, guard) {
  27029. var func = isArray(collection) ? arraySome : baseSome;
  27030. if (guard && isIterateeCall(collection, predicate, guard)) {
  27031. predicate = undefined;
  27032. }
  27033. return func(collection, getIteratee(predicate, 3));
  27034. }
  27035. /**
  27036. * Creates an array of elements, sorted in ascending order by the results of
  27037. * running each element in a collection thru each iteratee. This method
  27038. * performs a stable sort, that is, it preserves the original sort order of
  27039. * equal elements. The iteratees are invoked with one argument: (value).
  27040. *
  27041. * @static
  27042. * @memberOf _
  27043. * @since 0.1.0
  27044. * @category Collection
  27045. * @param {Array|Object} collection The collection to iterate over.
  27046. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  27047. * The iteratees to sort by.
  27048. * @returns {Array} Returns the new sorted array.
  27049. * @example
  27050. *
  27051. * var users = [
  27052. * { 'user': 'fred', 'age': 48 },
  27053. * { 'user': 'barney', 'age': 36 },
  27054. * { 'user': 'fred', 'age': 40 },
  27055. * { 'user': 'barney', 'age': 34 }
  27056. * ];
  27057. *
  27058. * _.sortBy(users, [function(o) { return o.user; }]);
  27059. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  27060. *
  27061. * _.sortBy(users, ['user', 'age']);
  27062. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  27063. */
  27064. var sortBy = baseRest(function(collection, iteratees) {
  27065. if (collection == null) {
  27066. return [];
  27067. }
  27068. var length = iteratees.length;
  27069. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  27070. iteratees = [];
  27071. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  27072. iteratees = [iteratees[0]];
  27073. }
  27074. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  27075. });
  27076. /*------------------------------------------------------------------------*/
  27077. /**
  27078. * Gets the timestamp of the number of milliseconds that have elapsed since
  27079. * the Unix epoch (1 January 1970 00:00:00 UTC).
  27080. *
  27081. * @static
  27082. * @memberOf _
  27083. * @since 2.4.0
  27084. * @category Date
  27085. * @returns {number} Returns the timestamp.
  27086. * @example
  27087. *
  27088. * _.defer(function(stamp) {
  27089. * console.log(_.now() - stamp);
  27090. * }, _.now());
  27091. * // => Logs the number of milliseconds it took for the deferred invocation.
  27092. */
  27093. var now = ctxNow || function() {
  27094. return root.Date.now();
  27095. };
  27096. /*------------------------------------------------------------------------*/
  27097. /**
  27098. * The opposite of `_.before`; this method creates a function that invokes
  27099. * `func` once it's called `n` or more times.
  27100. *
  27101. * @static
  27102. * @memberOf _
  27103. * @since 0.1.0
  27104. * @category Function
  27105. * @param {number} n The number of calls before `func` is invoked.
  27106. * @param {Function} func The function to restrict.
  27107. * @returns {Function} Returns the new restricted function.
  27108. * @example
  27109. *
  27110. * var saves = ['profile', 'settings'];
  27111. *
  27112. * var done = _.after(saves.length, function() {
  27113. * console.log('done saving!');
  27114. * });
  27115. *
  27116. * _.forEach(saves, function(type) {
  27117. * asyncSave({ 'type': type, 'complete': done });
  27118. * });
  27119. * // => Logs 'done saving!' after the two async saves have completed.
  27120. */
  27121. function after(n, func) {
  27122. if (typeof func != 'function') {
  27123. throw new TypeError(FUNC_ERROR_TEXT);
  27124. }
  27125. n = toInteger(n);
  27126. return function() {
  27127. if (--n < 1) {
  27128. return func.apply(this, arguments);
  27129. }
  27130. };
  27131. }
  27132. /**
  27133. * Creates a function that invokes `func`, with up to `n` arguments,
  27134. * ignoring any additional arguments.
  27135. *
  27136. * @static
  27137. * @memberOf _
  27138. * @since 3.0.0
  27139. * @category Function
  27140. * @param {Function} func The function to cap arguments for.
  27141. * @param {number} [n=func.length] The arity cap.
  27142. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27143. * @returns {Function} Returns the new capped function.
  27144. * @example
  27145. *
  27146. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27147. * // => [6, 8, 10]
  27148. */
  27149. function ary(func, n, guard) {
  27150. n = guard ? undefined : n;
  27151. n = (func && n == null) ? func.length : n;
  27152. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27153. }
  27154. /**
  27155. * Creates a function that invokes `func`, with the `this` binding and arguments
  27156. * of the created function, while it's called less than `n` times. Subsequent
  27157. * calls to the created function return the result of the last `func` invocation.
  27158. *
  27159. * @static
  27160. * @memberOf _
  27161. * @since 3.0.0
  27162. * @category Function
  27163. * @param {number} n The number of calls at which `func` is no longer invoked.
  27164. * @param {Function} func The function to restrict.
  27165. * @returns {Function} Returns the new restricted function.
  27166. * @example
  27167. *
  27168. * jQuery(element).on('click', _.before(5, addContactToList));
  27169. * // => Allows adding up to 4 contacts to the list.
  27170. */
  27171. function before(n, func) {
  27172. var result;
  27173. if (typeof func != 'function') {
  27174. throw new TypeError(FUNC_ERROR_TEXT);
  27175. }
  27176. n = toInteger(n);
  27177. return function() {
  27178. if (--n > 0) {
  27179. result = func.apply(this, arguments);
  27180. }
  27181. if (n <= 1) {
  27182. func = undefined;
  27183. }
  27184. return result;
  27185. };
  27186. }
  27187. /**
  27188. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27189. * and `partials` prepended to the arguments it receives.
  27190. *
  27191. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27192. * may be used as a placeholder for partially applied arguments.
  27193. *
  27194. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27195. * property of bound functions.
  27196. *
  27197. * @static
  27198. * @memberOf _
  27199. * @since 0.1.0
  27200. * @category Function
  27201. * @param {Function} func The function to bind.
  27202. * @param {*} thisArg The `this` binding of `func`.
  27203. * @param {...*} [partials] The arguments to be partially applied.
  27204. * @returns {Function} Returns the new bound function.
  27205. * @example
  27206. *
  27207. * function greet(greeting, punctuation) {
  27208. * return greeting + ' ' + this.user + punctuation;
  27209. * }
  27210. *
  27211. * var object = { 'user': 'fred' };
  27212. *
  27213. * var bound = _.bind(greet, object, 'hi');
  27214. * bound('!');
  27215. * // => 'hi fred!'
  27216. *
  27217. * // Bound with placeholders.
  27218. * var bound = _.bind(greet, object, _, '!');
  27219. * bound('hi');
  27220. * // => 'hi fred!'
  27221. */
  27222. var bind = baseRest(function(func, thisArg, partials) {
  27223. var bitmask = WRAP_BIND_FLAG;
  27224. if (partials.length) {
  27225. var holders = replaceHolders(partials, getHolder(bind));
  27226. bitmask |= WRAP_PARTIAL_FLAG;
  27227. }
  27228. return createWrap(func, bitmask, thisArg, partials, holders);
  27229. });
  27230. /**
  27231. * Creates a function that invokes the method at `object[key]` with `partials`
  27232. * prepended to the arguments it receives.
  27233. *
  27234. * This method differs from `_.bind` by allowing bound functions to reference
  27235. * methods that may be redefined or don't yet exist. See
  27236. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27237. * for more details.
  27238. *
  27239. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27240. * builds, may be used as a placeholder for partially applied arguments.
  27241. *
  27242. * @static
  27243. * @memberOf _
  27244. * @since 0.10.0
  27245. * @category Function
  27246. * @param {Object} object The object to invoke the method on.
  27247. * @param {string} key The key of the method.
  27248. * @param {...*} [partials] The arguments to be partially applied.
  27249. * @returns {Function} Returns the new bound function.
  27250. * @example
  27251. *
  27252. * var object = {
  27253. * 'user': 'fred',
  27254. * 'greet': function(greeting, punctuation) {
  27255. * return greeting + ' ' + this.user + punctuation;
  27256. * }
  27257. * };
  27258. *
  27259. * var bound = _.bindKey(object, 'greet', 'hi');
  27260. * bound('!');
  27261. * // => 'hi fred!'
  27262. *
  27263. * object.greet = function(greeting, punctuation) {
  27264. * return greeting + 'ya ' + this.user + punctuation;
  27265. * };
  27266. *
  27267. * bound('!');
  27268. * // => 'hiya fred!'
  27269. *
  27270. * // Bound with placeholders.
  27271. * var bound = _.bindKey(object, 'greet', _, '!');
  27272. * bound('hi');
  27273. * // => 'hiya fred!'
  27274. */
  27275. var bindKey = baseRest(function(object, key, partials) {
  27276. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27277. if (partials.length) {
  27278. var holders = replaceHolders(partials, getHolder(bindKey));
  27279. bitmask |= WRAP_PARTIAL_FLAG;
  27280. }
  27281. return createWrap(key, bitmask, object, partials, holders);
  27282. });
  27283. /**
  27284. * Creates a function that accepts arguments of `func` and either invokes
  27285. * `func` returning its result, if at least `arity` number of arguments have
  27286. * been provided, or returns a function that accepts the remaining `func`
  27287. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27288. * is not sufficient.
  27289. *
  27290. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27291. * may be used as a placeholder for provided arguments.
  27292. *
  27293. * **Note:** This method doesn't set the "length" property of curried functions.
  27294. *
  27295. * @static
  27296. * @memberOf _
  27297. * @since 2.0.0
  27298. * @category Function
  27299. * @param {Function} func The function to curry.
  27300. * @param {number} [arity=func.length] The arity of `func`.
  27301. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27302. * @returns {Function} Returns the new curried function.
  27303. * @example
  27304. *
  27305. * var abc = function(a, b, c) {
  27306. * return [a, b, c];
  27307. * };
  27308. *
  27309. * var curried = _.curry(abc);
  27310. *
  27311. * curried(1)(2)(3);
  27312. * // => [1, 2, 3]
  27313. *
  27314. * curried(1, 2)(3);
  27315. * // => [1, 2, 3]
  27316. *
  27317. * curried(1, 2, 3);
  27318. * // => [1, 2, 3]
  27319. *
  27320. * // Curried with placeholders.
  27321. * curried(1)(_, 3)(2);
  27322. * // => [1, 2, 3]
  27323. */
  27324. function curry(func, arity, guard) {
  27325. arity = guard ? undefined : arity;
  27326. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27327. result.placeholder = curry.placeholder;
  27328. return result;
  27329. }
  27330. /**
  27331. * This method is like `_.curry` except that arguments are applied to `func`
  27332. * in the manner of `_.partialRight` instead of `_.partial`.
  27333. *
  27334. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27335. * builds, may be used as a placeholder for provided arguments.
  27336. *
  27337. * **Note:** This method doesn't set the "length" property of curried functions.
  27338. *
  27339. * @static
  27340. * @memberOf _
  27341. * @since 3.0.0
  27342. * @category Function
  27343. * @param {Function} func The function to curry.
  27344. * @param {number} [arity=func.length] The arity of `func`.
  27345. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27346. * @returns {Function} Returns the new curried function.
  27347. * @example
  27348. *
  27349. * var abc = function(a, b, c) {
  27350. * return [a, b, c];
  27351. * };
  27352. *
  27353. * var curried = _.curryRight(abc);
  27354. *
  27355. * curried(3)(2)(1);
  27356. * // => [1, 2, 3]
  27357. *
  27358. * curried(2, 3)(1);
  27359. * // => [1, 2, 3]
  27360. *
  27361. * curried(1, 2, 3);
  27362. * // => [1, 2, 3]
  27363. *
  27364. * // Curried with placeholders.
  27365. * curried(3)(1, _)(2);
  27366. * // => [1, 2, 3]
  27367. */
  27368. function curryRight(func, arity, guard) {
  27369. arity = guard ? undefined : arity;
  27370. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27371. result.placeholder = curryRight.placeholder;
  27372. return result;
  27373. }
  27374. /**
  27375. * Creates a debounced function that delays invoking `func` until after `wait`
  27376. * milliseconds have elapsed since the last time the debounced function was
  27377. * invoked. The debounced function comes with a `cancel` method to cancel
  27378. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27379. * Provide `options` to indicate whether `func` should be invoked on the
  27380. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27381. * with the last arguments provided to the debounced function. Subsequent
  27382. * calls to the debounced function return the result of the last `func`
  27383. * invocation.
  27384. *
  27385. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27386. * invoked on the trailing edge of the timeout only if the debounced function
  27387. * is invoked more than once during the `wait` timeout.
  27388. *
  27389. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27390. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27391. *
  27392. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27393. * for details over the differences between `_.debounce` and `_.throttle`.
  27394. *
  27395. * @static
  27396. * @memberOf _
  27397. * @since 0.1.0
  27398. * @category Function
  27399. * @param {Function} func The function to debounce.
  27400. * @param {number} [wait=0] The number of milliseconds to delay.
  27401. * @param {Object} [options={}] The options object.
  27402. * @param {boolean} [options.leading=false]
  27403. * Specify invoking on the leading edge of the timeout.
  27404. * @param {number} [options.maxWait]
  27405. * The maximum time `func` is allowed to be delayed before it's invoked.
  27406. * @param {boolean} [options.trailing=true]
  27407. * Specify invoking on the trailing edge of the timeout.
  27408. * @returns {Function} Returns the new debounced function.
  27409. * @example
  27410. *
  27411. * // Avoid costly calculations while the window size is in flux.
  27412. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27413. *
  27414. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27415. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27416. * 'leading': true,
  27417. * 'trailing': false
  27418. * }));
  27419. *
  27420. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27421. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27422. * var source = new EventSource('/stream');
  27423. * jQuery(source).on('message', debounced);
  27424. *
  27425. * // Cancel the trailing debounced invocation.
  27426. * jQuery(window).on('popstate', debounced.cancel);
  27427. */
  27428. function debounce(func, wait, options) {
  27429. var lastArgs,
  27430. lastThis,
  27431. maxWait,
  27432. result,
  27433. timerId,
  27434. lastCallTime,
  27435. lastInvokeTime = 0,
  27436. leading = false,
  27437. maxing = false,
  27438. trailing = true;
  27439. if (typeof func != 'function') {
  27440. throw new TypeError(FUNC_ERROR_TEXT);
  27441. }
  27442. wait = toNumber(wait) || 0;
  27443. if (isObject(options)) {
  27444. leading = !!options.leading;
  27445. maxing = 'maxWait' in options;
  27446. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27447. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27448. }
  27449. function invokeFunc(time) {
  27450. var args = lastArgs,
  27451. thisArg = lastThis;
  27452. lastArgs = lastThis = undefined;
  27453. lastInvokeTime = time;
  27454. result = func.apply(thisArg, args);
  27455. return result;
  27456. }
  27457. function leadingEdge(time) {
  27458. // Reset any `maxWait` timer.
  27459. lastInvokeTime = time;
  27460. // Start the timer for the trailing edge.
  27461. timerId = setTimeout(timerExpired, wait);
  27462. // Invoke the leading edge.
  27463. return leading ? invokeFunc(time) : result;
  27464. }
  27465. function remainingWait(time) {
  27466. var timeSinceLastCall = time - lastCallTime,
  27467. timeSinceLastInvoke = time - lastInvokeTime,
  27468. timeWaiting = wait - timeSinceLastCall;
  27469. return maxing
  27470. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27471. : timeWaiting;
  27472. }
  27473. function shouldInvoke(time) {
  27474. var timeSinceLastCall = time - lastCallTime,
  27475. timeSinceLastInvoke = time - lastInvokeTime;
  27476. // Either this is the first call, activity has stopped and we're at the
  27477. // trailing edge, the system time has gone backwards and we're treating
  27478. // it as the trailing edge, or we've hit the `maxWait` limit.
  27479. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27480. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27481. }
  27482. function timerExpired() {
  27483. var time = now();
  27484. if (shouldInvoke(time)) {
  27485. return trailingEdge(time);
  27486. }
  27487. // Restart the timer.
  27488. timerId = setTimeout(timerExpired, remainingWait(time));
  27489. }
  27490. function trailingEdge(time) {
  27491. timerId = undefined;
  27492. // Only invoke if we have `lastArgs` which means `func` has been
  27493. // debounced at least once.
  27494. if (trailing && lastArgs) {
  27495. return invokeFunc(time);
  27496. }
  27497. lastArgs = lastThis = undefined;
  27498. return result;
  27499. }
  27500. function cancel() {
  27501. if (timerId !== undefined) {
  27502. clearTimeout(timerId);
  27503. }
  27504. lastInvokeTime = 0;
  27505. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27506. }
  27507. function flush() {
  27508. return timerId === undefined ? result : trailingEdge(now());
  27509. }
  27510. function debounced() {
  27511. var time = now(),
  27512. isInvoking = shouldInvoke(time);
  27513. lastArgs = arguments;
  27514. lastThis = this;
  27515. lastCallTime = time;
  27516. if (isInvoking) {
  27517. if (timerId === undefined) {
  27518. return leadingEdge(lastCallTime);
  27519. }
  27520. if (maxing) {
  27521. // Handle invocations in a tight loop.
  27522. clearTimeout(timerId);
  27523. timerId = setTimeout(timerExpired, wait);
  27524. return invokeFunc(lastCallTime);
  27525. }
  27526. }
  27527. if (timerId === undefined) {
  27528. timerId = setTimeout(timerExpired, wait);
  27529. }
  27530. return result;
  27531. }
  27532. debounced.cancel = cancel;
  27533. debounced.flush = flush;
  27534. return debounced;
  27535. }
  27536. /**
  27537. * Defers invoking the `func` until the current call stack has cleared. Any
  27538. * additional arguments are provided to `func` when it's invoked.
  27539. *
  27540. * @static
  27541. * @memberOf _
  27542. * @since 0.1.0
  27543. * @category Function
  27544. * @param {Function} func The function to defer.
  27545. * @param {...*} [args] The arguments to invoke `func` with.
  27546. * @returns {number} Returns the timer id.
  27547. * @example
  27548. *
  27549. * _.defer(function(text) {
  27550. * console.log(text);
  27551. * }, 'deferred');
  27552. * // => Logs 'deferred' after one millisecond.
  27553. */
  27554. var defer = baseRest(function(func, args) {
  27555. return baseDelay(func, 1, args);
  27556. });
  27557. /**
  27558. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27559. * provided to `func` when it's invoked.
  27560. *
  27561. * @static
  27562. * @memberOf _
  27563. * @since 0.1.0
  27564. * @category Function
  27565. * @param {Function} func The function to delay.
  27566. * @param {number} wait The number of milliseconds to delay invocation.
  27567. * @param {...*} [args] The arguments to invoke `func` with.
  27568. * @returns {number} Returns the timer id.
  27569. * @example
  27570. *
  27571. * _.delay(function(text) {
  27572. * console.log(text);
  27573. * }, 1000, 'later');
  27574. * // => Logs 'later' after one second.
  27575. */
  27576. var delay = baseRest(function(func, wait, args) {
  27577. return baseDelay(func, toNumber(wait) || 0, args);
  27578. });
  27579. /**
  27580. * Creates a function that invokes `func` with arguments reversed.
  27581. *
  27582. * @static
  27583. * @memberOf _
  27584. * @since 4.0.0
  27585. * @category Function
  27586. * @param {Function} func The function to flip arguments for.
  27587. * @returns {Function} Returns the new flipped function.
  27588. * @example
  27589. *
  27590. * var flipped = _.flip(function() {
  27591. * return _.toArray(arguments);
  27592. * });
  27593. *
  27594. * flipped('a', 'b', 'c', 'd');
  27595. * // => ['d', 'c', 'b', 'a']
  27596. */
  27597. function flip(func) {
  27598. return createWrap(func, WRAP_FLIP_FLAG);
  27599. }
  27600. /**
  27601. * Creates a function that memoizes the result of `func`. If `resolver` is
  27602. * provided, it determines the cache key for storing the result based on the
  27603. * arguments provided to the memoized function. By default, the first argument
  27604. * provided to the memoized function is used as the map cache key. The `func`
  27605. * is invoked with the `this` binding of the memoized function.
  27606. *
  27607. * **Note:** The cache is exposed as the `cache` property on the memoized
  27608. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27609. * constructor with one whose instances implement the
  27610. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27611. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27612. *
  27613. * @static
  27614. * @memberOf _
  27615. * @since 0.1.0
  27616. * @category Function
  27617. * @param {Function} func The function to have its output memoized.
  27618. * @param {Function} [resolver] The function to resolve the cache key.
  27619. * @returns {Function} Returns the new memoized function.
  27620. * @example
  27621. *
  27622. * var object = { 'a': 1, 'b': 2 };
  27623. * var other = { 'c': 3, 'd': 4 };
  27624. *
  27625. * var values = _.memoize(_.values);
  27626. * values(object);
  27627. * // => [1, 2]
  27628. *
  27629. * values(other);
  27630. * // => [3, 4]
  27631. *
  27632. * object.a = 2;
  27633. * values(object);
  27634. * // => [1, 2]
  27635. *
  27636. * // Modify the result cache.
  27637. * values.cache.set(object, ['a', 'b']);
  27638. * values(object);
  27639. * // => ['a', 'b']
  27640. *
  27641. * // Replace `_.memoize.Cache`.
  27642. * _.memoize.Cache = WeakMap;
  27643. */
  27644. function memoize(func, resolver) {
  27645. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27646. throw new TypeError(FUNC_ERROR_TEXT);
  27647. }
  27648. var memoized = function() {
  27649. var args = arguments,
  27650. key = resolver ? resolver.apply(this, args) : args[0],
  27651. cache = memoized.cache;
  27652. if (cache.has(key)) {
  27653. return cache.get(key);
  27654. }
  27655. var result = func.apply(this, args);
  27656. memoized.cache = cache.set(key, result) || cache;
  27657. return result;
  27658. };
  27659. memoized.cache = new (memoize.Cache || MapCache);
  27660. return memoized;
  27661. }
  27662. // Expose `MapCache`.
  27663. memoize.Cache = MapCache;
  27664. /**
  27665. * Creates a function that negates the result of the predicate `func`. The
  27666. * `func` predicate is invoked with the `this` binding and arguments of the
  27667. * created function.
  27668. *
  27669. * @static
  27670. * @memberOf _
  27671. * @since 3.0.0
  27672. * @category Function
  27673. * @param {Function} predicate The predicate to negate.
  27674. * @returns {Function} Returns the new negated function.
  27675. * @example
  27676. *
  27677. * function isEven(n) {
  27678. * return n % 2 == 0;
  27679. * }
  27680. *
  27681. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27682. * // => [1, 3, 5]
  27683. */
  27684. function negate(predicate) {
  27685. if (typeof predicate != 'function') {
  27686. throw new TypeError(FUNC_ERROR_TEXT);
  27687. }
  27688. return function() {
  27689. var args = arguments;
  27690. switch (args.length) {
  27691. case 0: return !predicate.call(this);
  27692. case 1: return !predicate.call(this, args[0]);
  27693. case 2: return !predicate.call(this, args[0], args[1]);
  27694. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27695. }
  27696. return !predicate.apply(this, args);
  27697. };
  27698. }
  27699. /**
  27700. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27701. * to the function return the value of the first invocation. The `func` is
  27702. * invoked with the `this` binding and arguments of the created function.
  27703. *
  27704. * @static
  27705. * @memberOf _
  27706. * @since 0.1.0
  27707. * @category Function
  27708. * @param {Function} func The function to restrict.
  27709. * @returns {Function} Returns the new restricted function.
  27710. * @example
  27711. *
  27712. * var initialize = _.once(createApplication);
  27713. * initialize();
  27714. * initialize();
  27715. * // => `createApplication` is invoked once
  27716. */
  27717. function once(func) {
  27718. return before(2, func);
  27719. }
  27720. /**
  27721. * Creates a function that invokes `func` with its arguments transformed.
  27722. *
  27723. * @static
  27724. * @since 4.0.0
  27725. * @memberOf _
  27726. * @category Function
  27727. * @param {Function} func The function to wrap.
  27728. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27729. * The argument transforms.
  27730. * @returns {Function} Returns the new function.
  27731. * @example
  27732. *
  27733. * function doubled(n) {
  27734. * return n * 2;
  27735. * }
  27736. *
  27737. * function square(n) {
  27738. * return n * n;
  27739. * }
  27740. *
  27741. * var func = _.overArgs(function(x, y) {
  27742. * return [x, y];
  27743. * }, [square, doubled]);
  27744. *
  27745. * func(9, 3);
  27746. * // => [81, 6]
  27747. *
  27748. * func(10, 5);
  27749. * // => [100, 10]
  27750. */
  27751. var overArgs = castRest(function(func, transforms) {
  27752. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27753. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27754. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27755. var funcsLength = transforms.length;
  27756. return baseRest(function(args) {
  27757. var index = -1,
  27758. length = nativeMin(args.length, funcsLength);
  27759. while (++index < length) {
  27760. args[index] = transforms[index].call(this, args[index]);
  27761. }
  27762. return apply(func, this, args);
  27763. });
  27764. });
  27765. /**
  27766. * Creates a function that invokes `func` with `partials` prepended to the
  27767. * arguments it receives. This method is like `_.bind` except it does **not**
  27768. * alter the `this` binding.
  27769. *
  27770. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27771. * builds, may be used as a placeholder for partially applied arguments.
  27772. *
  27773. * **Note:** This method doesn't set the "length" property of partially
  27774. * applied functions.
  27775. *
  27776. * @static
  27777. * @memberOf _
  27778. * @since 0.2.0
  27779. * @category Function
  27780. * @param {Function} func The function to partially apply arguments to.
  27781. * @param {...*} [partials] The arguments to be partially applied.
  27782. * @returns {Function} Returns the new partially applied function.
  27783. * @example
  27784. *
  27785. * function greet(greeting, name) {
  27786. * return greeting + ' ' + name;
  27787. * }
  27788. *
  27789. * var sayHelloTo = _.partial(greet, 'hello');
  27790. * sayHelloTo('fred');
  27791. * // => 'hello fred'
  27792. *
  27793. * // Partially applied with placeholders.
  27794. * var greetFred = _.partial(greet, _, 'fred');
  27795. * greetFred('hi');
  27796. * // => 'hi fred'
  27797. */
  27798. var partial = baseRest(function(func, partials) {
  27799. var holders = replaceHolders(partials, getHolder(partial));
  27800. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27801. });
  27802. /**
  27803. * This method is like `_.partial` except that partially applied arguments
  27804. * are appended to the arguments it receives.
  27805. *
  27806. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27807. * builds, may be used as a placeholder for partially applied arguments.
  27808. *
  27809. * **Note:** This method doesn't set the "length" property of partially
  27810. * applied functions.
  27811. *
  27812. * @static
  27813. * @memberOf _
  27814. * @since 1.0.0
  27815. * @category Function
  27816. * @param {Function} func The function to partially apply arguments to.
  27817. * @param {...*} [partials] The arguments to be partially applied.
  27818. * @returns {Function} Returns the new partially applied function.
  27819. * @example
  27820. *
  27821. * function greet(greeting, name) {
  27822. * return greeting + ' ' + name;
  27823. * }
  27824. *
  27825. * var greetFred = _.partialRight(greet, 'fred');
  27826. * greetFred('hi');
  27827. * // => 'hi fred'
  27828. *
  27829. * // Partially applied with placeholders.
  27830. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27831. * sayHelloTo('fred');
  27832. * // => 'hello fred'
  27833. */
  27834. var partialRight = baseRest(function(func, partials) {
  27835. var holders = replaceHolders(partials, getHolder(partialRight));
  27836. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27837. });
  27838. /**
  27839. * Creates a function that invokes `func` with arguments arranged according
  27840. * to the specified `indexes` where the argument value at the first index is
  27841. * provided as the first argument, the argument value at the second index is
  27842. * provided as the second argument, and so on.
  27843. *
  27844. * @static
  27845. * @memberOf _
  27846. * @since 3.0.0
  27847. * @category Function
  27848. * @param {Function} func The function to rearrange arguments for.
  27849. * @param {...(number|number[])} indexes The arranged argument indexes.
  27850. * @returns {Function} Returns the new function.
  27851. * @example
  27852. *
  27853. * var rearged = _.rearg(function(a, b, c) {
  27854. * return [a, b, c];
  27855. * }, [2, 0, 1]);
  27856. *
  27857. * rearged('b', 'c', 'a')
  27858. * // => ['a', 'b', 'c']
  27859. */
  27860. var rearg = flatRest(function(func, indexes) {
  27861. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27862. });
  27863. /**
  27864. * Creates a function that invokes `func` with the `this` binding of the
  27865. * created function and arguments from `start` and beyond provided as
  27866. * an array.
  27867. *
  27868. * **Note:** This method is based on the
  27869. * [rest parameter](https://mdn.io/rest_parameters).
  27870. *
  27871. * @static
  27872. * @memberOf _
  27873. * @since 4.0.0
  27874. * @category Function
  27875. * @param {Function} func The function to apply a rest parameter to.
  27876. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27877. * @returns {Function} Returns the new function.
  27878. * @example
  27879. *
  27880. * var say = _.rest(function(what, names) {
  27881. * return what + ' ' + _.initial(names).join(', ') +
  27882. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27883. * });
  27884. *
  27885. * say('hello', 'fred', 'barney', 'pebbles');
  27886. * // => 'hello fred, barney, & pebbles'
  27887. */
  27888. function rest(func, start) {
  27889. if (typeof func != 'function') {
  27890. throw new TypeError(FUNC_ERROR_TEXT);
  27891. }
  27892. start = start === undefined ? start : toInteger(start);
  27893. return baseRest(func, start);
  27894. }
  27895. /**
  27896. * Creates a function that invokes `func` with the `this` binding of the
  27897. * create function and an array of arguments much like
  27898. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27899. *
  27900. * **Note:** This method is based on the
  27901. * [spread operator](https://mdn.io/spread_operator).
  27902. *
  27903. * @static
  27904. * @memberOf _
  27905. * @since 3.2.0
  27906. * @category Function
  27907. * @param {Function} func The function to spread arguments over.
  27908. * @param {number} [start=0] The start position of the spread.
  27909. * @returns {Function} Returns the new function.
  27910. * @example
  27911. *
  27912. * var say = _.spread(function(who, what) {
  27913. * return who + ' says ' + what;
  27914. * });
  27915. *
  27916. * say(['fred', 'hello']);
  27917. * // => 'fred says hello'
  27918. *
  27919. * var numbers = Promise.all([
  27920. * Promise.resolve(40),
  27921. * Promise.resolve(36)
  27922. * ]);
  27923. *
  27924. * numbers.then(_.spread(function(x, y) {
  27925. * return x + y;
  27926. * }));
  27927. * // => a Promise of 76
  27928. */
  27929. function spread(func, start) {
  27930. if (typeof func != 'function') {
  27931. throw new TypeError(FUNC_ERROR_TEXT);
  27932. }
  27933. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27934. return baseRest(function(args) {
  27935. var array = args[start],
  27936. otherArgs = castSlice(args, 0, start);
  27937. if (array) {
  27938. arrayPush(otherArgs, array);
  27939. }
  27940. return apply(func, this, otherArgs);
  27941. });
  27942. }
  27943. /**
  27944. * Creates a throttled function that only invokes `func` at most once per
  27945. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27946. * method to cancel delayed `func` invocations and a `flush` method to
  27947. * immediately invoke them. Provide `options` to indicate whether `func`
  27948. * should be invoked on the leading and/or trailing edge of the `wait`
  27949. * timeout. The `func` is invoked with the last arguments provided to the
  27950. * throttled function. Subsequent calls to the throttled function return the
  27951. * result of the last `func` invocation.
  27952. *
  27953. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27954. * invoked on the trailing edge of the timeout only if the throttled function
  27955. * is invoked more than once during the `wait` timeout.
  27956. *
  27957. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27958. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27959. *
  27960. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27961. * for details over the differences between `_.throttle` and `_.debounce`.
  27962. *
  27963. * @static
  27964. * @memberOf _
  27965. * @since 0.1.0
  27966. * @category Function
  27967. * @param {Function} func The function to throttle.
  27968. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27969. * @param {Object} [options={}] The options object.
  27970. * @param {boolean} [options.leading=true]
  27971. * Specify invoking on the leading edge of the timeout.
  27972. * @param {boolean} [options.trailing=true]
  27973. * Specify invoking on the trailing edge of the timeout.
  27974. * @returns {Function} Returns the new throttled function.
  27975. * @example
  27976. *
  27977. * // Avoid excessively updating the position while scrolling.
  27978. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27979. *
  27980. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27981. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27982. * jQuery(element).on('click', throttled);
  27983. *
  27984. * // Cancel the trailing throttled invocation.
  27985. * jQuery(window).on('popstate', throttled.cancel);
  27986. */
  27987. function throttle(func, wait, options) {
  27988. var leading = true,
  27989. trailing = true;
  27990. if (typeof func != 'function') {
  27991. throw new TypeError(FUNC_ERROR_TEXT);
  27992. }
  27993. if (isObject(options)) {
  27994. leading = 'leading' in options ? !!options.leading : leading;
  27995. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27996. }
  27997. return debounce(func, wait, {
  27998. 'leading': leading,
  27999. 'maxWait': wait,
  28000. 'trailing': trailing
  28001. });
  28002. }
  28003. /**
  28004. * Creates a function that accepts up to one argument, ignoring any
  28005. * additional arguments.
  28006. *
  28007. * @static
  28008. * @memberOf _
  28009. * @since 4.0.0
  28010. * @category Function
  28011. * @param {Function} func The function to cap arguments for.
  28012. * @returns {Function} Returns the new capped function.
  28013. * @example
  28014. *
  28015. * _.map(['6', '8', '10'], _.unary(parseInt));
  28016. * // => [6, 8, 10]
  28017. */
  28018. function unary(func) {
  28019. return ary(func, 1);
  28020. }
  28021. /**
  28022. * Creates a function that provides `value` to `wrapper` as its first
  28023. * argument. Any additional arguments provided to the function are appended
  28024. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  28025. * binding of the created function.
  28026. *
  28027. * @static
  28028. * @memberOf _
  28029. * @since 0.1.0
  28030. * @category Function
  28031. * @param {*} value The value to wrap.
  28032. * @param {Function} [wrapper=identity] The wrapper function.
  28033. * @returns {Function} Returns the new function.
  28034. * @example
  28035. *
  28036. * var p = _.wrap(_.escape, function(func, text) {
  28037. * return '<p>' + func(text) + '</p>';
  28038. * });
  28039. *
  28040. * p('fred, barney, & pebbles');
  28041. * // => '<p>fred, barney, &amp; pebbles</p>'
  28042. */
  28043. function wrap(value, wrapper) {
  28044. return partial(castFunction(wrapper), value);
  28045. }
  28046. /*------------------------------------------------------------------------*/
  28047. /**
  28048. * Casts `value` as an array if it's not one.
  28049. *
  28050. * @static
  28051. * @memberOf _
  28052. * @since 4.4.0
  28053. * @category Lang
  28054. * @param {*} value The value to inspect.
  28055. * @returns {Array} Returns the cast array.
  28056. * @example
  28057. *
  28058. * _.castArray(1);
  28059. * // => [1]
  28060. *
  28061. * _.castArray({ 'a': 1 });
  28062. * // => [{ 'a': 1 }]
  28063. *
  28064. * _.castArray('abc');
  28065. * // => ['abc']
  28066. *
  28067. * _.castArray(null);
  28068. * // => [null]
  28069. *
  28070. * _.castArray(undefined);
  28071. * // => [undefined]
  28072. *
  28073. * _.castArray();
  28074. * // => []
  28075. *
  28076. * var array = [1, 2, 3];
  28077. * console.log(_.castArray(array) === array);
  28078. * // => true
  28079. */
  28080. function castArray() {
  28081. if (!arguments.length) {
  28082. return [];
  28083. }
  28084. var value = arguments[0];
  28085. return isArray(value) ? value : [value];
  28086. }
  28087. /**
  28088. * Creates a shallow clone of `value`.
  28089. *
  28090. * **Note:** This method is loosely based on the
  28091. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  28092. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  28093. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  28094. * arrays. The own enumerable properties of `arguments` objects are cloned
  28095. * as plain objects. An empty object is returned for uncloneable values such
  28096. * as error objects, functions, DOM nodes, and WeakMaps.
  28097. *
  28098. * @static
  28099. * @memberOf _
  28100. * @since 0.1.0
  28101. * @category Lang
  28102. * @param {*} value The value to clone.
  28103. * @returns {*} Returns the cloned value.
  28104. * @see _.cloneDeep
  28105. * @example
  28106. *
  28107. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28108. *
  28109. * var shallow = _.clone(objects);
  28110. * console.log(shallow[0] === objects[0]);
  28111. * // => true
  28112. */
  28113. function clone(value) {
  28114. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28115. }
  28116. /**
  28117. * This method is like `_.clone` except that it accepts `customizer` which
  28118. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28119. * cloning is handled by the method instead. The `customizer` is invoked with
  28120. * up to four arguments; (value [, index|key, object, stack]).
  28121. *
  28122. * @static
  28123. * @memberOf _
  28124. * @since 4.0.0
  28125. * @category Lang
  28126. * @param {*} value The value to clone.
  28127. * @param {Function} [customizer] The function to customize cloning.
  28128. * @returns {*} Returns the cloned value.
  28129. * @see _.cloneDeepWith
  28130. * @example
  28131. *
  28132. * function customizer(value) {
  28133. * if (_.isElement(value)) {
  28134. * return value.cloneNode(false);
  28135. * }
  28136. * }
  28137. *
  28138. * var el = _.cloneWith(document.body, customizer);
  28139. *
  28140. * console.log(el === document.body);
  28141. * // => false
  28142. * console.log(el.nodeName);
  28143. * // => 'BODY'
  28144. * console.log(el.childNodes.length);
  28145. * // => 0
  28146. */
  28147. function cloneWith(value, customizer) {
  28148. customizer = typeof customizer == 'function' ? customizer : undefined;
  28149. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28150. }
  28151. /**
  28152. * This method is like `_.clone` except that it recursively clones `value`.
  28153. *
  28154. * @static
  28155. * @memberOf _
  28156. * @since 1.0.0
  28157. * @category Lang
  28158. * @param {*} value The value to recursively clone.
  28159. * @returns {*} Returns the deep cloned value.
  28160. * @see _.clone
  28161. * @example
  28162. *
  28163. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28164. *
  28165. * var deep = _.cloneDeep(objects);
  28166. * console.log(deep[0] === objects[0]);
  28167. * // => false
  28168. */
  28169. function cloneDeep(value) {
  28170. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28171. }
  28172. /**
  28173. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28174. *
  28175. * @static
  28176. * @memberOf _
  28177. * @since 4.0.0
  28178. * @category Lang
  28179. * @param {*} value The value to recursively clone.
  28180. * @param {Function} [customizer] The function to customize cloning.
  28181. * @returns {*} Returns the deep cloned value.
  28182. * @see _.cloneWith
  28183. * @example
  28184. *
  28185. * function customizer(value) {
  28186. * if (_.isElement(value)) {
  28187. * return value.cloneNode(true);
  28188. * }
  28189. * }
  28190. *
  28191. * var el = _.cloneDeepWith(document.body, customizer);
  28192. *
  28193. * console.log(el === document.body);
  28194. * // => false
  28195. * console.log(el.nodeName);
  28196. * // => 'BODY'
  28197. * console.log(el.childNodes.length);
  28198. * // => 20
  28199. */
  28200. function cloneDeepWith(value, customizer) {
  28201. customizer = typeof customizer == 'function' ? customizer : undefined;
  28202. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28203. }
  28204. /**
  28205. * Checks if `object` conforms to `source` by invoking the predicate
  28206. * properties of `source` with the corresponding property values of `object`.
  28207. *
  28208. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28209. * partially applied.
  28210. *
  28211. * @static
  28212. * @memberOf _
  28213. * @since 4.14.0
  28214. * @category Lang
  28215. * @param {Object} object The object to inspect.
  28216. * @param {Object} source The object of property predicates to conform to.
  28217. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28218. * @example
  28219. *
  28220. * var object = { 'a': 1, 'b': 2 };
  28221. *
  28222. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28223. * // => true
  28224. *
  28225. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28226. * // => false
  28227. */
  28228. function conformsTo(object, source) {
  28229. return source == null || baseConformsTo(object, source, keys(source));
  28230. }
  28231. /**
  28232. * Performs a
  28233. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28234. * comparison between two values to determine if they are equivalent.
  28235. *
  28236. * @static
  28237. * @memberOf _
  28238. * @since 4.0.0
  28239. * @category Lang
  28240. * @param {*} value The value to compare.
  28241. * @param {*} other The other value to compare.
  28242. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28243. * @example
  28244. *
  28245. * var object = { 'a': 1 };
  28246. * var other = { 'a': 1 };
  28247. *
  28248. * _.eq(object, object);
  28249. * // => true
  28250. *
  28251. * _.eq(object, other);
  28252. * // => false
  28253. *
  28254. * _.eq('a', 'a');
  28255. * // => true
  28256. *
  28257. * _.eq('a', Object('a'));
  28258. * // => false
  28259. *
  28260. * _.eq(NaN, NaN);
  28261. * // => true
  28262. */
  28263. function eq(value, other) {
  28264. return value === other || (value !== value && other !== other);
  28265. }
  28266. /**
  28267. * Checks if `value` is greater than `other`.
  28268. *
  28269. * @static
  28270. * @memberOf _
  28271. * @since 3.9.0
  28272. * @category Lang
  28273. * @param {*} value The value to compare.
  28274. * @param {*} other The other value to compare.
  28275. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28276. * else `false`.
  28277. * @see _.lt
  28278. * @example
  28279. *
  28280. * _.gt(3, 1);
  28281. * // => true
  28282. *
  28283. * _.gt(3, 3);
  28284. * // => false
  28285. *
  28286. * _.gt(1, 3);
  28287. * // => false
  28288. */
  28289. var gt = createRelationalOperation(baseGt);
  28290. /**
  28291. * Checks if `value` is greater than or equal to `other`.
  28292. *
  28293. * @static
  28294. * @memberOf _
  28295. * @since 3.9.0
  28296. * @category Lang
  28297. * @param {*} value The value to compare.
  28298. * @param {*} other The other value to compare.
  28299. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28300. * `other`, else `false`.
  28301. * @see _.lte
  28302. * @example
  28303. *
  28304. * _.gte(3, 1);
  28305. * // => true
  28306. *
  28307. * _.gte(3, 3);
  28308. * // => true
  28309. *
  28310. * _.gte(1, 3);
  28311. * // => false
  28312. */
  28313. var gte = createRelationalOperation(function(value, other) {
  28314. return value >= other;
  28315. });
  28316. /**
  28317. * Checks if `value` is likely an `arguments` object.
  28318. *
  28319. * @static
  28320. * @memberOf _
  28321. * @since 0.1.0
  28322. * @category Lang
  28323. * @param {*} value The value to check.
  28324. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28325. * else `false`.
  28326. * @example
  28327. *
  28328. * _.isArguments(function() { return arguments; }());
  28329. * // => true
  28330. *
  28331. * _.isArguments([1, 2, 3]);
  28332. * // => false
  28333. */
  28334. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28335. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28336. !propertyIsEnumerable.call(value, 'callee');
  28337. };
  28338. /**
  28339. * Checks if `value` is classified as an `Array` object.
  28340. *
  28341. * @static
  28342. * @memberOf _
  28343. * @since 0.1.0
  28344. * @category Lang
  28345. * @param {*} value The value to check.
  28346. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28347. * @example
  28348. *
  28349. * _.isArray([1, 2, 3]);
  28350. * // => true
  28351. *
  28352. * _.isArray(document.body.children);
  28353. * // => false
  28354. *
  28355. * _.isArray('abc');
  28356. * // => false
  28357. *
  28358. * _.isArray(_.noop);
  28359. * // => false
  28360. */
  28361. var isArray = Array.isArray;
  28362. /**
  28363. * Checks if `value` is classified as an `ArrayBuffer` object.
  28364. *
  28365. * @static
  28366. * @memberOf _
  28367. * @since 4.3.0
  28368. * @category Lang
  28369. * @param {*} value The value to check.
  28370. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28371. * @example
  28372. *
  28373. * _.isArrayBuffer(new ArrayBuffer(2));
  28374. * // => true
  28375. *
  28376. * _.isArrayBuffer(new Array(2));
  28377. * // => false
  28378. */
  28379. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28380. /**
  28381. * Checks if `value` is array-like. A value is considered array-like if it's
  28382. * not a function and has a `value.length` that's an integer greater than or
  28383. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28384. *
  28385. * @static
  28386. * @memberOf _
  28387. * @since 4.0.0
  28388. * @category Lang
  28389. * @param {*} value The value to check.
  28390. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28391. * @example
  28392. *
  28393. * _.isArrayLike([1, 2, 3]);
  28394. * // => true
  28395. *
  28396. * _.isArrayLike(document.body.children);
  28397. * // => true
  28398. *
  28399. * _.isArrayLike('abc');
  28400. * // => true
  28401. *
  28402. * _.isArrayLike(_.noop);
  28403. * // => false
  28404. */
  28405. function isArrayLike(value) {
  28406. return value != null && isLength(value.length) && !isFunction(value);
  28407. }
  28408. /**
  28409. * This method is like `_.isArrayLike` except that it also checks if `value`
  28410. * is an object.
  28411. *
  28412. * @static
  28413. * @memberOf _
  28414. * @since 4.0.0
  28415. * @category Lang
  28416. * @param {*} value The value to check.
  28417. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28418. * else `false`.
  28419. * @example
  28420. *
  28421. * _.isArrayLikeObject([1, 2, 3]);
  28422. * // => true
  28423. *
  28424. * _.isArrayLikeObject(document.body.children);
  28425. * // => true
  28426. *
  28427. * _.isArrayLikeObject('abc');
  28428. * // => false
  28429. *
  28430. * _.isArrayLikeObject(_.noop);
  28431. * // => false
  28432. */
  28433. function isArrayLikeObject(value) {
  28434. return isObjectLike(value) && isArrayLike(value);
  28435. }
  28436. /**
  28437. * Checks if `value` is classified as a boolean primitive or object.
  28438. *
  28439. * @static
  28440. * @memberOf _
  28441. * @since 0.1.0
  28442. * @category Lang
  28443. * @param {*} value The value to check.
  28444. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28445. * @example
  28446. *
  28447. * _.isBoolean(false);
  28448. * // => true
  28449. *
  28450. * _.isBoolean(null);
  28451. * // => false
  28452. */
  28453. function isBoolean(value) {
  28454. return value === true || value === false ||
  28455. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28456. }
  28457. /**
  28458. * Checks if `value` is a buffer.
  28459. *
  28460. * @static
  28461. * @memberOf _
  28462. * @since 4.3.0
  28463. * @category Lang
  28464. * @param {*} value The value to check.
  28465. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28466. * @example
  28467. *
  28468. * _.isBuffer(new Buffer(2));
  28469. * // => true
  28470. *
  28471. * _.isBuffer(new Uint8Array(2));
  28472. * // => false
  28473. */
  28474. var isBuffer = nativeIsBuffer || stubFalse;
  28475. /**
  28476. * Checks if `value` is classified as a `Date` object.
  28477. *
  28478. * @static
  28479. * @memberOf _
  28480. * @since 0.1.0
  28481. * @category Lang
  28482. * @param {*} value The value to check.
  28483. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28484. * @example
  28485. *
  28486. * _.isDate(new Date);
  28487. * // => true
  28488. *
  28489. * _.isDate('Mon April 23 2012');
  28490. * // => false
  28491. */
  28492. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28493. /**
  28494. * Checks if `value` is likely a DOM element.
  28495. *
  28496. * @static
  28497. * @memberOf _
  28498. * @since 0.1.0
  28499. * @category Lang
  28500. * @param {*} value The value to check.
  28501. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28502. * @example
  28503. *
  28504. * _.isElement(document.body);
  28505. * // => true
  28506. *
  28507. * _.isElement('<body>');
  28508. * // => false
  28509. */
  28510. function isElement(value) {
  28511. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28512. }
  28513. /**
  28514. * Checks if `value` is an empty object, collection, map, or set.
  28515. *
  28516. * Objects are considered empty if they have no own enumerable string keyed
  28517. * properties.
  28518. *
  28519. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28520. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28521. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28522. *
  28523. * @static
  28524. * @memberOf _
  28525. * @since 0.1.0
  28526. * @category Lang
  28527. * @param {*} value The value to check.
  28528. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28529. * @example
  28530. *
  28531. * _.isEmpty(null);
  28532. * // => true
  28533. *
  28534. * _.isEmpty(true);
  28535. * // => true
  28536. *
  28537. * _.isEmpty(1);
  28538. * // => true
  28539. *
  28540. * _.isEmpty([1, 2, 3]);
  28541. * // => false
  28542. *
  28543. * _.isEmpty({ 'a': 1 });
  28544. * // => false
  28545. */
  28546. function isEmpty(value) {
  28547. if (value == null) {
  28548. return true;
  28549. }
  28550. if (isArrayLike(value) &&
  28551. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28552. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28553. return !value.length;
  28554. }
  28555. var tag = getTag(value);
  28556. if (tag == mapTag || tag == setTag) {
  28557. return !value.size;
  28558. }
  28559. if (isPrototype(value)) {
  28560. return !baseKeys(value).length;
  28561. }
  28562. for (var key in value) {
  28563. if (hasOwnProperty.call(value, key)) {
  28564. return false;
  28565. }
  28566. }
  28567. return true;
  28568. }
  28569. /**
  28570. * Performs a deep comparison between two values to determine if they are
  28571. * equivalent.
  28572. *
  28573. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28574. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28575. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28576. * by their own, not inherited, enumerable properties. Functions and DOM
  28577. * nodes are compared by strict equality, i.e. `===`.
  28578. *
  28579. * @static
  28580. * @memberOf _
  28581. * @since 0.1.0
  28582. * @category Lang
  28583. * @param {*} value The value to compare.
  28584. * @param {*} other The other value to compare.
  28585. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28586. * @example
  28587. *
  28588. * var object = { 'a': 1 };
  28589. * var other = { 'a': 1 };
  28590. *
  28591. * _.isEqual(object, other);
  28592. * // => true
  28593. *
  28594. * object === other;
  28595. * // => false
  28596. */
  28597. function isEqual(value, other) {
  28598. return baseIsEqual(value, other);
  28599. }
  28600. /**
  28601. * This method is like `_.isEqual` except that it accepts `customizer` which
  28602. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28603. * are handled by the method instead. The `customizer` is invoked with up to
  28604. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28605. *
  28606. * @static
  28607. * @memberOf _
  28608. * @since 4.0.0
  28609. * @category Lang
  28610. * @param {*} value The value to compare.
  28611. * @param {*} other The other value to compare.
  28612. * @param {Function} [customizer] The function to customize comparisons.
  28613. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28614. * @example
  28615. *
  28616. * function isGreeting(value) {
  28617. * return /^h(?:i|ello)$/.test(value);
  28618. * }
  28619. *
  28620. * function customizer(objValue, othValue) {
  28621. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28622. * return true;
  28623. * }
  28624. * }
  28625. *
  28626. * var array = ['hello', 'goodbye'];
  28627. * var other = ['hi', 'goodbye'];
  28628. *
  28629. * _.isEqualWith(array, other, customizer);
  28630. * // => true
  28631. */
  28632. function isEqualWith(value, other, customizer) {
  28633. customizer = typeof customizer == 'function' ? customizer : undefined;
  28634. var result = customizer ? customizer(value, other) : undefined;
  28635. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28636. }
  28637. /**
  28638. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28639. * `SyntaxError`, `TypeError`, or `URIError` object.
  28640. *
  28641. * @static
  28642. * @memberOf _
  28643. * @since 3.0.0
  28644. * @category Lang
  28645. * @param {*} value The value to check.
  28646. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28647. * @example
  28648. *
  28649. * _.isError(new Error);
  28650. * // => true
  28651. *
  28652. * _.isError(Error);
  28653. * // => false
  28654. */
  28655. function isError(value) {
  28656. if (!isObjectLike(value)) {
  28657. return false;
  28658. }
  28659. var tag = baseGetTag(value);
  28660. return tag == errorTag || tag == domExcTag ||
  28661. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28662. }
  28663. /**
  28664. * Checks if `value` is a finite primitive number.
  28665. *
  28666. * **Note:** This method is based on
  28667. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28668. *
  28669. * @static
  28670. * @memberOf _
  28671. * @since 0.1.0
  28672. * @category Lang
  28673. * @param {*} value The value to check.
  28674. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28675. * @example
  28676. *
  28677. * _.isFinite(3);
  28678. * // => true
  28679. *
  28680. * _.isFinite(Number.MIN_VALUE);
  28681. * // => true
  28682. *
  28683. * _.isFinite(Infinity);
  28684. * // => false
  28685. *
  28686. * _.isFinite('3');
  28687. * // => false
  28688. */
  28689. function isFinite(value) {
  28690. return typeof value == 'number' && nativeIsFinite(value);
  28691. }
  28692. /**
  28693. * Checks if `value` is classified as a `Function` object.
  28694. *
  28695. * @static
  28696. * @memberOf _
  28697. * @since 0.1.0
  28698. * @category Lang
  28699. * @param {*} value The value to check.
  28700. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28701. * @example
  28702. *
  28703. * _.isFunction(_);
  28704. * // => true
  28705. *
  28706. * _.isFunction(/abc/);
  28707. * // => false
  28708. */
  28709. function isFunction(value) {
  28710. if (!isObject(value)) {
  28711. return false;
  28712. }
  28713. // The use of `Object#toString` avoids issues with the `typeof` operator
  28714. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28715. var tag = baseGetTag(value);
  28716. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28717. }
  28718. /**
  28719. * Checks if `value` is an integer.
  28720. *
  28721. * **Note:** This method is based on
  28722. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28723. *
  28724. * @static
  28725. * @memberOf _
  28726. * @since 4.0.0
  28727. * @category Lang
  28728. * @param {*} value The value to check.
  28729. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28730. * @example
  28731. *
  28732. * _.isInteger(3);
  28733. * // => true
  28734. *
  28735. * _.isInteger(Number.MIN_VALUE);
  28736. * // => false
  28737. *
  28738. * _.isInteger(Infinity);
  28739. * // => false
  28740. *
  28741. * _.isInteger('3');
  28742. * // => false
  28743. */
  28744. function isInteger(value) {
  28745. return typeof value == 'number' && value == toInteger(value);
  28746. }
  28747. /**
  28748. * Checks if `value` is a valid array-like length.
  28749. *
  28750. * **Note:** This method is loosely based on
  28751. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28752. *
  28753. * @static
  28754. * @memberOf _
  28755. * @since 4.0.0
  28756. * @category Lang
  28757. * @param {*} value The value to check.
  28758. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28759. * @example
  28760. *
  28761. * _.isLength(3);
  28762. * // => true
  28763. *
  28764. * _.isLength(Number.MIN_VALUE);
  28765. * // => false
  28766. *
  28767. * _.isLength(Infinity);
  28768. * // => false
  28769. *
  28770. * _.isLength('3');
  28771. * // => false
  28772. */
  28773. function isLength(value) {
  28774. return typeof value == 'number' &&
  28775. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28776. }
  28777. /**
  28778. * Checks if `value` is the
  28779. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28780. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28781. *
  28782. * @static
  28783. * @memberOf _
  28784. * @since 0.1.0
  28785. * @category Lang
  28786. * @param {*} value The value to check.
  28787. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28788. * @example
  28789. *
  28790. * _.isObject({});
  28791. * // => true
  28792. *
  28793. * _.isObject([1, 2, 3]);
  28794. * // => true
  28795. *
  28796. * _.isObject(_.noop);
  28797. * // => true
  28798. *
  28799. * _.isObject(null);
  28800. * // => false
  28801. */
  28802. function isObject(value) {
  28803. var type = typeof value;
  28804. return value != null && (type == 'object' || type == 'function');
  28805. }
  28806. /**
  28807. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28808. * and has a `typeof` result of "object".
  28809. *
  28810. * @static
  28811. * @memberOf _
  28812. * @since 4.0.0
  28813. * @category Lang
  28814. * @param {*} value The value to check.
  28815. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28816. * @example
  28817. *
  28818. * _.isObjectLike({});
  28819. * // => true
  28820. *
  28821. * _.isObjectLike([1, 2, 3]);
  28822. * // => true
  28823. *
  28824. * _.isObjectLike(_.noop);
  28825. * // => false
  28826. *
  28827. * _.isObjectLike(null);
  28828. * // => false
  28829. */
  28830. function isObjectLike(value) {
  28831. return value != null && typeof value == 'object';
  28832. }
  28833. /**
  28834. * Checks if `value` is classified as a `Map` object.
  28835. *
  28836. * @static
  28837. * @memberOf _
  28838. * @since 4.3.0
  28839. * @category Lang
  28840. * @param {*} value The value to check.
  28841. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28842. * @example
  28843. *
  28844. * _.isMap(new Map);
  28845. * // => true
  28846. *
  28847. * _.isMap(new WeakMap);
  28848. * // => false
  28849. */
  28850. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28851. /**
  28852. * Performs a partial deep comparison between `object` and `source` to
  28853. * determine if `object` contains equivalent property values.
  28854. *
  28855. * **Note:** This method is equivalent to `_.matches` when `source` is
  28856. * partially applied.
  28857. *
  28858. * Partial comparisons will match empty array and empty object `source`
  28859. * values against any array or object value, respectively. See `_.isEqual`
  28860. * for a list of supported value comparisons.
  28861. *
  28862. * @static
  28863. * @memberOf _
  28864. * @since 3.0.0
  28865. * @category Lang
  28866. * @param {Object} object The object to inspect.
  28867. * @param {Object} source The object of property values to match.
  28868. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28869. * @example
  28870. *
  28871. * var object = { 'a': 1, 'b': 2 };
  28872. *
  28873. * _.isMatch(object, { 'b': 2 });
  28874. * // => true
  28875. *
  28876. * _.isMatch(object, { 'b': 1 });
  28877. * // => false
  28878. */
  28879. function isMatch(object, source) {
  28880. return object === source || baseIsMatch(object, source, getMatchData(source));
  28881. }
  28882. /**
  28883. * This method is like `_.isMatch` except that it accepts `customizer` which
  28884. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28885. * are handled by the method instead. The `customizer` is invoked with five
  28886. * arguments: (objValue, srcValue, index|key, object, source).
  28887. *
  28888. * @static
  28889. * @memberOf _
  28890. * @since 4.0.0
  28891. * @category Lang
  28892. * @param {Object} object The object to inspect.
  28893. * @param {Object} source The object of property values to match.
  28894. * @param {Function} [customizer] The function to customize comparisons.
  28895. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28896. * @example
  28897. *
  28898. * function isGreeting(value) {
  28899. * return /^h(?:i|ello)$/.test(value);
  28900. * }
  28901. *
  28902. * function customizer(objValue, srcValue) {
  28903. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28904. * return true;
  28905. * }
  28906. * }
  28907. *
  28908. * var object = { 'greeting': 'hello' };
  28909. * var source = { 'greeting': 'hi' };
  28910. *
  28911. * _.isMatchWith(object, source, customizer);
  28912. * // => true
  28913. */
  28914. function isMatchWith(object, source, customizer) {
  28915. customizer = typeof customizer == 'function' ? customizer : undefined;
  28916. return baseIsMatch(object, source, getMatchData(source), customizer);
  28917. }
  28918. /**
  28919. * Checks if `value` is `NaN`.
  28920. *
  28921. * **Note:** This method is based on
  28922. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28923. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28924. * `undefined` and other non-number values.
  28925. *
  28926. * @static
  28927. * @memberOf _
  28928. * @since 0.1.0
  28929. * @category Lang
  28930. * @param {*} value The value to check.
  28931. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28932. * @example
  28933. *
  28934. * _.isNaN(NaN);
  28935. * // => true
  28936. *
  28937. * _.isNaN(new Number(NaN));
  28938. * // => true
  28939. *
  28940. * isNaN(undefined);
  28941. * // => true
  28942. *
  28943. * _.isNaN(undefined);
  28944. * // => false
  28945. */
  28946. function isNaN(value) {
  28947. // An `NaN` primitive is the only value that is not equal to itself.
  28948. // Perform the `toStringTag` check first to avoid errors with some
  28949. // ActiveX objects in IE.
  28950. return isNumber(value) && value != +value;
  28951. }
  28952. /**
  28953. * Checks if `value` is a pristine native function.
  28954. *
  28955. * **Note:** This method can't reliably detect native functions in the presence
  28956. * of the core-js package because core-js circumvents this kind of detection.
  28957. * Despite multiple requests, the core-js maintainer has made it clear: any
  28958. * attempt to fix the detection will be obstructed. As a result, we're left
  28959. * with little choice but to throw an error. Unfortunately, this also affects
  28960. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28961. * which rely on core-js.
  28962. *
  28963. * @static
  28964. * @memberOf _
  28965. * @since 3.0.0
  28966. * @category Lang
  28967. * @param {*} value The value to check.
  28968. * @returns {boolean} Returns `true` if `value` is a native function,
  28969. * else `false`.
  28970. * @example
  28971. *
  28972. * _.isNative(Array.prototype.push);
  28973. * // => true
  28974. *
  28975. * _.isNative(_);
  28976. * // => false
  28977. */
  28978. function isNative(value) {
  28979. if (isMaskable(value)) {
  28980. throw new Error(CORE_ERROR_TEXT);
  28981. }
  28982. return baseIsNative(value);
  28983. }
  28984. /**
  28985. * Checks if `value` is `null`.
  28986. *
  28987. * @static
  28988. * @memberOf _
  28989. * @since 0.1.0
  28990. * @category Lang
  28991. * @param {*} value The value to check.
  28992. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28993. * @example
  28994. *
  28995. * _.isNull(null);
  28996. * // => true
  28997. *
  28998. * _.isNull(void 0);
  28999. * // => false
  29000. */
  29001. function isNull(value) {
  29002. return value === null;
  29003. }
  29004. /**
  29005. * Checks if `value` is `null` or `undefined`.
  29006. *
  29007. * @static
  29008. * @memberOf _
  29009. * @since 4.0.0
  29010. * @category Lang
  29011. * @param {*} value The value to check.
  29012. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  29013. * @example
  29014. *
  29015. * _.isNil(null);
  29016. * // => true
  29017. *
  29018. * _.isNil(void 0);
  29019. * // => true
  29020. *
  29021. * _.isNil(NaN);
  29022. * // => false
  29023. */
  29024. function isNil(value) {
  29025. return value == null;
  29026. }
  29027. /**
  29028. * Checks if `value` is classified as a `Number` primitive or object.
  29029. *
  29030. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  29031. * classified as numbers, use the `_.isFinite` method.
  29032. *
  29033. * @static
  29034. * @memberOf _
  29035. * @since 0.1.0
  29036. * @category Lang
  29037. * @param {*} value The value to check.
  29038. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  29039. * @example
  29040. *
  29041. * _.isNumber(3);
  29042. * // => true
  29043. *
  29044. * _.isNumber(Number.MIN_VALUE);
  29045. * // => true
  29046. *
  29047. * _.isNumber(Infinity);
  29048. * // => true
  29049. *
  29050. * _.isNumber('3');
  29051. * // => false
  29052. */
  29053. function isNumber(value) {
  29054. return typeof value == 'number' ||
  29055. (isObjectLike(value) && baseGetTag(value) == numberTag);
  29056. }
  29057. /**
  29058. * Checks if `value` is a plain object, that is, an object created by the
  29059. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  29060. *
  29061. * @static
  29062. * @memberOf _
  29063. * @since 0.8.0
  29064. * @category Lang
  29065. * @param {*} value The value to check.
  29066. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  29067. * @example
  29068. *
  29069. * function Foo() {
  29070. * this.a = 1;
  29071. * }
  29072. *
  29073. * _.isPlainObject(new Foo);
  29074. * // => false
  29075. *
  29076. * _.isPlainObject([1, 2, 3]);
  29077. * // => false
  29078. *
  29079. * _.isPlainObject({ 'x': 0, 'y': 0 });
  29080. * // => true
  29081. *
  29082. * _.isPlainObject(Object.create(null));
  29083. * // => true
  29084. */
  29085. function isPlainObject(value) {
  29086. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  29087. return false;
  29088. }
  29089. var proto = getPrototype(value);
  29090. if (proto === null) {
  29091. return true;
  29092. }
  29093. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  29094. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  29095. funcToString.call(Ctor) == objectCtorString;
  29096. }
  29097. /**
  29098. * Checks if `value` is classified as a `RegExp` object.
  29099. *
  29100. * @static
  29101. * @memberOf _
  29102. * @since 0.1.0
  29103. * @category Lang
  29104. * @param {*} value The value to check.
  29105. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  29106. * @example
  29107. *
  29108. * _.isRegExp(/abc/);
  29109. * // => true
  29110. *
  29111. * _.isRegExp('/abc/');
  29112. * // => false
  29113. */
  29114. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29115. /**
  29116. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29117. * double precision number which isn't the result of a rounded unsafe integer.
  29118. *
  29119. * **Note:** This method is based on
  29120. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29121. *
  29122. * @static
  29123. * @memberOf _
  29124. * @since 4.0.0
  29125. * @category Lang
  29126. * @param {*} value The value to check.
  29127. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29128. * @example
  29129. *
  29130. * _.isSafeInteger(3);
  29131. * // => true
  29132. *
  29133. * _.isSafeInteger(Number.MIN_VALUE);
  29134. * // => false
  29135. *
  29136. * _.isSafeInteger(Infinity);
  29137. * // => false
  29138. *
  29139. * _.isSafeInteger('3');
  29140. * // => false
  29141. */
  29142. function isSafeInteger(value) {
  29143. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29144. }
  29145. /**
  29146. * Checks if `value` is classified as a `Set` object.
  29147. *
  29148. * @static
  29149. * @memberOf _
  29150. * @since 4.3.0
  29151. * @category Lang
  29152. * @param {*} value The value to check.
  29153. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29154. * @example
  29155. *
  29156. * _.isSet(new Set);
  29157. * // => true
  29158. *
  29159. * _.isSet(new WeakSet);
  29160. * // => false
  29161. */
  29162. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29163. /**
  29164. * Checks if `value` is classified as a `String` primitive or object.
  29165. *
  29166. * @static
  29167. * @since 0.1.0
  29168. * @memberOf _
  29169. * @category Lang
  29170. * @param {*} value The value to check.
  29171. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29172. * @example
  29173. *
  29174. * _.isString('abc');
  29175. * // => true
  29176. *
  29177. * _.isString(1);
  29178. * // => false
  29179. */
  29180. function isString(value) {
  29181. return typeof value == 'string' ||
  29182. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29183. }
  29184. /**
  29185. * Checks if `value` is classified as a `Symbol` primitive or object.
  29186. *
  29187. * @static
  29188. * @memberOf _
  29189. * @since 4.0.0
  29190. * @category Lang
  29191. * @param {*} value The value to check.
  29192. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29193. * @example
  29194. *
  29195. * _.isSymbol(Symbol.iterator);
  29196. * // => true
  29197. *
  29198. * _.isSymbol('abc');
  29199. * // => false
  29200. */
  29201. function isSymbol(value) {
  29202. return typeof value == 'symbol' ||
  29203. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29204. }
  29205. /**
  29206. * Checks if `value` is classified as a typed array.
  29207. *
  29208. * @static
  29209. * @memberOf _
  29210. * @since 3.0.0
  29211. * @category Lang
  29212. * @param {*} value The value to check.
  29213. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29214. * @example
  29215. *
  29216. * _.isTypedArray(new Uint8Array);
  29217. * // => true
  29218. *
  29219. * _.isTypedArray([]);
  29220. * // => false
  29221. */
  29222. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29223. /**
  29224. * Checks if `value` is `undefined`.
  29225. *
  29226. * @static
  29227. * @since 0.1.0
  29228. * @memberOf _
  29229. * @category Lang
  29230. * @param {*} value The value to check.
  29231. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29232. * @example
  29233. *
  29234. * _.isUndefined(void 0);
  29235. * // => true
  29236. *
  29237. * _.isUndefined(null);
  29238. * // => false
  29239. */
  29240. function isUndefined(value) {
  29241. return value === undefined;
  29242. }
  29243. /**
  29244. * Checks if `value` is classified as a `WeakMap` object.
  29245. *
  29246. * @static
  29247. * @memberOf _
  29248. * @since 4.3.0
  29249. * @category Lang
  29250. * @param {*} value The value to check.
  29251. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29252. * @example
  29253. *
  29254. * _.isWeakMap(new WeakMap);
  29255. * // => true
  29256. *
  29257. * _.isWeakMap(new Map);
  29258. * // => false
  29259. */
  29260. function isWeakMap(value) {
  29261. return isObjectLike(value) && getTag(value) == weakMapTag;
  29262. }
  29263. /**
  29264. * Checks if `value` is classified as a `WeakSet` object.
  29265. *
  29266. * @static
  29267. * @memberOf _
  29268. * @since 4.3.0
  29269. * @category Lang
  29270. * @param {*} value The value to check.
  29271. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29272. * @example
  29273. *
  29274. * _.isWeakSet(new WeakSet);
  29275. * // => true
  29276. *
  29277. * _.isWeakSet(new Set);
  29278. * // => false
  29279. */
  29280. function isWeakSet(value) {
  29281. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29282. }
  29283. /**
  29284. * Checks if `value` is less than `other`.
  29285. *
  29286. * @static
  29287. * @memberOf _
  29288. * @since 3.9.0
  29289. * @category Lang
  29290. * @param {*} value The value to compare.
  29291. * @param {*} other The other value to compare.
  29292. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29293. * else `false`.
  29294. * @see _.gt
  29295. * @example
  29296. *
  29297. * _.lt(1, 3);
  29298. * // => true
  29299. *
  29300. * _.lt(3, 3);
  29301. * // => false
  29302. *
  29303. * _.lt(3, 1);
  29304. * // => false
  29305. */
  29306. var lt = createRelationalOperation(baseLt);
  29307. /**
  29308. * Checks if `value` is less than or equal to `other`.
  29309. *
  29310. * @static
  29311. * @memberOf _
  29312. * @since 3.9.0
  29313. * @category Lang
  29314. * @param {*} value The value to compare.
  29315. * @param {*} other The other value to compare.
  29316. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29317. * `other`, else `false`.
  29318. * @see _.gte
  29319. * @example
  29320. *
  29321. * _.lte(1, 3);
  29322. * // => true
  29323. *
  29324. * _.lte(3, 3);
  29325. * // => true
  29326. *
  29327. * _.lte(3, 1);
  29328. * // => false
  29329. */
  29330. var lte = createRelationalOperation(function(value, other) {
  29331. return value <= other;
  29332. });
  29333. /**
  29334. * Converts `value` to an array.
  29335. *
  29336. * @static
  29337. * @since 0.1.0
  29338. * @memberOf _
  29339. * @category Lang
  29340. * @param {*} value The value to convert.
  29341. * @returns {Array} Returns the converted array.
  29342. * @example
  29343. *
  29344. * _.toArray({ 'a': 1, 'b': 2 });
  29345. * // => [1, 2]
  29346. *
  29347. * _.toArray('abc');
  29348. * // => ['a', 'b', 'c']
  29349. *
  29350. * _.toArray(1);
  29351. * // => []
  29352. *
  29353. * _.toArray(null);
  29354. * // => []
  29355. */
  29356. function toArray(value) {
  29357. if (!value) {
  29358. return [];
  29359. }
  29360. if (isArrayLike(value)) {
  29361. return isString(value) ? stringToArray(value) : copyArray(value);
  29362. }
  29363. if (symIterator && value[symIterator]) {
  29364. return iteratorToArray(value[symIterator]());
  29365. }
  29366. var tag = getTag(value),
  29367. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29368. return func(value);
  29369. }
  29370. /**
  29371. * Converts `value` to a finite number.
  29372. *
  29373. * @static
  29374. * @memberOf _
  29375. * @since 4.12.0
  29376. * @category Lang
  29377. * @param {*} value The value to convert.
  29378. * @returns {number} Returns the converted number.
  29379. * @example
  29380. *
  29381. * _.toFinite(3.2);
  29382. * // => 3.2
  29383. *
  29384. * _.toFinite(Number.MIN_VALUE);
  29385. * // => 5e-324
  29386. *
  29387. * _.toFinite(Infinity);
  29388. * // => 1.7976931348623157e+308
  29389. *
  29390. * _.toFinite('3.2');
  29391. * // => 3.2
  29392. */
  29393. function toFinite(value) {
  29394. if (!value) {
  29395. return value === 0 ? value : 0;
  29396. }
  29397. value = toNumber(value);
  29398. if (value === INFINITY || value === -INFINITY) {
  29399. var sign = (value < 0 ? -1 : 1);
  29400. return sign * MAX_INTEGER;
  29401. }
  29402. return value === value ? value : 0;
  29403. }
  29404. /**
  29405. * Converts `value` to an integer.
  29406. *
  29407. * **Note:** This method is loosely based on
  29408. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29409. *
  29410. * @static
  29411. * @memberOf _
  29412. * @since 4.0.0
  29413. * @category Lang
  29414. * @param {*} value The value to convert.
  29415. * @returns {number} Returns the converted integer.
  29416. * @example
  29417. *
  29418. * _.toInteger(3.2);
  29419. * // => 3
  29420. *
  29421. * _.toInteger(Number.MIN_VALUE);
  29422. * // => 0
  29423. *
  29424. * _.toInteger(Infinity);
  29425. * // => 1.7976931348623157e+308
  29426. *
  29427. * _.toInteger('3.2');
  29428. * // => 3
  29429. */
  29430. function toInteger(value) {
  29431. var result = toFinite(value),
  29432. remainder = result % 1;
  29433. return result === result ? (remainder ? result - remainder : result) : 0;
  29434. }
  29435. /**
  29436. * Converts `value` to an integer suitable for use as the length of an
  29437. * array-like object.
  29438. *
  29439. * **Note:** This method is based on
  29440. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29441. *
  29442. * @static
  29443. * @memberOf _
  29444. * @since 4.0.0
  29445. * @category Lang
  29446. * @param {*} value The value to convert.
  29447. * @returns {number} Returns the converted integer.
  29448. * @example
  29449. *
  29450. * _.toLength(3.2);
  29451. * // => 3
  29452. *
  29453. * _.toLength(Number.MIN_VALUE);
  29454. * // => 0
  29455. *
  29456. * _.toLength(Infinity);
  29457. * // => 4294967295
  29458. *
  29459. * _.toLength('3.2');
  29460. * // => 3
  29461. */
  29462. function toLength(value) {
  29463. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29464. }
  29465. /**
  29466. * Converts `value` to a number.
  29467. *
  29468. * @static
  29469. * @memberOf _
  29470. * @since 4.0.0
  29471. * @category Lang
  29472. * @param {*} value The value to process.
  29473. * @returns {number} Returns the number.
  29474. * @example
  29475. *
  29476. * _.toNumber(3.2);
  29477. * // => 3.2
  29478. *
  29479. * _.toNumber(Number.MIN_VALUE);
  29480. * // => 5e-324
  29481. *
  29482. * _.toNumber(Infinity);
  29483. * // => Infinity
  29484. *
  29485. * _.toNumber('3.2');
  29486. * // => 3.2
  29487. */
  29488. function toNumber(value) {
  29489. if (typeof value == 'number') {
  29490. return value;
  29491. }
  29492. if (isSymbol(value)) {
  29493. return NAN;
  29494. }
  29495. if (isObject(value)) {
  29496. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29497. value = isObject(other) ? (other + '') : other;
  29498. }
  29499. if (typeof value != 'string') {
  29500. return value === 0 ? value : +value;
  29501. }
  29502. value = value.replace(reTrim, '');
  29503. var isBinary = reIsBinary.test(value);
  29504. return (isBinary || reIsOctal.test(value))
  29505. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29506. : (reIsBadHex.test(value) ? NAN : +value);
  29507. }
  29508. /**
  29509. * Converts `value` to a plain object flattening inherited enumerable string
  29510. * keyed properties of `value` to own properties of the plain object.
  29511. *
  29512. * @static
  29513. * @memberOf _
  29514. * @since 3.0.0
  29515. * @category Lang
  29516. * @param {*} value The value to convert.
  29517. * @returns {Object} Returns the converted plain object.
  29518. * @example
  29519. *
  29520. * function Foo() {
  29521. * this.b = 2;
  29522. * }
  29523. *
  29524. * Foo.prototype.c = 3;
  29525. *
  29526. * _.assign({ 'a': 1 }, new Foo);
  29527. * // => { 'a': 1, 'b': 2 }
  29528. *
  29529. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29530. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29531. */
  29532. function toPlainObject(value) {
  29533. return copyObject(value, keysIn(value));
  29534. }
  29535. /**
  29536. * Converts `value` to a safe integer. A safe integer can be compared and
  29537. * represented correctly.
  29538. *
  29539. * @static
  29540. * @memberOf _
  29541. * @since 4.0.0
  29542. * @category Lang
  29543. * @param {*} value The value to convert.
  29544. * @returns {number} Returns the converted integer.
  29545. * @example
  29546. *
  29547. * _.toSafeInteger(3.2);
  29548. * // => 3
  29549. *
  29550. * _.toSafeInteger(Number.MIN_VALUE);
  29551. * // => 0
  29552. *
  29553. * _.toSafeInteger(Infinity);
  29554. * // => 9007199254740991
  29555. *
  29556. * _.toSafeInteger('3.2');
  29557. * // => 3
  29558. */
  29559. function toSafeInteger(value) {
  29560. return value
  29561. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29562. : (value === 0 ? value : 0);
  29563. }
  29564. /**
  29565. * Converts `value` to a string. An empty string is returned for `null`
  29566. * and `undefined` values. The sign of `-0` is preserved.
  29567. *
  29568. * @static
  29569. * @memberOf _
  29570. * @since 4.0.0
  29571. * @category Lang
  29572. * @param {*} value The value to convert.
  29573. * @returns {string} Returns the converted string.
  29574. * @example
  29575. *
  29576. * _.toString(null);
  29577. * // => ''
  29578. *
  29579. * _.toString(-0);
  29580. * // => '-0'
  29581. *
  29582. * _.toString([1, 2, 3]);
  29583. * // => '1,2,3'
  29584. */
  29585. function toString(value) {
  29586. return value == null ? '' : baseToString(value);
  29587. }
  29588. /*------------------------------------------------------------------------*/
  29589. /**
  29590. * Assigns own enumerable string keyed properties of source objects to the
  29591. * destination object. Source objects are applied from left to right.
  29592. * Subsequent sources overwrite property assignments of previous sources.
  29593. *
  29594. * **Note:** This method mutates `object` and is loosely based on
  29595. * [`Object.assign`](https://mdn.io/Object/assign).
  29596. *
  29597. * @static
  29598. * @memberOf _
  29599. * @since 0.10.0
  29600. * @category Object
  29601. * @param {Object} object The destination object.
  29602. * @param {...Object} [sources] The source objects.
  29603. * @returns {Object} Returns `object`.
  29604. * @see _.assignIn
  29605. * @example
  29606. *
  29607. * function Foo() {
  29608. * this.a = 1;
  29609. * }
  29610. *
  29611. * function Bar() {
  29612. * this.c = 3;
  29613. * }
  29614. *
  29615. * Foo.prototype.b = 2;
  29616. * Bar.prototype.d = 4;
  29617. *
  29618. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29619. * // => { 'a': 1, 'c': 3 }
  29620. */
  29621. var assign = createAssigner(function(object, source) {
  29622. if (isPrototype(source) || isArrayLike(source)) {
  29623. copyObject(source, keys(source), object);
  29624. return;
  29625. }
  29626. for (var key in source) {
  29627. if (hasOwnProperty.call(source, key)) {
  29628. assignValue(object, key, source[key]);
  29629. }
  29630. }
  29631. });
  29632. /**
  29633. * This method is like `_.assign` except that it iterates over own and
  29634. * inherited source properties.
  29635. *
  29636. * **Note:** This method mutates `object`.
  29637. *
  29638. * @static
  29639. * @memberOf _
  29640. * @since 4.0.0
  29641. * @alias extend
  29642. * @category Object
  29643. * @param {Object} object The destination object.
  29644. * @param {...Object} [sources] The source objects.
  29645. * @returns {Object} Returns `object`.
  29646. * @see _.assign
  29647. * @example
  29648. *
  29649. * function Foo() {
  29650. * this.a = 1;
  29651. * }
  29652. *
  29653. * function Bar() {
  29654. * this.c = 3;
  29655. * }
  29656. *
  29657. * Foo.prototype.b = 2;
  29658. * Bar.prototype.d = 4;
  29659. *
  29660. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29661. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29662. */
  29663. var assignIn = createAssigner(function(object, source) {
  29664. copyObject(source, keysIn(source), object);
  29665. });
  29666. /**
  29667. * This method is like `_.assignIn` except that it accepts `customizer`
  29668. * which is invoked to produce the assigned values. If `customizer` returns
  29669. * `undefined`, assignment is handled by the method instead. The `customizer`
  29670. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29671. *
  29672. * **Note:** This method mutates `object`.
  29673. *
  29674. * @static
  29675. * @memberOf _
  29676. * @since 4.0.0
  29677. * @alias extendWith
  29678. * @category Object
  29679. * @param {Object} object The destination object.
  29680. * @param {...Object} sources The source objects.
  29681. * @param {Function} [customizer] The function to customize assigned values.
  29682. * @returns {Object} Returns `object`.
  29683. * @see _.assignWith
  29684. * @example
  29685. *
  29686. * function customizer(objValue, srcValue) {
  29687. * return _.isUndefined(objValue) ? srcValue : objValue;
  29688. * }
  29689. *
  29690. * var defaults = _.partialRight(_.assignInWith, customizer);
  29691. *
  29692. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29693. * // => { 'a': 1, 'b': 2 }
  29694. */
  29695. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29696. copyObject(source, keysIn(source), object, customizer);
  29697. });
  29698. /**
  29699. * This method is like `_.assign` except that it accepts `customizer`
  29700. * which is invoked to produce the assigned values. If `customizer` returns
  29701. * `undefined`, assignment is handled by the method instead. The `customizer`
  29702. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29703. *
  29704. * **Note:** This method mutates `object`.
  29705. *
  29706. * @static
  29707. * @memberOf _
  29708. * @since 4.0.0
  29709. * @category Object
  29710. * @param {Object} object The destination object.
  29711. * @param {...Object} sources The source objects.
  29712. * @param {Function} [customizer] The function to customize assigned values.
  29713. * @returns {Object} Returns `object`.
  29714. * @see _.assignInWith
  29715. * @example
  29716. *
  29717. * function customizer(objValue, srcValue) {
  29718. * return _.isUndefined(objValue) ? srcValue : objValue;
  29719. * }
  29720. *
  29721. * var defaults = _.partialRight(_.assignWith, customizer);
  29722. *
  29723. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29724. * // => { 'a': 1, 'b': 2 }
  29725. */
  29726. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29727. copyObject(source, keys(source), object, customizer);
  29728. });
  29729. /**
  29730. * Creates an array of values corresponding to `paths` of `object`.
  29731. *
  29732. * @static
  29733. * @memberOf _
  29734. * @since 1.0.0
  29735. * @category Object
  29736. * @param {Object} object The object to iterate over.
  29737. * @param {...(string|string[])} [paths] The property paths to pick.
  29738. * @returns {Array} Returns the picked values.
  29739. * @example
  29740. *
  29741. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29742. *
  29743. * _.at(object, ['a[0].b.c', 'a[1]']);
  29744. * // => [3, 4]
  29745. */
  29746. var at = flatRest(baseAt);
  29747. /**
  29748. * Creates an object that inherits from the `prototype` object. If a
  29749. * `properties` object is given, its own enumerable string keyed properties
  29750. * are assigned to the created object.
  29751. *
  29752. * @static
  29753. * @memberOf _
  29754. * @since 2.3.0
  29755. * @category Object
  29756. * @param {Object} prototype The object to inherit from.
  29757. * @param {Object} [properties] The properties to assign to the object.
  29758. * @returns {Object} Returns the new object.
  29759. * @example
  29760. *
  29761. * function Shape() {
  29762. * this.x = 0;
  29763. * this.y = 0;
  29764. * }
  29765. *
  29766. * function Circle() {
  29767. * Shape.call(this);
  29768. * }
  29769. *
  29770. * Circle.prototype = _.create(Shape.prototype, {
  29771. * 'constructor': Circle
  29772. * });
  29773. *
  29774. * var circle = new Circle;
  29775. * circle instanceof Circle;
  29776. * // => true
  29777. *
  29778. * circle instanceof Shape;
  29779. * // => true
  29780. */
  29781. function create(prototype, properties) {
  29782. var result = baseCreate(prototype);
  29783. return properties == null ? result : baseAssign(result, properties);
  29784. }
  29785. /**
  29786. * Assigns own and inherited enumerable string keyed properties of source
  29787. * objects to the destination object for all destination properties that
  29788. * resolve to `undefined`. Source objects are applied from left to right.
  29789. * Once a property is set, additional values of the same property are ignored.
  29790. *
  29791. * **Note:** This method mutates `object`.
  29792. *
  29793. * @static
  29794. * @since 0.1.0
  29795. * @memberOf _
  29796. * @category Object
  29797. * @param {Object} object The destination object.
  29798. * @param {...Object} [sources] The source objects.
  29799. * @returns {Object} Returns `object`.
  29800. * @see _.defaultsDeep
  29801. * @example
  29802. *
  29803. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29804. * // => { 'a': 1, 'b': 2 }
  29805. */
  29806. var defaults = baseRest(function(object, sources) {
  29807. object = Object(object);
  29808. var index = -1;
  29809. var length = sources.length;
  29810. var guard = length > 2 ? sources[2] : undefined;
  29811. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29812. length = 1;
  29813. }
  29814. while (++index < length) {
  29815. var source = sources[index];
  29816. var props = keysIn(source);
  29817. var propsIndex = -1;
  29818. var propsLength = props.length;
  29819. while (++propsIndex < propsLength) {
  29820. var key = props[propsIndex];
  29821. var value = object[key];
  29822. if (value === undefined ||
  29823. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29824. object[key] = source[key];
  29825. }
  29826. }
  29827. }
  29828. return object;
  29829. });
  29830. /**
  29831. * This method is like `_.defaults` except that it recursively assigns
  29832. * default properties.
  29833. *
  29834. * **Note:** This method mutates `object`.
  29835. *
  29836. * @static
  29837. * @memberOf _
  29838. * @since 3.10.0
  29839. * @category Object
  29840. * @param {Object} object The destination object.
  29841. * @param {...Object} [sources] The source objects.
  29842. * @returns {Object} Returns `object`.
  29843. * @see _.defaults
  29844. * @example
  29845. *
  29846. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29847. * // => { 'a': { 'b': 2, 'c': 3 } }
  29848. */
  29849. var defaultsDeep = baseRest(function(args) {
  29850. args.push(undefined, customDefaultsMerge);
  29851. return apply(mergeWith, undefined, args);
  29852. });
  29853. /**
  29854. * This method is like `_.find` except that it returns the key of the first
  29855. * element `predicate` returns truthy for instead of the element itself.
  29856. *
  29857. * @static
  29858. * @memberOf _
  29859. * @since 1.1.0
  29860. * @category Object
  29861. * @param {Object} object The object to inspect.
  29862. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29863. * @returns {string|undefined} Returns the key of the matched element,
  29864. * else `undefined`.
  29865. * @example
  29866. *
  29867. * var users = {
  29868. * 'barney': { 'age': 36, 'active': true },
  29869. * 'fred': { 'age': 40, 'active': false },
  29870. * 'pebbles': { 'age': 1, 'active': true }
  29871. * };
  29872. *
  29873. * _.findKey(users, function(o) { return o.age < 40; });
  29874. * // => 'barney' (iteration order is not guaranteed)
  29875. *
  29876. * // The `_.matches` iteratee shorthand.
  29877. * _.findKey(users, { 'age': 1, 'active': true });
  29878. * // => 'pebbles'
  29879. *
  29880. * // The `_.matchesProperty` iteratee shorthand.
  29881. * _.findKey(users, ['active', false]);
  29882. * // => 'fred'
  29883. *
  29884. * // The `_.property` iteratee shorthand.
  29885. * _.findKey(users, 'active');
  29886. * // => 'barney'
  29887. */
  29888. function findKey(object, predicate) {
  29889. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29890. }
  29891. /**
  29892. * This method is like `_.findKey` except that it iterates over elements of
  29893. * a collection in the opposite order.
  29894. *
  29895. * @static
  29896. * @memberOf _
  29897. * @since 2.0.0
  29898. * @category Object
  29899. * @param {Object} object The object to inspect.
  29900. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29901. * @returns {string|undefined} Returns the key of the matched element,
  29902. * else `undefined`.
  29903. * @example
  29904. *
  29905. * var users = {
  29906. * 'barney': { 'age': 36, 'active': true },
  29907. * 'fred': { 'age': 40, 'active': false },
  29908. * 'pebbles': { 'age': 1, 'active': true }
  29909. * };
  29910. *
  29911. * _.findLastKey(users, function(o) { return o.age < 40; });
  29912. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29913. *
  29914. * // The `_.matches` iteratee shorthand.
  29915. * _.findLastKey(users, { 'age': 36, 'active': true });
  29916. * // => 'barney'
  29917. *
  29918. * // The `_.matchesProperty` iteratee shorthand.
  29919. * _.findLastKey(users, ['active', false]);
  29920. * // => 'fred'
  29921. *
  29922. * // The `_.property` iteratee shorthand.
  29923. * _.findLastKey(users, 'active');
  29924. * // => 'pebbles'
  29925. */
  29926. function findLastKey(object, predicate) {
  29927. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29928. }
  29929. /**
  29930. * Iterates over own and inherited enumerable string keyed properties of an
  29931. * object and invokes `iteratee` for each property. The iteratee is invoked
  29932. * with three arguments: (value, key, object). Iteratee functions may exit
  29933. * iteration early by explicitly returning `false`.
  29934. *
  29935. * @static
  29936. * @memberOf _
  29937. * @since 0.3.0
  29938. * @category Object
  29939. * @param {Object} object The object to iterate over.
  29940. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29941. * @returns {Object} Returns `object`.
  29942. * @see _.forInRight
  29943. * @example
  29944. *
  29945. * function Foo() {
  29946. * this.a = 1;
  29947. * this.b = 2;
  29948. * }
  29949. *
  29950. * Foo.prototype.c = 3;
  29951. *
  29952. * _.forIn(new Foo, function(value, key) {
  29953. * console.log(key);
  29954. * });
  29955. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29956. */
  29957. function forIn(object, iteratee) {
  29958. return object == null
  29959. ? object
  29960. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29961. }
  29962. /**
  29963. * This method is like `_.forIn` except that it iterates over properties of
  29964. * `object` in the opposite order.
  29965. *
  29966. * @static
  29967. * @memberOf _
  29968. * @since 2.0.0
  29969. * @category Object
  29970. * @param {Object} object The object to iterate over.
  29971. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29972. * @returns {Object} Returns `object`.
  29973. * @see _.forIn
  29974. * @example
  29975. *
  29976. * function Foo() {
  29977. * this.a = 1;
  29978. * this.b = 2;
  29979. * }
  29980. *
  29981. * Foo.prototype.c = 3;
  29982. *
  29983. * _.forInRight(new Foo, function(value, key) {
  29984. * console.log(key);
  29985. * });
  29986. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29987. */
  29988. function forInRight(object, iteratee) {
  29989. return object == null
  29990. ? object
  29991. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29992. }
  29993. /**
  29994. * Iterates over own enumerable string keyed properties of an object and
  29995. * invokes `iteratee` for each property. The iteratee is invoked with three
  29996. * arguments: (value, key, object). Iteratee functions may exit iteration
  29997. * early by explicitly returning `false`.
  29998. *
  29999. * @static
  30000. * @memberOf _
  30001. * @since 0.3.0
  30002. * @category Object
  30003. * @param {Object} object The object to iterate over.
  30004. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30005. * @returns {Object} Returns `object`.
  30006. * @see _.forOwnRight
  30007. * @example
  30008. *
  30009. * function Foo() {
  30010. * this.a = 1;
  30011. * this.b = 2;
  30012. * }
  30013. *
  30014. * Foo.prototype.c = 3;
  30015. *
  30016. * _.forOwn(new Foo, function(value, key) {
  30017. * console.log(key);
  30018. * });
  30019. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  30020. */
  30021. function forOwn(object, iteratee) {
  30022. return object && baseForOwn(object, getIteratee(iteratee, 3));
  30023. }
  30024. /**
  30025. * This method is like `_.forOwn` except that it iterates over properties of
  30026. * `object` in the opposite order.
  30027. *
  30028. * @static
  30029. * @memberOf _
  30030. * @since 2.0.0
  30031. * @category Object
  30032. * @param {Object} object The object to iterate over.
  30033. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30034. * @returns {Object} Returns `object`.
  30035. * @see _.forOwn
  30036. * @example
  30037. *
  30038. * function Foo() {
  30039. * this.a = 1;
  30040. * this.b = 2;
  30041. * }
  30042. *
  30043. * Foo.prototype.c = 3;
  30044. *
  30045. * _.forOwnRight(new Foo, function(value, key) {
  30046. * console.log(key);
  30047. * });
  30048. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  30049. */
  30050. function forOwnRight(object, iteratee) {
  30051. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  30052. }
  30053. /**
  30054. * Creates an array of function property names from own enumerable properties
  30055. * of `object`.
  30056. *
  30057. * @static
  30058. * @since 0.1.0
  30059. * @memberOf _
  30060. * @category Object
  30061. * @param {Object} object The object to inspect.
  30062. * @returns {Array} Returns the function names.
  30063. * @see _.functionsIn
  30064. * @example
  30065. *
  30066. * function Foo() {
  30067. * this.a = _.constant('a');
  30068. * this.b = _.constant('b');
  30069. * }
  30070. *
  30071. * Foo.prototype.c = _.constant('c');
  30072. *
  30073. * _.functions(new Foo);
  30074. * // => ['a', 'b']
  30075. */
  30076. function functions(object) {
  30077. return object == null ? [] : baseFunctions(object, keys(object));
  30078. }
  30079. /**
  30080. * Creates an array of function property names from own and inherited
  30081. * enumerable properties of `object`.
  30082. *
  30083. * @static
  30084. * @memberOf _
  30085. * @since 4.0.0
  30086. * @category Object
  30087. * @param {Object} object The object to inspect.
  30088. * @returns {Array} Returns the function names.
  30089. * @see _.functions
  30090. * @example
  30091. *
  30092. * function Foo() {
  30093. * this.a = _.constant('a');
  30094. * this.b = _.constant('b');
  30095. * }
  30096. *
  30097. * Foo.prototype.c = _.constant('c');
  30098. *
  30099. * _.functionsIn(new Foo);
  30100. * // => ['a', 'b', 'c']
  30101. */
  30102. function functionsIn(object) {
  30103. return object == null ? [] : baseFunctions(object, keysIn(object));
  30104. }
  30105. /**
  30106. * Gets the value at `path` of `object`. If the resolved value is
  30107. * `undefined`, the `defaultValue` is returned in its place.
  30108. *
  30109. * @static
  30110. * @memberOf _
  30111. * @since 3.7.0
  30112. * @category Object
  30113. * @param {Object} object The object to query.
  30114. * @param {Array|string} path The path of the property to get.
  30115. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30116. * @returns {*} Returns the resolved value.
  30117. * @example
  30118. *
  30119. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30120. *
  30121. * _.get(object, 'a[0].b.c');
  30122. * // => 3
  30123. *
  30124. * _.get(object, ['a', '0', 'b', 'c']);
  30125. * // => 3
  30126. *
  30127. * _.get(object, 'a.b.c', 'default');
  30128. * // => 'default'
  30129. */
  30130. function get(object, path, defaultValue) {
  30131. var result = object == null ? undefined : baseGet(object, path);
  30132. return result === undefined ? defaultValue : result;
  30133. }
  30134. /**
  30135. * Checks if `path` is a direct property of `object`.
  30136. *
  30137. * @static
  30138. * @since 0.1.0
  30139. * @memberOf _
  30140. * @category Object
  30141. * @param {Object} object The object to query.
  30142. * @param {Array|string} path The path to check.
  30143. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30144. * @example
  30145. *
  30146. * var object = { 'a': { 'b': 2 } };
  30147. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30148. *
  30149. * _.has(object, 'a');
  30150. * // => true
  30151. *
  30152. * _.has(object, 'a.b');
  30153. * // => true
  30154. *
  30155. * _.has(object, ['a', 'b']);
  30156. * // => true
  30157. *
  30158. * _.has(other, 'a');
  30159. * // => false
  30160. */
  30161. function has(object, path) {
  30162. return object != null && hasPath(object, path, baseHas);
  30163. }
  30164. /**
  30165. * Checks if `path` is a direct or inherited property of `object`.
  30166. *
  30167. * @static
  30168. * @memberOf _
  30169. * @since 4.0.0
  30170. * @category Object
  30171. * @param {Object} object The object to query.
  30172. * @param {Array|string} path The path to check.
  30173. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30174. * @example
  30175. *
  30176. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30177. *
  30178. * _.hasIn(object, 'a');
  30179. * // => true
  30180. *
  30181. * _.hasIn(object, 'a.b');
  30182. * // => true
  30183. *
  30184. * _.hasIn(object, ['a', 'b']);
  30185. * // => true
  30186. *
  30187. * _.hasIn(object, 'b');
  30188. * // => false
  30189. */
  30190. function hasIn(object, path) {
  30191. return object != null && hasPath(object, path, baseHasIn);
  30192. }
  30193. /**
  30194. * Creates an object composed of the inverted keys and values of `object`.
  30195. * If `object` contains duplicate values, subsequent values overwrite
  30196. * property assignments of previous values.
  30197. *
  30198. * @static
  30199. * @memberOf _
  30200. * @since 0.7.0
  30201. * @category Object
  30202. * @param {Object} object The object to invert.
  30203. * @returns {Object} Returns the new inverted object.
  30204. * @example
  30205. *
  30206. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30207. *
  30208. * _.invert(object);
  30209. * // => { '1': 'c', '2': 'b' }
  30210. */
  30211. var invert = createInverter(function(result, value, key) {
  30212. if (value != null &&
  30213. typeof value.toString != 'function') {
  30214. value = nativeObjectToString.call(value);
  30215. }
  30216. result[value] = key;
  30217. }, constant(identity));
  30218. /**
  30219. * This method is like `_.invert` except that the inverted object is generated
  30220. * from the results of running each element of `object` thru `iteratee`. The
  30221. * corresponding inverted value of each inverted key is an array of keys
  30222. * responsible for generating the inverted value. The iteratee is invoked
  30223. * with one argument: (value).
  30224. *
  30225. * @static
  30226. * @memberOf _
  30227. * @since 4.1.0
  30228. * @category Object
  30229. * @param {Object} object The object to invert.
  30230. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30231. * @returns {Object} Returns the new inverted object.
  30232. * @example
  30233. *
  30234. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30235. *
  30236. * _.invertBy(object);
  30237. * // => { '1': ['a', 'c'], '2': ['b'] }
  30238. *
  30239. * _.invertBy(object, function(value) {
  30240. * return 'group' + value;
  30241. * });
  30242. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30243. */
  30244. var invertBy = createInverter(function(result, value, key) {
  30245. if (value != null &&
  30246. typeof value.toString != 'function') {
  30247. value = nativeObjectToString.call(value);
  30248. }
  30249. if (hasOwnProperty.call(result, value)) {
  30250. result[value].push(key);
  30251. } else {
  30252. result[value] = [key];
  30253. }
  30254. }, getIteratee);
  30255. /**
  30256. * Invokes the method at `path` of `object`.
  30257. *
  30258. * @static
  30259. * @memberOf _
  30260. * @since 4.0.0
  30261. * @category Object
  30262. * @param {Object} object The object to query.
  30263. * @param {Array|string} path The path of the method to invoke.
  30264. * @param {...*} [args] The arguments to invoke the method with.
  30265. * @returns {*} Returns the result of the invoked method.
  30266. * @example
  30267. *
  30268. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30269. *
  30270. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30271. * // => [2, 3]
  30272. */
  30273. var invoke = baseRest(baseInvoke);
  30274. /**
  30275. * Creates an array of the own enumerable property names of `object`.
  30276. *
  30277. * **Note:** Non-object values are coerced to objects. See the
  30278. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30279. * for more details.
  30280. *
  30281. * @static
  30282. * @since 0.1.0
  30283. * @memberOf _
  30284. * @category Object
  30285. * @param {Object} object The object to query.
  30286. * @returns {Array} Returns the array of property names.
  30287. * @example
  30288. *
  30289. * function Foo() {
  30290. * this.a = 1;
  30291. * this.b = 2;
  30292. * }
  30293. *
  30294. * Foo.prototype.c = 3;
  30295. *
  30296. * _.keys(new Foo);
  30297. * // => ['a', 'b'] (iteration order is not guaranteed)
  30298. *
  30299. * _.keys('hi');
  30300. * // => ['0', '1']
  30301. */
  30302. function keys(object) {
  30303. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30304. }
  30305. /**
  30306. * Creates an array of the own and inherited enumerable property names of `object`.
  30307. *
  30308. * **Note:** Non-object values are coerced to objects.
  30309. *
  30310. * @static
  30311. * @memberOf _
  30312. * @since 3.0.0
  30313. * @category Object
  30314. * @param {Object} object The object to query.
  30315. * @returns {Array} Returns the array of property names.
  30316. * @example
  30317. *
  30318. * function Foo() {
  30319. * this.a = 1;
  30320. * this.b = 2;
  30321. * }
  30322. *
  30323. * Foo.prototype.c = 3;
  30324. *
  30325. * _.keysIn(new Foo);
  30326. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30327. */
  30328. function keysIn(object) {
  30329. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30330. }
  30331. /**
  30332. * The opposite of `_.mapValues`; this method creates an object with the
  30333. * same values as `object` and keys generated by running each own enumerable
  30334. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30335. * with three arguments: (value, key, object).
  30336. *
  30337. * @static
  30338. * @memberOf _
  30339. * @since 3.8.0
  30340. * @category Object
  30341. * @param {Object} object The object to iterate over.
  30342. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30343. * @returns {Object} Returns the new mapped object.
  30344. * @see _.mapValues
  30345. * @example
  30346. *
  30347. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30348. * return key + value;
  30349. * });
  30350. * // => { 'a1': 1, 'b2': 2 }
  30351. */
  30352. function mapKeys(object, iteratee) {
  30353. var result = {};
  30354. iteratee = getIteratee(iteratee, 3);
  30355. baseForOwn(object, function(value, key, object) {
  30356. baseAssignValue(result, iteratee(value, key, object), value);
  30357. });
  30358. return result;
  30359. }
  30360. /**
  30361. * Creates an object with the same keys as `object` and values generated
  30362. * by running each own enumerable string keyed property of `object` thru
  30363. * `iteratee`. The iteratee is invoked with three arguments:
  30364. * (value, key, object).
  30365. *
  30366. * @static
  30367. * @memberOf _
  30368. * @since 2.4.0
  30369. * @category Object
  30370. * @param {Object} object The object to iterate over.
  30371. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30372. * @returns {Object} Returns the new mapped object.
  30373. * @see _.mapKeys
  30374. * @example
  30375. *
  30376. * var users = {
  30377. * 'fred': { 'user': 'fred', 'age': 40 },
  30378. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30379. * };
  30380. *
  30381. * _.mapValues(users, function(o) { return o.age; });
  30382. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30383. *
  30384. * // The `_.property` iteratee shorthand.
  30385. * _.mapValues(users, 'age');
  30386. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30387. */
  30388. function mapValues(object, iteratee) {
  30389. var result = {};
  30390. iteratee = getIteratee(iteratee, 3);
  30391. baseForOwn(object, function(value, key, object) {
  30392. baseAssignValue(result, key, iteratee(value, key, object));
  30393. });
  30394. return result;
  30395. }
  30396. /**
  30397. * This method is like `_.assign` except that it recursively merges own and
  30398. * inherited enumerable string keyed properties of source objects into the
  30399. * destination object. Source properties that resolve to `undefined` are
  30400. * skipped if a destination value exists. Array and plain object properties
  30401. * are merged recursively. Other objects and value types are overridden by
  30402. * assignment. Source objects are applied from left to right. Subsequent
  30403. * sources overwrite property assignments of previous sources.
  30404. *
  30405. * **Note:** This method mutates `object`.
  30406. *
  30407. * @static
  30408. * @memberOf _
  30409. * @since 0.5.0
  30410. * @category Object
  30411. * @param {Object} object The destination object.
  30412. * @param {...Object} [sources] The source objects.
  30413. * @returns {Object} Returns `object`.
  30414. * @example
  30415. *
  30416. * var object = {
  30417. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30418. * };
  30419. *
  30420. * var other = {
  30421. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30422. * };
  30423. *
  30424. * _.merge(object, other);
  30425. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30426. */
  30427. var merge = createAssigner(function(object, source, srcIndex) {
  30428. baseMerge(object, source, srcIndex);
  30429. });
  30430. /**
  30431. * This method is like `_.merge` except that it accepts `customizer` which
  30432. * is invoked to produce the merged values of the destination and source
  30433. * properties. If `customizer` returns `undefined`, merging is handled by the
  30434. * method instead. The `customizer` is invoked with six arguments:
  30435. * (objValue, srcValue, key, object, source, stack).
  30436. *
  30437. * **Note:** This method mutates `object`.
  30438. *
  30439. * @static
  30440. * @memberOf _
  30441. * @since 4.0.0
  30442. * @category Object
  30443. * @param {Object} object The destination object.
  30444. * @param {...Object} sources The source objects.
  30445. * @param {Function} customizer The function to customize assigned values.
  30446. * @returns {Object} Returns `object`.
  30447. * @example
  30448. *
  30449. * function customizer(objValue, srcValue) {
  30450. * if (_.isArray(objValue)) {
  30451. * return objValue.concat(srcValue);
  30452. * }
  30453. * }
  30454. *
  30455. * var object = { 'a': [1], 'b': [2] };
  30456. * var other = { 'a': [3], 'b': [4] };
  30457. *
  30458. * _.mergeWith(object, other, customizer);
  30459. * // => { 'a': [1, 3], 'b': [2, 4] }
  30460. */
  30461. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30462. baseMerge(object, source, srcIndex, customizer);
  30463. });
  30464. /**
  30465. * The opposite of `_.pick`; this method creates an object composed of the
  30466. * own and inherited enumerable property paths of `object` that are not omitted.
  30467. *
  30468. * **Note:** This method is considerably slower than `_.pick`.
  30469. *
  30470. * @static
  30471. * @since 0.1.0
  30472. * @memberOf _
  30473. * @category Object
  30474. * @param {Object} object The source object.
  30475. * @param {...(string|string[])} [paths] The property paths to omit.
  30476. * @returns {Object} Returns the new object.
  30477. * @example
  30478. *
  30479. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30480. *
  30481. * _.omit(object, ['a', 'c']);
  30482. * // => { 'b': '2' }
  30483. */
  30484. var omit = flatRest(function(object, paths) {
  30485. var result = {};
  30486. if (object == null) {
  30487. return result;
  30488. }
  30489. var isDeep = false;
  30490. paths = arrayMap(paths, function(path) {
  30491. path = castPath(path, object);
  30492. isDeep || (isDeep = path.length > 1);
  30493. return path;
  30494. });
  30495. copyObject(object, getAllKeysIn(object), result);
  30496. if (isDeep) {
  30497. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30498. }
  30499. var length = paths.length;
  30500. while (length--) {
  30501. baseUnset(result, paths[length]);
  30502. }
  30503. return result;
  30504. });
  30505. /**
  30506. * The opposite of `_.pickBy`; this method creates an object composed of
  30507. * the own and inherited enumerable string keyed properties of `object` that
  30508. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30509. * arguments: (value, key).
  30510. *
  30511. * @static
  30512. * @memberOf _
  30513. * @since 4.0.0
  30514. * @category Object
  30515. * @param {Object} object The source object.
  30516. * @param {Function} [predicate=_.identity] The function invoked per property.
  30517. * @returns {Object} Returns the new object.
  30518. * @example
  30519. *
  30520. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30521. *
  30522. * _.omitBy(object, _.isNumber);
  30523. * // => { 'b': '2' }
  30524. */
  30525. function omitBy(object, predicate) {
  30526. return pickBy(object, negate(getIteratee(predicate)));
  30527. }
  30528. /**
  30529. * Creates an object composed of the picked `object` properties.
  30530. *
  30531. * @static
  30532. * @since 0.1.0
  30533. * @memberOf _
  30534. * @category Object
  30535. * @param {Object} object The source object.
  30536. * @param {...(string|string[])} [paths] The property paths to pick.
  30537. * @returns {Object} Returns the new object.
  30538. * @example
  30539. *
  30540. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30541. *
  30542. * _.pick(object, ['a', 'c']);
  30543. * // => { 'a': 1, 'c': 3 }
  30544. */
  30545. var pick = flatRest(function(object, paths) {
  30546. return object == null ? {} : basePick(object, paths);
  30547. });
  30548. /**
  30549. * Creates an object composed of the `object` properties `predicate` returns
  30550. * truthy for. The predicate is invoked with two arguments: (value, key).
  30551. *
  30552. * @static
  30553. * @memberOf _
  30554. * @since 4.0.0
  30555. * @category Object
  30556. * @param {Object} object The source object.
  30557. * @param {Function} [predicate=_.identity] The function invoked per property.
  30558. * @returns {Object} Returns the new object.
  30559. * @example
  30560. *
  30561. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30562. *
  30563. * _.pickBy(object, _.isNumber);
  30564. * // => { 'a': 1, 'c': 3 }
  30565. */
  30566. function pickBy(object, predicate) {
  30567. if (object == null) {
  30568. return {};
  30569. }
  30570. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30571. return [prop];
  30572. });
  30573. predicate = getIteratee(predicate);
  30574. return basePickBy(object, props, function(value, path) {
  30575. return predicate(value, path[0]);
  30576. });
  30577. }
  30578. /**
  30579. * This method is like `_.get` except that if the resolved value is a
  30580. * function it's invoked with the `this` binding of its parent object and
  30581. * its result is returned.
  30582. *
  30583. * @static
  30584. * @since 0.1.0
  30585. * @memberOf _
  30586. * @category Object
  30587. * @param {Object} object The object to query.
  30588. * @param {Array|string} path The path of the property to resolve.
  30589. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30590. * @returns {*} Returns the resolved value.
  30591. * @example
  30592. *
  30593. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30594. *
  30595. * _.result(object, 'a[0].b.c1');
  30596. * // => 3
  30597. *
  30598. * _.result(object, 'a[0].b.c2');
  30599. * // => 4
  30600. *
  30601. * _.result(object, 'a[0].b.c3', 'default');
  30602. * // => 'default'
  30603. *
  30604. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30605. * // => 'default'
  30606. */
  30607. function result(object, path, defaultValue) {
  30608. path = castPath(path, object);
  30609. var index = -1,
  30610. length = path.length;
  30611. // Ensure the loop is entered when path is empty.
  30612. if (!length) {
  30613. length = 1;
  30614. object = undefined;
  30615. }
  30616. while (++index < length) {
  30617. var value = object == null ? undefined : object[toKey(path[index])];
  30618. if (value === undefined) {
  30619. index = length;
  30620. value = defaultValue;
  30621. }
  30622. object = isFunction(value) ? value.call(object) : value;
  30623. }
  30624. return object;
  30625. }
  30626. /**
  30627. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30628. * it's created. Arrays are created for missing index properties while objects
  30629. * are created for all other missing properties. Use `_.setWith` to customize
  30630. * `path` creation.
  30631. *
  30632. * **Note:** This method mutates `object`.
  30633. *
  30634. * @static
  30635. * @memberOf _
  30636. * @since 3.7.0
  30637. * @category Object
  30638. * @param {Object} object The object to modify.
  30639. * @param {Array|string} path The path of the property to set.
  30640. * @param {*} value The value to set.
  30641. * @returns {Object} Returns `object`.
  30642. * @example
  30643. *
  30644. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30645. *
  30646. * _.set(object, 'a[0].b.c', 4);
  30647. * console.log(object.a[0].b.c);
  30648. * // => 4
  30649. *
  30650. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30651. * console.log(object.x[0].y.z);
  30652. * // => 5
  30653. */
  30654. function set(object, path, value) {
  30655. return object == null ? object : baseSet(object, path, value);
  30656. }
  30657. /**
  30658. * This method is like `_.set` except that it accepts `customizer` which is
  30659. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30660. * path creation is handled by the method instead. The `customizer` is invoked
  30661. * with three arguments: (nsValue, key, nsObject).
  30662. *
  30663. * **Note:** This method mutates `object`.
  30664. *
  30665. * @static
  30666. * @memberOf _
  30667. * @since 4.0.0
  30668. * @category Object
  30669. * @param {Object} object The object to modify.
  30670. * @param {Array|string} path The path of the property to set.
  30671. * @param {*} value The value to set.
  30672. * @param {Function} [customizer] The function to customize assigned values.
  30673. * @returns {Object} Returns `object`.
  30674. * @example
  30675. *
  30676. * var object = {};
  30677. *
  30678. * _.setWith(object, '[0][1]', 'a', Object);
  30679. * // => { '0': { '1': 'a' } }
  30680. */
  30681. function setWith(object, path, value, customizer) {
  30682. customizer = typeof customizer == 'function' ? customizer : undefined;
  30683. return object == null ? object : baseSet(object, path, value, customizer);
  30684. }
  30685. /**
  30686. * Creates an array of own enumerable string keyed-value pairs for `object`
  30687. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30688. * entries are returned.
  30689. *
  30690. * @static
  30691. * @memberOf _
  30692. * @since 4.0.0
  30693. * @alias entries
  30694. * @category Object
  30695. * @param {Object} object The object to query.
  30696. * @returns {Array} Returns the key-value pairs.
  30697. * @example
  30698. *
  30699. * function Foo() {
  30700. * this.a = 1;
  30701. * this.b = 2;
  30702. * }
  30703. *
  30704. * Foo.prototype.c = 3;
  30705. *
  30706. * _.toPairs(new Foo);
  30707. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30708. */
  30709. var toPairs = createToPairs(keys);
  30710. /**
  30711. * Creates an array of own and inherited enumerable string keyed-value pairs
  30712. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30713. * or set, its entries are returned.
  30714. *
  30715. * @static
  30716. * @memberOf _
  30717. * @since 4.0.0
  30718. * @alias entriesIn
  30719. * @category Object
  30720. * @param {Object} object The object to query.
  30721. * @returns {Array} Returns the key-value pairs.
  30722. * @example
  30723. *
  30724. * function Foo() {
  30725. * this.a = 1;
  30726. * this.b = 2;
  30727. * }
  30728. *
  30729. * Foo.prototype.c = 3;
  30730. *
  30731. * _.toPairsIn(new Foo);
  30732. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30733. */
  30734. var toPairsIn = createToPairs(keysIn);
  30735. /**
  30736. * An alternative to `_.reduce`; this method transforms `object` to a new
  30737. * `accumulator` object which is the result of running each of its own
  30738. * enumerable string keyed properties thru `iteratee`, with each invocation
  30739. * potentially mutating the `accumulator` object. If `accumulator` is not
  30740. * provided, a new object with the same `[[Prototype]]` will be used. The
  30741. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30742. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30743. *
  30744. * @static
  30745. * @memberOf _
  30746. * @since 1.3.0
  30747. * @category Object
  30748. * @param {Object} object The object to iterate over.
  30749. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30750. * @param {*} [accumulator] The custom accumulator value.
  30751. * @returns {*} Returns the accumulated value.
  30752. * @example
  30753. *
  30754. * _.transform([2, 3, 4], function(result, n) {
  30755. * result.push(n *= n);
  30756. * return n % 2 == 0;
  30757. * }, []);
  30758. * // => [4, 9]
  30759. *
  30760. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30761. * (result[value] || (result[value] = [])).push(key);
  30762. * }, {});
  30763. * // => { '1': ['a', 'c'], '2': ['b'] }
  30764. */
  30765. function transform(object, iteratee, accumulator) {
  30766. var isArr = isArray(object),
  30767. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30768. iteratee = getIteratee(iteratee, 4);
  30769. if (accumulator == null) {
  30770. var Ctor = object && object.constructor;
  30771. if (isArrLike) {
  30772. accumulator = isArr ? new Ctor : [];
  30773. }
  30774. else if (isObject(object)) {
  30775. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30776. }
  30777. else {
  30778. accumulator = {};
  30779. }
  30780. }
  30781. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30782. return iteratee(accumulator, value, index, object);
  30783. });
  30784. return accumulator;
  30785. }
  30786. /**
  30787. * Removes the property at `path` of `object`.
  30788. *
  30789. * **Note:** This method mutates `object`.
  30790. *
  30791. * @static
  30792. * @memberOf _
  30793. * @since 4.0.0
  30794. * @category Object
  30795. * @param {Object} object The object to modify.
  30796. * @param {Array|string} path The path of the property to unset.
  30797. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30798. * @example
  30799. *
  30800. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30801. * _.unset(object, 'a[0].b.c');
  30802. * // => true
  30803. *
  30804. * console.log(object);
  30805. * // => { 'a': [{ 'b': {} }] };
  30806. *
  30807. * _.unset(object, ['a', '0', 'b', 'c']);
  30808. * // => true
  30809. *
  30810. * console.log(object);
  30811. * // => { 'a': [{ 'b': {} }] };
  30812. */
  30813. function unset(object, path) {
  30814. return object == null ? true : baseUnset(object, path);
  30815. }
  30816. /**
  30817. * This method is like `_.set` except that accepts `updater` to produce the
  30818. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30819. * is invoked with one argument: (value).
  30820. *
  30821. * **Note:** This method mutates `object`.
  30822. *
  30823. * @static
  30824. * @memberOf _
  30825. * @since 4.6.0
  30826. * @category Object
  30827. * @param {Object} object The object to modify.
  30828. * @param {Array|string} path The path of the property to set.
  30829. * @param {Function} updater The function to produce the updated value.
  30830. * @returns {Object} Returns `object`.
  30831. * @example
  30832. *
  30833. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30834. *
  30835. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30836. * console.log(object.a[0].b.c);
  30837. * // => 9
  30838. *
  30839. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30840. * console.log(object.x[0].y.z);
  30841. * // => 0
  30842. */
  30843. function update(object, path, updater) {
  30844. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30845. }
  30846. /**
  30847. * This method is like `_.update` except that it accepts `customizer` which is
  30848. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30849. * path creation is handled by the method instead. The `customizer` is invoked
  30850. * with three arguments: (nsValue, key, nsObject).
  30851. *
  30852. * **Note:** This method mutates `object`.
  30853. *
  30854. * @static
  30855. * @memberOf _
  30856. * @since 4.6.0
  30857. * @category Object
  30858. * @param {Object} object The object to modify.
  30859. * @param {Array|string} path The path of the property to set.
  30860. * @param {Function} updater The function to produce the updated value.
  30861. * @param {Function} [customizer] The function to customize assigned values.
  30862. * @returns {Object} Returns `object`.
  30863. * @example
  30864. *
  30865. * var object = {};
  30866. *
  30867. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30868. * // => { '0': { '1': 'a' } }
  30869. */
  30870. function updateWith(object, path, updater, customizer) {
  30871. customizer = typeof customizer == 'function' ? customizer : undefined;
  30872. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30873. }
  30874. /**
  30875. * Creates an array of the own enumerable string keyed property values of `object`.
  30876. *
  30877. * **Note:** Non-object values are coerced to objects.
  30878. *
  30879. * @static
  30880. * @since 0.1.0
  30881. * @memberOf _
  30882. * @category Object
  30883. * @param {Object} object The object to query.
  30884. * @returns {Array} Returns the array of property values.
  30885. * @example
  30886. *
  30887. * function Foo() {
  30888. * this.a = 1;
  30889. * this.b = 2;
  30890. * }
  30891. *
  30892. * Foo.prototype.c = 3;
  30893. *
  30894. * _.values(new Foo);
  30895. * // => [1, 2] (iteration order is not guaranteed)
  30896. *
  30897. * _.values('hi');
  30898. * // => ['h', 'i']
  30899. */
  30900. function values(object) {
  30901. return object == null ? [] : baseValues(object, keys(object));
  30902. }
  30903. /**
  30904. * Creates an array of the own and inherited enumerable string keyed property
  30905. * values of `object`.
  30906. *
  30907. * **Note:** Non-object values are coerced to objects.
  30908. *
  30909. * @static
  30910. * @memberOf _
  30911. * @since 3.0.0
  30912. * @category Object
  30913. * @param {Object} object The object to query.
  30914. * @returns {Array} Returns the array of property values.
  30915. * @example
  30916. *
  30917. * function Foo() {
  30918. * this.a = 1;
  30919. * this.b = 2;
  30920. * }
  30921. *
  30922. * Foo.prototype.c = 3;
  30923. *
  30924. * _.valuesIn(new Foo);
  30925. * // => [1, 2, 3] (iteration order is not guaranteed)
  30926. */
  30927. function valuesIn(object) {
  30928. return object == null ? [] : baseValues(object, keysIn(object));
  30929. }
  30930. /*------------------------------------------------------------------------*/
  30931. /**
  30932. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30933. *
  30934. * @static
  30935. * @memberOf _
  30936. * @since 4.0.0
  30937. * @category Number
  30938. * @param {number} number The number to clamp.
  30939. * @param {number} [lower] The lower bound.
  30940. * @param {number} upper The upper bound.
  30941. * @returns {number} Returns the clamped number.
  30942. * @example
  30943. *
  30944. * _.clamp(-10, -5, 5);
  30945. * // => -5
  30946. *
  30947. * _.clamp(10, -5, 5);
  30948. * // => 5
  30949. */
  30950. function clamp(number, lower, upper) {
  30951. if (upper === undefined) {
  30952. upper = lower;
  30953. lower = undefined;
  30954. }
  30955. if (upper !== undefined) {
  30956. upper = toNumber(upper);
  30957. upper = upper === upper ? upper : 0;
  30958. }
  30959. if (lower !== undefined) {
  30960. lower = toNumber(lower);
  30961. lower = lower === lower ? lower : 0;
  30962. }
  30963. return baseClamp(toNumber(number), lower, upper);
  30964. }
  30965. /**
  30966. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30967. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30968. * If `start` is greater than `end` the params are swapped to support
  30969. * negative ranges.
  30970. *
  30971. * @static
  30972. * @memberOf _
  30973. * @since 3.3.0
  30974. * @category Number
  30975. * @param {number} number The number to check.
  30976. * @param {number} [start=0] The start of the range.
  30977. * @param {number} end The end of the range.
  30978. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30979. * @see _.range, _.rangeRight
  30980. * @example
  30981. *
  30982. * _.inRange(3, 2, 4);
  30983. * // => true
  30984. *
  30985. * _.inRange(4, 8);
  30986. * // => true
  30987. *
  30988. * _.inRange(4, 2);
  30989. * // => false
  30990. *
  30991. * _.inRange(2, 2);
  30992. * // => false
  30993. *
  30994. * _.inRange(1.2, 2);
  30995. * // => true
  30996. *
  30997. * _.inRange(5.2, 4);
  30998. * // => false
  30999. *
  31000. * _.inRange(-3, -2, -6);
  31001. * // => true
  31002. */
  31003. function inRange(number, start, end) {
  31004. start = toFinite(start);
  31005. if (end === undefined) {
  31006. end = start;
  31007. start = 0;
  31008. } else {
  31009. end = toFinite(end);
  31010. }
  31011. number = toNumber(number);
  31012. return baseInRange(number, start, end);
  31013. }
  31014. /**
  31015. * Produces a random number between the inclusive `lower` and `upper` bounds.
  31016. * If only one argument is provided a number between `0` and the given number
  31017. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  31018. * floats, a floating-point number is returned instead of an integer.
  31019. *
  31020. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31021. * floating-point values which can produce unexpected results.
  31022. *
  31023. * @static
  31024. * @memberOf _
  31025. * @since 0.7.0
  31026. * @category Number
  31027. * @param {number} [lower=0] The lower bound.
  31028. * @param {number} [upper=1] The upper bound.
  31029. * @param {boolean} [floating] Specify returning a floating-point number.
  31030. * @returns {number} Returns the random number.
  31031. * @example
  31032. *
  31033. * _.random(0, 5);
  31034. * // => an integer between 0 and 5
  31035. *
  31036. * _.random(5);
  31037. * // => also an integer between 0 and 5
  31038. *
  31039. * _.random(5, true);
  31040. * // => a floating-point number between 0 and 5
  31041. *
  31042. * _.random(1.2, 5.2);
  31043. * // => a floating-point number between 1.2 and 5.2
  31044. */
  31045. function random(lower, upper, floating) {
  31046. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  31047. upper = floating = undefined;
  31048. }
  31049. if (floating === undefined) {
  31050. if (typeof upper == 'boolean') {
  31051. floating = upper;
  31052. upper = undefined;
  31053. }
  31054. else if (typeof lower == 'boolean') {
  31055. floating = lower;
  31056. lower = undefined;
  31057. }
  31058. }
  31059. if (lower === undefined && upper === undefined) {
  31060. lower = 0;
  31061. upper = 1;
  31062. }
  31063. else {
  31064. lower = toFinite(lower);
  31065. if (upper === undefined) {
  31066. upper = lower;
  31067. lower = 0;
  31068. } else {
  31069. upper = toFinite(upper);
  31070. }
  31071. }
  31072. if (lower > upper) {
  31073. var temp = lower;
  31074. lower = upper;
  31075. upper = temp;
  31076. }
  31077. if (floating || lower % 1 || upper % 1) {
  31078. var rand = nativeRandom();
  31079. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  31080. }
  31081. return baseRandom(lower, upper);
  31082. }
  31083. /*------------------------------------------------------------------------*/
  31084. /**
  31085. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  31086. *
  31087. * @static
  31088. * @memberOf _
  31089. * @since 3.0.0
  31090. * @category String
  31091. * @param {string} [string=''] The string to convert.
  31092. * @returns {string} Returns the camel cased string.
  31093. * @example
  31094. *
  31095. * _.camelCase('Foo Bar');
  31096. * // => 'fooBar'
  31097. *
  31098. * _.camelCase('--foo-bar--');
  31099. * // => 'fooBar'
  31100. *
  31101. * _.camelCase('__FOO_BAR__');
  31102. * // => 'fooBar'
  31103. */
  31104. var camelCase = createCompounder(function(result, word, index) {
  31105. word = word.toLowerCase();
  31106. return result + (index ? capitalize(word) : word);
  31107. });
  31108. /**
  31109. * Converts the first character of `string` to upper case and the remaining
  31110. * to lower case.
  31111. *
  31112. * @static
  31113. * @memberOf _
  31114. * @since 3.0.0
  31115. * @category String
  31116. * @param {string} [string=''] The string to capitalize.
  31117. * @returns {string} Returns the capitalized string.
  31118. * @example
  31119. *
  31120. * _.capitalize('FRED');
  31121. * // => 'Fred'
  31122. */
  31123. function capitalize(string) {
  31124. return upperFirst(toString(string).toLowerCase());
  31125. }
  31126. /**
  31127. * Deburrs `string` by converting
  31128. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31129. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31130. * letters to basic Latin letters and removing
  31131. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31132. *
  31133. * @static
  31134. * @memberOf _
  31135. * @since 3.0.0
  31136. * @category String
  31137. * @param {string} [string=''] The string to deburr.
  31138. * @returns {string} Returns the deburred string.
  31139. * @example
  31140. *
  31141. * _.deburr('déjà vu');
  31142. * // => 'deja vu'
  31143. */
  31144. function deburr(string) {
  31145. string = toString(string);
  31146. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31147. }
  31148. /**
  31149. * Checks if `string` ends with the given target string.
  31150. *
  31151. * @static
  31152. * @memberOf _
  31153. * @since 3.0.0
  31154. * @category String
  31155. * @param {string} [string=''] The string to inspect.
  31156. * @param {string} [target] The string to search for.
  31157. * @param {number} [position=string.length] The position to search up to.
  31158. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31159. * else `false`.
  31160. * @example
  31161. *
  31162. * _.endsWith('abc', 'c');
  31163. * // => true
  31164. *
  31165. * _.endsWith('abc', 'b');
  31166. * // => false
  31167. *
  31168. * _.endsWith('abc', 'b', 2);
  31169. * // => true
  31170. */
  31171. function endsWith(string, target, position) {
  31172. string = toString(string);
  31173. target = baseToString(target);
  31174. var length = string.length;
  31175. position = position === undefined
  31176. ? length
  31177. : baseClamp(toInteger(position), 0, length);
  31178. var end = position;
  31179. position -= target.length;
  31180. return position >= 0 && string.slice(position, end) == target;
  31181. }
  31182. /**
  31183. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31184. * corresponding HTML entities.
  31185. *
  31186. * **Note:** No other characters are escaped. To escape additional
  31187. * characters use a third-party library like [_he_](https://mths.be/he).
  31188. *
  31189. * Though the ">" character is escaped for symmetry, characters like
  31190. * ">" and "/" don't need escaping in HTML and have no special meaning
  31191. * unless they're part of a tag or unquoted attribute value. See
  31192. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31193. * (under "semi-related fun fact") for more details.
  31194. *
  31195. * When working with HTML you should always
  31196. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31197. * XSS vectors.
  31198. *
  31199. * @static
  31200. * @since 0.1.0
  31201. * @memberOf _
  31202. * @category String
  31203. * @param {string} [string=''] The string to escape.
  31204. * @returns {string} Returns the escaped string.
  31205. * @example
  31206. *
  31207. * _.escape('fred, barney, & pebbles');
  31208. * // => 'fred, barney, &amp; pebbles'
  31209. */
  31210. function escape(string) {
  31211. string = toString(string);
  31212. return (string && reHasUnescapedHtml.test(string))
  31213. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31214. : string;
  31215. }
  31216. /**
  31217. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31218. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31219. *
  31220. * @static
  31221. * @memberOf _
  31222. * @since 3.0.0
  31223. * @category String
  31224. * @param {string} [string=''] The string to escape.
  31225. * @returns {string} Returns the escaped string.
  31226. * @example
  31227. *
  31228. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31229. * // => '\[lodash\]\(https://lodash\.com/\)'
  31230. */
  31231. function escapeRegExp(string) {
  31232. string = toString(string);
  31233. return (string && reHasRegExpChar.test(string))
  31234. ? string.replace(reRegExpChar, '\\$&')
  31235. : string;
  31236. }
  31237. /**
  31238. * Converts `string` to
  31239. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31240. *
  31241. * @static
  31242. * @memberOf _
  31243. * @since 3.0.0
  31244. * @category String
  31245. * @param {string} [string=''] The string to convert.
  31246. * @returns {string} Returns the kebab cased string.
  31247. * @example
  31248. *
  31249. * _.kebabCase('Foo Bar');
  31250. * // => 'foo-bar'
  31251. *
  31252. * _.kebabCase('fooBar');
  31253. * // => 'foo-bar'
  31254. *
  31255. * _.kebabCase('__FOO_BAR__');
  31256. * // => 'foo-bar'
  31257. */
  31258. var kebabCase = createCompounder(function(result, word, index) {
  31259. return result + (index ? '-' : '') + word.toLowerCase();
  31260. });
  31261. /**
  31262. * Converts `string`, as space separated words, to lower case.
  31263. *
  31264. * @static
  31265. * @memberOf _
  31266. * @since 4.0.0
  31267. * @category String
  31268. * @param {string} [string=''] The string to convert.
  31269. * @returns {string} Returns the lower cased string.
  31270. * @example
  31271. *
  31272. * _.lowerCase('--Foo-Bar--');
  31273. * // => 'foo bar'
  31274. *
  31275. * _.lowerCase('fooBar');
  31276. * // => 'foo bar'
  31277. *
  31278. * _.lowerCase('__FOO_BAR__');
  31279. * // => 'foo bar'
  31280. */
  31281. var lowerCase = createCompounder(function(result, word, index) {
  31282. return result + (index ? ' ' : '') + word.toLowerCase();
  31283. });
  31284. /**
  31285. * Converts the first character of `string` to lower case.
  31286. *
  31287. * @static
  31288. * @memberOf _
  31289. * @since 4.0.0
  31290. * @category String
  31291. * @param {string} [string=''] The string to convert.
  31292. * @returns {string} Returns the converted string.
  31293. * @example
  31294. *
  31295. * _.lowerFirst('Fred');
  31296. * // => 'fred'
  31297. *
  31298. * _.lowerFirst('FRED');
  31299. * // => 'fRED'
  31300. */
  31301. var lowerFirst = createCaseFirst('toLowerCase');
  31302. /**
  31303. * Pads `string` on the left and right sides if it's shorter than `length`.
  31304. * Padding characters are truncated if they can't be evenly divided by `length`.
  31305. *
  31306. * @static
  31307. * @memberOf _
  31308. * @since 3.0.0
  31309. * @category String
  31310. * @param {string} [string=''] The string to pad.
  31311. * @param {number} [length=0] The padding length.
  31312. * @param {string} [chars=' '] The string used as padding.
  31313. * @returns {string} Returns the padded string.
  31314. * @example
  31315. *
  31316. * _.pad('abc', 8);
  31317. * // => ' abc '
  31318. *
  31319. * _.pad('abc', 8, '_-');
  31320. * // => '_-abc_-_'
  31321. *
  31322. * _.pad('abc', 3);
  31323. * // => 'abc'
  31324. */
  31325. function pad(string, length, chars) {
  31326. string = toString(string);
  31327. length = toInteger(length);
  31328. var strLength = length ? stringSize(string) : 0;
  31329. if (!length || strLength >= length) {
  31330. return string;
  31331. }
  31332. var mid = (length - strLength) / 2;
  31333. return (
  31334. createPadding(nativeFloor(mid), chars) +
  31335. string +
  31336. createPadding(nativeCeil(mid), chars)
  31337. );
  31338. }
  31339. /**
  31340. * Pads `string` on the right side if it's shorter than `length`. Padding
  31341. * characters are truncated if they exceed `length`.
  31342. *
  31343. * @static
  31344. * @memberOf _
  31345. * @since 4.0.0
  31346. * @category String
  31347. * @param {string} [string=''] The string to pad.
  31348. * @param {number} [length=0] The padding length.
  31349. * @param {string} [chars=' '] The string used as padding.
  31350. * @returns {string} Returns the padded string.
  31351. * @example
  31352. *
  31353. * _.padEnd('abc', 6);
  31354. * // => 'abc '
  31355. *
  31356. * _.padEnd('abc', 6, '_-');
  31357. * // => 'abc_-_'
  31358. *
  31359. * _.padEnd('abc', 3);
  31360. * // => 'abc'
  31361. */
  31362. function padEnd(string, length, chars) {
  31363. string = toString(string);
  31364. length = toInteger(length);
  31365. var strLength = length ? stringSize(string) : 0;
  31366. return (length && strLength < length)
  31367. ? (string + createPadding(length - strLength, chars))
  31368. : string;
  31369. }
  31370. /**
  31371. * Pads `string` on the left side if it's shorter than `length`. Padding
  31372. * characters are truncated if they exceed `length`.
  31373. *
  31374. * @static
  31375. * @memberOf _
  31376. * @since 4.0.0
  31377. * @category String
  31378. * @param {string} [string=''] The string to pad.
  31379. * @param {number} [length=0] The padding length.
  31380. * @param {string} [chars=' '] The string used as padding.
  31381. * @returns {string} Returns the padded string.
  31382. * @example
  31383. *
  31384. * _.padStart('abc', 6);
  31385. * // => ' abc'
  31386. *
  31387. * _.padStart('abc', 6, '_-');
  31388. * // => '_-_abc'
  31389. *
  31390. * _.padStart('abc', 3);
  31391. * // => 'abc'
  31392. */
  31393. function padStart(string, length, chars) {
  31394. string = toString(string);
  31395. length = toInteger(length);
  31396. var strLength = length ? stringSize(string) : 0;
  31397. return (length && strLength < length)
  31398. ? (createPadding(length - strLength, chars) + string)
  31399. : string;
  31400. }
  31401. /**
  31402. * Converts `string` to an integer of the specified radix. If `radix` is
  31403. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31404. * hexadecimal, in which case a `radix` of `16` is used.
  31405. *
  31406. * **Note:** This method aligns with the
  31407. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31408. *
  31409. * @static
  31410. * @memberOf _
  31411. * @since 1.1.0
  31412. * @category String
  31413. * @param {string} string The string to convert.
  31414. * @param {number} [radix=10] The radix to interpret `value` by.
  31415. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31416. * @returns {number} Returns the converted integer.
  31417. * @example
  31418. *
  31419. * _.parseInt('08');
  31420. * // => 8
  31421. *
  31422. * _.map(['6', '08', '10'], _.parseInt);
  31423. * // => [6, 8, 10]
  31424. */
  31425. function parseInt(string, radix, guard) {
  31426. if (guard || radix == null) {
  31427. radix = 0;
  31428. } else if (radix) {
  31429. radix = +radix;
  31430. }
  31431. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31432. }
  31433. /**
  31434. * Repeats the given string `n` times.
  31435. *
  31436. * @static
  31437. * @memberOf _
  31438. * @since 3.0.0
  31439. * @category String
  31440. * @param {string} [string=''] The string to repeat.
  31441. * @param {number} [n=1] The number of times to repeat the string.
  31442. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31443. * @returns {string} Returns the repeated string.
  31444. * @example
  31445. *
  31446. * _.repeat('*', 3);
  31447. * // => '***'
  31448. *
  31449. * _.repeat('abc', 2);
  31450. * // => 'abcabc'
  31451. *
  31452. * _.repeat('abc', 0);
  31453. * // => ''
  31454. */
  31455. function repeat(string, n, guard) {
  31456. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31457. n = 1;
  31458. } else {
  31459. n = toInteger(n);
  31460. }
  31461. return baseRepeat(toString(string), n);
  31462. }
  31463. /**
  31464. * Replaces matches for `pattern` in `string` with `replacement`.
  31465. *
  31466. * **Note:** This method is based on
  31467. * [`String#replace`](https://mdn.io/String/replace).
  31468. *
  31469. * @static
  31470. * @memberOf _
  31471. * @since 4.0.0
  31472. * @category String
  31473. * @param {string} [string=''] The string to modify.
  31474. * @param {RegExp|string} pattern The pattern to replace.
  31475. * @param {Function|string} replacement The match replacement.
  31476. * @returns {string} Returns the modified string.
  31477. * @example
  31478. *
  31479. * _.replace('Hi Fred', 'Fred', 'Barney');
  31480. * // => 'Hi Barney'
  31481. */
  31482. function replace() {
  31483. var args = arguments,
  31484. string = toString(args[0]);
  31485. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31486. }
  31487. /**
  31488. * Converts `string` to
  31489. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31490. *
  31491. * @static
  31492. * @memberOf _
  31493. * @since 3.0.0
  31494. * @category String
  31495. * @param {string} [string=''] The string to convert.
  31496. * @returns {string} Returns the snake cased string.
  31497. * @example
  31498. *
  31499. * _.snakeCase('Foo Bar');
  31500. * // => 'foo_bar'
  31501. *
  31502. * _.snakeCase('fooBar');
  31503. * // => 'foo_bar'
  31504. *
  31505. * _.snakeCase('--FOO-BAR--');
  31506. * // => 'foo_bar'
  31507. */
  31508. var snakeCase = createCompounder(function(result, word, index) {
  31509. return result + (index ? '_' : '') + word.toLowerCase();
  31510. });
  31511. /**
  31512. * Splits `string` by `separator`.
  31513. *
  31514. * **Note:** This method is based on
  31515. * [`String#split`](https://mdn.io/String/split).
  31516. *
  31517. * @static
  31518. * @memberOf _
  31519. * @since 4.0.0
  31520. * @category String
  31521. * @param {string} [string=''] The string to split.
  31522. * @param {RegExp|string} separator The separator pattern to split by.
  31523. * @param {number} [limit] The length to truncate results to.
  31524. * @returns {Array} Returns the string segments.
  31525. * @example
  31526. *
  31527. * _.split('a-b-c', '-', 2);
  31528. * // => ['a', 'b']
  31529. */
  31530. function split(string, separator, limit) {
  31531. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31532. separator = limit = undefined;
  31533. }
  31534. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31535. if (!limit) {
  31536. return [];
  31537. }
  31538. string = toString(string);
  31539. if (string && (
  31540. typeof separator == 'string' ||
  31541. (separator != null && !isRegExp(separator))
  31542. )) {
  31543. separator = baseToString(separator);
  31544. if (!separator && hasUnicode(string)) {
  31545. return castSlice(stringToArray(string), 0, limit);
  31546. }
  31547. }
  31548. return string.split(separator, limit);
  31549. }
  31550. /**
  31551. * Converts `string` to
  31552. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31553. *
  31554. * @static
  31555. * @memberOf _
  31556. * @since 3.1.0
  31557. * @category String
  31558. * @param {string} [string=''] The string to convert.
  31559. * @returns {string} Returns the start cased string.
  31560. * @example
  31561. *
  31562. * _.startCase('--foo-bar--');
  31563. * // => 'Foo Bar'
  31564. *
  31565. * _.startCase('fooBar');
  31566. * // => 'Foo Bar'
  31567. *
  31568. * _.startCase('__FOO_BAR__');
  31569. * // => 'FOO BAR'
  31570. */
  31571. var startCase = createCompounder(function(result, word, index) {
  31572. return result + (index ? ' ' : '') + upperFirst(word);
  31573. });
  31574. /**
  31575. * Checks if `string` starts with the given target string.
  31576. *
  31577. * @static
  31578. * @memberOf _
  31579. * @since 3.0.0
  31580. * @category String
  31581. * @param {string} [string=''] The string to inspect.
  31582. * @param {string} [target] The string to search for.
  31583. * @param {number} [position=0] The position to search from.
  31584. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31585. * else `false`.
  31586. * @example
  31587. *
  31588. * _.startsWith('abc', 'a');
  31589. * // => true
  31590. *
  31591. * _.startsWith('abc', 'b');
  31592. * // => false
  31593. *
  31594. * _.startsWith('abc', 'b', 1);
  31595. * // => true
  31596. */
  31597. function startsWith(string, target, position) {
  31598. string = toString(string);
  31599. position = position == null
  31600. ? 0
  31601. : baseClamp(toInteger(position), 0, string.length);
  31602. target = baseToString(target);
  31603. return string.slice(position, position + target.length) == target;
  31604. }
  31605. /**
  31606. * Creates a compiled template function that can interpolate data properties
  31607. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31608. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31609. * properties may be accessed as free variables in the template. If a setting
  31610. * object is given, it takes precedence over `_.templateSettings` values.
  31611. *
  31612. * **Note:** In the development build `_.template` utilizes
  31613. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31614. * for easier debugging.
  31615. *
  31616. * For more information on precompiling templates see
  31617. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31618. *
  31619. * For more information on Chrome extension sandboxes see
  31620. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31621. *
  31622. * @static
  31623. * @since 0.1.0
  31624. * @memberOf _
  31625. * @category String
  31626. * @param {string} [string=''] The template string.
  31627. * @param {Object} [options={}] The options object.
  31628. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31629. * The HTML "escape" delimiter.
  31630. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31631. * The "evaluate" delimiter.
  31632. * @param {Object} [options.imports=_.templateSettings.imports]
  31633. * An object to import into the template as free variables.
  31634. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31635. * The "interpolate" delimiter.
  31636. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31637. * The sourceURL of the compiled template.
  31638. * @param {string} [options.variable='obj']
  31639. * The data object variable name.
  31640. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31641. * @returns {Function} Returns the compiled template function.
  31642. * @example
  31643. *
  31644. * // Use the "interpolate" delimiter to create a compiled template.
  31645. * var compiled = _.template('hello <%= user %>!');
  31646. * compiled({ 'user': 'fred' });
  31647. * // => 'hello fred!'
  31648. *
  31649. * // Use the HTML "escape" delimiter to escape data property values.
  31650. * var compiled = _.template('<b><%- value %></b>');
  31651. * compiled({ 'value': '<script>' });
  31652. * // => '<b>&lt;script&gt;</b>'
  31653. *
  31654. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31655. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31656. * compiled({ 'users': ['fred', 'barney'] });
  31657. * // => '<li>fred</li><li>barney</li>'
  31658. *
  31659. * // Use the internal `print` function in "evaluate" delimiters.
  31660. * var compiled = _.template('<% print("hello " + user); %>!');
  31661. * compiled({ 'user': 'barney' });
  31662. * // => 'hello barney!'
  31663. *
  31664. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31665. * // Disable support by replacing the "interpolate" delimiter.
  31666. * var compiled = _.template('hello ${ user }!');
  31667. * compiled({ 'user': 'pebbles' });
  31668. * // => 'hello pebbles!'
  31669. *
  31670. * // Use backslashes to treat delimiters as plain text.
  31671. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31672. * compiled({ 'value': 'ignored' });
  31673. * // => '<%- value %>'
  31674. *
  31675. * // Use the `imports` option to import `jQuery` as `jq`.
  31676. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31677. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31678. * compiled({ 'users': ['fred', 'barney'] });
  31679. * // => '<li>fred</li><li>barney</li>'
  31680. *
  31681. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31682. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31683. * compiled(data);
  31684. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31685. *
  31686. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31687. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31688. * compiled.source;
  31689. * // => function(data) {
  31690. * // var __t, __p = '';
  31691. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31692. * // return __p;
  31693. * // }
  31694. *
  31695. * // Use custom template delimiters.
  31696. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31697. * var compiled = _.template('hello {{ user }}!');
  31698. * compiled({ 'user': 'mustache' });
  31699. * // => 'hello mustache!'
  31700. *
  31701. * // Use the `source` property to inline compiled templates for meaningful
  31702. * // line numbers in error messages and stack traces.
  31703. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31704. * var JST = {\
  31705. * "main": ' + _.template(mainText).source + '\
  31706. * };\
  31707. * ');
  31708. */
  31709. function template(string, options, guard) {
  31710. // Based on John Resig's `tmpl` implementation
  31711. // (http://ejohn.org/blog/javascript-micro-templating/)
  31712. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31713. var settings = lodash.templateSettings;
  31714. if (guard && isIterateeCall(string, options, guard)) {
  31715. options = undefined;
  31716. }
  31717. string = toString(string);
  31718. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31719. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31720. importsKeys = keys(imports),
  31721. importsValues = baseValues(imports, importsKeys);
  31722. var isEscaping,
  31723. isEvaluating,
  31724. index = 0,
  31725. interpolate = options.interpolate || reNoMatch,
  31726. source = "__p += '";
  31727. // Compile the regexp to match each delimiter.
  31728. var reDelimiters = RegExp(
  31729. (options.escape || reNoMatch).source + '|' +
  31730. interpolate.source + '|' +
  31731. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31732. (options.evaluate || reNoMatch).source + '|$'
  31733. , 'g');
  31734. // Use a sourceURL for easier debugging.
  31735. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31736. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31737. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31738. var sourceURL = '//# sourceURL=' +
  31739. (hasOwnProperty.call(options, 'sourceURL')
  31740. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31741. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31742. ) + '\n';
  31743. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31744. interpolateValue || (interpolateValue = esTemplateValue);
  31745. // Escape characters that can't be included in string literals.
  31746. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31747. // Replace delimiters with snippets.
  31748. if (escapeValue) {
  31749. isEscaping = true;
  31750. source += "' +\n__e(" + escapeValue + ") +\n'";
  31751. }
  31752. if (evaluateValue) {
  31753. isEvaluating = true;
  31754. source += "';\n" + evaluateValue + ";\n__p += '";
  31755. }
  31756. if (interpolateValue) {
  31757. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31758. }
  31759. index = offset + match.length;
  31760. // The JS engine embedded in Adobe products needs `match` returned in
  31761. // order to produce the correct `offset` value.
  31762. return match;
  31763. });
  31764. source += "';\n";
  31765. // If `variable` is not specified wrap a with-statement around the generated
  31766. // code to add the data object to the top of the scope chain.
  31767. // Like with sourceURL, we take care to not check the option's prototype,
  31768. // as this configuration is a code injection vector.
  31769. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31770. if (!variable) {
  31771. source = 'with (obj) {\n' + source + '\n}\n';
  31772. }
  31773. // Cleanup code by stripping empty strings.
  31774. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31775. .replace(reEmptyStringMiddle, '$1')
  31776. .replace(reEmptyStringTrailing, '$1;');
  31777. // Frame code as the function body.
  31778. source = 'function(' + (variable || 'obj') + ') {\n' +
  31779. (variable
  31780. ? ''
  31781. : 'obj || (obj = {});\n'
  31782. ) +
  31783. "var __t, __p = ''" +
  31784. (isEscaping
  31785. ? ', __e = _.escape'
  31786. : ''
  31787. ) +
  31788. (isEvaluating
  31789. ? ', __j = Array.prototype.join;\n' +
  31790. "function print() { __p += __j.call(arguments, '') }\n"
  31791. : ';\n'
  31792. ) +
  31793. source +
  31794. 'return __p\n}';
  31795. var result = attempt(function() {
  31796. return Function(importsKeys, sourceURL + 'return ' + source)
  31797. .apply(undefined, importsValues);
  31798. });
  31799. // Provide the compiled function's source by its `toString` method or
  31800. // the `source` property as a convenience for inlining compiled templates.
  31801. result.source = source;
  31802. if (isError(result)) {
  31803. throw result;
  31804. }
  31805. return result;
  31806. }
  31807. /**
  31808. * Converts `string`, as a whole, to lower case just like
  31809. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31810. *
  31811. * @static
  31812. * @memberOf _
  31813. * @since 4.0.0
  31814. * @category String
  31815. * @param {string} [string=''] The string to convert.
  31816. * @returns {string} Returns the lower cased string.
  31817. * @example
  31818. *
  31819. * _.toLower('--Foo-Bar--');
  31820. * // => '--foo-bar--'
  31821. *
  31822. * _.toLower('fooBar');
  31823. * // => 'foobar'
  31824. *
  31825. * _.toLower('__FOO_BAR__');
  31826. * // => '__foo_bar__'
  31827. */
  31828. function toLower(value) {
  31829. return toString(value).toLowerCase();
  31830. }
  31831. /**
  31832. * Converts `string`, as a whole, to upper case just like
  31833. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31834. *
  31835. * @static
  31836. * @memberOf _
  31837. * @since 4.0.0
  31838. * @category String
  31839. * @param {string} [string=''] The string to convert.
  31840. * @returns {string} Returns the upper cased string.
  31841. * @example
  31842. *
  31843. * _.toUpper('--foo-bar--');
  31844. * // => '--FOO-BAR--'
  31845. *
  31846. * _.toUpper('fooBar');
  31847. * // => 'FOOBAR'
  31848. *
  31849. * _.toUpper('__foo_bar__');
  31850. * // => '__FOO_BAR__'
  31851. */
  31852. function toUpper(value) {
  31853. return toString(value).toUpperCase();
  31854. }
  31855. /**
  31856. * Removes leading and trailing whitespace or specified characters from `string`.
  31857. *
  31858. * @static
  31859. * @memberOf _
  31860. * @since 3.0.0
  31861. * @category String
  31862. * @param {string} [string=''] The string to trim.
  31863. * @param {string} [chars=whitespace] The characters to trim.
  31864. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31865. * @returns {string} Returns the trimmed string.
  31866. * @example
  31867. *
  31868. * _.trim(' abc ');
  31869. * // => 'abc'
  31870. *
  31871. * _.trim('-_-abc-_-', '_-');
  31872. * // => 'abc'
  31873. *
  31874. * _.map([' foo ', ' bar '], _.trim);
  31875. * // => ['foo', 'bar']
  31876. */
  31877. function trim(string, chars, guard) {
  31878. string = toString(string);
  31879. if (string && (guard || chars === undefined)) {
  31880. return string.replace(reTrim, '');
  31881. }
  31882. if (!string || !(chars = baseToString(chars))) {
  31883. return string;
  31884. }
  31885. var strSymbols = stringToArray(string),
  31886. chrSymbols = stringToArray(chars),
  31887. start = charsStartIndex(strSymbols, chrSymbols),
  31888. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31889. return castSlice(strSymbols, start, end).join('');
  31890. }
  31891. /**
  31892. * Removes trailing whitespace or specified characters from `string`.
  31893. *
  31894. * @static
  31895. * @memberOf _
  31896. * @since 4.0.0
  31897. * @category String
  31898. * @param {string} [string=''] The string to trim.
  31899. * @param {string} [chars=whitespace] The characters to trim.
  31900. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31901. * @returns {string} Returns the trimmed string.
  31902. * @example
  31903. *
  31904. * _.trimEnd(' abc ');
  31905. * // => ' abc'
  31906. *
  31907. * _.trimEnd('-_-abc-_-', '_-');
  31908. * // => '-_-abc'
  31909. */
  31910. function trimEnd(string, chars, guard) {
  31911. string = toString(string);
  31912. if (string && (guard || chars === undefined)) {
  31913. return string.replace(reTrimEnd, '');
  31914. }
  31915. if (!string || !(chars = baseToString(chars))) {
  31916. return string;
  31917. }
  31918. var strSymbols = stringToArray(string),
  31919. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31920. return castSlice(strSymbols, 0, end).join('');
  31921. }
  31922. /**
  31923. * Removes leading whitespace or specified characters from `string`.
  31924. *
  31925. * @static
  31926. * @memberOf _
  31927. * @since 4.0.0
  31928. * @category String
  31929. * @param {string} [string=''] The string to trim.
  31930. * @param {string} [chars=whitespace] The characters to trim.
  31931. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31932. * @returns {string} Returns the trimmed string.
  31933. * @example
  31934. *
  31935. * _.trimStart(' abc ');
  31936. * // => 'abc '
  31937. *
  31938. * _.trimStart('-_-abc-_-', '_-');
  31939. * // => 'abc-_-'
  31940. */
  31941. function trimStart(string, chars, guard) {
  31942. string = toString(string);
  31943. if (string && (guard || chars === undefined)) {
  31944. return string.replace(reTrimStart, '');
  31945. }
  31946. if (!string || !(chars = baseToString(chars))) {
  31947. return string;
  31948. }
  31949. var strSymbols = stringToArray(string),
  31950. start = charsStartIndex(strSymbols, stringToArray(chars));
  31951. return castSlice(strSymbols, start).join('');
  31952. }
  31953. /**
  31954. * Truncates `string` if it's longer than the given maximum string length.
  31955. * The last characters of the truncated string are replaced with the omission
  31956. * string which defaults to "...".
  31957. *
  31958. * @static
  31959. * @memberOf _
  31960. * @since 4.0.0
  31961. * @category String
  31962. * @param {string} [string=''] The string to truncate.
  31963. * @param {Object} [options={}] The options object.
  31964. * @param {number} [options.length=30] The maximum string length.
  31965. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31966. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31967. * @returns {string} Returns the truncated string.
  31968. * @example
  31969. *
  31970. * _.truncate('hi-diddly-ho there, neighborino');
  31971. * // => 'hi-diddly-ho there, neighbo...'
  31972. *
  31973. * _.truncate('hi-diddly-ho there, neighborino', {
  31974. * 'length': 24,
  31975. * 'separator': ' '
  31976. * });
  31977. * // => 'hi-diddly-ho there,...'
  31978. *
  31979. * _.truncate('hi-diddly-ho there, neighborino', {
  31980. * 'length': 24,
  31981. * 'separator': /,? +/
  31982. * });
  31983. * // => 'hi-diddly-ho there...'
  31984. *
  31985. * _.truncate('hi-diddly-ho there, neighborino', {
  31986. * 'omission': ' [...]'
  31987. * });
  31988. * // => 'hi-diddly-ho there, neig [...]'
  31989. */
  31990. function truncate(string, options) {
  31991. var length = DEFAULT_TRUNC_LENGTH,
  31992. omission = DEFAULT_TRUNC_OMISSION;
  31993. if (isObject(options)) {
  31994. var separator = 'separator' in options ? options.separator : separator;
  31995. length = 'length' in options ? toInteger(options.length) : length;
  31996. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31997. }
  31998. string = toString(string);
  31999. var strLength = string.length;
  32000. if (hasUnicode(string)) {
  32001. var strSymbols = stringToArray(string);
  32002. strLength = strSymbols.length;
  32003. }
  32004. if (length >= strLength) {
  32005. return string;
  32006. }
  32007. var end = length - stringSize(omission);
  32008. if (end < 1) {
  32009. return omission;
  32010. }
  32011. var result = strSymbols
  32012. ? castSlice(strSymbols, 0, end).join('')
  32013. : string.slice(0, end);
  32014. if (separator === undefined) {
  32015. return result + omission;
  32016. }
  32017. if (strSymbols) {
  32018. end += (result.length - end);
  32019. }
  32020. if (isRegExp(separator)) {
  32021. if (string.slice(end).search(separator)) {
  32022. var match,
  32023. substring = result;
  32024. if (!separator.global) {
  32025. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  32026. }
  32027. separator.lastIndex = 0;
  32028. while ((match = separator.exec(substring))) {
  32029. var newEnd = match.index;
  32030. }
  32031. result = result.slice(0, newEnd === undefined ? end : newEnd);
  32032. }
  32033. } else if (string.indexOf(baseToString(separator), end) != end) {
  32034. var index = result.lastIndexOf(separator);
  32035. if (index > -1) {
  32036. result = result.slice(0, index);
  32037. }
  32038. }
  32039. return result + omission;
  32040. }
  32041. /**
  32042. * The inverse of `_.escape`; this method converts the HTML entities
  32043. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  32044. * their corresponding characters.
  32045. *
  32046. * **Note:** No other HTML entities are unescaped. To unescape additional
  32047. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  32048. *
  32049. * @static
  32050. * @memberOf _
  32051. * @since 0.6.0
  32052. * @category String
  32053. * @param {string} [string=''] The string to unescape.
  32054. * @returns {string} Returns the unescaped string.
  32055. * @example
  32056. *
  32057. * _.unescape('fred, barney, &amp; pebbles');
  32058. * // => 'fred, barney, & pebbles'
  32059. */
  32060. function unescape(string) {
  32061. string = toString(string);
  32062. return (string && reHasEscapedHtml.test(string))
  32063. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  32064. : string;
  32065. }
  32066. /**
  32067. * Converts `string`, as space separated words, to upper case.
  32068. *
  32069. * @static
  32070. * @memberOf _
  32071. * @since 4.0.0
  32072. * @category String
  32073. * @param {string} [string=''] The string to convert.
  32074. * @returns {string} Returns the upper cased string.
  32075. * @example
  32076. *
  32077. * _.upperCase('--foo-bar');
  32078. * // => 'FOO BAR'
  32079. *
  32080. * _.upperCase('fooBar');
  32081. * // => 'FOO BAR'
  32082. *
  32083. * _.upperCase('__foo_bar__');
  32084. * // => 'FOO BAR'
  32085. */
  32086. var upperCase = createCompounder(function(result, word, index) {
  32087. return result + (index ? ' ' : '') + word.toUpperCase();
  32088. });
  32089. /**
  32090. * Converts the first character of `string` to upper case.
  32091. *
  32092. * @static
  32093. * @memberOf _
  32094. * @since 4.0.0
  32095. * @category String
  32096. * @param {string} [string=''] The string to convert.
  32097. * @returns {string} Returns the converted string.
  32098. * @example
  32099. *
  32100. * _.upperFirst('fred');
  32101. * // => 'Fred'
  32102. *
  32103. * _.upperFirst('FRED');
  32104. * // => 'FRED'
  32105. */
  32106. var upperFirst = createCaseFirst('toUpperCase');
  32107. /**
  32108. * Splits `string` into an array of its words.
  32109. *
  32110. * @static
  32111. * @memberOf _
  32112. * @since 3.0.0
  32113. * @category String
  32114. * @param {string} [string=''] The string to inspect.
  32115. * @param {RegExp|string} [pattern] The pattern to match words.
  32116. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32117. * @returns {Array} Returns the words of `string`.
  32118. * @example
  32119. *
  32120. * _.words('fred, barney, & pebbles');
  32121. * // => ['fred', 'barney', 'pebbles']
  32122. *
  32123. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32124. * // => ['fred', 'barney', '&', 'pebbles']
  32125. */
  32126. function words(string, pattern, guard) {
  32127. string = toString(string);
  32128. pattern = guard ? undefined : pattern;
  32129. if (pattern === undefined) {
  32130. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32131. }
  32132. return string.match(pattern) || [];
  32133. }
  32134. /*------------------------------------------------------------------------*/
  32135. /**
  32136. * Attempts to invoke `func`, returning either the result or the caught error
  32137. * object. Any additional arguments are provided to `func` when it's invoked.
  32138. *
  32139. * @static
  32140. * @memberOf _
  32141. * @since 3.0.0
  32142. * @category Util
  32143. * @param {Function} func The function to attempt.
  32144. * @param {...*} [args] The arguments to invoke `func` with.
  32145. * @returns {*} Returns the `func` result or error object.
  32146. * @example
  32147. *
  32148. * // Avoid throwing errors for invalid selectors.
  32149. * var elements = _.attempt(function(selector) {
  32150. * return document.querySelectorAll(selector);
  32151. * }, '>_>');
  32152. *
  32153. * if (_.isError(elements)) {
  32154. * elements = [];
  32155. * }
  32156. */
  32157. var attempt = baseRest(function(func, args) {
  32158. try {
  32159. return apply(func, undefined, args);
  32160. } catch (e) {
  32161. return isError(e) ? e : new Error(e);
  32162. }
  32163. });
  32164. /**
  32165. * Binds methods of an object to the object itself, overwriting the existing
  32166. * method.
  32167. *
  32168. * **Note:** This method doesn't set the "length" property of bound functions.
  32169. *
  32170. * @static
  32171. * @since 0.1.0
  32172. * @memberOf _
  32173. * @category Util
  32174. * @param {Object} object The object to bind and assign the bound methods to.
  32175. * @param {...(string|string[])} methodNames The object method names to bind.
  32176. * @returns {Object} Returns `object`.
  32177. * @example
  32178. *
  32179. * var view = {
  32180. * 'label': 'docs',
  32181. * 'click': function() {
  32182. * console.log('clicked ' + this.label);
  32183. * }
  32184. * };
  32185. *
  32186. * _.bindAll(view, ['click']);
  32187. * jQuery(element).on('click', view.click);
  32188. * // => Logs 'clicked docs' when clicked.
  32189. */
  32190. var bindAll = flatRest(function(object, methodNames) {
  32191. arrayEach(methodNames, function(key) {
  32192. key = toKey(key);
  32193. baseAssignValue(object, key, bind(object[key], object));
  32194. });
  32195. return object;
  32196. });
  32197. /**
  32198. * Creates a function that iterates over `pairs` and invokes the corresponding
  32199. * function of the first predicate to return truthy. The predicate-function
  32200. * pairs are invoked with the `this` binding and arguments of the created
  32201. * function.
  32202. *
  32203. * @static
  32204. * @memberOf _
  32205. * @since 4.0.0
  32206. * @category Util
  32207. * @param {Array} pairs The predicate-function pairs.
  32208. * @returns {Function} Returns the new composite function.
  32209. * @example
  32210. *
  32211. * var func = _.cond([
  32212. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32213. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32214. * [_.stubTrue, _.constant('no match')]
  32215. * ]);
  32216. *
  32217. * func({ 'a': 1, 'b': 2 });
  32218. * // => 'matches A'
  32219. *
  32220. * func({ 'a': 0, 'b': 1 });
  32221. * // => 'matches B'
  32222. *
  32223. * func({ 'a': '1', 'b': '2' });
  32224. * // => 'no match'
  32225. */
  32226. function cond(pairs) {
  32227. var length = pairs == null ? 0 : pairs.length,
  32228. toIteratee = getIteratee();
  32229. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32230. if (typeof pair[1] != 'function') {
  32231. throw new TypeError(FUNC_ERROR_TEXT);
  32232. }
  32233. return [toIteratee(pair[0]), pair[1]];
  32234. });
  32235. return baseRest(function(args) {
  32236. var index = -1;
  32237. while (++index < length) {
  32238. var pair = pairs[index];
  32239. if (apply(pair[0], this, args)) {
  32240. return apply(pair[1], this, args);
  32241. }
  32242. }
  32243. });
  32244. }
  32245. /**
  32246. * Creates a function that invokes the predicate properties of `source` with
  32247. * the corresponding property values of a given object, returning `true` if
  32248. * all predicates return truthy, else `false`.
  32249. *
  32250. * **Note:** The created function is equivalent to `_.conformsTo` with
  32251. * `source` partially applied.
  32252. *
  32253. * @static
  32254. * @memberOf _
  32255. * @since 4.0.0
  32256. * @category Util
  32257. * @param {Object} source The object of property predicates to conform to.
  32258. * @returns {Function} Returns the new spec function.
  32259. * @example
  32260. *
  32261. * var objects = [
  32262. * { 'a': 2, 'b': 1 },
  32263. * { 'a': 1, 'b': 2 }
  32264. * ];
  32265. *
  32266. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32267. * // => [{ 'a': 1, 'b': 2 }]
  32268. */
  32269. function conforms(source) {
  32270. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32271. }
  32272. /**
  32273. * Creates a function that returns `value`.
  32274. *
  32275. * @static
  32276. * @memberOf _
  32277. * @since 2.4.0
  32278. * @category Util
  32279. * @param {*} value The value to return from the new function.
  32280. * @returns {Function} Returns the new constant function.
  32281. * @example
  32282. *
  32283. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32284. *
  32285. * console.log(objects);
  32286. * // => [{ 'a': 1 }, { 'a': 1 }]
  32287. *
  32288. * console.log(objects[0] === objects[1]);
  32289. * // => true
  32290. */
  32291. function constant(value) {
  32292. return function() {
  32293. return value;
  32294. };
  32295. }
  32296. /**
  32297. * Checks `value` to determine whether a default value should be returned in
  32298. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32299. * or `undefined`.
  32300. *
  32301. * @static
  32302. * @memberOf _
  32303. * @since 4.14.0
  32304. * @category Util
  32305. * @param {*} value The value to check.
  32306. * @param {*} defaultValue The default value.
  32307. * @returns {*} Returns the resolved value.
  32308. * @example
  32309. *
  32310. * _.defaultTo(1, 10);
  32311. * // => 1
  32312. *
  32313. * _.defaultTo(undefined, 10);
  32314. * // => 10
  32315. */
  32316. function defaultTo(value, defaultValue) {
  32317. return (value == null || value !== value) ? defaultValue : value;
  32318. }
  32319. /**
  32320. * Creates a function that returns the result of invoking the given functions
  32321. * with the `this` binding of the created function, where each successive
  32322. * invocation is supplied the return value of the previous.
  32323. *
  32324. * @static
  32325. * @memberOf _
  32326. * @since 3.0.0
  32327. * @category Util
  32328. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32329. * @returns {Function} Returns the new composite function.
  32330. * @see _.flowRight
  32331. * @example
  32332. *
  32333. * function square(n) {
  32334. * return n * n;
  32335. * }
  32336. *
  32337. * var addSquare = _.flow([_.add, square]);
  32338. * addSquare(1, 2);
  32339. * // => 9
  32340. */
  32341. var flow = createFlow();
  32342. /**
  32343. * This method is like `_.flow` except that it creates a function that
  32344. * invokes the given functions from right to left.
  32345. *
  32346. * @static
  32347. * @since 3.0.0
  32348. * @memberOf _
  32349. * @category Util
  32350. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32351. * @returns {Function} Returns the new composite function.
  32352. * @see _.flow
  32353. * @example
  32354. *
  32355. * function square(n) {
  32356. * return n * n;
  32357. * }
  32358. *
  32359. * var addSquare = _.flowRight([square, _.add]);
  32360. * addSquare(1, 2);
  32361. * // => 9
  32362. */
  32363. var flowRight = createFlow(true);
  32364. /**
  32365. * This method returns the first argument it receives.
  32366. *
  32367. * @static
  32368. * @since 0.1.0
  32369. * @memberOf _
  32370. * @category Util
  32371. * @param {*} value Any value.
  32372. * @returns {*} Returns `value`.
  32373. * @example
  32374. *
  32375. * var object = { 'a': 1 };
  32376. *
  32377. * console.log(_.identity(object) === object);
  32378. * // => true
  32379. */
  32380. function identity(value) {
  32381. return value;
  32382. }
  32383. /**
  32384. * Creates a function that invokes `func` with the arguments of the created
  32385. * function. If `func` is a property name, the created function returns the
  32386. * property value for a given element. If `func` is an array or object, the
  32387. * created function returns `true` for elements that contain the equivalent
  32388. * source properties, otherwise it returns `false`.
  32389. *
  32390. * @static
  32391. * @since 4.0.0
  32392. * @memberOf _
  32393. * @category Util
  32394. * @param {*} [func=_.identity] The value to convert to a callback.
  32395. * @returns {Function} Returns the callback.
  32396. * @example
  32397. *
  32398. * var users = [
  32399. * { 'user': 'barney', 'age': 36, 'active': true },
  32400. * { 'user': 'fred', 'age': 40, 'active': false }
  32401. * ];
  32402. *
  32403. * // The `_.matches` iteratee shorthand.
  32404. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32405. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32406. *
  32407. * // The `_.matchesProperty` iteratee shorthand.
  32408. * _.filter(users, _.iteratee(['user', 'fred']));
  32409. * // => [{ 'user': 'fred', 'age': 40 }]
  32410. *
  32411. * // The `_.property` iteratee shorthand.
  32412. * _.map(users, _.iteratee('user'));
  32413. * // => ['barney', 'fred']
  32414. *
  32415. * // Create custom iteratee shorthands.
  32416. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32417. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32418. * return func.test(string);
  32419. * };
  32420. * });
  32421. *
  32422. * _.filter(['abc', 'def'], /ef/);
  32423. * // => ['def']
  32424. */
  32425. function iteratee(func) {
  32426. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32427. }
  32428. /**
  32429. * Creates a function that performs a partial deep comparison between a given
  32430. * object and `source`, returning `true` if the given object has equivalent
  32431. * property values, else `false`.
  32432. *
  32433. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32434. * partially applied.
  32435. *
  32436. * Partial comparisons will match empty array and empty object `source`
  32437. * values against any array or object value, respectively. See `_.isEqual`
  32438. * for a list of supported value comparisons.
  32439. *
  32440. * @static
  32441. * @memberOf _
  32442. * @since 3.0.0
  32443. * @category Util
  32444. * @param {Object} source The object of property values to match.
  32445. * @returns {Function} Returns the new spec function.
  32446. * @example
  32447. *
  32448. * var objects = [
  32449. * { 'a': 1, 'b': 2, 'c': 3 },
  32450. * { 'a': 4, 'b': 5, 'c': 6 }
  32451. * ];
  32452. *
  32453. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32454. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32455. */
  32456. function matches(source) {
  32457. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32458. }
  32459. /**
  32460. * Creates a function that performs a partial deep comparison between the
  32461. * value at `path` of a given object to `srcValue`, returning `true` if the
  32462. * object value is equivalent, else `false`.
  32463. *
  32464. * **Note:** Partial comparisons will match empty array and empty object
  32465. * `srcValue` values against any array or object value, respectively. See
  32466. * `_.isEqual` for a list of supported value comparisons.
  32467. *
  32468. * @static
  32469. * @memberOf _
  32470. * @since 3.2.0
  32471. * @category Util
  32472. * @param {Array|string} path The path of the property to get.
  32473. * @param {*} srcValue The value to match.
  32474. * @returns {Function} Returns the new spec function.
  32475. * @example
  32476. *
  32477. * var objects = [
  32478. * { 'a': 1, 'b': 2, 'c': 3 },
  32479. * { 'a': 4, 'b': 5, 'c': 6 }
  32480. * ];
  32481. *
  32482. * _.find(objects, _.matchesProperty('a', 4));
  32483. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32484. */
  32485. function matchesProperty(path, srcValue) {
  32486. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32487. }
  32488. /**
  32489. * Creates a function that invokes the method at `path` of a given object.
  32490. * Any additional arguments are provided to the invoked method.
  32491. *
  32492. * @static
  32493. * @memberOf _
  32494. * @since 3.7.0
  32495. * @category Util
  32496. * @param {Array|string} path The path of the method to invoke.
  32497. * @param {...*} [args] The arguments to invoke the method with.
  32498. * @returns {Function} Returns the new invoker function.
  32499. * @example
  32500. *
  32501. * var objects = [
  32502. * { 'a': { 'b': _.constant(2) } },
  32503. * { 'a': { 'b': _.constant(1) } }
  32504. * ];
  32505. *
  32506. * _.map(objects, _.method('a.b'));
  32507. * // => [2, 1]
  32508. *
  32509. * _.map(objects, _.method(['a', 'b']));
  32510. * // => [2, 1]
  32511. */
  32512. var method = baseRest(function(path, args) {
  32513. return function(object) {
  32514. return baseInvoke(object, path, args);
  32515. };
  32516. });
  32517. /**
  32518. * The opposite of `_.method`; this method creates a function that invokes
  32519. * the method at a given path of `object`. Any additional arguments are
  32520. * provided to the invoked method.
  32521. *
  32522. * @static
  32523. * @memberOf _
  32524. * @since 3.7.0
  32525. * @category Util
  32526. * @param {Object} object The object to query.
  32527. * @param {...*} [args] The arguments to invoke the method with.
  32528. * @returns {Function} Returns the new invoker function.
  32529. * @example
  32530. *
  32531. * var array = _.times(3, _.constant),
  32532. * object = { 'a': array, 'b': array, 'c': array };
  32533. *
  32534. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32535. * // => [2, 0]
  32536. *
  32537. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32538. * // => [2, 0]
  32539. */
  32540. var methodOf = baseRest(function(object, args) {
  32541. return function(path) {
  32542. return baseInvoke(object, path, args);
  32543. };
  32544. });
  32545. /**
  32546. * Adds all own enumerable string keyed function properties of a source
  32547. * object to the destination object. If `object` is a function, then methods
  32548. * are added to its prototype as well.
  32549. *
  32550. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32551. * avoid conflicts caused by modifying the original.
  32552. *
  32553. * @static
  32554. * @since 0.1.0
  32555. * @memberOf _
  32556. * @category Util
  32557. * @param {Function|Object} [object=lodash] The destination object.
  32558. * @param {Object} source The object of functions to add.
  32559. * @param {Object} [options={}] The options object.
  32560. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32561. * @returns {Function|Object} Returns `object`.
  32562. * @example
  32563. *
  32564. * function vowels(string) {
  32565. * return _.filter(string, function(v) {
  32566. * return /[aeiou]/i.test(v);
  32567. * });
  32568. * }
  32569. *
  32570. * _.mixin({ 'vowels': vowels });
  32571. * _.vowels('fred');
  32572. * // => ['e']
  32573. *
  32574. * _('fred').vowels().value();
  32575. * // => ['e']
  32576. *
  32577. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32578. * _('fred').vowels();
  32579. * // => ['e']
  32580. */
  32581. function mixin(object, source, options) {
  32582. var props = keys(source),
  32583. methodNames = baseFunctions(source, props);
  32584. if (options == null &&
  32585. !(isObject(source) && (methodNames.length || !props.length))) {
  32586. options = source;
  32587. source = object;
  32588. object = this;
  32589. methodNames = baseFunctions(source, keys(source));
  32590. }
  32591. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32592. isFunc = isFunction(object);
  32593. arrayEach(methodNames, function(methodName) {
  32594. var func = source[methodName];
  32595. object[methodName] = func;
  32596. if (isFunc) {
  32597. object.prototype[methodName] = function() {
  32598. var chainAll = this.__chain__;
  32599. if (chain || chainAll) {
  32600. var result = object(this.__wrapped__),
  32601. actions = result.__actions__ = copyArray(this.__actions__);
  32602. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32603. result.__chain__ = chainAll;
  32604. return result;
  32605. }
  32606. return func.apply(object, arrayPush([this.value()], arguments));
  32607. };
  32608. }
  32609. });
  32610. return object;
  32611. }
  32612. /**
  32613. * Reverts the `_` variable to its previous value and returns a reference to
  32614. * the `lodash` function.
  32615. *
  32616. * @static
  32617. * @since 0.1.0
  32618. * @memberOf _
  32619. * @category Util
  32620. * @returns {Function} Returns the `lodash` function.
  32621. * @example
  32622. *
  32623. * var lodash = _.noConflict();
  32624. */
  32625. function noConflict() {
  32626. if (root._ === this) {
  32627. root._ = oldDash;
  32628. }
  32629. return this;
  32630. }
  32631. /**
  32632. * This method returns `undefined`.
  32633. *
  32634. * @static
  32635. * @memberOf _
  32636. * @since 2.3.0
  32637. * @category Util
  32638. * @example
  32639. *
  32640. * _.times(2, _.noop);
  32641. * // => [undefined, undefined]
  32642. */
  32643. function noop() {
  32644. // No operation performed.
  32645. }
  32646. /**
  32647. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32648. * the nth argument from the end is returned.
  32649. *
  32650. * @static
  32651. * @memberOf _
  32652. * @since 4.0.0
  32653. * @category Util
  32654. * @param {number} [n=0] The index of the argument to return.
  32655. * @returns {Function} Returns the new pass-thru function.
  32656. * @example
  32657. *
  32658. * var func = _.nthArg(1);
  32659. * func('a', 'b', 'c', 'd');
  32660. * // => 'b'
  32661. *
  32662. * var func = _.nthArg(-2);
  32663. * func('a', 'b', 'c', 'd');
  32664. * // => 'c'
  32665. */
  32666. function nthArg(n) {
  32667. n = toInteger(n);
  32668. return baseRest(function(args) {
  32669. return baseNth(args, n);
  32670. });
  32671. }
  32672. /**
  32673. * Creates a function that invokes `iteratees` with the arguments it receives
  32674. * and returns their results.
  32675. *
  32676. * @static
  32677. * @memberOf _
  32678. * @since 4.0.0
  32679. * @category Util
  32680. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32681. * The iteratees to invoke.
  32682. * @returns {Function} Returns the new function.
  32683. * @example
  32684. *
  32685. * var func = _.over([Math.max, Math.min]);
  32686. *
  32687. * func(1, 2, 3, 4);
  32688. * // => [4, 1]
  32689. */
  32690. var over = createOver(arrayMap);
  32691. /**
  32692. * Creates a function that checks if **all** of the `predicates` return
  32693. * truthy when invoked with the arguments it receives.
  32694. *
  32695. * @static
  32696. * @memberOf _
  32697. * @since 4.0.0
  32698. * @category Util
  32699. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32700. * The predicates to check.
  32701. * @returns {Function} Returns the new function.
  32702. * @example
  32703. *
  32704. * var func = _.overEvery([Boolean, isFinite]);
  32705. *
  32706. * func('1');
  32707. * // => true
  32708. *
  32709. * func(null);
  32710. * // => false
  32711. *
  32712. * func(NaN);
  32713. * // => false
  32714. */
  32715. var overEvery = createOver(arrayEvery);
  32716. /**
  32717. * Creates a function that checks if **any** of the `predicates` return
  32718. * truthy when invoked with the arguments it receives.
  32719. *
  32720. * @static
  32721. * @memberOf _
  32722. * @since 4.0.0
  32723. * @category Util
  32724. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32725. * The predicates to check.
  32726. * @returns {Function} Returns the new function.
  32727. * @example
  32728. *
  32729. * var func = _.overSome([Boolean, isFinite]);
  32730. *
  32731. * func('1');
  32732. * // => true
  32733. *
  32734. * func(null);
  32735. * // => true
  32736. *
  32737. * func(NaN);
  32738. * // => false
  32739. */
  32740. var overSome = createOver(arraySome);
  32741. /**
  32742. * Creates a function that returns the value at `path` of a given object.
  32743. *
  32744. * @static
  32745. * @memberOf _
  32746. * @since 2.4.0
  32747. * @category Util
  32748. * @param {Array|string} path The path of the property to get.
  32749. * @returns {Function} Returns the new accessor function.
  32750. * @example
  32751. *
  32752. * var objects = [
  32753. * { 'a': { 'b': 2 } },
  32754. * { 'a': { 'b': 1 } }
  32755. * ];
  32756. *
  32757. * _.map(objects, _.property('a.b'));
  32758. * // => [2, 1]
  32759. *
  32760. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32761. * // => [1, 2]
  32762. */
  32763. function property(path) {
  32764. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32765. }
  32766. /**
  32767. * The opposite of `_.property`; this method creates a function that returns
  32768. * the value at a given path of `object`.
  32769. *
  32770. * @static
  32771. * @memberOf _
  32772. * @since 3.0.0
  32773. * @category Util
  32774. * @param {Object} object The object to query.
  32775. * @returns {Function} Returns the new accessor function.
  32776. * @example
  32777. *
  32778. * var array = [0, 1, 2],
  32779. * object = { 'a': array, 'b': array, 'c': array };
  32780. *
  32781. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32782. * // => [2, 0]
  32783. *
  32784. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32785. * // => [2, 0]
  32786. */
  32787. function propertyOf(object) {
  32788. return function(path) {
  32789. return object == null ? undefined : baseGet(object, path);
  32790. };
  32791. }
  32792. /**
  32793. * Creates an array of numbers (positive and/or negative) progressing from
  32794. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32795. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32796. * it's set to `start` with `start` then set to `0`.
  32797. *
  32798. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32799. * floating-point values which can produce unexpected results.
  32800. *
  32801. * @static
  32802. * @since 0.1.0
  32803. * @memberOf _
  32804. * @category Util
  32805. * @param {number} [start=0] The start of the range.
  32806. * @param {number} end The end of the range.
  32807. * @param {number} [step=1] The value to increment or decrement by.
  32808. * @returns {Array} Returns the range of numbers.
  32809. * @see _.inRange, _.rangeRight
  32810. * @example
  32811. *
  32812. * _.range(4);
  32813. * // => [0, 1, 2, 3]
  32814. *
  32815. * _.range(-4);
  32816. * // => [0, -1, -2, -3]
  32817. *
  32818. * _.range(1, 5);
  32819. * // => [1, 2, 3, 4]
  32820. *
  32821. * _.range(0, 20, 5);
  32822. * // => [0, 5, 10, 15]
  32823. *
  32824. * _.range(0, -4, -1);
  32825. * // => [0, -1, -2, -3]
  32826. *
  32827. * _.range(1, 4, 0);
  32828. * // => [1, 1, 1]
  32829. *
  32830. * _.range(0);
  32831. * // => []
  32832. */
  32833. var range = createRange();
  32834. /**
  32835. * This method is like `_.range` except that it populates values in
  32836. * descending order.
  32837. *
  32838. * @static
  32839. * @memberOf _
  32840. * @since 4.0.0
  32841. * @category Util
  32842. * @param {number} [start=0] The start of the range.
  32843. * @param {number} end The end of the range.
  32844. * @param {number} [step=1] The value to increment or decrement by.
  32845. * @returns {Array} Returns the range of numbers.
  32846. * @see _.inRange, _.range
  32847. * @example
  32848. *
  32849. * _.rangeRight(4);
  32850. * // => [3, 2, 1, 0]
  32851. *
  32852. * _.rangeRight(-4);
  32853. * // => [-3, -2, -1, 0]
  32854. *
  32855. * _.rangeRight(1, 5);
  32856. * // => [4, 3, 2, 1]
  32857. *
  32858. * _.rangeRight(0, 20, 5);
  32859. * // => [15, 10, 5, 0]
  32860. *
  32861. * _.rangeRight(0, -4, -1);
  32862. * // => [-3, -2, -1, 0]
  32863. *
  32864. * _.rangeRight(1, 4, 0);
  32865. * // => [1, 1, 1]
  32866. *
  32867. * _.rangeRight(0);
  32868. * // => []
  32869. */
  32870. var rangeRight = createRange(true);
  32871. /**
  32872. * This method returns a new empty array.
  32873. *
  32874. * @static
  32875. * @memberOf _
  32876. * @since 4.13.0
  32877. * @category Util
  32878. * @returns {Array} Returns the new empty array.
  32879. * @example
  32880. *
  32881. * var arrays = _.times(2, _.stubArray);
  32882. *
  32883. * console.log(arrays);
  32884. * // => [[], []]
  32885. *
  32886. * console.log(arrays[0] === arrays[1]);
  32887. * // => false
  32888. */
  32889. function stubArray() {
  32890. return [];
  32891. }
  32892. /**
  32893. * This method returns `false`.
  32894. *
  32895. * @static
  32896. * @memberOf _
  32897. * @since 4.13.0
  32898. * @category Util
  32899. * @returns {boolean} Returns `false`.
  32900. * @example
  32901. *
  32902. * _.times(2, _.stubFalse);
  32903. * // => [false, false]
  32904. */
  32905. function stubFalse() {
  32906. return false;
  32907. }
  32908. /**
  32909. * This method returns a new empty object.
  32910. *
  32911. * @static
  32912. * @memberOf _
  32913. * @since 4.13.0
  32914. * @category Util
  32915. * @returns {Object} Returns the new empty object.
  32916. * @example
  32917. *
  32918. * var objects = _.times(2, _.stubObject);
  32919. *
  32920. * console.log(objects);
  32921. * // => [{}, {}]
  32922. *
  32923. * console.log(objects[0] === objects[1]);
  32924. * // => false
  32925. */
  32926. function stubObject() {
  32927. return {};
  32928. }
  32929. /**
  32930. * This method returns an empty string.
  32931. *
  32932. * @static
  32933. * @memberOf _
  32934. * @since 4.13.0
  32935. * @category Util
  32936. * @returns {string} Returns the empty string.
  32937. * @example
  32938. *
  32939. * _.times(2, _.stubString);
  32940. * // => ['', '']
  32941. */
  32942. function stubString() {
  32943. return '';
  32944. }
  32945. /**
  32946. * This method returns `true`.
  32947. *
  32948. * @static
  32949. * @memberOf _
  32950. * @since 4.13.0
  32951. * @category Util
  32952. * @returns {boolean} Returns `true`.
  32953. * @example
  32954. *
  32955. * _.times(2, _.stubTrue);
  32956. * // => [true, true]
  32957. */
  32958. function stubTrue() {
  32959. return true;
  32960. }
  32961. /**
  32962. * Invokes the iteratee `n` times, returning an array of the results of
  32963. * each invocation. The iteratee is invoked with one argument; (index).
  32964. *
  32965. * @static
  32966. * @since 0.1.0
  32967. * @memberOf _
  32968. * @category Util
  32969. * @param {number} n The number of times to invoke `iteratee`.
  32970. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32971. * @returns {Array} Returns the array of results.
  32972. * @example
  32973. *
  32974. * _.times(3, String);
  32975. * // => ['0', '1', '2']
  32976. *
  32977. * _.times(4, _.constant(0));
  32978. * // => [0, 0, 0, 0]
  32979. */
  32980. function times(n, iteratee) {
  32981. n = toInteger(n);
  32982. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32983. return [];
  32984. }
  32985. var index = MAX_ARRAY_LENGTH,
  32986. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32987. iteratee = getIteratee(iteratee);
  32988. n -= MAX_ARRAY_LENGTH;
  32989. var result = baseTimes(length, iteratee);
  32990. while (++index < n) {
  32991. iteratee(index);
  32992. }
  32993. return result;
  32994. }
  32995. /**
  32996. * Converts `value` to a property path array.
  32997. *
  32998. * @static
  32999. * @memberOf _
  33000. * @since 4.0.0
  33001. * @category Util
  33002. * @param {*} value The value to convert.
  33003. * @returns {Array} Returns the new property path array.
  33004. * @example
  33005. *
  33006. * _.toPath('a.b.c');
  33007. * // => ['a', 'b', 'c']
  33008. *
  33009. * _.toPath('a[0].b.c');
  33010. * // => ['a', '0', 'b', 'c']
  33011. */
  33012. function toPath(value) {
  33013. if (isArray(value)) {
  33014. return arrayMap(value, toKey);
  33015. }
  33016. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  33017. }
  33018. /**
  33019. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  33020. *
  33021. * @static
  33022. * @since 0.1.0
  33023. * @memberOf _
  33024. * @category Util
  33025. * @param {string} [prefix=''] The value to prefix the ID with.
  33026. * @returns {string} Returns the unique ID.
  33027. * @example
  33028. *
  33029. * _.uniqueId('contact_');
  33030. * // => 'contact_104'
  33031. *
  33032. * _.uniqueId();
  33033. * // => '105'
  33034. */
  33035. function uniqueId(prefix) {
  33036. var id = ++idCounter;
  33037. return toString(prefix) + id;
  33038. }
  33039. /*------------------------------------------------------------------------*/
  33040. /**
  33041. * Adds two numbers.
  33042. *
  33043. * @static
  33044. * @memberOf _
  33045. * @since 3.4.0
  33046. * @category Math
  33047. * @param {number} augend The first number in an addition.
  33048. * @param {number} addend The second number in an addition.
  33049. * @returns {number} Returns the total.
  33050. * @example
  33051. *
  33052. * _.add(6, 4);
  33053. * // => 10
  33054. */
  33055. var add = createMathOperation(function(augend, addend) {
  33056. return augend + addend;
  33057. }, 0);
  33058. /**
  33059. * Computes `number` rounded up to `precision`.
  33060. *
  33061. * @static
  33062. * @memberOf _
  33063. * @since 3.10.0
  33064. * @category Math
  33065. * @param {number} number The number to round up.
  33066. * @param {number} [precision=0] The precision to round up to.
  33067. * @returns {number} Returns the rounded up number.
  33068. * @example
  33069. *
  33070. * _.ceil(4.006);
  33071. * // => 5
  33072. *
  33073. * _.ceil(6.004, 2);
  33074. * // => 6.01
  33075. *
  33076. * _.ceil(6040, -2);
  33077. * // => 6100
  33078. */
  33079. var ceil = createRound('ceil');
  33080. /**
  33081. * Divide two numbers.
  33082. *
  33083. * @static
  33084. * @memberOf _
  33085. * @since 4.7.0
  33086. * @category Math
  33087. * @param {number} dividend The first number in a division.
  33088. * @param {number} divisor The second number in a division.
  33089. * @returns {number} Returns the quotient.
  33090. * @example
  33091. *
  33092. * _.divide(6, 4);
  33093. * // => 1.5
  33094. */
  33095. var divide = createMathOperation(function(dividend, divisor) {
  33096. return dividend / divisor;
  33097. }, 1);
  33098. /**
  33099. * Computes `number` rounded down to `precision`.
  33100. *
  33101. * @static
  33102. * @memberOf _
  33103. * @since 3.10.0
  33104. * @category Math
  33105. * @param {number} number The number to round down.
  33106. * @param {number} [precision=0] The precision to round down to.
  33107. * @returns {number} Returns the rounded down number.
  33108. * @example
  33109. *
  33110. * _.floor(4.006);
  33111. * // => 4
  33112. *
  33113. * _.floor(0.046, 2);
  33114. * // => 0.04
  33115. *
  33116. * _.floor(4060, -2);
  33117. * // => 4000
  33118. */
  33119. var floor = createRound('floor');
  33120. /**
  33121. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33122. * `undefined` is returned.
  33123. *
  33124. * @static
  33125. * @since 0.1.0
  33126. * @memberOf _
  33127. * @category Math
  33128. * @param {Array} array The array to iterate over.
  33129. * @returns {*} Returns the maximum value.
  33130. * @example
  33131. *
  33132. * _.max([4, 2, 8, 6]);
  33133. * // => 8
  33134. *
  33135. * _.max([]);
  33136. * // => undefined
  33137. */
  33138. function max(array) {
  33139. return (array && array.length)
  33140. ? baseExtremum(array, identity, baseGt)
  33141. : undefined;
  33142. }
  33143. /**
  33144. * This method is like `_.max` except that it accepts `iteratee` which is
  33145. * invoked for each element in `array` to generate the criterion by which
  33146. * the value is ranked. The iteratee is invoked with one argument: (value).
  33147. *
  33148. * @static
  33149. * @memberOf _
  33150. * @since 4.0.0
  33151. * @category Math
  33152. * @param {Array} array The array to iterate over.
  33153. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33154. * @returns {*} Returns the maximum value.
  33155. * @example
  33156. *
  33157. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33158. *
  33159. * _.maxBy(objects, function(o) { return o.n; });
  33160. * // => { 'n': 2 }
  33161. *
  33162. * // The `_.property` iteratee shorthand.
  33163. * _.maxBy(objects, 'n');
  33164. * // => { 'n': 2 }
  33165. */
  33166. function maxBy(array, iteratee) {
  33167. return (array && array.length)
  33168. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33169. : undefined;
  33170. }
  33171. /**
  33172. * Computes the mean of the values in `array`.
  33173. *
  33174. * @static
  33175. * @memberOf _
  33176. * @since 4.0.0
  33177. * @category Math
  33178. * @param {Array} array The array to iterate over.
  33179. * @returns {number} Returns the mean.
  33180. * @example
  33181. *
  33182. * _.mean([4, 2, 8, 6]);
  33183. * // => 5
  33184. */
  33185. function mean(array) {
  33186. return baseMean(array, identity);
  33187. }
  33188. /**
  33189. * This method is like `_.mean` except that it accepts `iteratee` which is
  33190. * invoked for each element in `array` to generate the value to be averaged.
  33191. * The iteratee is invoked with one argument: (value).
  33192. *
  33193. * @static
  33194. * @memberOf _
  33195. * @since 4.7.0
  33196. * @category Math
  33197. * @param {Array} array The array to iterate over.
  33198. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33199. * @returns {number} Returns the mean.
  33200. * @example
  33201. *
  33202. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33203. *
  33204. * _.meanBy(objects, function(o) { return o.n; });
  33205. * // => 5
  33206. *
  33207. * // The `_.property` iteratee shorthand.
  33208. * _.meanBy(objects, 'n');
  33209. * // => 5
  33210. */
  33211. function meanBy(array, iteratee) {
  33212. return baseMean(array, getIteratee(iteratee, 2));
  33213. }
  33214. /**
  33215. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33216. * `undefined` is returned.
  33217. *
  33218. * @static
  33219. * @since 0.1.0
  33220. * @memberOf _
  33221. * @category Math
  33222. * @param {Array} array The array to iterate over.
  33223. * @returns {*} Returns the minimum value.
  33224. * @example
  33225. *
  33226. * _.min([4, 2, 8, 6]);
  33227. * // => 2
  33228. *
  33229. * _.min([]);
  33230. * // => undefined
  33231. */
  33232. function min(array) {
  33233. return (array && array.length)
  33234. ? baseExtremum(array, identity, baseLt)
  33235. : undefined;
  33236. }
  33237. /**
  33238. * This method is like `_.min` except that it accepts `iteratee` which is
  33239. * invoked for each element in `array` to generate the criterion by which
  33240. * the value is ranked. The iteratee is invoked with one argument: (value).
  33241. *
  33242. * @static
  33243. * @memberOf _
  33244. * @since 4.0.0
  33245. * @category Math
  33246. * @param {Array} array The array to iterate over.
  33247. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33248. * @returns {*} Returns the minimum value.
  33249. * @example
  33250. *
  33251. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33252. *
  33253. * _.minBy(objects, function(o) { return o.n; });
  33254. * // => { 'n': 1 }
  33255. *
  33256. * // The `_.property` iteratee shorthand.
  33257. * _.minBy(objects, 'n');
  33258. * // => { 'n': 1 }
  33259. */
  33260. function minBy(array, iteratee) {
  33261. return (array && array.length)
  33262. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33263. : undefined;
  33264. }
  33265. /**
  33266. * Multiply two numbers.
  33267. *
  33268. * @static
  33269. * @memberOf _
  33270. * @since 4.7.0
  33271. * @category Math
  33272. * @param {number} multiplier The first number in a multiplication.
  33273. * @param {number} multiplicand The second number in a multiplication.
  33274. * @returns {number} Returns the product.
  33275. * @example
  33276. *
  33277. * _.multiply(6, 4);
  33278. * // => 24
  33279. */
  33280. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33281. return multiplier * multiplicand;
  33282. }, 1);
  33283. /**
  33284. * Computes `number` rounded to `precision`.
  33285. *
  33286. * @static
  33287. * @memberOf _
  33288. * @since 3.10.0
  33289. * @category Math
  33290. * @param {number} number The number to round.
  33291. * @param {number} [precision=0] The precision to round to.
  33292. * @returns {number} Returns the rounded number.
  33293. * @example
  33294. *
  33295. * _.round(4.006);
  33296. * // => 4
  33297. *
  33298. * _.round(4.006, 2);
  33299. * // => 4.01
  33300. *
  33301. * _.round(4060, -2);
  33302. * // => 4100
  33303. */
  33304. var round = createRound('round');
  33305. /**
  33306. * Subtract two numbers.
  33307. *
  33308. * @static
  33309. * @memberOf _
  33310. * @since 4.0.0
  33311. * @category Math
  33312. * @param {number} minuend The first number in a subtraction.
  33313. * @param {number} subtrahend The second number in a subtraction.
  33314. * @returns {number} Returns the difference.
  33315. * @example
  33316. *
  33317. * _.subtract(6, 4);
  33318. * // => 2
  33319. */
  33320. var subtract = createMathOperation(function(minuend, subtrahend) {
  33321. return minuend - subtrahend;
  33322. }, 0);
  33323. /**
  33324. * Computes the sum of the values in `array`.
  33325. *
  33326. * @static
  33327. * @memberOf _
  33328. * @since 3.4.0
  33329. * @category Math
  33330. * @param {Array} array The array to iterate over.
  33331. * @returns {number} Returns the sum.
  33332. * @example
  33333. *
  33334. * _.sum([4, 2, 8, 6]);
  33335. * // => 20
  33336. */
  33337. function sum(array) {
  33338. return (array && array.length)
  33339. ? baseSum(array, identity)
  33340. : 0;
  33341. }
  33342. /**
  33343. * This method is like `_.sum` except that it accepts `iteratee` which is
  33344. * invoked for each element in `array` to generate the value to be summed.
  33345. * The iteratee is invoked with one argument: (value).
  33346. *
  33347. * @static
  33348. * @memberOf _
  33349. * @since 4.0.0
  33350. * @category Math
  33351. * @param {Array} array The array to iterate over.
  33352. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33353. * @returns {number} Returns the sum.
  33354. * @example
  33355. *
  33356. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33357. *
  33358. * _.sumBy(objects, function(o) { return o.n; });
  33359. * // => 20
  33360. *
  33361. * // The `_.property` iteratee shorthand.
  33362. * _.sumBy(objects, 'n');
  33363. * // => 20
  33364. */
  33365. function sumBy(array, iteratee) {
  33366. return (array && array.length)
  33367. ? baseSum(array, getIteratee(iteratee, 2))
  33368. : 0;
  33369. }
  33370. /*------------------------------------------------------------------------*/
  33371. // Add methods that return wrapped values in chain sequences.
  33372. lodash.after = after;
  33373. lodash.ary = ary;
  33374. lodash.assign = assign;
  33375. lodash.assignIn = assignIn;
  33376. lodash.assignInWith = assignInWith;
  33377. lodash.assignWith = assignWith;
  33378. lodash.at = at;
  33379. lodash.before = before;
  33380. lodash.bind = bind;
  33381. lodash.bindAll = bindAll;
  33382. lodash.bindKey = bindKey;
  33383. lodash.castArray = castArray;
  33384. lodash.chain = chain;
  33385. lodash.chunk = chunk;
  33386. lodash.compact = compact;
  33387. lodash.concat = concat;
  33388. lodash.cond = cond;
  33389. lodash.conforms = conforms;
  33390. lodash.constant = constant;
  33391. lodash.countBy = countBy;
  33392. lodash.create = create;
  33393. lodash.curry = curry;
  33394. lodash.curryRight = curryRight;
  33395. lodash.debounce = debounce;
  33396. lodash.defaults = defaults;
  33397. lodash.defaultsDeep = defaultsDeep;
  33398. lodash.defer = defer;
  33399. lodash.delay = delay;
  33400. lodash.difference = difference;
  33401. lodash.differenceBy = differenceBy;
  33402. lodash.differenceWith = differenceWith;
  33403. lodash.drop = drop;
  33404. lodash.dropRight = dropRight;
  33405. lodash.dropRightWhile = dropRightWhile;
  33406. lodash.dropWhile = dropWhile;
  33407. lodash.fill = fill;
  33408. lodash.filter = filter;
  33409. lodash.flatMap = flatMap;
  33410. lodash.flatMapDeep = flatMapDeep;
  33411. lodash.flatMapDepth = flatMapDepth;
  33412. lodash.flatten = flatten;
  33413. lodash.flattenDeep = flattenDeep;
  33414. lodash.flattenDepth = flattenDepth;
  33415. lodash.flip = flip;
  33416. lodash.flow = flow;
  33417. lodash.flowRight = flowRight;
  33418. lodash.fromPairs = fromPairs;
  33419. lodash.functions = functions;
  33420. lodash.functionsIn = functionsIn;
  33421. lodash.groupBy = groupBy;
  33422. lodash.initial = initial;
  33423. lodash.intersection = intersection;
  33424. lodash.intersectionBy = intersectionBy;
  33425. lodash.intersectionWith = intersectionWith;
  33426. lodash.invert = invert;
  33427. lodash.invertBy = invertBy;
  33428. lodash.invokeMap = invokeMap;
  33429. lodash.iteratee = iteratee;
  33430. lodash.keyBy = keyBy;
  33431. lodash.keys = keys;
  33432. lodash.keysIn = keysIn;
  33433. lodash.map = map;
  33434. lodash.mapKeys = mapKeys;
  33435. lodash.mapValues = mapValues;
  33436. lodash.matches = matches;
  33437. lodash.matchesProperty = matchesProperty;
  33438. lodash.memoize = memoize;
  33439. lodash.merge = merge;
  33440. lodash.mergeWith = mergeWith;
  33441. lodash.method = method;
  33442. lodash.methodOf = methodOf;
  33443. lodash.mixin = mixin;
  33444. lodash.negate = negate;
  33445. lodash.nthArg = nthArg;
  33446. lodash.omit = omit;
  33447. lodash.omitBy = omitBy;
  33448. lodash.once = once;
  33449. lodash.orderBy = orderBy;
  33450. lodash.over = over;
  33451. lodash.overArgs = overArgs;
  33452. lodash.overEvery = overEvery;
  33453. lodash.overSome = overSome;
  33454. lodash.partial = partial;
  33455. lodash.partialRight = partialRight;
  33456. lodash.partition = partition;
  33457. lodash.pick = pick;
  33458. lodash.pickBy = pickBy;
  33459. lodash.property = property;
  33460. lodash.propertyOf = propertyOf;
  33461. lodash.pull = pull;
  33462. lodash.pullAll = pullAll;
  33463. lodash.pullAllBy = pullAllBy;
  33464. lodash.pullAllWith = pullAllWith;
  33465. lodash.pullAt = pullAt;
  33466. lodash.range = range;
  33467. lodash.rangeRight = rangeRight;
  33468. lodash.rearg = rearg;
  33469. lodash.reject = reject;
  33470. lodash.remove = remove;
  33471. lodash.rest = rest;
  33472. lodash.reverse = reverse;
  33473. lodash.sampleSize = sampleSize;
  33474. lodash.set = set;
  33475. lodash.setWith = setWith;
  33476. lodash.shuffle = shuffle;
  33477. lodash.slice = slice;
  33478. lodash.sortBy = sortBy;
  33479. lodash.sortedUniq = sortedUniq;
  33480. lodash.sortedUniqBy = sortedUniqBy;
  33481. lodash.split = split;
  33482. lodash.spread = spread;
  33483. lodash.tail = tail;
  33484. lodash.take = take;
  33485. lodash.takeRight = takeRight;
  33486. lodash.takeRightWhile = takeRightWhile;
  33487. lodash.takeWhile = takeWhile;
  33488. lodash.tap = tap;
  33489. lodash.throttle = throttle;
  33490. lodash.thru = thru;
  33491. lodash.toArray = toArray;
  33492. lodash.toPairs = toPairs;
  33493. lodash.toPairsIn = toPairsIn;
  33494. lodash.toPath = toPath;
  33495. lodash.toPlainObject = toPlainObject;
  33496. lodash.transform = transform;
  33497. lodash.unary = unary;
  33498. lodash.union = union;
  33499. lodash.unionBy = unionBy;
  33500. lodash.unionWith = unionWith;
  33501. lodash.uniq = uniq;
  33502. lodash.uniqBy = uniqBy;
  33503. lodash.uniqWith = uniqWith;
  33504. lodash.unset = unset;
  33505. lodash.unzip = unzip;
  33506. lodash.unzipWith = unzipWith;
  33507. lodash.update = update;
  33508. lodash.updateWith = updateWith;
  33509. lodash.values = values;
  33510. lodash.valuesIn = valuesIn;
  33511. lodash.without = without;
  33512. lodash.words = words;
  33513. lodash.wrap = wrap;
  33514. lodash.xor = xor;
  33515. lodash.xorBy = xorBy;
  33516. lodash.xorWith = xorWith;
  33517. lodash.zip = zip;
  33518. lodash.zipObject = zipObject;
  33519. lodash.zipObjectDeep = zipObjectDeep;
  33520. lodash.zipWith = zipWith;
  33521. // Add aliases.
  33522. lodash.entries = toPairs;
  33523. lodash.entriesIn = toPairsIn;
  33524. lodash.extend = assignIn;
  33525. lodash.extendWith = assignInWith;
  33526. // Add methods to `lodash.prototype`.
  33527. mixin(lodash, lodash);
  33528. /*------------------------------------------------------------------------*/
  33529. // Add methods that return unwrapped values in chain sequences.
  33530. lodash.add = add;
  33531. lodash.attempt = attempt;
  33532. lodash.camelCase = camelCase;
  33533. lodash.capitalize = capitalize;
  33534. lodash.ceil = ceil;
  33535. lodash.clamp = clamp;
  33536. lodash.clone = clone;
  33537. lodash.cloneDeep = cloneDeep;
  33538. lodash.cloneDeepWith = cloneDeepWith;
  33539. lodash.cloneWith = cloneWith;
  33540. lodash.conformsTo = conformsTo;
  33541. lodash.deburr = deburr;
  33542. lodash.defaultTo = defaultTo;
  33543. lodash.divide = divide;
  33544. lodash.endsWith = endsWith;
  33545. lodash.eq = eq;
  33546. lodash.escape = escape;
  33547. lodash.escapeRegExp = escapeRegExp;
  33548. lodash.every = every;
  33549. lodash.find = find;
  33550. lodash.findIndex = findIndex;
  33551. lodash.findKey = findKey;
  33552. lodash.findLast = findLast;
  33553. lodash.findLastIndex = findLastIndex;
  33554. lodash.findLastKey = findLastKey;
  33555. lodash.floor = floor;
  33556. lodash.forEach = forEach;
  33557. lodash.forEachRight = forEachRight;
  33558. lodash.forIn = forIn;
  33559. lodash.forInRight = forInRight;
  33560. lodash.forOwn = forOwn;
  33561. lodash.forOwnRight = forOwnRight;
  33562. lodash.get = get;
  33563. lodash.gt = gt;
  33564. lodash.gte = gte;
  33565. lodash.has = has;
  33566. lodash.hasIn = hasIn;
  33567. lodash.head = head;
  33568. lodash.identity = identity;
  33569. lodash.includes = includes;
  33570. lodash.indexOf = indexOf;
  33571. lodash.inRange = inRange;
  33572. lodash.invoke = invoke;
  33573. lodash.isArguments = isArguments;
  33574. lodash.isArray = isArray;
  33575. lodash.isArrayBuffer = isArrayBuffer;
  33576. lodash.isArrayLike = isArrayLike;
  33577. lodash.isArrayLikeObject = isArrayLikeObject;
  33578. lodash.isBoolean = isBoolean;
  33579. lodash.isBuffer = isBuffer;
  33580. lodash.isDate = isDate;
  33581. lodash.isElement = isElement;
  33582. lodash.isEmpty = isEmpty;
  33583. lodash.isEqual = isEqual;
  33584. lodash.isEqualWith = isEqualWith;
  33585. lodash.isError = isError;
  33586. lodash.isFinite = isFinite;
  33587. lodash.isFunction = isFunction;
  33588. lodash.isInteger = isInteger;
  33589. lodash.isLength = isLength;
  33590. lodash.isMap = isMap;
  33591. lodash.isMatch = isMatch;
  33592. lodash.isMatchWith = isMatchWith;
  33593. lodash.isNaN = isNaN;
  33594. lodash.isNative = isNative;
  33595. lodash.isNil = isNil;
  33596. lodash.isNull = isNull;
  33597. lodash.isNumber = isNumber;
  33598. lodash.isObject = isObject;
  33599. lodash.isObjectLike = isObjectLike;
  33600. lodash.isPlainObject = isPlainObject;
  33601. lodash.isRegExp = isRegExp;
  33602. lodash.isSafeInteger = isSafeInteger;
  33603. lodash.isSet = isSet;
  33604. lodash.isString = isString;
  33605. lodash.isSymbol = isSymbol;
  33606. lodash.isTypedArray = isTypedArray;
  33607. lodash.isUndefined = isUndefined;
  33608. lodash.isWeakMap = isWeakMap;
  33609. lodash.isWeakSet = isWeakSet;
  33610. lodash.join = join;
  33611. lodash.kebabCase = kebabCase;
  33612. lodash.last = last;
  33613. lodash.lastIndexOf = lastIndexOf;
  33614. lodash.lowerCase = lowerCase;
  33615. lodash.lowerFirst = lowerFirst;
  33616. lodash.lt = lt;
  33617. lodash.lte = lte;
  33618. lodash.max = max;
  33619. lodash.maxBy = maxBy;
  33620. lodash.mean = mean;
  33621. lodash.meanBy = meanBy;
  33622. lodash.min = min;
  33623. lodash.minBy = minBy;
  33624. lodash.stubArray = stubArray;
  33625. lodash.stubFalse = stubFalse;
  33626. lodash.stubObject = stubObject;
  33627. lodash.stubString = stubString;
  33628. lodash.stubTrue = stubTrue;
  33629. lodash.multiply = multiply;
  33630. lodash.nth = nth;
  33631. lodash.noConflict = noConflict;
  33632. lodash.noop = noop;
  33633. lodash.now = now;
  33634. lodash.pad = pad;
  33635. lodash.padEnd = padEnd;
  33636. lodash.padStart = padStart;
  33637. lodash.parseInt = parseInt;
  33638. lodash.random = random;
  33639. lodash.reduce = reduce;
  33640. lodash.reduceRight = reduceRight;
  33641. lodash.repeat = repeat;
  33642. lodash.replace = replace;
  33643. lodash.result = result;
  33644. lodash.round = round;
  33645. lodash.runInContext = runInContext;
  33646. lodash.sample = sample;
  33647. lodash.size = size;
  33648. lodash.snakeCase = snakeCase;
  33649. lodash.some = some;
  33650. lodash.sortedIndex = sortedIndex;
  33651. lodash.sortedIndexBy = sortedIndexBy;
  33652. lodash.sortedIndexOf = sortedIndexOf;
  33653. lodash.sortedLastIndex = sortedLastIndex;
  33654. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33655. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33656. lodash.startCase = startCase;
  33657. lodash.startsWith = startsWith;
  33658. lodash.subtract = subtract;
  33659. lodash.sum = sum;
  33660. lodash.sumBy = sumBy;
  33661. lodash.template = template;
  33662. lodash.times = times;
  33663. lodash.toFinite = toFinite;
  33664. lodash.toInteger = toInteger;
  33665. lodash.toLength = toLength;
  33666. lodash.toLower = toLower;
  33667. lodash.toNumber = toNumber;
  33668. lodash.toSafeInteger = toSafeInteger;
  33669. lodash.toString = toString;
  33670. lodash.toUpper = toUpper;
  33671. lodash.trim = trim;
  33672. lodash.trimEnd = trimEnd;
  33673. lodash.trimStart = trimStart;
  33674. lodash.truncate = truncate;
  33675. lodash.unescape = unescape;
  33676. lodash.uniqueId = uniqueId;
  33677. lodash.upperCase = upperCase;
  33678. lodash.upperFirst = upperFirst;
  33679. // Add aliases.
  33680. lodash.each = forEach;
  33681. lodash.eachRight = forEachRight;
  33682. lodash.first = head;
  33683. mixin(lodash, (function() {
  33684. var source = {};
  33685. baseForOwn(lodash, function(func, methodName) {
  33686. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33687. source[methodName] = func;
  33688. }
  33689. });
  33690. return source;
  33691. }()), { 'chain': false });
  33692. /*------------------------------------------------------------------------*/
  33693. /**
  33694. * The semantic version number.
  33695. *
  33696. * @static
  33697. * @memberOf _
  33698. * @type {string}
  33699. */
  33700. lodash.VERSION = VERSION;
  33701. // Assign default placeholders.
  33702. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33703. lodash[methodName].placeholder = lodash;
  33704. });
  33705. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33706. arrayEach(['drop', 'take'], function(methodName, index) {
  33707. LazyWrapper.prototype[methodName] = function(n) {
  33708. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33709. var result = (this.__filtered__ && !index)
  33710. ? new LazyWrapper(this)
  33711. : this.clone();
  33712. if (result.__filtered__) {
  33713. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33714. } else {
  33715. result.__views__.push({
  33716. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33717. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33718. });
  33719. }
  33720. return result;
  33721. };
  33722. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33723. return this.reverse()[methodName](n).reverse();
  33724. };
  33725. });
  33726. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33727. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33728. var type = index + 1,
  33729. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33730. LazyWrapper.prototype[methodName] = function(iteratee) {
  33731. var result = this.clone();
  33732. result.__iteratees__.push({
  33733. 'iteratee': getIteratee(iteratee, 3),
  33734. 'type': type
  33735. });
  33736. result.__filtered__ = result.__filtered__ || isFilter;
  33737. return result;
  33738. };
  33739. });
  33740. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33741. arrayEach(['head', 'last'], function(methodName, index) {
  33742. var takeName = 'take' + (index ? 'Right' : '');
  33743. LazyWrapper.prototype[methodName] = function() {
  33744. return this[takeName](1).value()[0];
  33745. };
  33746. });
  33747. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33748. arrayEach(['initial', 'tail'], function(methodName, index) {
  33749. var dropName = 'drop' + (index ? '' : 'Right');
  33750. LazyWrapper.prototype[methodName] = function() {
  33751. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33752. };
  33753. });
  33754. LazyWrapper.prototype.compact = function() {
  33755. return this.filter(identity);
  33756. };
  33757. LazyWrapper.prototype.find = function(predicate) {
  33758. return this.filter(predicate).head();
  33759. };
  33760. LazyWrapper.prototype.findLast = function(predicate) {
  33761. return this.reverse().find(predicate);
  33762. };
  33763. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33764. if (typeof path == 'function') {
  33765. return new LazyWrapper(this);
  33766. }
  33767. return this.map(function(value) {
  33768. return baseInvoke(value, path, args);
  33769. });
  33770. });
  33771. LazyWrapper.prototype.reject = function(predicate) {
  33772. return this.filter(negate(getIteratee(predicate)));
  33773. };
  33774. LazyWrapper.prototype.slice = function(start, end) {
  33775. start = toInteger(start);
  33776. var result = this;
  33777. if (result.__filtered__ && (start > 0 || end < 0)) {
  33778. return new LazyWrapper(result);
  33779. }
  33780. if (start < 0) {
  33781. result = result.takeRight(-start);
  33782. } else if (start) {
  33783. result = result.drop(start);
  33784. }
  33785. if (end !== undefined) {
  33786. end = toInteger(end);
  33787. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33788. }
  33789. return result;
  33790. };
  33791. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33792. return this.reverse().takeWhile(predicate).reverse();
  33793. };
  33794. LazyWrapper.prototype.toArray = function() {
  33795. return this.take(MAX_ARRAY_LENGTH);
  33796. };
  33797. // Add `LazyWrapper` methods to `lodash.prototype`.
  33798. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33799. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33800. isTaker = /^(?:head|last)$/.test(methodName),
  33801. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33802. retUnwrapped = isTaker || /^find/.test(methodName);
  33803. if (!lodashFunc) {
  33804. return;
  33805. }
  33806. lodash.prototype[methodName] = function() {
  33807. var value = this.__wrapped__,
  33808. args = isTaker ? [1] : arguments,
  33809. isLazy = value instanceof LazyWrapper,
  33810. iteratee = args[0],
  33811. useLazy = isLazy || isArray(value);
  33812. var interceptor = function(value) {
  33813. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33814. return (isTaker && chainAll) ? result[0] : result;
  33815. };
  33816. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33817. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33818. isLazy = useLazy = false;
  33819. }
  33820. var chainAll = this.__chain__,
  33821. isHybrid = !!this.__actions__.length,
  33822. isUnwrapped = retUnwrapped && !chainAll,
  33823. onlyLazy = isLazy && !isHybrid;
  33824. if (!retUnwrapped && useLazy) {
  33825. value = onlyLazy ? value : new LazyWrapper(this);
  33826. var result = func.apply(value, args);
  33827. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33828. return new LodashWrapper(result, chainAll);
  33829. }
  33830. if (isUnwrapped && onlyLazy) {
  33831. return func.apply(this, args);
  33832. }
  33833. result = this.thru(interceptor);
  33834. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33835. };
  33836. });
  33837. // Add `Array` methods to `lodash.prototype`.
  33838. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33839. var func = arrayProto[methodName],
  33840. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33841. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33842. lodash.prototype[methodName] = function() {
  33843. var args = arguments;
  33844. if (retUnwrapped && !this.__chain__) {
  33845. var value = this.value();
  33846. return func.apply(isArray(value) ? value : [], args);
  33847. }
  33848. return this[chainName](function(value) {
  33849. return func.apply(isArray(value) ? value : [], args);
  33850. });
  33851. };
  33852. });
  33853. // Map minified method names to their real names.
  33854. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33855. var lodashFunc = lodash[methodName];
  33856. if (lodashFunc) {
  33857. var key = lodashFunc.name + '';
  33858. if (!hasOwnProperty.call(realNames, key)) {
  33859. realNames[key] = [];
  33860. }
  33861. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33862. }
  33863. });
  33864. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33865. 'name': 'wrapper',
  33866. 'func': undefined
  33867. }];
  33868. // Add methods to `LazyWrapper`.
  33869. LazyWrapper.prototype.clone = lazyClone;
  33870. LazyWrapper.prototype.reverse = lazyReverse;
  33871. LazyWrapper.prototype.value = lazyValue;
  33872. // Add chain sequence methods to the `lodash` wrapper.
  33873. lodash.prototype.at = wrapperAt;
  33874. lodash.prototype.chain = wrapperChain;
  33875. lodash.prototype.commit = wrapperCommit;
  33876. lodash.prototype.next = wrapperNext;
  33877. lodash.prototype.plant = wrapperPlant;
  33878. lodash.prototype.reverse = wrapperReverse;
  33879. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33880. // Add lazy aliases.
  33881. lodash.prototype.first = lodash.prototype.head;
  33882. if (symIterator) {
  33883. lodash.prototype[symIterator] = wrapperToIterator;
  33884. }
  33885. return lodash;
  33886. });
  33887. /*--------------------------------------------------------------------------*/
  33888. // Export lodash.
  33889. var _ = runInContext();
  33890. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33891. if (true) {
  33892. // Expose Lodash on the global object to prevent errors when Lodash is
  33893. // loaded by a script tag in the presence of an AMD loader.
  33894. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33895. // Use `_.noConflict` to remove Lodash from the global object.
  33896. root._ = _;
  33897. // Define as an anonymous module so, through path mapping, it can be
  33898. // referenced as the "underscore" module.
  33899. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33900. return _;
  33901. }).call(exports, __webpack_require__, exports, module),
  33902. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33903. }
  33904. // Check for `exports` after `define` in case a build optimizer adds it.
  33905. else {}
  33906. }.call(this));
  33907. /* 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)))
  33908. /***/ }),
  33909. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33910. /*!***************************************************!*\
  33911. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33912. \***************************************************/
  33913. /*! exports provided: default */
  33914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33915. "use strict";
  33916. __webpack_require__.r(__webpack_exports__);
  33917. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33918. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33919. * @version 1.16.1
  33920. * @license
  33921. * Copyright (c) 2016 Federico Zivolo and contributors
  33922. *
  33923. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33924. * of this software and associated documentation files (the "Software"), to deal
  33925. * in the Software without restriction, including without limitation the rights
  33926. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33927. * copies of the Software, and to permit persons to whom the Software is
  33928. * furnished to do so, subject to the following conditions:
  33929. *
  33930. * The above copyright notice and this permission notice shall be included in all
  33931. * copies or substantial portions of the Software.
  33932. *
  33933. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33934. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33935. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33936. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33937. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33938. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33939. * SOFTWARE.
  33940. */
  33941. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33942. var timeoutDuration = function () {
  33943. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33944. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33945. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33946. return 1;
  33947. }
  33948. }
  33949. return 0;
  33950. }();
  33951. function microtaskDebounce(fn) {
  33952. var called = false;
  33953. return function () {
  33954. if (called) {
  33955. return;
  33956. }
  33957. called = true;
  33958. window.Promise.resolve().then(function () {
  33959. called = false;
  33960. fn();
  33961. });
  33962. };
  33963. }
  33964. function taskDebounce(fn) {
  33965. var scheduled = false;
  33966. return function () {
  33967. if (!scheduled) {
  33968. scheduled = true;
  33969. setTimeout(function () {
  33970. scheduled = false;
  33971. fn();
  33972. }, timeoutDuration);
  33973. }
  33974. };
  33975. }
  33976. var supportsMicroTasks = isBrowser && window.Promise;
  33977. /**
  33978. * Create a debounced version of a method, that's asynchronously deferred
  33979. * but called in the minimum time possible.
  33980. *
  33981. * @method
  33982. * @memberof Popper.Utils
  33983. * @argument {Function} fn
  33984. * @returns {Function}
  33985. */
  33986. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33987. /**
  33988. * Check if the given variable is a function
  33989. * @method
  33990. * @memberof Popper.Utils
  33991. * @argument {Any} functionToCheck - variable to check
  33992. * @returns {Boolean} answer to: is a function?
  33993. */
  33994. function isFunction(functionToCheck) {
  33995. var getType = {};
  33996. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33997. }
  33998. /**
  33999. * Get CSS computed property of the given element
  34000. * @method
  34001. * @memberof Popper.Utils
  34002. * @argument {Eement} element
  34003. * @argument {String} property
  34004. */
  34005. function getStyleComputedProperty(element, property) {
  34006. if (element.nodeType !== 1) {
  34007. return [];
  34008. }
  34009. // NOTE: 1 DOM access here
  34010. var window = element.ownerDocument.defaultView;
  34011. var css = window.getComputedStyle(element, null);
  34012. return property ? css[property] : css;
  34013. }
  34014. /**
  34015. * Returns the parentNode or the host of the element
  34016. * @method
  34017. * @memberof Popper.Utils
  34018. * @argument {Element} element
  34019. * @returns {Element} parent
  34020. */
  34021. function getParentNode(element) {
  34022. if (element.nodeName === 'HTML') {
  34023. return element;
  34024. }
  34025. return element.parentNode || element.host;
  34026. }
  34027. /**
  34028. * Returns the scrolling parent of the given element
  34029. * @method
  34030. * @memberof Popper.Utils
  34031. * @argument {Element} element
  34032. * @returns {Element} scroll parent
  34033. */
  34034. function getScrollParent(element) {
  34035. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  34036. if (!element) {
  34037. return document.body;
  34038. }
  34039. switch (element.nodeName) {
  34040. case 'HTML':
  34041. case 'BODY':
  34042. return element.ownerDocument.body;
  34043. case '#document':
  34044. return element.body;
  34045. }
  34046. // Firefox want us to check `-x` and `-y` variations as well
  34047. var _getStyleComputedProp = getStyleComputedProperty(element),
  34048. overflow = _getStyleComputedProp.overflow,
  34049. overflowX = _getStyleComputedProp.overflowX,
  34050. overflowY = _getStyleComputedProp.overflowY;
  34051. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  34052. return element;
  34053. }
  34054. return getScrollParent(getParentNode(element));
  34055. }
  34056. /**
  34057. * Returns the reference node of the reference object, or the reference object itself.
  34058. * @method
  34059. * @memberof Popper.Utils
  34060. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  34061. * @returns {Element} parent
  34062. */
  34063. function getReferenceNode(reference) {
  34064. return reference && reference.referenceNode ? reference.referenceNode : reference;
  34065. }
  34066. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  34067. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  34068. /**
  34069. * Determines if the browser is Internet Explorer
  34070. * @method
  34071. * @memberof Popper.Utils
  34072. * @param {Number} version to check
  34073. * @returns {Boolean} isIE
  34074. */
  34075. function isIE(version) {
  34076. if (version === 11) {
  34077. return isIE11;
  34078. }
  34079. if (version === 10) {
  34080. return isIE10;
  34081. }
  34082. return isIE11 || isIE10;
  34083. }
  34084. /**
  34085. * Returns the offset parent of the given element
  34086. * @method
  34087. * @memberof Popper.Utils
  34088. * @argument {Element} element
  34089. * @returns {Element} offset parent
  34090. */
  34091. function getOffsetParent(element) {
  34092. if (!element) {
  34093. return document.documentElement;
  34094. }
  34095. var noOffsetParent = isIE(10) ? document.body : null;
  34096. // NOTE: 1 DOM access here
  34097. var offsetParent = element.offsetParent || null;
  34098. // Skip hidden elements which don't have an offsetParent
  34099. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  34100. offsetParent = (element = element.nextElementSibling).offsetParent;
  34101. }
  34102. var nodeName = offsetParent && offsetParent.nodeName;
  34103. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  34104. return element ? element.ownerDocument.documentElement : document.documentElement;
  34105. }
  34106. // .offsetParent will return the closest TH, TD or TABLE in case
  34107. // no offsetParent is present, I hate this job...
  34108. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  34109. return getOffsetParent(offsetParent);
  34110. }
  34111. return offsetParent;
  34112. }
  34113. function isOffsetContainer(element) {
  34114. var nodeName = element.nodeName;
  34115. if (nodeName === 'BODY') {
  34116. return false;
  34117. }
  34118. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34119. }
  34120. /**
  34121. * Finds the root node (document, shadowDOM root) of the given element
  34122. * @method
  34123. * @memberof Popper.Utils
  34124. * @argument {Element} node
  34125. * @returns {Element} root node
  34126. */
  34127. function getRoot(node) {
  34128. if (node.parentNode !== null) {
  34129. return getRoot(node.parentNode);
  34130. }
  34131. return node;
  34132. }
  34133. /**
  34134. * Finds the offset parent common to the two provided nodes
  34135. * @method
  34136. * @memberof Popper.Utils
  34137. * @argument {Element} element1
  34138. * @argument {Element} element2
  34139. * @returns {Element} common offset parent
  34140. */
  34141. function findCommonOffsetParent(element1, element2) {
  34142. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34143. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34144. return document.documentElement;
  34145. }
  34146. // Here we make sure to give as "start" the element that comes first in the DOM
  34147. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34148. var start = order ? element1 : element2;
  34149. var end = order ? element2 : element1;
  34150. // Get common ancestor container
  34151. var range = document.createRange();
  34152. range.setStart(start, 0);
  34153. range.setEnd(end, 0);
  34154. var commonAncestorContainer = range.commonAncestorContainer;
  34155. // Both nodes are inside #document
  34156. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34157. if (isOffsetContainer(commonAncestorContainer)) {
  34158. return commonAncestorContainer;
  34159. }
  34160. return getOffsetParent(commonAncestorContainer);
  34161. }
  34162. // one of the nodes is inside shadowDOM, find which one
  34163. var element1root = getRoot(element1);
  34164. if (element1root.host) {
  34165. return findCommonOffsetParent(element1root.host, element2);
  34166. } else {
  34167. return findCommonOffsetParent(element1, getRoot(element2).host);
  34168. }
  34169. }
  34170. /**
  34171. * Gets the scroll value of the given element in the given side (top and left)
  34172. * @method
  34173. * @memberof Popper.Utils
  34174. * @argument {Element} element
  34175. * @argument {String} side `top` or `left`
  34176. * @returns {number} amount of scrolled pixels
  34177. */
  34178. function getScroll(element) {
  34179. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34180. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34181. var nodeName = element.nodeName;
  34182. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34183. var html = element.ownerDocument.documentElement;
  34184. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34185. return scrollingElement[upperSide];
  34186. }
  34187. return element[upperSide];
  34188. }
  34189. /*
  34190. * Sum or subtract the element scroll values (left and top) from a given rect object
  34191. * @method
  34192. * @memberof Popper.Utils
  34193. * @param {Object} rect - Rect object you want to change
  34194. * @param {HTMLElement} element - The element from the function reads the scroll values
  34195. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34196. * @return {Object} rect - The modifier rect object
  34197. */
  34198. function includeScroll(rect, element) {
  34199. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34200. var scrollTop = getScroll(element, 'top');
  34201. var scrollLeft = getScroll(element, 'left');
  34202. var modifier = subtract ? -1 : 1;
  34203. rect.top += scrollTop * modifier;
  34204. rect.bottom += scrollTop * modifier;
  34205. rect.left += scrollLeft * modifier;
  34206. rect.right += scrollLeft * modifier;
  34207. return rect;
  34208. }
  34209. /*
  34210. * Helper to detect borders of a given element
  34211. * @method
  34212. * @memberof Popper.Utils
  34213. * @param {CSSStyleDeclaration} styles
  34214. * Result of `getStyleComputedProperty` on the given element
  34215. * @param {String} axis - `x` or `y`
  34216. * @return {number} borders - The borders size of the given axis
  34217. */
  34218. function getBordersSize(styles, axis) {
  34219. var sideA = axis === 'x' ? 'Left' : 'Top';
  34220. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34221. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34222. }
  34223. function getSize(axis, body, html, computedStyle) {
  34224. 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);
  34225. }
  34226. function getWindowSizes(document) {
  34227. var body = document.body;
  34228. var html = document.documentElement;
  34229. var computedStyle = isIE(10) && getComputedStyle(html);
  34230. return {
  34231. height: getSize('Height', body, html, computedStyle),
  34232. width: getSize('Width', body, html, computedStyle)
  34233. };
  34234. }
  34235. var classCallCheck = function (instance, Constructor) {
  34236. if (!(instance instanceof Constructor)) {
  34237. throw new TypeError("Cannot call a class as a function");
  34238. }
  34239. };
  34240. var createClass = function () {
  34241. function defineProperties(target, props) {
  34242. for (var i = 0; i < props.length; i++) {
  34243. var descriptor = props[i];
  34244. descriptor.enumerable = descriptor.enumerable || false;
  34245. descriptor.configurable = true;
  34246. if ("value" in descriptor) descriptor.writable = true;
  34247. Object.defineProperty(target, descriptor.key, descriptor);
  34248. }
  34249. }
  34250. return function (Constructor, protoProps, staticProps) {
  34251. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34252. if (staticProps) defineProperties(Constructor, staticProps);
  34253. return Constructor;
  34254. };
  34255. }();
  34256. var defineProperty = function (obj, key, value) {
  34257. if (key in obj) {
  34258. Object.defineProperty(obj, key, {
  34259. value: value,
  34260. enumerable: true,
  34261. configurable: true,
  34262. writable: true
  34263. });
  34264. } else {
  34265. obj[key] = value;
  34266. }
  34267. return obj;
  34268. };
  34269. var _extends = Object.assign || function (target) {
  34270. for (var i = 1; i < arguments.length; i++) {
  34271. var source = arguments[i];
  34272. for (var key in source) {
  34273. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34274. target[key] = source[key];
  34275. }
  34276. }
  34277. }
  34278. return target;
  34279. };
  34280. /**
  34281. * Given element offsets, generate an output similar to getBoundingClientRect
  34282. * @method
  34283. * @memberof Popper.Utils
  34284. * @argument {Object} offsets
  34285. * @returns {Object} ClientRect like output
  34286. */
  34287. function getClientRect(offsets) {
  34288. return _extends({}, offsets, {
  34289. right: offsets.left + offsets.width,
  34290. bottom: offsets.top + offsets.height
  34291. });
  34292. }
  34293. /**
  34294. * Get bounding client rect of given element
  34295. * @method
  34296. * @memberof Popper.Utils
  34297. * @param {HTMLElement} element
  34298. * @return {Object} client rect
  34299. */
  34300. function getBoundingClientRect(element) {
  34301. var rect = {};
  34302. // IE10 10 FIX: Please, don't ask, the element isn't
  34303. // considered in DOM in some circumstances...
  34304. // This isn't reproducible in IE10 compatibility mode of IE11
  34305. try {
  34306. if (isIE(10)) {
  34307. rect = element.getBoundingClientRect();
  34308. var scrollTop = getScroll(element, 'top');
  34309. var scrollLeft = getScroll(element, 'left');
  34310. rect.top += scrollTop;
  34311. rect.left += scrollLeft;
  34312. rect.bottom += scrollTop;
  34313. rect.right += scrollLeft;
  34314. } else {
  34315. rect = element.getBoundingClientRect();
  34316. }
  34317. } catch (e) {}
  34318. var result = {
  34319. left: rect.left,
  34320. top: rect.top,
  34321. width: rect.right - rect.left,
  34322. height: rect.bottom - rect.top
  34323. };
  34324. // subtract scrollbar size from sizes
  34325. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34326. var width = sizes.width || element.clientWidth || result.width;
  34327. var height = sizes.height || element.clientHeight || result.height;
  34328. var horizScrollbar = element.offsetWidth - width;
  34329. var vertScrollbar = element.offsetHeight - height;
  34330. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34331. // we make this check conditional for performance reasons
  34332. if (horizScrollbar || vertScrollbar) {
  34333. var styles = getStyleComputedProperty(element);
  34334. horizScrollbar -= getBordersSize(styles, 'x');
  34335. vertScrollbar -= getBordersSize(styles, 'y');
  34336. result.width -= horizScrollbar;
  34337. result.height -= vertScrollbar;
  34338. }
  34339. return getClientRect(result);
  34340. }
  34341. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34342. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34343. var isIE10 = isIE(10);
  34344. var isHTML = parent.nodeName === 'HTML';
  34345. var childrenRect = getBoundingClientRect(children);
  34346. var parentRect = getBoundingClientRect(parent);
  34347. var scrollParent = getScrollParent(children);
  34348. var styles = getStyleComputedProperty(parent);
  34349. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34350. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34351. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34352. if (fixedPosition && isHTML) {
  34353. parentRect.top = Math.max(parentRect.top, 0);
  34354. parentRect.left = Math.max(parentRect.left, 0);
  34355. }
  34356. var offsets = getClientRect({
  34357. top: childrenRect.top - parentRect.top - borderTopWidth,
  34358. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34359. width: childrenRect.width,
  34360. height: childrenRect.height
  34361. });
  34362. offsets.marginTop = 0;
  34363. offsets.marginLeft = 0;
  34364. // Subtract margins of documentElement in case it's being used as parent
  34365. // we do this only on HTML because it's the only element that behaves
  34366. // differently when margins are applied to it. The margins are included in
  34367. // the box of the documentElement, in the other cases not.
  34368. if (!isIE10 && isHTML) {
  34369. var marginTop = parseFloat(styles.marginTop);
  34370. var marginLeft = parseFloat(styles.marginLeft);
  34371. offsets.top -= borderTopWidth - marginTop;
  34372. offsets.bottom -= borderTopWidth - marginTop;
  34373. offsets.left -= borderLeftWidth - marginLeft;
  34374. offsets.right -= borderLeftWidth - marginLeft;
  34375. // Attach marginTop and marginLeft because in some circumstances we may need them
  34376. offsets.marginTop = marginTop;
  34377. offsets.marginLeft = marginLeft;
  34378. }
  34379. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34380. offsets = includeScroll(offsets, parent);
  34381. }
  34382. return offsets;
  34383. }
  34384. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34385. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34386. var html = element.ownerDocument.documentElement;
  34387. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34388. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34389. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34390. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34391. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34392. var offset = {
  34393. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34394. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34395. width: width,
  34396. height: height
  34397. };
  34398. return getClientRect(offset);
  34399. }
  34400. /**
  34401. * Check if the given element is fixed or is inside a fixed parent
  34402. * @method
  34403. * @memberof Popper.Utils
  34404. * @argument {Element} element
  34405. * @argument {Element} customContainer
  34406. * @returns {Boolean} answer to "isFixed?"
  34407. */
  34408. function isFixed(element) {
  34409. var nodeName = element.nodeName;
  34410. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34411. return false;
  34412. }
  34413. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34414. return true;
  34415. }
  34416. var parentNode = getParentNode(element);
  34417. if (!parentNode) {
  34418. return false;
  34419. }
  34420. return isFixed(parentNode);
  34421. }
  34422. /**
  34423. * Finds the first parent of an element that has a transformed property defined
  34424. * @method
  34425. * @memberof Popper.Utils
  34426. * @argument {Element} element
  34427. * @returns {Element} first transformed parent or documentElement
  34428. */
  34429. function getFixedPositionOffsetParent(element) {
  34430. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34431. if (!element || !element.parentElement || isIE()) {
  34432. return document.documentElement;
  34433. }
  34434. var el = element.parentElement;
  34435. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34436. el = el.parentElement;
  34437. }
  34438. return el || document.documentElement;
  34439. }
  34440. /**
  34441. * Computed the boundaries limits and return them
  34442. * @method
  34443. * @memberof Popper.Utils
  34444. * @param {HTMLElement} popper
  34445. * @param {HTMLElement} reference
  34446. * @param {number} padding
  34447. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34448. * @param {Boolean} fixedPosition - Is in fixed position mode
  34449. * @returns {Object} Coordinates of the boundaries
  34450. */
  34451. function getBoundaries(popper, reference, padding, boundariesElement) {
  34452. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34453. // NOTE: 1 DOM access here
  34454. var boundaries = { top: 0, left: 0 };
  34455. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34456. // Handle viewport case
  34457. if (boundariesElement === 'viewport') {
  34458. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34459. } else {
  34460. // Handle other cases based on DOM element used as boundaries
  34461. var boundariesNode = void 0;
  34462. if (boundariesElement === 'scrollParent') {
  34463. boundariesNode = getScrollParent(getParentNode(reference));
  34464. if (boundariesNode.nodeName === 'BODY') {
  34465. boundariesNode = popper.ownerDocument.documentElement;
  34466. }
  34467. } else if (boundariesElement === 'window') {
  34468. boundariesNode = popper.ownerDocument.documentElement;
  34469. } else {
  34470. boundariesNode = boundariesElement;
  34471. }
  34472. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34473. // In case of HTML, we need a different computation
  34474. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34475. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34476. height = _getWindowSizes.height,
  34477. width = _getWindowSizes.width;
  34478. boundaries.top += offsets.top - offsets.marginTop;
  34479. boundaries.bottom = height + offsets.top;
  34480. boundaries.left += offsets.left - offsets.marginLeft;
  34481. boundaries.right = width + offsets.left;
  34482. } else {
  34483. // for all the other DOM elements, this one is good
  34484. boundaries = offsets;
  34485. }
  34486. }
  34487. // Add paddings
  34488. padding = padding || 0;
  34489. var isPaddingNumber = typeof padding === 'number';
  34490. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34491. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34492. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34493. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34494. return boundaries;
  34495. }
  34496. function getArea(_ref) {
  34497. var width = _ref.width,
  34498. height = _ref.height;
  34499. return width * height;
  34500. }
  34501. /**
  34502. * Utility used to transform the `auto` placement to the placement with more
  34503. * available space.
  34504. * @method
  34505. * @memberof Popper.Utils
  34506. * @argument {Object} data - The data object generated by update method
  34507. * @argument {Object} options - Modifiers configuration and options
  34508. * @returns {Object} The data object, properly modified
  34509. */
  34510. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34511. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34512. if (placement.indexOf('auto') === -1) {
  34513. return placement;
  34514. }
  34515. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34516. var rects = {
  34517. top: {
  34518. width: boundaries.width,
  34519. height: refRect.top - boundaries.top
  34520. },
  34521. right: {
  34522. width: boundaries.right - refRect.right,
  34523. height: boundaries.height
  34524. },
  34525. bottom: {
  34526. width: boundaries.width,
  34527. height: boundaries.bottom - refRect.bottom
  34528. },
  34529. left: {
  34530. width: refRect.left - boundaries.left,
  34531. height: boundaries.height
  34532. }
  34533. };
  34534. var sortedAreas = Object.keys(rects).map(function (key) {
  34535. return _extends({
  34536. key: key
  34537. }, rects[key], {
  34538. area: getArea(rects[key])
  34539. });
  34540. }).sort(function (a, b) {
  34541. return b.area - a.area;
  34542. });
  34543. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34544. var width = _ref2.width,
  34545. height = _ref2.height;
  34546. return width >= popper.clientWidth && height >= popper.clientHeight;
  34547. });
  34548. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34549. var variation = placement.split('-')[1];
  34550. return computedPlacement + (variation ? '-' + variation : '');
  34551. }
  34552. /**
  34553. * Get offsets to the reference element
  34554. * @method
  34555. * @memberof Popper.Utils
  34556. * @param {Object} state
  34557. * @param {Element} popper - the popper element
  34558. * @param {Element} reference - the reference element (the popper will be relative to this)
  34559. * @param {Element} fixedPosition - is in fixed position mode
  34560. * @returns {Object} An object containing the offsets which will be applied to the popper
  34561. */
  34562. function getReferenceOffsets(state, popper, reference) {
  34563. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34564. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34565. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34566. }
  34567. /**
  34568. * Get the outer sizes of the given element (offset size + margins)
  34569. * @method
  34570. * @memberof Popper.Utils
  34571. * @argument {Element} element
  34572. * @returns {Object} object containing width and height properties
  34573. */
  34574. function getOuterSizes(element) {
  34575. var window = element.ownerDocument.defaultView;
  34576. var styles = window.getComputedStyle(element);
  34577. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34578. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34579. var result = {
  34580. width: element.offsetWidth + y,
  34581. height: element.offsetHeight + x
  34582. };
  34583. return result;
  34584. }
  34585. /**
  34586. * Get the opposite placement of the given one
  34587. * @method
  34588. * @memberof Popper.Utils
  34589. * @argument {String} placement
  34590. * @returns {String} flipped placement
  34591. */
  34592. function getOppositePlacement(placement) {
  34593. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34594. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34595. return hash[matched];
  34596. });
  34597. }
  34598. /**
  34599. * Get offsets to the popper
  34600. * @method
  34601. * @memberof Popper.Utils
  34602. * @param {Object} position - CSS position the Popper will get applied
  34603. * @param {HTMLElement} popper - the popper element
  34604. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34605. * @param {String} placement - one of the valid placement options
  34606. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34607. */
  34608. function getPopperOffsets(popper, referenceOffsets, placement) {
  34609. placement = placement.split('-')[0];
  34610. // Get popper node sizes
  34611. var popperRect = getOuterSizes(popper);
  34612. // Add position, width and height to our offsets object
  34613. var popperOffsets = {
  34614. width: popperRect.width,
  34615. height: popperRect.height
  34616. };
  34617. // depending by the popper placement we have to compute its offsets slightly differently
  34618. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34619. var mainSide = isHoriz ? 'top' : 'left';
  34620. var secondarySide = isHoriz ? 'left' : 'top';
  34621. var measurement = isHoriz ? 'height' : 'width';
  34622. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34623. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34624. if (placement === secondarySide) {
  34625. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34626. } else {
  34627. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34628. }
  34629. return popperOffsets;
  34630. }
  34631. /**
  34632. * Mimics the `find` method of Array
  34633. * @method
  34634. * @memberof Popper.Utils
  34635. * @argument {Array} arr
  34636. * @argument prop
  34637. * @argument value
  34638. * @returns index or -1
  34639. */
  34640. function find(arr, check) {
  34641. // use native find if supported
  34642. if (Array.prototype.find) {
  34643. return arr.find(check);
  34644. }
  34645. // use `filter` to obtain the same behavior of `find`
  34646. return arr.filter(check)[0];
  34647. }
  34648. /**
  34649. * Return the index of the matching object
  34650. * @method
  34651. * @memberof Popper.Utils
  34652. * @argument {Array} arr
  34653. * @argument prop
  34654. * @argument value
  34655. * @returns index or -1
  34656. */
  34657. function findIndex(arr, prop, value) {
  34658. // use native findIndex if supported
  34659. if (Array.prototype.findIndex) {
  34660. return arr.findIndex(function (cur) {
  34661. return cur[prop] === value;
  34662. });
  34663. }
  34664. // use `find` + `indexOf` if `findIndex` isn't supported
  34665. var match = find(arr, function (obj) {
  34666. return obj[prop] === value;
  34667. });
  34668. return arr.indexOf(match);
  34669. }
  34670. /**
  34671. * Loop trough the list of modifiers and run them in order,
  34672. * each of them will then edit the data object.
  34673. * @method
  34674. * @memberof Popper.Utils
  34675. * @param {dataObject} data
  34676. * @param {Array} modifiers
  34677. * @param {String} ends - Optional modifier name used as stopper
  34678. * @returns {dataObject}
  34679. */
  34680. function runModifiers(modifiers, data, ends) {
  34681. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34682. modifiersToRun.forEach(function (modifier) {
  34683. if (modifier['function']) {
  34684. // eslint-disable-line dot-notation
  34685. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34686. }
  34687. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34688. if (modifier.enabled && isFunction(fn)) {
  34689. // Add properties to offsets to make them a complete clientRect object
  34690. // we do this before each modifier to make sure the previous one doesn't
  34691. // mess with these values
  34692. data.offsets.popper = getClientRect(data.offsets.popper);
  34693. data.offsets.reference = getClientRect(data.offsets.reference);
  34694. data = fn(data, modifier);
  34695. }
  34696. });
  34697. return data;
  34698. }
  34699. /**
  34700. * Updates the position of the popper, computing the new offsets and applying
  34701. * the new style.<br />
  34702. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34703. * @method
  34704. * @memberof Popper
  34705. */
  34706. function update() {
  34707. // if popper is destroyed, don't perform any further update
  34708. if (this.state.isDestroyed) {
  34709. return;
  34710. }
  34711. var data = {
  34712. instance: this,
  34713. styles: {},
  34714. arrowStyles: {},
  34715. attributes: {},
  34716. flipped: false,
  34717. offsets: {}
  34718. };
  34719. // compute reference element offsets
  34720. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34721. // compute auto placement, store placement inside the data object,
  34722. // modifiers will be able to edit `placement` if needed
  34723. // and refer to originalPlacement to know the original value
  34724. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34725. // store the computed placement inside `originalPlacement`
  34726. data.originalPlacement = data.placement;
  34727. data.positionFixed = this.options.positionFixed;
  34728. // compute the popper offsets
  34729. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34730. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34731. // run the modifiers
  34732. data = runModifiers(this.modifiers, data);
  34733. // the first `update` will call `onCreate` callback
  34734. // the other ones will call `onUpdate` callback
  34735. if (!this.state.isCreated) {
  34736. this.state.isCreated = true;
  34737. this.options.onCreate(data);
  34738. } else {
  34739. this.options.onUpdate(data);
  34740. }
  34741. }
  34742. /**
  34743. * Helper used to know if the given modifier is enabled.
  34744. * @method
  34745. * @memberof Popper.Utils
  34746. * @returns {Boolean}
  34747. */
  34748. function isModifierEnabled(modifiers, modifierName) {
  34749. return modifiers.some(function (_ref) {
  34750. var name = _ref.name,
  34751. enabled = _ref.enabled;
  34752. return enabled && name === modifierName;
  34753. });
  34754. }
  34755. /**
  34756. * Get the prefixed supported property name
  34757. * @method
  34758. * @memberof Popper.Utils
  34759. * @argument {String} property (camelCase)
  34760. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34761. */
  34762. function getSupportedPropertyName(property) {
  34763. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34764. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34765. for (var i = 0; i < prefixes.length; i++) {
  34766. var prefix = prefixes[i];
  34767. var toCheck = prefix ? '' + prefix + upperProp : property;
  34768. if (typeof document.body.style[toCheck] !== 'undefined') {
  34769. return toCheck;
  34770. }
  34771. }
  34772. return null;
  34773. }
  34774. /**
  34775. * Destroys the popper.
  34776. * @method
  34777. * @memberof Popper
  34778. */
  34779. function destroy() {
  34780. this.state.isDestroyed = true;
  34781. // touch DOM only if `applyStyle` modifier is enabled
  34782. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34783. this.popper.removeAttribute('x-placement');
  34784. this.popper.style.position = '';
  34785. this.popper.style.top = '';
  34786. this.popper.style.left = '';
  34787. this.popper.style.right = '';
  34788. this.popper.style.bottom = '';
  34789. this.popper.style.willChange = '';
  34790. this.popper.style[getSupportedPropertyName('transform')] = '';
  34791. }
  34792. this.disableEventListeners();
  34793. // remove the popper if user explicitly asked for the deletion on destroy
  34794. // do not use `remove` because IE11 doesn't support it
  34795. if (this.options.removeOnDestroy) {
  34796. this.popper.parentNode.removeChild(this.popper);
  34797. }
  34798. return this;
  34799. }
  34800. /**
  34801. * Get the window associated with the element
  34802. * @argument {Element} element
  34803. * @returns {Window}
  34804. */
  34805. function getWindow(element) {
  34806. var ownerDocument = element.ownerDocument;
  34807. return ownerDocument ? ownerDocument.defaultView : window;
  34808. }
  34809. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34810. var isBody = scrollParent.nodeName === 'BODY';
  34811. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34812. target.addEventListener(event, callback, { passive: true });
  34813. if (!isBody) {
  34814. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34815. }
  34816. scrollParents.push(target);
  34817. }
  34818. /**
  34819. * Setup needed event listeners used to update the popper position
  34820. * @method
  34821. * @memberof Popper.Utils
  34822. * @private
  34823. */
  34824. function setupEventListeners(reference, options, state, updateBound) {
  34825. // Resize event listener on window
  34826. state.updateBound = updateBound;
  34827. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34828. // Scroll event listener on scroll parents
  34829. var scrollElement = getScrollParent(reference);
  34830. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34831. state.scrollElement = scrollElement;
  34832. state.eventsEnabled = true;
  34833. return state;
  34834. }
  34835. /**
  34836. * It will add resize/scroll events and start recalculating
  34837. * position of the popper element when they are triggered.
  34838. * @method
  34839. * @memberof Popper
  34840. */
  34841. function enableEventListeners() {
  34842. if (!this.state.eventsEnabled) {
  34843. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34844. }
  34845. }
  34846. /**
  34847. * Remove event listeners used to update the popper position
  34848. * @method
  34849. * @memberof Popper.Utils
  34850. * @private
  34851. */
  34852. function removeEventListeners(reference, state) {
  34853. // Remove resize event listener on window
  34854. getWindow(reference).removeEventListener('resize', state.updateBound);
  34855. // Remove scroll event listener on scroll parents
  34856. state.scrollParents.forEach(function (target) {
  34857. target.removeEventListener('scroll', state.updateBound);
  34858. });
  34859. // Reset state
  34860. state.updateBound = null;
  34861. state.scrollParents = [];
  34862. state.scrollElement = null;
  34863. state.eventsEnabled = false;
  34864. return state;
  34865. }
  34866. /**
  34867. * It will remove resize/scroll events and won't recalculate popper position
  34868. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34869. * unless you call `update` method manually.
  34870. * @method
  34871. * @memberof Popper
  34872. */
  34873. function disableEventListeners() {
  34874. if (this.state.eventsEnabled) {
  34875. cancelAnimationFrame(this.scheduleUpdate);
  34876. this.state = removeEventListeners(this.reference, this.state);
  34877. }
  34878. }
  34879. /**
  34880. * Tells if a given input is a number
  34881. * @method
  34882. * @memberof Popper.Utils
  34883. * @param {*} input to check
  34884. * @return {Boolean}
  34885. */
  34886. function isNumeric(n) {
  34887. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34888. }
  34889. /**
  34890. * Set the style to the given popper
  34891. * @method
  34892. * @memberof Popper.Utils
  34893. * @argument {Element} element - Element to apply the style to
  34894. * @argument {Object} styles
  34895. * Object with a list of properties and values which will be applied to the element
  34896. */
  34897. function setStyles(element, styles) {
  34898. Object.keys(styles).forEach(function (prop) {
  34899. var unit = '';
  34900. // add unit if the value is numeric and is one of the following
  34901. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34902. unit = 'px';
  34903. }
  34904. element.style[prop] = styles[prop] + unit;
  34905. });
  34906. }
  34907. /**
  34908. * Set the attributes to the given popper
  34909. * @method
  34910. * @memberof Popper.Utils
  34911. * @argument {Element} element - Element to apply the attributes to
  34912. * @argument {Object} styles
  34913. * Object with a list of properties and values which will be applied to the element
  34914. */
  34915. function setAttributes(element, attributes) {
  34916. Object.keys(attributes).forEach(function (prop) {
  34917. var value = attributes[prop];
  34918. if (value !== false) {
  34919. element.setAttribute(prop, attributes[prop]);
  34920. } else {
  34921. element.removeAttribute(prop);
  34922. }
  34923. });
  34924. }
  34925. /**
  34926. * @function
  34927. * @memberof Modifiers
  34928. * @argument {Object} data - The data object generated by `update` method
  34929. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34930. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34931. * @argument {Object} options - Modifiers configuration and options
  34932. * @returns {Object} The same data object
  34933. */
  34934. function applyStyle(data) {
  34935. // any property present in `data.styles` will be applied to the popper,
  34936. // in this way we can make the 3rd party modifiers add custom styles to it
  34937. // Be aware, modifiers could override the properties defined in the previous
  34938. // lines of this modifier!
  34939. setStyles(data.instance.popper, data.styles);
  34940. // any property present in `data.attributes` will be applied to the popper,
  34941. // they will be set as HTML attributes of the element
  34942. setAttributes(data.instance.popper, data.attributes);
  34943. // if arrowElement is defined and arrowStyles has some properties
  34944. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34945. setStyles(data.arrowElement, data.arrowStyles);
  34946. }
  34947. return data;
  34948. }
  34949. /**
  34950. * Set the x-placement attribute before everything else because it could be used
  34951. * to add margins to the popper margins needs to be calculated to get the
  34952. * correct popper offsets.
  34953. * @method
  34954. * @memberof Popper.modifiers
  34955. * @param {HTMLElement} reference - The reference element used to position the popper
  34956. * @param {HTMLElement} popper - The HTML element used as popper
  34957. * @param {Object} options - Popper.js options
  34958. */
  34959. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34960. // compute reference element offsets
  34961. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34962. // compute auto placement, store placement inside the data object,
  34963. // modifiers will be able to edit `placement` if needed
  34964. // and refer to originalPlacement to know the original value
  34965. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34966. popper.setAttribute('x-placement', placement);
  34967. // Apply `position` to popper before anything else because
  34968. // without the position applied we can't guarantee correct computations
  34969. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34970. return options;
  34971. }
  34972. /**
  34973. * @function
  34974. * @memberof Popper.Utils
  34975. * @argument {Object} data - The data object generated by `update` method
  34976. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34977. * @returns {Object} The popper's position offsets rounded
  34978. *
  34979. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34980. * good as it can be within reason.
  34981. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34982. *
  34983. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34984. * as well on High DPI screens).
  34985. *
  34986. * Firefox prefers no rounding for positioning and does not have blurriness on
  34987. * high DPI screens.
  34988. *
  34989. * Only horizontal placement and left/right values need to be considered.
  34990. */
  34991. function getRoundedOffsets(data, shouldRound) {
  34992. var _data$offsets = data.offsets,
  34993. popper = _data$offsets.popper,
  34994. reference = _data$offsets.reference;
  34995. var round = Math.round,
  34996. floor = Math.floor;
  34997. var noRound = function noRound(v) {
  34998. return v;
  34999. };
  35000. var referenceWidth = round(reference.width);
  35001. var popperWidth = round(popper.width);
  35002. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  35003. var isVariation = data.placement.indexOf('-') !== -1;
  35004. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  35005. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  35006. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  35007. var verticalToInteger = !shouldRound ? noRound : round;
  35008. return {
  35009. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  35010. top: verticalToInteger(popper.top),
  35011. bottom: verticalToInteger(popper.bottom),
  35012. right: horizontalToInteger(popper.right)
  35013. };
  35014. }
  35015. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  35016. /**
  35017. * @function
  35018. * @memberof Modifiers
  35019. * @argument {Object} data - The data object generated by `update` method
  35020. * @argument {Object} options - Modifiers configuration and options
  35021. * @returns {Object} The data object, properly modified
  35022. */
  35023. function computeStyle(data, options) {
  35024. var x = options.x,
  35025. y = options.y;
  35026. var popper = data.offsets.popper;
  35027. // Remove this legacy support in Popper.js v2
  35028. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  35029. return modifier.name === 'applyStyle';
  35030. }).gpuAcceleration;
  35031. if (legacyGpuAccelerationOption !== undefined) {
  35032. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  35033. }
  35034. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  35035. var offsetParent = getOffsetParent(data.instance.popper);
  35036. var offsetParentRect = getBoundingClientRect(offsetParent);
  35037. // Styles
  35038. var styles = {
  35039. position: popper.position
  35040. };
  35041. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  35042. var sideA = x === 'bottom' ? 'top' : 'bottom';
  35043. var sideB = y === 'right' ? 'left' : 'right';
  35044. // if gpuAcceleration is set to `true` and transform is supported,
  35045. // we use `translate3d` to apply the position to the popper we
  35046. // automatically use the supported prefixed version if needed
  35047. var prefixedProperty = getSupportedPropertyName('transform');
  35048. // now, let's make a step back and look at this code closely (wtf?)
  35049. // If the content of the popper grows once it's been positioned, it
  35050. // may happen that the popper gets misplaced because of the new content
  35051. // overflowing its reference element
  35052. // To avoid this problem, we provide two options (x and y), which allow
  35053. // the consumer to define the offset origin.
  35054. // If we position a popper on top of a reference element, we can set
  35055. // `x` to `top` to make the popper grow towards its top instead of
  35056. // its bottom.
  35057. var left = void 0,
  35058. top = void 0;
  35059. if (sideA === 'bottom') {
  35060. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  35061. // and not the bottom of the html element
  35062. if (offsetParent.nodeName === 'HTML') {
  35063. top = -offsetParent.clientHeight + offsets.bottom;
  35064. } else {
  35065. top = -offsetParentRect.height + offsets.bottom;
  35066. }
  35067. } else {
  35068. top = offsets.top;
  35069. }
  35070. if (sideB === 'right') {
  35071. if (offsetParent.nodeName === 'HTML') {
  35072. left = -offsetParent.clientWidth + offsets.right;
  35073. } else {
  35074. left = -offsetParentRect.width + offsets.right;
  35075. }
  35076. } else {
  35077. left = offsets.left;
  35078. }
  35079. if (gpuAcceleration && prefixedProperty) {
  35080. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  35081. styles[sideA] = 0;
  35082. styles[sideB] = 0;
  35083. styles.willChange = 'transform';
  35084. } else {
  35085. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  35086. var invertTop = sideA === 'bottom' ? -1 : 1;
  35087. var invertLeft = sideB === 'right' ? -1 : 1;
  35088. styles[sideA] = top * invertTop;
  35089. styles[sideB] = left * invertLeft;
  35090. styles.willChange = sideA + ', ' + sideB;
  35091. }
  35092. // Attributes
  35093. var attributes = {
  35094. 'x-placement': data.placement
  35095. };
  35096. // Update `data` attributes, styles and arrowStyles
  35097. data.attributes = _extends({}, attributes, data.attributes);
  35098. data.styles = _extends({}, styles, data.styles);
  35099. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  35100. return data;
  35101. }
  35102. /**
  35103. * Helper used to know if the given modifier depends from another one.<br />
  35104. * It checks if the needed modifier is listed and enabled.
  35105. * @method
  35106. * @memberof Popper.Utils
  35107. * @param {Array} modifiers - list of modifiers
  35108. * @param {String} requestingName - name of requesting modifier
  35109. * @param {String} requestedName - name of requested modifier
  35110. * @returns {Boolean}
  35111. */
  35112. function isModifierRequired(modifiers, requestingName, requestedName) {
  35113. var requesting = find(modifiers, function (_ref) {
  35114. var name = _ref.name;
  35115. return name === requestingName;
  35116. });
  35117. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35118. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35119. });
  35120. if (!isRequired) {
  35121. var _requesting = '`' + requestingName + '`';
  35122. var requested = '`' + requestedName + '`';
  35123. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35124. }
  35125. return isRequired;
  35126. }
  35127. /**
  35128. * @function
  35129. * @memberof Modifiers
  35130. * @argument {Object} data - The data object generated by update method
  35131. * @argument {Object} options - Modifiers configuration and options
  35132. * @returns {Object} The data object, properly modified
  35133. */
  35134. function arrow(data, options) {
  35135. var _data$offsets$arrow;
  35136. // arrow depends on keepTogether in order to work
  35137. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35138. return data;
  35139. }
  35140. var arrowElement = options.element;
  35141. // if arrowElement is a string, suppose it's a CSS selector
  35142. if (typeof arrowElement === 'string') {
  35143. arrowElement = data.instance.popper.querySelector(arrowElement);
  35144. // if arrowElement is not found, don't run the modifier
  35145. if (!arrowElement) {
  35146. return data;
  35147. }
  35148. } else {
  35149. // if the arrowElement isn't a query selector we must check that the
  35150. // provided DOM node is child of its popper node
  35151. if (!data.instance.popper.contains(arrowElement)) {
  35152. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35153. return data;
  35154. }
  35155. }
  35156. var placement = data.placement.split('-')[0];
  35157. var _data$offsets = data.offsets,
  35158. popper = _data$offsets.popper,
  35159. reference = _data$offsets.reference;
  35160. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35161. var len = isVertical ? 'height' : 'width';
  35162. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35163. var side = sideCapitalized.toLowerCase();
  35164. var altSide = isVertical ? 'left' : 'top';
  35165. var opSide = isVertical ? 'bottom' : 'right';
  35166. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35167. //
  35168. // extends keepTogether behavior making sure the popper and its
  35169. // reference have enough pixels in conjunction
  35170. //
  35171. // top/left side
  35172. if (reference[opSide] - arrowElementSize < popper[side]) {
  35173. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35174. }
  35175. // bottom/right side
  35176. if (reference[side] + arrowElementSize > popper[opSide]) {
  35177. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35178. }
  35179. data.offsets.popper = getClientRect(data.offsets.popper);
  35180. // compute center of the popper
  35181. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35182. // Compute the sideValue using the updated popper offsets
  35183. // take popper margin in account because we don't have this info available
  35184. var css = getStyleComputedProperty(data.instance.popper);
  35185. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35186. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35187. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35188. // prevent arrowElement from being placed not contiguously to its popper
  35189. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35190. data.arrowElement = arrowElement;
  35191. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35192. return data;
  35193. }
  35194. /**
  35195. * Get the opposite placement variation of the given one
  35196. * @method
  35197. * @memberof Popper.Utils
  35198. * @argument {String} placement variation
  35199. * @returns {String} flipped placement variation
  35200. */
  35201. function getOppositeVariation(variation) {
  35202. if (variation === 'end') {
  35203. return 'start';
  35204. } else if (variation === 'start') {
  35205. return 'end';
  35206. }
  35207. return variation;
  35208. }
  35209. /**
  35210. * List of accepted placements to use as values of the `placement` option.<br />
  35211. * Valid placements are:
  35212. * - `auto`
  35213. * - `top`
  35214. * - `right`
  35215. * - `bottom`
  35216. * - `left`
  35217. *
  35218. * Each placement can have a variation from this list:
  35219. * - `-start`
  35220. * - `-end`
  35221. *
  35222. * Variations are interpreted easily if you think of them as the left to right
  35223. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35224. * is right.<br />
  35225. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35226. *
  35227. * Some valid examples are:
  35228. * - `top-end` (on top of reference, right aligned)
  35229. * - `right-start` (on right of reference, top aligned)
  35230. * - `bottom` (on bottom, centered)
  35231. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35232. *
  35233. * @static
  35234. * @type {Array}
  35235. * @enum {String}
  35236. * @readonly
  35237. * @method placements
  35238. * @memberof Popper
  35239. */
  35240. 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'];
  35241. // Get rid of `auto` `auto-start` and `auto-end`
  35242. var validPlacements = placements.slice(3);
  35243. /**
  35244. * Given an initial placement, returns all the subsequent placements
  35245. * clockwise (or counter-clockwise).
  35246. *
  35247. * @method
  35248. * @memberof Popper.Utils
  35249. * @argument {String} placement - A valid placement (it accepts variations)
  35250. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35251. * @returns {Array} placements including their variations
  35252. */
  35253. function clockwise(placement) {
  35254. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35255. var index = validPlacements.indexOf(placement);
  35256. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35257. return counter ? arr.reverse() : arr;
  35258. }
  35259. var BEHAVIORS = {
  35260. FLIP: 'flip',
  35261. CLOCKWISE: 'clockwise',
  35262. COUNTERCLOCKWISE: 'counterclockwise'
  35263. };
  35264. /**
  35265. * @function
  35266. * @memberof Modifiers
  35267. * @argument {Object} data - The data object generated by update method
  35268. * @argument {Object} options - Modifiers configuration and options
  35269. * @returns {Object} The data object, properly modified
  35270. */
  35271. function flip(data, options) {
  35272. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35273. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35274. return data;
  35275. }
  35276. if (data.flipped && data.placement === data.originalPlacement) {
  35277. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35278. return data;
  35279. }
  35280. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35281. var placement = data.placement.split('-')[0];
  35282. var placementOpposite = getOppositePlacement(placement);
  35283. var variation = data.placement.split('-')[1] || '';
  35284. var flipOrder = [];
  35285. switch (options.behavior) {
  35286. case BEHAVIORS.FLIP:
  35287. flipOrder = [placement, placementOpposite];
  35288. break;
  35289. case BEHAVIORS.CLOCKWISE:
  35290. flipOrder = clockwise(placement);
  35291. break;
  35292. case BEHAVIORS.COUNTERCLOCKWISE:
  35293. flipOrder = clockwise(placement, true);
  35294. break;
  35295. default:
  35296. flipOrder = options.behavior;
  35297. }
  35298. flipOrder.forEach(function (step, index) {
  35299. if (placement !== step || flipOrder.length === index + 1) {
  35300. return data;
  35301. }
  35302. placement = data.placement.split('-')[0];
  35303. placementOpposite = getOppositePlacement(placement);
  35304. var popperOffsets = data.offsets.popper;
  35305. var refOffsets = data.offsets.reference;
  35306. // using floor because the reference offsets may contain decimals we are not going to consider here
  35307. var floor = Math.floor;
  35308. 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);
  35309. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35310. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35311. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35312. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35313. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35314. // flip the variation if required
  35315. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35316. // flips variation if reference element overflows boundaries
  35317. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35318. // flips variation if popper content overflows boundaries
  35319. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35320. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35321. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35322. // this boolean to detect any flip loop
  35323. data.flipped = true;
  35324. if (overlapsRef || overflowsBoundaries) {
  35325. placement = flipOrder[index + 1];
  35326. }
  35327. if (flippedVariation) {
  35328. variation = getOppositeVariation(variation);
  35329. }
  35330. data.placement = placement + (variation ? '-' + variation : '');
  35331. // this object contains `position`, we want to preserve it along with
  35332. // any additional property we may add in the future
  35333. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35334. data = runModifiers(data.instance.modifiers, data, 'flip');
  35335. }
  35336. });
  35337. return data;
  35338. }
  35339. /**
  35340. * @function
  35341. * @memberof Modifiers
  35342. * @argument {Object} data - The data object generated by update method
  35343. * @argument {Object} options - Modifiers configuration and options
  35344. * @returns {Object} The data object, properly modified
  35345. */
  35346. function keepTogether(data) {
  35347. var _data$offsets = data.offsets,
  35348. popper = _data$offsets.popper,
  35349. reference = _data$offsets.reference;
  35350. var placement = data.placement.split('-')[0];
  35351. var floor = Math.floor;
  35352. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35353. var side = isVertical ? 'right' : 'bottom';
  35354. var opSide = isVertical ? 'left' : 'top';
  35355. var measurement = isVertical ? 'width' : 'height';
  35356. if (popper[side] < floor(reference[opSide])) {
  35357. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35358. }
  35359. if (popper[opSide] > floor(reference[side])) {
  35360. data.offsets.popper[opSide] = floor(reference[side]);
  35361. }
  35362. return data;
  35363. }
  35364. /**
  35365. * Converts a string containing value + unit into a px value number
  35366. * @function
  35367. * @memberof {modifiers~offset}
  35368. * @private
  35369. * @argument {String} str - Value + unit string
  35370. * @argument {String} measurement - `height` or `width`
  35371. * @argument {Object} popperOffsets
  35372. * @argument {Object} referenceOffsets
  35373. * @returns {Number|String}
  35374. * Value in pixels, or original string if no values were extracted
  35375. */
  35376. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35377. // separate value from unit
  35378. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35379. var value = +split[1];
  35380. var unit = split[2];
  35381. // If it's not a number it's an operator, I guess
  35382. if (!value) {
  35383. return str;
  35384. }
  35385. if (unit.indexOf('%') === 0) {
  35386. var element = void 0;
  35387. switch (unit) {
  35388. case '%p':
  35389. element = popperOffsets;
  35390. break;
  35391. case '%':
  35392. case '%r':
  35393. default:
  35394. element = referenceOffsets;
  35395. }
  35396. var rect = getClientRect(element);
  35397. return rect[measurement] / 100 * value;
  35398. } else if (unit === 'vh' || unit === 'vw') {
  35399. // if is a vh or vw, we calculate the size based on the viewport
  35400. var size = void 0;
  35401. if (unit === 'vh') {
  35402. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35403. } else {
  35404. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35405. }
  35406. return size / 100 * value;
  35407. } else {
  35408. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35409. // if is an implicit unit, it's px, and we return just the value
  35410. return value;
  35411. }
  35412. }
  35413. /**
  35414. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35415. * @function
  35416. * @memberof {modifiers~offset}
  35417. * @private
  35418. * @argument {String} offset
  35419. * @argument {Object} popperOffsets
  35420. * @argument {Object} referenceOffsets
  35421. * @argument {String} basePlacement
  35422. * @returns {Array} a two cells array with x and y offsets in numbers
  35423. */
  35424. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35425. var offsets = [0, 0];
  35426. // Use height if placement is left or right and index is 0 otherwise use width
  35427. // in this way the first offset will use an axis and the second one
  35428. // will use the other one
  35429. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35430. // Split the offset string to obtain a list of values and operands
  35431. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35432. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35433. return frag.trim();
  35434. });
  35435. // Detect if the offset string contains a pair of values or a single one
  35436. // they could be separated by comma or space
  35437. var divider = fragments.indexOf(find(fragments, function (frag) {
  35438. return frag.search(/,|\s/) !== -1;
  35439. }));
  35440. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35441. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35442. }
  35443. // If divider is found, we divide the list of values and operands to divide
  35444. // them by ofset X and Y.
  35445. var splitRegex = /\s*,\s*|\s+/;
  35446. 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];
  35447. // Convert the values with units to absolute pixels to allow our computations
  35448. ops = ops.map(function (op, index) {
  35449. // Most of the units rely on the orientation of the popper
  35450. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35451. var mergeWithPrevious = false;
  35452. return op
  35453. // This aggregates any `+` or `-` sign that aren't considered operators
  35454. // e.g.: 10 + +5 => [10, +, +5]
  35455. .reduce(function (a, b) {
  35456. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35457. a[a.length - 1] = b;
  35458. mergeWithPrevious = true;
  35459. return a;
  35460. } else if (mergeWithPrevious) {
  35461. a[a.length - 1] += b;
  35462. mergeWithPrevious = false;
  35463. return a;
  35464. } else {
  35465. return a.concat(b);
  35466. }
  35467. }, [])
  35468. // Here we convert the string values into number values (in px)
  35469. .map(function (str) {
  35470. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35471. });
  35472. });
  35473. // Loop trough the offsets arrays and execute the operations
  35474. ops.forEach(function (op, index) {
  35475. op.forEach(function (frag, index2) {
  35476. if (isNumeric(frag)) {
  35477. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35478. }
  35479. });
  35480. });
  35481. return offsets;
  35482. }
  35483. /**
  35484. * @function
  35485. * @memberof Modifiers
  35486. * @argument {Object} data - The data object generated by update method
  35487. * @argument {Object} options - Modifiers configuration and options
  35488. * @argument {Number|String} options.offset=0
  35489. * The offset value as described in the modifier description
  35490. * @returns {Object} The data object, properly modified
  35491. */
  35492. function offset(data, _ref) {
  35493. var offset = _ref.offset;
  35494. var placement = data.placement,
  35495. _data$offsets = data.offsets,
  35496. popper = _data$offsets.popper,
  35497. reference = _data$offsets.reference;
  35498. var basePlacement = placement.split('-')[0];
  35499. var offsets = void 0;
  35500. if (isNumeric(+offset)) {
  35501. offsets = [+offset, 0];
  35502. } else {
  35503. offsets = parseOffset(offset, popper, reference, basePlacement);
  35504. }
  35505. if (basePlacement === 'left') {
  35506. popper.top += offsets[0];
  35507. popper.left -= offsets[1];
  35508. } else if (basePlacement === 'right') {
  35509. popper.top += offsets[0];
  35510. popper.left += offsets[1];
  35511. } else if (basePlacement === 'top') {
  35512. popper.left += offsets[0];
  35513. popper.top -= offsets[1];
  35514. } else if (basePlacement === 'bottom') {
  35515. popper.left += offsets[0];
  35516. popper.top += offsets[1];
  35517. }
  35518. data.popper = popper;
  35519. return data;
  35520. }
  35521. /**
  35522. * @function
  35523. * @memberof Modifiers
  35524. * @argument {Object} data - The data object generated by `update` method
  35525. * @argument {Object} options - Modifiers configuration and options
  35526. * @returns {Object} The data object, properly modified
  35527. */
  35528. function preventOverflow(data, options) {
  35529. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35530. // If offsetParent is the reference element, we really want to
  35531. // go one step up and use the next offsetParent as reference to
  35532. // avoid to make this modifier completely useless and look like broken
  35533. if (data.instance.reference === boundariesElement) {
  35534. boundariesElement = getOffsetParent(boundariesElement);
  35535. }
  35536. // NOTE: DOM access here
  35537. // resets the popper's position so that the document size can be calculated excluding
  35538. // the size of the popper element itself
  35539. var transformProp = getSupportedPropertyName('transform');
  35540. var popperStyles = data.instance.popper.style; // assignment to help minification
  35541. var top = popperStyles.top,
  35542. left = popperStyles.left,
  35543. transform = popperStyles[transformProp];
  35544. popperStyles.top = '';
  35545. popperStyles.left = '';
  35546. popperStyles[transformProp] = '';
  35547. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35548. // NOTE: DOM access here
  35549. // restores the original style properties after the offsets have been computed
  35550. popperStyles.top = top;
  35551. popperStyles.left = left;
  35552. popperStyles[transformProp] = transform;
  35553. options.boundaries = boundaries;
  35554. var order = options.priority;
  35555. var popper = data.offsets.popper;
  35556. var check = {
  35557. primary: function primary(placement) {
  35558. var value = popper[placement];
  35559. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35560. value = Math.max(popper[placement], boundaries[placement]);
  35561. }
  35562. return defineProperty({}, placement, value);
  35563. },
  35564. secondary: function secondary(placement) {
  35565. var mainSide = placement === 'right' ? 'left' : 'top';
  35566. var value = popper[mainSide];
  35567. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35568. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35569. }
  35570. return defineProperty({}, mainSide, value);
  35571. }
  35572. };
  35573. order.forEach(function (placement) {
  35574. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35575. popper = _extends({}, popper, check[side](placement));
  35576. });
  35577. data.offsets.popper = popper;
  35578. return data;
  35579. }
  35580. /**
  35581. * @function
  35582. * @memberof Modifiers
  35583. * @argument {Object} data - The data object generated by `update` method
  35584. * @argument {Object} options - Modifiers configuration and options
  35585. * @returns {Object} The data object, properly modified
  35586. */
  35587. function shift(data) {
  35588. var placement = data.placement;
  35589. var basePlacement = placement.split('-')[0];
  35590. var shiftvariation = placement.split('-')[1];
  35591. // if shift shiftvariation is specified, run the modifier
  35592. if (shiftvariation) {
  35593. var _data$offsets = data.offsets,
  35594. reference = _data$offsets.reference,
  35595. popper = _data$offsets.popper;
  35596. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35597. var side = isVertical ? 'left' : 'top';
  35598. var measurement = isVertical ? 'width' : 'height';
  35599. var shiftOffsets = {
  35600. start: defineProperty({}, side, reference[side]),
  35601. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35602. };
  35603. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35604. }
  35605. return data;
  35606. }
  35607. /**
  35608. * @function
  35609. * @memberof Modifiers
  35610. * @argument {Object} data - The data object generated by update method
  35611. * @argument {Object} options - Modifiers configuration and options
  35612. * @returns {Object} The data object, properly modified
  35613. */
  35614. function hide(data) {
  35615. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35616. return data;
  35617. }
  35618. var refRect = data.offsets.reference;
  35619. var bound = find(data.instance.modifiers, function (modifier) {
  35620. return modifier.name === 'preventOverflow';
  35621. }).boundaries;
  35622. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35623. // Avoid unnecessary DOM access if visibility hasn't changed
  35624. if (data.hide === true) {
  35625. return data;
  35626. }
  35627. data.hide = true;
  35628. data.attributes['x-out-of-boundaries'] = '';
  35629. } else {
  35630. // Avoid unnecessary DOM access if visibility hasn't changed
  35631. if (data.hide === false) {
  35632. return data;
  35633. }
  35634. data.hide = false;
  35635. data.attributes['x-out-of-boundaries'] = false;
  35636. }
  35637. return data;
  35638. }
  35639. /**
  35640. * @function
  35641. * @memberof Modifiers
  35642. * @argument {Object} data - The data object generated by `update` method
  35643. * @argument {Object} options - Modifiers configuration and options
  35644. * @returns {Object} The data object, properly modified
  35645. */
  35646. function inner(data) {
  35647. var placement = data.placement;
  35648. var basePlacement = placement.split('-')[0];
  35649. var _data$offsets = data.offsets,
  35650. popper = _data$offsets.popper,
  35651. reference = _data$offsets.reference;
  35652. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35653. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35654. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35655. data.placement = getOppositePlacement(placement);
  35656. data.offsets.popper = getClientRect(popper);
  35657. return data;
  35658. }
  35659. /**
  35660. * Modifier function, each modifier can have a function of this type assigned
  35661. * to its `fn` property.<br />
  35662. * These functions will be called on each update, this means that you must
  35663. * make sure they are performant enough to avoid performance bottlenecks.
  35664. *
  35665. * @function ModifierFn
  35666. * @argument {dataObject} data - The data object generated by `update` method
  35667. * @argument {Object} options - Modifiers configuration and options
  35668. * @returns {dataObject} The data object, properly modified
  35669. */
  35670. /**
  35671. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35672. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35673. * needed by the library.
  35674. *
  35675. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35676. * All the other properties are configurations that could be tweaked.
  35677. * @namespace modifiers
  35678. */
  35679. var modifiers = {
  35680. /**
  35681. * Modifier used to shift the popper on the start or end of its reference
  35682. * element.<br />
  35683. * It will read the variation of the `placement` property.<br />
  35684. * It can be one either `-end` or `-start`.
  35685. * @memberof modifiers
  35686. * @inner
  35687. */
  35688. shift: {
  35689. /** @prop {number} order=100 - Index used to define the order of execution */
  35690. order: 100,
  35691. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35692. enabled: true,
  35693. /** @prop {ModifierFn} */
  35694. fn: shift
  35695. },
  35696. /**
  35697. * The `offset` modifier can shift your popper on both its axis.
  35698. *
  35699. * It accepts the following units:
  35700. * - `px` or unit-less, interpreted as pixels
  35701. * - `%` or `%r`, percentage relative to the length of the reference element
  35702. * - `%p`, percentage relative to the length of the popper element
  35703. * - `vw`, CSS viewport width unit
  35704. * - `vh`, CSS viewport height unit
  35705. *
  35706. * For length is intended the main axis relative to the placement of the popper.<br />
  35707. * This means that if the placement is `top` or `bottom`, the length will be the
  35708. * `width`. In case of `left` or `right`, it will be the `height`.
  35709. *
  35710. * You can provide a single value (as `Number` or `String`), or a pair of values
  35711. * as `String` divided by a comma or one (or more) white spaces.<br />
  35712. * The latter is a deprecated method because it leads to confusion and will be
  35713. * removed in v2.<br />
  35714. * Additionally, it accepts additions and subtractions between different units.
  35715. * Note that multiplications and divisions aren't supported.
  35716. *
  35717. * Valid examples are:
  35718. * ```
  35719. * 10
  35720. * '10%'
  35721. * '10, 10'
  35722. * '10%, 10'
  35723. * '10 + 10%'
  35724. * '10 - 5vh + 3%'
  35725. * '-10px + 5vh, 5px - 6%'
  35726. * ```
  35727. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35728. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35729. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35730. *
  35731. * @memberof modifiers
  35732. * @inner
  35733. */
  35734. offset: {
  35735. /** @prop {number} order=200 - Index used to define the order of execution */
  35736. order: 200,
  35737. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35738. enabled: true,
  35739. /** @prop {ModifierFn} */
  35740. fn: offset,
  35741. /** @prop {Number|String} offset=0
  35742. * The offset value as described in the modifier description
  35743. */
  35744. offset: 0
  35745. },
  35746. /**
  35747. * Modifier used to prevent the popper from being positioned outside the boundary.
  35748. *
  35749. * A scenario exists where the reference itself is not within the boundaries.<br />
  35750. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35751. * In this case we need to decide whether the popper should either:
  35752. *
  35753. * - detach from the reference and remain "trapped" in the boundaries, or
  35754. * - if it should ignore the boundary and "escape with its reference"
  35755. *
  35756. * When `escapeWithReference` is set to`true` and reference is completely
  35757. * outside its boundaries, the popper will overflow (or completely leave)
  35758. * the boundaries in order to remain attached to the edge of the reference.
  35759. *
  35760. * @memberof modifiers
  35761. * @inner
  35762. */
  35763. preventOverflow: {
  35764. /** @prop {number} order=300 - Index used to define the order of execution */
  35765. order: 300,
  35766. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35767. enabled: true,
  35768. /** @prop {ModifierFn} */
  35769. fn: preventOverflow,
  35770. /**
  35771. * @prop {Array} [priority=['left','right','top','bottom']]
  35772. * Popper will try to prevent overflow following these priorities by default,
  35773. * then, it could overflow on the left and on top of the `boundariesElement`
  35774. */
  35775. priority: ['left', 'right', 'top', 'bottom'],
  35776. /**
  35777. * @prop {number} padding=5
  35778. * Amount of pixel used to define a minimum distance between the boundaries
  35779. * and the popper. This makes sure the popper always has a little padding
  35780. * between the edges of its container
  35781. */
  35782. padding: 5,
  35783. /**
  35784. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35785. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35786. * `viewport` or any DOM element.
  35787. */
  35788. boundariesElement: 'scrollParent'
  35789. },
  35790. /**
  35791. * Modifier used to make sure the reference and its popper stay near each other
  35792. * without leaving any gap between the two. Especially useful when the arrow is
  35793. * enabled and you want to ensure that it points to its reference element.
  35794. * It cares only about the first axis. You can still have poppers with margin
  35795. * between the popper and its reference element.
  35796. * @memberof modifiers
  35797. * @inner
  35798. */
  35799. keepTogether: {
  35800. /** @prop {number} order=400 - Index used to define the order of execution */
  35801. order: 400,
  35802. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35803. enabled: true,
  35804. /** @prop {ModifierFn} */
  35805. fn: keepTogether
  35806. },
  35807. /**
  35808. * This modifier is used to move the `arrowElement` of the popper to make
  35809. * sure it is positioned between the reference element and its popper element.
  35810. * It will read the outer size of the `arrowElement` node to detect how many
  35811. * pixels of conjunction are needed.
  35812. *
  35813. * It has no effect if no `arrowElement` is provided.
  35814. * @memberof modifiers
  35815. * @inner
  35816. */
  35817. arrow: {
  35818. /** @prop {number} order=500 - Index used to define the order of execution */
  35819. order: 500,
  35820. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35821. enabled: true,
  35822. /** @prop {ModifierFn} */
  35823. fn: arrow,
  35824. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35825. element: '[x-arrow]'
  35826. },
  35827. /**
  35828. * Modifier used to flip the popper's placement when it starts to overlap its
  35829. * reference element.
  35830. *
  35831. * Requires the `preventOverflow` modifier before it in order to work.
  35832. *
  35833. * **NOTE:** this modifier will interrupt the current update cycle and will
  35834. * restart it if it detects the need to flip the placement.
  35835. * @memberof modifiers
  35836. * @inner
  35837. */
  35838. flip: {
  35839. /** @prop {number} order=600 - Index used to define the order of execution */
  35840. order: 600,
  35841. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35842. enabled: true,
  35843. /** @prop {ModifierFn} */
  35844. fn: flip,
  35845. /**
  35846. * @prop {String|Array} behavior='flip'
  35847. * The behavior used to change the popper's placement. It can be one of
  35848. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35849. * placements (with optional variations)
  35850. */
  35851. behavior: 'flip',
  35852. /**
  35853. * @prop {number} padding=5
  35854. * The popper will flip if it hits the edges of the `boundariesElement`
  35855. */
  35856. padding: 5,
  35857. /**
  35858. * @prop {String|HTMLElement} boundariesElement='viewport'
  35859. * The element which will define the boundaries of the popper position.
  35860. * The popper will never be placed outside of the defined boundaries
  35861. * (except if `keepTogether` is enabled)
  35862. */
  35863. boundariesElement: 'viewport',
  35864. /**
  35865. * @prop {Boolean} flipVariations=false
  35866. * The popper will switch placement variation between `-start` and `-end` when
  35867. * the reference element overlaps its boundaries.
  35868. *
  35869. * The original placement should have a set variation.
  35870. */
  35871. flipVariations: false,
  35872. /**
  35873. * @prop {Boolean} flipVariationsByContent=false
  35874. * The popper will switch placement variation between `-start` and `-end` when
  35875. * the popper element overlaps its reference boundaries.
  35876. *
  35877. * The original placement should have a set variation.
  35878. */
  35879. flipVariationsByContent: false
  35880. },
  35881. /**
  35882. * Modifier used to make the popper flow toward the inner of the reference element.
  35883. * By default, when this modifier is disabled, the popper will be placed outside
  35884. * the reference element.
  35885. * @memberof modifiers
  35886. * @inner
  35887. */
  35888. inner: {
  35889. /** @prop {number} order=700 - Index used to define the order of execution */
  35890. order: 700,
  35891. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35892. enabled: false,
  35893. /** @prop {ModifierFn} */
  35894. fn: inner
  35895. },
  35896. /**
  35897. * Modifier used to hide the popper when its reference element is outside of the
  35898. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35899. * be used to hide with a CSS selector the popper when its reference is
  35900. * out of boundaries.
  35901. *
  35902. * Requires the `preventOverflow` modifier before it in order to work.
  35903. * @memberof modifiers
  35904. * @inner
  35905. */
  35906. hide: {
  35907. /** @prop {number} order=800 - Index used to define the order of execution */
  35908. order: 800,
  35909. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35910. enabled: true,
  35911. /** @prop {ModifierFn} */
  35912. fn: hide
  35913. },
  35914. /**
  35915. * Computes the style that will be applied to the popper element to gets
  35916. * properly positioned.
  35917. *
  35918. * Note that this modifier will not touch the DOM, it just prepares the styles
  35919. * so that `applyStyle` modifier can apply it. This separation is useful
  35920. * in case you need to replace `applyStyle` with a custom implementation.
  35921. *
  35922. * This modifier has `850` as `order` value to maintain backward compatibility
  35923. * with previous versions of Popper.js. Expect the modifiers ordering method
  35924. * to change in future major versions of the library.
  35925. *
  35926. * @memberof modifiers
  35927. * @inner
  35928. */
  35929. computeStyle: {
  35930. /** @prop {number} order=850 - Index used to define the order of execution */
  35931. order: 850,
  35932. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35933. enabled: true,
  35934. /** @prop {ModifierFn} */
  35935. fn: computeStyle,
  35936. /**
  35937. * @prop {Boolean} gpuAcceleration=true
  35938. * If true, it uses the CSS 3D transformation to position the popper.
  35939. * Otherwise, it will use the `top` and `left` properties
  35940. */
  35941. gpuAcceleration: true,
  35942. /**
  35943. * @prop {string} [x='bottom']
  35944. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35945. * Change this if your popper should grow in a direction different from `bottom`
  35946. */
  35947. x: 'bottom',
  35948. /**
  35949. * @prop {string} [x='left']
  35950. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35951. * Change this if your popper should grow in a direction different from `right`
  35952. */
  35953. y: 'right'
  35954. },
  35955. /**
  35956. * Applies the computed styles to the popper element.
  35957. *
  35958. * All the DOM manipulations are limited to this modifier. This is useful in case
  35959. * you want to integrate Popper.js inside a framework or view library and you
  35960. * want to delegate all the DOM manipulations to it.
  35961. *
  35962. * Note that if you disable this modifier, you must make sure the popper element
  35963. * has its position set to `absolute` before Popper.js can do its work!
  35964. *
  35965. * Just disable this modifier and define your own to achieve the desired effect.
  35966. *
  35967. * @memberof modifiers
  35968. * @inner
  35969. */
  35970. applyStyle: {
  35971. /** @prop {number} order=900 - Index used to define the order of execution */
  35972. order: 900,
  35973. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35974. enabled: true,
  35975. /** @prop {ModifierFn} */
  35976. fn: applyStyle,
  35977. /** @prop {Function} */
  35978. onLoad: applyStyleOnLoad,
  35979. /**
  35980. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35981. * @prop {Boolean} gpuAcceleration=true
  35982. * If true, it uses the CSS 3D transformation to position the popper.
  35983. * Otherwise, it will use the `top` and `left` properties
  35984. */
  35985. gpuAcceleration: undefined
  35986. }
  35987. };
  35988. /**
  35989. * The `dataObject` is an object containing all the information used by Popper.js.
  35990. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35991. * @name dataObject
  35992. * @property {Object} data.instance The Popper.js instance
  35993. * @property {String} data.placement Placement applied to popper
  35994. * @property {String} data.originalPlacement Placement originally defined on init
  35995. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35996. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35997. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35998. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35999. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  36000. * @property {Object} data.boundaries Offsets of the popper boundaries
  36001. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  36002. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  36003. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  36004. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  36005. */
  36006. /**
  36007. * Default options provided to Popper.js constructor.<br />
  36008. * These can be overridden using the `options` argument of Popper.js.<br />
  36009. * To override an option, simply pass an object with the same
  36010. * structure of the `options` object, as the 3rd argument. For example:
  36011. * ```
  36012. * new Popper(ref, pop, {
  36013. * modifiers: {
  36014. * preventOverflow: { enabled: false }
  36015. * }
  36016. * })
  36017. * ```
  36018. * @type {Object}
  36019. * @static
  36020. * @memberof Popper
  36021. */
  36022. var Defaults = {
  36023. /**
  36024. * Popper's placement.
  36025. * @prop {Popper.placements} placement='bottom'
  36026. */
  36027. placement: 'bottom',
  36028. /**
  36029. * Set this to true if you want popper to position it self in 'fixed' mode
  36030. * @prop {Boolean} positionFixed=false
  36031. */
  36032. positionFixed: false,
  36033. /**
  36034. * Whether events (resize, scroll) are initially enabled.
  36035. * @prop {Boolean} eventsEnabled=true
  36036. */
  36037. eventsEnabled: true,
  36038. /**
  36039. * Set to true if you want to automatically remove the popper when
  36040. * you call the `destroy` method.
  36041. * @prop {Boolean} removeOnDestroy=false
  36042. */
  36043. removeOnDestroy: false,
  36044. /**
  36045. * Callback called when the popper is created.<br />
  36046. * By default, it is set to no-op.<br />
  36047. * Access Popper.js instance with `data.instance`.
  36048. * @prop {onCreate}
  36049. */
  36050. onCreate: function onCreate() {},
  36051. /**
  36052. * Callback called when the popper is updated. This callback is not called
  36053. * on the initialization/creation of the popper, but only on subsequent
  36054. * updates.<br />
  36055. * By default, it is set to no-op.<br />
  36056. * Access Popper.js instance with `data.instance`.
  36057. * @prop {onUpdate}
  36058. */
  36059. onUpdate: function onUpdate() {},
  36060. /**
  36061. * List of modifiers used to modify the offsets before they are applied to the popper.
  36062. * They provide most of the functionalities of Popper.js.
  36063. * @prop {modifiers}
  36064. */
  36065. modifiers: modifiers
  36066. };
  36067. /**
  36068. * @callback onCreate
  36069. * @param {dataObject} data
  36070. */
  36071. /**
  36072. * @callback onUpdate
  36073. * @param {dataObject} data
  36074. */
  36075. // Utils
  36076. // Methods
  36077. var Popper = function () {
  36078. /**
  36079. * Creates a new Popper.js instance.
  36080. * @class Popper
  36081. * @param {Element|referenceObject} reference - The reference element used to position the popper
  36082. * @param {Element} popper - The HTML / XML element used as the popper
  36083. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  36084. * @return {Object} instance - The generated Popper.js instance
  36085. */
  36086. function Popper(reference, popper) {
  36087. var _this = this;
  36088. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  36089. classCallCheck(this, Popper);
  36090. this.scheduleUpdate = function () {
  36091. return requestAnimationFrame(_this.update);
  36092. };
  36093. // make update() debounced, so that it only runs at most once-per-tick
  36094. this.update = debounce(this.update.bind(this));
  36095. // with {} we create a new object with the options inside it
  36096. this.options = _extends({}, Popper.Defaults, options);
  36097. // init state
  36098. this.state = {
  36099. isDestroyed: false,
  36100. isCreated: false,
  36101. scrollParents: []
  36102. };
  36103. // get reference and popper elements (allow jQuery wrappers)
  36104. this.reference = reference && reference.jquery ? reference[0] : reference;
  36105. this.popper = popper && popper.jquery ? popper[0] : popper;
  36106. // Deep merge modifiers options
  36107. this.options.modifiers = {};
  36108. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  36109. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36110. });
  36111. // Refactoring modifiers' list (Object => Array)
  36112. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36113. return _extends({
  36114. name: name
  36115. }, _this.options.modifiers[name]);
  36116. })
  36117. // sort the modifiers by order
  36118. .sort(function (a, b) {
  36119. return a.order - b.order;
  36120. });
  36121. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36122. // such code is executed in the same order of its modifier
  36123. // they could add new properties to their options configuration
  36124. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36125. this.modifiers.forEach(function (modifierOptions) {
  36126. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36127. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36128. }
  36129. });
  36130. // fire the first update to position the popper in the right place
  36131. this.update();
  36132. var eventsEnabled = this.options.eventsEnabled;
  36133. if (eventsEnabled) {
  36134. // setup event listeners, they will take care of update the position in specific situations
  36135. this.enableEventListeners();
  36136. }
  36137. this.state.eventsEnabled = eventsEnabled;
  36138. }
  36139. // We can't use class properties because they don't get listed in the
  36140. // class prototype and break stuff like Sinon stubs
  36141. createClass(Popper, [{
  36142. key: 'update',
  36143. value: function update$$1() {
  36144. return update.call(this);
  36145. }
  36146. }, {
  36147. key: 'destroy',
  36148. value: function destroy$$1() {
  36149. return destroy.call(this);
  36150. }
  36151. }, {
  36152. key: 'enableEventListeners',
  36153. value: function enableEventListeners$$1() {
  36154. return enableEventListeners.call(this);
  36155. }
  36156. }, {
  36157. key: 'disableEventListeners',
  36158. value: function disableEventListeners$$1() {
  36159. return disableEventListeners.call(this);
  36160. }
  36161. /**
  36162. * Schedules an update. It will run on the next UI update available.
  36163. * @method scheduleUpdate
  36164. * @memberof Popper
  36165. */
  36166. /**
  36167. * Collection of utilities useful when writing custom modifiers.
  36168. * Starting from version 1.7, this method is available only if you
  36169. * include `popper-utils.js` before `popper.js`.
  36170. *
  36171. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36172. * and will be removed in v2! Use the PopperUtils module directly instead.
  36173. * Due to the high instability of the methods contained in Utils, we can't
  36174. * guarantee them to follow semver. Use them at your own risk!
  36175. * @static
  36176. * @private
  36177. * @type {Object}
  36178. * @deprecated since version 1.8
  36179. * @member Utils
  36180. * @memberof Popper
  36181. */
  36182. }]);
  36183. return Popper;
  36184. }();
  36185. /**
  36186. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36187. * and lets you use it as replacement of a real DOM node.<br />
  36188. * You can use this method to position a popper relatively to a set of coordinates
  36189. * in case you don't have a DOM node to use as reference.
  36190. *
  36191. * ```
  36192. * new Popper(referenceObject, popperNode);
  36193. * ```
  36194. *
  36195. * NB: This feature isn't supported in Internet Explorer 10.
  36196. * @name referenceObject
  36197. * @property {Function} data.getBoundingClientRect
  36198. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36199. * @property {number} data.clientWidth
  36200. * An ES6 getter that will return the width of the virtual reference element.
  36201. * @property {number} data.clientHeight
  36202. * An ES6 getter that will return the height of the virtual reference element.
  36203. */
  36204. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36205. Popper.placements = placements;
  36206. Popper.Defaults = Defaults;
  36207. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36208. //# sourceMappingURL=popper.js.map
  36209. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36210. /***/ }),
  36211. /***/ "./node_modules/process/browser.js":
  36212. /*!*****************************************!*\
  36213. !*** ./node_modules/process/browser.js ***!
  36214. \*****************************************/
  36215. /*! no static exports found */
  36216. /***/ (function(module, exports) {
  36217. // shim for using process in browser
  36218. var process = module.exports = {};
  36219. // cached from whatever global is present so that test runners that stub it
  36220. // don't break things. But we need to wrap it in a try catch in case it is
  36221. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36222. // function because try/catches deoptimize in certain engines.
  36223. var cachedSetTimeout;
  36224. var cachedClearTimeout;
  36225. function defaultSetTimout() {
  36226. throw new Error('setTimeout has not been defined');
  36227. }
  36228. function defaultClearTimeout () {
  36229. throw new Error('clearTimeout has not been defined');
  36230. }
  36231. (function () {
  36232. try {
  36233. if (typeof setTimeout === 'function') {
  36234. cachedSetTimeout = setTimeout;
  36235. } else {
  36236. cachedSetTimeout = defaultSetTimout;
  36237. }
  36238. } catch (e) {
  36239. cachedSetTimeout = defaultSetTimout;
  36240. }
  36241. try {
  36242. if (typeof clearTimeout === 'function') {
  36243. cachedClearTimeout = clearTimeout;
  36244. } else {
  36245. cachedClearTimeout = defaultClearTimeout;
  36246. }
  36247. } catch (e) {
  36248. cachedClearTimeout = defaultClearTimeout;
  36249. }
  36250. } ())
  36251. function runTimeout(fun) {
  36252. if (cachedSetTimeout === setTimeout) {
  36253. //normal enviroments in sane situations
  36254. return setTimeout(fun, 0);
  36255. }
  36256. // if setTimeout wasn't available but was latter defined
  36257. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36258. cachedSetTimeout = setTimeout;
  36259. return setTimeout(fun, 0);
  36260. }
  36261. try {
  36262. // when when somebody has screwed with setTimeout but no I.E. maddness
  36263. return cachedSetTimeout(fun, 0);
  36264. } catch(e){
  36265. try {
  36266. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36267. return cachedSetTimeout.call(null, fun, 0);
  36268. } catch(e){
  36269. // 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
  36270. return cachedSetTimeout.call(this, fun, 0);
  36271. }
  36272. }
  36273. }
  36274. function runClearTimeout(marker) {
  36275. if (cachedClearTimeout === clearTimeout) {
  36276. //normal enviroments in sane situations
  36277. return clearTimeout(marker);
  36278. }
  36279. // if clearTimeout wasn't available but was latter defined
  36280. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36281. cachedClearTimeout = clearTimeout;
  36282. return clearTimeout(marker);
  36283. }
  36284. try {
  36285. // when when somebody has screwed with setTimeout but no I.E. maddness
  36286. return cachedClearTimeout(marker);
  36287. } catch (e){
  36288. try {
  36289. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36290. return cachedClearTimeout.call(null, marker);
  36291. } catch (e){
  36292. // 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.
  36293. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36294. return cachedClearTimeout.call(this, marker);
  36295. }
  36296. }
  36297. }
  36298. var queue = [];
  36299. var draining = false;
  36300. var currentQueue;
  36301. var queueIndex = -1;
  36302. function cleanUpNextTick() {
  36303. if (!draining || !currentQueue) {
  36304. return;
  36305. }
  36306. draining = false;
  36307. if (currentQueue.length) {
  36308. queue = currentQueue.concat(queue);
  36309. } else {
  36310. queueIndex = -1;
  36311. }
  36312. if (queue.length) {
  36313. drainQueue();
  36314. }
  36315. }
  36316. function drainQueue() {
  36317. if (draining) {
  36318. return;
  36319. }
  36320. var timeout = runTimeout(cleanUpNextTick);
  36321. draining = true;
  36322. var len = queue.length;
  36323. while(len) {
  36324. currentQueue = queue;
  36325. queue = [];
  36326. while (++queueIndex < len) {
  36327. if (currentQueue) {
  36328. currentQueue[queueIndex].run();
  36329. }
  36330. }
  36331. queueIndex = -1;
  36332. len = queue.length;
  36333. }
  36334. currentQueue = null;
  36335. draining = false;
  36336. runClearTimeout(timeout);
  36337. }
  36338. process.nextTick = function (fun) {
  36339. var args = new Array(arguments.length - 1);
  36340. if (arguments.length > 1) {
  36341. for (var i = 1; i < arguments.length; i++) {
  36342. args[i - 1] = arguments[i];
  36343. }
  36344. }
  36345. queue.push(new Item(fun, args));
  36346. if (queue.length === 1 && !draining) {
  36347. runTimeout(drainQueue);
  36348. }
  36349. };
  36350. // v8 likes predictible objects
  36351. function Item(fun, array) {
  36352. this.fun = fun;
  36353. this.array = array;
  36354. }
  36355. Item.prototype.run = function () {
  36356. this.fun.apply(null, this.array);
  36357. };
  36358. process.title = 'browser';
  36359. process.browser = true;
  36360. process.env = {};
  36361. process.argv = [];
  36362. process.version = ''; // empty string to avoid regexp issues
  36363. process.versions = {};
  36364. function noop() {}
  36365. process.on = noop;
  36366. process.addListener = noop;
  36367. process.once = noop;
  36368. process.off = noop;
  36369. process.removeListener = noop;
  36370. process.removeAllListeners = noop;
  36371. process.emit = noop;
  36372. process.prependListener = noop;
  36373. process.prependOnceListener = noop;
  36374. process.listeners = function (name) { return [] }
  36375. process.binding = function (name) {
  36376. throw new Error('process.binding is not supported');
  36377. };
  36378. process.cwd = function () { return '/' };
  36379. process.chdir = function (dir) {
  36380. throw new Error('process.chdir is not supported');
  36381. };
  36382. process.umask = function() { return 0; };
  36383. /***/ }),
  36384. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36385. /*!***************************************************!*\
  36386. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36387. \***************************************************/
  36388. /*! no static exports found */
  36389. /***/ (function(module, exports, __webpack_require__) {
  36390. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36391. * Pusher JavaScript Library v5.0.3
  36392. * https://pusher.com/
  36393. *
  36394. * Copyright 2017, Pusher
  36395. * Released under the MIT licence.
  36396. */
  36397. (function webpackUniversalModuleDefinition(root, factory) {
  36398. if(true)
  36399. module.exports = factory();
  36400. else {}
  36401. })(window, function() {
  36402. return /******/ (function(modules) { // webpackBootstrap
  36403. /******/ // The module cache
  36404. /******/ var installedModules = {};
  36405. /******/
  36406. /******/ // The require function
  36407. /******/ function __webpack_require__(moduleId) {
  36408. /******/
  36409. /******/ // Check if module is in cache
  36410. /******/ if(installedModules[moduleId]) {
  36411. /******/ return installedModules[moduleId].exports;
  36412. /******/ }
  36413. /******/ // Create a new module (and put it into the cache)
  36414. /******/ var module = installedModules[moduleId] = {
  36415. /******/ i: moduleId,
  36416. /******/ l: false,
  36417. /******/ exports: {}
  36418. /******/ };
  36419. /******/
  36420. /******/ // Execute the module function
  36421. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36422. /******/
  36423. /******/ // Flag the module as loaded
  36424. /******/ module.l = true;
  36425. /******/
  36426. /******/ // Return the exports of the module
  36427. /******/ return module.exports;
  36428. /******/ }
  36429. /******/
  36430. /******/
  36431. /******/ // expose the modules object (__webpack_modules__)
  36432. /******/ __webpack_require__.m = modules;
  36433. /******/
  36434. /******/ // expose the module cache
  36435. /******/ __webpack_require__.c = installedModules;
  36436. /******/
  36437. /******/ // define getter function for harmony exports
  36438. /******/ __webpack_require__.d = function(exports, name, getter) {
  36439. /******/ if(!__webpack_require__.o(exports, name)) {
  36440. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36441. /******/ }
  36442. /******/ };
  36443. /******/
  36444. /******/ // define __esModule on exports
  36445. /******/ __webpack_require__.r = function(exports) {
  36446. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36447. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36448. /******/ }
  36449. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36450. /******/ };
  36451. /******/
  36452. /******/ // create a fake namespace object
  36453. /******/ // mode & 1: value is a module id, require it
  36454. /******/ // mode & 2: merge all properties of value into the ns
  36455. /******/ // mode & 4: return value when already ns object
  36456. /******/ // mode & 8|1: behave like require
  36457. /******/ __webpack_require__.t = function(value, mode) {
  36458. /******/ if(mode & 1) value = __webpack_require__(value);
  36459. /******/ if(mode & 8) return value;
  36460. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36461. /******/ var ns = Object.create(null);
  36462. /******/ __webpack_require__.r(ns);
  36463. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36464. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36465. /******/ return ns;
  36466. /******/ };
  36467. /******/
  36468. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36469. /******/ __webpack_require__.n = function(module) {
  36470. /******/ var getter = module && module.__esModule ?
  36471. /******/ function getDefault() { return module['default']; } :
  36472. /******/ function getModuleExports() { return module; };
  36473. /******/ __webpack_require__.d(getter, 'a', getter);
  36474. /******/ return getter;
  36475. /******/ };
  36476. /******/
  36477. /******/ // Object.prototype.hasOwnProperty.call
  36478. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36479. /******/
  36480. /******/ // __webpack_public_path__
  36481. /******/ __webpack_require__.p = "";
  36482. /******/
  36483. /******/
  36484. /******/ // Load entry module and return exports
  36485. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36486. /******/ })
  36487. /************************************************************************/
  36488. /******/ ([
  36489. /* 0 */
  36490. /***/ (function(module, exports, __webpack_require__) {
  36491. (function(nacl) {
  36492. 'use strict';
  36493. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36494. // Public domain.
  36495. //
  36496. // Implementation derived from TweetNaCl version 20140427.
  36497. // See for details: http://tweetnacl.cr.yp.to/
  36498. var gf = function(init) {
  36499. var i, r = new Float64Array(16);
  36500. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36501. return r;
  36502. };
  36503. // Pluggable, initialized in high-level API below.
  36504. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36505. var _0 = new Uint8Array(16);
  36506. var _9 = new Uint8Array(32); _9[0] = 9;
  36507. var gf0 = gf(),
  36508. gf1 = gf([1]),
  36509. _121665 = gf([0xdb41, 1]),
  36510. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36511. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36512. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36513. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36514. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36515. function ts64(x, i, h, l) {
  36516. x[i] = (h >> 24) & 0xff;
  36517. x[i+1] = (h >> 16) & 0xff;
  36518. x[i+2] = (h >> 8) & 0xff;
  36519. x[i+3] = h & 0xff;
  36520. x[i+4] = (l >> 24) & 0xff;
  36521. x[i+5] = (l >> 16) & 0xff;
  36522. x[i+6] = (l >> 8) & 0xff;
  36523. x[i+7] = l & 0xff;
  36524. }
  36525. function vn(x, xi, y, yi, n) {
  36526. var i,d = 0;
  36527. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36528. return (1 & ((d - 1) >>> 8)) - 1;
  36529. }
  36530. function crypto_verify_16(x, xi, y, yi) {
  36531. return vn(x,xi,y,yi,16);
  36532. }
  36533. function crypto_verify_32(x, xi, y, yi) {
  36534. return vn(x,xi,y,yi,32);
  36535. }
  36536. function core_salsa20(o, p, k, c) {
  36537. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36538. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36539. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36540. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36541. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36542. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36543. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36544. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36545. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36546. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36547. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36548. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36549. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36550. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36551. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36552. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36553. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36554. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36555. x15 = j15, u;
  36556. for (var i = 0; i < 20; i += 2) {
  36557. u = x0 + x12 | 0;
  36558. x4 ^= u<<7 | u>>>(32-7);
  36559. u = x4 + x0 | 0;
  36560. x8 ^= u<<9 | u>>>(32-9);
  36561. u = x8 + x4 | 0;
  36562. x12 ^= u<<13 | u>>>(32-13);
  36563. u = x12 + x8 | 0;
  36564. x0 ^= u<<18 | u>>>(32-18);
  36565. u = x5 + x1 | 0;
  36566. x9 ^= u<<7 | u>>>(32-7);
  36567. u = x9 + x5 | 0;
  36568. x13 ^= u<<9 | u>>>(32-9);
  36569. u = x13 + x9 | 0;
  36570. x1 ^= u<<13 | u>>>(32-13);
  36571. u = x1 + x13 | 0;
  36572. x5 ^= u<<18 | u>>>(32-18);
  36573. u = x10 + x6 | 0;
  36574. x14 ^= u<<7 | u>>>(32-7);
  36575. u = x14 + x10 | 0;
  36576. x2 ^= u<<9 | u>>>(32-9);
  36577. u = x2 + x14 | 0;
  36578. x6 ^= u<<13 | u>>>(32-13);
  36579. u = x6 + x2 | 0;
  36580. x10 ^= u<<18 | u>>>(32-18);
  36581. u = x15 + x11 | 0;
  36582. x3 ^= u<<7 | u>>>(32-7);
  36583. u = x3 + x15 | 0;
  36584. x7 ^= u<<9 | u>>>(32-9);
  36585. u = x7 + x3 | 0;
  36586. x11 ^= u<<13 | u>>>(32-13);
  36587. u = x11 + x7 | 0;
  36588. x15 ^= u<<18 | u>>>(32-18);
  36589. u = x0 + x3 | 0;
  36590. x1 ^= u<<7 | u>>>(32-7);
  36591. u = x1 + x0 | 0;
  36592. x2 ^= u<<9 | u>>>(32-9);
  36593. u = x2 + x1 | 0;
  36594. x3 ^= u<<13 | u>>>(32-13);
  36595. u = x3 + x2 | 0;
  36596. x0 ^= u<<18 | u>>>(32-18);
  36597. u = x5 + x4 | 0;
  36598. x6 ^= u<<7 | u>>>(32-7);
  36599. u = x6 + x5 | 0;
  36600. x7 ^= u<<9 | u>>>(32-9);
  36601. u = x7 + x6 | 0;
  36602. x4 ^= u<<13 | u>>>(32-13);
  36603. u = x4 + x7 | 0;
  36604. x5 ^= u<<18 | u>>>(32-18);
  36605. u = x10 + x9 | 0;
  36606. x11 ^= u<<7 | u>>>(32-7);
  36607. u = x11 + x10 | 0;
  36608. x8 ^= u<<9 | u>>>(32-9);
  36609. u = x8 + x11 | 0;
  36610. x9 ^= u<<13 | u>>>(32-13);
  36611. u = x9 + x8 | 0;
  36612. x10 ^= u<<18 | u>>>(32-18);
  36613. u = x15 + x14 | 0;
  36614. x12 ^= u<<7 | u>>>(32-7);
  36615. u = x12 + x15 | 0;
  36616. x13 ^= u<<9 | u>>>(32-9);
  36617. u = x13 + x12 | 0;
  36618. x14 ^= u<<13 | u>>>(32-13);
  36619. u = x14 + x13 | 0;
  36620. x15 ^= u<<18 | u>>>(32-18);
  36621. }
  36622. x0 = x0 + j0 | 0;
  36623. x1 = x1 + j1 | 0;
  36624. x2 = x2 + j2 | 0;
  36625. x3 = x3 + j3 | 0;
  36626. x4 = x4 + j4 | 0;
  36627. x5 = x5 + j5 | 0;
  36628. x6 = x6 + j6 | 0;
  36629. x7 = x7 + j7 | 0;
  36630. x8 = x8 + j8 | 0;
  36631. x9 = x9 + j9 | 0;
  36632. x10 = x10 + j10 | 0;
  36633. x11 = x11 + j11 | 0;
  36634. x12 = x12 + j12 | 0;
  36635. x13 = x13 + j13 | 0;
  36636. x14 = x14 + j14 | 0;
  36637. x15 = x15 + j15 | 0;
  36638. o[ 0] = x0 >>> 0 & 0xff;
  36639. o[ 1] = x0 >>> 8 & 0xff;
  36640. o[ 2] = x0 >>> 16 & 0xff;
  36641. o[ 3] = x0 >>> 24 & 0xff;
  36642. o[ 4] = x1 >>> 0 & 0xff;
  36643. o[ 5] = x1 >>> 8 & 0xff;
  36644. o[ 6] = x1 >>> 16 & 0xff;
  36645. o[ 7] = x1 >>> 24 & 0xff;
  36646. o[ 8] = x2 >>> 0 & 0xff;
  36647. o[ 9] = x2 >>> 8 & 0xff;
  36648. o[10] = x2 >>> 16 & 0xff;
  36649. o[11] = x2 >>> 24 & 0xff;
  36650. o[12] = x3 >>> 0 & 0xff;
  36651. o[13] = x3 >>> 8 & 0xff;
  36652. o[14] = x3 >>> 16 & 0xff;
  36653. o[15] = x3 >>> 24 & 0xff;
  36654. o[16] = x4 >>> 0 & 0xff;
  36655. o[17] = x4 >>> 8 & 0xff;
  36656. o[18] = x4 >>> 16 & 0xff;
  36657. o[19] = x4 >>> 24 & 0xff;
  36658. o[20] = x5 >>> 0 & 0xff;
  36659. o[21] = x5 >>> 8 & 0xff;
  36660. o[22] = x5 >>> 16 & 0xff;
  36661. o[23] = x5 >>> 24 & 0xff;
  36662. o[24] = x6 >>> 0 & 0xff;
  36663. o[25] = x6 >>> 8 & 0xff;
  36664. o[26] = x6 >>> 16 & 0xff;
  36665. o[27] = x6 >>> 24 & 0xff;
  36666. o[28] = x7 >>> 0 & 0xff;
  36667. o[29] = x7 >>> 8 & 0xff;
  36668. o[30] = x7 >>> 16 & 0xff;
  36669. o[31] = x7 >>> 24 & 0xff;
  36670. o[32] = x8 >>> 0 & 0xff;
  36671. o[33] = x8 >>> 8 & 0xff;
  36672. o[34] = x8 >>> 16 & 0xff;
  36673. o[35] = x8 >>> 24 & 0xff;
  36674. o[36] = x9 >>> 0 & 0xff;
  36675. o[37] = x9 >>> 8 & 0xff;
  36676. o[38] = x9 >>> 16 & 0xff;
  36677. o[39] = x9 >>> 24 & 0xff;
  36678. o[40] = x10 >>> 0 & 0xff;
  36679. o[41] = x10 >>> 8 & 0xff;
  36680. o[42] = x10 >>> 16 & 0xff;
  36681. o[43] = x10 >>> 24 & 0xff;
  36682. o[44] = x11 >>> 0 & 0xff;
  36683. o[45] = x11 >>> 8 & 0xff;
  36684. o[46] = x11 >>> 16 & 0xff;
  36685. o[47] = x11 >>> 24 & 0xff;
  36686. o[48] = x12 >>> 0 & 0xff;
  36687. o[49] = x12 >>> 8 & 0xff;
  36688. o[50] = x12 >>> 16 & 0xff;
  36689. o[51] = x12 >>> 24 & 0xff;
  36690. o[52] = x13 >>> 0 & 0xff;
  36691. o[53] = x13 >>> 8 & 0xff;
  36692. o[54] = x13 >>> 16 & 0xff;
  36693. o[55] = x13 >>> 24 & 0xff;
  36694. o[56] = x14 >>> 0 & 0xff;
  36695. o[57] = x14 >>> 8 & 0xff;
  36696. o[58] = x14 >>> 16 & 0xff;
  36697. o[59] = x14 >>> 24 & 0xff;
  36698. o[60] = x15 >>> 0 & 0xff;
  36699. o[61] = x15 >>> 8 & 0xff;
  36700. o[62] = x15 >>> 16 & 0xff;
  36701. o[63] = x15 >>> 24 & 0xff;
  36702. }
  36703. function core_hsalsa20(o,p,k,c) {
  36704. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36705. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36706. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36707. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36708. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36709. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36710. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36711. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36712. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36713. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36714. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36715. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36716. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36717. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36718. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36719. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36720. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36721. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36722. x15 = j15, u;
  36723. for (var i = 0; i < 20; i += 2) {
  36724. u = x0 + x12 | 0;
  36725. x4 ^= u<<7 | u>>>(32-7);
  36726. u = x4 + x0 | 0;
  36727. x8 ^= u<<9 | u>>>(32-9);
  36728. u = x8 + x4 | 0;
  36729. x12 ^= u<<13 | u>>>(32-13);
  36730. u = x12 + x8 | 0;
  36731. x0 ^= u<<18 | u>>>(32-18);
  36732. u = x5 + x1 | 0;
  36733. x9 ^= u<<7 | u>>>(32-7);
  36734. u = x9 + x5 | 0;
  36735. x13 ^= u<<9 | u>>>(32-9);
  36736. u = x13 + x9 | 0;
  36737. x1 ^= u<<13 | u>>>(32-13);
  36738. u = x1 + x13 | 0;
  36739. x5 ^= u<<18 | u>>>(32-18);
  36740. u = x10 + x6 | 0;
  36741. x14 ^= u<<7 | u>>>(32-7);
  36742. u = x14 + x10 | 0;
  36743. x2 ^= u<<9 | u>>>(32-9);
  36744. u = x2 + x14 | 0;
  36745. x6 ^= u<<13 | u>>>(32-13);
  36746. u = x6 + x2 | 0;
  36747. x10 ^= u<<18 | u>>>(32-18);
  36748. u = x15 + x11 | 0;
  36749. x3 ^= u<<7 | u>>>(32-7);
  36750. u = x3 + x15 | 0;
  36751. x7 ^= u<<9 | u>>>(32-9);
  36752. u = x7 + x3 | 0;
  36753. x11 ^= u<<13 | u>>>(32-13);
  36754. u = x11 + x7 | 0;
  36755. x15 ^= u<<18 | u>>>(32-18);
  36756. u = x0 + x3 | 0;
  36757. x1 ^= u<<7 | u>>>(32-7);
  36758. u = x1 + x0 | 0;
  36759. x2 ^= u<<9 | u>>>(32-9);
  36760. u = x2 + x1 | 0;
  36761. x3 ^= u<<13 | u>>>(32-13);
  36762. u = x3 + x2 | 0;
  36763. x0 ^= u<<18 | u>>>(32-18);
  36764. u = x5 + x4 | 0;
  36765. x6 ^= u<<7 | u>>>(32-7);
  36766. u = x6 + x5 | 0;
  36767. x7 ^= u<<9 | u>>>(32-9);
  36768. u = x7 + x6 | 0;
  36769. x4 ^= u<<13 | u>>>(32-13);
  36770. u = x4 + x7 | 0;
  36771. x5 ^= u<<18 | u>>>(32-18);
  36772. u = x10 + x9 | 0;
  36773. x11 ^= u<<7 | u>>>(32-7);
  36774. u = x11 + x10 | 0;
  36775. x8 ^= u<<9 | u>>>(32-9);
  36776. u = x8 + x11 | 0;
  36777. x9 ^= u<<13 | u>>>(32-13);
  36778. u = x9 + x8 | 0;
  36779. x10 ^= u<<18 | u>>>(32-18);
  36780. u = x15 + x14 | 0;
  36781. x12 ^= u<<7 | u>>>(32-7);
  36782. u = x12 + x15 | 0;
  36783. x13 ^= u<<9 | u>>>(32-9);
  36784. u = x13 + x12 | 0;
  36785. x14 ^= u<<13 | u>>>(32-13);
  36786. u = x14 + x13 | 0;
  36787. x15 ^= u<<18 | u>>>(32-18);
  36788. }
  36789. o[ 0] = x0 >>> 0 & 0xff;
  36790. o[ 1] = x0 >>> 8 & 0xff;
  36791. o[ 2] = x0 >>> 16 & 0xff;
  36792. o[ 3] = x0 >>> 24 & 0xff;
  36793. o[ 4] = x5 >>> 0 & 0xff;
  36794. o[ 5] = x5 >>> 8 & 0xff;
  36795. o[ 6] = x5 >>> 16 & 0xff;
  36796. o[ 7] = x5 >>> 24 & 0xff;
  36797. o[ 8] = x10 >>> 0 & 0xff;
  36798. o[ 9] = x10 >>> 8 & 0xff;
  36799. o[10] = x10 >>> 16 & 0xff;
  36800. o[11] = x10 >>> 24 & 0xff;
  36801. o[12] = x15 >>> 0 & 0xff;
  36802. o[13] = x15 >>> 8 & 0xff;
  36803. o[14] = x15 >>> 16 & 0xff;
  36804. o[15] = x15 >>> 24 & 0xff;
  36805. o[16] = x6 >>> 0 & 0xff;
  36806. o[17] = x6 >>> 8 & 0xff;
  36807. o[18] = x6 >>> 16 & 0xff;
  36808. o[19] = x6 >>> 24 & 0xff;
  36809. o[20] = x7 >>> 0 & 0xff;
  36810. o[21] = x7 >>> 8 & 0xff;
  36811. o[22] = x7 >>> 16 & 0xff;
  36812. o[23] = x7 >>> 24 & 0xff;
  36813. o[24] = x8 >>> 0 & 0xff;
  36814. o[25] = x8 >>> 8 & 0xff;
  36815. o[26] = x8 >>> 16 & 0xff;
  36816. o[27] = x8 >>> 24 & 0xff;
  36817. o[28] = x9 >>> 0 & 0xff;
  36818. o[29] = x9 >>> 8 & 0xff;
  36819. o[30] = x9 >>> 16 & 0xff;
  36820. o[31] = x9 >>> 24 & 0xff;
  36821. }
  36822. function crypto_core_salsa20(out,inp,k,c) {
  36823. core_salsa20(out,inp,k,c);
  36824. }
  36825. function crypto_core_hsalsa20(out,inp,k,c) {
  36826. core_hsalsa20(out,inp,k,c);
  36827. }
  36828. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36829. // "expand 32-byte k"
  36830. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36831. var z = new Uint8Array(16), x = new Uint8Array(64);
  36832. var u, i;
  36833. for (i = 0; i < 16; i++) z[i] = 0;
  36834. for (i = 0; i < 8; i++) z[i] = n[i];
  36835. while (b >= 64) {
  36836. crypto_core_salsa20(x,z,k,sigma);
  36837. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36838. u = 1;
  36839. for (i = 8; i < 16; i++) {
  36840. u = u + (z[i] & 0xff) | 0;
  36841. z[i] = u & 0xff;
  36842. u >>>= 8;
  36843. }
  36844. b -= 64;
  36845. cpos += 64;
  36846. mpos += 64;
  36847. }
  36848. if (b > 0) {
  36849. crypto_core_salsa20(x,z,k,sigma);
  36850. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36851. }
  36852. return 0;
  36853. }
  36854. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36855. var z = new Uint8Array(16), x = new Uint8Array(64);
  36856. var u, i;
  36857. for (i = 0; i < 16; i++) z[i] = 0;
  36858. for (i = 0; i < 8; i++) z[i] = n[i];
  36859. while (b >= 64) {
  36860. crypto_core_salsa20(x,z,k,sigma);
  36861. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36862. u = 1;
  36863. for (i = 8; i < 16; i++) {
  36864. u = u + (z[i] & 0xff) | 0;
  36865. z[i] = u & 0xff;
  36866. u >>>= 8;
  36867. }
  36868. b -= 64;
  36869. cpos += 64;
  36870. }
  36871. if (b > 0) {
  36872. crypto_core_salsa20(x,z,k,sigma);
  36873. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36874. }
  36875. return 0;
  36876. }
  36877. function crypto_stream(c,cpos,d,n,k) {
  36878. var s = new Uint8Array(32);
  36879. crypto_core_hsalsa20(s,n,k,sigma);
  36880. var sn = new Uint8Array(8);
  36881. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36882. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36883. }
  36884. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36885. var s = new Uint8Array(32);
  36886. crypto_core_hsalsa20(s,n,k,sigma);
  36887. var sn = new Uint8Array(8);
  36888. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36889. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36890. }
  36891. /*
  36892. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36893. * https://github.com/floodyberry/poly1305-donna
  36894. */
  36895. var poly1305 = function(key) {
  36896. this.buffer = new Uint8Array(16);
  36897. this.r = new Uint16Array(10);
  36898. this.h = new Uint16Array(10);
  36899. this.pad = new Uint16Array(8);
  36900. this.leftover = 0;
  36901. this.fin = 0;
  36902. var t0, t1, t2, t3, t4, t5, t6, t7;
  36903. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36904. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36905. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36906. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36907. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36908. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36909. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36910. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36911. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36912. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36913. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36914. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36915. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36916. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36917. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36918. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36919. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36920. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36921. };
  36922. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36923. var hibit = this.fin ? 0 : (1 << 11);
  36924. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36925. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36926. var h0 = this.h[0],
  36927. h1 = this.h[1],
  36928. h2 = this.h[2],
  36929. h3 = this.h[3],
  36930. h4 = this.h[4],
  36931. h5 = this.h[5],
  36932. h6 = this.h[6],
  36933. h7 = this.h[7],
  36934. h8 = this.h[8],
  36935. h9 = this.h[9];
  36936. var r0 = this.r[0],
  36937. r1 = this.r[1],
  36938. r2 = this.r[2],
  36939. r3 = this.r[3],
  36940. r4 = this.r[4],
  36941. r5 = this.r[5],
  36942. r6 = this.r[6],
  36943. r7 = this.r[7],
  36944. r8 = this.r[8],
  36945. r9 = this.r[9];
  36946. while (bytes >= 16) {
  36947. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36948. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36949. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36950. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36951. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36952. h5 += ((t4 >>> 1)) & 0x1fff;
  36953. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36954. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36955. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36956. h9 += ((t7 >>> 5)) | hibit;
  36957. c = 0;
  36958. d0 = c;
  36959. d0 += h0 * r0;
  36960. d0 += h1 * (5 * r9);
  36961. d0 += h2 * (5 * r8);
  36962. d0 += h3 * (5 * r7);
  36963. d0 += h4 * (5 * r6);
  36964. c = (d0 >>> 13); d0 &= 0x1fff;
  36965. d0 += h5 * (5 * r5);
  36966. d0 += h6 * (5 * r4);
  36967. d0 += h7 * (5 * r3);
  36968. d0 += h8 * (5 * r2);
  36969. d0 += h9 * (5 * r1);
  36970. c += (d0 >>> 13); d0 &= 0x1fff;
  36971. d1 = c;
  36972. d1 += h0 * r1;
  36973. d1 += h1 * r0;
  36974. d1 += h2 * (5 * r9);
  36975. d1 += h3 * (5 * r8);
  36976. d1 += h4 * (5 * r7);
  36977. c = (d1 >>> 13); d1 &= 0x1fff;
  36978. d1 += h5 * (5 * r6);
  36979. d1 += h6 * (5 * r5);
  36980. d1 += h7 * (5 * r4);
  36981. d1 += h8 * (5 * r3);
  36982. d1 += h9 * (5 * r2);
  36983. c += (d1 >>> 13); d1 &= 0x1fff;
  36984. d2 = c;
  36985. d2 += h0 * r2;
  36986. d2 += h1 * r1;
  36987. d2 += h2 * r0;
  36988. d2 += h3 * (5 * r9);
  36989. d2 += h4 * (5 * r8);
  36990. c = (d2 >>> 13); d2 &= 0x1fff;
  36991. d2 += h5 * (5 * r7);
  36992. d2 += h6 * (5 * r6);
  36993. d2 += h7 * (5 * r5);
  36994. d2 += h8 * (5 * r4);
  36995. d2 += h9 * (5 * r3);
  36996. c += (d2 >>> 13); d2 &= 0x1fff;
  36997. d3 = c;
  36998. d3 += h0 * r3;
  36999. d3 += h1 * r2;
  37000. d3 += h2 * r1;
  37001. d3 += h3 * r0;
  37002. d3 += h4 * (5 * r9);
  37003. c = (d3 >>> 13); d3 &= 0x1fff;
  37004. d3 += h5 * (5 * r8);
  37005. d3 += h6 * (5 * r7);
  37006. d3 += h7 * (5 * r6);
  37007. d3 += h8 * (5 * r5);
  37008. d3 += h9 * (5 * r4);
  37009. c += (d3 >>> 13); d3 &= 0x1fff;
  37010. d4 = c;
  37011. d4 += h0 * r4;
  37012. d4 += h1 * r3;
  37013. d4 += h2 * r2;
  37014. d4 += h3 * r1;
  37015. d4 += h4 * r0;
  37016. c = (d4 >>> 13); d4 &= 0x1fff;
  37017. d4 += h5 * (5 * r9);
  37018. d4 += h6 * (5 * r8);
  37019. d4 += h7 * (5 * r7);
  37020. d4 += h8 * (5 * r6);
  37021. d4 += h9 * (5 * r5);
  37022. c += (d4 >>> 13); d4 &= 0x1fff;
  37023. d5 = c;
  37024. d5 += h0 * r5;
  37025. d5 += h1 * r4;
  37026. d5 += h2 * r3;
  37027. d5 += h3 * r2;
  37028. d5 += h4 * r1;
  37029. c = (d5 >>> 13); d5 &= 0x1fff;
  37030. d5 += h5 * r0;
  37031. d5 += h6 * (5 * r9);
  37032. d5 += h7 * (5 * r8);
  37033. d5 += h8 * (5 * r7);
  37034. d5 += h9 * (5 * r6);
  37035. c += (d5 >>> 13); d5 &= 0x1fff;
  37036. d6 = c;
  37037. d6 += h0 * r6;
  37038. d6 += h1 * r5;
  37039. d6 += h2 * r4;
  37040. d6 += h3 * r3;
  37041. d6 += h4 * r2;
  37042. c = (d6 >>> 13); d6 &= 0x1fff;
  37043. d6 += h5 * r1;
  37044. d6 += h6 * r0;
  37045. d6 += h7 * (5 * r9);
  37046. d6 += h8 * (5 * r8);
  37047. d6 += h9 * (5 * r7);
  37048. c += (d6 >>> 13); d6 &= 0x1fff;
  37049. d7 = c;
  37050. d7 += h0 * r7;
  37051. d7 += h1 * r6;
  37052. d7 += h2 * r5;
  37053. d7 += h3 * r4;
  37054. d7 += h4 * r3;
  37055. c = (d7 >>> 13); d7 &= 0x1fff;
  37056. d7 += h5 * r2;
  37057. d7 += h6 * r1;
  37058. d7 += h7 * r0;
  37059. d7 += h8 * (5 * r9);
  37060. d7 += h9 * (5 * r8);
  37061. c += (d7 >>> 13); d7 &= 0x1fff;
  37062. d8 = c;
  37063. d8 += h0 * r8;
  37064. d8 += h1 * r7;
  37065. d8 += h2 * r6;
  37066. d8 += h3 * r5;
  37067. d8 += h4 * r4;
  37068. c = (d8 >>> 13); d8 &= 0x1fff;
  37069. d8 += h5 * r3;
  37070. d8 += h6 * r2;
  37071. d8 += h7 * r1;
  37072. d8 += h8 * r0;
  37073. d8 += h9 * (5 * r9);
  37074. c += (d8 >>> 13); d8 &= 0x1fff;
  37075. d9 = c;
  37076. d9 += h0 * r9;
  37077. d9 += h1 * r8;
  37078. d9 += h2 * r7;
  37079. d9 += h3 * r6;
  37080. d9 += h4 * r5;
  37081. c = (d9 >>> 13); d9 &= 0x1fff;
  37082. d9 += h5 * r4;
  37083. d9 += h6 * r3;
  37084. d9 += h7 * r2;
  37085. d9 += h8 * r1;
  37086. d9 += h9 * r0;
  37087. c += (d9 >>> 13); d9 &= 0x1fff;
  37088. c = (((c << 2) + c)) | 0;
  37089. c = (c + d0) | 0;
  37090. d0 = c & 0x1fff;
  37091. c = (c >>> 13);
  37092. d1 += c;
  37093. h0 = d0;
  37094. h1 = d1;
  37095. h2 = d2;
  37096. h3 = d3;
  37097. h4 = d4;
  37098. h5 = d5;
  37099. h6 = d6;
  37100. h7 = d7;
  37101. h8 = d8;
  37102. h9 = d9;
  37103. mpos += 16;
  37104. bytes -= 16;
  37105. }
  37106. this.h[0] = h0;
  37107. this.h[1] = h1;
  37108. this.h[2] = h2;
  37109. this.h[3] = h3;
  37110. this.h[4] = h4;
  37111. this.h[5] = h5;
  37112. this.h[6] = h6;
  37113. this.h[7] = h7;
  37114. this.h[8] = h8;
  37115. this.h[9] = h9;
  37116. };
  37117. poly1305.prototype.finish = function(mac, macpos) {
  37118. var g = new Uint16Array(10);
  37119. var c, mask, f, i;
  37120. if (this.leftover) {
  37121. i = this.leftover;
  37122. this.buffer[i++] = 1;
  37123. for (; i < 16; i++) this.buffer[i] = 0;
  37124. this.fin = 1;
  37125. this.blocks(this.buffer, 0, 16);
  37126. }
  37127. c = this.h[1] >>> 13;
  37128. this.h[1] &= 0x1fff;
  37129. for (i = 2; i < 10; i++) {
  37130. this.h[i] += c;
  37131. c = this.h[i] >>> 13;
  37132. this.h[i] &= 0x1fff;
  37133. }
  37134. this.h[0] += (c * 5);
  37135. c = this.h[0] >>> 13;
  37136. this.h[0] &= 0x1fff;
  37137. this.h[1] += c;
  37138. c = this.h[1] >>> 13;
  37139. this.h[1] &= 0x1fff;
  37140. this.h[2] += c;
  37141. g[0] = this.h[0] + 5;
  37142. c = g[0] >>> 13;
  37143. g[0] &= 0x1fff;
  37144. for (i = 1; i < 10; i++) {
  37145. g[i] = this.h[i] + c;
  37146. c = g[i] >>> 13;
  37147. g[i] &= 0x1fff;
  37148. }
  37149. g[9] -= (1 << 13);
  37150. mask = (c ^ 1) - 1;
  37151. for (i = 0; i < 10; i++) g[i] &= mask;
  37152. mask = ~mask;
  37153. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37154. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37155. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37156. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37157. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37158. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37159. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37160. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37161. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37162. f = this.h[0] + this.pad[0];
  37163. this.h[0] = f & 0xffff;
  37164. for (i = 1; i < 8; i++) {
  37165. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37166. this.h[i] = f & 0xffff;
  37167. }
  37168. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37169. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37170. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37171. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37172. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37173. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37174. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37175. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37176. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37177. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37178. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37179. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37180. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37181. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37182. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37183. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37184. };
  37185. poly1305.prototype.update = function(m, mpos, bytes) {
  37186. var i, want;
  37187. if (this.leftover) {
  37188. want = (16 - this.leftover);
  37189. if (want > bytes)
  37190. want = bytes;
  37191. for (i = 0; i < want; i++)
  37192. this.buffer[this.leftover + i] = m[mpos+i];
  37193. bytes -= want;
  37194. mpos += want;
  37195. this.leftover += want;
  37196. if (this.leftover < 16)
  37197. return;
  37198. this.blocks(this.buffer, 0, 16);
  37199. this.leftover = 0;
  37200. }
  37201. if (bytes >= 16) {
  37202. want = bytes - (bytes % 16);
  37203. this.blocks(m, mpos, want);
  37204. mpos += want;
  37205. bytes -= want;
  37206. }
  37207. if (bytes) {
  37208. for (i = 0; i < bytes; i++)
  37209. this.buffer[this.leftover + i] = m[mpos+i];
  37210. this.leftover += bytes;
  37211. }
  37212. };
  37213. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37214. var s = new poly1305(k);
  37215. s.update(m, mpos, n);
  37216. s.finish(out, outpos);
  37217. return 0;
  37218. }
  37219. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37220. var x = new Uint8Array(16);
  37221. crypto_onetimeauth(x,0,m,mpos,n,k);
  37222. return crypto_verify_16(h,hpos,x,0);
  37223. }
  37224. function crypto_secretbox(c,m,d,n,k) {
  37225. var i;
  37226. if (d < 32) return -1;
  37227. crypto_stream_xor(c,0,m,0,d,n,k);
  37228. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37229. for (i = 0; i < 16; i++) c[i] = 0;
  37230. return 0;
  37231. }
  37232. function crypto_secretbox_open(m,c,d,n,k) {
  37233. var i;
  37234. var x = new Uint8Array(32);
  37235. if (d < 32) return -1;
  37236. crypto_stream(x,0,32,n,k);
  37237. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37238. crypto_stream_xor(m,0,c,0,d,n,k);
  37239. for (i = 0; i < 32; i++) m[i] = 0;
  37240. return 0;
  37241. }
  37242. function set25519(r, a) {
  37243. var i;
  37244. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37245. }
  37246. function car25519(o) {
  37247. var i, v, c = 1;
  37248. for (i = 0; i < 16; i++) {
  37249. v = o[i] + c + 65535;
  37250. c = Math.floor(v / 65536);
  37251. o[i] = v - c * 65536;
  37252. }
  37253. o[0] += c-1 + 37 * (c-1);
  37254. }
  37255. function sel25519(p, q, b) {
  37256. var t, c = ~(b-1);
  37257. for (var i = 0; i < 16; i++) {
  37258. t = c & (p[i] ^ q[i]);
  37259. p[i] ^= t;
  37260. q[i] ^= t;
  37261. }
  37262. }
  37263. function pack25519(o, n) {
  37264. var i, j, b;
  37265. var m = gf(), t = gf();
  37266. for (i = 0; i < 16; i++) t[i] = n[i];
  37267. car25519(t);
  37268. car25519(t);
  37269. car25519(t);
  37270. for (j = 0; j < 2; j++) {
  37271. m[0] = t[0] - 0xffed;
  37272. for (i = 1; i < 15; i++) {
  37273. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37274. m[i-1] &= 0xffff;
  37275. }
  37276. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37277. b = (m[15]>>16) & 1;
  37278. m[14] &= 0xffff;
  37279. sel25519(t, m, 1-b);
  37280. }
  37281. for (i = 0; i < 16; i++) {
  37282. o[2*i] = t[i] & 0xff;
  37283. o[2*i+1] = t[i]>>8;
  37284. }
  37285. }
  37286. function neq25519(a, b) {
  37287. var c = new Uint8Array(32), d = new Uint8Array(32);
  37288. pack25519(c, a);
  37289. pack25519(d, b);
  37290. return crypto_verify_32(c, 0, d, 0);
  37291. }
  37292. function par25519(a) {
  37293. var d = new Uint8Array(32);
  37294. pack25519(d, a);
  37295. return d[0] & 1;
  37296. }
  37297. function unpack25519(o, n) {
  37298. var i;
  37299. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37300. o[15] &= 0x7fff;
  37301. }
  37302. function A(o, a, b) {
  37303. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37304. }
  37305. function Z(o, a, b) {
  37306. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37307. }
  37308. function M(o, a, b) {
  37309. var v, c,
  37310. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37311. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37312. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37313. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37314. b0 = b[0],
  37315. b1 = b[1],
  37316. b2 = b[2],
  37317. b3 = b[3],
  37318. b4 = b[4],
  37319. b5 = b[5],
  37320. b6 = b[6],
  37321. b7 = b[7],
  37322. b8 = b[8],
  37323. b9 = b[9],
  37324. b10 = b[10],
  37325. b11 = b[11],
  37326. b12 = b[12],
  37327. b13 = b[13],
  37328. b14 = b[14],
  37329. b15 = b[15];
  37330. v = a[0];
  37331. t0 += v * b0;
  37332. t1 += v * b1;
  37333. t2 += v * b2;
  37334. t3 += v * b3;
  37335. t4 += v * b4;
  37336. t5 += v * b5;
  37337. t6 += v * b6;
  37338. t7 += v * b7;
  37339. t8 += v * b8;
  37340. t9 += v * b9;
  37341. t10 += v * b10;
  37342. t11 += v * b11;
  37343. t12 += v * b12;
  37344. t13 += v * b13;
  37345. t14 += v * b14;
  37346. t15 += v * b15;
  37347. v = a[1];
  37348. t1 += v * b0;
  37349. t2 += v * b1;
  37350. t3 += v * b2;
  37351. t4 += v * b3;
  37352. t5 += v * b4;
  37353. t6 += v * b5;
  37354. t7 += v * b6;
  37355. t8 += v * b7;
  37356. t9 += v * b8;
  37357. t10 += v * b9;
  37358. t11 += v * b10;
  37359. t12 += v * b11;
  37360. t13 += v * b12;
  37361. t14 += v * b13;
  37362. t15 += v * b14;
  37363. t16 += v * b15;
  37364. v = a[2];
  37365. t2 += v * b0;
  37366. t3 += v * b1;
  37367. t4 += v * b2;
  37368. t5 += v * b3;
  37369. t6 += v * b4;
  37370. t7 += v * b5;
  37371. t8 += v * b6;
  37372. t9 += v * b7;
  37373. t10 += v * b8;
  37374. t11 += v * b9;
  37375. t12 += v * b10;
  37376. t13 += v * b11;
  37377. t14 += v * b12;
  37378. t15 += v * b13;
  37379. t16 += v * b14;
  37380. t17 += v * b15;
  37381. v = a[3];
  37382. t3 += v * b0;
  37383. t4 += v * b1;
  37384. t5 += v * b2;
  37385. t6 += v * b3;
  37386. t7 += v * b4;
  37387. t8 += v * b5;
  37388. t9 += v * b6;
  37389. t10 += v * b7;
  37390. t11 += v * b8;
  37391. t12 += v * b9;
  37392. t13 += v * b10;
  37393. t14 += v * b11;
  37394. t15 += v * b12;
  37395. t16 += v * b13;
  37396. t17 += v * b14;
  37397. t18 += v * b15;
  37398. v = a[4];
  37399. t4 += v * b0;
  37400. t5 += v * b1;
  37401. t6 += v * b2;
  37402. t7 += v * b3;
  37403. t8 += v * b4;
  37404. t9 += v * b5;
  37405. t10 += v * b6;
  37406. t11 += v * b7;
  37407. t12 += v * b8;
  37408. t13 += v * b9;
  37409. t14 += v * b10;
  37410. t15 += v * b11;
  37411. t16 += v * b12;
  37412. t17 += v * b13;
  37413. t18 += v * b14;
  37414. t19 += v * b15;
  37415. v = a[5];
  37416. t5 += v * b0;
  37417. t6 += v * b1;
  37418. t7 += v * b2;
  37419. t8 += v * b3;
  37420. t9 += v * b4;
  37421. t10 += v * b5;
  37422. t11 += v * b6;
  37423. t12 += v * b7;
  37424. t13 += v * b8;
  37425. t14 += v * b9;
  37426. t15 += v * b10;
  37427. t16 += v * b11;
  37428. t17 += v * b12;
  37429. t18 += v * b13;
  37430. t19 += v * b14;
  37431. t20 += v * b15;
  37432. v = a[6];
  37433. t6 += v * b0;
  37434. t7 += v * b1;
  37435. t8 += v * b2;
  37436. t9 += v * b3;
  37437. t10 += v * b4;
  37438. t11 += v * b5;
  37439. t12 += v * b6;
  37440. t13 += v * b7;
  37441. t14 += v * b8;
  37442. t15 += v * b9;
  37443. t16 += v * b10;
  37444. t17 += v * b11;
  37445. t18 += v * b12;
  37446. t19 += v * b13;
  37447. t20 += v * b14;
  37448. t21 += v * b15;
  37449. v = a[7];
  37450. t7 += v * b0;
  37451. t8 += v * b1;
  37452. t9 += v * b2;
  37453. t10 += v * b3;
  37454. t11 += v * b4;
  37455. t12 += v * b5;
  37456. t13 += v * b6;
  37457. t14 += v * b7;
  37458. t15 += v * b8;
  37459. t16 += v * b9;
  37460. t17 += v * b10;
  37461. t18 += v * b11;
  37462. t19 += v * b12;
  37463. t20 += v * b13;
  37464. t21 += v * b14;
  37465. t22 += v * b15;
  37466. v = a[8];
  37467. t8 += v * b0;
  37468. t9 += v * b1;
  37469. t10 += v * b2;
  37470. t11 += v * b3;
  37471. t12 += v * b4;
  37472. t13 += v * b5;
  37473. t14 += v * b6;
  37474. t15 += v * b7;
  37475. t16 += v * b8;
  37476. t17 += v * b9;
  37477. t18 += v * b10;
  37478. t19 += v * b11;
  37479. t20 += v * b12;
  37480. t21 += v * b13;
  37481. t22 += v * b14;
  37482. t23 += v * b15;
  37483. v = a[9];
  37484. t9 += v * b0;
  37485. t10 += v * b1;
  37486. t11 += v * b2;
  37487. t12 += v * b3;
  37488. t13 += v * b4;
  37489. t14 += v * b5;
  37490. t15 += v * b6;
  37491. t16 += v * b7;
  37492. t17 += v * b8;
  37493. t18 += v * b9;
  37494. t19 += v * b10;
  37495. t20 += v * b11;
  37496. t21 += v * b12;
  37497. t22 += v * b13;
  37498. t23 += v * b14;
  37499. t24 += v * b15;
  37500. v = a[10];
  37501. t10 += v * b0;
  37502. t11 += v * b1;
  37503. t12 += v * b2;
  37504. t13 += v * b3;
  37505. t14 += v * b4;
  37506. t15 += v * b5;
  37507. t16 += v * b6;
  37508. t17 += v * b7;
  37509. t18 += v * b8;
  37510. t19 += v * b9;
  37511. t20 += v * b10;
  37512. t21 += v * b11;
  37513. t22 += v * b12;
  37514. t23 += v * b13;
  37515. t24 += v * b14;
  37516. t25 += v * b15;
  37517. v = a[11];
  37518. t11 += v * b0;
  37519. t12 += v * b1;
  37520. t13 += v * b2;
  37521. t14 += v * b3;
  37522. t15 += v * b4;
  37523. t16 += v * b5;
  37524. t17 += v * b6;
  37525. t18 += v * b7;
  37526. t19 += v * b8;
  37527. t20 += v * b9;
  37528. t21 += v * b10;
  37529. t22 += v * b11;
  37530. t23 += v * b12;
  37531. t24 += v * b13;
  37532. t25 += v * b14;
  37533. t26 += v * b15;
  37534. v = a[12];
  37535. t12 += v * b0;
  37536. t13 += v * b1;
  37537. t14 += v * b2;
  37538. t15 += v * b3;
  37539. t16 += v * b4;
  37540. t17 += v * b5;
  37541. t18 += v * b6;
  37542. t19 += v * b7;
  37543. t20 += v * b8;
  37544. t21 += v * b9;
  37545. t22 += v * b10;
  37546. t23 += v * b11;
  37547. t24 += v * b12;
  37548. t25 += v * b13;
  37549. t26 += v * b14;
  37550. t27 += v * b15;
  37551. v = a[13];
  37552. t13 += v * b0;
  37553. t14 += v * b1;
  37554. t15 += v * b2;
  37555. t16 += v * b3;
  37556. t17 += v * b4;
  37557. t18 += v * b5;
  37558. t19 += v * b6;
  37559. t20 += v * b7;
  37560. t21 += v * b8;
  37561. t22 += v * b9;
  37562. t23 += v * b10;
  37563. t24 += v * b11;
  37564. t25 += v * b12;
  37565. t26 += v * b13;
  37566. t27 += v * b14;
  37567. t28 += v * b15;
  37568. v = a[14];
  37569. t14 += v * b0;
  37570. t15 += v * b1;
  37571. t16 += v * b2;
  37572. t17 += v * b3;
  37573. t18 += v * b4;
  37574. t19 += v * b5;
  37575. t20 += v * b6;
  37576. t21 += v * b7;
  37577. t22 += v * b8;
  37578. t23 += v * b9;
  37579. t24 += v * b10;
  37580. t25 += v * b11;
  37581. t26 += v * b12;
  37582. t27 += v * b13;
  37583. t28 += v * b14;
  37584. t29 += v * b15;
  37585. v = a[15];
  37586. t15 += v * b0;
  37587. t16 += v * b1;
  37588. t17 += v * b2;
  37589. t18 += v * b3;
  37590. t19 += v * b4;
  37591. t20 += v * b5;
  37592. t21 += v * b6;
  37593. t22 += v * b7;
  37594. t23 += v * b8;
  37595. t24 += v * b9;
  37596. t25 += v * b10;
  37597. t26 += v * b11;
  37598. t27 += v * b12;
  37599. t28 += v * b13;
  37600. t29 += v * b14;
  37601. t30 += v * b15;
  37602. t0 += 38 * t16;
  37603. t1 += 38 * t17;
  37604. t2 += 38 * t18;
  37605. t3 += 38 * t19;
  37606. t4 += 38 * t20;
  37607. t5 += 38 * t21;
  37608. t6 += 38 * t22;
  37609. t7 += 38 * t23;
  37610. t8 += 38 * t24;
  37611. t9 += 38 * t25;
  37612. t10 += 38 * t26;
  37613. t11 += 38 * t27;
  37614. t12 += 38 * t28;
  37615. t13 += 38 * t29;
  37616. t14 += 38 * t30;
  37617. // t15 left as is
  37618. // first car
  37619. c = 1;
  37620. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37621. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37622. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37623. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37624. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37625. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37626. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37627. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37628. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37629. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37630. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37631. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37632. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37633. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37634. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37635. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37636. t0 += c-1 + 37 * (c-1);
  37637. // second car
  37638. c = 1;
  37639. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37640. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37641. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37642. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37643. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37644. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37645. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37646. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37647. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37648. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37649. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37650. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37651. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37652. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37653. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37654. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37655. t0 += c-1 + 37 * (c-1);
  37656. o[ 0] = t0;
  37657. o[ 1] = t1;
  37658. o[ 2] = t2;
  37659. o[ 3] = t3;
  37660. o[ 4] = t4;
  37661. o[ 5] = t5;
  37662. o[ 6] = t6;
  37663. o[ 7] = t7;
  37664. o[ 8] = t8;
  37665. o[ 9] = t9;
  37666. o[10] = t10;
  37667. o[11] = t11;
  37668. o[12] = t12;
  37669. o[13] = t13;
  37670. o[14] = t14;
  37671. o[15] = t15;
  37672. }
  37673. function S(o, a) {
  37674. M(o, a, a);
  37675. }
  37676. function inv25519(o, i) {
  37677. var c = gf();
  37678. var a;
  37679. for (a = 0; a < 16; a++) c[a] = i[a];
  37680. for (a = 253; a >= 0; a--) {
  37681. S(c, c);
  37682. if(a !== 2 && a !== 4) M(c, c, i);
  37683. }
  37684. for (a = 0; a < 16; a++) o[a] = c[a];
  37685. }
  37686. function pow2523(o, i) {
  37687. var c = gf();
  37688. var a;
  37689. for (a = 0; a < 16; a++) c[a] = i[a];
  37690. for (a = 250; a >= 0; a--) {
  37691. S(c, c);
  37692. if(a !== 1) M(c, c, i);
  37693. }
  37694. for (a = 0; a < 16; a++) o[a] = c[a];
  37695. }
  37696. function crypto_scalarmult(q, n, p) {
  37697. var z = new Uint8Array(32);
  37698. var x = new Float64Array(80), r, i;
  37699. var a = gf(), b = gf(), c = gf(),
  37700. d = gf(), e = gf(), f = gf();
  37701. for (i = 0; i < 31; i++) z[i] = n[i];
  37702. z[31]=(n[31]&127)|64;
  37703. z[0]&=248;
  37704. unpack25519(x,p);
  37705. for (i = 0; i < 16; i++) {
  37706. b[i]=x[i];
  37707. d[i]=a[i]=c[i]=0;
  37708. }
  37709. a[0]=d[0]=1;
  37710. for (i=254; i>=0; --i) {
  37711. r=(z[i>>>3]>>>(i&7))&1;
  37712. sel25519(a,b,r);
  37713. sel25519(c,d,r);
  37714. A(e,a,c);
  37715. Z(a,a,c);
  37716. A(c,b,d);
  37717. Z(b,b,d);
  37718. S(d,e);
  37719. S(f,a);
  37720. M(a,c,a);
  37721. M(c,b,e);
  37722. A(e,a,c);
  37723. Z(a,a,c);
  37724. S(b,a);
  37725. Z(c,d,f);
  37726. M(a,c,_121665);
  37727. A(a,a,d);
  37728. M(c,c,a);
  37729. M(a,d,f);
  37730. M(d,b,x);
  37731. S(b,e);
  37732. sel25519(a,b,r);
  37733. sel25519(c,d,r);
  37734. }
  37735. for (i = 0; i < 16; i++) {
  37736. x[i+16]=a[i];
  37737. x[i+32]=c[i];
  37738. x[i+48]=b[i];
  37739. x[i+64]=d[i];
  37740. }
  37741. var x32 = x.subarray(32);
  37742. var x16 = x.subarray(16);
  37743. inv25519(x32,x32);
  37744. M(x16,x16,x32);
  37745. pack25519(q,x16);
  37746. return 0;
  37747. }
  37748. function crypto_scalarmult_base(q, n) {
  37749. return crypto_scalarmult(q, n, _9);
  37750. }
  37751. function crypto_box_keypair(y, x) {
  37752. randombytes(x, 32);
  37753. return crypto_scalarmult_base(y, x);
  37754. }
  37755. function crypto_box_beforenm(k, y, x) {
  37756. var s = new Uint8Array(32);
  37757. crypto_scalarmult(s, x, y);
  37758. return crypto_core_hsalsa20(k, _0, s, sigma);
  37759. }
  37760. var crypto_box_afternm = crypto_secretbox;
  37761. var crypto_box_open_afternm = crypto_secretbox_open;
  37762. function crypto_box(c, m, d, n, y, x) {
  37763. var k = new Uint8Array(32);
  37764. crypto_box_beforenm(k, y, x);
  37765. return crypto_box_afternm(c, m, d, n, k);
  37766. }
  37767. function crypto_box_open(m, c, d, n, y, x) {
  37768. var k = new Uint8Array(32);
  37769. crypto_box_beforenm(k, y, x);
  37770. return crypto_box_open_afternm(m, c, d, n, k);
  37771. }
  37772. var K = [
  37773. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37774. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37775. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37776. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37777. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37778. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37779. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37780. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37781. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37782. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37783. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37784. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37785. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37786. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37787. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37788. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37789. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37790. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37791. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37792. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37793. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37794. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37795. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37796. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37797. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37798. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37799. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37800. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37801. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37802. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37803. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37804. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37805. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37806. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37807. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37808. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37809. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37810. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37811. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37812. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37813. ];
  37814. function crypto_hashblocks_hl(hh, hl, m, n) {
  37815. var wh = new Int32Array(16), wl = new Int32Array(16),
  37816. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37817. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37818. th, tl, i, j, h, l, a, b, c, d;
  37819. var ah0 = hh[0],
  37820. ah1 = hh[1],
  37821. ah2 = hh[2],
  37822. ah3 = hh[3],
  37823. ah4 = hh[4],
  37824. ah5 = hh[5],
  37825. ah6 = hh[6],
  37826. ah7 = hh[7],
  37827. al0 = hl[0],
  37828. al1 = hl[1],
  37829. al2 = hl[2],
  37830. al3 = hl[3],
  37831. al4 = hl[4],
  37832. al5 = hl[5],
  37833. al6 = hl[6],
  37834. al7 = hl[7];
  37835. var pos = 0;
  37836. while (n >= 128) {
  37837. for (i = 0; i < 16; i++) {
  37838. j = 8 * i + pos;
  37839. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37840. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37841. }
  37842. for (i = 0; i < 80; i++) {
  37843. bh0 = ah0;
  37844. bh1 = ah1;
  37845. bh2 = ah2;
  37846. bh3 = ah3;
  37847. bh4 = ah4;
  37848. bh5 = ah5;
  37849. bh6 = ah6;
  37850. bh7 = ah7;
  37851. bl0 = al0;
  37852. bl1 = al1;
  37853. bl2 = al2;
  37854. bl3 = al3;
  37855. bl4 = al4;
  37856. bl5 = al5;
  37857. bl6 = al6;
  37858. bl7 = al7;
  37859. // add
  37860. h = ah7;
  37861. l = al7;
  37862. a = l & 0xffff; b = l >>> 16;
  37863. c = h & 0xffff; d = h >>> 16;
  37864. // Sigma1
  37865. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37866. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37867. a += l & 0xffff; b += l >>> 16;
  37868. c += h & 0xffff; d += h >>> 16;
  37869. // Ch
  37870. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37871. l = (al4 & al5) ^ (~al4 & al6);
  37872. a += l & 0xffff; b += l >>> 16;
  37873. c += h & 0xffff; d += h >>> 16;
  37874. // K
  37875. h = K[i*2];
  37876. l = K[i*2+1];
  37877. a += l & 0xffff; b += l >>> 16;
  37878. c += h & 0xffff; d += h >>> 16;
  37879. // w
  37880. h = wh[i%16];
  37881. l = wl[i%16];
  37882. a += l & 0xffff; b += l >>> 16;
  37883. c += h & 0xffff; d += h >>> 16;
  37884. b += a >>> 16;
  37885. c += b >>> 16;
  37886. d += c >>> 16;
  37887. th = c & 0xffff | d << 16;
  37888. tl = a & 0xffff | b << 16;
  37889. // add
  37890. h = th;
  37891. l = tl;
  37892. a = l & 0xffff; b = l >>> 16;
  37893. c = h & 0xffff; d = h >>> 16;
  37894. // Sigma0
  37895. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37896. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37897. a += l & 0xffff; b += l >>> 16;
  37898. c += h & 0xffff; d += h >>> 16;
  37899. // Maj
  37900. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37901. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37902. a += l & 0xffff; b += l >>> 16;
  37903. c += h & 0xffff; d += h >>> 16;
  37904. b += a >>> 16;
  37905. c += b >>> 16;
  37906. d += c >>> 16;
  37907. bh7 = (c & 0xffff) | (d << 16);
  37908. bl7 = (a & 0xffff) | (b << 16);
  37909. // add
  37910. h = bh3;
  37911. l = bl3;
  37912. a = l & 0xffff; b = l >>> 16;
  37913. c = h & 0xffff; d = h >>> 16;
  37914. h = th;
  37915. l = tl;
  37916. a += l & 0xffff; b += l >>> 16;
  37917. c += h & 0xffff; d += h >>> 16;
  37918. b += a >>> 16;
  37919. c += b >>> 16;
  37920. d += c >>> 16;
  37921. bh3 = (c & 0xffff) | (d << 16);
  37922. bl3 = (a & 0xffff) | (b << 16);
  37923. ah1 = bh0;
  37924. ah2 = bh1;
  37925. ah3 = bh2;
  37926. ah4 = bh3;
  37927. ah5 = bh4;
  37928. ah6 = bh5;
  37929. ah7 = bh6;
  37930. ah0 = bh7;
  37931. al1 = bl0;
  37932. al2 = bl1;
  37933. al3 = bl2;
  37934. al4 = bl3;
  37935. al5 = bl4;
  37936. al6 = bl5;
  37937. al7 = bl6;
  37938. al0 = bl7;
  37939. if (i%16 === 15) {
  37940. for (j = 0; j < 16; j++) {
  37941. // add
  37942. h = wh[j];
  37943. l = wl[j];
  37944. a = l & 0xffff; b = l >>> 16;
  37945. c = h & 0xffff; d = h >>> 16;
  37946. h = wh[(j+9)%16];
  37947. l = wl[(j+9)%16];
  37948. a += l & 0xffff; b += l >>> 16;
  37949. c += h & 0xffff; d += h >>> 16;
  37950. // sigma0
  37951. th = wh[(j+1)%16];
  37952. tl = wl[(j+1)%16];
  37953. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37954. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37955. a += l & 0xffff; b += l >>> 16;
  37956. c += h & 0xffff; d += h >>> 16;
  37957. // sigma1
  37958. th = wh[(j+14)%16];
  37959. tl = wl[(j+14)%16];
  37960. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37961. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37962. a += l & 0xffff; b += l >>> 16;
  37963. c += h & 0xffff; d += h >>> 16;
  37964. b += a >>> 16;
  37965. c += b >>> 16;
  37966. d += c >>> 16;
  37967. wh[j] = (c & 0xffff) | (d << 16);
  37968. wl[j] = (a & 0xffff) | (b << 16);
  37969. }
  37970. }
  37971. }
  37972. // add
  37973. h = ah0;
  37974. l = al0;
  37975. a = l & 0xffff; b = l >>> 16;
  37976. c = h & 0xffff; d = h >>> 16;
  37977. h = hh[0];
  37978. l = hl[0];
  37979. a += l & 0xffff; b += l >>> 16;
  37980. c += h & 0xffff; d += h >>> 16;
  37981. b += a >>> 16;
  37982. c += b >>> 16;
  37983. d += c >>> 16;
  37984. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37985. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37986. h = ah1;
  37987. l = al1;
  37988. a = l & 0xffff; b = l >>> 16;
  37989. c = h & 0xffff; d = h >>> 16;
  37990. h = hh[1];
  37991. l = hl[1];
  37992. a += l & 0xffff; b += l >>> 16;
  37993. c += h & 0xffff; d += h >>> 16;
  37994. b += a >>> 16;
  37995. c += b >>> 16;
  37996. d += c >>> 16;
  37997. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37998. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37999. h = ah2;
  38000. l = al2;
  38001. a = l & 0xffff; b = l >>> 16;
  38002. c = h & 0xffff; d = h >>> 16;
  38003. h = hh[2];
  38004. l = hl[2];
  38005. a += l & 0xffff; b += l >>> 16;
  38006. c += h & 0xffff; d += h >>> 16;
  38007. b += a >>> 16;
  38008. c += b >>> 16;
  38009. d += c >>> 16;
  38010. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  38011. hl[2] = al2 = (a & 0xffff) | (b << 16);
  38012. h = ah3;
  38013. l = al3;
  38014. a = l & 0xffff; b = l >>> 16;
  38015. c = h & 0xffff; d = h >>> 16;
  38016. h = hh[3];
  38017. l = hl[3];
  38018. a += l & 0xffff; b += l >>> 16;
  38019. c += h & 0xffff; d += h >>> 16;
  38020. b += a >>> 16;
  38021. c += b >>> 16;
  38022. d += c >>> 16;
  38023. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  38024. hl[3] = al3 = (a & 0xffff) | (b << 16);
  38025. h = ah4;
  38026. l = al4;
  38027. a = l & 0xffff; b = l >>> 16;
  38028. c = h & 0xffff; d = h >>> 16;
  38029. h = hh[4];
  38030. l = hl[4];
  38031. a += l & 0xffff; b += l >>> 16;
  38032. c += h & 0xffff; d += h >>> 16;
  38033. b += a >>> 16;
  38034. c += b >>> 16;
  38035. d += c >>> 16;
  38036. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  38037. hl[4] = al4 = (a & 0xffff) | (b << 16);
  38038. h = ah5;
  38039. l = al5;
  38040. a = l & 0xffff; b = l >>> 16;
  38041. c = h & 0xffff; d = h >>> 16;
  38042. h = hh[5];
  38043. l = hl[5];
  38044. a += l & 0xffff; b += l >>> 16;
  38045. c += h & 0xffff; d += h >>> 16;
  38046. b += a >>> 16;
  38047. c += b >>> 16;
  38048. d += c >>> 16;
  38049. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  38050. hl[5] = al5 = (a & 0xffff) | (b << 16);
  38051. h = ah6;
  38052. l = al6;
  38053. a = l & 0xffff; b = l >>> 16;
  38054. c = h & 0xffff; d = h >>> 16;
  38055. h = hh[6];
  38056. l = hl[6];
  38057. a += l & 0xffff; b += l >>> 16;
  38058. c += h & 0xffff; d += h >>> 16;
  38059. b += a >>> 16;
  38060. c += b >>> 16;
  38061. d += c >>> 16;
  38062. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  38063. hl[6] = al6 = (a & 0xffff) | (b << 16);
  38064. h = ah7;
  38065. l = al7;
  38066. a = l & 0xffff; b = l >>> 16;
  38067. c = h & 0xffff; d = h >>> 16;
  38068. h = hh[7];
  38069. l = hl[7];
  38070. a += l & 0xffff; b += l >>> 16;
  38071. c += h & 0xffff; d += h >>> 16;
  38072. b += a >>> 16;
  38073. c += b >>> 16;
  38074. d += c >>> 16;
  38075. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  38076. hl[7] = al7 = (a & 0xffff) | (b << 16);
  38077. pos += 128;
  38078. n -= 128;
  38079. }
  38080. return n;
  38081. }
  38082. function crypto_hash(out, m, n) {
  38083. var hh = new Int32Array(8),
  38084. hl = new Int32Array(8),
  38085. x = new Uint8Array(256),
  38086. i, b = n;
  38087. hh[0] = 0x6a09e667;
  38088. hh[1] = 0xbb67ae85;
  38089. hh[2] = 0x3c6ef372;
  38090. hh[3] = 0xa54ff53a;
  38091. hh[4] = 0x510e527f;
  38092. hh[5] = 0x9b05688c;
  38093. hh[6] = 0x1f83d9ab;
  38094. hh[7] = 0x5be0cd19;
  38095. hl[0] = 0xf3bcc908;
  38096. hl[1] = 0x84caa73b;
  38097. hl[2] = 0xfe94f82b;
  38098. hl[3] = 0x5f1d36f1;
  38099. hl[4] = 0xade682d1;
  38100. hl[5] = 0x2b3e6c1f;
  38101. hl[6] = 0xfb41bd6b;
  38102. hl[7] = 0x137e2179;
  38103. crypto_hashblocks_hl(hh, hl, m, n);
  38104. n %= 128;
  38105. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  38106. x[n] = 128;
  38107. n = 256-128*(n<112?1:0);
  38108. x[n-9] = 0;
  38109. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38110. crypto_hashblocks_hl(hh, hl, x, n);
  38111. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38112. return 0;
  38113. }
  38114. function add(p, q) {
  38115. var a = gf(), b = gf(), c = gf(),
  38116. d = gf(), e = gf(), f = gf(),
  38117. g = gf(), h = gf(), t = gf();
  38118. Z(a, p[1], p[0]);
  38119. Z(t, q[1], q[0]);
  38120. M(a, a, t);
  38121. A(b, p[0], p[1]);
  38122. A(t, q[0], q[1]);
  38123. M(b, b, t);
  38124. M(c, p[3], q[3]);
  38125. M(c, c, D2);
  38126. M(d, p[2], q[2]);
  38127. A(d, d, d);
  38128. Z(e, b, a);
  38129. Z(f, d, c);
  38130. A(g, d, c);
  38131. A(h, b, a);
  38132. M(p[0], e, f);
  38133. M(p[1], h, g);
  38134. M(p[2], g, f);
  38135. M(p[3], e, h);
  38136. }
  38137. function cswap(p, q, b) {
  38138. var i;
  38139. for (i = 0; i < 4; i++) {
  38140. sel25519(p[i], q[i], b);
  38141. }
  38142. }
  38143. function pack(r, p) {
  38144. var tx = gf(), ty = gf(), zi = gf();
  38145. inv25519(zi, p[2]);
  38146. M(tx, p[0], zi);
  38147. M(ty, p[1], zi);
  38148. pack25519(r, ty);
  38149. r[31] ^= par25519(tx) << 7;
  38150. }
  38151. function scalarmult(p, q, s) {
  38152. var b, i;
  38153. set25519(p[0], gf0);
  38154. set25519(p[1], gf1);
  38155. set25519(p[2], gf1);
  38156. set25519(p[3], gf0);
  38157. for (i = 255; i >= 0; --i) {
  38158. b = (s[(i/8)|0] >> (i&7)) & 1;
  38159. cswap(p, q, b);
  38160. add(q, p);
  38161. add(p, p);
  38162. cswap(p, q, b);
  38163. }
  38164. }
  38165. function scalarbase(p, s) {
  38166. var q = [gf(), gf(), gf(), gf()];
  38167. set25519(q[0], X);
  38168. set25519(q[1], Y);
  38169. set25519(q[2], gf1);
  38170. M(q[3], X, Y);
  38171. scalarmult(p, q, s);
  38172. }
  38173. function crypto_sign_keypair(pk, sk, seeded) {
  38174. var d = new Uint8Array(64);
  38175. var p = [gf(), gf(), gf(), gf()];
  38176. var i;
  38177. if (!seeded) randombytes(sk, 32);
  38178. crypto_hash(d, sk, 32);
  38179. d[0] &= 248;
  38180. d[31] &= 127;
  38181. d[31] |= 64;
  38182. scalarbase(p, d);
  38183. pack(pk, p);
  38184. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38185. return 0;
  38186. }
  38187. 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]);
  38188. function modL(r, x) {
  38189. var carry, i, j, k;
  38190. for (i = 63; i >= 32; --i) {
  38191. carry = 0;
  38192. for (j = i - 32, k = i - 12; j < k; ++j) {
  38193. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38194. carry = (x[j] + 128) >> 8;
  38195. x[j] -= carry * 256;
  38196. }
  38197. x[j] += carry;
  38198. x[i] = 0;
  38199. }
  38200. carry = 0;
  38201. for (j = 0; j < 32; j++) {
  38202. x[j] += carry - (x[31] >> 4) * L[j];
  38203. carry = x[j] >> 8;
  38204. x[j] &= 255;
  38205. }
  38206. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38207. for (i = 0; i < 32; i++) {
  38208. x[i+1] += x[i] >> 8;
  38209. r[i] = x[i] & 255;
  38210. }
  38211. }
  38212. function reduce(r) {
  38213. var x = new Float64Array(64), i;
  38214. for (i = 0; i < 64; i++) x[i] = r[i];
  38215. for (i = 0; i < 64; i++) r[i] = 0;
  38216. modL(r, x);
  38217. }
  38218. // Note: difference from C - smlen returned, not passed as argument.
  38219. function crypto_sign(sm, m, n, sk) {
  38220. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38221. var i, j, x = new Float64Array(64);
  38222. var p = [gf(), gf(), gf(), gf()];
  38223. crypto_hash(d, sk, 32);
  38224. d[0] &= 248;
  38225. d[31] &= 127;
  38226. d[31] |= 64;
  38227. var smlen = n + 64;
  38228. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38229. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38230. crypto_hash(r, sm.subarray(32), n+32);
  38231. reduce(r);
  38232. scalarbase(p, r);
  38233. pack(sm, p);
  38234. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38235. crypto_hash(h, sm, n + 64);
  38236. reduce(h);
  38237. for (i = 0; i < 64; i++) x[i] = 0;
  38238. for (i = 0; i < 32; i++) x[i] = r[i];
  38239. for (i = 0; i < 32; i++) {
  38240. for (j = 0; j < 32; j++) {
  38241. x[i+j] += h[i] * d[j];
  38242. }
  38243. }
  38244. modL(sm.subarray(32), x);
  38245. return smlen;
  38246. }
  38247. function unpackneg(r, p) {
  38248. var t = gf(), chk = gf(), num = gf(),
  38249. den = gf(), den2 = gf(), den4 = gf(),
  38250. den6 = gf();
  38251. set25519(r[2], gf1);
  38252. unpack25519(r[1], p);
  38253. S(num, r[1]);
  38254. M(den, num, D);
  38255. Z(num, num, r[2]);
  38256. A(den, r[2], den);
  38257. S(den2, den);
  38258. S(den4, den2);
  38259. M(den6, den4, den2);
  38260. M(t, den6, num);
  38261. M(t, t, den);
  38262. pow2523(t, t);
  38263. M(t, t, num);
  38264. M(t, t, den);
  38265. M(t, t, den);
  38266. M(r[0], t, den);
  38267. S(chk, r[0]);
  38268. M(chk, chk, den);
  38269. if (neq25519(chk, num)) M(r[0], r[0], I);
  38270. S(chk, r[0]);
  38271. M(chk, chk, den);
  38272. if (neq25519(chk, num)) return -1;
  38273. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38274. M(r[3], r[0], r[1]);
  38275. return 0;
  38276. }
  38277. function crypto_sign_open(m, sm, n, pk) {
  38278. var i, mlen;
  38279. var t = new Uint8Array(32), h = new Uint8Array(64);
  38280. var p = [gf(), gf(), gf(), gf()],
  38281. q = [gf(), gf(), gf(), gf()];
  38282. mlen = -1;
  38283. if (n < 64) return -1;
  38284. if (unpackneg(q, pk)) return -1;
  38285. for (i = 0; i < n; i++) m[i] = sm[i];
  38286. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38287. crypto_hash(h, m, n);
  38288. reduce(h);
  38289. scalarmult(p, q, h);
  38290. scalarbase(q, sm.subarray(32));
  38291. add(p, q);
  38292. pack(t, p);
  38293. n -= 64;
  38294. if (crypto_verify_32(sm, 0, t, 0)) {
  38295. for (i = 0; i < n; i++) m[i] = 0;
  38296. return -1;
  38297. }
  38298. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38299. mlen = n;
  38300. return mlen;
  38301. }
  38302. var crypto_secretbox_KEYBYTES = 32,
  38303. crypto_secretbox_NONCEBYTES = 24,
  38304. crypto_secretbox_ZEROBYTES = 32,
  38305. crypto_secretbox_BOXZEROBYTES = 16,
  38306. crypto_scalarmult_BYTES = 32,
  38307. crypto_scalarmult_SCALARBYTES = 32,
  38308. crypto_box_PUBLICKEYBYTES = 32,
  38309. crypto_box_SECRETKEYBYTES = 32,
  38310. crypto_box_BEFORENMBYTES = 32,
  38311. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38312. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38313. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38314. crypto_sign_BYTES = 64,
  38315. crypto_sign_PUBLICKEYBYTES = 32,
  38316. crypto_sign_SECRETKEYBYTES = 64,
  38317. crypto_sign_SEEDBYTES = 32,
  38318. crypto_hash_BYTES = 64;
  38319. nacl.lowlevel = {
  38320. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38321. crypto_stream_xor: crypto_stream_xor,
  38322. crypto_stream: crypto_stream,
  38323. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38324. crypto_stream_salsa20: crypto_stream_salsa20,
  38325. crypto_onetimeauth: crypto_onetimeauth,
  38326. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38327. crypto_verify_16: crypto_verify_16,
  38328. crypto_verify_32: crypto_verify_32,
  38329. crypto_secretbox: crypto_secretbox,
  38330. crypto_secretbox_open: crypto_secretbox_open,
  38331. crypto_scalarmult: crypto_scalarmult,
  38332. crypto_scalarmult_base: crypto_scalarmult_base,
  38333. crypto_box_beforenm: crypto_box_beforenm,
  38334. crypto_box_afternm: crypto_box_afternm,
  38335. crypto_box: crypto_box,
  38336. crypto_box_open: crypto_box_open,
  38337. crypto_box_keypair: crypto_box_keypair,
  38338. crypto_hash: crypto_hash,
  38339. crypto_sign: crypto_sign,
  38340. crypto_sign_keypair: crypto_sign_keypair,
  38341. crypto_sign_open: crypto_sign_open,
  38342. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38343. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38344. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38345. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38346. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38347. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38348. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38349. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38350. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38351. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38352. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38353. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38354. crypto_sign_BYTES: crypto_sign_BYTES,
  38355. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38356. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38357. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38358. crypto_hash_BYTES: crypto_hash_BYTES
  38359. };
  38360. /* High-level API */
  38361. function checkLengths(k, n) {
  38362. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38363. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38364. }
  38365. function checkBoxLengths(pk, sk) {
  38366. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38367. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38368. }
  38369. function checkArrayTypes() {
  38370. for (var i = 0; i < arguments.length; i++) {
  38371. if (!(arguments[i] instanceof Uint8Array))
  38372. throw new TypeError('unexpected type, use Uint8Array');
  38373. }
  38374. }
  38375. function cleanup(arr) {
  38376. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38377. }
  38378. nacl.randomBytes = function(n) {
  38379. var b = new Uint8Array(n);
  38380. randombytes(b, n);
  38381. return b;
  38382. };
  38383. nacl.secretbox = function(msg, nonce, key) {
  38384. checkArrayTypes(msg, nonce, key);
  38385. checkLengths(key, nonce);
  38386. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38387. var c = new Uint8Array(m.length);
  38388. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38389. crypto_secretbox(c, m, m.length, nonce, key);
  38390. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38391. };
  38392. nacl.secretbox.open = function(box, nonce, key) {
  38393. checkArrayTypes(box, nonce, key);
  38394. checkLengths(key, nonce);
  38395. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38396. var m = new Uint8Array(c.length);
  38397. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38398. if (c.length < 32) return null;
  38399. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38400. return m.subarray(crypto_secretbox_ZEROBYTES);
  38401. };
  38402. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38403. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38404. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38405. nacl.scalarMult = function(n, p) {
  38406. checkArrayTypes(n, p);
  38407. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38408. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38409. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38410. crypto_scalarmult(q, n, p);
  38411. return q;
  38412. };
  38413. nacl.scalarMult.base = function(n) {
  38414. checkArrayTypes(n);
  38415. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38416. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38417. crypto_scalarmult_base(q, n);
  38418. return q;
  38419. };
  38420. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38421. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38422. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38423. var k = nacl.box.before(publicKey, secretKey);
  38424. return nacl.secretbox(msg, nonce, k);
  38425. };
  38426. nacl.box.before = function(publicKey, secretKey) {
  38427. checkArrayTypes(publicKey, secretKey);
  38428. checkBoxLengths(publicKey, secretKey);
  38429. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38430. crypto_box_beforenm(k, publicKey, secretKey);
  38431. return k;
  38432. };
  38433. nacl.box.after = nacl.secretbox;
  38434. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38435. var k = nacl.box.before(publicKey, secretKey);
  38436. return nacl.secretbox.open(msg, nonce, k);
  38437. };
  38438. nacl.box.open.after = nacl.secretbox.open;
  38439. nacl.box.keyPair = function() {
  38440. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38441. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38442. crypto_box_keypair(pk, sk);
  38443. return {publicKey: pk, secretKey: sk};
  38444. };
  38445. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38446. checkArrayTypes(secretKey);
  38447. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38448. throw new Error('bad secret key size');
  38449. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38450. crypto_scalarmult_base(pk, secretKey);
  38451. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38452. };
  38453. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38454. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38455. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38456. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38457. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38458. nacl.sign = function(msg, secretKey) {
  38459. checkArrayTypes(msg, secretKey);
  38460. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38461. throw new Error('bad secret key size');
  38462. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38463. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38464. return signedMsg;
  38465. };
  38466. nacl.sign.open = function(signedMsg, publicKey) {
  38467. checkArrayTypes(signedMsg, publicKey);
  38468. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38469. throw new Error('bad public key size');
  38470. var tmp = new Uint8Array(signedMsg.length);
  38471. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38472. if (mlen < 0) return null;
  38473. var m = new Uint8Array(mlen);
  38474. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38475. return m;
  38476. };
  38477. nacl.sign.detached = function(msg, secretKey) {
  38478. var signedMsg = nacl.sign(msg, secretKey);
  38479. var sig = new Uint8Array(crypto_sign_BYTES);
  38480. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38481. return sig;
  38482. };
  38483. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38484. checkArrayTypes(msg, sig, publicKey);
  38485. if (sig.length !== crypto_sign_BYTES)
  38486. throw new Error('bad signature size');
  38487. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38488. throw new Error('bad public key size');
  38489. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38490. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38491. var i;
  38492. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38493. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38494. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38495. };
  38496. nacl.sign.keyPair = function() {
  38497. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38498. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38499. crypto_sign_keypair(pk, sk);
  38500. return {publicKey: pk, secretKey: sk};
  38501. };
  38502. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38503. checkArrayTypes(secretKey);
  38504. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38505. throw new Error('bad secret key size');
  38506. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38507. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38508. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38509. };
  38510. nacl.sign.keyPair.fromSeed = function(seed) {
  38511. checkArrayTypes(seed);
  38512. if (seed.length !== crypto_sign_SEEDBYTES)
  38513. throw new Error('bad seed size');
  38514. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38515. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38516. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38517. crypto_sign_keypair(pk, sk, true);
  38518. return {publicKey: pk, secretKey: sk};
  38519. };
  38520. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38521. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38522. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38523. nacl.sign.signatureLength = crypto_sign_BYTES;
  38524. nacl.hash = function(msg) {
  38525. checkArrayTypes(msg);
  38526. var h = new Uint8Array(crypto_hash_BYTES);
  38527. crypto_hash(h, msg, msg.length);
  38528. return h;
  38529. };
  38530. nacl.hash.hashLength = crypto_hash_BYTES;
  38531. nacl.verify = function(x, y) {
  38532. checkArrayTypes(x, y);
  38533. // Zero length arguments are considered not equal.
  38534. if (x.length === 0 || y.length === 0) return false;
  38535. if (x.length !== y.length) return false;
  38536. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38537. };
  38538. nacl.setPRNG = function(fn) {
  38539. randombytes = fn;
  38540. };
  38541. (function() {
  38542. // Initialize PRNG if environment provides CSPRNG.
  38543. // If not, methods calling randombytes will throw.
  38544. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38545. if (crypto && crypto.getRandomValues) {
  38546. // Browsers.
  38547. var QUOTA = 65536;
  38548. nacl.setPRNG(function(x, n) {
  38549. var i, v = new Uint8Array(n);
  38550. for (i = 0; i < n; i += QUOTA) {
  38551. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38552. }
  38553. for (i = 0; i < n; i++) x[i] = v[i];
  38554. cleanup(v);
  38555. });
  38556. } else if (true) {
  38557. // Node.js.
  38558. crypto = __webpack_require__(3);
  38559. if (crypto && crypto.randomBytes) {
  38560. nacl.setPRNG(function(x, n) {
  38561. var i, v = crypto.randomBytes(n);
  38562. for (i = 0; i < n; i++) x[i] = v[i];
  38563. cleanup(v);
  38564. });
  38565. }
  38566. }
  38567. })();
  38568. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38569. /***/ }),
  38570. /* 1 */
  38571. /***/ (function(module, exports, __webpack_require__) {
  38572. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38573. // Public domain.
  38574. (function(root, f) {
  38575. 'use strict';
  38576. if ( true && module.exports) module.exports = f();
  38577. else if (root.nacl) root.nacl.util = f();
  38578. else {
  38579. root.nacl = {};
  38580. root.nacl.util = f();
  38581. }
  38582. }(this, function() {
  38583. 'use strict';
  38584. var util = {};
  38585. function validateBase64(s) {
  38586. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38587. throw new TypeError('invalid encoding');
  38588. }
  38589. }
  38590. util.decodeUTF8 = function(s) {
  38591. if (typeof s !== 'string') throw new TypeError('expected string');
  38592. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38593. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38594. return b;
  38595. };
  38596. util.encodeUTF8 = function(arr) {
  38597. var i, s = [];
  38598. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38599. return decodeURIComponent(escape(s.join('')));
  38600. };
  38601. if (typeof atob === 'undefined') {
  38602. // Node.js
  38603. if (typeof Buffer.from !== 'undefined') {
  38604. // Node v6 and later
  38605. util.encodeBase64 = function (arr) { // v6 and later
  38606. return Buffer.from(arr).toString('base64');
  38607. };
  38608. util.decodeBase64 = function (s) {
  38609. validateBase64(s);
  38610. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38611. };
  38612. } else {
  38613. // Node earlier than v6
  38614. util.encodeBase64 = function (arr) { // v6 and later
  38615. return (new Buffer(arr)).toString('base64');
  38616. };
  38617. util.decodeBase64 = function(s) {
  38618. validateBase64(s);
  38619. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38620. };
  38621. }
  38622. } else {
  38623. // Browsers
  38624. util.encodeBase64 = function(arr) {
  38625. var i, s = [], len = arr.length;
  38626. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38627. return btoa(s.join(''));
  38628. };
  38629. util.decodeBase64 = function(s) {
  38630. validateBase64(s);
  38631. var i, d = atob(s), b = new Uint8Array(d.length);
  38632. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38633. return b;
  38634. };
  38635. }
  38636. return util;
  38637. }));
  38638. /***/ }),
  38639. /* 2 */
  38640. /***/ (function(module, exports, __webpack_require__) {
  38641. // required so we don't have to do require('pusher').default etc.
  38642. module.exports = __webpack_require__(4).default;
  38643. /***/ }),
  38644. /* 3 */
  38645. /***/ (function(module, exports) {
  38646. /* (ignored) */
  38647. /***/ }),
  38648. /* 4 */
  38649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38650. "use strict";
  38651. __webpack_require__.r(__webpack_exports__);
  38652. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38653. var ScriptReceiverFactory = (function () {
  38654. function ScriptReceiverFactory(prefix, name) {
  38655. this.lastId = 0;
  38656. this.prefix = prefix;
  38657. this.name = name;
  38658. }
  38659. ScriptReceiverFactory.prototype.create = function (callback) {
  38660. this.lastId++;
  38661. var number = this.lastId;
  38662. var id = this.prefix + number;
  38663. var name = this.name + "[" + number + "]";
  38664. var called = false;
  38665. var callbackWrapper = function () {
  38666. if (!called) {
  38667. callback.apply(null, arguments);
  38668. called = true;
  38669. }
  38670. };
  38671. this[number] = callbackWrapper;
  38672. return { number: number, id: id, name: name, callback: callbackWrapper };
  38673. };
  38674. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38675. delete this[receiver.number];
  38676. };
  38677. return ScriptReceiverFactory;
  38678. }());
  38679. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38680. // CONCATENATED MODULE: ./src/core/defaults.ts
  38681. var Defaults = {
  38682. VERSION: "5.0.3",
  38683. PROTOCOL: 7,
  38684. host: 'ws.pusherapp.com',
  38685. ws_port: 80,
  38686. wss_port: 443,
  38687. ws_path: '',
  38688. sockjs_host: 'sockjs.pusher.com',
  38689. sockjs_http_port: 80,
  38690. sockjs_https_port: 443,
  38691. sockjs_path: '/pusher',
  38692. stats_host: 'stats.pusher.com',
  38693. channel_auth_endpoint: '/pusher/auth',
  38694. channel_auth_transport: 'ajax',
  38695. activity_timeout: 120000,
  38696. pong_timeout: 30000,
  38697. unavailable_timeout: 10000,
  38698. cdn_http: "http://js.pusher.com",
  38699. cdn_https: "https://js.pusher.com",
  38700. dependency_suffix: ""
  38701. };
  38702. /* harmony default export */ var defaults = (Defaults);
  38703. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38704. var dependency_loader_DependencyLoader = (function () {
  38705. function DependencyLoader(options) {
  38706. this.options = options;
  38707. this.receivers = options.receivers || ScriptReceivers;
  38708. this.loading = {};
  38709. }
  38710. DependencyLoader.prototype.load = function (name, options, callback) {
  38711. var self = this;
  38712. if (self.loading[name] && self.loading[name].length > 0) {
  38713. self.loading[name].push(callback);
  38714. }
  38715. else {
  38716. self.loading[name] = [callback];
  38717. var request = runtime.createScriptRequest(self.getPath(name, options));
  38718. var receiver = self.receivers.create(function (error) {
  38719. self.receivers.remove(receiver);
  38720. if (self.loading[name]) {
  38721. var callbacks = self.loading[name];
  38722. delete self.loading[name];
  38723. var successCallback = function (wasSuccessful) {
  38724. if (!wasSuccessful) {
  38725. request.cleanup();
  38726. }
  38727. };
  38728. for (var i = 0; i < callbacks.length; i++) {
  38729. callbacks[i](error, successCallback);
  38730. }
  38731. }
  38732. });
  38733. request.send(receiver);
  38734. }
  38735. };
  38736. DependencyLoader.prototype.getRoot = function (options) {
  38737. var cdn;
  38738. var protocol = runtime.getDocument().location.protocol;
  38739. if ((options && options.useTLS) || protocol === "https:") {
  38740. cdn = this.options.cdn_https;
  38741. }
  38742. else {
  38743. cdn = this.options.cdn_http;
  38744. }
  38745. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38746. };
  38747. DependencyLoader.prototype.getPath = function (name, options) {
  38748. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38749. };
  38750. ;
  38751. return DependencyLoader;
  38752. }());
  38753. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38754. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38755. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38756. var Dependencies = new dependency_loader({
  38757. cdn_http: defaults.cdn_http,
  38758. cdn_https: defaults.cdn_https,
  38759. version: defaults.VERSION,
  38760. suffix: defaults.dependency_suffix,
  38761. receivers: DependenciesReceivers
  38762. });
  38763. // CONCATENATED MODULE: ./src/core/base64.ts
  38764. function encode(s) {
  38765. return btoa(utob(s));
  38766. }
  38767. var fromCharCode = String.fromCharCode;
  38768. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38769. var b64tab = {};
  38770. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38771. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38772. }
  38773. var cb_utob = function (c) {
  38774. var cc = c.charCodeAt(0);
  38775. return cc < 0x80
  38776. ? c
  38777. : cc < 0x800
  38778. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38779. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38780. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38781. fromCharCode(0x80 | (cc & 0x3f));
  38782. };
  38783. var utob = function (u) {
  38784. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38785. };
  38786. var cb_encode = function (ccc) {
  38787. var padlen = [0, 2, 1][ccc.length % 3];
  38788. var ord = (ccc.charCodeAt(0) << 16) |
  38789. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38790. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38791. var chars = [
  38792. b64chars.charAt(ord >>> 18),
  38793. b64chars.charAt((ord >>> 12) & 63),
  38794. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38795. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38796. ];
  38797. return chars.join('');
  38798. };
  38799. var btoa = window.btoa ||
  38800. function (b) {
  38801. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38802. };
  38803. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38804. var Timer = (function () {
  38805. function Timer(set, clear, delay, callback) {
  38806. var _this = this;
  38807. this.clear = clear;
  38808. this.timer = set(function () {
  38809. if (_this.timer) {
  38810. _this.timer = callback(_this.timer);
  38811. }
  38812. }, delay);
  38813. }
  38814. Timer.prototype.isRunning = function () {
  38815. return this.timer !== null;
  38816. };
  38817. Timer.prototype.ensureAborted = function () {
  38818. if (this.timer) {
  38819. this.clear(this.timer);
  38820. this.timer = null;
  38821. }
  38822. };
  38823. return Timer;
  38824. }());
  38825. /* harmony default export */ var abstract_timer = (Timer);
  38826. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38827. var __extends = (undefined && undefined.__extends) || (function () {
  38828. var extendStatics = function (d, b) {
  38829. extendStatics = Object.setPrototypeOf ||
  38830. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38831. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38832. return extendStatics(d, b);
  38833. };
  38834. return function (d, b) {
  38835. extendStatics(d, b);
  38836. function __() { this.constructor = d; }
  38837. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38838. };
  38839. })();
  38840. function timers_clearTimeout(timer) {
  38841. window.clearTimeout(timer);
  38842. }
  38843. function timers_clearInterval(timer) {
  38844. window.clearInterval(timer);
  38845. }
  38846. var OneOffTimer = (function (_super) {
  38847. __extends(OneOffTimer, _super);
  38848. function OneOffTimer(delay, callback) {
  38849. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38850. callback();
  38851. return null;
  38852. }) || this;
  38853. }
  38854. return OneOffTimer;
  38855. }(abstract_timer));
  38856. var PeriodicTimer = (function (_super) {
  38857. __extends(PeriodicTimer, _super);
  38858. function PeriodicTimer(delay, callback) {
  38859. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38860. callback();
  38861. return timer;
  38862. }) || this;
  38863. }
  38864. return PeriodicTimer;
  38865. }(abstract_timer));
  38866. // CONCATENATED MODULE: ./src/core/util.ts
  38867. var Util = {
  38868. now: function () {
  38869. if (Date.now) {
  38870. return Date.now();
  38871. }
  38872. else {
  38873. return new Date().valueOf();
  38874. }
  38875. },
  38876. defer: function (callback) {
  38877. return new OneOffTimer(0, callback);
  38878. },
  38879. method: function (name) {
  38880. var args = [];
  38881. for (var _i = 1; _i < arguments.length; _i++) {
  38882. args[_i - 1] = arguments[_i];
  38883. }
  38884. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38885. return function (object) {
  38886. return object[name].apply(object, boundArguments.concat(arguments));
  38887. };
  38888. }
  38889. };
  38890. /* harmony default export */ var util = (Util);
  38891. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38892. function extend(target) {
  38893. var sources = [];
  38894. for (var _i = 1; _i < arguments.length; _i++) {
  38895. sources[_i - 1] = arguments[_i];
  38896. }
  38897. for (var i = 0; i < sources.length; i++) {
  38898. var extensions = sources[i];
  38899. for (var property in extensions) {
  38900. if (extensions[property] && extensions[property].constructor &&
  38901. extensions[property].constructor === Object) {
  38902. target[property] = extend(target[property] || {}, extensions[property]);
  38903. }
  38904. else {
  38905. target[property] = extensions[property];
  38906. }
  38907. }
  38908. }
  38909. return target;
  38910. }
  38911. function stringify() {
  38912. var m = ["Pusher"];
  38913. for (var i = 0; i < arguments.length; i++) {
  38914. if (typeof arguments[i] === "string") {
  38915. m.push(arguments[i]);
  38916. }
  38917. else {
  38918. m.push(safeJSONStringify(arguments[i]));
  38919. }
  38920. }
  38921. return m.join(" : ");
  38922. }
  38923. function arrayIndexOf(array, item) {
  38924. var nativeIndexOf = Array.prototype.indexOf;
  38925. if (array === null) {
  38926. return -1;
  38927. }
  38928. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38929. return array.indexOf(item);
  38930. }
  38931. for (var i = 0, l = array.length; i < l; i++) {
  38932. if (array[i] === item) {
  38933. return i;
  38934. }
  38935. }
  38936. return -1;
  38937. }
  38938. function objectApply(object, f) {
  38939. for (var key in object) {
  38940. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38941. f(object[key], key, object);
  38942. }
  38943. }
  38944. }
  38945. function keys(object) {
  38946. var keys = [];
  38947. objectApply(object, function (_, key) {
  38948. keys.push(key);
  38949. });
  38950. return keys;
  38951. }
  38952. function values(object) {
  38953. var values = [];
  38954. objectApply(object, function (value) {
  38955. values.push(value);
  38956. });
  38957. return values;
  38958. }
  38959. function apply(array, f, context) {
  38960. for (var i = 0; i < array.length; i++) {
  38961. f.call(context || window, array[i], i, array);
  38962. }
  38963. }
  38964. function map(array, f) {
  38965. var result = [];
  38966. for (var i = 0; i < array.length; i++) {
  38967. result.push(f(array[i], i, array, result));
  38968. }
  38969. return result;
  38970. }
  38971. function mapObject(object, f) {
  38972. var result = {};
  38973. objectApply(object, function (value, key) {
  38974. result[key] = f(value);
  38975. });
  38976. return result;
  38977. }
  38978. function filter(array, test) {
  38979. test = test || function (value) { return !!value; };
  38980. var result = [];
  38981. for (var i = 0; i < array.length; i++) {
  38982. if (test(array[i], i, array, result)) {
  38983. result.push(array[i]);
  38984. }
  38985. }
  38986. return result;
  38987. }
  38988. function filterObject(object, test) {
  38989. var result = {};
  38990. objectApply(object, function (value, key) {
  38991. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38992. result[key] = value;
  38993. }
  38994. });
  38995. return result;
  38996. }
  38997. function flatten(object) {
  38998. var result = [];
  38999. objectApply(object, function (value, key) {
  39000. result.push([key, value]);
  39001. });
  39002. return result;
  39003. }
  39004. function any(array, test) {
  39005. for (var i = 0; i < array.length; i++) {
  39006. if (test(array[i], i, array)) {
  39007. return true;
  39008. }
  39009. }
  39010. return false;
  39011. }
  39012. function collections_all(array, test) {
  39013. for (var i = 0; i < array.length; i++) {
  39014. if (!test(array[i], i, array)) {
  39015. return false;
  39016. }
  39017. }
  39018. return true;
  39019. }
  39020. function encodeParamsObject(data) {
  39021. return mapObject(data, function (value) {
  39022. if (typeof value === "object") {
  39023. value = safeJSONStringify(value);
  39024. }
  39025. return encodeURIComponent(encode(value.toString()));
  39026. });
  39027. }
  39028. function buildQueryString(data) {
  39029. var params = filterObject(data, function (value) {
  39030. return value !== undefined;
  39031. });
  39032. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  39033. return query;
  39034. }
  39035. function decycleObject(object) {
  39036. var objects = [], paths = [];
  39037. return (function derez(value, path) {
  39038. var i, name, nu;
  39039. switch (typeof value) {
  39040. case 'object':
  39041. if (!value) {
  39042. return null;
  39043. }
  39044. for (i = 0; i < objects.length; i += 1) {
  39045. if (objects[i] === value) {
  39046. return { $ref: paths[i] };
  39047. }
  39048. }
  39049. objects.push(value);
  39050. paths.push(path);
  39051. if (Object.prototype.toString.apply(value) === '[object Array]') {
  39052. nu = [];
  39053. for (i = 0; i < value.length; i += 1) {
  39054. nu[i] = derez(value[i], path + '[' + i + ']');
  39055. }
  39056. }
  39057. else {
  39058. nu = {};
  39059. for (name in value) {
  39060. if (Object.prototype.hasOwnProperty.call(value, name)) {
  39061. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  39062. }
  39063. }
  39064. }
  39065. return nu;
  39066. case 'number':
  39067. case 'string':
  39068. case 'boolean':
  39069. return value;
  39070. }
  39071. }(object, '$'));
  39072. }
  39073. function safeJSONStringify(source) {
  39074. try {
  39075. return JSON.stringify(source);
  39076. }
  39077. catch (e) {
  39078. return JSON.stringify(decycleObject(source));
  39079. }
  39080. }
  39081. // CONCATENATED MODULE: ./src/core/logger.ts
  39082. var logger_Logger = (function () {
  39083. function Logger() {
  39084. this.globalLog = function (message) {
  39085. if (window.console && window.console.log) {
  39086. window.console.log(message);
  39087. }
  39088. };
  39089. }
  39090. Logger.prototype.debug = function () {
  39091. var args = [];
  39092. for (var _i = 0; _i < arguments.length; _i++) {
  39093. args[_i] = arguments[_i];
  39094. }
  39095. this.log(this.globalLog, args);
  39096. };
  39097. Logger.prototype.warn = function () {
  39098. var args = [];
  39099. for (var _i = 0; _i < arguments.length; _i++) {
  39100. args[_i] = arguments[_i];
  39101. }
  39102. this.log(this.globalLogWarn, args);
  39103. };
  39104. Logger.prototype.error = function () {
  39105. var args = [];
  39106. for (var _i = 0; _i < arguments.length; _i++) {
  39107. args[_i] = arguments[_i];
  39108. }
  39109. this.log(this.globalLogError, args);
  39110. };
  39111. Logger.prototype.globalLogWarn = function (message) {
  39112. if (window.console && window.console.warn) {
  39113. window.console.warn(message);
  39114. }
  39115. else {
  39116. this.globalLog(message);
  39117. }
  39118. };
  39119. Logger.prototype.globalLogError = function (message) {
  39120. if (window.console && window.console.error) {
  39121. window.console.error(message);
  39122. }
  39123. else {
  39124. this.globalLogWarn(message);
  39125. }
  39126. };
  39127. Logger.prototype.log = function (defaultLoggingFunction) {
  39128. var args = [];
  39129. for (var _i = 1; _i < arguments.length; _i++) {
  39130. args[_i - 1] = arguments[_i];
  39131. }
  39132. var message = stringify.apply(this, arguments);
  39133. if (core_pusher.log) {
  39134. core_pusher.log(message);
  39135. }
  39136. else if (core_pusher.logToConsole) {
  39137. var log = defaultLoggingFunction.bind(this);
  39138. log(message);
  39139. }
  39140. };
  39141. return Logger;
  39142. }());
  39143. /* harmony default export */ var logger = (new logger_Logger());
  39144. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39145. var urlStore = {
  39146. baseUrl: "https://pusher.com",
  39147. urls: {
  39148. authenticationEndpoint: {
  39149. path: "/docs/authenticating_users",
  39150. },
  39151. javascriptQuickStart: {
  39152. path: "/docs/javascript_quick_start"
  39153. },
  39154. triggeringClientEvents: {
  39155. path: "/docs/client_api_guide/client_events#trigger-events"
  39156. }
  39157. }
  39158. };
  39159. var buildLogSuffix = function (key) {
  39160. var urlPrefix = "See:";
  39161. var urlObj = urlStore.urls[key];
  39162. if (!urlObj)
  39163. return "";
  39164. var url;
  39165. if (urlObj.fullUrl) {
  39166. url = urlObj.fullUrl;
  39167. }
  39168. else if (urlObj.path) {
  39169. url = urlStore.baseUrl + urlObj.path;
  39170. }
  39171. if (!url)
  39172. return "";
  39173. return urlPrefix + " " + url;
  39174. };
  39175. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39176. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39177. var ajax = function (context, socketId, callback) {
  39178. var self = this, xhr;
  39179. xhr = runtime.createXHR();
  39180. xhr.open("POST", self.options.authEndpoint, true);
  39181. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39182. for (var headerName in this.authOptions.headers) {
  39183. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39184. }
  39185. xhr.onreadystatechange = function () {
  39186. if (xhr.readyState === 4) {
  39187. if (xhr.status === 200) {
  39188. var data, parsed = false;
  39189. try {
  39190. data = JSON.parse(xhr.responseText);
  39191. parsed = true;
  39192. }
  39193. catch (e) {
  39194. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39195. }
  39196. if (parsed) {
  39197. callback(false, data);
  39198. }
  39199. }
  39200. else {
  39201. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39202. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39203. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39204. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39205. callback(true, xhr.status);
  39206. }
  39207. }
  39208. };
  39209. xhr.send(this.composeQuery(socketId));
  39210. return xhr;
  39211. };
  39212. /* harmony default export */ var xhr_auth = (ajax);
  39213. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39214. var jsonp = function (context, socketId, callback) {
  39215. if (this.authOptions.headers !== undefined) {
  39216. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39217. }
  39218. var callbackName = context.nextAuthCallbackID.toString();
  39219. context.nextAuthCallbackID++;
  39220. var document = context.getDocument();
  39221. var script = document.createElement("script");
  39222. context.auth_callbacks[callbackName] = function (data) {
  39223. callback(false, data);
  39224. };
  39225. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39226. script.src = this.options.authEndpoint +
  39227. '?callback=' +
  39228. encodeURIComponent(callback_name) +
  39229. '&' +
  39230. this.composeQuery(socketId);
  39231. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39232. head.insertBefore(script, head.firstChild);
  39233. };
  39234. /* harmony default export */ var jsonp_auth = (jsonp);
  39235. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39236. var ScriptRequest = (function () {
  39237. function ScriptRequest(src) {
  39238. this.src = src;
  39239. }
  39240. ScriptRequest.prototype.send = function (receiver) {
  39241. var self = this;
  39242. var errorString = "Error loading " + self.src;
  39243. self.script = document.createElement("script");
  39244. self.script.id = receiver.id;
  39245. self.script.src = self.src;
  39246. self.script.type = "text/javascript";
  39247. self.script.charset = "UTF-8";
  39248. if (self.script.addEventListener) {
  39249. self.script.onerror = function () {
  39250. receiver.callback(errorString);
  39251. };
  39252. self.script.onload = function () {
  39253. receiver.callback(null);
  39254. };
  39255. }
  39256. else {
  39257. self.script.onreadystatechange = function () {
  39258. if (self.script.readyState === 'loaded' ||
  39259. self.script.readyState === 'complete') {
  39260. receiver.callback(null);
  39261. }
  39262. };
  39263. }
  39264. if (self.script.async === undefined && document.attachEvent &&
  39265. /opera/i.test(navigator.userAgent)) {
  39266. self.errorScript = document.createElement("script");
  39267. self.errorScript.id = receiver.id + "_error";
  39268. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39269. self.script.async = self.errorScript.async = false;
  39270. }
  39271. else {
  39272. self.script.async = true;
  39273. }
  39274. var head = document.getElementsByTagName('head')[0];
  39275. head.insertBefore(self.script, head.firstChild);
  39276. if (self.errorScript) {
  39277. head.insertBefore(self.errorScript, self.script.nextSibling);
  39278. }
  39279. };
  39280. ScriptRequest.prototype.cleanup = function () {
  39281. if (this.script) {
  39282. this.script.onload = this.script.onerror = null;
  39283. this.script.onreadystatechange = null;
  39284. }
  39285. if (this.script && this.script.parentNode) {
  39286. this.script.parentNode.removeChild(this.script);
  39287. }
  39288. if (this.errorScript && this.errorScript.parentNode) {
  39289. this.errorScript.parentNode.removeChild(this.errorScript);
  39290. }
  39291. this.script = null;
  39292. this.errorScript = null;
  39293. };
  39294. return ScriptRequest;
  39295. }());
  39296. /* harmony default export */ var script_request = (ScriptRequest);
  39297. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39298. var jsonp_request_JSONPRequest = (function () {
  39299. function JSONPRequest(url, data) {
  39300. this.url = url;
  39301. this.data = data;
  39302. }
  39303. JSONPRequest.prototype.send = function (receiver) {
  39304. if (this.request) {
  39305. return;
  39306. }
  39307. var query = buildQueryString(this.data);
  39308. var url = this.url + "/" + receiver.number + "?" + query;
  39309. this.request = runtime.createScriptRequest(url);
  39310. this.request.send(receiver);
  39311. };
  39312. JSONPRequest.prototype.cleanup = function () {
  39313. if (this.request) {
  39314. this.request.cleanup();
  39315. }
  39316. };
  39317. return JSONPRequest;
  39318. }());
  39319. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39320. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39321. var getAgent = function (sender, useTLS) {
  39322. return function (data, callback) {
  39323. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39324. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39325. var request = runtime.createJSONPRequest(url, data);
  39326. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39327. ScriptReceivers.remove(receiver);
  39328. request.cleanup();
  39329. if (result && result.host) {
  39330. sender.host = result.host;
  39331. }
  39332. if (callback) {
  39333. callback(error, result);
  39334. }
  39335. });
  39336. request.send(receiver);
  39337. };
  39338. };
  39339. var jsonp_timeline_jsonp = {
  39340. name: 'jsonp',
  39341. getAgent: getAgent
  39342. };
  39343. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39344. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39345. function getGenericURL(baseScheme, params, path) {
  39346. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39347. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39348. return scheme + "://" + host + path;
  39349. }
  39350. function getGenericPath(key, queryString) {
  39351. var path = "/app/" + key;
  39352. var query = "?protocol=" + defaults.PROTOCOL +
  39353. "&client=js" +
  39354. "&version=" + defaults.VERSION +
  39355. (queryString ? ("&" + queryString) : "");
  39356. return path + query;
  39357. }
  39358. var ws = {
  39359. getInitial: function (key, params) {
  39360. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39361. return getGenericURL("ws", params, path);
  39362. }
  39363. };
  39364. var http = {
  39365. getInitial: function (key, params) {
  39366. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39367. return getGenericURL("http", params, path);
  39368. }
  39369. };
  39370. var sockjs = {
  39371. getInitial: function (key, params) {
  39372. return getGenericURL("http", params, params.httpPath || "/pusher");
  39373. },
  39374. getPath: function (key, params) {
  39375. return getGenericPath(key);
  39376. }
  39377. };
  39378. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39379. var callback_registry_CallbackRegistry = (function () {
  39380. function CallbackRegistry() {
  39381. this._callbacks = {};
  39382. }
  39383. CallbackRegistry.prototype.get = function (name) {
  39384. return this._callbacks[prefix(name)];
  39385. };
  39386. CallbackRegistry.prototype.add = function (name, callback, context) {
  39387. var prefixedEventName = prefix(name);
  39388. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39389. this._callbacks[prefixedEventName].push({
  39390. fn: callback,
  39391. context: context
  39392. });
  39393. };
  39394. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39395. if (!name && !callback && !context) {
  39396. this._callbacks = {};
  39397. return;
  39398. }
  39399. var names = name ? [prefix(name)] : keys(this._callbacks);
  39400. if (callback || context) {
  39401. this.removeCallback(names, callback, context);
  39402. }
  39403. else {
  39404. this.removeAllCallbacks(names);
  39405. }
  39406. };
  39407. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39408. apply(names, function (name) {
  39409. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39410. return (callback && callback !== binding.fn) ||
  39411. (context && context !== binding.context);
  39412. });
  39413. if (this._callbacks[name].length === 0) {
  39414. delete this._callbacks[name];
  39415. }
  39416. }, this);
  39417. };
  39418. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39419. apply(names, function (name) {
  39420. delete this._callbacks[name];
  39421. }, this);
  39422. };
  39423. return CallbackRegistry;
  39424. }());
  39425. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39426. function prefix(name) {
  39427. return "_" + name;
  39428. }
  39429. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39430. var dispatcher_Dispatcher = (function () {
  39431. function Dispatcher(failThrough) {
  39432. this.callbacks = new callback_registry();
  39433. this.global_callbacks = [];
  39434. this.failThrough = failThrough;
  39435. }
  39436. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39437. this.callbacks.add(eventName, callback, context);
  39438. return this;
  39439. };
  39440. Dispatcher.prototype.bind_global = function (callback) {
  39441. this.global_callbacks.push(callback);
  39442. return this;
  39443. };
  39444. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39445. this.callbacks.remove(eventName, callback, context);
  39446. return this;
  39447. };
  39448. Dispatcher.prototype.unbind_global = function (callback) {
  39449. if (!callback) {
  39450. this.global_callbacks = [];
  39451. return this;
  39452. }
  39453. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39454. return this;
  39455. };
  39456. Dispatcher.prototype.unbind_all = function () {
  39457. this.unbind();
  39458. this.unbind_global();
  39459. return this;
  39460. };
  39461. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39462. for (var i = 0; i < this.global_callbacks.length; i++) {
  39463. this.global_callbacks[i](eventName, data);
  39464. }
  39465. var callbacks = this.callbacks.get(eventName);
  39466. var args = [];
  39467. if (metadata) {
  39468. args.push(data, metadata);
  39469. }
  39470. else if (data) {
  39471. args.push(data);
  39472. }
  39473. if (callbacks && callbacks.length > 0) {
  39474. for (var i = 0; i < callbacks.length; i++) {
  39475. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39476. }
  39477. }
  39478. else if (this.failThrough) {
  39479. this.failThrough(eventName, data);
  39480. }
  39481. return this;
  39482. };
  39483. return Dispatcher;
  39484. }());
  39485. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39486. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39487. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39488. var extendStatics = function (d, b) {
  39489. extendStatics = Object.setPrototypeOf ||
  39490. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39491. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39492. return extendStatics(d, b);
  39493. };
  39494. return function (d, b) {
  39495. extendStatics(d, b);
  39496. function __() { this.constructor = d; }
  39497. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39498. };
  39499. })();
  39500. var transport_connection_TransportConnection = (function (_super) {
  39501. transport_connection_extends(TransportConnection, _super);
  39502. function TransportConnection(hooks, name, priority, key, options) {
  39503. var _this = _super.call(this) || this;
  39504. _this.initialize = runtime.transportConnectionInitializer;
  39505. _this.hooks = hooks;
  39506. _this.name = name;
  39507. _this.priority = priority;
  39508. _this.key = key;
  39509. _this.options = options;
  39510. _this.state = "new";
  39511. _this.timeline = options.timeline;
  39512. _this.activityTimeout = options.activityTimeout;
  39513. _this.id = _this.timeline.generateUniqueID();
  39514. return _this;
  39515. }
  39516. TransportConnection.prototype.handlesActivityChecks = function () {
  39517. return Boolean(this.hooks.handlesActivityChecks);
  39518. };
  39519. TransportConnection.prototype.supportsPing = function () {
  39520. return Boolean(this.hooks.supportsPing);
  39521. };
  39522. TransportConnection.prototype.connect = function () {
  39523. var _this = this;
  39524. if (this.socket || this.state !== "initialized") {
  39525. return false;
  39526. }
  39527. var url = this.hooks.urls.getInitial(this.key, this.options);
  39528. try {
  39529. this.socket = this.hooks.getSocket(url, this.options);
  39530. }
  39531. catch (e) {
  39532. util.defer(function () {
  39533. _this.onError(e);
  39534. _this.changeState("closed");
  39535. });
  39536. return false;
  39537. }
  39538. this.bindListeners();
  39539. logger.debug("Connecting", { transport: this.name, url: url });
  39540. this.changeState("connecting");
  39541. return true;
  39542. };
  39543. TransportConnection.prototype.close = function () {
  39544. if (this.socket) {
  39545. this.socket.close();
  39546. return true;
  39547. }
  39548. else {
  39549. return false;
  39550. }
  39551. };
  39552. TransportConnection.prototype.send = function (data) {
  39553. var _this = this;
  39554. if (this.state === "open") {
  39555. util.defer(function () {
  39556. if (_this.socket) {
  39557. _this.socket.send(data);
  39558. }
  39559. });
  39560. return true;
  39561. }
  39562. else {
  39563. return false;
  39564. }
  39565. };
  39566. TransportConnection.prototype.ping = function () {
  39567. if (this.state === "open" && this.supportsPing()) {
  39568. this.socket.ping();
  39569. }
  39570. };
  39571. TransportConnection.prototype.onOpen = function () {
  39572. if (this.hooks.beforeOpen) {
  39573. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39574. }
  39575. this.changeState("open");
  39576. this.socket.onopen = undefined;
  39577. };
  39578. TransportConnection.prototype.onError = function (error) {
  39579. this.emit("error", { type: 'WebSocketError', error: error });
  39580. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39581. };
  39582. TransportConnection.prototype.onClose = function (closeEvent) {
  39583. if (closeEvent) {
  39584. this.changeState("closed", {
  39585. code: closeEvent.code,
  39586. reason: closeEvent.reason,
  39587. wasClean: closeEvent.wasClean
  39588. });
  39589. }
  39590. else {
  39591. this.changeState("closed");
  39592. }
  39593. this.unbindListeners();
  39594. this.socket = undefined;
  39595. };
  39596. TransportConnection.prototype.onMessage = function (message) {
  39597. this.emit("message", message);
  39598. };
  39599. TransportConnection.prototype.onActivity = function () {
  39600. this.emit("activity");
  39601. };
  39602. TransportConnection.prototype.bindListeners = function () {
  39603. var _this = this;
  39604. this.socket.onopen = function () {
  39605. _this.onOpen();
  39606. };
  39607. this.socket.onerror = function (error) {
  39608. _this.onError(error);
  39609. };
  39610. this.socket.onclose = function (closeEvent) {
  39611. _this.onClose(closeEvent);
  39612. };
  39613. this.socket.onmessage = function (message) {
  39614. _this.onMessage(message);
  39615. };
  39616. if (this.supportsPing()) {
  39617. this.socket.onactivity = function () { _this.onActivity(); };
  39618. }
  39619. };
  39620. TransportConnection.prototype.unbindListeners = function () {
  39621. if (this.socket) {
  39622. this.socket.onopen = undefined;
  39623. this.socket.onerror = undefined;
  39624. this.socket.onclose = undefined;
  39625. this.socket.onmessage = undefined;
  39626. if (this.supportsPing()) {
  39627. this.socket.onactivity = undefined;
  39628. }
  39629. }
  39630. };
  39631. TransportConnection.prototype.changeState = function (state, params) {
  39632. this.state = state;
  39633. this.timeline.info(this.buildTimelineMessage({
  39634. state: state,
  39635. params: params
  39636. }));
  39637. this.emit(state, params);
  39638. };
  39639. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39640. return extend({ cid: this.id }, message);
  39641. };
  39642. return TransportConnection;
  39643. }(dispatcher));
  39644. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39645. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39646. var transport_Transport = (function () {
  39647. function Transport(hooks) {
  39648. this.hooks = hooks;
  39649. }
  39650. Transport.prototype.isSupported = function (environment) {
  39651. return this.hooks.isSupported(environment);
  39652. };
  39653. Transport.prototype.createConnection = function (name, priority, key, options) {
  39654. return new transport_connection(this.hooks, name, priority, key, options);
  39655. };
  39656. return Transport;
  39657. }());
  39658. /* harmony default export */ var transports_transport = (transport_Transport);
  39659. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39660. var WSTransport = new transports_transport({
  39661. urls: ws,
  39662. handlesActivityChecks: false,
  39663. supportsPing: false,
  39664. isInitialized: function () {
  39665. return Boolean(runtime.getWebSocketAPI());
  39666. },
  39667. isSupported: function () {
  39668. return Boolean(runtime.getWebSocketAPI());
  39669. },
  39670. getSocket: function (url) {
  39671. return runtime.createWebSocket(url);
  39672. }
  39673. });
  39674. var httpConfiguration = {
  39675. urls: http,
  39676. handlesActivityChecks: false,
  39677. supportsPing: true,
  39678. isInitialized: function () {
  39679. return true;
  39680. }
  39681. };
  39682. var streamingConfiguration = extend({ getSocket: function (url) {
  39683. return runtime.HTTPFactory.createStreamingSocket(url);
  39684. }
  39685. }, httpConfiguration);
  39686. var pollingConfiguration = extend({ getSocket: function (url) {
  39687. return runtime.HTTPFactory.createPollingSocket(url);
  39688. }
  39689. }, httpConfiguration);
  39690. var xhrConfiguration = {
  39691. isSupported: function () {
  39692. return runtime.isXHRSupported();
  39693. }
  39694. };
  39695. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39696. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39697. var Transports = {
  39698. ws: WSTransport,
  39699. xhr_streaming: XHRStreamingTransport,
  39700. xhr_polling: XHRPollingTransport
  39701. };
  39702. /* harmony default export */ var transports = (Transports);
  39703. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39704. var SockJSTransport = new transports_transport({
  39705. file: "sockjs",
  39706. urls: sockjs,
  39707. handlesActivityChecks: true,
  39708. supportsPing: false,
  39709. isSupported: function () {
  39710. return true;
  39711. },
  39712. isInitialized: function () {
  39713. return window.SockJS !== undefined;
  39714. },
  39715. getSocket: function (url, options) {
  39716. return new window.SockJS(url, null, {
  39717. js_path: Dependencies.getPath("sockjs", {
  39718. useTLS: options.useTLS
  39719. }),
  39720. ignore_null_origin: options.ignoreNullOrigin
  39721. });
  39722. },
  39723. beforeOpen: function (socket, path) {
  39724. socket.send(JSON.stringify({
  39725. path: path
  39726. }));
  39727. }
  39728. });
  39729. var xdrConfiguration = {
  39730. isSupported: function (environment) {
  39731. var yes = runtime.isXDRSupported(environment.useTLS);
  39732. return yes;
  39733. }
  39734. };
  39735. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39736. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39737. transports.xdr_streaming = XDRStreamingTransport;
  39738. transports.xdr_polling = XDRPollingTransport;
  39739. transports.sockjs = SockJSTransport;
  39740. /* harmony default export */ var transports_transports = (transports);
  39741. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39742. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39743. var extendStatics = function (d, b) {
  39744. extendStatics = Object.setPrototypeOf ||
  39745. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39746. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39747. return extendStatics(d, b);
  39748. };
  39749. return function (d, b) {
  39750. extendStatics(d, b);
  39751. function __() { this.constructor = d; }
  39752. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39753. };
  39754. })();
  39755. var NetInfo = (function (_super) {
  39756. net_info_extends(NetInfo, _super);
  39757. function NetInfo() {
  39758. var _this = _super.call(this) || this;
  39759. var self = _this;
  39760. if (window.addEventListener !== undefined) {
  39761. window.addEventListener("online", function () {
  39762. self.emit('online');
  39763. }, false);
  39764. window.addEventListener("offline", function () {
  39765. self.emit('offline');
  39766. }, false);
  39767. }
  39768. return _this;
  39769. }
  39770. NetInfo.prototype.isOnline = function () {
  39771. if (window.navigator.onLine === undefined) {
  39772. return true;
  39773. }
  39774. else {
  39775. return window.navigator.onLine;
  39776. }
  39777. };
  39778. return NetInfo;
  39779. }(dispatcher));
  39780. var net_info_Network = new NetInfo();
  39781. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39782. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39783. function AssistantToTheTransportManager(manager, transport, options) {
  39784. this.manager = manager;
  39785. this.transport = transport;
  39786. this.minPingDelay = options.minPingDelay;
  39787. this.maxPingDelay = options.maxPingDelay;
  39788. this.pingDelay = undefined;
  39789. }
  39790. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39791. var _this = this;
  39792. options = extend({}, options, {
  39793. activityTimeout: this.pingDelay
  39794. });
  39795. var connection = this.transport.createConnection(name, priority, key, options);
  39796. var openTimestamp = null;
  39797. var onOpen = function () {
  39798. connection.unbind("open", onOpen);
  39799. connection.bind("closed", onClosed);
  39800. openTimestamp = util.now();
  39801. };
  39802. var onClosed = function (closeEvent) {
  39803. connection.unbind("closed", onClosed);
  39804. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39805. _this.manager.reportDeath();
  39806. }
  39807. else if (!closeEvent.wasClean && openTimestamp) {
  39808. var lifespan = util.now() - openTimestamp;
  39809. if (lifespan < 2 * _this.maxPingDelay) {
  39810. _this.manager.reportDeath();
  39811. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39812. }
  39813. }
  39814. };
  39815. connection.bind("open", onOpen);
  39816. return connection;
  39817. };
  39818. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39819. return this.manager.isAlive() && this.transport.isSupported(environment);
  39820. };
  39821. return AssistantToTheTransportManager;
  39822. }());
  39823. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39824. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39825. var Protocol = {
  39826. decodeMessage: function (messageEvent) {
  39827. try {
  39828. var messageData = JSON.parse(messageEvent.data);
  39829. var pusherEventData = messageData.data;
  39830. if (typeof pusherEventData === 'string') {
  39831. try {
  39832. pusherEventData = JSON.parse(messageData.data);
  39833. }
  39834. catch (e) { }
  39835. }
  39836. var pusherEvent = {
  39837. event: messageData.event,
  39838. channel: messageData.channel,
  39839. data: pusherEventData,
  39840. };
  39841. if (messageData.user_id) {
  39842. pusherEvent.user_id = messageData.user_id;
  39843. }
  39844. return pusherEvent;
  39845. }
  39846. catch (e) {
  39847. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39848. }
  39849. },
  39850. encodeMessage: function (event) {
  39851. return JSON.stringify(event);
  39852. },
  39853. processHandshake: function (messageEvent) {
  39854. var message = Protocol.decodeMessage(messageEvent);
  39855. if (message.event === "pusher:connection_established") {
  39856. if (!message.data.activity_timeout) {
  39857. throw "No activity timeout specified in handshake";
  39858. }
  39859. return {
  39860. action: "connected",
  39861. id: message.data.socket_id,
  39862. activityTimeout: message.data.activity_timeout * 1000
  39863. };
  39864. }
  39865. else if (message.event === "pusher:error") {
  39866. return {
  39867. action: this.getCloseAction(message.data),
  39868. error: this.getCloseError(message.data)
  39869. };
  39870. }
  39871. else {
  39872. throw "Invalid handshake";
  39873. }
  39874. },
  39875. getCloseAction: function (closeEvent) {
  39876. if (closeEvent.code < 4000) {
  39877. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39878. return "backoff";
  39879. }
  39880. else {
  39881. return null;
  39882. }
  39883. }
  39884. else if (closeEvent.code === 4000) {
  39885. return "tls_only";
  39886. }
  39887. else if (closeEvent.code < 4100) {
  39888. return "refused";
  39889. }
  39890. else if (closeEvent.code < 4200) {
  39891. return "backoff";
  39892. }
  39893. else if (closeEvent.code < 4300) {
  39894. return "retry";
  39895. }
  39896. else {
  39897. return "refused";
  39898. }
  39899. },
  39900. getCloseError: function (closeEvent) {
  39901. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39902. return {
  39903. type: 'PusherError',
  39904. data: {
  39905. code: closeEvent.code,
  39906. message: closeEvent.reason || closeEvent.message
  39907. }
  39908. };
  39909. }
  39910. else {
  39911. return null;
  39912. }
  39913. }
  39914. };
  39915. /* harmony default export */ var protocol_protocol = (Protocol);
  39916. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39917. var connection_extends = (undefined && undefined.__extends) || (function () {
  39918. var extendStatics = function (d, b) {
  39919. extendStatics = Object.setPrototypeOf ||
  39920. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39921. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39922. return extendStatics(d, b);
  39923. };
  39924. return function (d, b) {
  39925. extendStatics(d, b);
  39926. function __() { this.constructor = d; }
  39927. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39928. };
  39929. })();
  39930. var connection_Connection = (function (_super) {
  39931. connection_extends(Connection, _super);
  39932. function Connection(id, transport) {
  39933. var _this = _super.call(this) || this;
  39934. _this.id = id;
  39935. _this.transport = transport;
  39936. _this.activityTimeout = transport.activityTimeout;
  39937. _this.bindListeners();
  39938. return _this;
  39939. }
  39940. Connection.prototype.handlesActivityChecks = function () {
  39941. return this.transport.handlesActivityChecks();
  39942. };
  39943. Connection.prototype.send = function (data) {
  39944. return this.transport.send(data);
  39945. };
  39946. Connection.prototype.send_event = function (name, data, channel) {
  39947. var event = { event: name, data: data };
  39948. if (channel) {
  39949. event.channel = channel;
  39950. }
  39951. logger.debug('Event sent', event);
  39952. return this.send(protocol_protocol.encodeMessage(event));
  39953. };
  39954. Connection.prototype.ping = function () {
  39955. if (this.transport.supportsPing()) {
  39956. this.transport.ping();
  39957. }
  39958. else {
  39959. this.send_event('pusher:ping', {});
  39960. }
  39961. };
  39962. Connection.prototype.close = function () {
  39963. this.transport.close();
  39964. };
  39965. Connection.prototype.bindListeners = function () {
  39966. var _this = this;
  39967. var listeners = {
  39968. message: function (messageEvent) {
  39969. var pusherEvent;
  39970. try {
  39971. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39972. }
  39973. catch (e) {
  39974. _this.emit('error', {
  39975. type: 'MessageParseError',
  39976. error: e,
  39977. data: messageEvent.data
  39978. });
  39979. }
  39980. if (pusherEvent !== undefined) {
  39981. logger.debug('Event recd', pusherEvent);
  39982. switch (pusherEvent.event) {
  39983. case 'pusher:error':
  39984. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39985. break;
  39986. case 'pusher:ping':
  39987. _this.emit("ping");
  39988. break;
  39989. case 'pusher:pong':
  39990. _this.emit("pong");
  39991. break;
  39992. }
  39993. _this.emit('message', pusherEvent);
  39994. }
  39995. },
  39996. activity: function () {
  39997. _this.emit("activity");
  39998. },
  39999. error: function (error) {
  40000. _this.emit("error", { type: "WebSocketError", error: error });
  40001. },
  40002. closed: function (closeEvent) {
  40003. unbindListeners();
  40004. if (closeEvent && closeEvent.code) {
  40005. _this.handleCloseEvent(closeEvent);
  40006. }
  40007. _this.transport = null;
  40008. _this.emit("closed");
  40009. }
  40010. };
  40011. var unbindListeners = function () {
  40012. objectApply(listeners, function (listener, event) {
  40013. _this.transport.unbind(event, listener);
  40014. });
  40015. };
  40016. objectApply(listeners, function (listener, event) {
  40017. _this.transport.bind(event, listener);
  40018. });
  40019. };
  40020. Connection.prototype.handleCloseEvent = function (closeEvent) {
  40021. var action = protocol_protocol.getCloseAction(closeEvent);
  40022. var error = protocol_protocol.getCloseError(closeEvent);
  40023. if (error) {
  40024. this.emit('error', error);
  40025. }
  40026. if (action) {
  40027. this.emit(action, { action: action, error: error });
  40028. }
  40029. };
  40030. return Connection;
  40031. }(dispatcher));
  40032. /* harmony default export */ var connection_connection = (connection_Connection);
  40033. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  40034. var handshake_Handshake = (function () {
  40035. function Handshake(transport, callback) {
  40036. this.transport = transport;
  40037. this.callback = callback;
  40038. this.bindListeners();
  40039. }
  40040. Handshake.prototype.close = function () {
  40041. this.unbindListeners();
  40042. this.transport.close();
  40043. };
  40044. Handshake.prototype.bindListeners = function () {
  40045. var _this = this;
  40046. this.onMessage = function (m) {
  40047. _this.unbindListeners();
  40048. var result;
  40049. try {
  40050. result = protocol_protocol.processHandshake(m);
  40051. }
  40052. catch (e) {
  40053. _this.finish("error", { error: e });
  40054. _this.transport.close();
  40055. return;
  40056. }
  40057. if (result.action === "connected") {
  40058. _this.finish("connected", {
  40059. connection: new connection_connection(result.id, _this.transport),
  40060. activityTimeout: result.activityTimeout
  40061. });
  40062. }
  40063. else {
  40064. _this.finish(result.action, { error: result.error });
  40065. _this.transport.close();
  40066. }
  40067. };
  40068. this.onClosed = function (closeEvent) {
  40069. _this.unbindListeners();
  40070. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  40071. var error = protocol_protocol.getCloseError(closeEvent);
  40072. _this.finish(action, { error: error });
  40073. };
  40074. this.transport.bind("message", this.onMessage);
  40075. this.transport.bind("closed", this.onClosed);
  40076. };
  40077. Handshake.prototype.unbindListeners = function () {
  40078. this.transport.unbind("message", this.onMessage);
  40079. this.transport.unbind("closed", this.onClosed);
  40080. };
  40081. Handshake.prototype.finish = function (action, params) {
  40082. this.callback(extend({ transport: this.transport, action: action }, params));
  40083. };
  40084. return Handshake;
  40085. }());
  40086. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  40087. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  40088. var pusher_authorizer_PusherAuthorizer = (function () {
  40089. function PusherAuthorizer(channel, options) {
  40090. this.channel = channel;
  40091. var authTransport = options.authTransport;
  40092. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  40093. throw "'" + authTransport + "' is not a recognized auth transport";
  40094. }
  40095. this.type = authTransport;
  40096. this.options = options;
  40097. this.authOptions = (options || {}).auth || {};
  40098. }
  40099. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  40100. var query = 'socket_id=' + encodeURIComponent(socketId) +
  40101. '&channel_name=' + encodeURIComponent(this.channel.name);
  40102. for (var i in this.authOptions.params) {
  40103. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  40104. }
  40105. return query;
  40106. };
  40107. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  40108. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  40109. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40110. };
  40111. return PusherAuthorizer;
  40112. }());
  40113. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40114. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40115. var timeline_sender_TimelineSender = (function () {
  40116. function TimelineSender(timeline, options) {
  40117. this.timeline = timeline;
  40118. this.options = options || {};
  40119. }
  40120. TimelineSender.prototype.send = function (useTLS, callback) {
  40121. if (this.timeline.isEmpty()) {
  40122. return;
  40123. }
  40124. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40125. };
  40126. return TimelineSender;
  40127. }());
  40128. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40129. // CONCATENATED MODULE: ./src/core/errors.ts
  40130. var errors_extends = (undefined && undefined.__extends) || (function () {
  40131. var extendStatics = function (d, b) {
  40132. extendStatics = Object.setPrototypeOf ||
  40133. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40134. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40135. return extendStatics(d, b);
  40136. };
  40137. return function (d, b) {
  40138. extendStatics(d, b);
  40139. function __() { this.constructor = d; }
  40140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40141. };
  40142. })();
  40143. var BadEventName = (function (_super) {
  40144. errors_extends(BadEventName, _super);
  40145. function BadEventName(msg) {
  40146. var _newTarget = this.constructor;
  40147. var _this = _super.call(this, msg) || this;
  40148. Object.setPrototypeOf(_this, _newTarget.prototype);
  40149. return _this;
  40150. }
  40151. return BadEventName;
  40152. }(Error));
  40153. var RequestTimedOut = (function (_super) {
  40154. errors_extends(RequestTimedOut, _super);
  40155. function RequestTimedOut(msg) {
  40156. var _newTarget = this.constructor;
  40157. var _this = _super.call(this, msg) || this;
  40158. Object.setPrototypeOf(_this, _newTarget.prototype);
  40159. return _this;
  40160. }
  40161. return RequestTimedOut;
  40162. }(Error));
  40163. var TransportPriorityTooLow = (function (_super) {
  40164. errors_extends(TransportPriorityTooLow, _super);
  40165. function TransportPriorityTooLow(msg) {
  40166. var _newTarget = this.constructor;
  40167. var _this = _super.call(this, msg) || this;
  40168. Object.setPrototypeOf(_this, _newTarget.prototype);
  40169. return _this;
  40170. }
  40171. return TransportPriorityTooLow;
  40172. }(Error));
  40173. var TransportClosed = (function (_super) {
  40174. errors_extends(TransportClosed, _super);
  40175. function TransportClosed(msg) {
  40176. var _newTarget = this.constructor;
  40177. var _this = _super.call(this, msg) || this;
  40178. Object.setPrototypeOf(_this, _newTarget.prototype);
  40179. return _this;
  40180. }
  40181. return TransportClosed;
  40182. }(Error));
  40183. var UnsupportedFeature = (function (_super) {
  40184. errors_extends(UnsupportedFeature, _super);
  40185. function UnsupportedFeature(msg) {
  40186. var _newTarget = this.constructor;
  40187. var _this = _super.call(this, msg) || this;
  40188. Object.setPrototypeOf(_this, _newTarget.prototype);
  40189. return _this;
  40190. }
  40191. return UnsupportedFeature;
  40192. }(Error));
  40193. var UnsupportedTransport = (function (_super) {
  40194. errors_extends(UnsupportedTransport, _super);
  40195. function UnsupportedTransport(msg) {
  40196. var _newTarget = this.constructor;
  40197. var _this = _super.call(this, msg) || this;
  40198. Object.setPrototypeOf(_this, _newTarget.prototype);
  40199. return _this;
  40200. }
  40201. return UnsupportedTransport;
  40202. }(Error));
  40203. var UnsupportedStrategy = (function (_super) {
  40204. errors_extends(UnsupportedStrategy, _super);
  40205. function UnsupportedStrategy(msg) {
  40206. var _newTarget = this.constructor;
  40207. var _this = _super.call(this, msg) || this;
  40208. Object.setPrototypeOf(_this, _newTarget.prototype);
  40209. return _this;
  40210. }
  40211. return UnsupportedStrategy;
  40212. }(Error));
  40213. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40214. var channel_extends = (undefined && undefined.__extends) || (function () {
  40215. var extendStatics = function (d, b) {
  40216. extendStatics = Object.setPrototypeOf ||
  40217. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40218. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40219. return extendStatics(d, b);
  40220. };
  40221. return function (d, b) {
  40222. extendStatics(d, b);
  40223. function __() { this.constructor = d; }
  40224. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40225. };
  40226. })();
  40227. var channel_Channel = (function (_super) {
  40228. channel_extends(Channel, _super);
  40229. function Channel(name, pusher) {
  40230. var _this = _super.call(this, function (event, data) {
  40231. logger.debug('No callbacks on ' + name + ' for ' + event);
  40232. }) || this;
  40233. _this.name = name;
  40234. _this.pusher = pusher;
  40235. _this.subscribed = false;
  40236. _this.subscriptionPending = false;
  40237. _this.subscriptionCancelled = false;
  40238. return _this;
  40239. }
  40240. Channel.prototype.authorize = function (socketId, callback) {
  40241. return callback(false, {});
  40242. };
  40243. Channel.prototype.trigger = function (event, data) {
  40244. if (event.indexOf("client-") !== 0) {
  40245. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40246. }
  40247. if (!this.subscribed) {
  40248. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40249. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40250. }
  40251. return this.pusher.send_event(event, data, this.name);
  40252. };
  40253. Channel.prototype.disconnect = function () {
  40254. this.subscribed = false;
  40255. this.subscriptionPending = false;
  40256. };
  40257. Channel.prototype.handleEvent = function (event) {
  40258. var eventName = event.event;
  40259. var data = event.data;
  40260. if (eventName === "pusher_internal:subscription_succeeded") {
  40261. this.handleSubscriptionSucceededEvent(event);
  40262. }
  40263. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40264. var metadata = {};
  40265. this.emit(eventName, data, metadata);
  40266. }
  40267. };
  40268. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40269. this.subscriptionPending = false;
  40270. this.subscribed = true;
  40271. if (this.subscriptionCancelled) {
  40272. this.pusher.unsubscribe(this.name);
  40273. }
  40274. else {
  40275. this.emit("pusher:subscription_succeeded", event.data);
  40276. }
  40277. };
  40278. Channel.prototype.subscribe = function () {
  40279. var _this = this;
  40280. if (this.subscribed) {
  40281. return;
  40282. }
  40283. this.subscriptionPending = true;
  40284. this.subscriptionCancelled = false;
  40285. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40286. if (error) {
  40287. logger.error(data);
  40288. _this.emit('pusher:subscription_error', data);
  40289. }
  40290. else {
  40291. _this.pusher.send_event('pusher:subscribe', {
  40292. auth: data.auth,
  40293. channel_data: data.channel_data,
  40294. channel: _this.name
  40295. });
  40296. }
  40297. });
  40298. };
  40299. Channel.prototype.unsubscribe = function () {
  40300. this.subscribed = false;
  40301. this.pusher.send_event('pusher:unsubscribe', {
  40302. channel: this.name
  40303. });
  40304. };
  40305. Channel.prototype.cancelSubscription = function () {
  40306. this.subscriptionCancelled = true;
  40307. };
  40308. Channel.prototype.reinstateSubscription = function () {
  40309. this.subscriptionCancelled = false;
  40310. };
  40311. return Channel;
  40312. }(dispatcher));
  40313. /* harmony default export */ var channels_channel = (channel_Channel);
  40314. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40315. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40316. var extendStatics = function (d, b) {
  40317. extendStatics = Object.setPrototypeOf ||
  40318. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40319. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40320. return extendStatics(d, b);
  40321. };
  40322. return function (d, b) {
  40323. extendStatics(d, b);
  40324. function __() { this.constructor = d; }
  40325. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40326. };
  40327. })();
  40328. var private_channel_PrivateChannel = (function (_super) {
  40329. private_channel_extends(PrivateChannel, _super);
  40330. function PrivateChannel() {
  40331. return _super !== null && _super.apply(this, arguments) || this;
  40332. }
  40333. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40334. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40335. return authorizer.authorize(socketId, callback);
  40336. };
  40337. return PrivateChannel;
  40338. }(channels_channel));
  40339. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40340. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40341. var members_Members = (function () {
  40342. function Members() {
  40343. this.reset();
  40344. }
  40345. Members.prototype.get = function (id) {
  40346. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40347. return {
  40348. id: id,
  40349. info: this.members[id]
  40350. };
  40351. }
  40352. else {
  40353. return null;
  40354. }
  40355. };
  40356. Members.prototype.each = function (callback) {
  40357. var _this = this;
  40358. objectApply(this.members, function (member, id) {
  40359. callback(_this.get(id));
  40360. });
  40361. };
  40362. Members.prototype.setMyID = function (id) {
  40363. this.myID = id;
  40364. };
  40365. Members.prototype.onSubscription = function (subscriptionData) {
  40366. this.members = subscriptionData.presence.hash;
  40367. this.count = subscriptionData.presence.count;
  40368. this.me = this.get(this.myID);
  40369. };
  40370. Members.prototype.addMember = function (memberData) {
  40371. if (this.get(memberData.user_id) === null) {
  40372. this.count++;
  40373. }
  40374. this.members[memberData.user_id] = memberData.user_info;
  40375. return this.get(memberData.user_id);
  40376. };
  40377. Members.prototype.removeMember = function (memberData) {
  40378. var member = this.get(memberData.user_id);
  40379. if (member) {
  40380. delete this.members[memberData.user_id];
  40381. this.count--;
  40382. }
  40383. return member;
  40384. };
  40385. Members.prototype.reset = function () {
  40386. this.members = {};
  40387. this.count = 0;
  40388. this.myID = null;
  40389. this.me = null;
  40390. };
  40391. return Members;
  40392. }());
  40393. /* harmony default export */ var members = (members_Members);
  40394. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40395. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40396. var extendStatics = function (d, b) {
  40397. extendStatics = Object.setPrototypeOf ||
  40398. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40399. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40400. return extendStatics(d, b);
  40401. };
  40402. return function (d, b) {
  40403. extendStatics(d, b);
  40404. function __() { this.constructor = d; }
  40405. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40406. };
  40407. })();
  40408. var presence_channel_PresenceChannel = (function (_super) {
  40409. presence_channel_extends(PresenceChannel, _super);
  40410. function PresenceChannel(name, pusher) {
  40411. var _this = _super.call(this, name, pusher) || this;
  40412. _this.members = new members();
  40413. return _this;
  40414. }
  40415. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40416. var _this = this;
  40417. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40418. if (!error) {
  40419. if (authData.channel_data === undefined) {
  40420. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40421. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40422. ("expected 'channel_data' field. " + suffix));
  40423. callback("Invalid auth response");
  40424. return;
  40425. }
  40426. var channelData = JSON.parse(authData.channel_data);
  40427. _this.members.setMyID(channelData.user_id);
  40428. }
  40429. callback(error, authData);
  40430. });
  40431. };
  40432. PresenceChannel.prototype.handleEvent = function (event) {
  40433. var eventName = event.event;
  40434. if (eventName.indexOf("pusher_internal:") === 0) {
  40435. this.handleInternalEvent(event);
  40436. }
  40437. else {
  40438. var data = event.data;
  40439. var metadata = {};
  40440. if (event.user_id) {
  40441. metadata.user_id = event.user_id;
  40442. }
  40443. this.emit(eventName, data, metadata);
  40444. }
  40445. };
  40446. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40447. var eventName = event.event;
  40448. var data = event.data;
  40449. switch (eventName) {
  40450. case "pusher_internal:subscription_succeeded":
  40451. this.handleSubscriptionSucceededEvent(event);
  40452. break;
  40453. case "pusher_internal:member_added":
  40454. var addedMember = this.members.addMember(data);
  40455. this.emit('pusher:member_added', addedMember);
  40456. break;
  40457. case "pusher_internal:member_removed":
  40458. var removedMember = this.members.removeMember(data);
  40459. if (removedMember) {
  40460. this.emit('pusher:member_removed', removedMember);
  40461. }
  40462. break;
  40463. }
  40464. };
  40465. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40466. this.subscriptionPending = false;
  40467. this.subscribed = true;
  40468. if (this.subscriptionCancelled) {
  40469. this.pusher.unsubscribe(this.name);
  40470. }
  40471. else {
  40472. this.members.onSubscription(event.data);
  40473. this.emit("pusher:subscription_succeeded", this.members);
  40474. }
  40475. };
  40476. PresenceChannel.prototype.disconnect = function () {
  40477. this.members.reset();
  40478. _super.prototype.disconnect.call(this);
  40479. };
  40480. return PresenceChannel;
  40481. }(private_channel));
  40482. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40483. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40484. var nacl_fast = __webpack_require__(0);
  40485. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40486. var nacl_util = __webpack_require__(1);
  40487. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40488. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40489. var extendStatics = function (d, b) {
  40490. extendStatics = Object.setPrototypeOf ||
  40491. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40492. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40493. return extendStatics(d, b);
  40494. };
  40495. return function (d, b) {
  40496. extendStatics(d, b);
  40497. function __() { this.constructor = d; }
  40498. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40499. };
  40500. })();
  40501. var encrypted_channel_EncryptedChannel = (function (_super) {
  40502. encrypted_channel_extends(EncryptedChannel, _super);
  40503. function EncryptedChannel() {
  40504. var _this = _super !== null && _super.apply(this, arguments) || this;
  40505. _this.key = null;
  40506. return _this;
  40507. }
  40508. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40509. var _this = this;
  40510. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40511. if (error) {
  40512. callback(true, authData);
  40513. return;
  40514. }
  40515. var sharedSecret = authData["shared_secret"];
  40516. if (!sharedSecret) {
  40517. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40518. callback(true, errorMsg);
  40519. return;
  40520. }
  40521. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40522. delete authData["shared_secret"];
  40523. callback(false, authData);
  40524. });
  40525. };
  40526. EncryptedChannel.prototype.trigger = function (event, data) {
  40527. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40528. };
  40529. EncryptedChannel.prototype.handleEvent = function (event) {
  40530. var eventName = event.event;
  40531. var data = event.data;
  40532. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40533. _super.prototype.handleEvent.call(this, event);
  40534. return;
  40535. }
  40536. this.handleEncryptedEvent(eventName, data);
  40537. };
  40538. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40539. var _this = this;
  40540. if (!this.key) {
  40541. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40542. return;
  40543. }
  40544. if (!data.ciphertext || !data.nonce) {
  40545. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40546. return;
  40547. }
  40548. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40549. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40550. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40551. return;
  40552. }
  40553. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40554. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40555. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40556. return;
  40557. }
  40558. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40559. if (bytes === null) {
  40560. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40561. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40562. if (error) {
  40563. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40564. return;
  40565. }
  40566. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40567. if (bytes === null) {
  40568. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40569. return;
  40570. }
  40571. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40572. return;
  40573. });
  40574. return;
  40575. }
  40576. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40577. };
  40578. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40579. try {
  40580. this.emit(eventName, JSON.parse(data));
  40581. }
  40582. catch (e) {
  40583. this.emit(eventName, data);
  40584. }
  40585. return this;
  40586. };
  40587. return EncryptedChannel;
  40588. }(private_channel));
  40589. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40590. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40591. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40592. var extendStatics = function (d, b) {
  40593. extendStatics = Object.setPrototypeOf ||
  40594. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40595. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40596. return extendStatics(d, b);
  40597. };
  40598. return function (d, b) {
  40599. extendStatics(d, b);
  40600. function __() { this.constructor = d; }
  40601. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40602. };
  40603. })();
  40604. var connection_manager_ConnectionManager = (function (_super) {
  40605. connection_manager_extends(ConnectionManager, _super);
  40606. function ConnectionManager(key, options) {
  40607. var _this = _super.call(this) || this;
  40608. _this.key = key;
  40609. _this.options = options || {};
  40610. _this.state = "initialized";
  40611. _this.connection = null;
  40612. _this.usingTLS = !!options.useTLS;
  40613. _this.timeline = _this.options.timeline;
  40614. _this.errorCallbacks = _this.buildErrorCallbacks();
  40615. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40616. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40617. var Network = runtime.getNetwork();
  40618. Network.bind("online", function () {
  40619. _this.timeline.info({ netinfo: "online" });
  40620. if (_this.state === "connecting" || _this.state === "unavailable") {
  40621. _this.retryIn(0);
  40622. }
  40623. });
  40624. Network.bind("offline", function () {
  40625. _this.timeline.info({ netinfo: "offline" });
  40626. if (_this.connection) {
  40627. _this.sendActivityCheck();
  40628. }
  40629. });
  40630. _this.updateStrategy();
  40631. return _this;
  40632. }
  40633. ConnectionManager.prototype.connect = function () {
  40634. if (this.connection || this.runner) {
  40635. return;
  40636. }
  40637. if (!this.strategy.isSupported()) {
  40638. this.updateState("failed");
  40639. return;
  40640. }
  40641. this.updateState("connecting");
  40642. this.startConnecting();
  40643. this.setUnavailableTimer();
  40644. };
  40645. ;
  40646. ConnectionManager.prototype.send = function (data) {
  40647. if (this.connection) {
  40648. return this.connection.send(data);
  40649. }
  40650. else {
  40651. return false;
  40652. }
  40653. };
  40654. ;
  40655. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40656. if (this.connection) {
  40657. return this.connection.send_event(name, data, channel);
  40658. }
  40659. else {
  40660. return false;
  40661. }
  40662. };
  40663. ;
  40664. ConnectionManager.prototype.disconnect = function () {
  40665. this.disconnectInternally();
  40666. this.updateState("disconnected");
  40667. };
  40668. ;
  40669. ConnectionManager.prototype.isUsingTLS = function () {
  40670. return this.usingTLS;
  40671. };
  40672. ;
  40673. ConnectionManager.prototype.startConnecting = function () {
  40674. var _this = this;
  40675. var callback = function (error, handshake) {
  40676. if (error) {
  40677. _this.runner = _this.strategy.connect(0, callback);
  40678. }
  40679. else {
  40680. if (handshake.action === "error") {
  40681. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40682. _this.timeline.error({ handshakeError: handshake.error });
  40683. }
  40684. else {
  40685. _this.abortConnecting();
  40686. _this.handshakeCallbacks[handshake.action](handshake);
  40687. }
  40688. }
  40689. };
  40690. this.runner = this.strategy.connect(0, callback);
  40691. };
  40692. ;
  40693. ConnectionManager.prototype.abortConnecting = function () {
  40694. if (this.runner) {
  40695. this.runner.abort();
  40696. this.runner = null;
  40697. }
  40698. };
  40699. ;
  40700. ConnectionManager.prototype.disconnectInternally = function () {
  40701. this.abortConnecting();
  40702. this.clearRetryTimer();
  40703. this.clearUnavailableTimer();
  40704. if (this.connection) {
  40705. var connection = this.abandonConnection();
  40706. connection.close();
  40707. }
  40708. };
  40709. ;
  40710. ConnectionManager.prototype.updateStrategy = function () {
  40711. this.strategy = this.options.getStrategy({
  40712. key: this.key,
  40713. timeline: this.timeline,
  40714. useTLS: this.usingTLS
  40715. });
  40716. };
  40717. ;
  40718. ConnectionManager.prototype.retryIn = function (delay) {
  40719. var _this = this;
  40720. this.timeline.info({ action: "retry", delay: delay });
  40721. if (delay > 0) {
  40722. this.emit("connecting_in", Math.round(delay / 1000));
  40723. }
  40724. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40725. _this.disconnectInternally();
  40726. _this.connect();
  40727. });
  40728. };
  40729. ;
  40730. ConnectionManager.prototype.clearRetryTimer = function () {
  40731. if (this.retryTimer) {
  40732. this.retryTimer.ensureAborted();
  40733. this.retryTimer = null;
  40734. }
  40735. };
  40736. ;
  40737. ConnectionManager.prototype.setUnavailableTimer = function () {
  40738. var _this = this;
  40739. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40740. _this.updateState("unavailable");
  40741. });
  40742. };
  40743. ;
  40744. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40745. if (this.unavailableTimer) {
  40746. this.unavailableTimer.ensureAborted();
  40747. }
  40748. };
  40749. ;
  40750. ConnectionManager.prototype.sendActivityCheck = function () {
  40751. var _this = this;
  40752. this.stopActivityCheck();
  40753. this.connection.ping();
  40754. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40755. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40756. _this.retryIn(0);
  40757. });
  40758. };
  40759. ;
  40760. ConnectionManager.prototype.resetActivityCheck = function () {
  40761. var _this = this;
  40762. this.stopActivityCheck();
  40763. if (this.connection && !this.connection.handlesActivityChecks()) {
  40764. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40765. _this.sendActivityCheck();
  40766. });
  40767. }
  40768. };
  40769. ;
  40770. ConnectionManager.prototype.stopActivityCheck = function () {
  40771. if (this.activityTimer) {
  40772. this.activityTimer.ensureAborted();
  40773. }
  40774. };
  40775. ;
  40776. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40777. var _this = this;
  40778. return extend({}, errorCallbacks, {
  40779. message: function (message) {
  40780. _this.resetActivityCheck();
  40781. _this.emit('message', message);
  40782. },
  40783. ping: function () {
  40784. _this.send_event('pusher:pong', {});
  40785. },
  40786. activity: function () {
  40787. _this.resetActivityCheck();
  40788. },
  40789. error: function (error) {
  40790. _this.emit("error", { type: "WebSocketError", error: error });
  40791. },
  40792. closed: function () {
  40793. _this.abandonConnection();
  40794. if (_this.shouldRetry()) {
  40795. _this.retryIn(1000);
  40796. }
  40797. }
  40798. });
  40799. };
  40800. ;
  40801. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40802. var _this = this;
  40803. return extend({}, errorCallbacks, {
  40804. connected: function (handshake) {
  40805. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40806. _this.clearUnavailableTimer();
  40807. _this.setConnection(handshake.connection);
  40808. _this.socket_id = _this.connection.id;
  40809. _this.updateState("connected", { socket_id: _this.socket_id });
  40810. }
  40811. });
  40812. };
  40813. ;
  40814. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40815. var _this = this;
  40816. var withErrorEmitted = function (callback) {
  40817. return function (result) {
  40818. if (result.error) {
  40819. _this.emit("error", { type: "WebSocketError", error: result.error });
  40820. }
  40821. callback(result);
  40822. };
  40823. };
  40824. return {
  40825. tls_only: withErrorEmitted(function () {
  40826. _this.usingTLS = true;
  40827. _this.updateStrategy();
  40828. _this.retryIn(0);
  40829. }),
  40830. refused: withErrorEmitted(function () {
  40831. _this.disconnect();
  40832. }),
  40833. backoff: withErrorEmitted(function () {
  40834. _this.retryIn(1000);
  40835. }),
  40836. retry: withErrorEmitted(function () {
  40837. _this.retryIn(0);
  40838. })
  40839. };
  40840. };
  40841. ;
  40842. ConnectionManager.prototype.setConnection = function (connection) {
  40843. this.connection = connection;
  40844. for (var event in this.connectionCallbacks) {
  40845. this.connection.bind(event, this.connectionCallbacks[event]);
  40846. }
  40847. this.resetActivityCheck();
  40848. };
  40849. ;
  40850. ConnectionManager.prototype.abandonConnection = function () {
  40851. if (!this.connection) {
  40852. return;
  40853. }
  40854. this.stopActivityCheck();
  40855. for (var event in this.connectionCallbacks) {
  40856. this.connection.unbind(event, this.connectionCallbacks[event]);
  40857. }
  40858. var connection = this.connection;
  40859. this.connection = null;
  40860. return connection;
  40861. };
  40862. ConnectionManager.prototype.updateState = function (newState, data) {
  40863. var previousState = this.state;
  40864. this.state = newState;
  40865. if (previousState !== newState) {
  40866. var newStateDescription = newState;
  40867. if (newStateDescription === "connected") {
  40868. newStateDescription += " with new socket ID " + data.socket_id;
  40869. }
  40870. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40871. this.timeline.info({ state: newState, params: data });
  40872. this.emit('state_change', { previous: previousState, current: newState });
  40873. this.emit(newState, data);
  40874. }
  40875. };
  40876. ConnectionManager.prototype.shouldRetry = function () {
  40877. return this.state === "connecting" || this.state === "connected";
  40878. };
  40879. return ConnectionManager;
  40880. }(dispatcher));
  40881. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40882. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40883. var channels_Channels = (function () {
  40884. function Channels() {
  40885. this.channels = {};
  40886. }
  40887. Channels.prototype.add = function (name, pusher) {
  40888. if (!this.channels[name]) {
  40889. this.channels[name] = createChannel(name, pusher);
  40890. }
  40891. return this.channels[name];
  40892. };
  40893. Channels.prototype.all = function () {
  40894. return values(this.channels);
  40895. };
  40896. Channels.prototype.find = function (name) {
  40897. return this.channels[name];
  40898. };
  40899. Channels.prototype.remove = function (name) {
  40900. var channel = this.channels[name];
  40901. delete this.channels[name];
  40902. return channel;
  40903. };
  40904. Channels.prototype.disconnect = function () {
  40905. objectApply(this.channels, function (channel) {
  40906. channel.disconnect();
  40907. });
  40908. };
  40909. return Channels;
  40910. }());
  40911. /* harmony default export */ var channels = (channels_Channels);
  40912. function createChannel(name, pusher) {
  40913. if (name.indexOf('private-encrypted-') === 0) {
  40914. if (false) { var errorMsg; }
  40915. return factory.createEncryptedChannel(name, pusher);
  40916. }
  40917. else if (name.indexOf('private-') === 0) {
  40918. return factory.createPrivateChannel(name, pusher);
  40919. }
  40920. else if (name.indexOf('presence-') === 0) {
  40921. return factory.createPresenceChannel(name, pusher);
  40922. }
  40923. else {
  40924. return factory.createChannel(name, pusher);
  40925. }
  40926. }
  40927. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40928. var Factory = {
  40929. createChannels: function () {
  40930. return new channels();
  40931. },
  40932. createConnectionManager: function (key, options) {
  40933. return new connection_manager(key, options);
  40934. },
  40935. createChannel: function (name, pusher) {
  40936. return new channels_channel(name, pusher);
  40937. },
  40938. createPrivateChannel: function (name, pusher) {
  40939. return new private_channel(name, pusher);
  40940. },
  40941. createPresenceChannel: function (name, pusher) {
  40942. return new presence_channel(name, pusher);
  40943. },
  40944. createEncryptedChannel: function (name, pusher) {
  40945. return new encrypted_channel(name, pusher);
  40946. },
  40947. createTimelineSender: function (timeline, options) {
  40948. return new timeline_sender(timeline, options);
  40949. },
  40950. createAuthorizer: function (channel, options) {
  40951. if (options.authorizer) {
  40952. return options.authorizer(channel, options);
  40953. }
  40954. return new pusher_authorizer(channel, options);
  40955. },
  40956. createHandshake: function (transport, callback) {
  40957. return new connection_handshake(transport, callback);
  40958. },
  40959. createAssistantToTheTransportManager: function (manager, transport, options) {
  40960. return new assistant_to_the_transport_manager(manager, transport, options);
  40961. }
  40962. };
  40963. /* harmony default export */ var factory = (Factory);
  40964. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40965. var transport_manager_TransportManager = (function () {
  40966. function TransportManager(options) {
  40967. this.options = options || {};
  40968. this.livesLeft = this.options.lives || Infinity;
  40969. }
  40970. TransportManager.prototype.getAssistant = function (transport) {
  40971. return factory.createAssistantToTheTransportManager(this, transport, {
  40972. minPingDelay: this.options.minPingDelay,
  40973. maxPingDelay: this.options.maxPingDelay
  40974. });
  40975. };
  40976. TransportManager.prototype.isAlive = function () {
  40977. return this.livesLeft > 0;
  40978. };
  40979. TransportManager.prototype.reportDeath = function () {
  40980. this.livesLeft -= 1;
  40981. };
  40982. return TransportManager;
  40983. }());
  40984. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40985. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40986. var sequential_strategy_SequentialStrategy = (function () {
  40987. function SequentialStrategy(strategies, options) {
  40988. this.strategies = strategies;
  40989. this.loop = Boolean(options.loop);
  40990. this.failFast = Boolean(options.failFast);
  40991. this.timeout = options.timeout;
  40992. this.timeoutLimit = options.timeoutLimit;
  40993. }
  40994. SequentialStrategy.prototype.isSupported = function () {
  40995. return any(this.strategies, util.method("isSupported"));
  40996. };
  40997. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40998. var _this = this;
  40999. var strategies = this.strategies;
  41000. var current = 0;
  41001. var timeout = this.timeout;
  41002. var runner = null;
  41003. var tryNextStrategy = function (error, handshake) {
  41004. if (handshake) {
  41005. callback(null, handshake);
  41006. }
  41007. else {
  41008. current = current + 1;
  41009. if (_this.loop) {
  41010. current = current % strategies.length;
  41011. }
  41012. if (current < strategies.length) {
  41013. if (timeout) {
  41014. timeout = timeout * 2;
  41015. if (_this.timeoutLimit) {
  41016. timeout = Math.min(timeout, _this.timeoutLimit);
  41017. }
  41018. }
  41019. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  41020. }
  41021. else {
  41022. callback(true);
  41023. }
  41024. }
  41025. };
  41026. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  41027. return {
  41028. abort: function () {
  41029. runner.abort();
  41030. },
  41031. forceMinPriority: function (p) {
  41032. minPriority = p;
  41033. if (runner) {
  41034. runner.forceMinPriority(p);
  41035. }
  41036. }
  41037. };
  41038. };
  41039. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  41040. var timer = null;
  41041. var runner = null;
  41042. if (options.timeout > 0) {
  41043. timer = new OneOffTimer(options.timeout, function () {
  41044. runner.abort();
  41045. callback(true);
  41046. });
  41047. }
  41048. runner = strategy.connect(minPriority, function (error, handshake) {
  41049. if (error && timer && timer.isRunning() && !options.failFast) {
  41050. return;
  41051. }
  41052. if (timer) {
  41053. timer.ensureAborted();
  41054. }
  41055. callback(error, handshake);
  41056. });
  41057. return {
  41058. abort: function () {
  41059. if (timer) {
  41060. timer.ensureAborted();
  41061. }
  41062. runner.abort();
  41063. },
  41064. forceMinPriority: function (p) {
  41065. runner.forceMinPriority(p);
  41066. }
  41067. };
  41068. };
  41069. return SequentialStrategy;
  41070. }());
  41071. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  41072. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  41073. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  41074. function BestConnectedEverStrategy(strategies) {
  41075. this.strategies = strategies;
  41076. }
  41077. BestConnectedEverStrategy.prototype.isSupported = function () {
  41078. return any(this.strategies, util.method("isSupported"));
  41079. };
  41080. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  41081. return connect(this.strategies, minPriority, function (i, runners) {
  41082. return function (error, handshake) {
  41083. runners[i].error = error;
  41084. if (error) {
  41085. if (allRunnersFailed(runners)) {
  41086. callback(true);
  41087. }
  41088. return;
  41089. }
  41090. apply(runners, function (runner) {
  41091. runner.forceMinPriority(handshake.transport.priority);
  41092. });
  41093. callback(null, handshake);
  41094. };
  41095. });
  41096. };
  41097. return BestConnectedEverStrategy;
  41098. }());
  41099. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  41100. function connect(strategies, minPriority, callbackBuilder) {
  41101. var runners = map(strategies, function (strategy, i, _, rs) {
  41102. return strategy.connect(minPriority, callbackBuilder(i, rs));
  41103. });
  41104. return {
  41105. abort: function () {
  41106. apply(runners, abortRunner);
  41107. },
  41108. forceMinPriority: function (p) {
  41109. apply(runners, function (runner) {
  41110. runner.forceMinPriority(p);
  41111. });
  41112. }
  41113. };
  41114. }
  41115. function allRunnersFailed(runners) {
  41116. return collections_all(runners, function (runner) {
  41117. return Boolean(runner.error);
  41118. });
  41119. }
  41120. function abortRunner(runner) {
  41121. if (!runner.error && !runner.aborted) {
  41122. runner.abort();
  41123. runner.aborted = true;
  41124. }
  41125. }
  41126. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41127. var cached_strategy_CachedStrategy = (function () {
  41128. function CachedStrategy(strategy, transports, options) {
  41129. this.strategy = strategy;
  41130. this.transports = transports;
  41131. this.ttl = options.ttl || 1800 * 1000;
  41132. this.usingTLS = options.useTLS;
  41133. this.timeline = options.timeline;
  41134. }
  41135. CachedStrategy.prototype.isSupported = function () {
  41136. return this.strategy.isSupported();
  41137. };
  41138. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41139. var usingTLS = this.usingTLS;
  41140. var info = fetchTransportCache(usingTLS);
  41141. var strategies = [this.strategy];
  41142. if (info && info.timestamp + this.ttl >= util.now()) {
  41143. var transport = this.transports[info.transport];
  41144. if (transport) {
  41145. this.timeline.info({
  41146. cached: true,
  41147. transport: info.transport,
  41148. latency: info.latency
  41149. });
  41150. strategies.push(new sequential_strategy([transport], {
  41151. timeout: info.latency * 2 + 1000,
  41152. failFast: true
  41153. }));
  41154. }
  41155. }
  41156. var startTimestamp = util.now();
  41157. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41158. if (error) {
  41159. flushTransportCache(usingTLS);
  41160. if (strategies.length > 0) {
  41161. startTimestamp = util.now();
  41162. runner = strategies.pop().connect(minPriority, cb);
  41163. }
  41164. else {
  41165. callback(error);
  41166. }
  41167. }
  41168. else {
  41169. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41170. callback(null, handshake);
  41171. }
  41172. });
  41173. return {
  41174. abort: function () {
  41175. runner.abort();
  41176. },
  41177. forceMinPriority: function (p) {
  41178. minPriority = p;
  41179. if (runner) {
  41180. runner.forceMinPriority(p);
  41181. }
  41182. }
  41183. };
  41184. };
  41185. return CachedStrategy;
  41186. }());
  41187. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41188. function getTransportCacheKey(usingTLS) {
  41189. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41190. }
  41191. function fetchTransportCache(usingTLS) {
  41192. var storage = runtime.getLocalStorage();
  41193. if (storage) {
  41194. try {
  41195. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41196. if (serializedCache) {
  41197. return JSON.parse(serializedCache);
  41198. }
  41199. }
  41200. catch (e) {
  41201. flushTransportCache(usingTLS);
  41202. }
  41203. }
  41204. return null;
  41205. }
  41206. function storeTransportCache(usingTLS, transport, latency) {
  41207. var storage = runtime.getLocalStorage();
  41208. if (storage) {
  41209. try {
  41210. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41211. timestamp: util.now(),
  41212. transport: transport,
  41213. latency: latency
  41214. });
  41215. }
  41216. catch (e) {
  41217. }
  41218. }
  41219. }
  41220. function flushTransportCache(usingTLS) {
  41221. var storage = runtime.getLocalStorage();
  41222. if (storage) {
  41223. try {
  41224. delete storage[getTransportCacheKey(usingTLS)];
  41225. }
  41226. catch (e) {
  41227. }
  41228. }
  41229. }
  41230. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41231. var delayed_strategy_DelayedStrategy = (function () {
  41232. function DelayedStrategy(strategy, _a) {
  41233. var number = _a.delay;
  41234. this.strategy = strategy;
  41235. this.options = { delay: number };
  41236. }
  41237. DelayedStrategy.prototype.isSupported = function () {
  41238. return this.strategy.isSupported();
  41239. };
  41240. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41241. var strategy = this.strategy;
  41242. var runner;
  41243. var timer = new OneOffTimer(this.options.delay, function () {
  41244. runner = strategy.connect(minPriority, callback);
  41245. });
  41246. return {
  41247. abort: function () {
  41248. timer.ensureAborted();
  41249. if (runner) {
  41250. runner.abort();
  41251. }
  41252. },
  41253. forceMinPriority: function (p) {
  41254. minPriority = p;
  41255. if (runner) {
  41256. runner.forceMinPriority(p);
  41257. }
  41258. }
  41259. };
  41260. };
  41261. return DelayedStrategy;
  41262. }());
  41263. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41264. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41265. var IfStrategy = (function () {
  41266. function IfStrategy(test, trueBranch, falseBranch) {
  41267. this.test = test;
  41268. this.trueBranch = trueBranch;
  41269. this.falseBranch = falseBranch;
  41270. }
  41271. IfStrategy.prototype.isSupported = function () {
  41272. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41273. return branch.isSupported();
  41274. };
  41275. IfStrategy.prototype.connect = function (minPriority, callback) {
  41276. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41277. return branch.connect(minPriority, callback);
  41278. };
  41279. return IfStrategy;
  41280. }());
  41281. /* harmony default export */ var if_strategy = (IfStrategy);
  41282. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41283. var FirstConnectedStrategy = (function () {
  41284. function FirstConnectedStrategy(strategy) {
  41285. this.strategy = strategy;
  41286. }
  41287. FirstConnectedStrategy.prototype.isSupported = function () {
  41288. return this.strategy.isSupported();
  41289. };
  41290. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41291. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41292. if (handshake) {
  41293. runner.abort();
  41294. }
  41295. callback(error, handshake);
  41296. });
  41297. return runner;
  41298. };
  41299. return FirstConnectedStrategy;
  41300. }());
  41301. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41302. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41303. function testSupportsStrategy(strategy) {
  41304. return function () {
  41305. return strategy.isSupported();
  41306. };
  41307. }
  41308. var getDefaultStrategy = function (config, defineTransport) {
  41309. var definedTransports = {};
  41310. function defineTransportStrategy(name, type, priority, options, manager) {
  41311. var transport = defineTransport(config, name, type, priority, options, manager);
  41312. definedTransports[name] = transport;
  41313. return transport;
  41314. }
  41315. var ws_options = {
  41316. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41317. hostTLS: config.wsHost + ":" + config.wssPort,
  41318. httpPath: config.wsPath
  41319. };
  41320. var wss_options = extend({}, ws_options, {
  41321. useTLS: true
  41322. });
  41323. var sockjs_options = {
  41324. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41325. hostTLS: config.httpHost + ":" + config.httpsPort,
  41326. httpPath: config.httpPath
  41327. };
  41328. var timeouts = {
  41329. loop: true,
  41330. timeout: 15000,
  41331. timeoutLimit: 60000
  41332. };
  41333. var ws_manager = new transport_manager({
  41334. lives: 2,
  41335. minPingDelay: 10000,
  41336. maxPingDelay: config.activity_timeout
  41337. });
  41338. var streaming_manager = new transport_manager({
  41339. lives: 2,
  41340. minPingDelay: 10000,
  41341. maxPingDelay: config.activity_timeout
  41342. });
  41343. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41344. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41345. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41346. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41347. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41348. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41349. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41350. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41351. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41352. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41353. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41354. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41355. 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);
  41356. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41357. var wsStrategy;
  41358. if (config.useTLS) {
  41359. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41360. }
  41361. else {
  41362. wsStrategy = new best_connected_ever_strategy([
  41363. ws_loop,
  41364. new delayed_strategy(wss_loop, { delay: 2000 }),
  41365. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41366. ]);
  41367. }
  41368. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41369. ttl: 1800000,
  41370. timeline: config.timeline,
  41371. useTLS: config.useTLS
  41372. });
  41373. };
  41374. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41375. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41376. /* harmony default export */ var transport_connection_initializer = (function () {
  41377. var self = this;
  41378. self.timeline.info(self.buildTimelineMessage({
  41379. transport: self.name + (self.options.useTLS ? "s" : "")
  41380. }));
  41381. if (self.hooks.isInitialized()) {
  41382. self.changeState("initialized");
  41383. }
  41384. else if (self.hooks.file) {
  41385. self.changeState("initializing");
  41386. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41387. if (self.hooks.isInitialized()) {
  41388. self.changeState("initialized");
  41389. callback(true);
  41390. }
  41391. else {
  41392. if (error) {
  41393. self.onError(error);
  41394. }
  41395. self.onClose();
  41396. callback(false);
  41397. }
  41398. });
  41399. }
  41400. else {
  41401. self.onClose();
  41402. }
  41403. });
  41404. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41405. var http_xdomain_request_hooks = {
  41406. getRequest: function (socket) {
  41407. var xdr = new window.XDomainRequest();
  41408. xdr.ontimeout = function () {
  41409. socket.emit("error", new RequestTimedOut());
  41410. socket.close();
  41411. };
  41412. xdr.onerror = function (e) {
  41413. socket.emit("error", e);
  41414. socket.close();
  41415. };
  41416. xdr.onprogress = function () {
  41417. if (xdr.responseText && xdr.responseText.length > 0) {
  41418. socket.onChunk(200, xdr.responseText);
  41419. }
  41420. };
  41421. xdr.onload = function () {
  41422. if (xdr.responseText && xdr.responseText.length > 0) {
  41423. socket.onChunk(200, xdr.responseText);
  41424. }
  41425. socket.emit("finished", 200);
  41426. socket.close();
  41427. };
  41428. return xdr;
  41429. },
  41430. abortRequest: function (xdr) {
  41431. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41432. xdr.abort();
  41433. }
  41434. };
  41435. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41436. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41437. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41438. var extendStatics = function (d, b) {
  41439. extendStatics = Object.setPrototypeOf ||
  41440. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41441. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41442. return extendStatics(d, b);
  41443. };
  41444. return function (d, b) {
  41445. extendStatics(d, b);
  41446. function __() { this.constructor = d; }
  41447. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41448. };
  41449. })();
  41450. var MAX_BUFFER_LENGTH = 256 * 1024;
  41451. var http_request_HTTPRequest = (function (_super) {
  41452. http_request_extends(HTTPRequest, _super);
  41453. function HTTPRequest(hooks, method, url) {
  41454. var _this = _super.call(this) || this;
  41455. _this.hooks = hooks;
  41456. _this.method = method;
  41457. _this.url = url;
  41458. return _this;
  41459. }
  41460. HTTPRequest.prototype.start = function (payload) {
  41461. var _this = this;
  41462. this.position = 0;
  41463. this.xhr = this.hooks.getRequest(this);
  41464. this.unloader = function () {
  41465. _this.close();
  41466. };
  41467. runtime.addUnloadListener(this.unloader);
  41468. this.xhr.open(this.method, this.url, true);
  41469. if (this.xhr.setRequestHeader) {
  41470. this.xhr.setRequestHeader("Content-Type", "application/json");
  41471. }
  41472. this.xhr.send(payload);
  41473. };
  41474. HTTPRequest.prototype.close = function () {
  41475. if (this.unloader) {
  41476. runtime.removeUnloadListener(this.unloader);
  41477. this.unloader = null;
  41478. }
  41479. if (this.xhr) {
  41480. this.hooks.abortRequest(this.xhr);
  41481. this.xhr = null;
  41482. }
  41483. };
  41484. HTTPRequest.prototype.onChunk = function (status, data) {
  41485. while (true) {
  41486. var chunk = this.advanceBuffer(data);
  41487. if (chunk) {
  41488. this.emit("chunk", { status: status, data: chunk });
  41489. }
  41490. else {
  41491. break;
  41492. }
  41493. }
  41494. if (this.isBufferTooLong(data)) {
  41495. this.emit("buffer_too_long");
  41496. }
  41497. };
  41498. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41499. var unreadData = buffer.slice(this.position);
  41500. var endOfLinePosition = unreadData.indexOf("\n");
  41501. if (endOfLinePosition !== -1) {
  41502. this.position += endOfLinePosition + 1;
  41503. return unreadData.slice(0, endOfLinePosition);
  41504. }
  41505. else {
  41506. return null;
  41507. }
  41508. };
  41509. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41510. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41511. };
  41512. return HTTPRequest;
  41513. }(dispatcher));
  41514. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41515. // CONCATENATED MODULE: ./src/core/http/state.ts
  41516. var State;
  41517. (function (State) {
  41518. State[State["CONNECTING"] = 0] = "CONNECTING";
  41519. State[State["OPEN"] = 1] = "OPEN";
  41520. State[State["CLOSED"] = 3] = "CLOSED";
  41521. })(State || (State = {}));
  41522. /* harmony default export */ var state = (State);
  41523. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41524. var autoIncrement = 1;
  41525. var http_socket_HTTPSocket = (function () {
  41526. function HTTPSocket(hooks, url) {
  41527. this.hooks = hooks;
  41528. this.session = randomNumber(1000) + "/" + randomString(8);
  41529. this.location = getLocation(url);
  41530. this.readyState = state.CONNECTING;
  41531. this.openStream();
  41532. }
  41533. HTTPSocket.prototype.send = function (payload) {
  41534. return this.sendRaw(JSON.stringify([payload]));
  41535. };
  41536. HTTPSocket.prototype.ping = function () {
  41537. this.hooks.sendHeartbeat(this);
  41538. };
  41539. HTTPSocket.prototype.close = function (code, reason) {
  41540. this.onClose(code, reason, true);
  41541. };
  41542. HTTPSocket.prototype.sendRaw = function (payload) {
  41543. if (this.readyState === state.OPEN) {
  41544. try {
  41545. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41546. return true;
  41547. }
  41548. catch (e) {
  41549. return false;
  41550. }
  41551. }
  41552. else {
  41553. return false;
  41554. }
  41555. };
  41556. HTTPSocket.prototype.reconnect = function () {
  41557. this.closeStream();
  41558. this.openStream();
  41559. };
  41560. ;
  41561. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41562. this.closeStream();
  41563. this.readyState = state.CLOSED;
  41564. if (this.onclose) {
  41565. this.onclose({
  41566. code: code,
  41567. reason: reason,
  41568. wasClean: wasClean
  41569. });
  41570. }
  41571. };
  41572. HTTPSocket.prototype.onChunk = function (chunk) {
  41573. if (chunk.status !== 200) {
  41574. return;
  41575. }
  41576. if (this.readyState === state.OPEN) {
  41577. this.onActivity();
  41578. }
  41579. var payload;
  41580. var type = chunk.data.slice(0, 1);
  41581. switch (type) {
  41582. case 'o':
  41583. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41584. this.onOpen(payload);
  41585. break;
  41586. case 'a':
  41587. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41588. for (var i = 0; i < payload.length; i++) {
  41589. this.onEvent(payload[i]);
  41590. }
  41591. break;
  41592. case 'm':
  41593. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41594. this.onEvent(payload);
  41595. break;
  41596. case 'h':
  41597. this.hooks.onHeartbeat(this);
  41598. break;
  41599. case 'c':
  41600. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41601. this.onClose(payload[0], payload[1], true);
  41602. break;
  41603. }
  41604. };
  41605. HTTPSocket.prototype.onOpen = function (options) {
  41606. if (this.readyState === state.CONNECTING) {
  41607. if (options && options.hostname) {
  41608. this.location.base = replaceHost(this.location.base, options.hostname);
  41609. }
  41610. this.readyState = state.OPEN;
  41611. if (this.onopen) {
  41612. this.onopen();
  41613. }
  41614. }
  41615. else {
  41616. this.onClose(1006, "Server lost session", true);
  41617. }
  41618. };
  41619. HTTPSocket.prototype.onEvent = function (event) {
  41620. if (this.readyState === state.OPEN && this.onmessage) {
  41621. this.onmessage({ data: event });
  41622. }
  41623. };
  41624. HTTPSocket.prototype.onActivity = function () {
  41625. if (this.onactivity) {
  41626. this.onactivity();
  41627. }
  41628. };
  41629. HTTPSocket.prototype.onError = function (error) {
  41630. if (this.onerror) {
  41631. this.onerror(error);
  41632. }
  41633. };
  41634. HTTPSocket.prototype.openStream = function () {
  41635. var _this = this;
  41636. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41637. this.stream.bind("chunk", function (chunk) {
  41638. _this.onChunk(chunk);
  41639. });
  41640. this.stream.bind("finished", function (status) {
  41641. _this.hooks.onFinished(_this, status);
  41642. });
  41643. this.stream.bind("buffer_too_long", function () {
  41644. _this.reconnect();
  41645. });
  41646. try {
  41647. this.stream.start();
  41648. }
  41649. catch (error) {
  41650. util.defer(function () {
  41651. _this.onError(error);
  41652. _this.onClose(1006, "Could not start streaming", false);
  41653. });
  41654. }
  41655. };
  41656. HTTPSocket.prototype.closeStream = function () {
  41657. if (this.stream) {
  41658. this.stream.unbind_all();
  41659. this.stream.close();
  41660. this.stream = null;
  41661. }
  41662. };
  41663. return HTTPSocket;
  41664. }());
  41665. function getLocation(url) {
  41666. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41667. return {
  41668. base: parts[1],
  41669. queryString: parts[2]
  41670. };
  41671. }
  41672. function getSendURL(url, session) {
  41673. return url.base + "/" + session + "/xhr_send";
  41674. }
  41675. function getUniqueURL(url) {
  41676. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41677. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41678. }
  41679. function replaceHost(url, hostname) {
  41680. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41681. return urlParts[1] + hostname + urlParts[3];
  41682. }
  41683. function randomNumber(max) {
  41684. return Math.floor(Math.random() * max);
  41685. }
  41686. function randomString(length) {
  41687. var result = [];
  41688. for (var i = 0; i < length; i++) {
  41689. result.push(randomNumber(32).toString(32));
  41690. }
  41691. return result.join('');
  41692. }
  41693. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41694. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41695. var http_streaming_socket_hooks = {
  41696. getReceiveURL: function (url, session) {
  41697. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41698. },
  41699. onHeartbeat: function (socket) {
  41700. socket.sendRaw("[]");
  41701. },
  41702. sendHeartbeat: function (socket) {
  41703. socket.sendRaw("[]");
  41704. },
  41705. onFinished: function (socket, status) {
  41706. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41707. }
  41708. };
  41709. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41710. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41711. var http_polling_socket_hooks = {
  41712. getReceiveURL: function (url, session) {
  41713. return url.base + "/" + session + "/xhr" + url.queryString;
  41714. },
  41715. onHeartbeat: function () {
  41716. },
  41717. sendHeartbeat: function (socket) {
  41718. socket.sendRaw("[]");
  41719. },
  41720. onFinished: function (socket, status) {
  41721. if (status === 200) {
  41722. socket.reconnect();
  41723. }
  41724. else {
  41725. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41726. }
  41727. }
  41728. };
  41729. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41730. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41731. var http_xhr_request_hooks = {
  41732. getRequest: function (socket) {
  41733. var Constructor = runtime.getXHRAPI();
  41734. var xhr = new Constructor();
  41735. xhr.onreadystatechange = xhr.onprogress = function () {
  41736. switch (xhr.readyState) {
  41737. case 3:
  41738. if (xhr.responseText && xhr.responseText.length > 0) {
  41739. socket.onChunk(xhr.status, xhr.responseText);
  41740. }
  41741. break;
  41742. case 4:
  41743. if (xhr.responseText && xhr.responseText.length > 0) {
  41744. socket.onChunk(xhr.status, xhr.responseText);
  41745. }
  41746. socket.emit("finished", xhr.status);
  41747. socket.close();
  41748. break;
  41749. }
  41750. };
  41751. return xhr;
  41752. },
  41753. abortRequest: function (xhr) {
  41754. xhr.onreadystatechange = null;
  41755. xhr.abort();
  41756. }
  41757. };
  41758. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41759. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41760. var HTTP = {
  41761. createStreamingSocket: function (url) {
  41762. return this.createSocket(http_streaming_socket, url);
  41763. },
  41764. createPollingSocket: function (url) {
  41765. return this.createSocket(http_polling_socket, url);
  41766. },
  41767. createSocket: function (hooks, url) {
  41768. return new http_socket(hooks, url);
  41769. },
  41770. createXHR: function (method, url) {
  41771. return this.createRequest(http_xhr_request, method, url);
  41772. },
  41773. createRequest: function (hooks, method, url) {
  41774. return new http_request(hooks, method, url);
  41775. }
  41776. };
  41777. /* harmony default export */ var http_http = (HTTP);
  41778. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41779. http_http.createXDR = function (method, url) {
  41780. return this.createRequest(http_xdomain_request, method, url);
  41781. };
  41782. /* harmony default export */ var web_http_http = (http_http);
  41783. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41784. var Runtime = {
  41785. nextAuthCallbackID: 1,
  41786. auth_callbacks: {},
  41787. ScriptReceivers: ScriptReceivers,
  41788. DependenciesReceivers: DependenciesReceivers,
  41789. getDefaultStrategy: default_strategy,
  41790. Transports: transports_transports,
  41791. transportConnectionInitializer: transport_connection_initializer,
  41792. HTTPFactory: web_http_http,
  41793. TimelineTransport: jsonp_timeline,
  41794. getXHRAPI: function () {
  41795. return window.XMLHttpRequest;
  41796. },
  41797. getWebSocketAPI: function () {
  41798. return window.WebSocket || window.MozWebSocket;
  41799. },
  41800. setup: function (PusherClass) {
  41801. var _this = this;
  41802. window.Pusher = PusherClass;
  41803. var initializeOnDocumentBody = function () {
  41804. _this.onDocumentBody(PusherClass.ready);
  41805. };
  41806. if (!window.JSON) {
  41807. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41808. }
  41809. else {
  41810. initializeOnDocumentBody();
  41811. }
  41812. },
  41813. getDocument: function () {
  41814. return document;
  41815. },
  41816. getProtocol: function () {
  41817. return this.getDocument().location.protocol;
  41818. },
  41819. getAuthorizers: function () {
  41820. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41821. },
  41822. onDocumentBody: function (callback) {
  41823. var _this = this;
  41824. if (document.body) {
  41825. callback();
  41826. }
  41827. else {
  41828. setTimeout(function () {
  41829. _this.onDocumentBody(callback);
  41830. }, 0);
  41831. }
  41832. },
  41833. createJSONPRequest: function (url, data) {
  41834. return new jsonp_request(url, data);
  41835. },
  41836. createScriptRequest: function (src) {
  41837. return new script_request(src);
  41838. },
  41839. getLocalStorage: function () {
  41840. try {
  41841. return window.localStorage;
  41842. }
  41843. catch (e) {
  41844. return undefined;
  41845. }
  41846. },
  41847. createXHR: function () {
  41848. if (this.getXHRAPI()) {
  41849. return this.createXMLHttpRequest();
  41850. }
  41851. else {
  41852. return this.createMicrosoftXHR();
  41853. }
  41854. },
  41855. createXMLHttpRequest: function () {
  41856. var Constructor = this.getXHRAPI();
  41857. return new Constructor();
  41858. },
  41859. createMicrosoftXHR: function () {
  41860. return new ActiveXObject("Microsoft.XMLHTTP");
  41861. },
  41862. getNetwork: function () {
  41863. return net_info_Network;
  41864. },
  41865. createWebSocket: function (url) {
  41866. var Constructor = this.getWebSocketAPI();
  41867. return new Constructor(url);
  41868. },
  41869. createSocketRequest: function (method, url) {
  41870. if (this.isXHRSupported()) {
  41871. return this.HTTPFactory.createXHR(method, url);
  41872. }
  41873. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41874. return this.HTTPFactory.createXDR(method, url);
  41875. }
  41876. else {
  41877. throw "Cross-origin HTTP requests are not supported";
  41878. }
  41879. },
  41880. isXHRSupported: function () {
  41881. var Constructor = this.getXHRAPI();
  41882. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41883. },
  41884. isXDRSupported: function (useTLS) {
  41885. var protocol = useTLS ? "https:" : "http:";
  41886. var documentProtocol = this.getProtocol();
  41887. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41888. },
  41889. addUnloadListener: function (listener) {
  41890. if (window.addEventListener !== undefined) {
  41891. window.addEventListener("unload", listener, false);
  41892. }
  41893. else if (window.attachEvent !== undefined) {
  41894. window.attachEvent("onunload", listener);
  41895. }
  41896. },
  41897. removeUnloadListener: function (listener) {
  41898. if (window.addEventListener !== undefined) {
  41899. window.removeEventListener("unload", listener, false);
  41900. }
  41901. else if (window.detachEvent !== undefined) {
  41902. window.detachEvent("onunload", listener);
  41903. }
  41904. }
  41905. };
  41906. /* harmony default export */ var runtime = (Runtime);
  41907. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41908. var TimelineLevel;
  41909. (function (TimelineLevel) {
  41910. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41911. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41912. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41913. })(TimelineLevel || (TimelineLevel = {}));
  41914. /* harmony default export */ var timeline_level = (TimelineLevel);
  41915. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41916. var timeline_Timeline = (function () {
  41917. function Timeline(key, session, options) {
  41918. this.key = key;
  41919. this.session = session;
  41920. this.events = [];
  41921. this.options = options || {};
  41922. this.sent = 0;
  41923. this.uniqueID = 0;
  41924. }
  41925. Timeline.prototype.log = function (level, event) {
  41926. if (level <= this.options.level) {
  41927. this.events.push(extend({}, event, { timestamp: util.now() }));
  41928. if (this.options.limit && this.events.length > this.options.limit) {
  41929. this.events.shift();
  41930. }
  41931. }
  41932. };
  41933. Timeline.prototype.error = function (event) {
  41934. this.log(timeline_level.ERROR, event);
  41935. };
  41936. Timeline.prototype.info = function (event) {
  41937. this.log(timeline_level.INFO, event);
  41938. };
  41939. Timeline.prototype.debug = function (event) {
  41940. this.log(timeline_level.DEBUG, event);
  41941. };
  41942. Timeline.prototype.isEmpty = function () {
  41943. return this.events.length === 0;
  41944. };
  41945. Timeline.prototype.send = function (sendfn, callback) {
  41946. var _this = this;
  41947. var data = extend({
  41948. session: this.session,
  41949. bundle: this.sent + 1,
  41950. key: this.key,
  41951. lib: "js",
  41952. version: this.options.version,
  41953. cluster: this.options.cluster,
  41954. features: this.options.features,
  41955. timeline: this.events
  41956. }, this.options.params);
  41957. this.events = [];
  41958. sendfn(data, function (error, result) {
  41959. if (!error) {
  41960. _this.sent++;
  41961. }
  41962. if (callback) {
  41963. callback(error, result);
  41964. }
  41965. });
  41966. return true;
  41967. };
  41968. Timeline.prototype.generateUniqueID = function () {
  41969. this.uniqueID++;
  41970. return this.uniqueID;
  41971. };
  41972. return Timeline;
  41973. }());
  41974. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41975. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41976. var transport_strategy_TransportStrategy = (function () {
  41977. function TransportStrategy(name, priority, transport, options) {
  41978. this.name = name;
  41979. this.priority = priority;
  41980. this.transport = transport;
  41981. this.options = options || {};
  41982. }
  41983. TransportStrategy.prototype.isSupported = function () {
  41984. return this.transport.isSupported({
  41985. useTLS: this.options.useTLS
  41986. });
  41987. };
  41988. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41989. var _this = this;
  41990. if (!this.isSupported()) {
  41991. return failAttempt(new UnsupportedStrategy(), callback);
  41992. }
  41993. else if (this.priority < minPriority) {
  41994. return failAttempt(new TransportPriorityTooLow(), callback);
  41995. }
  41996. var connected = false;
  41997. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41998. var handshake = null;
  41999. var onInitialized = function () {
  42000. transport.unbind("initialized", onInitialized);
  42001. transport.connect();
  42002. };
  42003. var onOpen = function () {
  42004. handshake = factory.createHandshake(transport, function (result) {
  42005. connected = true;
  42006. unbindListeners();
  42007. callback(null, result);
  42008. });
  42009. };
  42010. var onError = function (error) {
  42011. unbindListeners();
  42012. callback(error);
  42013. };
  42014. var onClosed = function () {
  42015. unbindListeners();
  42016. var serializedTransport;
  42017. serializedTransport = safeJSONStringify(transport);
  42018. callback(new TransportClosed(serializedTransport));
  42019. };
  42020. var unbindListeners = function () {
  42021. transport.unbind("initialized", onInitialized);
  42022. transport.unbind("open", onOpen);
  42023. transport.unbind("error", onError);
  42024. transport.unbind("closed", onClosed);
  42025. };
  42026. transport.bind("initialized", onInitialized);
  42027. transport.bind("open", onOpen);
  42028. transport.bind("error", onError);
  42029. transport.bind("closed", onClosed);
  42030. transport.initialize();
  42031. return {
  42032. abort: function () {
  42033. if (connected) {
  42034. return;
  42035. }
  42036. unbindListeners();
  42037. if (handshake) {
  42038. handshake.close();
  42039. }
  42040. else {
  42041. transport.close();
  42042. }
  42043. },
  42044. forceMinPriority: function (p) {
  42045. if (connected) {
  42046. return;
  42047. }
  42048. if (_this.priority < p) {
  42049. if (handshake) {
  42050. handshake.close();
  42051. }
  42052. else {
  42053. transport.close();
  42054. }
  42055. }
  42056. }
  42057. };
  42058. };
  42059. return TransportStrategy;
  42060. }());
  42061. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  42062. function failAttempt(error, callback) {
  42063. util.defer(function () {
  42064. callback(error);
  42065. });
  42066. return {
  42067. abort: function () { },
  42068. forceMinPriority: function () { }
  42069. };
  42070. }
  42071. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  42072. var strategy_builder_Transports = runtime.Transports;
  42073. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  42074. var transportClass = strategy_builder_Transports[type];
  42075. if (!transportClass) {
  42076. throw new UnsupportedTransport(type);
  42077. }
  42078. var enabled = (!config.enabledTransports ||
  42079. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  42080. (!config.disabledTransports ||
  42081. arrayIndexOf(config.disabledTransports, name) === -1);
  42082. var transport;
  42083. if (enabled) {
  42084. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  42085. key: config.key,
  42086. useTLS: config.useTLS,
  42087. timeline: config.timeline,
  42088. ignoreNullOrigin: config.ignoreNullOrigin
  42089. }, options));
  42090. }
  42091. else {
  42092. transport = strategy_builder_UnsupportedStrategy;
  42093. }
  42094. return transport;
  42095. };
  42096. var strategy_builder_UnsupportedStrategy = {
  42097. isSupported: function () {
  42098. return false;
  42099. },
  42100. connect: function (_, callback) {
  42101. var deferred = util.defer(function () {
  42102. callback(new UnsupportedStrategy());
  42103. });
  42104. return {
  42105. abort: function () {
  42106. deferred.ensureAborted();
  42107. },
  42108. forceMinPriority: function () { }
  42109. };
  42110. }
  42111. };
  42112. // CONCATENATED MODULE: ./src/core/config.ts
  42113. var getGlobalConfig = function () {
  42114. return {
  42115. wsHost: defaults.host,
  42116. wsPort: defaults.ws_port,
  42117. wssPort: defaults.wss_port,
  42118. wsPath: defaults.ws_path,
  42119. httpHost: defaults.sockjs_host,
  42120. httpPort: defaults.sockjs_http_port,
  42121. httpsPort: defaults.sockjs_https_port,
  42122. httpPath: defaults.sockjs_path,
  42123. statsHost: defaults.stats_host,
  42124. authEndpoint: defaults.channel_auth_endpoint,
  42125. authTransport: defaults.channel_auth_transport,
  42126. activity_timeout: defaults.activity_timeout,
  42127. pong_timeout: defaults.pong_timeout,
  42128. unavailable_timeout: defaults.unavailable_timeout
  42129. };
  42130. };
  42131. var getClusterConfig = function (clusterName) {
  42132. return {
  42133. wsHost: 'ws-' + clusterName + '.pusher.com',
  42134. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42135. };
  42136. };
  42137. // CONCATENATED MODULE: ./src/core/pusher.ts
  42138. var pusher_Pusher = (function () {
  42139. function Pusher(app_key, options) {
  42140. var _this = this;
  42141. checkAppKey(app_key);
  42142. options = options || {};
  42143. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42144. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42145. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42146. }
  42147. this.key = app_key;
  42148. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42149. this.channels = factory.createChannels();
  42150. this.global_emitter = new dispatcher();
  42151. this.sessionID = Math.floor(Math.random() * 1000000000);
  42152. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42153. cluster: this.config.cluster,
  42154. features: Pusher.getClientFeatures(),
  42155. params: this.config.timelineParams || {},
  42156. limit: 50,
  42157. level: timeline_level.INFO,
  42158. version: defaults.VERSION
  42159. });
  42160. if (!this.config.disableStats) {
  42161. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42162. host: this.config.statsHost,
  42163. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42164. });
  42165. }
  42166. var getStrategy = function (options) {
  42167. var config = extend({}, _this.config, options);
  42168. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42169. };
  42170. this.connection = factory.createConnectionManager(this.key, extend({
  42171. getStrategy: getStrategy,
  42172. timeline: this.timeline,
  42173. activityTimeout: this.config.activity_timeout,
  42174. pongTimeout: this.config.pong_timeout,
  42175. unavailableTimeout: this.config.unavailable_timeout
  42176. }, this.config, { useTLS: this.shouldUseTLS() }));
  42177. this.connection.bind('connected', function () {
  42178. _this.subscribeAll();
  42179. if (_this.timelineSender) {
  42180. _this.timelineSender.send(_this.connection.isUsingTLS());
  42181. }
  42182. });
  42183. this.connection.bind('message', function (event) {
  42184. var eventName = event.event;
  42185. var internal = eventName.indexOf('pusher_internal:') === 0;
  42186. if (event.channel) {
  42187. var channel = _this.channel(event.channel);
  42188. if (channel) {
  42189. channel.handleEvent(event);
  42190. }
  42191. }
  42192. if (!internal) {
  42193. _this.global_emitter.emit(event.event, event.data);
  42194. }
  42195. });
  42196. this.connection.bind('connecting', function () {
  42197. _this.channels.disconnect();
  42198. });
  42199. this.connection.bind('disconnected', function () {
  42200. _this.channels.disconnect();
  42201. });
  42202. this.connection.bind('error', function (err) {
  42203. logger.warn(err);
  42204. });
  42205. Pusher.instances.push(this);
  42206. this.timeline.info({ instances: Pusher.instances.length });
  42207. if (Pusher.isReady) {
  42208. this.connect();
  42209. }
  42210. }
  42211. Pusher.ready = function () {
  42212. Pusher.isReady = true;
  42213. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42214. Pusher.instances[i].connect();
  42215. }
  42216. };
  42217. Pusher.getClientFeatures = function () {
  42218. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42219. return t.isSupported({});
  42220. }));
  42221. };
  42222. Pusher.prototype.channel = function (name) {
  42223. return this.channels.find(name);
  42224. };
  42225. Pusher.prototype.allChannels = function () {
  42226. return this.channels.all();
  42227. };
  42228. Pusher.prototype.connect = function () {
  42229. this.connection.connect();
  42230. if (this.timelineSender) {
  42231. if (!this.timelineSenderTimer) {
  42232. var usingTLS = this.connection.isUsingTLS();
  42233. var timelineSender = this.timelineSender;
  42234. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42235. timelineSender.send(usingTLS);
  42236. });
  42237. }
  42238. }
  42239. };
  42240. Pusher.prototype.disconnect = function () {
  42241. this.connection.disconnect();
  42242. if (this.timelineSenderTimer) {
  42243. this.timelineSenderTimer.ensureAborted();
  42244. this.timelineSenderTimer = null;
  42245. }
  42246. };
  42247. Pusher.prototype.bind = function (event_name, callback, context) {
  42248. this.global_emitter.bind(event_name, callback, context);
  42249. return this;
  42250. };
  42251. Pusher.prototype.unbind = function (event_name, callback, context) {
  42252. this.global_emitter.unbind(event_name, callback, context);
  42253. return this;
  42254. };
  42255. Pusher.prototype.bind_global = function (callback) {
  42256. this.global_emitter.bind_global(callback);
  42257. return this;
  42258. };
  42259. Pusher.prototype.unbind_global = function (callback) {
  42260. this.global_emitter.unbind_global(callback);
  42261. return this;
  42262. };
  42263. Pusher.prototype.unbind_all = function (callback) {
  42264. this.global_emitter.unbind_all();
  42265. return this;
  42266. };
  42267. Pusher.prototype.subscribeAll = function () {
  42268. var channelName;
  42269. for (channelName in this.channels.channels) {
  42270. if (this.channels.channels.hasOwnProperty(channelName)) {
  42271. this.subscribe(channelName);
  42272. }
  42273. }
  42274. };
  42275. Pusher.prototype.subscribe = function (channel_name) {
  42276. var channel = this.channels.add(channel_name, this);
  42277. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42278. channel.reinstateSubscription();
  42279. }
  42280. else if (!channel.subscriptionPending &&
  42281. this.connection.state === 'connected') {
  42282. channel.subscribe();
  42283. }
  42284. return channel;
  42285. };
  42286. Pusher.prototype.unsubscribe = function (channel_name) {
  42287. var channel = this.channels.find(channel_name);
  42288. if (channel && channel.subscriptionPending) {
  42289. channel.cancelSubscription();
  42290. }
  42291. else {
  42292. channel = this.channels.remove(channel_name);
  42293. if (channel && this.connection.state === 'connected') {
  42294. channel.unsubscribe();
  42295. }
  42296. }
  42297. };
  42298. Pusher.prototype.send_event = function (event_name, data, channel) {
  42299. return this.connection.send_event(event_name, data, channel);
  42300. };
  42301. Pusher.prototype.shouldUseTLS = function () {
  42302. if (runtime.getProtocol() === 'https:') {
  42303. return true;
  42304. }
  42305. else if (this.config.forceTLS === true) {
  42306. return true;
  42307. }
  42308. else {
  42309. return Boolean(this.config.encrypted);
  42310. }
  42311. };
  42312. Pusher.instances = [];
  42313. Pusher.isReady = false;
  42314. Pusher.logToConsole = false;
  42315. Pusher.Runtime = runtime;
  42316. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42317. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42318. Pusher.auth_callbacks = runtime.auth_callbacks;
  42319. return Pusher;
  42320. }());
  42321. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42322. function checkAppKey(key) {
  42323. if (key === null || key === undefined) {
  42324. throw 'You must pass your app key when you instantiate Pusher.';
  42325. }
  42326. }
  42327. runtime.setup(pusher_Pusher);
  42328. /***/ })
  42329. /******/ ]);
  42330. });
  42331. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42332. /***/ }),
  42333. /***/ "./node_modules/setimmediate/setImmediate.js":
  42334. /*!***************************************************!*\
  42335. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42336. \***************************************************/
  42337. /*! no static exports found */
  42338. /***/ (function(module, exports, __webpack_require__) {
  42339. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42340. "use strict";
  42341. if (global.setImmediate) {
  42342. return;
  42343. }
  42344. var nextHandle = 1; // Spec says greater than zero
  42345. var tasksByHandle = {};
  42346. var currentlyRunningATask = false;
  42347. var doc = global.document;
  42348. var registerImmediate;
  42349. function setImmediate(callback) {
  42350. // Callback can either be a function or a string
  42351. if (typeof callback !== "function") {
  42352. callback = new Function("" + callback);
  42353. }
  42354. // Copy function arguments
  42355. var args = new Array(arguments.length - 1);
  42356. for (var i = 0; i < args.length; i++) {
  42357. args[i] = arguments[i + 1];
  42358. }
  42359. // Store and register the task
  42360. var task = { callback: callback, args: args };
  42361. tasksByHandle[nextHandle] = task;
  42362. registerImmediate(nextHandle);
  42363. return nextHandle++;
  42364. }
  42365. function clearImmediate(handle) {
  42366. delete tasksByHandle[handle];
  42367. }
  42368. function run(task) {
  42369. var callback = task.callback;
  42370. var args = task.args;
  42371. switch (args.length) {
  42372. case 0:
  42373. callback();
  42374. break;
  42375. case 1:
  42376. callback(args[0]);
  42377. break;
  42378. case 2:
  42379. callback(args[0], args[1]);
  42380. break;
  42381. case 3:
  42382. callback(args[0], args[1], args[2]);
  42383. break;
  42384. default:
  42385. callback.apply(undefined, args);
  42386. break;
  42387. }
  42388. }
  42389. function runIfPresent(handle) {
  42390. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42391. // So if we're currently running a task, we'll need to delay this invocation.
  42392. if (currentlyRunningATask) {
  42393. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42394. // "too much recursion" error.
  42395. setTimeout(runIfPresent, 0, handle);
  42396. } else {
  42397. var task = tasksByHandle[handle];
  42398. if (task) {
  42399. currentlyRunningATask = true;
  42400. try {
  42401. run(task);
  42402. } finally {
  42403. clearImmediate(handle);
  42404. currentlyRunningATask = false;
  42405. }
  42406. }
  42407. }
  42408. }
  42409. function installNextTickImplementation() {
  42410. registerImmediate = function(handle) {
  42411. process.nextTick(function () { runIfPresent(handle); });
  42412. };
  42413. }
  42414. function canUsePostMessage() {
  42415. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42416. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42417. if (global.postMessage && !global.importScripts) {
  42418. var postMessageIsAsynchronous = true;
  42419. var oldOnMessage = global.onmessage;
  42420. global.onmessage = function() {
  42421. postMessageIsAsynchronous = false;
  42422. };
  42423. global.postMessage("", "*");
  42424. global.onmessage = oldOnMessage;
  42425. return postMessageIsAsynchronous;
  42426. }
  42427. }
  42428. function installPostMessageImplementation() {
  42429. // Installs an event handler on `global` for the `message` event: see
  42430. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42431. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42432. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42433. var onGlobalMessage = function(event) {
  42434. if (event.source === global &&
  42435. typeof event.data === "string" &&
  42436. event.data.indexOf(messagePrefix) === 0) {
  42437. runIfPresent(+event.data.slice(messagePrefix.length));
  42438. }
  42439. };
  42440. if (global.addEventListener) {
  42441. global.addEventListener("message", onGlobalMessage, false);
  42442. } else {
  42443. global.attachEvent("onmessage", onGlobalMessage);
  42444. }
  42445. registerImmediate = function(handle) {
  42446. global.postMessage(messagePrefix + handle, "*");
  42447. };
  42448. }
  42449. function installMessageChannelImplementation() {
  42450. var channel = new MessageChannel();
  42451. channel.port1.onmessage = function(event) {
  42452. var handle = event.data;
  42453. runIfPresent(handle);
  42454. };
  42455. registerImmediate = function(handle) {
  42456. channel.port2.postMessage(handle);
  42457. };
  42458. }
  42459. function installReadyStateChangeImplementation() {
  42460. var html = doc.documentElement;
  42461. registerImmediate = function(handle) {
  42462. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42463. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42464. var script = doc.createElement("script");
  42465. script.onreadystatechange = function () {
  42466. runIfPresent(handle);
  42467. script.onreadystatechange = null;
  42468. html.removeChild(script);
  42469. script = null;
  42470. };
  42471. html.appendChild(script);
  42472. };
  42473. }
  42474. function installSetTimeoutImplementation() {
  42475. registerImmediate = function(handle) {
  42476. setTimeout(runIfPresent, 0, handle);
  42477. };
  42478. }
  42479. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42480. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42481. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42482. // Don't get fooled by e.g. browserify environments.
  42483. if ({}.toString.call(global.process) === "[object process]") {
  42484. // For Node.js before 0.9
  42485. installNextTickImplementation();
  42486. } else if (canUsePostMessage()) {
  42487. // For non-IE10 modern browsers
  42488. installPostMessageImplementation();
  42489. } else if (global.MessageChannel) {
  42490. // For web workers, where supported
  42491. installMessageChannelImplementation();
  42492. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42493. // For IE 6–8
  42494. installReadyStateChangeImplementation();
  42495. } else {
  42496. // For older browsers
  42497. installSetTimeoutImplementation();
  42498. }
  42499. attachTo.setImmediate = setImmediate;
  42500. attachTo.clearImmediate = clearImmediate;
  42501. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42502. /* 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")))
  42503. /***/ }),
  42504. /***/ "./node_modules/timers-browserify/main.js":
  42505. /*!************************************************!*\
  42506. !*** ./node_modules/timers-browserify/main.js ***!
  42507. \************************************************/
  42508. /*! no static exports found */
  42509. /***/ (function(module, exports, __webpack_require__) {
  42510. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42511. (typeof self !== "undefined" && self) ||
  42512. window;
  42513. var apply = Function.prototype.apply;
  42514. // DOM APIs, for completeness
  42515. exports.setTimeout = function() {
  42516. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42517. };
  42518. exports.setInterval = function() {
  42519. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42520. };
  42521. exports.clearTimeout =
  42522. exports.clearInterval = function(timeout) {
  42523. if (timeout) {
  42524. timeout.close();
  42525. }
  42526. };
  42527. function Timeout(id, clearFn) {
  42528. this._id = id;
  42529. this._clearFn = clearFn;
  42530. }
  42531. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42532. Timeout.prototype.close = function() {
  42533. this._clearFn.call(scope, this._id);
  42534. };
  42535. // Does not start the time, just sets up the members needed.
  42536. exports.enroll = function(item, msecs) {
  42537. clearTimeout(item._idleTimeoutId);
  42538. item._idleTimeout = msecs;
  42539. };
  42540. exports.unenroll = function(item) {
  42541. clearTimeout(item._idleTimeoutId);
  42542. item._idleTimeout = -1;
  42543. };
  42544. exports._unrefActive = exports.active = function(item) {
  42545. clearTimeout(item._idleTimeoutId);
  42546. var msecs = item._idleTimeout;
  42547. if (msecs >= 0) {
  42548. item._idleTimeoutId = setTimeout(function onTimeout() {
  42549. if (item._onTimeout)
  42550. item._onTimeout();
  42551. }, msecs);
  42552. }
  42553. };
  42554. // setimmediate attaches itself to the global object
  42555. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42556. // On some exotic environments, it's not clear which object `setimmediate` was
  42557. // able to install onto. Search each possibility in the same order as the
  42558. // `setimmediate` library.
  42559. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42560. (typeof global !== "undefined" && global.setImmediate) ||
  42561. (this && this.setImmediate);
  42562. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42563. (typeof global !== "undefined" && global.clearImmediate) ||
  42564. (this && this.clearImmediate);
  42565. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42566. /***/ }),
  42567. /***/ "./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&":
  42568. /*!*******************************************************************************************************************************************************************************************************************!*\
  42569. !*** ./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& ***!
  42570. \*******************************************************************************************************************************************************************************************************************/
  42571. /*! exports provided: render, staticRenderFns */
  42572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42573. "use strict";
  42574. __webpack_require__.r(__webpack_exports__);
  42575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42577. var render = function() {
  42578. var _vm = this
  42579. var _h = _vm.$createElement
  42580. var _c = _vm._self._c || _h
  42581. return _vm._m(0)
  42582. }
  42583. var staticRenderFns = [
  42584. function() {
  42585. var _vm = this
  42586. var _h = _vm.$createElement
  42587. var _c = _vm._self._c || _h
  42588. return _c("div", { staticClass: "container" }, [
  42589. _c("div", { staticClass: "row justify-content-center" }, [
  42590. _c("div", { staticClass: "col-md-8" }, [
  42591. _c("div", { staticClass: "card" }, [
  42592. _c("div", { staticClass: "card-header" }, [
  42593. _vm._v("Example Component")
  42594. ]),
  42595. _vm._v(" "),
  42596. _c("div", { staticClass: "card-body" }, [
  42597. _vm._v(
  42598. "\n I'm an example component.\n "
  42599. )
  42600. ])
  42601. ])
  42602. ])
  42603. ])
  42604. ])
  42605. }
  42606. ]
  42607. render._withStripped = true
  42608. /***/ }),
  42609. /***/ "./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&":
  42610. /*!************************************************************************************************************************************************************************************************************!*\
  42611. !*** ./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& ***!
  42612. \************************************************************************************************************************************************************************************************************/
  42613. /*! exports provided: render, staticRenderFns */
  42614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42615. "use strict";
  42616. __webpack_require__.r(__webpack_exports__);
  42617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42619. var render = function() {
  42620. var _vm = this
  42621. var _h = _vm.$createElement
  42622. var _c = _vm._self._c || _h
  42623. return _c(
  42624. "div",
  42625. [
  42626. _c(
  42627. "modal",
  42628. {
  42629. attrs: {
  42630. id: "asseteditModal",
  42631. tabindex: "-1",
  42632. role: "dialog",
  42633. "aria-labelledby": "asseteditModalLabel"
  42634. }
  42635. },
  42636. [
  42637. _c(
  42638. "h5",
  42639. {
  42640. staticClass: "modal-title",
  42641. attrs: { slot: "header", id: "asseteditModalLabel" },
  42642. slot: "header"
  42643. },
  42644. [_vm._v("\n Edit Work Order Information\n ")]
  42645. ),
  42646. _vm._v(" "),
  42647. _c("div", { attrs: { slot: "body" }, slot: "body" }, [
  42648. _c("div", { staticClass: "form-group" }, [
  42649. _c("label", { attrs: { for: "manufacturer" } }, [
  42650. _vm._v("Manufacturer")
  42651. ]),
  42652. _vm._v(" "),
  42653. _c("input", {
  42654. directives: [
  42655. {
  42656. name: "model",
  42657. rawName: "v-model",
  42658. value: _vm.data.pcmanu,
  42659. expression: "data.pcmanu"
  42660. }
  42661. ],
  42662. staticClass: "form-control",
  42663. attrs: {
  42664. type: "text",
  42665. name: "manufacturer",
  42666. id: "manufacturer"
  42667. },
  42668. domProps: { value: _vm.data.pcmanu },
  42669. on: {
  42670. input: function($event) {
  42671. if ($event.target.composing) {
  42672. return
  42673. }
  42674. _vm.$set(_vm.data, "pcmanu", $event.target.value)
  42675. }
  42676. }
  42677. })
  42678. ]),
  42679. _vm._v(" "),
  42680. _c("div", { staticClass: "form-group" }, [
  42681. _c("label", { attrs: { for: "make" } }, [_vm._v("Make")]),
  42682. _vm._v(" "),
  42683. _c("input", {
  42684. directives: [
  42685. {
  42686. name: "model",
  42687. rawName: "v-model",
  42688. value: _vm.data.pcmake,
  42689. expression: "data.pcmake"
  42690. }
  42691. ],
  42692. staticClass: "form-control",
  42693. attrs: { type: "text", name: "make", id: "make" },
  42694. domProps: { value: _vm.data.pcmake },
  42695. on: {
  42696. input: function($event) {
  42697. if ($event.target.composing) {
  42698. return
  42699. }
  42700. _vm.$set(_vm.data, "pcmake", $event.target.value)
  42701. }
  42702. }
  42703. })
  42704. ]),
  42705. _vm._v(" "),
  42706. _c("div", { staticClass: "form-group" }, [
  42707. _c("label", { attrs: { for: "nickname" } }, [_vm._v("Nickname")]),
  42708. _vm._v(" "),
  42709. _c("input", {
  42710. directives: [
  42711. {
  42712. name: "model",
  42713. rawName: "v-model",
  42714. value: _vm.data.pcnickname,
  42715. expression: "data.pcnickname"
  42716. }
  42717. ],
  42718. staticClass: "form-control",
  42719. attrs: { type: "text", name: "nickname", id: "nickname" },
  42720. domProps: { value: _vm.data.pcnickname },
  42721. on: {
  42722. input: function($event) {
  42723. if ($event.target.composing) {
  42724. return
  42725. }
  42726. _vm.$set(_vm.data, "pcnickname", $event.target.value)
  42727. }
  42728. }
  42729. })
  42730. ]),
  42731. _vm._v(" "),
  42732. _c("div", { staticClass: "form-group" }, [
  42733. _c("label", { attrs: { for: "os" } }, [_vm._v("OS")]),
  42734. _vm._v(" "),
  42735. _c("input", {
  42736. directives: [
  42737. {
  42738. name: "model",
  42739. rawName: "v-model",
  42740. value: _vm.pcextra[2],
  42741. expression: "pcextra[2]"
  42742. }
  42743. ],
  42744. staticClass: "form-control",
  42745. attrs: { type: "text", name: "os", id: "os" },
  42746. domProps: { value: _vm.pcextra[2] },
  42747. on: {
  42748. input: function($event) {
  42749. if ($event.target.composing) {
  42750. return
  42751. }
  42752. _vm.$set(_vm.pcextra, 2, $event.target.value)
  42753. }
  42754. }
  42755. })
  42756. ]),
  42757. _vm._v(" "),
  42758. _c("div", { staticClass: "form-group" }, [
  42759. _c("label", { attrs: { for: "serial" } }, [
  42760. _vm._v("Serial Number")
  42761. ]),
  42762. _vm._v(" "),
  42763. _c("input", {
  42764. directives: [
  42765. {
  42766. name: "model",
  42767. rawName: "v-model",
  42768. value: _vm.pcextra[104],
  42769. expression: "pcextra[104]"
  42770. }
  42771. ],
  42772. staticClass: "form-control",
  42773. attrs: { type: "text", id: "serial", name: "serial" },
  42774. domProps: { value: _vm.pcextra[104] },
  42775. on: {
  42776. input: function($event) {
  42777. if ($event.target.composing) {
  42778. return
  42779. }
  42780. _vm.$set(_vm.pcextra, 104, $event.target.value)
  42781. }
  42782. }
  42783. })
  42784. ]),
  42785. _vm._v(" "),
  42786. _c("div", { staticClass: "form-group" }, [
  42787. _c("label", { attrs: { for: "cpu" } }, [_vm._v("CPU")]),
  42788. _vm._v(" "),
  42789. _c("input", {
  42790. directives: [
  42791. {
  42792. name: "model",
  42793. rawName: "v-model",
  42794. value: _vm.pcextra[101],
  42795. expression: "pcextra[101]"
  42796. }
  42797. ],
  42798. staticClass: "form-control",
  42799. attrs: { type: "text", id: "cpu", name: "cpu" },
  42800. domProps: { value: _vm.pcextra[101] },
  42801. on: {
  42802. input: function($event) {
  42803. if ($event.target.composing) {
  42804. return
  42805. }
  42806. _vm.$set(_vm.pcextra, 101, $event.target.value)
  42807. }
  42808. }
  42809. })
  42810. ]),
  42811. _vm._v(" "),
  42812. _c("div", { staticClass: "form-group" }, [
  42813. _c("label", { attrs: { for: "ram" } }, [_vm._v("RAM")]),
  42814. _vm._v(" "),
  42815. _c("input", {
  42816. directives: [
  42817. {
  42818. name: "model",
  42819. rawName: "v-model",
  42820. value: _vm.pcextra[100],
  42821. expression: "pcextra[100]"
  42822. }
  42823. ],
  42824. staticClass: "form-control",
  42825. attrs: { type: "text", name: "ram", id: "ram" },
  42826. domProps: { value: _vm.pcextra[100] },
  42827. on: {
  42828. input: function($event) {
  42829. if ($event.target.composing) {
  42830. return
  42831. }
  42832. _vm.$set(_vm.pcextra, 100, $event.target.value)
  42833. }
  42834. }
  42835. })
  42836. ]),
  42837. _vm._v(" "),
  42838. _c("div", { staticClass: "form-group" }, [
  42839. _c("label", { attrs: { for: "graphics" } }, [_vm._v("Graphics")]),
  42840. _vm._v(" "),
  42841. _c("input", {
  42842. directives: [
  42843. {
  42844. name: "model",
  42845. rawName: "v-model",
  42846. value: _vm.pcextra[4],
  42847. expression: "pcextra[4]"
  42848. }
  42849. ],
  42850. staticClass: "form-control",
  42851. attrs: { type: "text", name: "graphics", id: "grapics" },
  42852. domProps: { value: _vm.pcextra[4] },
  42853. on: {
  42854. input: function($event) {
  42855. if ($event.target.composing) {
  42856. return
  42857. }
  42858. _vm.$set(_vm.pcextra, 4, $event.target.value)
  42859. }
  42860. }
  42861. })
  42862. ])
  42863. ]),
  42864. _vm._v(" "),
  42865. _c("div", { attrs: { slot: "footer" }, slot: "footer" }, [
  42866. _c(
  42867. "button",
  42868. {
  42869. staticClass: "btn btn-secondary",
  42870. attrs: { type: "button", "data-dismiss": "modal" }
  42871. },
  42872. [_vm._v("Close")]
  42873. ),
  42874. _vm._v(" "),
  42875. _c(
  42876. "button",
  42877. {
  42878. staticClass: "btn btn-primary",
  42879. attrs: { type: "button" },
  42880. on: {
  42881. click: function($event) {
  42882. return _vm.updateAsset()
  42883. }
  42884. }
  42885. },
  42886. [_vm._v("Save")]
  42887. )
  42888. ])
  42889. ]
  42890. ),
  42891. _vm._v(" "),
  42892. _c("h4", { staticClass: "text-center" }, [
  42893. _vm._v(
  42894. _vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "
  42895. ),
  42896. _c("small", { staticClass: "text-muted" }, [
  42897. _vm._v(_vm._s(this.data.pcnickname))
  42898. ])
  42899. ]),
  42900. _vm._v(" "),
  42901. _c("p", [_vm._v("OS: " + _vm._s(this.pcextra[2]))]),
  42902. _vm._v(" "),
  42903. _c("p", [_vm._v("S/N: " + _vm._s(this.pcextra[104]))]),
  42904. _vm._v(" "),
  42905. _c("p", [_vm._v("CPU: " + _vm._s(this.pcextra[101]))]),
  42906. _vm._v(" "),
  42907. _c("p", [_vm._v("RAM: " + _vm._s(this.pcextra[100]))]),
  42908. _vm._v(" "),
  42909. _c("p", [_vm._v("Graphics: " + _vm._s(this.pcextra[4]))]),
  42910. _vm._v(" "),
  42911. _c(
  42912. "button",
  42913. {
  42914. staticClass: "btn btn-primary",
  42915. attrs: {
  42916. type: "button",
  42917. "data-toggle": "modal",
  42918. "data-target": "#asseteditModal"
  42919. }
  42920. },
  42921. [_vm._v("Edit")]
  42922. )
  42923. ],
  42924. 1
  42925. )
  42926. }
  42927. var staticRenderFns = []
  42928. render._withStripped = true
  42929. /***/ }),
  42930. /***/ "./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&":
  42931. /*!*************************************************************************************************************************************************************************************************************!*\
  42932. !*** ./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& ***!
  42933. \*************************************************************************************************************************************************************************************************************/
  42934. /*! exports provided: render, staticRenderFns */
  42935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42936. "use strict";
  42937. __webpack_require__.r(__webpack_exports__);
  42938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42940. var render = function() {
  42941. var _vm = this
  42942. var _h = _vm.$createElement
  42943. var _c = _vm._self._c || _h
  42944. return _c(
  42945. "div",
  42946. { staticClass: "bg-lightgray m-1 p-2 border rounded container-fluid" },
  42947. [
  42948. _c("div", { staticClass: "row no-gutters" }, [
  42949. _c("div", { staticClass: "h5 col-3 text-left" }, [
  42950. _vm._v(_vm._s(this.data.creddesc))
  42951. ]),
  42952. _vm._v(" "),
  42953. _c("div", { staticClass: "col-9 text-right" }, [
  42954. _vm._v(_vm._s(this.data.creddate))
  42955. ])
  42956. ]),
  42957. _vm._v(" "),
  42958. _c("div", { staticClass: "row" }, [
  42959. _c("div", { staticClass: "col-lg-9" }, [
  42960. _c("div", [
  42961. _vm._m(0),
  42962. _vm._v(" "),
  42963. _c("input", {
  42964. staticClass: "border-0 credential",
  42965. attrs: {
  42966. type: "text",
  42967. id: "username" + this.data.credid,
  42968. readonly: ""
  42969. },
  42970. domProps: { value: this.data.creduser }
  42971. }),
  42972. _vm._v(" "),
  42973. _c(
  42974. "button",
  42975. {
  42976. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42977. attrs: {
  42978. id: "btn-username" + this.data.credid,
  42979. "data-clipboard-target": "#username" + this.data.credid
  42980. }
  42981. },
  42982. [_c("i", { staticClass: "far fa-clone" })]
  42983. )
  42984. ]),
  42985. _vm._v(" "),
  42986. _c("div", [
  42987. _vm._m(1),
  42988. _vm._v(" "),
  42989. _c("input", {
  42990. staticClass: "border-0 credential",
  42991. attrs: {
  42992. type: "text",
  42993. id: "password" + this.data.credid,
  42994. readonly: ""
  42995. },
  42996. domProps: { value: this.data.credpass }
  42997. }),
  42998. _vm._v(" "),
  42999. _c(
  43000. "button",
  43001. {
  43002. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  43003. attrs: {
  43004. id: "btn-password" + this.data.credid,
  43005. "data-clipboard-target": "#password" + this.data.credid
  43006. }
  43007. },
  43008. [_c("i", { staticClass: "far fa-clone" })]
  43009. )
  43010. ])
  43011. ]),
  43012. _vm._v(" "),
  43013. _vm._m(2)
  43014. ])
  43015. ]
  43016. )
  43017. }
  43018. var staticRenderFns = [
  43019. function() {
  43020. var _vm = this
  43021. var _h = _vm.$createElement
  43022. var _c = _vm._self._c || _h
  43023. return _c("label", { attrs: { for: "username" } }, [
  43024. _c("i", { staticClass: "fas fa-fw fa-user" })
  43025. ])
  43026. },
  43027. function() {
  43028. var _vm = this
  43029. var _h = _vm.$createElement
  43030. var _c = _vm._self._c || _h
  43031. return _c("label", { attrs: { for: "password" } }, [
  43032. _c("i", { staticClass: "fas fa-fw fa-key" })
  43033. ])
  43034. },
  43035. function() {
  43036. var _vm = this
  43037. var _h = _vm.$createElement
  43038. var _c = _vm._self._c || _h
  43039. return _c(
  43040. "div",
  43041. {
  43042. staticClass: "btn-group col-lg-2 align-self-end w-25 w-lg-auto",
  43043. attrs: { role: "group", "aria-label": "Edit and Delete" }
  43044. },
  43045. [
  43046. _c(
  43047. "button",
  43048. {
  43049. staticClass: "btn btn-sm btn-secondary p-lg-1",
  43050. attrs: { type: "button" }
  43051. },
  43052. [_c("i", { staticClass: "fas fa-fw fa-edit" })]
  43053. ),
  43054. _vm._v(" "),
  43055. _c(
  43056. "button",
  43057. {
  43058. staticClass: "btn btn-sm btn-danger p-lg-1",
  43059. attrs: { type: "button" }
  43060. },
  43061. [_c("i", { staticClass: "fas fa-fw fa-trash-alt" })]
  43062. )
  43063. ]
  43064. )
  43065. }
  43066. ]
  43067. render._withStripped = true
  43068. /***/ }),
  43069. /***/ "./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&":
  43070. /*!********************************************************************************************************************************************************************************************************!*\
  43071. !*** ./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& ***!
  43072. \********************************************************************************************************************************************************************************************************/
  43073. /*! exports provided: render, staticRenderFns */
  43074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43075. "use strict";
  43076. __webpack_require__.r(__webpack_exports__);
  43077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43079. var render = function() {
  43080. var _vm = this
  43081. var _h = _vm.$createElement
  43082. var _c = _vm._self._c || _h
  43083. return _c("div", { staticClass: "modal fade" }, [
  43084. _c(
  43085. "div",
  43086. { staticClass: "modal-dialog modal-lg", attrs: { role: "document" } },
  43087. [
  43088. _c("div", { staticClass: "modal-content" }, [
  43089. _c(
  43090. "div",
  43091. { staticClass: "modal-header" },
  43092. [_vm._m(0), _vm._v(" "), _vm._t("header")],
  43093. 2
  43094. ),
  43095. _vm._v(" "),
  43096. _c("div", { staticClass: "modal-body" }, [_vm._t("body")], 2),
  43097. _vm._v(" "),
  43098. _c("div", { staticClass: "modal-footer" }, [_vm._t("footer")], 2)
  43099. ])
  43100. ]
  43101. )
  43102. ])
  43103. }
  43104. var staticRenderFns = [
  43105. function() {
  43106. var _vm = this
  43107. var _h = _vm.$createElement
  43108. var _c = _vm._self._c || _h
  43109. return _c(
  43110. "button",
  43111. {
  43112. staticClass: "close",
  43113. attrs: {
  43114. type: "button",
  43115. "data-dismiss": "modal",
  43116. "aria-label": "Close"
  43117. }
  43118. },
  43119. [_c("span", { attrs: { "aria-hidden": "true" } }, [_vm._v("×")])]
  43120. )
  43121. }
  43122. ]
  43123. render._withStripped = true
  43124. /***/ }),
  43125. /***/ "./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&":
  43126. /*!********************************************************************************************************************************************************************************************************!*\
  43127. !*** ./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& ***!
  43128. \********************************************************************************************************************************************************************************************************/
  43129. /*! exports provided: render, staticRenderFns */
  43130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43131. "use strict";
  43132. __webpack_require__.r(__webpack_exports__);
  43133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43135. var render = function() {
  43136. var _vm = this
  43137. var _h = _vm.$createElement
  43138. var _c = _vm._self._c || _h
  43139. return _c(
  43140. "ul",
  43141. { staticClass: "list-unstyled" },
  43142. _vm._l(this.notes, function(note) {
  43143. return _c(
  43144. "li",
  43145. { key: note.noteid, staticClass: "row no-gutters mb-2" },
  43146. [
  43147. _c("div", { staticClass: "col-md-1 d-flex flex-column mx-md-3" }, [
  43148. _c("div", { staticClass: "text-center p-0 m-0" }, [
  43149. _vm._v(_vm._s(note.noteuser))
  43150. ]),
  43151. _vm._v(" "),
  43152. _c(
  43153. "div",
  43154. { staticClass: "text-muted text-small text-center p-0 m-0" },
  43155. [_vm._v(_vm._s(_vm.getHRDate(note.notetime)))]
  43156. ),
  43157. _vm._v(" "),
  43158. _c(
  43159. "div",
  43160. { staticClass: "btn-group justify-content-center p-0 m-0" },
  43161. [
  43162. _vm.authusername === note.noteuser ||
  43163. _vm.authusername === "admin"
  43164. ? [
  43165. _vm._m(0, true),
  43166. _vm._v(" "),
  43167. _vm._m(1, true),
  43168. _vm._v(" "),
  43169. _vm._m(2, true)
  43170. ]
  43171. : _vm._e()
  43172. ],
  43173. 2
  43174. )
  43175. ]),
  43176. _vm._v(" "),
  43177. _c("div", { staticClass: "col-md-10" }, [
  43178. _c("div", { staticClass: "card m-2" }, [
  43179. _c("div", { staticClass: "card-body p-2" }, [
  43180. _vm._v(
  43181. "\n " +
  43182. _vm._s(note.thenote) +
  43183. "\n "
  43184. )
  43185. ])
  43186. ])
  43187. ])
  43188. ]
  43189. )
  43190. }),
  43191. 0
  43192. )
  43193. }
  43194. var staticRenderFns = [
  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: "fas fa-fw fa-edit" })
  43201. ])
  43202. },
  43203. function() {
  43204. var _vm = this
  43205. var _h = _vm.$createElement
  43206. var _c = _vm._self._c || _h
  43207. return _c("button", { staticClass: "btn btn-sm btn-danger m-1" }, [
  43208. _c("i", { staticClass: "fas fa-fw fa-trash-alt" })
  43209. ])
  43210. },
  43211. function() {
  43212. var _vm = this
  43213. var _h = _vm.$createElement
  43214. var _c = _vm._self._c || _h
  43215. return _c("button", { staticClass: "btn btn-sm btn-primary m-1" }, [
  43216. _c("i", { staticClass: "fa fa-fw fa-random" })
  43217. ])
  43218. }
  43219. ]
  43220. render._withStripped = true
  43221. /***/ }),
  43222. /***/ "./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&":
  43223. /*!*********************************************************************************************************************************************************************************************************!*\
  43224. !*** ./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& ***!
  43225. \*********************************************************************************************************************************************************************************************************/
  43226. /*! exports provided: render, staticRenderFns */
  43227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43228. "use strict";
  43229. __webpack_require__.r(__webpack_exports__);
  43230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43232. var render = function() {
  43233. var _vm = this
  43234. var _h = _vm.$createElement
  43235. var _c = _vm._self._c || _h
  43236. return _c(
  43237. "div",
  43238. [
  43239. _c(
  43240. "modal",
  43241. {
  43242. attrs: {
  43243. id: "workordereditModal",
  43244. tabindex: "-1",
  43245. role: "dialog",
  43246. "aria-labelledby": "workordereditModalLabel"
  43247. }
  43248. },
  43249. [
  43250. _c(
  43251. "h5",
  43252. {
  43253. staticClass: "modal-title",
  43254. attrs: { slot: "header", id: "workordereditModalLabel" },
  43255. slot: "header"
  43256. },
  43257. [_vm._v("\n Edit Work Order Information\n ")]
  43258. ),
  43259. _vm._v(" "),
  43260. _c("div", { attrs: { slot: "body" }, slot: "body" }, [
  43261. _c("div", { staticClass: "form-group" }, [
  43262. _c("label", { attrs: { for: "probdesc" } }, [
  43263. _vm._v("Problem Description")
  43264. ]),
  43265. _vm._v(" "),
  43266. _c("textarea", {
  43267. directives: [
  43268. {
  43269. name: "model",
  43270. rawName: "v-model",
  43271. value: _vm.data.probdesc,
  43272. expression: "data.probdesc"
  43273. }
  43274. ],
  43275. staticClass: "form-control",
  43276. attrs: { id: "probdesc", name: "probdesc" },
  43277. domProps: { value: _vm.data.probdesc },
  43278. on: {
  43279. input: function($event) {
  43280. if ($event.target.composing) {
  43281. return
  43282. }
  43283. _vm.$set(_vm.data, "probdesc", $event.target.value)
  43284. }
  43285. }
  43286. })
  43287. ]),
  43288. _vm._v(" "),
  43289. _c("div", { staticClass: "form-group" }, [
  43290. _c("label", { attrs: { for: "suggested" } }, [
  43291. _vm._v("Suggested Solution")
  43292. ]),
  43293. _vm._v(" "),
  43294. _c("textarea", {
  43295. directives: [
  43296. {
  43297. name: "model",
  43298. rawName: "v-model",
  43299. value: _vm.data.suggested,
  43300. expression: "data.suggested"
  43301. }
  43302. ],
  43303. staticClass: "form-control",
  43304. attrs: { id: "suggested", name: "suggested" },
  43305. domProps: { value: _vm.data.suggested },
  43306. on: {
  43307. input: function($event) {
  43308. if ($event.target.composing) {
  43309. return
  43310. }
  43311. _vm.$set(_vm.data, "suggested", $event.target.value)
  43312. }
  43313. }
  43314. })
  43315. ]),
  43316. _vm._v(" "),
  43317. _c("div", { staticClass: "form-group" }, [
  43318. _c("label", { attrs: { for: "storelist" } }, [_vm._v("Store")]),
  43319. _vm._v(" "),
  43320. _vm.storeList
  43321. ? _c(
  43322. "select",
  43323. {
  43324. directives: [
  43325. {
  43326. name: "model",
  43327. rawName: "v-model",
  43328. value: _vm.data.storeid,
  43329. expression: "data.storeid"
  43330. }
  43331. ],
  43332. staticClass: "form-control",
  43333. attrs: { name: "storelist", id: "storelist" },
  43334. on: {
  43335. change: function($event) {
  43336. var $$selectedVal = Array.prototype.filter
  43337. .call($event.target.options, function(o) {
  43338. return o.selected
  43339. })
  43340. .map(function(o) {
  43341. var val = "_value" in o ? o._value : o.value
  43342. return val
  43343. })
  43344. _vm.$set(
  43345. _vm.data,
  43346. "storeid",
  43347. $event.target.multiple
  43348. ? $$selectedVal
  43349. : $$selectedVal[0]
  43350. )
  43351. }
  43352. }
  43353. },
  43354. _vm._l(_vm.storeList.values(), function(store) {
  43355. return _c(
  43356. "option",
  43357. {
  43358. key: store.storeid,
  43359. domProps: { value: store.storeid }
  43360. },
  43361. [
  43362. _vm._v(
  43363. "\n " +
  43364. _vm._s(store.storesname) +
  43365. "\n "
  43366. )
  43367. ]
  43368. )
  43369. }),
  43370. 0
  43371. )
  43372. : _vm._e()
  43373. ])
  43374. ]),
  43375. _vm._v(" "),
  43376. _c("div", { attrs: { slot: "footer" }, slot: "footer" }, [
  43377. _c(
  43378. "button",
  43379. {
  43380. staticClass: "btn btn-secondary",
  43381. attrs: { type: "button", "data-dismiss": "modal" }
  43382. },
  43383. [_vm._v("Close")]
  43384. ),
  43385. _vm._v(" "),
  43386. _c(
  43387. "button",
  43388. {
  43389. staticClass: "btn btn-primary",
  43390. attrs: { type: "button" },
  43391. on: {
  43392. click: function($event) {
  43393. return _vm.updateWorkOrder()
  43394. }
  43395. }
  43396. },
  43397. [_vm._v("Save")]
  43398. )
  43399. ])
  43400. ]
  43401. ),
  43402. _vm._v(" "),
  43403. _c("p", [
  43404. _c("i", { staticClass: "fas fa-fw fa-info-circle" }),
  43405. _vm._v(" "),
  43406. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  43407. ]),
  43408. _vm._v(" "),
  43409. _c("p", [
  43410. _c("i", { staticClass: "far fa-fw fa-lightbulb" }),
  43411. _vm._v(" "),
  43412. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  43413. ]),
  43414. _vm._v(" "),
  43415. _c("p", [
  43416. _c("i", { staticClass: "fas fa-fw fa-paste" }),
  43417. _vm._v(" "),
  43418. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  43419. ]),
  43420. _vm._v(" "),
  43421. _c("p", [
  43422. _c("i", { staticClass: "fas fa-fw fa-building" }),
  43423. _vm._v(" "),
  43424. this.storeList
  43425. ? _c("span", [
  43426. _vm._v(_vm._s(this.storeList.get(this.data.storeid).storesname))
  43427. ])
  43428. : _vm._e()
  43429. ]),
  43430. _vm._v(" "),
  43431. _c("p", [
  43432. _c("i", { staticClass: "fas fa-fw fa-sign-in-alt" }),
  43433. _vm._v(" "),
  43434. _c(
  43435. "span",
  43436. {
  43437. staticClass: "dashed-underline",
  43438. attrs: {
  43439. "data-toggle": "tooltip",
  43440. "data-placement": "bottom",
  43441. title: this.getHRDate(this.data.dropdate)
  43442. }
  43443. },
  43444. [
  43445. _vm._v(
  43446. "\n " +
  43447. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  43448. " days ago\n "
  43449. )
  43450. ]
  43451. )
  43452. ]),
  43453. _vm._v(" "),
  43454. _c("p", [
  43455. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  43456. _vm._v(" "),
  43457. !this.isZero(this.data.pickupdate)
  43458. ? _c(
  43459. "span",
  43460. {
  43461. staticClass: "dashed-underline",
  43462. attrs: {
  43463. "data-toggle": "tooltip",
  43464. "data-placement": "bottom",
  43465. title: this.getHRDate(this.data.pickupdate)
  43466. }
  43467. },
  43468. [
  43469. _vm._v(
  43470. "\n " +
  43471. _vm._s(
  43472. Math.floor(this.daysSinceToday(this.data.pickupdate))
  43473. ) +
  43474. " days ago\n "
  43475. )
  43476. ]
  43477. )
  43478. : _vm._e()
  43479. ]),
  43480. _vm._v(" "),
  43481. _c(
  43482. "button",
  43483. {
  43484. staticClass: "btn btn-primary",
  43485. attrs: {
  43486. type: "button",
  43487. "data-toggle": "modal",
  43488. "data-target": "#workordereditModal"
  43489. }
  43490. },
  43491. [_vm._v("Edit")]
  43492. )
  43493. ],
  43494. 1
  43495. )
  43496. }
  43497. var staticRenderFns = []
  43498. render._withStripped = true
  43499. /***/ }),
  43500. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  43501. /*!********************************************************************!*\
  43502. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  43503. \********************************************************************/
  43504. /*! exports provided: default */
  43505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43506. "use strict";
  43507. __webpack_require__.r(__webpack_exports__);
  43508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  43509. /* globals __VUE_SSR_CONTEXT__ */
  43510. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  43511. // This module is a runtime utility for cleaner component module output and will
  43512. // be included in the final webpack user bundle.
  43513. function normalizeComponent (
  43514. scriptExports,
  43515. render,
  43516. staticRenderFns,
  43517. functionalTemplate,
  43518. injectStyles,
  43519. scopeId,
  43520. moduleIdentifier, /* server only */
  43521. shadowMode /* vue-cli only */
  43522. ) {
  43523. // Vue.extend constructor export interop
  43524. var options = typeof scriptExports === 'function'
  43525. ? scriptExports.options
  43526. : scriptExports
  43527. // render functions
  43528. if (render) {
  43529. options.render = render
  43530. options.staticRenderFns = staticRenderFns
  43531. options._compiled = true
  43532. }
  43533. // functional template
  43534. if (functionalTemplate) {
  43535. options.functional = true
  43536. }
  43537. // scopedId
  43538. if (scopeId) {
  43539. options._scopeId = 'data-v-' + scopeId
  43540. }
  43541. var hook
  43542. if (moduleIdentifier) { // server build
  43543. hook = function (context) {
  43544. // 2.3 injection
  43545. context =
  43546. context || // cached call
  43547. (this.$vnode && this.$vnode.ssrContext) || // stateful
  43548. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  43549. // 2.2 with runInNewContext: true
  43550. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  43551. context = __VUE_SSR_CONTEXT__
  43552. }
  43553. // inject component styles
  43554. if (injectStyles) {
  43555. injectStyles.call(this, context)
  43556. }
  43557. // register component module identifier for async chunk inferrence
  43558. if (context && context._registeredComponents) {
  43559. context._registeredComponents.add(moduleIdentifier)
  43560. }
  43561. }
  43562. // used by ssr in case component is cached and beforeCreate
  43563. // never gets called
  43564. options._ssrRegister = hook
  43565. } else if (injectStyles) {
  43566. hook = shadowMode
  43567. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  43568. : injectStyles
  43569. }
  43570. if (hook) {
  43571. if (options.functional) {
  43572. // for template-only hot-reload because in that case the render fn doesn't
  43573. // go through the normalizer
  43574. options._injectStyles = hook
  43575. // register for functioal component in vue file
  43576. var originalRender = options.render
  43577. options.render = function renderWithStyleInjection (h, context) {
  43578. hook.call(context)
  43579. return originalRender(h, context)
  43580. }
  43581. } else {
  43582. // inject component registration as beforeCreate hook
  43583. var existing = options.beforeCreate
  43584. options.beforeCreate = existing
  43585. ? [].concat(existing, hook)
  43586. : [hook]
  43587. }
  43588. }
  43589. return {
  43590. exports: scriptExports,
  43591. options: options
  43592. }
  43593. }
  43594. /***/ }),
  43595. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  43596. /*!*************************************************!*\
  43597. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  43598. \*************************************************/
  43599. /*! no static exports found */
  43600. /***/ (function(module, exports, __webpack_require__) {
  43601. "use strict";
  43602. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  43603. * Vue.js v2.6.11
  43604. * (c) 2014-2019 Evan You
  43605. * Released under the MIT License.
  43606. */
  43607. /* */
  43608. var emptyObject = Object.freeze({});
  43609. // These helpers produce better VM code in JS engines due to their
  43610. // explicitness and function inlining.
  43611. function isUndef (v) {
  43612. return v === undefined || v === null
  43613. }
  43614. function isDef (v) {
  43615. return v !== undefined && v !== null
  43616. }
  43617. function isTrue (v) {
  43618. return v === true
  43619. }
  43620. function isFalse (v) {
  43621. return v === false
  43622. }
  43623. /**
  43624. * Check if value is primitive.
  43625. */
  43626. function isPrimitive (value) {
  43627. return (
  43628. typeof value === 'string' ||
  43629. typeof value === 'number' ||
  43630. // $flow-disable-line
  43631. typeof value === 'symbol' ||
  43632. typeof value === 'boolean'
  43633. )
  43634. }
  43635. /**
  43636. * Quick object check - this is primarily used to tell
  43637. * Objects from primitive values when we know the value
  43638. * is a JSON-compliant type.
  43639. */
  43640. function isObject (obj) {
  43641. return obj !== null && typeof obj === 'object'
  43642. }
  43643. /**
  43644. * Get the raw type string of a value, e.g., [object Object].
  43645. */
  43646. var _toString = Object.prototype.toString;
  43647. function toRawType (value) {
  43648. return _toString.call(value).slice(8, -1)
  43649. }
  43650. /**
  43651. * Strict object type check. Only returns true
  43652. * for plain JavaScript objects.
  43653. */
  43654. function isPlainObject (obj) {
  43655. return _toString.call(obj) === '[object Object]'
  43656. }
  43657. function isRegExp (v) {
  43658. return _toString.call(v) === '[object RegExp]'
  43659. }
  43660. /**
  43661. * Check if val is a valid array index.
  43662. */
  43663. function isValidArrayIndex (val) {
  43664. var n = parseFloat(String(val));
  43665. return n >= 0 && Math.floor(n) === n && isFinite(val)
  43666. }
  43667. function isPromise (val) {
  43668. return (
  43669. isDef(val) &&
  43670. typeof val.then === 'function' &&
  43671. typeof val.catch === 'function'
  43672. )
  43673. }
  43674. /**
  43675. * Convert a value to a string that is actually rendered.
  43676. */
  43677. function toString (val) {
  43678. return val == null
  43679. ? ''
  43680. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  43681. ? JSON.stringify(val, null, 2)
  43682. : String(val)
  43683. }
  43684. /**
  43685. * Convert an input value to a number for persistence.
  43686. * If the conversion fails, return original string.
  43687. */
  43688. function toNumber (val) {
  43689. var n = parseFloat(val);
  43690. return isNaN(n) ? val : n
  43691. }
  43692. /**
  43693. * Make a map and return a function for checking if a key
  43694. * is in that map.
  43695. */
  43696. function makeMap (
  43697. str,
  43698. expectsLowerCase
  43699. ) {
  43700. var map = Object.create(null);
  43701. var list = str.split(',');
  43702. for (var i = 0; i < list.length; i++) {
  43703. map[list[i]] = true;
  43704. }
  43705. return expectsLowerCase
  43706. ? function (val) { return map[val.toLowerCase()]; }
  43707. : function (val) { return map[val]; }
  43708. }
  43709. /**
  43710. * Check if a tag is a built-in tag.
  43711. */
  43712. var isBuiltInTag = makeMap('slot,component', true);
  43713. /**
  43714. * Check if an attribute is a reserved attribute.
  43715. */
  43716. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  43717. /**
  43718. * Remove an item from an array.
  43719. */
  43720. function remove (arr, item) {
  43721. if (arr.length) {
  43722. var index = arr.indexOf(item);
  43723. if (index > -1) {
  43724. return arr.splice(index, 1)
  43725. }
  43726. }
  43727. }
  43728. /**
  43729. * Check whether an object has the property.
  43730. */
  43731. var hasOwnProperty = Object.prototype.hasOwnProperty;
  43732. function hasOwn (obj, key) {
  43733. return hasOwnProperty.call(obj, key)
  43734. }
  43735. /**
  43736. * Create a cached version of a pure function.
  43737. */
  43738. function cached (fn) {
  43739. var cache = Object.create(null);
  43740. return (function cachedFn (str) {
  43741. var hit = cache[str];
  43742. return hit || (cache[str] = fn(str))
  43743. })
  43744. }
  43745. /**
  43746. * Camelize a hyphen-delimited string.
  43747. */
  43748. var camelizeRE = /-(\w)/g;
  43749. var camelize = cached(function (str) {
  43750. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  43751. });
  43752. /**
  43753. * Capitalize a string.
  43754. */
  43755. var capitalize = cached(function (str) {
  43756. return str.charAt(0).toUpperCase() + str.slice(1)
  43757. });
  43758. /**
  43759. * Hyphenate a camelCase string.
  43760. */
  43761. var hyphenateRE = /\B([A-Z])/g;
  43762. var hyphenate = cached(function (str) {
  43763. return str.replace(hyphenateRE, '-$1').toLowerCase()
  43764. });
  43765. /**
  43766. * Simple bind polyfill for environments that do not support it,
  43767. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  43768. * since native bind is now performant enough in most browsers.
  43769. * But removing it would mean breaking code that was able to run in
  43770. * PhantomJS 1.x, so this must be kept for backward compatibility.
  43771. */
  43772. /* istanbul ignore next */
  43773. function polyfillBind (fn, ctx) {
  43774. function boundFn (a) {
  43775. var l = arguments.length;
  43776. return l
  43777. ? l > 1
  43778. ? fn.apply(ctx, arguments)
  43779. : fn.call(ctx, a)
  43780. : fn.call(ctx)
  43781. }
  43782. boundFn._length = fn.length;
  43783. return boundFn
  43784. }
  43785. function nativeBind (fn, ctx) {
  43786. return fn.bind(ctx)
  43787. }
  43788. var bind = Function.prototype.bind
  43789. ? nativeBind
  43790. : polyfillBind;
  43791. /**
  43792. * Convert an Array-like object to a real Array.
  43793. */
  43794. function toArray (list, start) {
  43795. start = start || 0;
  43796. var i = list.length - start;
  43797. var ret = new Array(i);
  43798. while (i--) {
  43799. ret[i] = list[i + start];
  43800. }
  43801. return ret
  43802. }
  43803. /**
  43804. * Mix properties into target object.
  43805. */
  43806. function extend (to, _from) {
  43807. for (var key in _from) {
  43808. to[key] = _from[key];
  43809. }
  43810. return to
  43811. }
  43812. /**
  43813. * Merge an Array of Objects into a single Object.
  43814. */
  43815. function toObject (arr) {
  43816. var res = {};
  43817. for (var i = 0; i < arr.length; i++) {
  43818. if (arr[i]) {
  43819. extend(res, arr[i]);
  43820. }
  43821. }
  43822. return res
  43823. }
  43824. /* eslint-disable no-unused-vars */
  43825. /**
  43826. * Perform no operation.
  43827. * Stubbing args to make Flow happy without leaving useless transpiled code
  43828. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  43829. */
  43830. function noop (a, b, c) {}
  43831. /**
  43832. * Always return false.
  43833. */
  43834. var no = function (a, b, c) { return false; };
  43835. /* eslint-enable no-unused-vars */
  43836. /**
  43837. * Return the same value.
  43838. */
  43839. var identity = function (_) { return _; };
  43840. /**
  43841. * Generate a string containing static keys from compiler modules.
  43842. */
  43843. function genStaticKeys (modules) {
  43844. return modules.reduce(function (keys, m) {
  43845. return keys.concat(m.staticKeys || [])
  43846. }, []).join(',')
  43847. }
  43848. /**
  43849. * Check if two values are loosely equal - that is,
  43850. * if they are plain objects, do they have the same shape?
  43851. */
  43852. function looseEqual (a, b) {
  43853. if (a === b) { return true }
  43854. var isObjectA = isObject(a);
  43855. var isObjectB = isObject(b);
  43856. if (isObjectA && isObjectB) {
  43857. try {
  43858. var isArrayA = Array.isArray(a);
  43859. var isArrayB = Array.isArray(b);
  43860. if (isArrayA && isArrayB) {
  43861. return a.length === b.length && a.every(function (e, i) {
  43862. return looseEqual(e, b[i])
  43863. })
  43864. } else if (a instanceof Date && b instanceof Date) {
  43865. return a.getTime() === b.getTime()
  43866. } else if (!isArrayA && !isArrayB) {
  43867. var keysA = Object.keys(a);
  43868. var keysB = Object.keys(b);
  43869. return keysA.length === keysB.length && keysA.every(function (key) {
  43870. return looseEqual(a[key], b[key])
  43871. })
  43872. } else {
  43873. /* istanbul ignore next */
  43874. return false
  43875. }
  43876. } catch (e) {
  43877. /* istanbul ignore next */
  43878. return false
  43879. }
  43880. } else if (!isObjectA && !isObjectB) {
  43881. return String(a) === String(b)
  43882. } else {
  43883. return false
  43884. }
  43885. }
  43886. /**
  43887. * Return the first index at which a loosely equal value can be
  43888. * found in the array (if value is a plain object, the array must
  43889. * contain an object of the same shape), or -1 if it is not present.
  43890. */
  43891. function looseIndexOf (arr, val) {
  43892. for (var i = 0; i < arr.length; i++) {
  43893. if (looseEqual(arr[i], val)) { return i }
  43894. }
  43895. return -1
  43896. }
  43897. /**
  43898. * Ensure a function is called only once.
  43899. */
  43900. function once (fn) {
  43901. var called = false;
  43902. return function () {
  43903. if (!called) {
  43904. called = true;
  43905. fn.apply(this, arguments);
  43906. }
  43907. }
  43908. }
  43909. var SSR_ATTR = 'data-server-rendered';
  43910. var ASSET_TYPES = [
  43911. 'component',
  43912. 'directive',
  43913. 'filter'
  43914. ];
  43915. var LIFECYCLE_HOOKS = [
  43916. 'beforeCreate',
  43917. 'created',
  43918. 'beforeMount',
  43919. 'mounted',
  43920. 'beforeUpdate',
  43921. 'updated',
  43922. 'beforeDestroy',
  43923. 'destroyed',
  43924. 'activated',
  43925. 'deactivated',
  43926. 'errorCaptured',
  43927. 'serverPrefetch'
  43928. ];
  43929. /* */
  43930. var config = ({
  43931. /**
  43932. * Option merge strategies (used in core/util/options)
  43933. */
  43934. // $flow-disable-line
  43935. optionMergeStrategies: Object.create(null),
  43936. /**
  43937. * Whether to suppress warnings.
  43938. */
  43939. silent: false,
  43940. /**
  43941. * Show production mode tip message on boot?
  43942. */
  43943. productionTip: "development" !== 'production',
  43944. /**
  43945. * Whether to enable devtools
  43946. */
  43947. devtools: "development" !== 'production',
  43948. /**
  43949. * Whether to record perf
  43950. */
  43951. performance: false,
  43952. /**
  43953. * Error handler for watcher errors
  43954. */
  43955. errorHandler: null,
  43956. /**
  43957. * Warn handler for watcher warns
  43958. */
  43959. warnHandler: null,
  43960. /**
  43961. * Ignore certain custom elements
  43962. */
  43963. ignoredElements: [],
  43964. /**
  43965. * Custom user key aliases for v-on
  43966. */
  43967. // $flow-disable-line
  43968. keyCodes: Object.create(null),
  43969. /**
  43970. * Check if a tag is reserved so that it cannot be registered as a
  43971. * component. This is platform-dependent and may be overwritten.
  43972. */
  43973. isReservedTag: no,
  43974. /**
  43975. * Check if an attribute is reserved so that it cannot be used as a component
  43976. * prop. This is platform-dependent and may be overwritten.
  43977. */
  43978. isReservedAttr: no,
  43979. /**
  43980. * Check if a tag is an unknown element.
  43981. * Platform-dependent.
  43982. */
  43983. isUnknownElement: no,
  43984. /**
  43985. * Get the namespace of an element
  43986. */
  43987. getTagNamespace: noop,
  43988. /**
  43989. * Parse the real tag name for the specific platform.
  43990. */
  43991. parsePlatformTagName: identity,
  43992. /**
  43993. * Check if an attribute must be bound using property, e.g. value
  43994. * Platform-dependent.
  43995. */
  43996. mustUseProp: no,
  43997. /**
  43998. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  43999. * This will significantly reduce performance if set to false.
  44000. */
  44001. async: true,
  44002. /**
  44003. * Exposed for legacy reasons
  44004. */
  44005. _lifecycleHooks: LIFECYCLE_HOOKS
  44006. });
  44007. /* */
  44008. /**
  44009. * unicode letters used for parsing html tags, component names and property paths.
  44010. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  44011. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  44012. */
  44013. 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/;
  44014. /**
  44015. * Check if a string starts with $ or _
  44016. */
  44017. function isReserved (str) {
  44018. var c = (str + '').charCodeAt(0);
  44019. return c === 0x24 || c === 0x5F
  44020. }
  44021. /**
  44022. * Define a property.
  44023. */
  44024. function def (obj, key, val, enumerable) {
  44025. Object.defineProperty(obj, key, {
  44026. value: val,
  44027. enumerable: !!enumerable,
  44028. writable: true,
  44029. configurable: true
  44030. });
  44031. }
  44032. /**
  44033. * Parse simple path.
  44034. */
  44035. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  44036. function parsePath (path) {
  44037. if (bailRE.test(path)) {
  44038. return
  44039. }
  44040. var segments = path.split('.');
  44041. return function (obj) {
  44042. for (var i = 0; i < segments.length; i++) {
  44043. if (!obj) { return }
  44044. obj = obj[segments[i]];
  44045. }
  44046. return obj
  44047. }
  44048. }
  44049. /* */
  44050. // can we use __proto__?
  44051. var hasProto = '__proto__' in {};
  44052. // Browser environment sniffing
  44053. var inBrowser = typeof window !== 'undefined';
  44054. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  44055. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  44056. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  44057. var isIE = UA && /msie|trident/.test(UA);
  44058. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  44059. var isEdge = UA && UA.indexOf('edge/') > 0;
  44060. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  44061. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  44062. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  44063. var isPhantomJS = UA && /phantomjs/.test(UA);
  44064. var isFF = UA && UA.match(/firefox\/(\d+)/);
  44065. // Firefox has a "watch" function on Object.prototype...
  44066. var nativeWatch = ({}).watch;
  44067. var supportsPassive = false;
  44068. if (inBrowser) {
  44069. try {
  44070. var opts = {};
  44071. Object.defineProperty(opts, 'passive', ({
  44072. get: function get () {
  44073. /* istanbul ignore next */
  44074. supportsPassive = true;
  44075. }
  44076. })); // https://github.com/facebook/flow/issues/285
  44077. window.addEventListener('test-passive', null, opts);
  44078. } catch (e) {}
  44079. }
  44080. // this needs to be lazy-evaled because vue may be required before
  44081. // vue-server-renderer can set VUE_ENV
  44082. var _isServer;
  44083. var isServerRendering = function () {
  44084. if (_isServer === undefined) {
  44085. /* istanbul ignore if */
  44086. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  44087. // detect presence of vue-server-renderer and avoid
  44088. // Webpack shimming the process
  44089. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  44090. } else {
  44091. _isServer = false;
  44092. }
  44093. }
  44094. return _isServer
  44095. };
  44096. // detect devtools
  44097. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  44098. /* istanbul ignore next */
  44099. function isNative (Ctor) {
  44100. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  44101. }
  44102. var hasSymbol =
  44103. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  44104. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  44105. var _Set;
  44106. /* istanbul ignore if */ // $flow-disable-line
  44107. if (typeof Set !== 'undefined' && isNative(Set)) {
  44108. // use native Set when available.
  44109. _Set = Set;
  44110. } else {
  44111. // a non-standard Set polyfill that only works with primitive keys.
  44112. _Set = /*@__PURE__*/(function () {
  44113. function Set () {
  44114. this.set = Object.create(null);
  44115. }
  44116. Set.prototype.has = function has (key) {
  44117. return this.set[key] === true
  44118. };
  44119. Set.prototype.add = function add (key) {
  44120. this.set[key] = true;
  44121. };
  44122. Set.prototype.clear = function clear () {
  44123. this.set = Object.create(null);
  44124. };
  44125. return Set;
  44126. }());
  44127. }
  44128. /* */
  44129. var warn = noop;
  44130. var tip = noop;
  44131. var generateComponentTrace = (noop); // work around flow check
  44132. var formatComponentName = (noop);
  44133. {
  44134. var hasConsole = typeof console !== 'undefined';
  44135. var classifyRE = /(?:^|[-_])(\w)/g;
  44136. var classify = function (str) { return str
  44137. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  44138. .replace(/[-_]/g, ''); };
  44139. warn = function (msg, vm) {
  44140. var trace = vm ? generateComponentTrace(vm) : '';
  44141. if (config.warnHandler) {
  44142. config.warnHandler.call(null, msg, vm, trace);
  44143. } else if (hasConsole && (!config.silent)) {
  44144. console.error(("[Vue warn]: " + msg + trace));
  44145. }
  44146. };
  44147. tip = function (msg, vm) {
  44148. if (hasConsole && (!config.silent)) {
  44149. console.warn("[Vue tip]: " + msg + (
  44150. vm ? generateComponentTrace(vm) : ''
  44151. ));
  44152. }
  44153. };
  44154. formatComponentName = function (vm, includeFile) {
  44155. if (vm.$root === vm) {
  44156. return '<Root>'
  44157. }
  44158. var options = typeof vm === 'function' && vm.cid != null
  44159. ? vm.options
  44160. : vm._isVue
  44161. ? vm.$options || vm.constructor.options
  44162. : vm;
  44163. var name = options.name || options._componentTag;
  44164. var file = options.__file;
  44165. if (!name && file) {
  44166. var match = file.match(/([^/\\]+)\.vue$/);
  44167. name = match && match[1];
  44168. }
  44169. return (
  44170. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  44171. (file && includeFile !== false ? (" at " + file) : '')
  44172. )
  44173. };
  44174. var repeat = function (str, n) {
  44175. var res = '';
  44176. while (n) {
  44177. if (n % 2 === 1) { res += str; }
  44178. if (n > 1) { str += str; }
  44179. n >>= 1;
  44180. }
  44181. return res
  44182. };
  44183. generateComponentTrace = function (vm) {
  44184. if (vm._isVue && vm.$parent) {
  44185. var tree = [];
  44186. var currentRecursiveSequence = 0;
  44187. while (vm) {
  44188. if (tree.length > 0) {
  44189. var last = tree[tree.length - 1];
  44190. if (last.constructor === vm.constructor) {
  44191. currentRecursiveSequence++;
  44192. vm = vm.$parent;
  44193. continue
  44194. } else if (currentRecursiveSequence > 0) {
  44195. tree[tree.length - 1] = [last, currentRecursiveSequence];
  44196. currentRecursiveSequence = 0;
  44197. }
  44198. }
  44199. tree.push(vm);
  44200. vm = vm.$parent;
  44201. }
  44202. return '\n\nfound in\n\n' + tree
  44203. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  44204. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  44205. : formatComponentName(vm))); })
  44206. .join('\n')
  44207. } else {
  44208. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  44209. }
  44210. };
  44211. }
  44212. /* */
  44213. var uid = 0;
  44214. /**
  44215. * A dep is an observable that can have multiple
  44216. * directives subscribing to it.
  44217. */
  44218. var Dep = function Dep () {
  44219. this.id = uid++;
  44220. this.subs = [];
  44221. };
  44222. Dep.prototype.addSub = function addSub (sub) {
  44223. this.subs.push(sub);
  44224. };
  44225. Dep.prototype.removeSub = function removeSub (sub) {
  44226. remove(this.subs, sub);
  44227. };
  44228. Dep.prototype.depend = function depend () {
  44229. if (Dep.target) {
  44230. Dep.target.addDep(this);
  44231. }
  44232. };
  44233. Dep.prototype.notify = function notify () {
  44234. // stabilize the subscriber list first
  44235. var subs = this.subs.slice();
  44236. if (!config.async) {
  44237. // subs aren't sorted in scheduler if not running async
  44238. // we need to sort them now to make sure they fire in correct
  44239. // order
  44240. subs.sort(function (a, b) { return a.id - b.id; });
  44241. }
  44242. for (var i = 0, l = subs.length; i < l; i++) {
  44243. subs[i].update();
  44244. }
  44245. };
  44246. // The current target watcher being evaluated.
  44247. // This is globally unique because only one watcher
  44248. // can be evaluated at a time.
  44249. Dep.target = null;
  44250. var targetStack = [];
  44251. function pushTarget (target) {
  44252. targetStack.push(target);
  44253. Dep.target = target;
  44254. }
  44255. function popTarget () {
  44256. targetStack.pop();
  44257. Dep.target = targetStack[targetStack.length - 1];
  44258. }
  44259. /* */
  44260. var VNode = function VNode (
  44261. tag,
  44262. data,
  44263. children,
  44264. text,
  44265. elm,
  44266. context,
  44267. componentOptions,
  44268. asyncFactory
  44269. ) {
  44270. this.tag = tag;
  44271. this.data = data;
  44272. this.children = children;
  44273. this.text = text;
  44274. this.elm = elm;
  44275. this.ns = undefined;
  44276. this.context = context;
  44277. this.fnContext = undefined;
  44278. this.fnOptions = undefined;
  44279. this.fnScopeId = undefined;
  44280. this.key = data && data.key;
  44281. this.componentOptions = componentOptions;
  44282. this.componentInstance = undefined;
  44283. this.parent = undefined;
  44284. this.raw = false;
  44285. this.isStatic = false;
  44286. this.isRootInsert = true;
  44287. this.isComment = false;
  44288. this.isCloned = false;
  44289. this.isOnce = false;
  44290. this.asyncFactory = asyncFactory;
  44291. this.asyncMeta = undefined;
  44292. this.isAsyncPlaceholder = false;
  44293. };
  44294. var prototypeAccessors = { child: { configurable: true } };
  44295. // DEPRECATED: alias for componentInstance for backwards compat.
  44296. /* istanbul ignore next */
  44297. prototypeAccessors.child.get = function () {
  44298. return this.componentInstance
  44299. };
  44300. Object.defineProperties( VNode.prototype, prototypeAccessors );
  44301. var createEmptyVNode = function (text) {
  44302. if ( text === void 0 ) text = '';
  44303. var node = new VNode();
  44304. node.text = text;
  44305. node.isComment = true;
  44306. return node
  44307. };
  44308. function createTextVNode (val) {
  44309. return new VNode(undefined, undefined, undefined, String(val))
  44310. }
  44311. // optimized shallow clone
  44312. // used for static nodes and slot nodes because they may be reused across
  44313. // multiple renders, cloning them avoids errors when DOM manipulations rely
  44314. // on their elm reference.
  44315. function cloneVNode (vnode) {
  44316. var cloned = new VNode(
  44317. vnode.tag,
  44318. vnode.data,
  44319. // #7975
  44320. // clone children array to avoid mutating original in case of cloning
  44321. // a child.
  44322. vnode.children && vnode.children.slice(),
  44323. vnode.text,
  44324. vnode.elm,
  44325. vnode.context,
  44326. vnode.componentOptions,
  44327. vnode.asyncFactory
  44328. );
  44329. cloned.ns = vnode.ns;
  44330. cloned.isStatic = vnode.isStatic;
  44331. cloned.key = vnode.key;
  44332. cloned.isComment = vnode.isComment;
  44333. cloned.fnContext = vnode.fnContext;
  44334. cloned.fnOptions = vnode.fnOptions;
  44335. cloned.fnScopeId = vnode.fnScopeId;
  44336. cloned.asyncMeta = vnode.asyncMeta;
  44337. cloned.isCloned = true;
  44338. return cloned
  44339. }
  44340. /*
  44341. * not type checking this file because flow doesn't play well with
  44342. * dynamically accessing methods on Array prototype
  44343. */
  44344. var arrayProto = Array.prototype;
  44345. var arrayMethods = Object.create(arrayProto);
  44346. var methodsToPatch = [
  44347. 'push',
  44348. 'pop',
  44349. 'shift',
  44350. 'unshift',
  44351. 'splice',
  44352. 'sort',
  44353. 'reverse'
  44354. ];
  44355. /**
  44356. * Intercept mutating methods and emit events
  44357. */
  44358. methodsToPatch.forEach(function (method) {
  44359. // cache original method
  44360. var original = arrayProto[method];
  44361. def(arrayMethods, method, function mutator () {
  44362. var args = [], len = arguments.length;
  44363. while ( len-- ) args[ len ] = arguments[ len ];
  44364. var result = original.apply(this, args);
  44365. var ob = this.__ob__;
  44366. var inserted;
  44367. switch (method) {
  44368. case 'push':
  44369. case 'unshift':
  44370. inserted = args;
  44371. break
  44372. case 'splice':
  44373. inserted = args.slice(2);
  44374. break
  44375. }
  44376. if (inserted) { ob.observeArray(inserted); }
  44377. // notify change
  44378. ob.dep.notify();
  44379. return result
  44380. });
  44381. });
  44382. /* */
  44383. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  44384. /**
  44385. * In some cases we may want to disable observation inside a component's
  44386. * update computation.
  44387. */
  44388. var shouldObserve = true;
  44389. function toggleObserving (value) {
  44390. shouldObserve = value;
  44391. }
  44392. /**
  44393. * Observer class that is attached to each observed
  44394. * object. Once attached, the observer converts the target
  44395. * object's property keys into getter/setters that
  44396. * collect dependencies and dispatch updates.
  44397. */
  44398. var Observer = function Observer (value) {
  44399. this.value = value;
  44400. this.dep = new Dep();
  44401. this.vmCount = 0;
  44402. def(value, '__ob__', this);
  44403. if (Array.isArray(value)) {
  44404. if (hasProto) {
  44405. protoAugment(value, arrayMethods);
  44406. } else {
  44407. copyAugment(value, arrayMethods, arrayKeys);
  44408. }
  44409. this.observeArray(value);
  44410. } else {
  44411. this.walk(value);
  44412. }
  44413. };
  44414. /**
  44415. * Walk through all properties and convert them into
  44416. * getter/setters. This method should only be called when
  44417. * value type is Object.
  44418. */
  44419. Observer.prototype.walk = function walk (obj) {
  44420. var keys = Object.keys(obj);
  44421. for (var i = 0; i < keys.length; i++) {
  44422. defineReactive$$1(obj, keys[i]);
  44423. }
  44424. };
  44425. /**
  44426. * Observe a list of Array items.
  44427. */
  44428. Observer.prototype.observeArray = function observeArray (items) {
  44429. for (var i = 0, l = items.length; i < l; i++) {
  44430. observe(items[i]);
  44431. }
  44432. };
  44433. // helpers
  44434. /**
  44435. * Augment a target Object or Array by intercepting
  44436. * the prototype chain using __proto__
  44437. */
  44438. function protoAugment (target, src) {
  44439. /* eslint-disable no-proto */
  44440. target.__proto__ = src;
  44441. /* eslint-enable no-proto */
  44442. }
  44443. /**
  44444. * Augment a target Object or Array by defining
  44445. * hidden properties.
  44446. */
  44447. /* istanbul ignore next */
  44448. function copyAugment (target, src, keys) {
  44449. for (var i = 0, l = keys.length; i < l; i++) {
  44450. var key = keys[i];
  44451. def(target, key, src[key]);
  44452. }
  44453. }
  44454. /**
  44455. * Attempt to create an observer instance for a value,
  44456. * returns the new observer if successfully observed,
  44457. * or the existing observer if the value already has one.
  44458. */
  44459. function observe (value, asRootData) {
  44460. if (!isObject(value) || value instanceof VNode) {
  44461. return
  44462. }
  44463. var ob;
  44464. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  44465. ob = value.__ob__;
  44466. } else if (
  44467. shouldObserve &&
  44468. !isServerRendering() &&
  44469. (Array.isArray(value) || isPlainObject(value)) &&
  44470. Object.isExtensible(value) &&
  44471. !value._isVue
  44472. ) {
  44473. ob = new Observer(value);
  44474. }
  44475. if (asRootData && ob) {
  44476. ob.vmCount++;
  44477. }
  44478. return ob
  44479. }
  44480. /**
  44481. * Define a reactive property on an Object.
  44482. */
  44483. function defineReactive$$1 (
  44484. obj,
  44485. key,
  44486. val,
  44487. customSetter,
  44488. shallow
  44489. ) {
  44490. var dep = new Dep();
  44491. var property = Object.getOwnPropertyDescriptor(obj, key);
  44492. if (property && property.configurable === false) {
  44493. return
  44494. }
  44495. // cater for pre-defined getter/setters
  44496. var getter = property && property.get;
  44497. var setter = property && property.set;
  44498. if ((!getter || setter) && arguments.length === 2) {
  44499. val = obj[key];
  44500. }
  44501. var childOb = !shallow && observe(val);
  44502. Object.defineProperty(obj, key, {
  44503. enumerable: true,
  44504. configurable: true,
  44505. get: function reactiveGetter () {
  44506. var value = getter ? getter.call(obj) : val;
  44507. if (Dep.target) {
  44508. dep.depend();
  44509. if (childOb) {
  44510. childOb.dep.depend();
  44511. if (Array.isArray(value)) {
  44512. dependArray(value);
  44513. }
  44514. }
  44515. }
  44516. return value
  44517. },
  44518. set: function reactiveSetter (newVal) {
  44519. var value = getter ? getter.call(obj) : val;
  44520. /* eslint-disable no-self-compare */
  44521. if (newVal === value || (newVal !== newVal && value !== value)) {
  44522. return
  44523. }
  44524. /* eslint-enable no-self-compare */
  44525. if (customSetter) {
  44526. customSetter();
  44527. }
  44528. // #7981: for accessor properties without setter
  44529. if (getter && !setter) { return }
  44530. if (setter) {
  44531. setter.call(obj, newVal);
  44532. } else {
  44533. val = newVal;
  44534. }
  44535. childOb = !shallow && observe(newVal);
  44536. dep.notify();
  44537. }
  44538. });
  44539. }
  44540. /**
  44541. * Set a property on an object. Adds the new property and
  44542. * triggers change notification if the property doesn't
  44543. * already exist.
  44544. */
  44545. function set (target, key, val) {
  44546. if (isUndef(target) || isPrimitive(target)
  44547. ) {
  44548. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  44549. }
  44550. if (Array.isArray(target) && isValidArrayIndex(key)) {
  44551. target.length = Math.max(target.length, key);
  44552. target.splice(key, 1, val);
  44553. return val
  44554. }
  44555. if (key in target && !(key in Object.prototype)) {
  44556. target[key] = val;
  44557. return val
  44558. }
  44559. var ob = (target).__ob__;
  44560. if (target._isVue || (ob && ob.vmCount)) {
  44561. warn(
  44562. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  44563. 'at runtime - declare it upfront in the data option.'
  44564. );
  44565. return val
  44566. }
  44567. if (!ob) {
  44568. target[key] = val;
  44569. return val
  44570. }
  44571. defineReactive$$1(ob.value, key, val);
  44572. ob.dep.notify();
  44573. return val
  44574. }
  44575. /**
  44576. * Delete a property and trigger change if necessary.
  44577. */
  44578. function del (target, key) {
  44579. if (isUndef(target) || isPrimitive(target)
  44580. ) {
  44581. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  44582. }
  44583. if (Array.isArray(target) && isValidArrayIndex(key)) {
  44584. target.splice(key, 1);
  44585. return
  44586. }
  44587. var ob = (target).__ob__;
  44588. if (target._isVue || (ob && ob.vmCount)) {
  44589. warn(
  44590. 'Avoid deleting properties on a Vue instance or its root $data ' +
  44591. '- just set it to null.'
  44592. );
  44593. return
  44594. }
  44595. if (!hasOwn(target, key)) {
  44596. return
  44597. }
  44598. delete target[key];
  44599. if (!ob) {
  44600. return
  44601. }
  44602. ob.dep.notify();
  44603. }
  44604. /**
  44605. * Collect dependencies on array elements when the array is touched, since
  44606. * we cannot intercept array element access like property getters.
  44607. */
  44608. function dependArray (value) {
  44609. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  44610. e = value[i];
  44611. e && e.__ob__ && e.__ob__.dep.depend();
  44612. if (Array.isArray(e)) {
  44613. dependArray(e);
  44614. }
  44615. }
  44616. }
  44617. /* */
  44618. /**
  44619. * Option overwriting strategies are functions that handle
  44620. * how to merge a parent option value and a child option
  44621. * value into the final value.
  44622. */
  44623. var strats = config.optionMergeStrategies;
  44624. /**
  44625. * Options with restrictions
  44626. */
  44627. {
  44628. strats.el = strats.propsData = function (parent, child, vm, key) {
  44629. if (!vm) {
  44630. warn(
  44631. "option \"" + key + "\" can only be used during instance " +
  44632. 'creation with the `new` keyword.'
  44633. );
  44634. }
  44635. return defaultStrat(parent, child)
  44636. };
  44637. }
  44638. /**
  44639. * Helper that recursively merges two data objects together.
  44640. */
  44641. function mergeData (to, from) {
  44642. if (!from) { return to }
  44643. var key, toVal, fromVal;
  44644. var keys = hasSymbol
  44645. ? Reflect.ownKeys(from)
  44646. : Object.keys(from);
  44647. for (var i = 0; i < keys.length; i++) {
  44648. key = keys[i];
  44649. // in case the object is already observed...
  44650. if (key === '__ob__') { continue }
  44651. toVal = to[key];
  44652. fromVal = from[key];
  44653. if (!hasOwn(to, key)) {
  44654. set(to, key, fromVal);
  44655. } else if (
  44656. toVal !== fromVal &&
  44657. isPlainObject(toVal) &&
  44658. isPlainObject(fromVal)
  44659. ) {
  44660. mergeData(toVal, fromVal);
  44661. }
  44662. }
  44663. return to
  44664. }
  44665. /**
  44666. * Data
  44667. */
  44668. function mergeDataOrFn (
  44669. parentVal,
  44670. childVal,
  44671. vm
  44672. ) {
  44673. if (!vm) {
  44674. // in a Vue.extend merge, both should be functions
  44675. if (!childVal) {
  44676. return parentVal
  44677. }
  44678. if (!parentVal) {
  44679. return childVal
  44680. }
  44681. // when parentVal & childVal are both present,
  44682. // we need to return a function that returns the
  44683. // merged result of both functions... no need to
  44684. // check if parentVal is a function here because
  44685. // it has to be a function to pass previous merges.
  44686. return function mergedDataFn () {
  44687. return mergeData(
  44688. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  44689. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  44690. )
  44691. }
  44692. } else {
  44693. return function mergedInstanceDataFn () {
  44694. // instance merge
  44695. var instanceData = typeof childVal === 'function'
  44696. ? childVal.call(vm, vm)
  44697. : childVal;
  44698. var defaultData = typeof parentVal === 'function'
  44699. ? parentVal.call(vm, vm)
  44700. : parentVal;
  44701. if (instanceData) {
  44702. return mergeData(instanceData, defaultData)
  44703. } else {
  44704. return defaultData
  44705. }
  44706. }
  44707. }
  44708. }
  44709. strats.data = function (
  44710. parentVal,
  44711. childVal,
  44712. vm
  44713. ) {
  44714. if (!vm) {
  44715. if (childVal && typeof childVal !== 'function') {
  44716. warn(
  44717. 'The "data" option should be a function ' +
  44718. 'that returns a per-instance value in component ' +
  44719. 'definitions.',
  44720. vm
  44721. );
  44722. return parentVal
  44723. }
  44724. return mergeDataOrFn(parentVal, childVal)
  44725. }
  44726. return mergeDataOrFn(parentVal, childVal, vm)
  44727. };
  44728. /**
  44729. * Hooks and props are merged as arrays.
  44730. */
  44731. function mergeHook (
  44732. parentVal,
  44733. childVal
  44734. ) {
  44735. var res = childVal
  44736. ? parentVal
  44737. ? parentVal.concat(childVal)
  44738. : Array.isArray(childVal)
  44739. ? childVal
  44740. : [childVal]
  44741. : parentVal;
  44742. return res
  44743. ? dedupeHooks(res)
  44744. : res
  44745. }
  44746. function dedupeHooks (hooks) {
  44747. var res = [];
  44748. for (var i = 0; i < hooks.length; i++) {
  44749. if (res.indexOf(hooks[i]) === -1) {
  44750. res.push(hooks[i]);
  44751. }
  44752. }
  44753. return res
  44754. }
  44755. LIFECYCLE_HOOKS.forEach(function (hook) {
  44756. strats[hook] = mergeHook;
  44757. });
  44758. /**
  44759. * Assets
  44760. *
  44761. * When a vm is present (instance creation), we need to do
  44762. * a three-way merge between constructor options, instance
  44763. * options and parent options.
  44764. */
  44765. function mergeAssets (
  44766. parentVal,
  44767. childVal,
  44768. vm,
  44769. key
  44770. ) {
  44771. var res = Object.create(parentVal || null);
  44772. if (childVal) {
  44773. assertObjectType(key, childVal, vm);
  44774. return extend(res, childVal)
  44775. } else {
  44776. return res
  44777. }
  44778. }
  44779. ASSET_TYPES.forEach(function (type) {
  44780. strats[type + 's'] = mergeAssets;
  44781. });
  44782. /**
  44783. * Watchers.
  44784. *
  44785. * Watchers hashes should not overwrite one
  44786. * another, so we merge them as arrays.
  44787. */
  44788. strats.watch = function (
  44789. parentVal,
  44790. childVal,
  44791. vm,
  44792. key
  44793. ) {
  44794. // work around Firefox's Object.prototype.watch...
  44795. if (parentVal === nativeWatch) { parentVal = undefined; }
  44796. if (childVal === nativeWatch) { childVal = undefined; }
  44797. /* istanbul ignore if */
  44798. if (!childVal) { return Object.create(parentVal || null) }
  44799. {
  44800. assertObjectType(key, childVal, vm);
  44801. }
  44802. if (!parentVal) { return childVal }
  44803. var ret = {};
  44804. extend(ret, parentVal);
  44805. for (var key$1 in childVal) {
  44806. var parent = ret[key$1];
  44807. var child = childVal[key$1];
  44808. if (parent && !Array.isArray(parent)) {
  44809. parent = [parent];
  44810. }
  44811. ret[key$1] = parent
  44812. ? parent.concat(child)
  44813. : Array.isArray(child) ? child : [child];
  44814. }
  44815. return ret
  44816. };
  44817. /**
  44818. * Other object hashes.
  44819. */
  44820. strats.props =
  44821. strats.methods =
  44822. strats.inject =
  44823. strats.computed = function (
  44824. parentVal,
  44825. childVal,
  44826. vm,
  44827. key
  44828. ) {
  44829. if (childVal && "development" !== 'production') {
  44830. assertObjectType(key, childVal, vm);
  44831. }
  44832. if (!parentVal) { return childVal }
  44833. var ret = Object.create(null);
  44834. extend(ret, parentVal);
  44835. if (childVal) { extend(ret, childVal); }
  44836. return ret
  44837. };
  44838. strats.provide = mergeDataOrFn;
  44839. /**
  44840. * Default strategy.
  44841. */
  44842. var defaultStrat = function (parentVal, childVal) {
  44843. return childVal === undefined
  44844. ? parentVal
  44845. : childVal
  44846. };
  44847. /**
  44848. * Validate component names
  44849. */
  44850. function checkComponents (options) {
  44851. for (var key in options.components) {
  44852. validateComponentName(key);
  44853. }
  44854. }
  44855. function validateComponentName (name) {
  44856. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  44857. warn(
  44858. 'Invalid component name: "' + name + '". Component names ' +
  44859. 'should conform to valid custom element name in html5 specification.'
  44860. );
  44861. }
  44862. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  44863. warn(
  44864. 'Do not use built-in or reserved HTML elements as component ' +
  44865. 'id: ' + name
  44866. );
  44867. }
  44868. }
  44869. /**
  44870. * Ensure all props option syntax are normalized into the
  44871. * Object-based format.
  44872. */
  44873. function normalizeProps (options, vm) {
  44874. var props = options.props;
  44875. if (!props) { return }
  44876. var res = {};
  44877. var i, val, name;
  44878. if (Array.isArray(props)) {
  44879. i = props.length;
  44880. while (i--) {
  44881. val = props[i];
  44882. if (typeof val === 'string') {
  44883. name = camelize(val);
  44884. res[name] = { type: null };
  44885. } else {
  44886. warn('props must be strings when using array syntax.');
  44887. }
  44888. }
  44889. } else if (isPlainObject(props)) {
  44890. for (var key in props) {
  44891. val = props[key];
  44892. name = camelize(key);
  44893. res[name] = isPlainObject(val)
  44894. ? val
  44895. : { type: val };
  44896. }
  44897. } else {
  44898. warn(
  44899. "Invalid value for option \"props\": expected an Array or an Object, " +
  44900. "but got " + (toRawType(props)) + ".",
  44901. vm
  44902. );
  44903. }
  44904. options.props = res;
  44905. }
  44906. /**
  44907. * Normalize all injections into Object-based format
  44908. */
  44909. function normalizeInject (options, vm) {
  44910. var inject = options.inject;
  44911. if (!inject) { return }
  44912. var normalized = options.inject = {};
  44913. if (Array.isArray(inject)) {
  44914. for (var i = 0; i < inject.length; i++) {
  44915. normalized[inject[i]] = { from: inject[i] };
  44916. }
  44917. } else if (isPlainObject(inject)) {
  44918. for (var key in inject) {
  44919. var val = inject[key];
  44920. normalized[key] = isPlainObject(val)
  44921. ? extend({ from: key }, val)
  44922. : { from: val };
  44923. }
  44924. } else {
  44925. warn(
  44926. "Invalid value for option \"inject\": expected an Array or an Object, " +
  44927. "but got " + (toRawType(inject)) + ".",
  44928. vm
  44929. );
  44930. }
  44931. }
  44932. /**
  44933. * Normalize raw function directives into object format.
  44934. */
  44935. function normalizeDirectives (options) {
  44936. var dirs = options.directives;
  44937. if (dirs) {
  44938. for (var key in dirs) {
  44939. var def$$1 = dirs[key];
  44940. if (typeof def$$1 === 'function') {
  44941. dirs[key] = { bind: def$$1, update: def$$1 };
  44942. }
  44943. }
  44944. }
  44945. }
  44946. function assertObjectType (name, value, vm) {
  44947. if (!isPlainObject(value)) {
  44948. warn(
  44949. "Invalid value for option \"" + name + "\": expected an Object, " +
  44950. "but got " + (toRawType(value)) + ".",
  44951. vm
  44952. );
  44953. }
  44954. }
  44955. /**
  44956. * Merge two option objects into a new one.
  44957. * Core utility used in both instantiation and inheritance.
  44958. */
  44959. function mergeOptions (
  44960. parent,
  44961. child,
  44962. vm
  44963. ) {
  44964. {
  44965. checkComponents(child);
  44966. }
  44967. if (typeof child === 'function') {
  44968. child = child.options;
  44969. }
  44970. normalizeProps(child, vm);
  44971. normalizeInject(child, vm);
  44972. normalizeDirectives(child);
  44973. // Apply extends and mixins on the child options,
  44974. // but only if it is a raw options object that isn't
  44975. // the result of another mergeOptions call.
  44976. // Only merged options has the _base property.
  44977. if (!child._base) {
  44978. if (child.extends) {
  44979. parent = mergeOptions(parent, child.extends, vm);
  44980. }
  44981. if (child.mixins) {
  44982. for (var i = 0, l = child.mixins.length; i < l; i++) {
  44983. parent = mergeOptions(parent, child.mixins[i], vm);
  44984. }
  44985. }
  44986. }
  44987. var options = {};
  44988. var key;
  44989. for (key in parent) {
  44990. mergeField(key);
  44991. }
  44992. for (key in child) {
  44993. if (!hasOwn(parent, key)) {
  44994. mergeField(key);
  44995. }
  44996. }
  44997. function mergeField (key) {
  44998. var strat = strats[key] || defaultStrat;
  44999. options[key] = strat(parent[key], child[key], vm, key);
  45000. }
  45001. return options
  45002. }
  45003. /**
  45004. * Resolve an asset.
  45005. * This function is used because child instances need access
  45006. * to assets defined in its ancestor chain.
  45007. */
  45008. function resolveAsset (
  45009. options,
  45010. type,
  45011. id,
  45012. warnMissing
  45013. ) {
  45014. /* istanbul ignore if */
  45015. if (typeof id !== 'string') {
  45016. return
  45017. }
  45018. var assets = options[type];
  45019. // check local registration variations first
  45020. if (hasOwn(assets, id)) { return assets[id] }
  45021. var camelizedId = camelize(id);
  45022. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  45023. var PascalCaseId = capitalize(camelizedId);
  45024. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  45025. // fallback to prototype chain
  45026. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  45027. if (warnMissing && !res) {
  45028. warn(
  45029. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  45030. options
  45031. );
  45032. }
  45033. return res
  45034. }
  45035. /* */
  45036. function validateProp (
  45037. key,
  45038. propOptions,
  45039. propsData,
  45040. vm
  45041. ) {
  45042. var prop = propOptions[key];
  45043. var absent = !hasOwn(propsData, key);
  45044. var value = propsData[key];
  45045. // boolean casting
  45046. var booleanIndex = getTypeIndex(Boolean, prop.type);
  45047. if (booleanIndex > -1) {
  45048. if (absent && !hasOwn(prop, 'default')) {
  45049. value = false;
  45050. } else if (value === '' || value === hyphenate(key)) {
  45051. // only cast empty string / same name to boolean if
  45052. // boolean has higher priority
  45053. var stringIndex = getTypeIndex(String, prop.type);
  45054. if (stringIndex < 0 || booleanIndex < stringIndex) {
  45055. value = true;
  45056. }
  45057. }
  45058. }
  45059. // check default value
  45060. if (value === undefined) {
  45061. value = getPropDefaultValue(vm, prop, key);
  45062. // since the default value is a fresh copy,
  45063. // make sure to observe it.
  45064. var prevShouldObserve = shouldObserve;
  45065. toggleObserving(true);
  45066. observe(value);
  45067. toggleObserving(prevShouldObserve);
  45068. }
  45069. {
  45070. assertProp(prop, key, value, vm, absent);
  45071. }
  45072. return value
  45073. }
  45074. /**
  45075. * Get the default value of a prop.
  45076. */
  45077. function getPropDefaultValue (vm, prop, key) {
  45078. // no default, return undefined
  45079. if (!hasOwn(prop, 'default')) {
  45080. return undefined
  45081. }
  45082. var def = prop.default;
  45083. // warn against non-factory defaults for Object & Array
  45084. if (isObject(def)) {
  45085. warn(
  45086. 'Invalid default value for prop "' + key + '": ' +
  45087. 'Props with type Object/Array must use a factory function ' +
  45088. 'to return the default value.',
  45089. vm
  45090. );
  45091. }
  45092. // the raw prop value was also undefined from previous render,
  45093. // return previous default value to avoid unnecessary watcher trigger
  45094. if (vm && vm.$options.propsData &&
  45095. vm.$options.propsData[key] === undefined &&
  45096. vm._props[key] !== undefined
  45097. ) {
  45098. return vm._props[key]
  45099. }
  45100. // call factory function for non-Function types
  45101. // a value is Function if its prototype is function even across different execution context
  45102. return typeof def === 'function' && getType(prop.type) !== 'Function'
  45103. ? def.call(vm)
  45104. : def
  45105. }
  45106. /**
  45107. * Assert whether a prop is valid.
  45108. */
  45109. function assertProp (
  45110. prop,
  45111. name,
  45112. value,
  45113. vm,
  45114. absent
  45115. ) {
  45116. if (prop.required && absent) {
  45117. warn(
  45118. 'Missing required prop: "' + name + '"',
  45119. vm
  45120. );
  45121. return
  45122. }
  45123. if (value == null && !prop.required) {
  45124. return
  45125. }
  45126. var type = prop.type;
  45127. var valid = !type || type === true;
  45128. var expectedTypes = [];
  45129. if (type) {
  45130. if (!Array.isArray(type)) {
  45131. type = [type];
  45132. }
  45133. for (var i = 0; i < type.length && !valid; i++) {
  45134. var assertedType = assertType(value, type[i]);
  45135. expectedTypes.push(assertedType.expectedType || '');
  45136. valid = assertedType.valid;
  45137. }
  45138. }
  45139. if (!valid) {
  45140. warn(
  45141. getInvalidTypeMessage(name, value, expectedTypes),
  45142. vm
  45143. );
  45144. return
  45145. }
  45146. var validator = prop.validator;
  45147. if (validator) {
  45148. if (!validator(value)) {
  45149. warn(
  45150. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  45151. vm
  45152. );
  45153. }
  45154. }
  45155. }
  45156. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  45157. function assertType (value, type) {
  45158. var valid;
  45159. var expectedType = getType(type);
  45160. if (simpleCheckRE.test(expectedType)) {
  45161. var t = typeof value;
  45162. valid = t === expectedType.toLowerCase();
  45163. // for primitive wrapper objects
  45164. if (!valid && t === 'object') {
  45165. valid = value instanceof type;
  45166. }
  45167. } else if (expectedType === 'Object') {
  45168. valid = isPlainObject(value);
  45169. } else if (expectedType === 'Array') {
  45170. valid = Array.isArray(value);
  45171. } else {
  45172. valid = value instanceof type;
  45173. }
  45174. return {
  45175. valid: valid,
  45176. expectedType: expectedType
  45177. }
  45178. }
  45179. /**
  45180. * Use function string name to check built-in types,
  45181. * because a simple equality check will fail when running
  45182. * across different vms / iframes.
  45183. */
  45184. function getType (fn) {
  45185. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  45186. return match ? match[1] : ''
  45187. }
  45188. function isSameType (a, b) {
  45189. return getType(a) === getType(b)
  45190. }
  45191. function getTypeIndex (type, expectedTypes) {
  45192. if (!Array.isArray(expectedTypes)) {
  45193. return isSameType(expectedTypes, type) ? 0 : -1
  45194. }
  45195. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  45196. if (isSameType(expectedTypes[i], type)) {
  45197. return i
  45198. }
  45199. }
  45200. return -1
  45201. }
  45202. function getInvalidTypeMessage (name, value, expectedTypes) {
  45203. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  45204. " Expected " + (expectedTypes.map(capitalize).join(', '));
  45205. var expectedType = expectedTypes[0];
  45206. var receivedType = toRawType(value);
  45207. var expectedValue = styleValue(value, expectedType);
  45208. var receivedValue = styleValue(value, receivedType);
  45209. // check if we need to specify expected value
  45210. if (expectedTypes.length === 1 &&
  45211. isExplicable(expectedType) &&
  45212. !isBoolean(expectedType, receivedType)) {
  45213. message += " with value " + expectedValue;
  45214. }
  45215. message += ", got " + receivedType + " ";
  45216. // check if we need to specify received value
  45217. if (isExplicable(receivedType)) {
  45218. message += "with value " + receivedValue + ".";
  45219. }
  45220. return message
  45221. }
  45222. function styleValue (value, type) {
  45223. if (type === 'String') {
  45224. return ("\"" + value + "\"")
  45225. } else if (type === 'Number') {
  45226. return ("" + (Number(value)))
  45227. } else {
  45228. return ("" + value)
  45229. }
  45230. }
  45231. function isExplicable (value) {
  45232. var explicitTypes = ['string', 'number', 'boolean'];
  45233. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  45234. }
  45235. function isBoolean () {
  45236. var args = [], len = arguments.length;
  45237. while ( len-- ) args[ len ] = arguments[ len ];
  45238. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  45239. }
  45240. /* */
  45241. function handleError (err, vm, info) {
  45242. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  45243. // See: https://github.com/vuejs/vuex/issues/1505
  45244. pushTarget();
  45245. try {
  45246. if (vm) {
  45247. var cur = vm;
  45248. while ((cur = cur.$parent)) {
  45249. var hooks = cur.$options.errorCaptured;
  45250. if (hooks) {
  45251. for (var i = 0; i < hooks.length; i++) {
  45252. try {
  45253. var capture = hooks[i].call(cur, err, vm, info) === false;
  45254. if (capture) { return }
  45255. } catch (e) {
  45256. globalHandleError(e, cur, 'errorCaptured hook');
  45257. }
  45258. }
  45259. }
  45260. }
  45261. }
  45262. globalHandleError(err, vm, info);
  45263. } finally {
  45264. popTarget();
  45265. }
  45266. }
  45267. function invokeWithErrorHandling (
  45268. handler,
  45269. context,
  45270. args,
  45271. vm,
  45272. info
  45273. ) {
  45274. var res;
  45275. try {
  45276. res = args ? handler.apply(context, args) : handler.call(context);
  45277. if (res && !res._isVue && isPromise(res) && !res._handled) {
  45278. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  45279. // issue #9511
  45280. // avoid catch triggering multiple times when nested calls
  45281. res._handled = true;
  45282. }
  45283. } catch (e) {
  45284. handleError(e, vm, info);
  45285. }
  45286. return res
  45287. }
  45288. function globalHandleError (err, vm, info) {
  45289. if (config.errorHandler) {
  45290. try {
  45291. return config.errorHandler.call(null, err, vm, info)
  45292. } catch (e) {
  45293. // if the user intentionally throws the original error in the handler,
  45294. // do not log it twice
  45295. if (e !== err) {
  45296. logError(e, null, 'config.errorHandler');
  45297. }
  45298. }
  45299. }
  45300. logError(err, vm, info);
  45301. }
  45302. function logError (err, vm, info) {
  45303. {
  45304. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  45305. }
  45306. /* istanbul ignore else */
  45307. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  45308. console.error(err);
  45309. } else {
  45310. throw err
  45311. }
  45312. }
  45313. /* */
  45314. var isUsingMicroTask = false;
  45315. var callbacks = [];
  45316. var pending = false;
  45317. function flushCallbacks () {
  45318. pending = false;
  45319. var copies = callbacks.slice(0);
  45320. callbacks.length = 0;
  45321. for (var i = 0; i < copies.length; i++) {
  45322. copies[i]();
  45323. }
  45324. }
  45325. // Here we have async deferring wrappers using microtasks.
  45326. // In 2.5 we used (macro) tasks (in combination with microtasks).
  45327. // However, it has subtle problems when state is changed right before repaint
  45328. // (e.g. #6813, out-in transitions).
  45329. // Also, using (macro) tasks in event handler would cause some weird behaviors
  45330. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  45331. // So we now use microtasks everywhere, again.
  45332. // A major drawback of this tradeoff is that there are some scenarios
  45333. // where microtasks have too high a priority and fire in between supposedly
  45334. // sequential events (e.g. #4521, #6690, which have workarounds)
  45335. // or even between bubbling of the same event (#6566).
  45336. var timerFunc;
  45337. // The nextTick behavior leverages the microtask queue, which can be accessed
  45338. // via either native Promise.then or MutationObserver.
  45339. // MutationObserver has wider support, however it is seriously bugged in
  45340. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  45341. // completely stops working after triggering a few times... so, if native
  45342. // Promise is available, we will use it:
  45343. /* istanbul ignore next, $flow-disable-line */
  45344. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  45345. var p = Promise.resolve();
  45346. timerFunc = function () {
  45347. p.then(flushCallbacks);
  45348. // In problematic UIWebViews, Promise.then doesn't completely break, but
  45349. // it can get stuck in a weird state where callbacks are pushed into the
  45350. // microtask queue but the queue isn't being flushed, until the browser
  45351. // needs to do some other work, e.g. handle a timer. Therefore we can
  45352. // "force" the microtask queue to be flushed by adding an empty timer.
  45353. if (isIOS) { setTimeout(noop); }
  45354. };
  45355. isUsingMicroTask = true;
  45356. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  45357. isNative(MutationObserver) ||
  45358. // PhantomJS and iOS 7.x
  45359. MutationObserver.toString() === '[object MutationObserverConstructor]'
  45360. )) {
  45361. // Use MutationObserver where native Promise is not available,
  45362. // e.g. PhantomJS, iOS7, Android 4.4
  45363. // (#6466 MutationObserver is unreliable in IE11)
  45364. var counter = 1;
  45365. var observer = new MutationObserver(flushCallbacks);
  45366. var textNode = document.createTextNode(String(counter));
  45367. observer.observe(textNode, {
  45368. characterData: true
  45369. });
  45370. timerFunc = function () {
  45371. counter = (counter + 1) % 2;
  45372. textNode.data = String(counter);
  45373. };
  45374. isUsingMicroTask = true;
  45375. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  45376. // Fallback to setImmediate.
  45377. // Technically it leverages the (macro) task queue,
  45378. // but it is still a better choice than setTimeout.
  45379. timerFunc = function () {
  45380. setImmediate(flushCallbacks);
  45381. };
  45382. } else {
  45383. // Fallback to setTimeout.
  45384. timerFunc = function () {
  45385. setTimeout(flushCallbacks, 0);
  45386. };
  45387. }
  45388. function nextTick (cb, ctx) {
  45389. var _resolve;
  45390. callbacks.push(function () {
  45391. if (cb) {
  45392. try {
  45393. cb.call(ctx);
  45394. } catch (e) {
  45395. handleError(e, ctx, 'nextTick');
  45396. }
  45397. } else if (_resolve) {
  45398. _resolve(ctx);
  45399. }
  45400. });
  45401. if (!pending) {
  45402. pending = true;
  45403. timerFunc();
  45404. }
  45405. // $flow-disable-line
  45406. if (!cb && typeof Promise !== 'undefined') {
  45407. return new Promise(function (resolve) {
  45408. _resolve = resolve;
  45409. })
  45410. }
  45411. }
  45412. /* */
  45413. var mark;
  45414. var measure;
  45415. {
  45416. var perf = inBrowser && window.performance;
  45417. /* istanbul ignore if */
  45418. if (
  45419. perf &&
  45420. perf.mark &&
  45421. perf.measure &&
  45422. perf.clearMarks &&
  45423. perf.clearMeasures
  45424. ) {
  45425. mark = function (tag) { return perf.mark(tag); };
  45426. measure = function (name, startTag, endTag) {
  45427. perf.measure(name, startTag, endTag);
  45428. perf.clearMarks(startTag);
  45429. perf.clearMarks(endTag);
  45430. // perf.clearMeasures(name)
  45431. };
  45432. }
  45433. }
  45434. /* not type checking this file because flow doesn't play well with Proxy */
  45435. var initProxy;
  45436. {
  45437. var allowedGlobals = makeMap(
  45438. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  45439. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  45440. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  45441. 'require' // for Webpack/Browserify
  45442. );
  45443. var warnNonPresent = function (target, key) {
  45444. warn(
  45445. "Property or method \"" + key + "\" is not defined on the instance but " +
  45446. 'referenced during render. Make sure that this property is reactive, ' +
  45447. 'either in the data option, or for class-based components, by ' +
  45448. 'initializing the property. ' +
  45449. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  45450. target
  45451. );
  45452. };
  45453. var warnReservedPrefix = function (target, key) {
  45454. warn(
  45455. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  45456. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  45457. 'prevent conflicts with Vue internals. ' +
  45458. 'See: https://vuejs.org/v2/api/#data',
  45459. target
  45460. );
  45461. };
  45462. var hasProxy =
  45463. typeof Proxy !== 'undefined' && isNative(Proxy);
  45464. if (hasProxy) {
  45465. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  45466. config.keyCodes = new Proxy(config.keyCodes, {
  45467. set: function set (target, key, value) {
  45468. if (isBuiltInModifier(key)) {
  45469. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  45470. return false
  45471. } else {
  45472. target[key] = value;
  45473. return true
  45474. }
  45475. }
  45476. });
  45477. }
  45478. var hasHandler = {
  45479. has: function has (target, key) {
  45480. var has = key in target;
  45481. var isAllowed = allowedGlobals(key) ||
  45482. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  45483. if (!has && !isAllowed) {
  45484. if (key in target.$data) { warnReservedPrefix(target, key); }
  45485. else { warnNonPresent(target, key); }
  45486. }
  45487. return has || !isAllowed
  45488. }
  45489. };
  45490. var getHandler = {
  45491. get: function get (target, key) {
  45492. if (typeof key === 'string' && !(key in target)) {
  45493. if (key in target.$data) { warnReservedPrefix(target, key); }
  45494. else { warnNonPresent(target, key); }
  45495. }
  45496. return target[key]
  45497. }
  45498. };
  45499. initProxy = function initProxy (vm) {
  45500. if (hasProxy) {
  45501. // determine which proxy handler to use
  45502. var options = vm.$options;
  45503. var handlers = options.render && options.render._withStripped
  45504. ? getHandler
  45505. : hasHandler;
  45506. vm._renderProxy = new Proxy(vm, handlers);
  45507. } else {
  45508. vm._renderProxy = vm;
  45509. }
  45510. };
  45511. }
  45512. /* */
  45513. var seenObjects = new _Set();
  45514. /**
  45515. * Recursively traverse an object to evoke all converted
  45516. * getters, so that every nested property inside the object
  45517. * is collected as a "deep" dependency.
  45518. */
  45519. function traverse (val) {
  45520. _traverse(val, seenObjects);
  45521. seenObjects.clear();
  45522. }
  45523. function _traverse (val, seen) {
  45524. var i, keys;
  45525. var isA = Array.isArray(val);
  45526. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  45527. return
  45528. }
  45529. if (val.__ob__) {
  45530. var depId = val.__ob__.dep.id;
  45531. if (seen.has(depId)) {
  45532. return
  45533. }
  45534. seen.add(depId);
  45535. }
  45536. if (isA) {
  45537. i = val.length;
  45538. while (i--) { _traverse(val[i], seen); }
  45539. } else {
  45540. keys = Object.keys(val);
  45541. i = keys.length;
  45542. while (i--) { _traverse(val[keys[i]], seen); }
  45543. }
  45544. }
  45545. /* */
  45546. var normalizeEvent = cached(function (name) {
  45547. var passive = name.charAt(0) === '&';
  45548. name = passive ? name.slice(1) : name;
  45549. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  45550. name = once$$1 ? name.slice(1) : name;
  45551. var capture = name.charAt(0) === '!';
  45552. name = capture ? name.slice(1) : name;
  45553. return {
  45554. name: name,
  45555. once: once$$1,
  45556. capture: capture,
  45557. passive: passive
  45558. }
  45559. });
  45560. function createFnInvoker (fns, vm) {
  45561. function invoker () {
  45562. var arguments$1 = arguments;
  45563. var fns = invoker.fns;
  45564. if (Array.isArray(fns)) {
  45565. var cloned = fns.slice();
  45566. for (var i = 0; i < cloned.length; i++) {
  45567. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  45568. }
  45569. } else {
  45570. // return handler return value for single handlers
  45571. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  45572. }
  45573. }
  45574. invoker.fns = fns;
  45575. return invoker
  45576. }
  45577. function updateListeners (
  45578. on,
  45579. oldOn,
  45580. add,
  45581. remove$$1,
  45582. createOnceHandler,
  45583. vm
  45584. ) {
  45585. var name, def$$1, cur, old, event;
  45586. for (name in on) {
  45587. def$$1 = cur = on[name];
  45588. old = oldOn[name];
  45589. event = normalizeEvent(name);
  45590. if (isUndef(cur)) {
  45591. warn(
  45592. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  45593. vm
  45594. );
  45595. } else if (isUndef(old)) {
  45596. if (isUndef(cur.fns)) {
  45597. cur = on[name] = createFnInvoker(cur, vm);
  45598. }
  45599. if (isTrue(event.once)) {
  45600. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  45601. }
  45602. add(event.name, cur, event.capture, event.passive, event.params);
  45603. } else if (cur !== old) {
  45604. old.fns = cur;
  45605. on[name] = old;
  45606. }
  45607. }
  45608. for (name in oldOn) {
  45609. if (isUndef(on[name])) {
  45610. event = normalizeEvent(name);
  45611. remove$$1(event.name, oldOn[name], event.capture);
  45612. }
  45613. }
  45614. }
  45615. /* */
  45616. function mergeVNodeHook (def, hookKey, hook) {
  45617. if (def instanceof VNode) {
  45618. def = def.data.hook || (def.data.hook = {});
  45619. }
  45620. var invoker;
  45621. var oldHook = def[hookKey];
  45622. function wrappedHook () {
  45623. hook.apply(this, arguments);
  45624. // important: remove merged hook to ensure it's called only once
  45625. // and prevent memory leak
  45626. remove(invoker.fns, wrappedHook);
  45627. }
  45628. if (isUndef(oldHook)) {
  45629. // no existing hook
  45630. invoker = createFnInvoker([wrappedHook]);
  45631. } else {
  45632. /* istanbul ignore if */
  45633. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  45634. // already a merged invoker
  45635. invoker = oldHook;
  45636. invoker.fns.push(wrappedHook);
  45637. } else {
  45638. // existing plain hook
  45639. invoker = createFnInvoker([oldHook, wrappedHook]);
  45640. }
  45641. }
  45642. invoker.merged = true;
  45643. def[hookKey] = invoker;
  45644. }
  45645. /* */
  45646. function extractPropsFromVNodeData (
  45647. data,
  45648. Ctor,
  45649. tag
  45650. ) {
  45651. // we are only extracting raw values here.
  45652. // validation and default values are handled in the child
  45653. // component itself.
  45654. var propOptions = Ctor.options.props;
  45655. if (isUndef(propOptions)) {
  45656. return
  45657. }
  45658. var res = {};
  45659. var attrs = data.attrs;
  45660. var props = data.props;
  45661. if (isDef(attrs) || isDef(props)) {
  45662. for (var key in propOptions) {
  45663. var altKey = hyphenate(key);
  45664. {
  45665. var keyInLowerCase = key.toLowerCase();
  45666. if (
  45667. key !== keyInLowerCase &&
  45668. attrs && hasOwn(attrs, keyInLowerCase)
  45669. ) {
  45670. tip(
  45671. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  45672. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  45673. " \"" + key + "\". " +
  45674. "Note that HTML attributes are case-insensitive and camelCased " +
  45675. "props need to use their kebab-case equivalents when using in-DOM " +
  45676. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  45677. );
  45678. }
  45679. }
  45680. checkProp(res, props, key, altKey, true) ||
  45681. checkProp(res, attrs, key, altKey, false);
  45682. }
  45683. }
  45684. return res
  45685. }
  45686. function checkProp (
  45687. res,
  45688. hash,
  45689. key,
  45690. altKey,
  45691. preserve
  45692. ) {
  45693. if (isDef(hash)) {
  45694. if (hasOwn(hash, key)) {
  45695. res[key] = hash[key];
  45696. if (!preserve) {
  45697. delete hash[key];
  45698. }
  45699. return true
  45700. } else if (hasOwn(hash, altKey)) {
  45701. res[key] = hash[altKey];
  45702. if (!preserve) {
  45703. delete hash[altKey];
  45704. }
  45705. return true
  45706. }
  45707. }
  45708. return false
  45709. }
  45710. /* */
  45711. // The template compiler attempts to minimize the need for normalization by
  45712. // statically analyzing the template at compile time.
  45713. //
  45714. // For plain HTML markup, normalization can be completely skipped because the
  45715. // generated render function is guaranteed to return Array<VNode>. There are
  45716. // two cases where extra normalization is needed:
  45717. // 1. When the children contains components - because a functional component
  45718. // may return an Array instead of a single root. In this case, just a simple
  45719. // normalization is needed - if any child is an Array, we flatten the whole
  45720. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  45721. // because functional components already normalize their own children.
  45722. function simpleNormalizeChildren (children) {
  45723. for (var i = 0; i < children.length; i++) {
  45724. if (Array.isArray(children[i])) {
  45725. return Array.prototype.concat.apply([], children)
  45726. }
  45727. }
  45728. return children
  45729. }
  45730. // 2. When the children contains constructs that always generated nested Arrays,
  45731. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  45732. // with hand-written render functions / JSX. In such cases a full normalization
  45733. // is needed to cater to all possible types of children values.
  45734. function normalizeChildren (children) {
  45735. return isPrimitive(children)
  45736. ? [createTextVNode(children)]
  45737. : Array.isArray(children)
  45738. ? normalizeArrayChildren(children)
  45739. : undefined
  45740. }
  45741. function isTextNode (node) {
  45742. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  45743. }
  45744. function normalizeArrayChildren (children, nestedIndex) {
  45745. var res = [];
  45746. var i, c, lastIndex, last;
  45747. for (i = 0; i < children.length; i++) {
  45748. c = children[i];
  45749. if (isUndef(c) || typeof c === 'boolean') { continue }
  45750. lastIndex = res.length - 1;
  45751. last = res[lastIndex];
  45752. // nested
  45753. if (Array.isArray(c)) {
  45754. if (c.length > 0) {
  45755. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  45756. // merge adjacent text nodes
  45757. if (isTextNode(c[0]) && isTextNode(last)) {
  45758. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  45759. c.shift();
  45760. }
  45761. res.push.apply(res, c);
  45762. }
  45763. } else if (isPrimitive(c)) {
  45764. if (isTextNode(last)) {
  45765. // merge adjacent text nodes
  45766. // this is necessary for SSR hydration because text nodes are
  45767. // essentially merged when rendered to HTML strings
  45768. res[lastIndex] = createTextVNode(last.text + c);
  45769. } else if (c !== '') {
  45770. // convert primitive to vnode
  45771. res.push(createTextVNode(c));
  45772. }
  45773. } else {
  45774. if (isTextNode(c) && isTextNode(last)) {
  45775. // merge adjacent text nodes
  45776. res[lastIndex] = createTextVNode(last.text + c.text);
  45777. } else {
  45778. // default key for nested array children (likely generated by v-for)
  45779. if (isTrue(children._isVList) &&
  45780. isDef(c.tag) &&
  45781. isUndef(c.key) &&
  45782. isDef(nestedIndex)) {
  45783. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  45784. }
  45785. res.push(c);
  45786. }
  45787. }
  45788. }
  45789. return res
  45790. }
  45791. /* */
  45792. function initProvide (vm) {
  45793. var provide = vm.$options.provide;
  45794. if (provide) {
  45795. vm._provided = typeof provide === 'function'
  45796. ? provide.call(vm)
  45797. : provide;
  45798. }
  45799. }
  45800. function initInjections (vm) {
  45801. var result = resolveInject(vm.$options.inject, vm);
  45802. if (result) {
  45803. toggleObserving(false);
  45804. Object.keys(result).forEach(function (key) {
  45805. /* istanbul ignore else */
  45806. {
  45807. defineReactive$$1(vm, key, result[key], function () {
  45808. warn(
  45809. "Avoid mutating an injected value directly since the changes will be " +
  45810. "overwritten whenever the provided component re-renders. " +
  45811. "injection being mutated: \"" + key + "\"",
  45812. vm
  45813. );
  45814. });
  45815. }
  45816. });
  45817. toggleObserving(true);
  45818. }
  45819. }
  45820. function resolveInject (inject, vm) {
  45821. if (inject) {
  45822. // inject is :any because flow is not smart enough to figure out cached
  45823. var result = Object.create(null);
  45824. var keys = hasSymbol
  45825. ? Reflect.ownKeys(inject)
  45826. : Object.keys(inject);
  45827. for (var i = 0; i < keys.length; i++) {
  45828. var key = keys[i];
  45829. // #6574 in case the inject object is observed...
  45830. if (key === '__ob__') { continue }
  45831. var provideKey = inject[key].from;
  45832. var source = vm;
  45833. while (source) {
  45834. if (source._provided && hasOwn(source._provided, provideKey)) {
  45835. result[key] = source._provided[provideKey];
  45836. break
  45837. }
  45838. source = source.$parent;
  45839. }
  45840. if (!source) {
  45841. if ('default' in inject[key]) {
  45842. var provideDefault = inject[key].default;
  45843. result[key] = typeof provideDefault === 'function'
  45844. ? provideDefault.call(vm)
  45845. : provideDefault;
  45846. } else {
  45847. warn(("Injection \"" + key + "\" not found"), vm);
  45848. }
  45849. }
  45850. }
  45851. return result
  45852. }
  45853. }
  45854. /* */
  45855. /**
  45856. * Runtime helper for resolving raw children VNodes into a slot object.
  45857. */
  45858. function resolveSlots (
  45859. children,
  45860. context
  45861. ) {
  45862. if (!children || !children.length) {
  45863. return {}
  45864. }
  45865. var slots = {};
  45866. for (var i = 0, l = children.length; i < l; i++) {
  45867. var child = children[i];
  45868. var data = child.data;
  45869. // remove slot attribute if the node is resolved as a Vue slot node
  45870. if (data && data.attrs && data.attrs.slot) {
  45871. delete data.attrs.slot;
  45872. }
  45873. // named slots should only be respected if the vnode was rendered in the
  45874. // same context.
  45875. if ((child.context === context || child.fnContext === context) &&
  45876. data && data.slot != null
  45877. ) {
  45878. var name = data.slot;
  45879. var slot = (slots[name] || (slots[name] = []));
  45880. if (child.tag === 'template') {
  45881. slot.push.apply(slot, child.children || []);
  45882. } else {
  45883. slot.push(child);
  45884. }
  45885. } else {
  45886. (slots.default || (slots.default = [])).push(child);
  45887. }
  45888. }
  45889. // ignore slots that contains only whitespace
  45890. for (var name$1 in slots) {
  45891. if (slots[name$1].every(isWhitespace)) {
  45892. delete slots[name$1];
  45893. }
  45894. }
  45895. return slots
  45896. }
  45897. function isWhitespace (node) {
  45898. return (node.isComment && !node.asyncFactory) || node.text === ' '
  45899. }
  45900. /* */
  45901. function normalizeScopedSlots (
  45902. slots,
  45903. normalSlots,
  45904. prevSlots
  45905. ) {
  45906. var res;
  45907. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  45908. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  45909. var key = slots && slots.$key;
  45910. if (!slots) {
  45911. res = {};
  45912. } else if (slots._normalized) {
  45913. // fast path 1: child component re-render only, parent did not change
  45914. return slots._normalized
  45915. } else if (
  45916. isStable &&
  45917. prevSlots &&
  45918. prevSlots !== emptyObject &&
  45919. key === prevSlots.$key &&
  45920. !hasNormalSlots &&
  45921. !prevSlots.$hasNormal
  45922. ) {
  45923. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  45924. // only need to normalize once
  45925. return prevSlots
  45926. } else {
  45927. res = {};
  45928. for (var key$1 in slots) {
  45929. if (slots[key$1] && key$1[0] !== '$') {
  45930. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  45931. }
  45932. }
  45933. }
  45934. // expose normal slots on scopedSlots
  45935. for (var key$2 in normalSlots) {
  45936. if (!(key$2 in res)) {
  45937. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  45938. }
  45939. }
  45940. // avoriaz seems to mock a non-extensible $scopedSlots object
  45941. // and when that is passed down this would cause an error
  45942. if (slots && Object.isExtensible(slots)) {
  45943. (slots)._normalized = res;
  45944. }
  45945. def(res, '$stable', isStable);
  45946. def(res, '$key', key);
  45947. def(res, '$hasNormal', hasNormalSlots);
  45948. return res
  45949. }
  45950. function normalizeScopedSlot(normalSlots, key, fn) {
  45951. var normalized = function () {
  45952. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  45953. res = res && typeof res === 'object' && !Array.isArray(res)
  45954. ? [res] // single vnode
  45955. : normalizeChildren(res);
  45956. return res && (
  45957. res.length === 0 ||
  45958. (res.length === 1 && res[0].isComment) // #9658
  45959. ) ? undefined
  45960. : res
  45961. };
  45962. // this is a slot using the new v-slot syntax without scope. although it is
  45963. // compiled as a scoped slot, render fn users would expect it to be present
  45964. // on this.$slots because the usage is semantically a normal slot.
  45965. if (fn.proxy) {
  45966. Object.defineProperty(normalSlots, key, {
  45967. get: normalized,
  45968. enumerable: true,
  45969. configurable: true
  45970. });
  45971. }
  45972. return normalized
  45973. }
  45974. function proxyNormalSlot(slots, key) {
  45975. return function () { return slots[key]; }
  45976. }
  45977. /* */
  45978. /**
  45979. * Runtime helper for rendering v-for lists.
  45980. */
  45981. function renderList (
  45982. val,
  45983. render
  45984. ) {
  45985. var ret, i, l, keys, key;
  45986. if (Array.isArray(val) || typeof val === 'string') {
  45987. ret = new Array(val.length);
  45988. for (i = 0, l = val.length; i < l; i++) {
  45989. ret[i] = render(val[i], i);
  45990. }
  45991. } else if (typeof val === 'number') {
  45992. ret = new Array(val);
  45993. for (i = 0; i < val; i++) {
  45994. ret[i] = render(i + 1, i);
  45995. }
  45996. } else if (isObject(val)) {
  45997. if (hasSymbol && val[Symbol.iterator]) {
  45998. ret = [];
  45999. var iterator = val[Symbol.iterator]();
  46000. var result = iterator.next();
  46001. while (!result.done) {
  46002. ret.push(render(result.value, ret.length));
  46003. result = iterator.next();
  46004. }
  46005. } else {
  46006. keys = Object.keys(val);
  46007. ret = new Array(keys.length);
  46008. for (i = 0, l = keys.length; i < l; i++) {
  46009. key = keys[i];
  46010. ret[i] = render(val[key], key, i);
  46011. }
  46012. }
  46013. }
  46014. if (!isDef(ret)) {
  46015. ret = [];
  46016. }
  46017. (ret)._isVList = true;
  46018. return ret
  46019. }
  46020. /* */
  46021. /**
  46022. * Runtime helper for rendering <slot>
  46023. */
  46024. function renderSlot (
  46025. name,
  46026. fallback,
  46027. props,
  46028. bindObject
  46029. ) {
  46030. var scopedSlotFn = this.$scopedSlots[name];
  46031. var nodes;
  46032. if (scopedSlotFn) { // scoped slot
  46033. props = props || {};
  46034. if (bindObject) {
  46035. if (!isObject(bindObject)) {
  46036. warn(
  46037. 'slot v-bind without argument expects an Object',
  46038. this
  46039. );
  46040. }
  46041. props = extend(extend({}, bindObject), props);
  46042. }
  46043. nodes = scopedSlotFn(props) || fallback;
  46044. } else {
  46045. nodes = this.$slots[name] || fallback;
  46046. }
  46047. var target = props && props.slot;
  46048. if (target) {
  46049. return this.$createElement('template', { slot: target }, nodes)
  46050. } else {
  46051. return nodes
  46052. }
  46053. }
  46054. /* */
  46055. /**
  46056. * Runtime helper for resolving filters
  46057. */
  46058. function resolveFilter (id) {
  46059. return resolveAsset(this.$options, 'filters', id, true) || identity
  46060. }
  46061. /* */
  46062. function isKeyNotMatch (expect, actual) {
  46063. if (Array.isArray(expect)) {
  46064. return expect.indexOf(actual) === -1
  46065. } else {
  46066. return expect !== actual
  46067. }
  46068. }
  46069. /**
  46070. * Runtime helper for checking keyCodes from config.
  46071. * exposed as Vue.prototype._k
  46072. * passing in eventKeyName as last argument separately for backwards compat
  46073. */
  46074. function checkKeyCodes (
  46075. eventKeyCode,
  46076. key,
  46077. builtInKeyCode,
  46078. eventKeyName,
  46079. builtInKeyName
  46080. ) {
  46081. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  46082. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  46083. return isKeyNotMatch(builtInKeyName, eventKeyName)
  46084. } else if (mappedKeyCode) {
  46085. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  46086. } else if (eventKeyName) {
  46087. return hyphenate(eventKeyName) !== key
  46088. }
  46089. }
  46090. /* */
  46091. /**
  46092. * Runtime helper for merging v-bind="object" into a VNode's data.
  46093. */
  46094. function bindObjectProps (
  46095. data,
  46096. tag,
  46097. value,
  46098. asProp,
  46099. isSync
  46100. ) {
  46101. if (value) {
  46102. if (!isObject(value)) {
  46103. warn(
  46104. 'v-bind without argument expects an Object or Array value',
  46105. this
  46106. );
  46107. } else {
  46108. if (Array.isArray(value)) {
  46109. value = toObject(value);
  46110. }
  46111. var hash;
  46112. var loop = function ( key ) {
  46113. if (
  46114. key === 'class' ||
  46115. key === 'style' ||
  46116. isReservedAttribute(key)
  46117. ) {
  46118. hash = data;
  46119. } else {
  46120. var type = data.attrs && data.attrs.type;
  46121. hash = asProp || config.mustUseProp(tag, type, key)
  46122. ? data.domProps || (data.domProps = {})
  46123. : data.attrs || (data.attrs = {});
  46124. }
  46125. var camelizedKey = camelize(key);
  46126. var hyphenatedKey = hyphenate(key);
  46127. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  46128. hash[key] = value[key];
  46129. if (isSync) {
  46130. var on = data.on || (data.on = {});
  46131. on[("update:" + key)] = function ($event) {
  46132. value[key] = $event;
  46133. };
  46134. }
  46135. }
  46136. };
  46137. for (var key in value) loop( key );
  46138. }
  46139. }
  46140. return data
  46141. }
  46142. /* */
  46143. /**
  46144. * Runtime helper for rendering static trees.
  46145. */
  46146. function renderStatic (
  46147. index,
  46148. isInFor
  46149. ) {
  46150. var cached = this._staticTrees || (this._staticTrees = []);
  46151. var tree = cached[index];
  46152. // if has already-rendered static tree and not inside v-for,
  46153. // we can reuse the same tree.
  46154. if (tree && !isInFor) {
  46155. return tree
  46156. }
  46157. // otherwise, render a fresh tree.
  46158. tree = cached[index] = this.$options.staticRenderFns[index].call(
  46159. this._renderProxy,
  46160. null,
  46161. this // for render fns generated for functional component templates
  46162. );
  46163. markStatic(tree, ("__static__" + index), false);
  46164. return tree
  46165. }
  46166. /**
  46167. * Runtime helper for v-once.
  46168. * Effectively it means marking the node as static with a unique key.
  46169. */
  46170. function markOnce (
  46171. tree,
  46172. index,
  46173. key
  46174. ) {
  46175. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  46176. return tree
  46177. }
  46178. function markStatic (
  46179. tree,
  46180. key,
  46181. isOnce
  46182. ) {
  46183. if (Array.isArray(tree)) {
  46184. for (var i = 0; i < tree.length; i++) {
  46185. if (tree[i] && typeof tree[i] !== 'string') {
  46186. markStaticNode(tree[i], (key + "_" + i), isOnce);
  46187. }
  46188. }
  46189. } else {
  46190. markStaticNode(tree, key, isOnce);
  46191. }
  46192. }
  46193. function markStaticNode (node, key, isOnce) {
  46194. node.isStatic = true;
  46195. node.key = key;
  46196. node.isOnce = isOnce;
  46197. }
  46198. /* */
  46199. function bindObjectListeners (data, value) {
  46200. if (value) {
  46201. if (!isPlainObject(value)) {
  46202. warn(
  46203. 'v-on without argument expects an Object value',
  46204. this
  46205. );
  46206. } else {
  46207. var on = data.on = data.on ? extend({}, data.on) : {};
  46208. for (var key in value) {
  46209. var existing = on[key];
  46210. var ours = value[key];
  46211. on[key] = existing ? [].concat(existing, ours) : ours;
  46212. }
  46213. }
  46214. }
  46215. return data
  46216. }
  46217. /* */
  46218. function resolveScopedSlots (
  46219. fns, // see flow/vnode
  46220. res,
  46221. // the following are added in 2.6
  46222. hasDynamicKeys,
  46223. contentHashKey
  46224. ) {
  46225. res = res || { $stable: !hasDynamicKeys };
  46226. for (var i = 0; i < fns.length; i++) {
  46227. var slot = fns[i];
  46228. if (Array.isArray(slot)) {
  46229. resolveScopedSlots(slot, res, hasDynamicKeys);
  46230. } else if (slot) {
  46231. // marker for reverse proxying v-slot without scope on this.$slots
  46232. if (slot.proxy) {
  46233. slot.fn.proxy = true;
  46234. }
  46235. res[slot.key] = slot.fn;
  46236. }
  46237. }
  46238. if (contentHashKey) {
  46239. (res).$key = contentHashKey;
  46240. }
  46241. return res
  46242. }
  46243. /* */
  46244. function bindDynamicKeys (baseObj, values) {
  46245. for (var i = 0; i < values.length; i += 2) {
  46246. var key = values[i];
  46247. if (typeof key === 'string' && key) {
  46248. baseObj[values[i]] = values[i + 1];
  46249. } else if (key !== '' && key !== null) {
  46250. // null is a special value for explicitly removing a binding
  46251. warn(
  46252. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  46253. this
  46254. );
  46255. }
  46256. }
  46257. return baseObj
  46258. }
  46259. // helper to dynamically append modifier runtime markers to event names.
  46260. // ensure only append when value is already string, otherwise it will be cast
  46261. // to string and cause the type check to miss.
  46262. function prependModifier (value, symbol) {
  46263. return typeof value === 'string' ? symbol + value : value
  46264. }
  46265. /* */
  46266. function installRenderHelpers (target) {
  46267. target._o = markOnce;
  46268. target._n = toNumber;
  46269. target._s = toString;
  46270. target._l = renderList;
  46271. target._t = renderSlot;
  46272. target._q = looseEqual;
  46273. target._i = looseIndexOf;
  46274. target._m = renderStatic;
  46275. target._f = resolveFilter;
  46276. target._k = checkKeyCodes;
  46277. target._b = bindObjectProps;
  46278. target._v = createTextVNode;
  46279. target._e = createEmptyVNode;
  46280. target._u = resolveScopedSlots;
  46281. target._g = bindObjectListeners;
  46282. target._d = bindDynamicKeys;
  46283. target._p = prependModifier;
  46284. }
  46285. /* */
  46286. function FunctionalRenderContext (
  46287. data,
  46288. props,
  46289. children,
  46290. parent,
  46291. Ctor
  46292. ) {
  46293. var this$1 = this;
  46294. var options = Ctor.options;
  46295. // ensure the createElement function in functional components
  46296. // gets a unique context - this is necessary for correct named slot check
  46297. var contextVm;
  46298. if (hasOwn(parent, '_uid')) {
  46299. contextVm = Object.create(parent);
  46300. // $flow-disable-line
  46301. contextVm._original = parent;
  46302. } else {
  46303. // the context vm passed in is a functional context as well.
  46304. // in this case we want to make sure we are able to get a hold to the
  46305. // real context instance.
  46306. contextVm = parent;
  46307. // $flow-disable-line
  46308. parent = parent._original;
  46309. }
  46310. var isCompiled = isTrue(options._compiled);
  46311. var needNormalization = !isCompiled;
  46312. this.data = data;
  46313. this.props = props;
  46314. this.children = children;
  46315. this.parent = parent;
  46316. this.listeners = data.on || emptyObject;
  46317. this.injections = resolveInject(options.inject, parent);
  46318. this.slots = function () {
  46319. if (!this$1.$slots) {
  46320. normalizeScopedSlots(
  46321. data.scopedSlots,
  46322. this$1.$slots = resolveSlots(children, parent)
  46323. );
  46324. }
  46325. return this$1.$slots
  46326. };
  46327. Object.defineProperty(this, 'scopedSlots', ({
  46328. enumerable: true,
  46329. get: function get () {
  46330. return normalizeScopedSlots(data.scopedSlots, this.slots())
  46331. }
  46332. }));
  46333. // support for compiled functional template
  46334. if (isCompiled) {
  46335. // exposing $options for renderStatic()
  46336. this.$options = options;
  46337. // pre-resolve slots for renderSlot()
  46338. this.$slots = this.slots();
  46339. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  46340. }
  46341. if (options._scopeId) {
  46342. this._c = function (a, b, c, d) {
  46343. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  46344. if (vnode && !Array.isArray(vnode)) {
  46345. vnode.fnScopeId = options._scopeId;
  46346. vnode.fnContext = parent;
  46347. }
  46348. return vnode
  46349. };
  46350. } else {
  46351. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  46352. }
  46353. }
  46354. installRenderHelpers(FunctionalRenderContext.prototype);
  46355. function createFunctionalComponent (
  46356. Ctor,
  46357. propsData,
  46358. data,
  46359. contextVm,
  46360. children
  46361. ) {
  46362. var options = Ctor.options;
  46363. var props = {};
  46364. var propOptions = options.props;
  46365. if (isDef(propOptions)) {
  46366. for (var key in propOptions) {
  46367. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  46368. }
  46369. } else {
  46370. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  46371. if (isDef(data.props)) { mergeProps(props, data.props); }
  46372. }
  46373. var renderContext = new FunctionalRenderContext(
  46374. data,
  46375. props,
  46376. children,
  46377. contextVm,
  46378. Ctor
  46379. );
  46380. var vnode = options.render.call(null, renderContext._c, renderContext);
  46381. if (vnode instanceof VNode) {
  46382. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  46383. } else if (Array.isArray(vnode)) {
  46384. var vnodes = normalizeChildren(vnode) || [];
  46385. var res = new Array(vnodes.length);
  46386. for (var i = 0; i < vnodes.length; i++) {
  46387. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  46388. }
  46389. return res
  46390. }
  46391. }
  46392. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  46393. // #7817 clone node before setting fnContext, otherwise if the node is reused
  46394. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  46395. // that should not be matched to match.
  46396. var clone = cloneVNode(vnode);
  46397. clone.fnContext = contextVm;
  46398. clone.fnOptions = options;
  46399. {
  46400. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  46401. }
  46402. if (data.slot) {
  46403. (clone.data || (clone.data = {})).slot = data.slot;
  46404. }
  46405. return clone
  46406. }
  46407. function mergeProps (to, from) {
  46408. for (var key in from) {
  46409. to[camelize(key)] = from[key];
  46410. }
  46411. }
  46412. /* */
  46413. /* */
  46414. /* */
  46415. /* */
  46416. // inline hooks to be invoked on component VNodes during patch
  46417. var componentVNodeHooks = {
  46418. init: function init (vnode, hydrating) {
  46419. if (
  46420. vnode.componentInstance &&
  46421. !vnode.componentInstance._isDestroyed &&
  46422. vnode.data.keepAlive
  46423. ) {
  46424. // kept-alive components, treat as a patch
  46425. var mountedNode = vnode; // work around flow
  46426. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  46427. } else {
  46428. var child = vnode.componentInstance = createComponentInstanceForVnode(
  46429. vnode,
  46430. activeInstance
  46431. );
  46432. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  46433. }
  46434. },
  46435. prepatch: function prepatch (oldVnode, vnode) {
  46436. var options = vnode.componentOptions;
  46437. var child = vnode.componentInstance = oldVnode.componentInstance;
  46438. updateChildComponent(
  46439. child,
  46440. options.propsData, // updated props
  46441. options.listeners, // updated listeners
  46442. vnode, // new parent vnode
  46443. options.children // new children
  46444. );
  46445. },
  46446. insert: function insert (vnode) {
  46447. var context = vnode.context;
  46448. var componentInstance = vnode.componentInstance;
  46449. if (!componentInstance._isMounted) {
  46450. componentInstance._isMounted = true;
  46451. callHook(componentInstance, 'mounted');
  46452. }
  46453. if (vnode.data.keepAlive) {
  46454. if (context._isMounted) {
  46455. // vue-router#1212
  46456. // During updates, a kept-alive component's child components may
  46457. // change, so directly walking the tree here may call activated hooks
  46458. // on incorrect children. Instead we push them into a queue which will
  46459. // be processed after the whole patch process ended.
  46460. queueActivatedComponent(componentInstance);
  46461. } else {
  46462. activateChildComponent(componentInstance, true /* direct */);
  46463. }
  46464. }
  46465. },
  46466. destroy: function destroy (vnode) {
  46467. var componentInstance = vnode.componentInstance;
  46468. if (!componentInstance._isDestroyed) {
  46469. if (!vnode.data.keepAlive) {
  46470. componentInstance.$destroy();
  46471. } else {
  46472. deactivateChildComponent(componentInstance, true /* direct */);
  46473. }
  46474. }
  46475. }
  46476. };
  46477. var hooksToMerge = Object.keys(componentVNodeHooks);
  46478. function createComponent (
  46479. Ctor,
  46480. data,
  46481. context,
  46482. children,
  46483. tag
  46484. ) {
  46485. if (isUndef(Ctor)) {
  46486. return
  46487. }
  46488. var baseCtor = context.$options._base;
  46489. // plain options object: turn it into a constructor
  46490. if (isObject(Ctor)) {
  46491. Ctor = baseCtor.extend(Ctor);
  46492. }
  46493. // if at this stage it's not a constructor or an async component factory,
  46494. // reject.
  46495. if (typeof Ctor !== 'function') {
  46496. {
  46497. warn(("Invalid Component definition: " + (String(Ctor))), context);
  46498. }
  46499. return
  46500. }
  46501. // async component
  46502. var asyncFactory;
  46503. if (isUndef(Ctor.cid)) {
  46504. asyncFactory = Ctor;
  46505. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  46506. if (Ctor === undefined) {
  46507. // return a placeholder node for async component, which is rendered
  46508. // as a comment node but preserves all the raw information for the node.
  46509. // the information will be used for async server-rendering and hydration.
  46510. return createAsyncPlaceholder(
  46511. asyncFactory,
  46512. data,
  46513. context,
  46514. children,
  46515. tag
  46516. )
  46517. }
  46518. }
  46519. data = data || {};
  46520. // resolve constructor options in case global mixins are applied after
  46521. // component constructor creation
  46522. resolveConstructorOptions(Ctor);
  46523. // transform component v-model data into props & events
  46524. if (isDef(data.model)) {
  46525. transformModel(Ctor.options, data);
  46526. }
  46527. // extract props
  46528. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  46529. // functional component
  46530. if (isTrue(Ctor.options.functional)) {
  46531. return createFunctionalComponent(Ctor, propsData, data, context, children)
  46532. }
  46533. // extract listeners, since these needs to be treated as
  46534. // child component listeners instead of DOM listeners
  46535. var listeners = data.on;
  46536. // replace with listeners with .native modifier
  46537. // so it gets processed during parent component patch.
  46538. data.on = data.nativeOn;
  46539. if (isTrue(Ctor.options.abstract)) {
  46540. // abstract components do not keep anything
  46541. // other than props & listeners & slot
  46542. // work around flow
  46543. var slot = data.slot;
  46544. data = {};
  46545. if (slot) {
  46546. data.slot = slot;
  46547. }
  46548. }
  46549. // install component management hooks onto the placeholder node
  46550. installComponentHooks(data);
  46551. // return a placeholder vnode
  46552. var name = Ctor.options.name || tag;
  46553. var vnode = new VNode(
  46554. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  46555. data, undefined, undefined, undefined, context,
  46556. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  46557. asyncFactory
  46558. );
  46559. return vnode
  46560. }
  46561. function createComponentInstanceForVnode (
  46562. vnode, // we know it's MountedComponentVNode but flow doesn't
  46563. parent // activeInstance in lifecycle state
  46564. ) {
  46565. var options = {
  46566. _isComponent: true,
  46567. _parentVnode: vnode,
  46568. parent: parent
  46569. };
  46570. // check inline-template render functions
  46571. var inlineTemplate = vnode.data.inlineTemplate;
  46572. if (isDef(inlineTemplate)) {
  46573. options.render = inlineTemplate.render;
  46574. options.staticRenderFns = inlineTemplate.staticRenderFns;
  46575. }
  46576. return new vnode.componentOptions.Ctor(options)
  46577. }
  46578. function installComponentHooks (data) {
  46579. var hooks = data.hook || (data.hook = {});
  46580. for (var i = 0; i < hooksToMerge.length; i++) {
  46581. var key = hooksToMerge[i];
  46582. var existing = hooks[key];
  46583. var toMerge = componentVNodeHooks[key];
  46584. if (existing !== toMerge && !(existing && existing._merged)) {
  46585. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  46586. }
  46587. }
  46588. }
  46589. function mergeHook$1 (f1, f2) {
  46590. var merged = function (a, b) {
  46591. // flow complains about extra args which is why we use any
  46592. f1(a, b);
  46593. f2(a, b);
  46594. };
  46595. merged._merged = true;
  46596. return merged
  46597. }
  46598. // transform component v-model info (value and callback) into
  46599. // prop and event handler respectively.
  46600. function transformModel (options, data) {
  46601. var prop = (options.model && options.model.prop) || 'value';
  46602. var event = (options.model && options.model.event) || 'input'
  46603. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  46604. var on = data.on || (data.on = {});
  46605. var existing = on[event];
  46606. var callback = data.model.callback;
  46607. if (isDef(existing)) {
  46608. if (
  46609. Array.isArray(existing)
  46610. ? existing.indexOf(callback) === -1
  46611. : existing !== callback
  46612. ) {
  46613. on[event] = [callback].concat(existing);
  46614. }
  46615. } else {
  46616. on[event] = callback;
  46617. }
  46618. }
  46619. /* */
  46620. var SIMPLE_NORMALIZE = 1;
  46621. var ALWAYS_NORMALIZE = 2;
  46622. // wrapper function for providing a more flexible interface
  46623. // without getting yelled at by flow
  46624. function createElement (
  46625. context,
  46626. tag,
  46627. data,
  46628. children,
  46629. normalizationType,
  46630. alwaysNormalize
  46631. ) {
  46632. if (Array.isArray(data) || isPrimitive(data)) {
  46633. normalizationType = children;
  46634. children = data;
  46635. data = undefined;
  46636. }
  46637. if (isTrue(alwaysNormalize)) {
  46638. normalizationType = ALWAYS_NORMALIZE;
  46639. }
  46640. return _createElement(context, tag, data, children, normalizationType)
  46641. }
  46642. function _createElement (
  46643. context,
  46644. tag,
  46645. data,
  46646. children,
  46647. normalizationType
  46648. ) {
  46649. if (isDef(data) && isDef((data).__ob__)) {
  46650. warn(
  46651. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  46652. 'Always create fresh vnode data objects in each render!',
  46653. context
  46654. );
  46655. return createEmptyVNode()
  46656. }
  46657. // object syntax in v-bind
  46658. if (isDef(data) && isDef(data.is)) {
  46659. tag = data.is;
  46660. }
  46661. if (!tag) {
  46662. // in case of component :is set to falsy value
  46663. return createEmptyVNode()
  46664. }
  46665. // warn against non-primitive key
  46666. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  46667. ) {
  46668. {
  46669. warn(
  46670. 'Avoid using non-primitive value as key, ' +
  46671. 'use string/number value instead.',
  46672. context
  46673. );
  46674. }
  46675. }
  46676. // support single function children as default scoped slot
  46677. if (Array.isArray(children) &&
  46678. typeof children[0] === 'function'
  46679. ) {
  46680. data = data || {};
  46681. data.scopedSlots = { default: children[0] };
  46682. children.length = 0;
  46683. }
  46684. if (normalizationType === ALWAYS_NORMALIZE) {
  46685. children = normalizeChildren(children);
  46686. } else if (normalizationType === SIMPLE_NORMALIZE) {
  46687. children = simpleNormalizeChildren(children);
  46688. }
  46689. var vnode, ns;
  46690. if (typeof tag === 'string') {
  46691. var Ctor;
  46692. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  46693. if (config.isReservedTag(tag)) {
  46694. // platform built-in elements
  46695. if (isDef(data) && isDef(data.nativeOn)) {
  46696. warn(
  46697. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  46698. context
  46699. );
  46700. }
  46701. vnode = new VNode(
  46702. config.parsePlatformTagName(tag), data, children,
  46703. undefined, undefined, context
  46704. );
  46705. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  46706. // component
  46707. vnode = createComponent(Ctor, data, context, children, tag);
  46708. } else {
  46709. // unknown or unlisted namespaced elements
  46710. // check at runtime because it may get assigned a namespace when its
  46711. // parent normalizes children
  46712. vnode = new VNode(
  46713. tag, data, children,
  46714. undefined, undefined, context
  46715. );
  46716. }
  46717. } else {
  46718. // direct component options / constructor
  46719. vnode = createComponent(tag, data, context, children);
  46720. }
  46721. if (Array.isArray(vnode)) {
  46722. return vnode
  46723. } else if (isDef(vnode)) {
  46724. if (isDef(ns)) { applyNS(vnode, ns); }
  46725. if (isDef(data)) { registerDeepBindings(data); }
  46726. return vnode
  46727. } else {
  46728. return createEmptyVNode()
  46729. }
  46730. }
  46731. function applyNS (vnode, ns, force) {
  46732. vnode.ns = ns;
  46733. if (vnode.tag === 'foreignObject') {
  46734. // use default namespace inside foreignObject
  46735. ns = undefined;
  46736. force = true;
  46737. }
  46738. if (isDef(vnode.children)) {
  46739. for (var i = 0, l = vnode.children.length; i < l; i++) {
  46740. var child = vnode.children[i];
  46741. if (isDef(child.tag) && (
  46742. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  46743. applyNS(child, ns, force);
  46744. }
  46745. }
  46746. }
  46747. }
  46748. // ref #5318
  46749. // necessary to ensure parent re-render when deep bindings like :style and
  46750. // :class are used on slot nodes
  46751. function registerDeepBindings (data) {
  46752. if (isObject(data.style)) {
  46753. traverse(data.style);
  46754. }
  46755. if (isObject(data.class)) {
  46756. traverse(data.class);
  46757. }
  46758. }
  46759. /* */
  46760. function initRender (vm) {
  46761. vm._vnode = null; // the root of the child tree
  46762. vm._staticTrees = null; // v-once cached trees
  46763. var options = vm.$options;
  46764. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  46765. var renderContext = parentVnode && parentVnode.context;
  46766. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  46767. vm.$scopedSlots = emptyObject;
  46768. // bind the createElement fn to this instance
  46769. // so that we get proper render context inside it.
  46770. // args order: tag, data, children, normalizationType, alwaysNormalize
  46771. // internal version is used by render functions compiled from templates
  46772. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  46773. // normalization is always applied for the public version, used in
  46774. // user-written render functions.
  46775. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  46776. // $attrs & $listeners are exposed for easier HOC creation.
  46777. // they need to be reactive so that HOCs using them are always updated
  46778. var parentData = parentVnode && parentVnode.data;
  46779. /* istanbul ignore else */
  46780. {
  46781. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  46782. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  46783. }, true);
  46784. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  46785. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  46786. }, true);
  46787. }
  46788. }
  46789. var currentRenderingInstance = null;
  46790. function renderMixin (Vue) {
  46791. // install runtime convenience helpers
  46792. installRenderHelpers(Vue.prototype);
  46793. Vue.prototype.$nextTick = function (fn) {
  46794. return nextTick(fn, this)
  46795. };
  46796. Vue.prototype._render = function () {
  46797. var vm = this;
  46798. var ref = vm.$options;
  46799. var render = ref.render;
  46800. var _parentVnode = ref._parentVnode;
  46801. if (_parentVnode) {
  46802. vm.$scopedSlots = normalizeScopedSlots(
  46803. _parentVnode.data.scopedSlots,
  46804. vm.$slots,
  46805. vm.$scopedSlots
  46806. );
  46807. }
  46808. // set parent vnode. this allows render functions to have access
  46809. // to the data on the placeholder node.
  46810. vm.$vnode = _parentVnode;
  46811. // render self
  46812. var vnode;
  46813. try {
  46814. // There's no need to maintain a stack because all render fns are called
  46815. // separately from one another. Nested component's render fns are called
  46816. // when parent component is patched.
  46817. currentRenderingInstance = vm;
  46818. vnode = render.call(vm._renderProxy, vm.$createElement);
  46819. } catch (e) {
  46820. handleError(e, vm, "render");
  46821. // return error render result,
  46822. // or previous vnode to prevent render error causing blank component
  46823. /* istanbul ignore else */
  46824. if (vm.$options.renderError) {
  46825. try {
  46826. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  46827. } catch (e) {
  46828. handleError(e, vm, "renderError");
  46829. vnode = vm._vnode;
  46830. }
  46831. } else {
  46832. vnode = vm._vnode;
  46833. }
  46834. } finally {
  46835. currentRenderingInstance = null;
  46836. }
  46837. // if the returned array contains only a single node, allow it
  46838. if (Array.isArray(vnode) && vnode.length === 1) {
  46839. vnode = vnode[0];
  46840. }
  46841. // return empty vnode in case the render function errored out
  46842. if (!(vnode instanceof VNode)) {
  46843. if (Array.isArray(vnode)) {
  46844. warn(
  46845. 'Multiple root nodes returned from render function. Render function ' +
  46846. 'should return a single root node.',
  46847. vm
  46848. );
  46849. }
  46850. vnode = createEmptyVNode();
  46851. }
  46852. // set parent
  46853. vnode.parent = _parentVnode;
  46854. return vnode
  46855. };
  46856. }
  46857. /* */
  46858. function ensureCtor (comp, base) {
  46859. if (
  46860. comp.__esModule ||
  46861. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  46862. ) {
  46863. comp = comp.default;
  46864. }
  46865. return isObject(comp)
  46866. ? base.extend(comp)
  46867. : comp
  46868. }
  46869. function createAsyncPlaceholder (
  46870. factory,
  46871. data,
  46872. context,
  46873. children,
  46874. tag
  46875. ) {
  46876. var node = createEmptyVNode();
  46877. node.asyncFactory = factory;
  46878. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  46879. return node
  46880. }
  46881. function resolveAsyncComponent (
  46882. factory,
  46883. baseCtor
  46884. ) {
  46885. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  46886. return factory.errorComp
  46887. }
  46888. if (isDef(factory.resolved)) {
  46889. return factory.resolved
  46890. }
  46891. var owner = currentRenderingInstance;
  46892. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  46893. // already pending
  46894. factory.owners.push(owner);
  46895. }
  46896. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  46897. return factory.loadingComp
  46898. }
  46899. if (owner && !isDef(factory.owners)) {
  46900. var owners = factory.owners = [owner];
  46901. var sync = true;
  46902. var timerLoading = null;
  46903. var timerTimeout = null
  46904. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  46905. var forceRender = function (renderCompleted) {
  46906. for (var i = 0, l = owners.length; i < l; i++) {
  46907. (owners[i]).$forceUpdate();
  46908. }
  46909. if (renderCompleted) {
  46910. owners.length = 0;
  46911. if (timerLoading !== null) {
  46912. clearTimeout(timerLoading);
  46913. timerLoading = null;
  46914. }
  46915. if (timerTimeout !== null) {
  46916. clearTimeout(timerTimeout);
  46917. timerTimeout = null;
  46918. }
  46919. }
  46920. };
  46921. var resolve = once(function (res) {
  46922. // cache resolved
  46923. factory.resolved = ensureCtor(res, baseCtor);
  46924. // invoke callbacks only if this is not a synchronous resolve
  46925. // (async resolves are shimmed as synchronous during SSR)
  46926. if (!sync) {
  46927. forceRender(true);
  46928. } else {
  46929. owners.length = 0;
  46930. }
  46931. });
  46932. var reject = once(function (reason) {
  46933. warn(
  46934. "Failed to resolve async component: " + (String(factory)) +
  46935. (reason ? ("\nReason: " + reason) : '')
  46936. );
  46937. if (isDef(factory.errorComp)) {
  46938. factory.error = true;
  46939. forceRender(true);
  46940. }
  46941. });
  46942. var res = factory(resolve, reject);
  46943. if (isObject(res)) {
  46944. if (isPromise(res)) {
  46945. // () => Promise
  46946. if (isUndef(factory.resolved)) {
  46947. res.then(resolve, reject);
  46948. }
  46949. } else if (isPromise(res.component)) {
  46950. res.component.then(resolve, reject);
  46951. if (isDef(res.error)) {
  46952. factory.errorComp = ensureCtor(res.error, baseCtor);
  46953. }
  46954. if (isDef(res.loading)) {
  46955. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  46956. if (res.delay === 0) {
  46957. factory.loading = true;
  46958. } else {
  46959. timerLoading = setTimeout(function () {
  46960. timerLoading = null;
  46961. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  46962. factory.loading = true;
  46963. forceRender(false);
  46964. }
  46965. }, res.delay || 200);
  46966. }
  46967. }
  46968. if (isDef(res.timeout)) {
  46969. timerTimeout = setTimeout(function () {
  46970. timerTimeout = null;
  46971. if (isUndef(factory.resolved)) {
  46972. reject(
  46973. "timeout (" + (res.timeout) + "ms)"
  46974. );
  46975. }
  46976. }, res.timeout);
  46977. }
  46978. }
  46979. }
  46980. sync = false;
  46981. // return in case resolved synchronously
  46982. return factory.loading
  46983. ? factory.loadingComp
  46984. : factory.resolved
  46985. }
  46986. }
  46987. /* */
  46988. function isAsyncPlaceholder (node) {
  46989. return node.isComment && node.asyncFactory
  46990. }
  46991. /* */
  46992. function getFirstComponentChild (children) {
  46993. if (Array.isArray(children)) {
  46994. for (var i = 0; i < children.length; i++) {
  46995. var c = children[i];
  46996. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  46997. return c
  46998. }
  46999. }
  47000. }
  47001. }
  47002. /* */
  47003. /* */
  47004. function initEvents (vm) {
  47005. vm._events = Object.create(null);
  47006. vm._hasHookEvent = false;
  47007. // init parent attached events
  47008. var listeners = vm.$options._parentListeners;
  47009. if (listeners) {
  47010. updateComponentListeners(vm, listeners);
  47011. }
  47012. }
  47013. var target;
  47014. function add (event, fn) {
  47015. target.$on(event, fn);
  47016. }
  47017. function remove$1 (event, fn) {
  47018. target.$off(event, fn);
  47019. }
  47020. function createOnceHandler (event, fn) {
  47021. var _target = target;
  47022. return function onceHandler () {
  47023. var res = fn.apply(null, arguments);
  47024. if (res !== null) {
  47025. _target.$off(event, onceHandler);
  47026. }
  47027. }
  47028. }
  47029. function updateComponentListeners (
  47030. vm,
  47031. listeners,
  47032. oldListeners
  47033. ) {
  47034. target = vm;
  47035. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  47036. target = undefined;
  47037. }
  47038. function eventsMixin (Vue) {
  47039. var hookRE = /^hook:/;
  47040. Vue.prototype.$on = function (event, fn) {
  47041. var vm = this;
  47042. if (Array.isArray(event)) {
  47043. for (var i = 0, l = event.length; i < l; i++) {
  47044. vm.$on(event[i], fn);
  47045. }
  47046. } else {
  47047. (vm._events[event] || (vm._events[event] = [])).push(fn);
  47048. // optimize hook:event cost by using a boolean flag marked at registration
  47049. // instead of a hash lookup
  47050. if (hookRE.test(event)) {
  47051. vm._hasHookEvent = true;
  47052. }
  47053. }
  47054. return vm
  47055. };
  47056. Vue.prototype.$once = function (event, fn) {
  47057. var vm = this;
  47058. function on () {
  47059. vm.$off(event, on);
  47060. fn.apply(vm, arguments);
  47061. }
  47062. on.fn = fn;
  47063. vm.$on(event, on);
  47064. return vm
  47065. };
  47066. Vue.prototype.$off = function (event, fn) {
  47067. var vm = this;
  47068. // all
  47069. if (!arguments.length) {
  47070. vm._events = Object.create(null);
  47071. return vm
  47072. }
  47073. // array of events
  47074. if (Array.isArray(event)) {
  47075. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  47076. vm.$off(event[i$1], fn);
  47077. }
  47078. return vm
  47079. }
  47080. // specific event
  47081. var cbs = vm._events[event];
  47082. if (!cbs) {
  47083. return vm
  47084. }
  47085. if (!fn) {
  47086. vm._events[event] = null;
  47087. return vm
  47088. }
  47089. // specific handler
  47090. var cb;
  47091. var i = cbs.length;
  47092. while (i--) {
  47093. cb = cbs[i];
  47094. if (cb === fn || cb.fn === fn) {
  47095. cbs.splice(i, 1);
  47096. break
  47097. }
  47098. }
  47099. return vm
  47100. };
  47101. Vue.prototype.$emit = function (event) {
  47102. var vm = this;
  47103. {
  47104. var lowerCaseEvent = event.toLowerCase();
  47105. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  47106. tip(
  47107. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  47108. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  47109. "Note that HTML attributes are case-insensitive and you cannot use " +
  47110. "v-on to listen to camelCase events when using in-DOM templates. " +
  47111. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  47112. );
  47113. }
  47114. }
  47115. var cbs = vm._events[event];
  47116. if (cbs) {
  47117. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  47118. var args = toArray(arguments, 1);
  47119. var info = "event handler for \"" + event + "\"";
  47120. for (var i = 0, l = cbs.length; i < l; i++) {
  47121. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  47122. }
  47123. }
  47124. return vm
  47125. };
  47126. }
  47127. /* */
  47128. var activeInstance = null;
  47129. var isUpdatingChildComponent = false;
  47130. function setActiveInstance(vm) {
  47131. var prevActiveInstance = activeInstance;
  47132. activeInstance = vm;
  47133. return function () {
  47134. activeInstance = prevActiveInstance;
  47135. }
  47136. }
  47137. function initLifecycle (vm) {
  47138. var options = vm.$options;
  47139. // locate first non-abstract parent
  47140. var parent = options.parent;
  47141. if (parent && !options.abstract) {
  47142. while (parent.$options.abstract && parent.$parent) {
  47143. parent = parent.$parent;
  47144. }
  47145. parent.$children.push(vm);
  47146. }
  47147. vm.$parent = parent;
  47148. vm.$root = parent ? parent.$root : vm;
  47149. vm.$children = [];
  47150. vm.$refs = {};
  47151. vm._watcher = null;
  47152. vm._inactive = null;
  47153. vm._directInactive = false;
  47154. vm._isMounted = false;
  47155. vm._isDestroyed = false;
  47156. vm._isBeingDestroyed = false;
  47157. }
  47158. function lifecycleMixin (Vue) {
  47159. Vue.prototype._update = function (vnode, hydrating) {
  47160. var vm = this;
  47161. var prevEl = vm.$el;
  47162. var prevVnode = vm._vnode;
  47163. var restoreActiveInstance = setActiveInstance(vm);
  47164. vm._vnode = vnode;
  47165. // Vue.prototype.__patch__ is injected in entry points
  47166. // based on the rendering backend used.
  47167. if (!prevVnode) {
  47168. // initial render
  47169. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  47170. } else {
  47171. // updates
  47172. vm.$el = vm.__patch__(prevVnode, vnode);
  47173. }
  47174. restoreActiveInstance();
  47175. // update __vue__ reference
  47176. if (prevEl) {
  47177. prevEl.__vue__ = null;
  47178. }
  47179. if (vm.$el) {
  47180. vm.$el.__vue__ = vm;
  47181. }
  47182. // if parent is an HOC, update its $el as well
  47183. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  47184. vm.$parent.$el = vm.$el;
  47185. }
  47186. // updated hook is called by the scheduler to ensure that children are
  47187. // updated in a parent's updated hook.
  47188. };
  47189. Vue.prototype.$forceUpdate = function () {
  47190. var vm = this;
  47191. if (vm._watcher) {
  47192. vm._watcher.update();
  47193. }
  47194. };
  47195. Vue.prototype.$destroy = function () {
  47196. var vm = this;
  47197. if (vm._isBeingDestroyed) {
  47198. return
  47199. }
  47200. callHook(vm, 'beforeDestroy');
  47201. vm._isBeingDestroyed = true;
  47202. // remove self from parent
  47203. var parent = vm.$parent;
  47204. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  47205. remove(parent.$children, vm);
  47206. }
  47207. // teardown watchers
  47208. if (vm._watcher) {
  47209. vm._watcher.teardown();
  47210. }
  47211. var i = vm._watchers.length;
  47212. while (i--) {
  47213. vm._watchers[i].teardown();
  47214. }
  47215. // remove reference from data ob
  47216. // frozen object may not have observer.
  47217. if (vm._data.__ob__) {
  47218. vm._data.__ob__.vmCount--;
  47219. }
  47220. // call the last hook...
  47221. vm._isDestroyed = true;
  47222. // invoke destroy hooks on current rendered tree
  47223. vm.__patch__(vm._vnode, null);
  47224. // fire destroyed hook
  47225. callHook(vm, 'destroyed');
  47226. // turn off all instance listeners.
  47227. vm.$off();
  47228. // remove __vue__ reference
  47229. if (vm.$el) {
  47230. vm.$el.__vue__ = null;
  47231. }
  47232. // release circular reference (#6759)
  47233. if (vm.$vnode) {
  47234. vm.$vnode.parent = null;
  47235. }
  47236. };
  47237. }
  47238. function mountComponent (
  47239. vm,
  47240. el,
  47241. hydrating
  47242. ) {
  47243. vm.$el = el;
  47244. if (!vm.$options.render) {
  47245. vm.$options.render = createEmptyVNode;
  47246. {
  47247. /* istanbul ignore if */
  47248. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  47249. vm.$options.el || el) {
  47250. warn(
  47251. 'You are using the runtime-only build of Vue where the template ' +
  47252. 'compiler is not available. Either pre-compile the templates into ' +
  47253. 'render functions, or use the compiler-included build.',
  47254. vm
  47255. );
  47256. } else {
  47257. warn(
  47258. 'Failed to mount component: template or render function not defined.',
  47259. vm
  47260. );
  47261. }
  47262. }
  47263. }
  47264. callHook(vm, 'beforeMount');
  47265. var updateComponent;
  47266. /* istanbul ignore if */
  47267. if (config.performance && mark) {
  47268. updateComponent = function () {
  47269. var name = vm._name;
  47270. var id = vm._uid;
  47271. var startTag = "vue-perf-start:" + id;
  47272. var endTag = "vue-perf-end:" + id;
  47273. mark(startTag);
  47274. var vnode = vm._render();
  47275. mark(endTag);
  47276. measure(("vue " + name + " render"), startTag, endTag);
  47277. mark(startTag);
  47278. vm._update(vnode, hydrating);
  47279. mark(endTag);
  47280. measure(("vue " + name + " patch"), startTag, endTag);
  47281. };
  47282. } else {
  47283. updateComponent = function () {
  47284. vm._update(vm._render(), hydrating);
  47285. };
  47286. }
  47287. // we set this to vm._watcher inside the watcher's constructor
  47288. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  47289. // component's mounted hook), which relies on vm._watcher being already defined
  47290. new Watcher(vm, updateComponent, noop, {
  47291. before: function before () {
  47292. if (vm._isMounted && !vm._isDestroyed) {
  47293. callHook(vm, 'beforeUpdate');
  47294. }
  47295. }
  47296. }, true /* isRenderWatcher */);
  47297. hydrating = false;
  47298. // manually mounted instance, call mounted on self
  47299. // mounted is called for render-created child components in its inserted hook
  47300. if (vm.$vnode == null) {
  47301. vm._isMounted = true;
  47302. callHook(vm, 'mounted');
  47303. }
  47304. return vm
  47305. }
  47306. function updateChildComponent (
  47307. vm,
  47308. propsData,
  47309. listeners,
  47310. parentVnode,
  47311. renderChildren
  47312. ) {
  47313. {
  47314. isUpdatingChildComponent = true;
  47315. }
  47316. // determine whether component has slot children
  47317. // we need to do this before overwriting $options._renderChildren.
  47318. // check if there are dynamic scopedSlots (hand-written or compiled but with
  47319. // dynamic slot names). Static scoped slots compiled from template has the
  47320. // "$stable" marker.
  47321. var newScopedSlots = parentVnode.data.scopedSlots;
  47322. var oldScopedSlots = vm.$scopedSlots;
  47323. var hasDynamicScopedSlot = !!(
  47324. (newScopedSlots && !newScopedSlots.$stable) ||
  47325. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  47326. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  47327. );
  47328. // Any static slot children from the parent may have changed during parent's
  47329. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  47330. // update is necessary to ensure correctness.
  47331. var needsForceUpdate = !!(
  47332. renderChildren || // has new static slots
  47333. vm.$options._renderChildren || // has old static slots
  47334. hasDynamicScopedSlot
  47335. );
  47336. vm.$options._parentVnode = parentVnode;
  47337. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  47338. if (vm._vnode) { // update child tree's parent
  47339. vm._vnode.parent = parentVnode;
  47340. }
  47341. vm.$options._renderChildren = renderChildren;
  47342. // update $attrs and $listeners hash
  47343. // these are also reactive so they may trigger child update if the child
  47344. // used them during render
  47345. vm.$attrs = parentVnode.data.attrs || emptyObject;
  47346. vm.$listeners = listeners || emptyObject;
  47347. // update props
  47348. if (propsData && vm.$options.props) {
  47349. toggleObserving(false);
  47350. var props = vm._props;
  47351. var propKeys = vm.$options._propKeys || [];
  47352. for (var i = 0; i < propKeys.length; i++) {
  47353. var key = propKeys[i];
  47354. var propOptions = vm.$options.props; // wtf flow?
  47355. props[key] = validateProp(key, propOptions, propsData, vm);
  47356. }
  47357. toggleObserving(true);
  47358. // keep a copy of raw propsData
  47359. vm.$options.propsData = propsData;
  47360. }
  47361. // update listeners
  47362. listeners = listeners || emptyObject;
  47363. var oldListeners = vm.$options._parentListeners;
  47364. vm.$options._parentListeners = listeners;
  47365. updateComponentListeners(vm, listeners, oldListeners);
  47366. // resolve slots + force update if has children
  47367. if (needsForceUpdate) {
  47368. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  47369. vm.$forceUpdate();
  47370. }
  47371. {
  47372. isUpdatingChildComponent = false;
  47373. }
  47374. }
  47375. function isInInactiveTree (vm) {
  47376. while (vm && (vm = vm.$parent)) {
  47377. if (vm._inactive) { return true }
  47378. }
  47379. return false
  47380. }
  47381. function activateChildComponent (vm, direct) {
  47382. if (direct) {
  47383. vm._directInactive = false;
  47384. if (isInInactiveTree(vm)) {
  47385. return
  47386. }
  47387. } else if (vm._directInactive) {
  47388. return
  47389. }
  47390. if (vm._inactive || vm._inactive === null) {
  47391. vm._inactive = false;
  47392. for (var i = 0; i < vm.$children.length; i++) {
  47393. activateChildComponent(vm.$children[i]);
  47394. }
  47395. callHook(vm, 'activated');
  47396. }
  47397. }
  47398. function deactivateChildComponent (vm, direct) {
  47399. if (direct) {
  47400. vm._directInactive = true;
  47401. if (isInInactiveTree(vm)) {
  47402. return
  47403. }
  47404. }
  47405. if (!vm._inactive) {
  47406. vm._inactive = true;
  47407. for (var i = 0; i < vm.$children.length; i++) {
  47408. deactivateChildComponent(vm.$children[i]);
  47409. }
  47410. callHook(vm, 'deactivated');
  47411. }
  47412. }
  47413. function callHook (vm, hook) {
  47414. // #7573 disable dep collection when invoking lifecycle hooks
  47415. pushTarget();
  47416. var handlers = vm.$options[hook];
  47417. var info = hook + " hook";
  47418. if (handlers) {
  47419. for (var i = 0, j = handlers.length; i < j; i++) {
  47420. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  47421. }
  47422. }
  47423. if (vm._hasHookEvent) {
  47424. vm.$emit('hook:' + hook);
  47425. }
  47426. popTarget();
  47427. }
  47428. /* */
  47429. var MAX_UPDATE_COUNT = 100;
  47430. var queue = [];
  47431. var activatedChildren = [];
  47432. var has = {};
  47433. var circular = {};
  47434. var waiting = false;
  47435. var flushing = false;
  47436. var index = 0;
  47437. /**
  47438. * Reset the scheduler's state.
  47439. */
  47440. function resetSchedulerState () {
  47441. index = queue.length = activatedChildren.length = 0;
  47442. has = {};
  47443. {
  47444. circular = {};
  47445. }
  47446. waiting = flushing = false;
  47447. }
  47448. // Async edge case #6566 requires saving the timestamp when event listeners are
  47449. // attached. However, calling performance.now() has a perf overhead especially
  47450. // if the page has thousands of event listeners. Instead, we take a timestamp
  47451. // every time the scheduler flushes and use that for all event listeners
  47452. // attached during that flush.
  47453. var currentFlushTimestamp = 0;
  47454. // Async edge case fix requires storing an event listener's attach timestamp.
  47455. var getNow = Date.now;
  47456. // Determine what event timestamp the browser is using. Annoyingly, the
  47457. // timestamp can either be hi-res (relative to page load) or low-res
  47458. // (relative to UNIX epoch), so in order to compare time we have to use the
  47459. // same timestamp type when saving the flush timestamp.
  47460. // All IE versions use low-res event timestamps, and have problematic clock
  47461. // implementations (#9632)
  47462. if (inBrowser && !isIE) {
  47463. var performance = window.performance;
  47464. if (
  47465. performance &&
  47466. typeof performance.now === 'function' &&
  47467. getNow() > document.createEvent('Event').timeStamp
  47468. ) {
  47469. // if the event timestamp, although evaluated AFTER the Date.now(), is
  47470. // smaller than it, it means the event is using a hi-res timestamp,
  47471. // and we need to use the hi-res version for event listener timestamps as
  47472. // well.
  47473. getNow = function () { return performance.now(); };
  47474. }
  47475. }
  47476. /**
  47477. * Flush both queues and run the watchers.
  47478. */
  47479. function flushSchedulerQueue () {
  47480. currentFlushTimestamp = getNow();
  47481. flushing = true;
  47482. var watcher, id;
  47483. // Sort queue before flush.
  47484. // This ensures that:
  47485. // 1. Components are updated from parent to child. (because parent is always
  47486. // created before the child)
  47487. // 2. A component's user watchers are run before its render watcher (because
  47488. // user watchers are created before the render watcher)
  47489. // 3. If a component is destroyed during a parent component's watcher run,
  47490. // its watchers can be skipped.
  47491. queue.sort(function (a, b) { return a.id - b.id; });
  47492. // do not cache length because more watchers might be pushed
  47493. // as we run existing watchers
  47494. for (index = 0; index < queue.length; index++) {
  47495. watcher = queue[index];
  47496. if (watcher.before) {
  47497. watcher.before();
  47498. }
  47499. id = watcher.id;
  47500. has[id] = null;
  47501. watcher.run();
  47502. // in dev build, check and stop circular updates.
  47503. if (has[id] != null) {
  47504. circular[id] = (circular[id] || 0) + 1;
  47505. if (circular[id] > MAX_UPDATE_COUNT) {
  47506. warn(
  47507. 'You may have an infinite update loop ' + (
  47508. watcher.user
  47509. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  47510. : "in a component render function."
  47511. ),
  47512. watcher.vm
  47513. );
  47514. break
  47515. }
  47516. }
  47517. }
  47518. // keep copies of post queues before resetting state
  47519. var activatedQueue = activatedChildren.slice();
  47520. var updatedQueue = queue.slice();
  47521. resetSchedulerState();
  47522. // call component updated and activated hooks
  47523. callActivatedHooks(activatedQueue);
  47524. callUpdatedHooks(updatedQueue);
  47525. // devtool hook
  47526. /* istanbul ignore if */
  47527. if (devtools && config.devtools) {
  47528. devtools.emit('flush');
  47529. }
  47530. }
  47531. function callUpdatedHooks (queue) {
  47532. var i = queue.length;
  47533. while (i--) {
  47534. var watcher = queue[i];
  47535. var vm = watcher.vm;
  47536. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  47537. callHook(vm, 'updated');
  47538. }
  47539. }
  47540. }
  47541. /**
  47542. * Queue a kept-alive component that was activated during patch.
  47543. * The queue will be processed after the entire tree has been patched.
  47544. */
  47545. function queueActivatedComponent (vm) {
  47546. // setting _inactive to false here so that a render function can
  47547. // rely on checking whether it's in an inactive tree (e.g. router-view)
  47548. vm._inactive = false;
  47549. activatedChildren.push(vm);
  47550. }
  47551. function callActivatedHooks (queue) {
  47552. for (var i = 0; i < queue.length; i++) {
  47553. queue[i]._inactive = true;
  47554. activateChildComponent(queue[i], true /* true */);
  47555. }
  47556. }
  47557. /**
  47558. * Push a watcher into the watcher queue.
  47559. * Jobs with duplicate IDs will be skipped unless it's
  47560. * pushed when the queue is being flushed.
  47561. */
  47562. function queueWatcher (watcher) {
  47563. var id = watcher.id;
  47564. if (has[id] == null) {
  47565. has[id] = true;
  47566. if (!flushing) {
  47567. queue.push(watcher);
  47568. } else {
  47569. // if already flushing, splice the watcher based on its id
  47570. // if already past its id, it will be run next immediately.
  47571. var i = queue.length - 1;
  47572. while (i > index && queue[i].id > watcher.id) {
  47573. i--;
  47574. }
  47575. queue.splice(i + 1, 0, watcher);
  47576. }
  47577. // queue the flush
  47578. if (!waiting) {
  47579. waiting = true;
  47580. if (!config.async) {
  47581. flushSchedulerQueue();
  47582. return
  47583. }
  47584. nextTick(flushSchedulerQueue);
  47585. }
  47586. }
  47587. }
  47588. /* */
  47589. var uid$2 = 0;
  47590. /**
  47591. * A watcher parses an expression, collects dependencies,
  47592. * and fires callback when the expression value changes.
  47593. * This is used for both the $watch() api and directives.
  47594. */
  47595. var Watcher = function Watcher (
  47596. vm,
  47597. expOrFn,
  47598. cb,
  47599. options,
  47600. isRenderWatcher
  47601. ) {
  47602. this.vm = vm;
  47603. if (isRenderWatcher) {
  47604. vm._watcher = this;
  47605. }
  47606. vm._watchers.push(this);
  47607. // options
  47608. if (options) {
  47609. this.deep = !!options.deep;
  47610. this.user = !!options.user;
  47611. this.lazy = !!options.lazy;
  47612. this.sync = !!options.sync;
  47613. this.before = options.before;
  47614. } else {
  47615. this.deep = this.user = this.lazy = this.sync = false;
  47616. }
  47617. this.cb = cb;
  47618. this.id = ++uid$2; // uid for batching
  47619. this.active = true;
  47620. this.dirty = this.lazy; // for lazy watchers
  47621. this.deps = [];
  47622. this.newDeps = [];
  47623. this.depIds = new _Set();
  47624. this.newDepIds = new _Set();
  47625. this.expression = expOrFn.toString();
  47626. // parse expression for getter
  47627. if (typeof expOrFn === 'function') {
  47628. this.getter = expOrFn;
  47629. } else {
  47630. this.getter = parsePath(expOrFn);
  47631. if (!this.getter) {
  47632. this.getter = noop;
  47633. warn(
  47634. "Failed watching path: \"" + expOrFn + "\" " +
  47635. 'Watcher only accepts simple dot-delimited paths. ' +
  47636. 'For full control, use a function instead.',
  47637. vm
  47638. );
  47639. }
  47640. }
  47641. this.value = this.lazy
  47642. ? undefined
  47643. : this.get();
  47644. };
  47645. /**
  47646. * Evaluate the getter, and re-collect dependencies.
  47647. */
  47648. Watcher.prototype.get = function get () {
  47649. pushTarget(this);
  47650. var value;
  47651. var vm = this.vm;
  47652. try {
  47653. value = this.getter.call(vm, vm);
  47654. } catch (e) {
  47655. if (this.user) {
  47656. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  47657. } else {
  47658. throw e
  47659. }
  47660. } finally {
  47661. // "touch" every property so they are all tracked as
  47662. // dependencies for deep watching
  47663. if (this.deep) {
  47664. traverse(value);
  47665. }
  47666. popTarget();
  47667. this.cleanupDeps();
  47668. }
  47669. return value
  47670. };
  47671. /**
  47672. * Add a dependency to this directive.
  47673. */
  47674. Watcher.prototype.addDep = function addDep (dep) {
  47675. var id = dep.id;
  47676. if (!this.newDepIds.has(id)) {
  47677. this.newDepIds.add(id);
  47678. this.newDeps.push(dep);
  47679. if (!this.depIds.has(id)) {
  47680. dep.addSub(this);
  47681. }
  47682. }
  47683. };
  47684. /**
  47685. * Clean up for dependency collection.
  47686. */
  47687. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  47688. var i = this.deps.length;
  47689. while (i--) {
  47690. var dep = this.deps[i];
  47691. if (!this.newDepIds.has(dep.id)) {
  47692. dep.removeSub(this);
  47693. }
  47694. }
  47695. var tmp = this.depIds;
  47696. this.depIds = this.newDepIds;
  47697. this.newDepIds = tmp;
  47698. this.newDepIds.clear();
  47699. tmp = this.deps;
  47700. this.deps = this.newDeps;
  47701. this.newDeps = tmp;
  47702. this.newDeps.length = 0;
  47703. };
  47704. /**
  47705. * Subscriber interface.
  47706. * Will be called when a dependency changes.
  47707. */
  47708. Watcher.prototype.update = function update () {
  47709. /* istanbul ignore else */
  47710. if (this.lazy) {
  47711. this.dirty = true;
  47712. } else if (this.sync) {
  47713. this.run();
  47714. } else {
  47715. queueWatcher(this);
  47716. }
  47717. };
  47718. /**
  47719. * Scheduler job interface.
  47720. * Will be called by the scheduler.
  47721. */
  47722. Watcher.prototype.run = function run () {
  47723. if (this.active) {
  47724. var value = this.get();
  47725. if (
  47726. value !== this.value ||
  47727. // Deep watchers and watchers on Object/Arrays should fire even
  47728. // when the value is the same, because the value may
  47729. // have mutated.
  47730. isObject(value) ||
  47731. this.deep
  47732. ) {
  47733. // set new value
  47734. var oldValue = this.value;
  47735. this.value = value;
  47736. if (this.user) {
  47737. try {
  47738. this.cb.call(this.vm, value, oldValue);
  47739. } catch (e) {
  47740. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  47741. }
  47742. } else {
  47743. this.cb.call(this.vm, value, oldValue);
  47744. }
  47745. }
  47746. }
  47747. };
  47748. /**
  47749. * Evaluate the value of the watcher.
  47750. * This only gets called for lazy watchers.
  47751. */
  47752. Watcher.prototype.evaluate = function evaluate () {
  47753. this.value = this.get();
  47754. this.dirty = false;
  47755. };
  47756. /**
  47757. * Depend on all deps collected by this watcher.
  47758. */
  47759. Watcher.prototype.depend = function depend () {
  47760. var i = this.deps.length;
  47761. while (i--) {
  47762. this.deps[i].depend();
  47763. }
  47764. };
  47765. /**
  47766. * Remove self from all dependencies' subscriber list.
  47767. */
  47768. Watcher.prototype.teardown = function teardown () {
  47769. if (this.active) {
  47770. // remove self from vm's watcher list
  47771. // this is a somewhat expensive operation so we skip it
  47772. // if the vm is being destroyed.
  47773. if (!this.vm._isBeingDestroyed) {
  47774. remove(this.vm._watchers, this);
  47775. }
  47776. var i = this.deps.length;
  47777. while (i--) {
  47778. this.deps[i].removeSub(this);
  47779. }
  47780. this.active = false;
  47781. }
  47782. };
  47783. /* */
  47784. var sharedPropertyDefinition = {
  47785. enumerable: true,
  47786. configurable: true,
  47787. get: noop,
  47788. set: noop
  47789. };
  47790. function proxy (target, sourceKey, key) {
  47791. sharedPropertyDefinition.get = function proxyGetter () {
  47792. return this[sourceKey][key]
  47793. };
  47794. sharedPropertyDefinition.set = function proxySetter (val) {
  47795. this[sourceKey][key] = val;
  47796. };
  47797. Object.defineProperty(target, key, sharedPropertyDefinition);
  47798. }
  47799. function initState (vm) {
  47800. vm._watchers = [];
  47801. var opts = vm.$options;
  47802. if (opts.props) { initProps(vm, opts.props); }
  47803. if (opts.methods) { initMethods(vm, opts.methods); }
  47804. if (opts.data) {
  47805. initData(vm);
  47806. } else {
  47807. observe(vm._data = {}, true /* asRootData */);
  47808. }
  47809. if (opts.computed) { initComputed(vm, opts.computed); }
  47810. if (opts.watch && opts.watch !== nativeWatch) {
  47811. initWatch(vm, opts.watch);
  47812. }
  47813. }
  47814. function initProps (vm, propsOptions) {
  47815. var propsData = vm.$options.propsData || {};
  47816. var props = vm._props = {};
  47817. // cache prop keys so that future props updates can iterate using Array
  47818. // instead of dynamic object key enumeration.
  47819. var keys = vm.$options._propKeys = [];
  47820. var isRoot = !vm.$parent;
  47821. // root instance props should be converted
  47822. if (!isRoot) {
  47823. toggleObserving(false);
  47824. }
  47825. var loop = function ( key ) {
  47826. keys.push(key);
  47827. var value = validateProp(key, propsOptions, propsData, vm);
  47828. /* istanbul ignore else */
  47829. {
  47830. var hyphenatedKey = hyphenate(key);
  47831. if (isReservedAttribute(hyphenatedKey) ||
  47832. config.isReservedAttr(hyphenatedKey)) {
  47833. warn(
  47834. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  47835. vm
  47836. );
  47837. }
  47838. defineReactive$$1(props, key, value, function () {
  47839. if (!isRoot && !isUpdatingChildComponent) {
  47840. warn(
  47841. "Avoid mutating a prop directly since the value will be " +
  47842. "overwritten whenever the parent component re-renders. " +
  47843. "Instead, use a data or computed property based on the prop's " +
  47844. "value. Prop being mutated: \"" + key + "\"",
  47845. vm
  47846. );
  47847. }
  47848. });
  47849. }
  47850. // static props are already proxied on the component's prototype
  47851. // during Vue.extend(). We only need to proxy props defined at
  47852. // instantiation here.
  47853. if (!(key in vm)) {
  47854. proxy(vm, "_props", key);
  47855. }
  47856. };
  47857. for (var key in propsOptions) loop( key );
  47858. toggleObserving(true);
  47859. }
  47860. function initData (vm) {
  47861. var data = vm.$options.data;
  47862. data = vm._data = typeof data === 'function'
  47863. ? getData(data, vm)
  47864. : data || {};
  47865. if (!isPlainObject(data)) {
  47866. data = {};
  47867. warn(
  47868. 'data functions should return an object:\n' +
  47869. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  47870. vm
  47871. );
  47872. }
  47873. // proxy data on instance
  47874. var keys = Object.keys(data);
  47875. var props = vm.$options.props;
  47876. var methods = vm.$options.methods;
  47877. var i = keys.length;
  47878. while (i--) {
  47879. var key = keys[i];
  47880. {
  47881. if (methods && hasOwn(methods, key)) {
  47882. warn(
  47883. ("Method \"" + key + "\" has already been defined as a data property."),
  47884. vm
  47885. );
  47886. }
  47887. }
  47888. if (props && hasOwn(props, key)) {
  47889. warn(
  47890. "The data property \"" + key + "\" is already declared as a prop. " +
  47891. "Use prop default value instead.",
  47892. vm
  47893. );
  47894. } else if (!isReserved(key)) {
  47895. proxy(vm, "_data", key);
  47896. }
  47897. }
  47898. // observe data
  47899. observe(data, true /* asRootData */);
  47900. }
  47901. function getData (data, vm) {
  47902. // #7573 disable dep collection when invoking data getters
  47903. pushTarget();
  47904. try {
  47905. return data.call(vm, vm)
  47906. } catch (e) {
  47907. handleError(e, vm, "data()");
  47908. return {}
  47909. } finally {
  47910. popTarget();
  47911. }
  47912. }
  47913. var computedWatcherOptions = { lazy: true };
  47914. function initComputed (vm, computed) {
  47915. // $flow-disable-line
  47916. var watchers = vm._computedWatchers = Object.create(null);
  47917. // computed properties are just getters during SSR
  47918. var isSSR = isServerRendering();
  47919. for (var key in computed) {
  47920. var userDef = computed[key];
  47921. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  47922. if (getter == null) {
  47923. warn(
  47924. ("Getter is missing for computed property \"" + key + "\"."),
  47925. vm
  47926. );
  47927. }
  47928. if (!isSSR) {
  47929. // create internal watcher for the computed property.
  47930. watchers[key] = new Watcher(
  47931. vm,
  47932. getter || noop,
  47933. noop,
  47934. computedWatcherOptions
  47935. );
  47936. }
  47937. // component-defined computed properties are already defined on the
  47938. // component prototype. We only need to define computed properties defined
  47939. // at instantiation here.
  47940. if (!(key in vm)) {
  47941. defineComputed(vm, key, userDef);
  47942. } else {
  47943. if (key in vm.$data) {
  47944. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  47945. } else if (vm.$options.props && key in vm.$options.props) {
  47946. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  47947. }
  47948. }
  47949. }
  47950. }
  47951. function defineComputed (
  47952. target,
  47953. key,
  47954. userDef
  47955. ) {
  47956. var shouldCache = !isServerRendering();
  47957. if (typeof userDef === 'function') {
  47958. sharedPropertyDefinition.get = shouldCache
  47959. ? createComputedGetter(key)
  47960. : createGetterInvoker(userDef);
  47961. sharedPropertyDefinition.set = noop;
  47962. } else {
  47963. sharedPropertyDefinition.get = userDef.get
  47964. ? shouldCache && userDef.cache !== false
  47965. ? createComputedGetter(key)
  47966. : createGetterInvoker(userDef.get)
  47967. : noop;
  47968. sharedPropertyDefinition.set = userDef.set || noop;
  47969. }
  47970. if (sharedPropertyDefinition.set === noop) {
  47971. sharedPropertyDefinition.set = function () {
  47972. warn(
  47973. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  47974. this
  47975. );
  47976. };
  47977. }
  47978. Object.defineProperty(target, key, sharedPropertyDefinition);
  47979. }
  47980. function createComputedGetter (key) {
  47981. return function computedGetter () {
  47982. var watcher = this._computedWatchers && this._computedWatchers[key];
  47983. if (watcher) {
  47984. if (watcher.dirty) {
  47985. watcher.evaluate();
  47986. }
  47987. if (Dep.target) {
  47988. watcher.depend();
  47989. }
  47990. return watcher.value
  47991. }
  47992. }
  47993. }
  47994. function createGetterInvoker(fn) {
  47995. return function computedGetter () {
  47996. return fn.call(this, this)
  47997. }
  47998. }
  47999. function initMethods (vm, methods) {
  48000. var props = vm.$options.props;
  48001. for (var key in methods) {
  48002. {
  48003. if (typeof methods[key] !== 'function') {
  48004. warn(
  48005. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  48006. "Did you reference the function correctly?",
  48007. vm
  48008. );
  48009. }
  48010. if (props && hasOwn(props, key)) {
  48011. warn(
  48012. ("Method \"" + key + "\" has already been defined as a prop."),
  48013. vm
  48014. );
  48015. }
  48016. if ((key in vm) && isReserved(key)) {
  48017. warn(
  48018. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  48019. "Avoid defining component methods that start with _ or $."
  48020. );
  48021. }
  48022. }
  48023. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  48024. }
  48025. }
  48026. function initWatch (vm, watch) {
  48027. for (var key in watch) {
  48028. var handler = watch[key];
  48029. if (Array.isArray(handler)) {
  48030. for (var i = 0; i < handler.length; i++) {
  48031. createWatcher(vm, key, handler[i]);
  48032. }
  48033. } else {
  48034. createWatcher(vm, key, handler);
  48035. }
  48036. }
  48037. }
  48038. function createWatcher (
  48039. vm,
  48040. expOrFn,
  48041. handler,
  48042. options
  48043. ) {
  48044. if (isPlainObject(handler)) {
  48045. options = handler;
  48046. handler = handler.handler;
  48047. }
  48048. if (typeof handler === 'string') {
  48049. handler = vm[handler];
  48050. }
  48051. return vm.$watch(expOrFn, handler, options)
  48052. }
  48053. function stateMixin (Vue) {
  48054. // flow somehow has problems with directly declared definition object
  48055. // when using Object.defineProperty, so we have to procedurally build up
  48056. // the object here.
  48057. var dataDef = {};
  48058. dataDef.get = function () { return this._data };
  48059. var propsDef = {};
  48060. propsDef.get = function () { return this._props };
  48061. {
  48062. dataDef.set = function () {
  48063. warn(
  48064. 'Avoid replacing instance root $data. ' +
  48065. 'Use nested data properties instead.',
  48066. this
  48067. );
  48068. };
  48069. propsDef.set = function () {
  48070. warn("$props is readonly.", this);
  48071. };
  48072. }
  48073. Object.defineProperty(Vue.prototype, '$data', dataDef);
  48074. Object.defineProperty(Vue.prototype, '$props', propsDef);
  48075. Vue.prototype.$set = set;
  48076. Vue.prototype.$delete = del;
  48077. Vue.prototype.$watch = function (
  48078. expOrFn,
  48079. cb,
  48080. options
  48081. ) {
  48082. var vm = this;
  48083. if (isPlainObject(cb)) {
  48084. return createWatcher(vm, expOrFn, cb, options)
  48085. }
  48086. options = options || {};
  48087. options.user = true;
  48088. var watcher = new Watcher(vm, expOrFn, cb, options);
  48089. if (options.immediate) {
  48090. try {
  48091. cb.call(vm, watcher.value);
  48092. } catch (error) {
  48093. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  48094. }
  48095. }
  48096. return function unwatchFn () {
  48097. watcher.teardown();
  48098. }
  48099. };
  48100. }
  48101. /* */
  48102. var uid$3 = 0;
  48103. function initMixin (Vue) {
  48104. Vue.prototype._init = function (options) {
  48105. var vm = this;
  48106. // a uid
  48107. vm._uid = uid$3++;
  48108. var startTag, endTag;
  48109. /* istanbul ignore if */
  48110. if (config.performance && mark) {
  48111. startTag = "vue-perf-start:" + (vm._uid);
  48112. endTag = "vue-perf-end:" + (vm._uid);
  48113. mark(startTag);
  48114. }
  48115. // a flag to avoid this being observed
  48116. vm._isVue = true;
  48117. // merge options
  48118. if (options && options._isComponent) {
  48119. // optimize internal component instantiation
  48120. // since dynamic options merging is pretty slow, and none of the
  48121. // internal component options needs special treatment.
  48122. initInternalComponent(vm, options);
  48123. } else {
  48124. vm.$options = mergeOptions(
  48125. resolveConstructorOptions(vm.constructor),
  48126. options || {},
  48127. vm
  48128. );
  48129. }
  48130. /* istanbul ignore else */
  48131. {
  48132. initProxy(vm);
  48133. }
  48134. // expose real self
  48135. vm._self = vm;
  48136. initLifecycle(vm);
  48137. initEvents(vm);
  48138. initRender(vm);
  48139. callHook(vm, 'beforeCreate');
  48140. initInjections(vm); // resolve injections before data/props
  48141. initState(vm);
  48142. initProvide(vm); // resolve provide after data/props
  48143. callHook(vm, 'created');
  48144. /* istanbul ignore if */
  48145. if (config.performance && mark) {
  48146. vm._name = formatComponentName(vm, false);
  48147. mark(endTag);
  48148. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  48149. }
  48150. if (vm.$options.el) {
  48151. vm.$mount(vm.$options.el);
  48152. }
  48153. };
  48154. }
  48155. function initInternalComponent (vm, options) {
  48156. var opts = vm.$options = Object.create(vm.constructor.options);
  48157. // doing this because it's faster than dynamic enumeration.
  48158. var parentVnode = options._parentVnode;
  48159. opts.parent = options.parent;
  48160. opts._parentVnode = parentVnode;
  48161. var vnodeComponentOptions = parentVnode.componentOptions;
  48162. opts.propsData = vnodeComponentOptions.propsData;
  48163. opts._parentListeners = vnodeComponentOptions.listeners;
  48164. opts._renderChildren = vnodeComponentOptions.children;
  48165. opts._componentTag = vnodeComponentOptions.tag;
  48166. if (options.render) {
  48167. opts.render = options.render;
  48168. opts.staticRenderFns = options.staticRenderFns;
  48169. }
  48170. }
  48171. function resolveConstructorOptions (Ctor) {
  48172. var options = Ctor.options;
  48173. if (Ctor.super) {
  48174. var superOptions = resolveConstructorOptions(Ctor.super);
  48175. var cachedSuperOptions = Ctor.superOptions;
  48176. if (superOptions !== cachedSuperOptions) {
  48177. // super option changed,
  48178. // need to resolve new options.
  48179. Ctor.superOptions = superOptions;
  48180. // check if there are any late-modified/attached options (#4976)
  48181. var modifiedOptions = resolveModifiedOptions(Ctor);
  48182. // update base extend options
  48183. if (modifiedOptions) {
  48184. extend(Ctor.extendOptions, modifiedOptions);
  48185. }
  48186. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  48187. if (options.name) {
  48188. options.components[options.name] = Ctor;
  48189. }
  48190. }
  48191. }
  48192. return options
  48193. }
  48194. function resolveModifiedOptions (Ctor) {
  48195. var modified;
  48196. var latest = Ctor.options;
  48197. var sealed = Ctor.sealedOptions;
  48198. for (var key in latest) {
  48199. if (latest[key] !== sealed[key]) {
  48200. if (!modified) { modified = {}; }
  48201. modified[key] = latest[key];
  48202. }
  48203. }
  48204. return modified
  48205. }
  48206. function Vue (options) {
  48207. if (!(this instanceof Vue)
  48208. ) {
  48209. warn('Vue is a constructor and should be called with the `new` keyword');
  48210. }
  48211. this._init(options);
  48212. }
  48213. initMixin(Vue);
  48214. stateMixin(Vue);
  48215. eventsMixin(Vue);
  48216. lifecycleMixin(Vue);
  48217. renderMixin(Vue);
  48218. /* */
  48219. function initUse (Vue) {
  48220. Vue.use = function (plugin) {
  48221. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  48222. if (installedPlugins.indexOf(plugin) > -1) {
  48223. return this
  48224. }
  48225. // additional parameters
  48226. var args = toArray(arguments, 1);
  48227. args.unshift(this);
  48228. if (typeof plugin.install === 'function') {
  48229. plugin.install.apply(plugin, args);
  48230. } else if (typeof plugin === 'function') {
  48231. plugin.apply(null, args);
  48232. }
  48233. installedPlugins.push(plugin);
  48234. return this
  48235. };
  48236. }
  48237. /* */
  48238. function initMixin$1 (Vue) {
  48239. Vue.mixin = function (mixin) {
  48240. this.options = mergeOptions(this.options, mixin);
  48241. return this
  48242. };
  48243. }
  48244. /* */
  48245. function initExtend (Vue) {
  48246. /**
  48247. * Each instance constructor, including Vue, has a unique
  48248. * cid. This enables us to create wrapped "child
  48249. * constructors" for prototypal inheritance and cache them.
  48250. */
  48251. Vue.cid = 0;
  48252. var cid = 1;
  48253. /**
  48254. * Class inheritance
  48255. */
  48256. Vue.extend = function (extendOptions) {
  48257. extendOptions = extendOptions || {};
  48258. var Super = this;
  48259. var SuperId = Super.cid;
  48260. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  48261. if (cachedCtors[SuperId]) {
  48262. return cachedCtors[SuperId]
  48263. }
  48264. var name = extendOptions.name || Super.options.name;
  48265. if (name) {
  48266. validateComponentName(name);
  48267. }
  48268. var Sub = function VueComponent (options) {
  48269. this._init(options);
  48270. };
  48271. Sub.prototype = Object.create(Super.prototype);
  48272. Sub.prototype.constructor = Sub;
  48273. Sub.cid = cid++;
  48274. Sub.options = mergeOptions(
  48275. Super.options,
  48276. extendOptions
  48277. );
  48278. Sub['super'] = Super;
  48279. // For props and computed properties, we define the proxy getters on
  48280. // the Vue instances at extension time, on the extended prototype. This
  48281. // avoids Object.defineProperty calls for each instance created.
  48282. if (Sub.options.props) {
  48283. initProps$1(Sub);
  48284. }
  48285. if (Sub.options.computed) {
  48286. initComputed$1(Sub);
  48287. }
  48288. // allow further extension/mixin/plugin usage
  48289. Sub.extend = Super.extend;
  48290. Sub.mixin = Super.mixin;
  48291. Sub.use = Super.use;
  48292. // create asset registers, so extended classes
  48293. // can have their private assets too.
  48294. ASSET_TYPES.forEach(function (type) {
  48295. Sub[type] = Super[type];
  48296. });
  48297. // enable recursive self-lookup
  48298. if (name) {
  48299. Sub.options.components[name] = Sub;
  48300. }
  48301. // keep a reference to the super options at extension time.
  48302. // later at instantiation we can check if Super's options have
  48303. // been updated.
  48304. Sub.superOptions = Super.options;
  48305. Sub.extendOptions = extendOptions;
  48306. Sub.sealedOptions = extend({}, Sub.options);
  48307. // cache constructor
  48308. cachedCtors[SuperId] = Sub;
  48309. return Sub
  48310. };
  48311. }
  48312. function initProps$1 (Comp) {
  48313. var props = Comp.options.props;
  48314. for (var key in props) {
  48315. proxy(Comp.prototype, "_props", key);
  48316. }
  48317. }
  48318. function initComputed$1 (Comp) {
  48319. var computed = Comp.options.computed;
  48320. for (var key in computed) {
  48321. defineComputed(Comp.prototype, key, computed[key]);
  48322. }
  48323. }
  48324. /* */
  48325. function initAssetRegisters (Vue) {
  48326. /**
  48327. * Create asset registration methods.
  48328. */
  48329. ASSET_TYPES.forEach(function (type) {
  48330. Vue[type] = function (
  48331. id,
  48332. definition
  48333. ) {
  48334. if (!definition) {
  48335. return this.options[type + 's'][id]
  48336. } else {
  48337. /* istanbul ignore if */
  48338. if (type === 'component') {
  48339. validateComponentName(id);
  48340. }
  48341. if (type === 'component' && isPlainObject(definition)) {
  48342. definition.name = definition.name || id;
  48343. definition = this.options._base.extend(definition);
  48344. }
  48345. if (type === 'directive' && typeof definition === 'function') {
  48346. definition = { bind: definition, update: definition };
  48347. }
  48348. this.options[type + 's'][id] = definition;
  48349. return definition
  48350. }
  48351. };
  48352. });
  48353. }
  48354. /* */
  48355. function getComponentName (opts) {
  48356. return opts && (opts.Ctor.options.name || opts.tag)
  48357. }
  48358. function matches (pattern, name) {
  48359. if (Array.isArray(pattern)) {
  48360. return pattern.indexOf(name) > -1
  48361. } else if (typeof pattern === 'string') {
  48362. return pattern.split(',').indexOf(name) > -1
  48363. } else if (isRegExp(pattern)) {
  48364. return pattern.test(name)
  48365. }
  48366. /* istanbul ignore next */
  48367. return false
  48368. }
  48369. function pruneCache (keepAliveInstance, filter) {
  48370. var cache = keepAliveInstance.cache;
  48371. var keys = keepAliveInstance.keys;
  48372. var _vnode = keepAliveInstance._vnode;
  48373. for (var key in cache) {
  48374. var cachedNode = cache[key];
  48375. if (cachedNode) {
  48376. var name = getComponentName(cachedNode.componentOptions);
  48377. if (name && !filter(name)) {
  48378. pruneCacheEntry(cache, key, keys, _vnode);
  48379. }
  48380. }
  48381. }
  48382. }
  48383. function pruneCacheEntry (
  48384. cache,
  48385. key,
  48386. keys,
  48387. current
  48388. ) {
  48389. var cached$$1 = cache[key];
  48390. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  48391. cached$$1.componentInstance.$destroy();
  48392. }
  48393. cache[key] = null;
  48394. remove(keys, key);
  48395. }
  48396. var patternTypes = [String, RegExp, Array];
  48397. var KeepAlive = {
  48398. name: 'keep-alive',
  48399. abstract: true,
  48400. props: {
  48401. include: patternTypes,
  48402. exclude: patternTypes,
  48403. max: [String, Number]
  48404. },
  48405. created: function created () {
  48406. this.cache = Object.create(null);
  48407. this.keys = [];
  48408. },
  48409. destroyed: function destroyed () {
  48410. for (var key in this.cache) {
  48411. pruneCacheEntry(this.cache, key, this.keys);
  48412. }
  48413. },
  48414. mounted: function mounted () {
  48415. var this$1 = this;
  48416. this.$watch('include', function (val) {
  48417. pruneCache(this$1, function (name) { return matches(val, name); });
  48418. });
  48419. this.$watch('exclude', function (val) {
  48420. pruneCache(this$1, function (name) { return !matches(val, name); });
  48421. });
  48422. },
  48423. render: function render () {
  48424. var slot = this.$slots.default;
  48425. var vnode = getFirstComponentChild(slot);
  48426. var componentOptions = vnode && vnode.componentOptions;
  48427. if (componentOptions) {
  48428. // check pattern
  48429. var name = getComponentName(componentOptions);
  48430. var ref = this;
  48431. var include = ref.include;
  48432. var exclude = ref.exclude;
  48433. if (
  48434. // not included
  48435. (include && (!name || !matches(include, name))) ||
  48436. // excluded
  48437. (exclude && name && matches(exclude, name))
  48438. ) {
  48439. return vnode
  48440. }
  48441. var ref$1 = this;
  48442. var cache = ref$1.cache;
  48443. var keys = ref$1.keys;
  48444. var key = vnode.key == null
  48445. // same constructor may get registered as different local components
  48446. // so cid alone is not enough (#3269)
  48447. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  48448. : vnode.key;
  48449. if (cache[key]) {
  48450. vnode.componentInstance = cache[key].componentInstance;
  48451. // make current key freshest
  48452. remove(keys, key);
  48453. keys.push(key);
  48454. } else {
  48455. cache[key] = vnode;
  48456. keys.push(key);
  48457. // prune oldest entry
  48458. if (this.max && keys.length > parseInt(this.max)) {
  48459. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  48460. }
  48461. }
  48462. vnode.data.keepAlive = true;
  48463. }
  48464. return vnode || (slot && slot[0])
  48465. }
  48466. };
  48467. var builtInComponents = {
  48468. KeepAlive: KeepAlive
  48469. };
  48470. /* */
  48471. function initGlobalAPI (Vue) {
  48472. // config
  48473. var configDef = {};
  48474. configDef.get = function () { return config; };
  48475. {
  48476. configDef.set = function () {
  48477. warn(
  48478. 'Do not replace the Vue.config object, set individual fields instead.'
  48479. );
  48480. };
  48481. }
  48482. Object.defineProperty(Vue, 'config', configDef);
  48483. // exposed util methods.
  48484. // NOTE: these are not considered part of the public API - avoid relying on
  48485. // them unless you are aware of the risk.
  48486. Vue.util = {
  48487. warn: warn,
  48488. extend: extend,
  48489. mergeOptions: mergeOptions,
  48490. defineReactive: defineReactive$$1
  48491. };
  48492. Vue.set = set;
  48493. Vue.delete = del;
  48494. Vue.nextTick = nextTick;
  48495. // 2.6 explicit observable API
  48496. Vue.observable = function (obj) {
  48497. observe(obj);
  48498. return obj
  48499. };
  48500. Vue.options = Object.create(null);
  48501. ASSET_TYPES.forEach(function (type) {
  48502. Vue.options[type + 's'] = Object.create(null);
  48503. });
  48504. // this is used to identify the "base" constructor to extend all plain-object
  48505. // components with in Weex's multi-instance scenarios.
  48506. Vue.options._base = Vue;
  48507. extend(Vue.options.components, builtInComponents);
  48508. initUse(Vue);
  48509. initMixin$1(Vue);
  48510. initExtend(Vue);
  48511. initAssetRegisters(Vue);
  48512. }
  48513. initGlobalAPI(Vue);
  48514. Object.defineProperty(Vue.prototype, '$isServer', {
  48515. get: isServerRendering
  48516. });
  48517. Object.defineProperty(Vue.prototype, '$ssrContext', {
  48518. get: function get () {
  48519. /* istanbul ignore next */
  48520. return this.$vnode && this.$vnode.ssrContext
  48521. }
  48522. });
  48523. // expose FunctionalRenderContext for ssr runtime helper installation
  48524. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  48525. value: FunctionalRenderContext
  48526. });
  48527. Vue.version = '2.6.11';
  48528. /* */
  48529. // these are reserved for web because they are directly compiled away
  48530. // during template compilation
  48531. var isReservedAttr = makeMap('style,class');
  48532. // attributes that should be using props for binding
  48533. var acceptValue = makeMap('input,textarea,option,select,progress');
  48534. var mustUseProp = function (tag, type, attr) {
  48535. return (
  48536. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  48537. (attr === 'selected' && tag === 'option') ||
  48538. (attr === 'checked' && tag === 'input') ||
  48539. (attr === 'muted' && tag === 'video')
  48540. )
  48541. };
  48542. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  48543. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  48544. var convertEnumeratedValue = function (key, value) {
  48545. return isFalsyAttrValue(value) || value === 'false'
  48546. ? 'false'
  48547. // allow arbitrary string value for contenteditable
  48548. : key === 'contenteditable' && isValidContentEditableValue(value)
  48549. ? value
  48550. : 'true'
  48551. };
  48552. var isBooleanAttr = makeMap(
  48553. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  48554. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  48555. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  48556. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  48557. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  48558. 'truespeed,typemustmatch,visible'
  48559. );
  48560. var xlinkNS = 'http://www.w3.org/1999/xlink';
  48561. var isXlink = function (name) {
  48562. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  48563. };
  48564. var getXlinkProp = function (name) {
  48565. return isXlink(name) ? name.slice(6, name.length) : ''
  48566. };
  48567. var isFalsyAttrValue = function (val) {
  48568. return val == null || val === false
  48569. };
  48570. /* */
  48571. function genClassForVnode (vnode) {
  48572. var data = vnode.data;
  48573. var parentNode = vnode;
  48574. var childNode = vnode;
  48575. while (isDef(childNode.componentInstance)) {
  48576. childNode = childNode.componentInstance._vnode;
  48577. if (childNode && childNode.data) {
  48578. data = mergeClassData(childNode.data, data);
  48579. }
  48580. }
  48581. while (isDef(parentNode = parentNode.parent)) {
  48582. if (parentNode && parentNode.data) {
  48583. data = mergeClassData(data, parentNode.data);
  48584. }
  48585. }
  48586. return renderClass(data.staticClass, data.class)
  48587. }
  48588. function mergeClassData (child, parent) {
  48589. return {
  48590. staticClass: concat(child.staticClass, parent.staticClass),
  48591. class: isDef(child.class)
  48592. ? [child.class, parent.class]
  48593. : parent.class
  48594. }
  48595. }
  48596. function renderClass (
  48597. staticClass,
  48598. dynamicClass
  48599. ) {
  48600. if (isDef(staticClass) || isDef(dynamicClass)) {
  48601. return concat(staticClass, stringifyClass(dynamicClass))
  48602. }
  48603. /* istanbul ignore next */
  48604. return ''
  48605. }
  48606. function concat (a, b) {
  48607. return a ? b ? (a + ' ' + b) : a : (b || '')
  48608. }
  48609. function stringifyClass (value) {
  48610. if (Array.isArray(value)) {
  48611. return stringifyArray(value)
  48612. }
  48613. if (isObject(value)) {
  48614. return stringifyObject(value)
  48615. }
  48616. if (typeof value === 'string') {
  48617. return value
  48618. }
  48619. /* istanbul ignore next */
  48620. return ''
  48621. }
  48622. function stringifyArray (value) {
  48623. var res = '';
  48624. var stringified;
  48625. for (var i = 0, l = value.length; i < l; i++) {
  48626. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  48627. if (res) { res += ' '; }
  48628. res += stringified;
  48629. }
  48630. }
  48631. return res
  48632. }
  48633. function stringifyObject (value) {
  48634. var res = '';
  48635. for (var key in value) {
  48636. if (value[key]) {
  48637. if (res) { res += ' '; }
  48638. res += key;
  48639. }
  48640. }
  48641. return res
  48642. }
  48643. /* */
  48644. var namespaceMap = {
  48645. svg: 'http://www.w3.org/2000/svg',
  48646. math: 'http://www.w3.org/1998/Math/MathML'
  48647. };
  48648. var isHTMLTag = makeMap(
  48649. 'html,body,base,head,link,meta,style,title,' +
  48650. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  48651. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  48652. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  48653. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  48654. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  48655. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  48656. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  48657. 'output,progress,select,textarea,' +
  48658. 'details,dialog,menu,menuitem,summary,' +
  48659. 'content,element,shadow,template,blockquote,iframe,tfoot'
  48660. );
  48661. // this map is intentionally selective, only covering SVG elements that may
  48662. // contain child elements.
  48663. var isSVG = makeMap(
  48664. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  48665. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  48666. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  48667. true
  48668. );
  48669. var isPreTag = function (tag) { return tag === 'pre'; };
  48670. var isReservedTag = function (tag) {
  48671. return isHTMLTag(tag) || isSVG(tag)
  48672. };
  48673. function getTagNamespace (tag) {
  48674. if (isSVG(tag)) {
  48675. return 'svg'
  48676. }
  48677. // basic support for MathML
  48678. // note it doesn't support other MathML elements being component roots
  48679. if (tag === 'math') {
  48680. return 'math'
  48681. }
  48682. }
  48683. var unknownElementCache = Object.create(null);
  48684. function isUnknownElement (tag) {
  48685. /* istanbul ignore if */
  48686. if (!inBrowser) {
  48687. return true
  48688. }
  48689. if (isReservedTag(tag)) {
  48690. return false
  48691. }
  48692. tag = tag.toLowerCase();
  48693. /* istanbul ignore if */
  48694. if (unknownElementCache[tag] != null) {
  48695. return unknownElementCache[tag]
  48696. }
  48697. var el = document.createElement(tag);
  48698. if (tag.indexOf('-') > -1) {
  48699. // http://stackoverflow.com/a/28210364/1070244
  48700. return (unknownElementCache[tag] = (
  48701. el.constructor === window.HTMLUnknownElement ||
  48702. el.constructor === window.HTMLElement
  48703. ))
  48704. } else {
  48705. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  48706. }
  48707. }
  48708. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  48709. /* */
  48710. /**
  48711. * Query an element selector if it's not an element already.
  48712. */
  48713. function query (el) {
  48714. if (typeof el === 'string') {
  48715. var selected = document.querySelector(el);
  48716. if (!selected) {
  48717. warn(
  48718. 'Cannot find element: ' + el
  48719. );
  48720. return document.createElement('div')
  48721. }
  48722. return selected
  48723. } else {
  48724. return el
  48725. }
  48726. }
  48727. /* */
  48728. function createElement$1 (tagName, vnode) {
  48729. var elm = document.createElement(tagName);
  48730. if (tagName !== 'select') {
  48731. return elm
  48732. }
  48733. // false or null will remove the attribute but undefined will not
  48734. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  48735. elm.setAttribute('multiple', 'multiple');
  48736. }
  48737. return elm
  48738. }
  48739. function createElementNS (namespace, tagName) {
  48740. return document.createElementNS(namespaceMap[namespace], tagName)
  48741. }
  48742. function createTextNode (text) {
  48743. return document.createTextNode(text)
  48744. }
  48745. function createComment (text) {
  48746. return document.createComment(text)
  48747. }
  48748. function insertBefore (parentNode, newNode, referenceNode) {
  48749. parentNode.insertBefore(newNode, referenceNode);
  48750. }
  48751. function removeChild (node, child) {
  48752. node.removeChild(child);
  48753. }
  48754. function appendChild (node, child) {
  48755. node.appendChild(child);
  48756. }
  48757. function parentNode (node) {
  48758. return node.parentNode
  48759. }
  48760. function nextSibling (node) {
  48761. return node.nextSibling
  48762. }
  48763. function tagName (node) {
  48764. return node.tagName
  48765. }
  48766. function setTextContent (node, text) {
  48767. node.textContent = text;
  48768. }
  48769. function setStyleScope (node, scopeId) {
  48770. node.setAttribute(scopeId, '');
  48771. }
  48772. var nodeOps = /*#__PURE__*/Object.freeze({
  48773. createElement: createElement$1,
  48774. createElementNS: createElementNS,
  48775. createTextNode: createTextNode,
  48776. createComment: createComment,
  48777. insertBefore: insertBefore,
  48778. removeChild: removeChild,
  48779. appendChild: appendChild,
  48780. parentNode: parentNode,
  48781. nextSibling: nextSibling,
  48782. tagName: tagName,
  48783. setTextContent: setTextContent,
  48784. setStyleScope: setStyleScope
  48785. });
  48786. /* */
  48787. var ref = {
  48788. create: function create (_, vnode) {
  48789. registerRef(vnode);
  48790. },
  48791. update: function update (oldVnode, vnode) {
  48792. if (oldVnode.data.ref !== vnode.data.ref) {
  48793. registerRef(oldVnode, true);
  48794. registerRef(vnode);
  48795. }
  48796. },
  48797. destroy: function destroy (vnode) {
  48798. registerRef(vnode, true);
  48799. }
  48800. };
  48801. function registerRef (vnode, isRemoval) {
  48802. var key = vnode.data.ref;
  48803. if (!isDef(key)) { return }
  48804. var vm = vnode.context;
  48805. var ref = vnode.componentInstance || vnode.elm;
  48806. var refs = vm.$refs;
  48807. if (isRemoval) {
  48808. if (Array.isArray(refs[key])) {
  48809. remove(refs[key], ref);
  48810. } else if (refs[key] === ref) {
  48811. refs[key] = undefined;
  48812. }
  48813. } else {
  48814. if (vnode.data.refInFor) {
  48815. if (!Array.isArray(refs[key])) {
  48816. refs[key] = [ref];
  48817. } else if (refs[key].indexOf(ref) < 0) {
  48818. // $flow-disable-line
  48819. refs[key].push(ref);
  48820. }
  48821. } else {
  48822. refs[key] = ref;
  48823. }
  48824. }
  48825. }
  48826. /**
  48827. * Virtual DOM patching algorithm based on Snabbdom by
  48828. * Simon Friis Vindum (@paldepind)
  48829. * Licensed under the MIT License
  48830. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  48831. *
  48832. * modified by Evan You (@yyx990803)
  48833. *
  48834. * Not type-checking this because this file is perf-critical and the cost
  48835. * of making flow understand it is not worth it.
  48836. */
  48837. var emptyNode = new VNode('', {}, []);
  48838. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  48839. function sameVnode (a, b) {
  48840. return (
  48841. a.key === b.key && (
  48842. (
  48843. a.tag === b.tag &&
  48844. a.isComment === b.isComment &&
  48845. isDef(a.data) === isDef(b.data) &&
  48846. sameInputType(a, b)
  48847. ) || (
  48848. isTrue(a.isAsyncPlaceholder) &&
  48849. a.asyncFactory === b.asyncFactory &&
  48850. isUndef(b.asyncFactory.error)
  48851. )
  48852. )
  48853. )
  48854. }
  48855. function sameInputType (a, b) {
  48856. if (a.tag !== 'input') { return true }
  48857. var i;
  48858. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  48859. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  48860. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  48861. }
  48862. function createKeyToOldIdx (children, beginIdx, endIdx) {
  48863. var i, key;
  48864. var map = {};
  48865. for (i = beginIdx; i <= endIdx; ++i) {
  48866. key = children[i].key;
  48867. if (isDef(key)) { map[key] = i; }
  48868. }
  48869. return map
  48870. }
  48871. function createPatchFunction (backend) {
  48872. var i, j;
  48873. var cbs = {};
  48874. var modules = backend.modules;
  48875. var nodeOps = backend.nodeOps;
  48876. for (i = 0; i < hooks.length; ++i) {
  48877. cbs[hooks[i]] = [];
  48878. for (j = 0; j < modules.length; ++j) {
  48879. if (isDef(modules[j][hooks[i]])) {
  48880. cbs[hooks[i]].push(modules[j][hooks[i]]);
  48881. }
  48882. }
  48883. }
  48884. function emptyNodeAt (elm) {
  48885. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  48886. }
  48887. function createRmCb (childElm, listeners) {
  48888. function remove$$1 () {
  48889. if (--remove$$1.listeners === 0) {
  48890. removeNode(childElm);
  48891. }
  48892. }
  48893. remove$$1.listeners = listeners;
  48894. return remove$$1
  48895. }
  48896. function removeNode (el) {
  48897. var parent = nodeOps.parentNode(el);
  48898. // element may have already been removed due to v-html / v-text
  48899. if (isDef(parent)) {
  48900. nodeOps.removeChild(parent, el);
  48901. }
  48902. }
  48903. function isUnknownElement$$1 (vnode, inVPre) {
  48904. return (
  48905. !inVPre &&
  48906. !vnode.ns &&
  48907. !(
  48908. config.ignoredElements.length &&
  48909. config.ignoredElements.some(function (ignore) {
  48910. return isRegExp(ignore)
  48911. ? ignore.test(vnode.tag)
  48912. : ignore === vnode.tag
  48913. })
  48914. ) &&
  48915. config.isUnknownElement(vnode.tag)
  48916. )
  48917. }
  48918. var creatingElmInVPre = 0;
  48919. function createElm (
  48920. vnode,
  48921. insertedVnodeQueue,
  48922. parentElm,
  48923. refElm,
  48924. nested,
  48925. ownerArray,
  48926. index
  48927. ) {
  48928. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48929. // This vnode was used in a previous render!
  48930. // now it's used as a new node, overwriting its elm would cause
  48931. // potential patch errors down the road when it's used as an insertion
  48932. // reference node. Instead, we clone the node on-demand before creating
  48933. // associated DOM element for it.
  48934. vnode = ownerArray[index] = cloneVNode(vnode);
  48935. }
  48936. vnode.isRootInsert = !nested; // for transition enter check
  48937. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  48938. return
  48939. }
  48940. var data = vnode.data;
  48941. var children = vnode.children;
  48942. var tag = vnode.tag;
  48943. if (isDef(tag)) {
  48944. {
  48945. if (data && data.pre) {
  48946. creatingElmInVPre++;
  48947. }
  48948. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  48949. warn(
  48950. 'Unknown custom element: <' + tag + '> - did you ' +
  48951. 'register the component correctly? For recursive components, ' +
  48952. 'make sure to provide the "name" option.',
  48953. vnode.context
  48954. );
  48955. }
  48956. }
  48957. vnode.elm = vnode.ns
  48958. ? nodeOps.createElementNS(vnode.ns, tag)
  48959. : nodeOps.createElement(tag, vnode);
  48960. setScope(vnode);
  48961. /* istanbul ignore if */
  48962. {
  48963. createChildren(vnode, children, insertedVnodeQueue);
  48964. if (isDef(data)) {
  48965. invokeCreateHooks(vnode, insertedVnodeQueue);
  48966. }
  48967. insert(parentElm, vnode.elm, refElm);
  48968. }
  48969. if (data && data.pre) {
  48970. creatingElmInVPre--;
  48971. }
  48972. } else if (isTrue(vnode.isComment)) {
  48973. vnode.elm = nodeOps.createComment(vnode.text);
  48974. insert(parentElm, vnode.elm, refElm);
  48975. } else {
  48976. vnode.elm = nodeOps.createTextNode(vnode.text);
  48977. insert(parentElm, vnode.elm, refElm);
  48978. }
  48979. }
  48980. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48981. var i = vnode.data;
  48982. if (isDef(i)) {
  48983. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  48984. if (isDef(i = i.hook) && isDef(i = i.init)) {
  48985. i(vnode, false /* hydrating */);
  48986. }
  48987. // after calling the init hook, if the vnode is a child component
  48988. // it should've created a child instance and mounted it. the child
  48989. // component also has set the placeholder vnode's elm.
  48990. // in that case we can just return the element and be done.
  48991. if (isDef(vnode.componentInstance)) {
  48992. initComponent(vnode, insertedVnodeQueue);
  48993. insert(parentElm, vnode.elm, refElm);
  48994. if (isTrue(isReactivated)) {
  48995. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  48996. }
  48997. return true
  48998. }
  48999. }
  49000. }
  49001. function initComponent (vnode, insertedVnodeQueue) {
  49002. if (isDef(vnode.data.pendingInsert)) {
  49003. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  49004. vnode.data.pendingInsert = null;
  49005. }
  49006. vnode.elm = vnode.componentInstance.$el;
  49007. if (isPatchable(vnode)) {
  49008. invokeCreateHooks(vnode, insertedVnodeQueue);
  49009. setScope(vnode);
  49010. } else {
  49011. // empty component root.
  49012. // skip all element-related modules except for ref (#3455)
  49013. registerRef(vnode);
  49014. // make sure to invoke the insert hook
  49015. insertedVnodeQueue.push(vnode);
  49016. }
  49017. }
  49018. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  49019. var i;
  49020. // hack for #4339: a reactivated component with inner transition
  49021. // does not trigger because the inner node's created hooks are not called
  49022. // again. It's not ideal to involve module-specific logic in here but
  49023. // there doesn't seem to be a better way to do it.
  49024. var innerNode = vnode;
  49025. while (innerNode.componentInstance) {
  49026. innerNode = innerNode.componentInstance._vnode;
  49027. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  49028. for (i = 0; i < cbs.activate.length; ++i) {
  49029. cbs.activate[i](emptyNode, innerNode);
  49030. }
  49031. insertedVnodeQueue.push(innerNode);
  49032. break
  49033. }
  49034. }
  49035. // unlike a newly created component,
  49036. // a reactivated keep-alive component doesn't insert itself
  49037. insert(parentElm, vnode.elm, refElm);
  49038. }
  49039. function insert (parent, elm, ref$$1) {
  49040. if (isDef(parent)) {
  49041. if (isDef(ref$$1)) {
  49042. if (nodeOps.parentNode(ref$$1) === parent) {
  49043. nodeOps.insertBefore(parent, elm, ref$$1);
  49044. }
  49045. } else {
  49046. nodeOps.appendChild(parent, elm);
  49047. }
  49048. }
  49049. }
  49050. function createChildren (vnode, children, insertedVnodeQueue) {
  49051. if (Array.isArray(children)) {
  49052. {
  49053. checkDuplicateKeys(children);
  49054. }
  49055. for (var i = 0; i < children.length; ++i) {
  49056. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  49057. }
  49058. } else if (isPrimitive(vnode.text)) {
  49059. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  49060. }
  49061. }
  49062. function isPatchable (vnode) {
  49063. while (vnode.componentInstance) {
  49064. vnode = vnode.componentInstance._vnode;
  49065. }
  49066. return isDef(vnode.tag)
  49067. }
  49068. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  49069. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  49070. cbs.create[i$1](emptyNode, vnode);
  49071. }
  49072. i = vnode.data.hook; // Reuse variable
  49073. if (isDef(i)) {
  49074. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  49075. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  49076. }
  49077. }
  49078. // set scope id attribute for scoped CSS.
  49079. // this is implemented as a special case to avoid the overhead
  49080. // of going through the normal attribute patching process.
  49081. function setScope (vnode) {
  49082. var i;
  49083. if (isDef(i = vnode.fnScopeId)) {
  49084. nodeOps.setStyleScope(vnode.elm, i);
  49085. } else {
  49086. var ancestor = vnode;
  49087. while (ancestor) {
  49088. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  49089. nodeOps.setStyleScope(vnode.elm, i);
  49090. }
  49091. ancestor = ancestor.parent;
  49092. }
  49093. }
  49094. // for slot content they should also get the scopeId from the host instance.
  49095. if (isDef(i = activeInstance) &&
  49096. i !== vnode.context &&
  49097. i !== vnode.fnContext &&
  49098. isDef(i = i.$options._scopeId)
  49099. ) {
  49100. nodeOps.setStyleScope(vnode.elm, i);
  49101. }
  49102. }
  49103. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  49104. for (; startIdx <= endIdx; ++startIdx) {
  49105. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  49106. }
  49107. }
  49108. function invokeDestroyHook (vnode) {
  49109. var i, j;
  49110. var data = vnode.data;
  49111. if (isDef(data)) {
  49112. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  49113. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  49114. }
  49115. if (isDef(i = vnode.children)) {
  49116. for (j = 0; j < vnode.children.length; ++j) {
  49117. invokeDestroyHook(vnode.children[j]);
  49118. }
  49119. }
  49120. }
  49121. function removeVnodes (vnodes, startIdx, endIdx) {
  49122. for (; startIdx <= endIdx; ++startIdx) {
  49123. var ch = vnodes[startIdx];
  49124. if (isDef(ch)) {
  49125. if (isDef(ch.tag)) {
  49126. removeAndInvokeRemoveHook(ch);
  49127. invokeDestroyHook(ch);
  49128. } else { // Text node
  49129. removeNode(ch.elm);
  49130. }
  49131. }
  49132. }
  49133. }
  49134. function removeAndInvokeRemoveHook (vnode, rm) {
  49135. if (isDef(rm) || isDef(vnode.data)) {
  49136. var i;
  49137. var listeners = cbs.remove.length + 1;
  49138. if (isDef(rm)) {
  49139. // we have a recursively passed down rm callback
  49140. // increase the listeners count
  49141. rm.listeners += listeners;
  49142. } else {
  49143. // directly removing
  49144. rm = createRmCb(vnode.elm, listeners);
  49145. }
  49146. // recursively invoke hooks on child component root node
  49147. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  49148. removeAndInvokeRemoveHook(i, rm);
  49149. }
  49150. for (i = 0; i < cbs.remove.length; ++i) {
  49151. cbs.remove[i](vnode, rm);
  49152. }
  49153. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  49154. i(vnode, rm);
  49155. } else {
  49156. rm();
  49157. }
  49158. } else {
  49159. removeNode(vnode.elm);
  49160. }
  49161. }
  49162. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  49163. var oldStartIdx = 0;
  49164. var newStartIdx = 0;
  49165. var oldEndIdx = oldCh.length - 1;
  49166. var oldStartVnode = oldCh[0];
  49167. var oldEndVnode = oldCh[oldEndIdx];
  49168. var newEndIdx = newCh.length - 1;
  49169. var newStartVnode = newCh[0];
  49170. var newEndVnode = newCh[newEndIdx];
  49171. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  49172. // removeOnly is a special flag used only by <transition-group>
  49173. // to ensure removed elements stay in correct relative positions
  49174. // during leaving transitions
  49175. var canMove = !removeOnly;
  49176. {
  49177. checkDuplicateKeys(newCh);
  49178. }
  49179. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  49180. if (isUndef(oldStartVnode)) {
  49181. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  49182. } else if (isUndef(oldEndVnode)) {
  49183. oldEndVnode = oldCh[--oldEndIdx];
  49184. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  49185. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49186. oldStartVnode = oldCh[++oldStartIdx];
  49187. newStartVnode = newCh[++newStartIdx];
  49188. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  49189. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  49190. oldEndVnode = oldCh[--oldEndIdx];
  49191. newEndVnode = newCh[--newEndIdx];
  49192. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  49193. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  49194. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  49195. oldStartVnode = oldCh[++oldStartIdx];
  49196. newEndVnode = newCh[--newEndIdx];
  49197. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  49198. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49199. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  49200. oldEndVnode = oldCh[--oldEndIdx];
  49201. newStartVnode = newCh[++newStartIdx];
  49202. } else {
  49203. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  49204. idxInOld = isDef(newStartVnode.key)
  49205. ? oldKeyToIdx[newStartVnode.key]
  49206. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  49207. if (isUndef(idxInOld)) { // New element
  49208. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  49209. } else {
  49210. vnodeToMove = oldCh[idxInOld];
  49211. if (sameVnode(vnodeToMove, newStartVnode)) {
  49212. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  49213. oldCh[idxInOld] = undefined;
  49214. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  49215. } else {
  49216. // same key but different element. treat as new element
  49217. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  49218. }
  49219. }
  49220. newStartVnode = newCh[++newStartIdx];
  49221. }
  49222. }
  49223. if (oldStartIdx > oldEndIdx) {
  49224. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  49225. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  49226. } else if (newStartIdx > newEndIdx) {
  49227. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  49228. }
  49229. }
  49230. function checkDuplicateKeys (children) {
  49231. var seenKeys = {};
  49232. for (var i = 0; i < children.length; i++) {
  49233. var vnode = children[i];
  49234. var key = vnode.key;
  49235. if (isDef(key)) {
  49236. if (seenKeys[key]) {
  49237. warn(
  49238. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  49239. vnode.context
  49240. );
  49241. } else {
  49242. seenKeys[key] = true;
  49243. }
  49244. }
  49245. }
  49246. }
  49247. function findIdxInOld (node, oldCh, start, end) {
  49248. for (var i = start; i < end; i++) {
  49249. var c = oldCh[i];
  49250. if (isDef(c) && sameVnode(node, c)) { return i }
  49251. }
  49252. }
  49253. function patchVnode (
  49254. oldVnode,
  49255. vnode,
  49256. insertedVnodeQueue,
  49257. ownerArray,
  49258. index,
  49259. removeOnly
  49260. ) {
  49261. if (oldVnode === vnode) {
  49262. return
  49263. }
  49264. if (isDef(vnode.elm) && isDef(ownerArray)) {
  49265. // clone reused vnode
  49266. vnode = ownerArray[index] = cloneVNode(vnode);
  49267. }
  49268. var elm = vnode.elm = oldVnode.elm;
  49269. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  49270. if (isDef(vnode.asyncFactory.resolved)) {
  49271. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  49272. } else {
  49273. vnode.isAsyncPlaceholder = true;
  49274. }
  49275. return
  49276. }
  49277. // reuse element for static trees.
  49278. // note we only do this if the vnode is cloned -
  49279. // if the new node is not cloned it means the render functions have been
  49280. // reset by the hot-reload-api and we need to do a proper re-render.
  49281. if (isTrue(vnode.isStatic) &&
  49282. isTrue(oldVnode.isStatic) &&
  49283. vnode.key === oldVnode.key &&
  49284. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  49285. ) {
  49286. vnode.componentInstance = oldVnode.componentInstance;
  49287. return
  49288. }
  49289. var i;
  49290. var data = vnode.data;
  49291. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  49292. i(oldVnode, vnode);
  49293. }
  49294. var oldCh = oldVnode.children;
  49295. var ch = vnode.children;
  49296. if (isDef(data) && isPatchable(vnode)) {
  49297. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  49298. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  49299. }
  49300. if (isUndef(vnode.text)) {
  49301. if (isDef(oldCh) && isDef(ch)) {
  49302. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  49303. } else if (isDef(ch)) {
  49304. {
  49305. checkDuplicateKeys(ch);
  49306. }
  49307. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  49308. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  49309. } else if (isDef(oldCh)) {
  49310. removeVnodes(oldCh, 0, oldCh.length - 1);
  49311. } else if (isDef(oldVnode.text)) {
  49312. nodeOps.setTextContent(elm, '');
  49313. }
  49314. } else if (oldVnode.text !== vnode.text) {
  49315. nodeOps.setTextContent(elm, vnode.text);
  49316. }
  49317. if (isDef(data)) {
  49318. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  49319. }
  49320. }
  49321. function invokeInsertHook (vnode, queue, initial) {
  49322. // delay insert hooks for component root nodes, invoke them after the
  49323. // element is really inserted
  49324. if (isTrue(initial) && isDef(vnode.parent)) {
  49325. vnode.parent.data.pendingInsert = queue;
  49326. } else {
  49327. for (var i = 0; i < queue.length; ++i) {
  49328. queue[i].data.hook.insert(queue[i]);
  49329. }
  49330. }
  49331. }
  49332. var hydrationBailed = false;
  49333. // list of modules that can skip create hook during hydration because they
  49334. // are already rendered on the client or has no need for initialization
  49335. // Note: style is excluded because it relies on initial clone for future
  49336. // deep updates (#7063).
  49337. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  49338. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  49339. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  49340. var i;
  49341. var tag = vnode.tag;
  49342. var data = vnode.data;
  49343. var children = vnode.children;
  49344. inVPre = inVPre || (data && data.pre);
  49345. vnode.elm = elm;
  49346. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  49347. vnode.isAsyncPlaceholder = true;
  49348. return true
  49349. }
  49350. // assert node match
  49351. {
  49352. if (!assertNodeMatch(elm, vnode, inVPre)) {
  49353. return false
  49354. }
  49355. }
  49356. if (isDef(data)) {
  49357. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  49358. if (isDef(i = vnode.componentInstance)) {
  49359. // child component. it should have hydrated its own tree.
  49360. initComponent(vnode, insertedVnodeQueue);
  49361. return true
  49362. }
  49363. }
  49364. if (isDef(tag)) {
  49365. if (isDef(children)) {
  49366. // empty element, allow client to pick up and populate children
  49367. if (!elm.hasChildNodes()) {
  49368. createChildren(vnode, children, insertedVnodeQueue);
  49369. } else {
  49370. // v-html and domProps: innerHTML
  49371. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  49372. if (i !== elm.innerHTML) {
  49373. /* istanbul ignore if */
  49374. if (typeof console !== 'undefined' &&
  49375. !hydrationBailed
  49376. ) {
  49377. hydrationBailed = true;
  49378. console.warn('Parent: ', elm);
  49379. console.warn('server innerHTML: ', i);
  49380. console.warn('client innerHTML: ', elm.innerHTML);
  49381. }
  49382. return false
  49383. }
  49384. } else {
  49385. // iterate and compare children lists
  49386. var childrenMatch = true;
  49387. var childNode = elm.firstChild;
  49388. for (var i$1 = 0; i$1 < children.length; i$1++) {
  49389. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  49390. childrenMatch = false;
  49391. break
  49392. }
  49393. childNode = childNode.nextSibling;
  49394. }
  49395. // if childNode is not null, it means the actual childNodes list is
  49396. // longer than the virtual children list.
  49397. if (!childrenMatch || childNode) {
  49398. /* istanbul ignore if */
  49399. if (typeof console !== 'undefined' &&
  49400. !hydrationBailed
  49401. ) {
  49402. hydrationBailed = true;
  49403. console.warn('Parent: ', elm);
  49404. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  49405. }
  49406. return false
  49407. }
  49408. }
  49409. }
  49410. }
  49411. if (isDef(data)) {
  49412. var fullInvoke = false;
  49413. for (var key in data) {
  49414. if (!isRenderedModule(key)) {
  49415. fullInvoke = true;
  49416. invokeCreateHooks(vnode, insertedVnodeQueue);
  49417. break
  49418. }
  49419. }
  49420. if (!fullInvoke && data['class']) {
  49421. // ensure collecting deps for deep class bindings for future updates
  49422. traverse(data['class']);
  49423. }
  49424. }
  49425. } else if (elm.data !== vnode.text) {
  49426. elm.data = vnode.text;
  49427. }
  49428. return true
  49429. }
  49430. function assertNodeMatch (node, vnode, inVPre) {
  49431. if (isDef(vnode.tag)) {
  49432. return vnode.tag.indexOf('vue-component') === 0 || (
  49433. !isUnknownElement$$1(vnode, inVPre) &&
  49434. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  49435. )
  49436. } else {
  49437. return node.nodeType === (vnode.isComment ? 8 : 3)
  49438. }
  49439. }
  49440. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  49441. if (isUndef(vnode)) {
  49442. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  49443. return
  49444. }
  49445. var isInitialPatch = false;
  49446. var insertedVnodeQueue = [];
  49447. if (isUndef(oldVnode)) {
  49448. // empty mount (likely as component), create new root element
  49449. isInitialPatch = true;
  49450. createElm(vnode, insertedVnodeQueue);
  49451. } else {
  49452. var isRealElement = isDef(oldVnode.nodeType);
  49453. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  49454. // patch existing root node
  49455. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  49456. } else {
  49457. if (isRealElement) {
  49458. // mounting to a real element
  49459. // check if this is server-rendered content and if we can perform
  49460. // a successful hydration.
  49461. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  49462. oldVnode.removeAttribute(SSR_ATTR);
  49463. hydrating = true;
  49464. }
  49465. if (isTrue(hydrating)) {
  49466. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  49467. invokeInsertHook(vnode, insertedVnodeQueue, true);
  49468. return oldVnode
  49469. } else {
  49470. warn(
  49471. 'The client-side rendered virtual DOM tree is not matching ' +
  49472. 'server-rendered content. This is likely caused by incorrect ' +
  49473. 'HTML markup, for example nesting block-level elements inside ' +
  49474. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  49475. 'full client-side render.'
  49476. );
  49477. }
  49478. }
  49479. // either not server-rendered, or hydration failed.
  49480. // create an empty node and replace it
  49481. oldVnode = emptyNodeAt(oldVnode);
  49482. }
  49483. // replacing existing element
  49484. var oldElm = oldVnode.elm;
  49485. var parentElm = nodeOps.parentNode(oldElm);
  49486. // create new node
  49487. createElm(
  49488. vnode,
  49489. insertedVnodeQueue,
  49490. // extremely rare edge case: do not insert if old element is in a
  49491. // leaving transition. Only happens when combining transition +
  49492. // keep-alive + HOCs. (#4590)
  49493. oldElm._leaveCb ? null : parentElm,
  49494. nodeOps.nextSibling(oldElm)
  49495. );
  49496. // update parent placeholder node element, recursively
  49497. if (isDef(vnode.parent)) {
  49498. var ancestor = vnode.parent;
  49499. var patchable = isPatchable(vnode);
  49500. while (ancestor) {
  49501. for (var i = 0; i < cbs.destroy.length; ++i) {
  49502. cbs.destroy[i](ancestor);
  49503. }
  49504. ancestor.elm = vnode.elm;
  49505. if (patchable) {
  49506. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  49507. cbs.create[i$1](emptyNode, ancestor);
  49508. }
  49509. // #6513
  49510. // invoke insert hooks that may have been merged by create hooks.
  49511. // e.g. for directives that uses the "inserted" hook.
  49512. var insert = ancestor.data.hook.insert;
  49513. if (insert.merged) {
  49514. // start at index 1 to avoid re-invoking component mounted hook
  49515. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  49516. insert.fns[i$2]();
  49517. }
  49518. }
  49519. } else {
  49520. registerRef(ancestor);
  49521. }
  49522. ancestor = ancestor.parent;
  49523. }
  49524. }
  49525. // destroy old node
  49526. if (isDef(parentElm)) {
  49527. removeVnodes([oldVnode], 0, 0);
  49528. } else if (isDef(oldVnode.tag)) {
  49529. invokeDestroyHook(oldVnode);
  49530. }
  49531. }
  49532. }
  49533. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  49534. return vnode.elm
  49535. }
  49536. }
  49537. /* */
  49538. var directives = {
  49539. create: updateDirectives,
  49540. update: updateDirectives,
  49541. destroy: function unbindDirectives (vnode) {
  49542. updateDirectives(vnode, emptyNode);
  49543. }
  49544. };
  49545. function updateDirectives (oldVnode, vnode) {
  49546. if (oldVnode.data.directives || vnode.data.directives) {
  49547. _update(oldVnode, vnode);
  49548. }
  49549. }
  49550. function _update (oldVnode, vnode) {
  49551. var isCreate = oldVnode === emptyNode;
  49552. var isDestroy = vnode === emptyNode;
  49553. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  49554. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  49555. var dirsWithInsert = [];
  49556. var dirsWithPostpatch = [];
  49557. var key, oldDir, dir;
  49558. for (key in newDirs) {
  49559. oldDir = oldDirs[key];
  49560. dir = newDirs[key];
  49561. if (!oldDir) {
  49562. // new directive, bind
  49563. callHook$1(dir, 'bind', vnode, oldVnode);
  49564. if (dir.def && dir.def.inserted) {
  49565. dirsWithInsert.push(dir);
  49566. }
  49567. } else {
  49568. // existing directive, update
  49569. dir.oldValue = oldDir.value;
  49570. dir.oldArg = oldDir.arg;
  49571. callHook$1(dir, 'update', vnode, oldVnode);
  49572. if (dir.def && dir.def.componentUpdated) {
  49573. dirsWithPostpatch.push(dir);
  49574. }
  49575. }
  49576. }
  49577. if (dirsWithInsert.length) {
  49578. var callInsert = function () {
  49579. for (var i = 0; i < dirsWithInsert.length; i++) {
  49580. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  49581. }
  49582. };
  49583. if (isCreate) {
  49584. mergeVNodeHook(vnode, 'insert', callInsert);
  49585. } else {
  49586. callInsert();
  49587. }
  49588. }
  49589. if (dirsWithPostpatch.length) {
  49590. mergeVNodeHook(vnode, 'postpatch', function () {
  49591. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  49592. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  49593. }
  49594. });
  49595. }
  49596. if (!isCreate) {
  49597. for (key in oldDirs) {
  49598. if (!newDirs[key]) {
  49599. // no longer present, unbind
  49600. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  49601. }
  49602. }
  49603. }
  49604. }
  49605. var emptyModifiers = Object.create(null);
  49606. function normalizeDirectives$1 (
  49607. dirs,
  49608. vm
  49609. ) {
  49610. var res = Object.create(null);
  49611. if (!dirs) {
  49612. // $flow-disable-line
  49613. return res
  49614. }
  49615. var i, dir;
  49616. for (i = 0; i < dirs.length; i++) {
  49617. dir = dirs[i];
  49618. if (!dir.modifiers) {
  49619. // $flow-disable-line
  49620. dir.modifiers = emptyModifiers;
  49621. }
  49622. res[getRawDirName(dir)] = dir;
  49623. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  49624. }
  49625. // $flow-disable-line
  49626. return res
  49627. }
  49628. function getRawDirName (dir) {
  49629. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  49630. }
  49631. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  49632. var fn = dir.def && dir.def[hook];
  49633. if (fn) {
  49634. try {
  49635. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  49636. } catch (e) {
  49637. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  49638. }
  49639. }
  49640. }
  49641. var baseModules = [
  49642. ref,
  49643. directives
  49644. ];
  49645. /* */
  49646. function updateAttrs (oldVnode, vnode) {
  49647. var opts = vnode.componentOptions;
  49648. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  49649. return
  49650. }
  49651. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  49652. return
  49653. }
  49654. var key, cur, old;
  49655. var elm = vnode.elm;
  49656. var oldAttrs = oldVnode.data.attrs || {};
  49657. var attrs = vnode.data.attrs || {};
  49658. // clone observed objects, as the user probably wants to mutate it
  49659. if (isDef(attrs.__ob__)) {
  49660. attrs = vnode.data.attrs = extend({}, attrs);
  49661. }
  49662. for (key in attrs) {
  49663. cur = attrs[key];
  49664. old = oldAttrs[key];
  49665. if (old !== cur) {
  49666. setAttr(elm, key, cur);
  49667. }
  49668. }
  49669. // #4391: in IE9, setting type can reset value for input[type=radio]
  49670. // #6666: IE/Edge forces progress value down to 1 before setting a max
  49671. /* istanbul ignore if */
  49672. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  49673. setAttr(elm, 'value', attrs.value);
  49674. }
  49675. for (key in oldAttrs) {
  49676. if (isUndef(attrs[key])) {
  49677. if (isXlink(key)) {
  49678. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49679. } else if (!isEnumeratedAttr(key)) {
  49680. elm.removeAttribute(key);
  49681. }
  49682. }
  49683. }
  49684. }
  49685. function setAttr (el, key, value) {
  49686. if (el.tagName.indexOf('-') > -1) {
  49687. baseSetAttr(el, key, value);
  49688. } else if (isBooleanAttr(key)) {
  49689. // set attribute for blank value
  49690. // e.g. <option disabled>Select one</option>
  49691. if (isFalsyAttrValue(value)) {
  49692. el.removeAttribute(key);
  49693. } else {
  49694. // technically allowfullscreen is a boolean attribute for <iframe>,
  49695. // but Flash expects a value of "true" when used on <embed> tag
  49696. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  49697. ? 'true'
  49698. : key;
  49699. el.setAttribute(key, value);
  49700. }
  49701. } else if (isEnumeratedAttr(key)) {
  49702. el.setAttribute(key, convertEnumeratedValue(key, value));
  49703. } else if (isXlink(key)) {
  49704. if (isFalsyAttrValue(value)) {
  49705. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49706. } else {
  49707. el.setAttributeNS(xlinkNS, key, value);
  49708. }
  49709. } else {
  49710. baseSetAttr(el, key, value);
  49711. }
  49712. }
  49713. function baseSetAttr (el, key, value) {
  49714. if (isFalsyAttrValue(value)) {
  49715. el.removeAttribute(key);
  49716. } else {
  49717. // #7138: IE10 & 11 fires input event when setting placeholder on
  49718. // <textarea>... block the first input event and remove the blocker
  49719. // immediately.
  49720. /* istanbul ignore if */
  49721. if (
  49722. isIE && !isIE9 &&
  49723. el.tagName === 'TEXTAREA' &&
  49724. key === 'placeholder' && value !== '' && !el.__ieph
  49725. ) {
  49726. var blocker = function (e) {
  49727. e.stopImmediatePropagation();
  49728. el.removeEventListener('input', blocker);
  49729. };
  49730. el.addEventListener('input', blocker);
  49731. // $flow-disable-line
  49732. el.__ieph = true; /* IE placeholder patched */
  49733. }
  49734. el.setAttribute(key, value);
  49735. }
  49736. }
  49737. var attrs = {
  49738. create: updateAttrs,
  49739. update: updateAttrs
  49740. };
  49741. /* */
  49742. function updateClass (oldVnode, vnode) {
  49743. var el = vnode.elm;
  49744. var data = vnode.data;
  49745. var oldData = oldVnode.data;
  49746. if (
  49747. isUndef(data.staticClass) &&
  49748. isUndef(data.class) && (
  49749. isUndef(oldData) || (
  49750. isUndef(oldData.staticClass) &&
  49751. isUndef(oldData.class)
  49752. )
  49753. )
  49754. ) {
  49755. return
  49756. }
  49757. var cls = genClassForVnode(vnode);
  49758. // handle transition classes
  49759. var transitionClass = el._transitionClasses;
  49760. if (isDef(transitionClass)) {
  49761. cls = concat(cls, stringifyClass(transitionClass));
  49762. }
  49763. // set the class
  49764. if (cls !== el._prevClass) {
  49765. el.setAttribute('class', cls);
  49766. el._prevClass = cls;
  49767. }
  49768. }
  49769. var klass = {
  49770. create: updateClass,
  49771. update: updateClass
  49772. };
  49773. /* */
  49774. var validDivisionCharRE = /[\w).+\-_$\]]/;
  49775. function parseFilters (exp) {
  49776. var inSingle = false;
  49777. var inDouble = false;
  49778. var inTemplateString = false;
  49779. var inRegex = false;
  49780. var curly = 0;
  49781. var square = 0;
  49782. var paren = 0;
  49783. var lastFilterIndex = 0;
  49784. var c, prev, i, expression, filters;
  49785. for (i = 0; i < exp.length; i++) {
  49786. prev = c;
  49787. c = exp.charCodeAt(i);
  49788. if (inSingle) {
  49789. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  49790. } else if (inDouble) {
  49791. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  49792. } else if (inTemplateString) {
  49793. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  49794. } else if (inRegex) {
  49795. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  49796. } else if (
  49797. c === 0x7C && // pipe
  49798. exp.charCodeAt(i + 1) !== 0x7C &&
  49799. exp.charCodeAt(i - 1) !== 0x7C &&
  49800. !curly && !square && !paren
  49801. ) {
  49802. if (expression === undefined) {
  49803. // first filter, end of expression
  49804. lastFilterIndex = i + 1;
  49805. expression = exp.slice(0, i).trim();
  49806. } else {
  49807. pushFilter();
  49808. }
  49809. } else {
  49810. switch (c) {
  49811. case 0x22: inDouble = true; break // "
  49812. case 0x27: inSingle = true; break // '
  49813. case 0x60: inTemplateString = true; break // `
  49814. case 0x28: paren++; break // (
  49815. case 0x29: paren--; break // )
  49816. case 0x5B: square++; break // [
  49817. case 0x5D: square--; break // ]
  49818. case 0x7B: curly++; break // {
  49819. case 0x7D: curly--; break // }
  49820. }
  49821. if (c === 0x2f) { // /
  49822. var j = i - 1;
  49823. var p = (void 0);
  49824. // find first non-whitespace prev char
  49825. for (; j >= 0; j--) {
  49826. p = exp.charAt(j);
  49827. if (p !== ' ') { break }
  49828. }
  49829. if (!p || !validDivisionCharRE.test(p)) {
  49830. inRegex = true;
  49831. }
  49832. }
  49833. }
  49834. }
  49835. if (expression === undefined) {
  49836. expression = exp.slice(0, i).trim();
  49837. } else if (lastFilterIndex !== 0) {
  49838. pushFilter();
  49839. }
  49840. function pushFilter () {
  49841. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  49842. lastFilterIndex = i + 1;
  49843. }
  49844. if (filters) {
  49845. for (i = 0; i < filters.length; i++) {
  49846. expression = wrapFilter(expression, filters[i]);
  49847. }
  49848. }
  49849. return expression
  49850. }
  49851. function wrapFilter (exp, filter) {
  49852. var i = filter.indexOf('(');
  49853. if (i < 0) {
  49854. // _f: resolveFilter
  49855. return ("_f(\"" + filter + "\")(" + exp + ")")
  49856. } else {
  49857. var name = filter.slice(0, i);
  49858. var args = filter.slice(i + 1);
  49859. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  49860. }
  49861. }
  49862. /* */
  49863. /* eslint-disable no-unused-vars */
  49864. function baseWarn (msg, range) {
  49865. console.error(("[Vue compiler]: " + msg));
  49866. }
  49867. /* eslint-enable no-unused-vars */
  49868. function pluckModuleFunction (
  49869. modules,
  49870. key
  49871. ) {
  49872. return modules
  49873. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  49874. : []
  49875. }
  49876. function addProp (el, name, value, range, dynamic) {
  49877. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49878. el.plain = false;
  49879. }
  49880. function addAttr (el, name, value, range, dynamic) {
  49881. var attrs = dynamic
  49882. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  49883. : (el.attrs || (el.attrs = []));
  49884. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49885. el.plain = false;
  49886. }
  49887. // add a raw attr (use this in preTransforms)
  49888. function addRawAttr (el, name, value, range) {
  49889. el.attrsMap[name] = value;
  49890. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  49891. }
  49892. function addDirective (
  49893. el,
  49894. name,
  49895. rawName,
  49896. value,
  49897. arg,
  49898. isDynamicArg,
  49899. modifiers,
  49900. range
  49901. ) {
  49902. (el.directives || (el.directives = [])).push(rangeSetItem({
  49903. name: name,
  49904. rawName: rawName,
  49905. value: value,
  49906. arg: arg,
  49907. isDynamicArg: isDynamicArg,
  49908. modifiers: modifiers
  49909. }, range));
  49910. el.plain = false;
  49911. }
  49912. function prependModifierMarker (symbol, name, dynamic) {
  49913. return dynamic
  49914. ? ("_p(" + name + ",\"" + symbol + "\")")
  49915. : symbol + name // mark the event as captured
  49916. }
  49917. function addHandler (
  49918. el,
  49919. name,
  49920. value,
  49921. modifiers,
  49922. important,
  49923. warn,
  49924. range,
  49925. dynamic
  49926. ) {
  49927. modifiers = modifiers || emptyObject;
  49928. // warn prevent and passive modifier
  49929. /* istanbul ignore if */
  49930. if (
  49931. warn &&
  49932. modifiers.prevent && modifiers.passive
  49933. ) {
  49934. warn(
  49935. 'passive and prevent can\'t be used together. ' +
  49936. 'Passive handler can\'t prevent default event.',
  49937. range
  49938. );
  49939. }
  49940. // normalize click.right and click.middle since they don't actually fire
  49941. // this is technically browser-specific, but at least for now browsers are
  49942. // the only target envs that have right/middle clicks.
  49943. if (modifiers.right) {
  49944. if (dynamic) {
  49945. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  49946. } else if (name === 'click') {
  49947. name = 'contextmenu';
  49948. delete modifiers.right;
  49949. }
  49950. } else if (modifiers.middle) {
  49951. if (dynamic) {
  49952. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  49953. } else if (name === 'click') {
  49954. name = 'mouseup';
  49955. }
  49956. }
  49957. // check capture modifier
  49958. if (modifiers.capture) {
  49959. delete modifiers.capture;
  49960. name = prependModifierMarker('!', name, dynamic);
  49961. }
  49962. if (modifiers.once) {
  49963. delete modifiers.once;
  49964. name = prependModifierMarker('~', name, dynamic);
  49965. }
  49966. /* istanbul ignore if */
  49967. if (modifiers.passive) {
  49968. delete modifiers.passive;
  49969. name = prependModifierMarker('&', name, dynamic);
  49970. }
  49971. var events;
  49972. if (modifiers.native) {
  49973. delete modifiers.native;
  49974. events = el.nativeEvents || (el.nativeEvents = {});
  49975. } else {
  49976. events = el.events || (el.events = {});
  49977. }
  49978. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  49979. if (modifiers !== emptyObject) {
  49980. newHandler.modifiers = modifiers;
  49981. }
  49982. var handlers = events[name];
  49983. /* istanbul ignore if */
  49984. if (Array.isArray(handlers)) {
  49985. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  49986. } else if (handlers) {
  49987. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  49988. } else {
  49989. events[name] = newHandler;
  49990. }
  49991. el.plain = false;
  49992. }
  49993. function getRawBindingAttr (
  49994. el,
  49995. name
  49996. ) {
  49997. return el.rawAttrsMap[':' + name] ||
  49998. el.rawAttrsMap['v-bind:' + name] ||
  49999. el.rawAttrsMap[name]
  50000. }
  50001. function getBindingAttr (
  50002. el,
  50003. name,
  50004. getStatic
  50005. ) {
  50006. var dynamicValue =
  50007. getAndRemoveAttr(el, ':' + name) ||
  50008. getAndRemoveAttr(el, 'v-bind:' + name);
  50009. if (dynamicValue != null) {
  50010. return parseFilters(dynamicValue)
  50011. } else if (getStatic !== false) {
  50012. var staticValue = getAndRemoveAttr(el, name);
  50013. if (staticValue != null) {
  50014. return JSON.stringify(staticValue)
  50015. }
  50016. }
  50017. }
  50018. // note: this only removes the attr from the Array (attrsList) so that it
  50019. // doesn't get processed by processAttrs.
  50020. // By default it does NOT remove it from the map (attrsMap) because the map is
  50021. // needed during codegen.
  50022. function getAndRemoveAttr (
  50023. el,
  50024. name,
  50025. removeFromMap
  50026. ) {
  50027. var val;
  50028. if ((val = el.attrsMap[name]) != null) {
  50029. var list = el.attrsList;
  50030. for (var i = 0, l = list.length; i < l; i++) {
  50031. if (list[i].name === name) {
  50032. list.splice(i, 1);
  50033. break
  50034. }
  50035. }
  50036. }
  50037. if (removeFromMap) {
  50038. delete el.attrsMap[name];
  50039. }
  50040. return val
  50041. }
  50042. function getAndRemoveAttrByRegex (
  50043. el,
  50044. name
  50045. ) {
  50046. var list = el.attrsList;
  50047. for (var i = 0, l = list.length; i < l; i++) {
  50048. var attr = list[i];
  50049. if (name.test(attr.name)) {
  50050. list.splice(i, 1);
  50051. return attr
  50052. }
  50053. }
  50054. }
  50055. function rangeSetItem (
  50056. item,
  50057. range
  50058. ) {
  50059. if (range) {
  50060. if (range.start != null) {
  50061. item.start = range.start;
  50062. }
  50063. if (range.end != null) {
  50064. item.end = range.end;
  50065. }
  50066. }
  50067. return item
  50068. }
  50069. /* */
  50070. /**
  50071. * Cross-platform code generation for component v-model
  50072. */
  50073. function genComponentModel (
  50074. el,
  50075. value,
  50076. modifiers
  50077. ) {
  50078. var ref = modifiers || {};
  50079. var number = ref.number;
  50080. var trim = ref.trim;
  50081. var baseValueExpression = '$$v';
  50082. var valueExpression = baseValueExpression;
  50083. if (trim) {
  50084. valueExpression =
  50085. "(typeof " + baseValueExpression + " === 'string'" +
  50086. "? " + baseValueExpression + ".trim()" +
  50087. ": " + baseValueExpression + ")";
  50088. }
  50089. if (number) {
  50090. valueExpression = "_n(" + valueExpression + ")";
  50091. }
  50092. var assignment = genAssignmentCode(value, valueExpression);
  50093. el.model = {
  50094. value: ("(" + value + ")"),
  50095. expression: JSON.stringify(value),
  50096. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  50097. };
  50098. }
  50099. /**
  50100. * Cross-platform codegen helper for generating v-model value assignment code.
  50101. */
  50102. function genAssignmentCode (
  50103. value,
  50104. assignment
  50105. ) {
  50106. var res = parseModel(value);
  50107. if (res.key === null) {
  50108. return (value + "=" + assignment)
  50109. } else {
  50110. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  50111. }
  50112. }
  50113. /**
  50114. * Parse a v-model expression into a base path and a final key segment.
  50115. * Handles both dot-path and possible square brackets.
  50116. *
  50117. * Possible cases:
  50118. *
  50119. * - test
  50120. * - test[key]
  50121. * - test[test1[key]]
  50122. * - test["a"][key]
  50123. * - xxx.test[a[a].test1[key]]
  50124. * - test.xxx.a["asa"][test1[key]]
  50125. *
  50126. */
  50127. var len, str, chr, index$1, expressionPos, expressionEndPos;
  50128. function parseModel (val) {
  50129. // Fix https://github.com/vuejs/vue/pull/7730
  50130. // allow v-model="obj.val " (trailing whitespace)
  50131. val = val.trim();
  50132. len = val.length;
  50133. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  50134. index$1 = val.lastIndexOf('.');
  50135. if (index$1 > -1) {
  50136. return {
  50137. exp: val.slice(0, index$1),
  50138. key: '"' + val.slice(index$1 + 1) + '"'
  50139. }
  50140. } else {
  50141. return {
  50142. exp: val,
  50143. key: null
  50144. }
  50145. }
  50146. }
  50147. str = val;
  50148. index$1 = expressionPos = expressionEndPos = 0;
  50149. while (!eof()) {
  50150. chr = next();
  50151. /* istanbul ignore if */
  50152. if (isStringStart(chr)) {
  50153. parseString(chr);
  50154. } else if (chr === 0x5B) {
  50155. parseBracket(chr);
  50156. }
  50157. }
  50158. return {
  50159. exp: val.slice(0, expressionPos),
  50160. key: val.slice(expressionPos + 1, expressionEndPos)
  50161. }
  50162. }
  50163. function next () {
  50164. return str.charCodeAt(++index$1)
  50165. }
  50166. function eof () {
  50167. return index$1 >= len
  50168. }
  50169. function isStringStart (chr) {
  50170. return chr === 0x22 || chr === 0x27
  50171. }
  50172. function parseBracket (chr) {
  50173. var inBracket = 1;
  50174. expressionPos = index$1;
  50175. while (!eof()) {
  50176. chr = next();
  50177. if (isStringStart(chr)) {
  50178. parseString(chr);
  50179. continue
  50180. }
  50181. if (chr === 0x5B) { inBracket++; }
  50182. if (chr === 0x5D) { inBracket--; }
  50183. if (inBracket === 0) {
  50184. expressionEndPos = index$1;
  50185. break
  50186. }
  50187. }
  50188. }
  50189. function parseString (chr) {
  50190. var stringQuote = chr;
  50191. while (!eof()) {
  50192. chr = next();
  50193. if (chr === stringQuote) {
  50194. break
  50195. }
  50196. }
  50197. }
  50198. /* */
  50199. var warn$1;
  50200. // in some cases, the event used has to be determined at runtime
  50201. // so we used some reserved tokens during compile.
  50202. var RANGE_TOKEN = '__r';
  50203. var CHECKBOX_RADIO_TOKEN = '__c';
  50204. function model (
  50205. el,
  50206. dir,
  50207. _warn
  50208. ) {
  50209. warn$1 = _warn;
  50210. var value = dir.value;
  50211. var modifiers = dir.modifiers;
  50212. var tag = el.tag;
  50213. var type = el.attrsMap.type;
  50214. {
  50215. // inputs with type="file" are read only and setting the input's
  50216. // value will throw an error.
  50217. if (tag === 'input' && type === 'file') {
  50218. warn$1(
  50219. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  50220. "File inputs are read only. Use a v-on:change listener instead.",
  50221. el.rawAttrsMap['v-model']
  50222. );
  50223. }
  50224. }
  50225. if (el.component) {
  50226. genComponentModel(el, value, modifiers);
  50227. // component v-model doesn't need extra runtime
  50228. return false
  50229. } else if (tag === 'select') {
  50230. genSelect(el, value, modifiers);
  50231. } else if (tag === 'input' && type === 'checkbox') {
  50232. genCheckboxModel(el, value, modifiers);
  50233. } else if (tag === 'input' && type === 'radio') {
  50234. genRadioModel(el, value, modifiers);
  50235. } else if (tag === 'input' || tag === 'textarea') {
  50236. genDefaultModel(el, value, modifiers);
  50237. } else if (!config.isReservedTag(tag)) {
  50238. genComponentModel(el, value, modifiers);
  50239. // component v-model doesn't need extra runtime
  50240. return false
  50241. } else {
  50242. warn$1(
  50243. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  50244. "v-model is not supported on this element type. " +
  50245. 'If you are working with contenteditable, it\'s recommended to ' +
  50246. 'wrap a library dedicated for that purpose inside a custom component.',
  50247. el.rawAttrsMap['v-model']
  50248. );
  50249. }
  50250. // ensure runtime directive metadata
  50251. return true
  50252. }
  50253. function genCheckboxModel (
  50254. el,
  50255. value,
  50256. modifiers
  50257. ) {
  50258. var number = modifiers && modifiers.number;
  50259. var valueBinding = getBindingAttr(el, 'value') || 'null';
  50260. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  50261. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  50262. addProp(el, 'checked',
  50263. "Array.isArray(" + value + ")" +
  50264. "?_i(" + value + "," + valueBinding + ")>-1" + (
  50265. trueValueBinding === 'true'
  50266. ? (":(" + value + ")")
  50267. : (":_q(" + value + "," + trueValueBinding + ")")
  50268. )
  50269. );
  50270. addHandler(el, 'change',
  50271. "var $$a=" + value + "," +
  50272. '$$el=$event.target,' +
  50273. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  50274. 'if(Array.isArray($$a)){' +
  50275. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  50276. '$$i=_i($$a,$$v);' +
  50277. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  50278. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  50279. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  50280. null, true
  50281. );
  50282. }
  50283. function genRadioModel (
  50284. el,
  50285. value,
  50286. modifiers
  50287. ) {
  50288. var number = modifiers && modifiers.number;
  50289. var valueBinding = getBindingAttr(el, 'value') || 'null';
  50290. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  50291. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  50292. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  50293. }
  50294. function genSelect (
  50295. el,
  50296. value,
  50297. modifiers
  50298. ) {
  50299. var number = modifiers && modifiers.number;
  50300. var selectedVal = "Array.prototype.filter" +
  50301. ".call($event.target.options,function(o){return o.selected})" +
  50302. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  50303. "return " + (number ? '_n(val)' : 'val') + "})";
  50304. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  50305. var code = "var $$selectedVal = " + selectedVal + ";";
  50306. code = code + " " + (genAssignmentCode(value, assignment));
  50307. addHandler(el, 'change', code, null, true);
  50308. }
  50309. function genDefaultModel (
  50310. el,
  50311. value,
  50312. modifiers
  50313. ) {
  50314. var type = el.attrsMap.type;
  50315. // warn if v-bind:value conflicts with v-model
  50316. // except for inputs with v-bind:type
  50317. {
  50318. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  50319. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  50320. if (value$1 && !typeBinding) {
  50321. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  50322. warn$1(
  50323. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  50324. 'because the latter already expands to a value binding internally',
  50325. el.rawAttrsMap[binding]
  50326. );
  50327. }
  50328. }
  50329. var ref = modifiers || {};
  50330. var lazy = ref.lazy;
  50331. var number = ref.number;
  50332. var trim = ref.trim;
  50333. var needCompositionGuard = !lazy && type !== 'range';
  50334. var event = lazy
  50335. ? 'change'
  50336. : type === 'range'
  50337. ? RANGE_TOKEN
  50338. : 'input';
  50339. var valueExpression = '$event.target.value';
  50340. if (trim) {
  50341. valueExpression = "$event.target.value.trim()";
  50342. }
  50343. if (number) {
  50344. valueExpression = "_n(" + valueExpression + ")";
  50345. }
  50346. var code = genAssignmentCode(value, valueExpression);
  50347. if (needCompositionGuard) {
  50348. code = "if($event.target.composing)return;" + code;
  50349. }
  50350. addProp(el, 'value', ("(" + value + ")"));
  50351. addHandler(el, event, code, null, true);
  50352. if (trim || number) {
  50353. addHandler(el, 'blur', '$forceUpdate()');
  50354. }
  50355. }
  50356. /* */
  50357. // normalize v-model event tokens that can only be determined at runtime.
  50358. // it's important to place the event as the first in the array because
  50359. // the whole point is ensuring the v-model callback gets called before
  50360. // user-attached handlers.
  50361. function normalizeEvents (on) {
  50362. /* istanbul ignore if */
  50363. if (isDef(on[RANGE_TOKEN])) {
  50364. // IE input[type=range] only supports `change` event
  50365. var event = isIE ? 'change' : 'input';
  50366. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  50367. delete on[RANGE_TOKEN];
  50368. }
  50369. // This was originally intended to fix #4521 but no longer necessary
  50370. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  50371. /* istanbul ignore if */
  50372. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  50373. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  50374. delete on[CHECKBOX_RADIO_TOKEN];
  50375. }
  50376. }
  50377. var target$1;
  50378. function createOnceHandler$1 (event, handler, capture) {
  50379. var _target = target$1; // save current target element in closure
  50380. return function onceHandler () {
  50381. var res = handler.apply(null, arguments);
  50382. if (res !== null) {
  50383. remove$2(event, onceHandler, capture, _target);
  50384. }
  50385. }
  50386. }
  50387. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  50388. // implementation and does not fire microtasks in between event propagation, so
  50389. // safe to exclude.
  50390. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  50391. function add$1 (
  50392. name,
  50393. handler,
  50394. capture,
  50395. passive
  50396. ) {
  50397. // async edge case #6566: inner click event triggers patch, event handler
  50398. // attached to outer element during patch, and triggered again. This
  50399. // happens because browsers fire microtask ticks between event propagation.
  50400. // the solution is simple: we save the timestamp when a handler is attached,
  50401. // and the handler would only fire if the event passed to it was fired
  50402. // AFTER it was attached.
  50403. if (useMicrotaskFix) {
  50404. var attachedTimestamp = currentFlushTimestamp;
  50405. var original = handler;
  50406. handler = original._wrapper = function (e) {
  50407. if (
  50408. // no bubbling, should always fire.
  50409. // this is just a safety net in case event.timeStamp is unreliable in
  50410. // certain weird environments...
  50411. e.target === e.currentTarget ||
  50412. // event is fired after handler attachment
  50413. e.timeStamp >= attachedTimestamp ||
  50414. // bail for environments that have buggy event.timeStamp implementations
  50415. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  50416. // #9681 QtWebEngine event.timeStamp is negative value
  50417. e.timeStamp <= 0 ||
  50418. // #9448 bail if event is fired in another document in a multi-page
  50419. // electron/nw.js app, since event.timeStamp will be using a different
  50420. // starting reference
  50421. e.target.ownerDocument !== document
  50422. ) {
  50423. return original.apply(this, arguments)
  50424. }
  50425. };
  50426. }
  50427. target$1.addEventListener(
  50428. name,
  50429. handler,
  50430. supportsPassive
  50431. ? { capture: capture, passive: passive }
  50432. : capture
  50433. );
  50434. }
  50435. function remove$2 (
  50436. name,
  50437. handler,
  50438. capture,
  50439. _target
  50440. ) {
  50441. (_target || target$1).removeEventListener(
  50442. name,
  50443. handler._wrapper || handler,
  50444. capture
  50445. );
  50446. }
  50447. function updateDOMListeners (oldVnode, vnode) {
  50448. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  50449. return
  50450. }
  50451. var on = vnode.data.on || {};
  50452. var oldOn = oldVnode.data.on || {};
  50453. target$1 = vnode.elm;
  50454. normalizeEvents(on);
  50455. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  50456. target$1 = undefined;
  50457. }
  50458. var events = {
  50459. create: updateDOMListeners,
  50460. update: updateDOMListeners
  50461. };
  50462. /* */
  50463. var svgContainer;
  50464. function updateDOMProps (oldVnode, vnode) {
  50465. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  50466. return
  50467. }
  50468. var key, cur;
  50469. var elm = vnode.elm;
  50470. var oldProps = oldVnode.data.domProps || {};
  50471. var props = vnode.data.domProps || {};
  50472. // clone observed objects, as the user probably wants to mutate it
  50473. if (isDef(props.__ob__)) {
  50474. props = vnode.data.domProps = extend({}, props);
  50475. }
  50476. for (key in oldProps) {
  50477. if (!(key in props)) {
  50478. elm[key] = '';
  50479. }
  50480. }
  50481. for (key in props) {
  50482. cur = props[key];
  50483. // ignore children if the node has textContent or innerHTML,
  50484. // as these will throw away existing DOM nodes and cause removal errors
  50485. // on subsequent patches (#3360)
  50486. if (key === 'textContent' || key === 'innerHTML') {
  50487. if (vnode.children) { vnode.children.length = 0; }
  50488. if (cur === oldProps[key]) { continue }
  50489. // #6601 work around Chrome version <= 55 bug where single textNode
  50490. // replaced by innerHTML/textContent retains its parentNode property
  50491. if (elm.childNodes.length === 1) {
  50492. elm.removeChild(elm.childNodes[0]);
  50493. }
  50494. }
  50495. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  50496. // store value as _value as well since
  50497. // non-string values will be stringified
  50498. elm._value = cur;
  50499. // avoid resetting cursor position when value is the same
  50500. var strCur = isUndef(cur) ? '' : String(cur);
  50501. if (shouldUpdateValue(elm, strCur)) {
  50502. elm.value = strCur;
  50503. }
  50504. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  50505. // IE doesn't support innerHTML for SVG elements
  50506. svgContainer = svgContainer || document.createElement('div');
  50507. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  50508. var svg = svgContainer.firstChild;
  50509. while (elm.firstChild) {
  50510. elm.removeChild(elm.firstChild);
  50511. }
  50512. while (svg.firstChild) {
  50513. elm.appendChild(svg.firstChild);
  50514. }
  50515. } else if (
  50516. // skip the update if old and new VDOM state is the same.
  50517. // `value` is handled separately because the DOM value may be temporarily
  50518. // out of sync with VDOM state due to focus, composition and modifiers.
  50519. // This #4521 by skipping the unnecesarry `checked` update.
  50520. cur !== oldProps[key]
  50521. ) {
  50522. // some property updates can throw
  50523. // e.g. `value` on <progress> w/ non-finite value
  50524. try {
  50525. elm[key] = cur;
  50526. } catch (e) {}
  50527. }
  50528. }
  50529. }
  50530. // check platforms/web/util/attrs.js acceptValue
  50531. function shouldUpdateValue (elm, checkVal) {
  50532. return (!elm.composing && (
  50533. elm.tagName === 'OPTION' ||
  50534. isNotInFocusAndDirty(elm, checkVal) ||
  50535. isDirtyWithModifiers(elm, checkVal)
  50536. ))
  50537. }
  50538. function isNotInFocusAndDirty (elm, checkVal) {
  50539. // return true when textbox (.number and .trim) loses focus and its value is
  50540. // not equal to the updated value
  50541. var notInFocus = true;
  50542. // #6157
  50543. // work around IE bug when accessing document.activeElement in an iframe
  50544. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  50545. return notInFocus && elm.value !== checkVal
  50546. }
  50547. function isDirtyWithModifiers (elm, newVal) {
  50548. var value = elm.value;
  50549. var modifiers = elm._vModifiers; // injected by v-model runtime
  50550. if (isDef(modifiers)) {
  50551. if (modifiers.number) {
  50552. return toNumber(value) !== toNumber(newVal)
  50553. }
  50554. if (modifiers.trim) {
  50555. return value.trim() !== newVal.trim()
  50556. }
  50557. }
  50558. return value !== newVal
  50559. }
  50560. var domProps = {
  50561. create: updateDOMProps,
  50562. update: updateDOMProps
  50563. };
  50564. /* */
  50565. var parseStyleText = cached(function (cssText) {
  50566. var res = {};
  50567. var listDelimiter = /;(?![^(]*\))/g;
  50568. var propertyDelimiter = /:(.+)/;
  50569. cssText.split(listDelimiter).forEach(function (item) {
  50570. if (item) {
  50571. var tmp = item.split(propertyDelimiter);
  50572. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  50573. }
  50574. });
  50575. return res
  50576. });
  50577. // merge static and dynamic style data on the same vnode
  50578. function normalizeStyleData (data) {
  50579. var style = normalizeStyleBinding(data.style);
  50580. // static style is pre-processed into an object during compilation
  50581. // and is always a fresh object, so it's safe to merge into it
  50582. return data.staticStyle
  50583. ? extend(data.staticStyle, style)
  50584. : style
  50585. }
  50586. // normalize possible array / string values into Object
  50587. function normalizeStyleBinding (bindingStyle) {
  50588. if (Array.isArray(bindingStyle)) {
  50589. return toObject(bindingStyle)
  50590. }
  50591. if (typeof bindingStyle === 'string') {
  50592. return parseStyleText(bindingStyle)
  50593. }
  50594. return bindingStyle
  50595. }
  50596. /**
  50597. * parent component style should be after child's
  50598. * so that parent component's style could override it
  50599. */
  50600. function getStyle (vnode, checkChild) {
  50601. var res = {};
  50602. var styleData;
  50603. if (checkChild) {
  50604. var childNode = vnode;
  50605. while (childNode.componentInstance) {
  50606. childNode = childNode.componentInstance._vnode;
  50607. if (
  50608. childNode && childNode.data &&
  50609. (styleData = normalizeStyleData(childNode.data))
  50610. ) {
  50611. extend(res, styleData);
  50612. }
  50613. }
  50614. }
  50615. if ((styleData = normalizeStyleData(vnode.data))) {
  50616. extend(res, styleData);
  50617. }
  50618. var parentNode = vnode;
  50619. while ((parentNode = parentNode.parent)) {
  50620. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  50621. extend(res, styleData);
  50622. }
  50623. }
  50624. return res
  50625. }
  50626. /* */
  50627. var cssVarRE = /^--/;
  50628. var importantRE = /\s*!important$/;
  50629. var setProp = function (el, name, val) {
  50630. /* istanbul ignore if */
  50631. if (cssVarRE.test(name)) {
  50632. el.style.setProperty(name, val);
  50633. } else if (importantRE.test(val)) {
  50634. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  50635. } else {
  50636. var normalizedName = normalize(name);
  50637. if (Array.isArray(val)) {
  50638. // Support values array created by autoprefixer, e.g.
  50639. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  50640. // Set them one by one, and the browser will only set those it can recognize
  50641. for (var i = 0, len = val.length; i < len; i++) {
  50642. el.style[normalizedName] = val[i];
  50643. }
  50644. } else {
  50645. el.style[normalizedName] = val;
  50646. }
  50647. }
  50648. };
  50649. var vendorNames = ['Webkit', 'Moz', 'ms'];
  50650. var emptyStyle;
  50651. var normalize = cached(function (prop) {
  50652. emptyStyle = emptyStyle || document.createElement('div').style;
  50653. prop = camelize(prop);
  50654. if (prop !== 'filter' && (prop in emptyStyle)) {
  50655. return prop
  50656. }
  50657. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  50658. for (var i = 0; i < vendorNames.length; i++) {
  50659. var name = vendorNames[i] + capName;
  50660. if (name in emptyStyle) {
  50661. return name
  50662. }
  50663. }
  50664. });
  50665. function updateStyle (oldVnode, vnode) {
  50666. var data = vnode.data;
  50667. var oldData = oldVnode.data;
  50668. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  50669. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  50670. ) {
  50671. return
  50672. }
  50673. var cur, name;
  50674. var el = vnode.elm;
  50675. var oldStaticStyle = oldData.staticStyle;
  50676. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  50677. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  50678. var oldStyle = oldStaticStyle || oldStyleBinding;
  50679. var style = normalizeStyleBinding(vnode.data.style) || {};
  50680. // store normalized style under a different key for next diff
  50681. // make sure to clone it if it's reactive, since the user likely wants
  50682. // to mutate it.
  50683. vnode.data.normalizedStyle = isDef(style.__ob__)
  50684. ? extend({}, style)
  50685. : style;
  50686. var newStyle = getStyle(vnode, true);
  50687. for (name in oldStyle) {
  50688. if (isUndef(newStyle[name])) {
  50689. setProp(el, name, '');
  50690. }
  50691. }
  50692. for (name in newStyle) {
  50693. cur = newStyle[name];
  50694. if (cur !== oldStyle[name]) {
  50695. // ie9 setting to null has no effect, must use empty string
  50696. setProp(el, name, cur == null ? '' : cur);
  50697. }
  50698. }
  50699. }
  50700. var style = {
  50701. create: updateStyle,
  50702. update: updateStyle
  50703. };
  50704. /* */
  50705. var whitespaceRE = /\s+/;
  50706. /**
  50707. * Add class with compatibility for SVG since classList is not supported on
  50708. * SVG elements in IE
  50709. */
  50710. function addClass (el, cls) {
  50711. /* istanbul ignore if */
  50712. if (!cls || !(cls = cls.trim())) {
  50713. return
  50714. }
  50715. /* istanbul ignore else */
  50716. if (el.classList) {
  50717. if (cls.indexOf(' ') > -1) {
  50718. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  50719. } else {
  50720. el.classList.add(cls);
  50721. }
  50722. } else {
  50723. var cur = " " + (el.getAttribute('class') || '') + " ";
  50724. if (cur.indexOf(' ' + cls + ' ') < 0) {
  50725. el.setAttribute('class', (cur + cls).trim());
  50726. }
  50727. }
  50728. }
  50729. /**
  50730. * Remove class with compatibility for SVG since classList is not supported on
  50731. * SVG elements in IE
  50732. */
  50733. function removeClass (el, cls) {
  50734. /* istanbul ignore if */
  50735. if (!cls || !(cls = cls.trim())) {
  50736. return
  50737. }
  50738. /* istanbul ignore else */
  50739. if (el.classList) {
  50740. if (cls.indexOf(' ') > -1) {
  50741. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  50742. } else {
  50743. el.classList.remove(cls);
  50744. }
  50745. if (!el.classList.length) {
  50746. el.removeAttribute('class');
  50747. }
  50748. } else {
  50749. var cur = " " + (el.getAttribute('class') || '') + " ";
  50750. var tar = ' ' + cls + ' ';
  50751. while (cur.indexOf(tar) >= 0) {
  50752. cur = cur.replace(tar, ' ');
  50753. }
  50754. cur = cur.trim();
  50755. if (cur) {
  50756. el.setAttribute('class', cur);
  50757. } else {
  50758. el.removeAttribute('class');
  50759. }
  50760. }
  50761. }
  50762. /* */
  50763. function resolveTransition (def$$1) {
  50764. if (!def$$1) {
  50765. return
  50766. }
  50767. /* istanbul ignore else */
  50768. if (typeof def$$1 === 'object') {
  50769. var res = {};
  50770. if (def$$1.css !== false) {
  50771. extend(res, autoCssTransition(def$$1.name || 'v'));
  50772. }
  50773. extend(res, def$$1);
  50774. return res
  50775. } else if (typeof def$$1 === 'string') {
  50776. return autoCssTransition(def$$1)
  50777. }
  50778. }
  50779. var autoCssTransition = cached(function (name) {
  50780. return {
  50781. enterClass: (name + "-enter"),
  50782. enterToClass: (name + "-enter-to"),
  50783. enterActiveClass: (name + "-enter-active"),
  50784. leaveClass: (name + "-leave"),
  50785. leaveToClass: (name + "-leave-to"),
  50786. leaveActiveClass: (name + "-leave-active")
  50787. }
  50788. });
  50789. var hasTransition = inBrowser && !isIE9;
  50790. var TRANSITION = 'transition';
  50791. var ANIMATION = 'animation';
  50792. // Transition property/event sniffing
  50793. var transitionProp = 'transition';
  50794. var transitionEndEvent = 'transitionend';
  50795. var animationProp = 'animation';
  50796. var animationEndEvent = 'animationend';
  50797. if (hasTransition) {
  50798. /* istanbul ignore if */
  50799. if (window.ontransitionend === undefined &&
  50800. window.onwebkittransitionend !== undefined
  50801. ) {
  50802. transitionProp = 'WebkitTransition';
  50803. transitionEndEvent = 'webkitTransitionEnd';
  50804. }
  50805. if (window.onanimationend === undefined &&
  50806. window.onwebkitanimationend !== undefined
  50807. ) {
  50808. animationProp = 'WebkitAnimation';
  50809. animationEndEvent = 'webkitAnimationEnd';
  50810. }
  50811. }
  50812. // binding to window is necessary to make hot reload work in IE in strict mode
  50813. var raf = inBrowser
  50814. ? window.requestAnimationFrame
  50815. ? window.requestAnimationFrame.bind(window)
  50816. : setTimeout
  50817. : /* istanbul ignore next */ function (fn) { return fn(); };
  50818. function nextFrame (fn) {
  50819. raf(function () {
  50820. raf(fn);
  50821. });
  50822. }
  50823. function addTransitionClass (el, cls) {
  50824. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  50825. if (transitionClasses.indexOf(cls) < 0) {
  50826. transitionClasses.push(cls);
  50827. addClass(el, cls);
  50828. }
  50829. }
  50830. function removeTransitionClass (el, cls) {
  50831. if (el._transitionClasses) {
  50832. remove(el._transitionClasses, cls);
  50833. }
  50834. removeClass(el, cls);
  50835. }
  50836. function whenTransitionEnds (
  50837. el,
  50838. expectedType,
  50839. cb
  50840. ) {
  50841. var ref = getTransitionInfo(el, expectedType);
  50842. var type = ref.type;
  50843. var timeout = ref.timeout;
  50844. var propCount = ref.propCount;
  50845. if (!type) { return cb() }
  50846. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  50847. var ended = 0;
  50848. var end = function () {
  50849. el.removeEventListener(event, onEnd);
  50850. cb();
  50851. };
  50852. var onEnd = function (e) {
  50853. if (e.target === el) {
  50854. if (++ended >= propCount) {
  50855. end();
  50856. }
  50857. }
  50858. };
  50859. setTimeout(function () {
  50860. if (ended < propCount) {
  50861. end();
  50862. }
  50863. }, timeout + 1);
  50864. el.addEventListener(event, onEnd);
  50865. }
  50866. var transformRE = /\b(transform|all)(,|$)/;
  50867. function getTransitionInfo (el, expectedType) {
  50868. var styles = window.getComputedStyle(el);
  50869. // JSDOM may return undefined for transition properties
  50870. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  50871. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  50872. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  50873. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  50874. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  50875. var animationTimeout = getTimeout(animationDelays, animationDurations);
  50876. var type;
  50877. var timeout = 0;
  50878. var propCount = 0;
  50879. /* istanbul ignore if */
  50880. if (expectedType === TRANSITION) {
  50881. if (transitionTimeout > 0) {
  50882. type = TRANSITION;
  50883. timeout = transitionTimeout;
  50884. propCount = transitionDurations.length;
  50885. }
  50886. } else if (expectedType === ANIMATION) {
  50887. if (animationTimeout > 0) {
  50888. type = ANIMATION;
  50889. timeout = animationTimeout;
  50890. propCount = animationDurations.length;
  50891. }
  50892. } else {
  50893. timeout = Math.max(transitionTimeout, animationTimeout);
  50894. type = timeout > 0
  50895. ? transitionTimeout > animationTimeout
  50896. ? TRANSITION
  50897. : ANIMATION
  50898. : null;
  50899. propCount = type
  50900. ? type === TRANSITION
  50901. ? transitionDurations.length
  50902. : animationDurations.length
  50903. : 0;
  50904. }
  50905. var hasTransform =
  50906. type === TRANSITION &&
  50907. transformRE.test(styles[transitionProp + 'Property']);
  50908. return {
  50909. type: type,
  50910. timeout: timeout,
  50911. propCount: propCount,
  50912. hasTransform: hasTransform
  50913. }
  50914. }
  50915. function getTimeout (delays, durations) {
  50916. /* istanbul ignore next */
  50917. while (delays.length < durations.length) {
  50918. delays = delays.concat(delays);
  50919. }
  50920. return Math.max.apply(null, durations.map(function (d, i) {
  50921. return toMs(d) + toMs(delays[i])
  50922. }))
  50923. }
  50924. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  50925. // in a locale-dependent way, using a comma instead of a dot.
  50926. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  50927. // as a floor function) causing unexpected behaviors
  50928. function toMs (s) {
  50929. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  50930. }
  50931. /* */
  50932. function enter (vnode, toggleDisplay) {
  50933. var el = vnode.elm;
  50934. // call leave callback now
  50935. if (isDef(el._leaveCb)) {
  50936. el._leaveCb.cancelled = true;
  50937. el._leaveCb();
  50938. }
  50939. var data = resolveTransition(vnode.data.transition);
  50940. if (isUndef(data)) {
  50941. return
  50942. }
  50943. /* istanbul ignore if */
  50944. if (isDef(el._enterCb) || el.nodeType !== 1) {
  50945. return
  50946. }
  50947. var css = data.css;
  50948. var type = data.type;
  50949. var enterClass = data.enterClass;
  50950. var enterToClass = data.enterToClass;
  50951. var enterActiveClass = data.enterActiveClass;
  50952. var appearClass = data.appearClass;
  50953. var appearToClass = data.appearToClass;
  50954. var appearActiveClass = data.appearActiveClass;
  50955. var beforeEnter = data.beforeEnter;
  50956. var enter = data.enter;
  50957. var afterEnter = data.afterEnter;
  50958. var enterCancelled = data.enterCancelled;
  50959. var beforeAppear = data.beforeAppear;
  50960. var appear = data.appear;
  50961. var afterAppear = data.afterAppear;
  50962. var appearCancelled = data.appearCancelled;
  50963. var duration = data.duration;
  50964. // activeInstance will always be the <transition> component managing this
  50965. // transition. One edge case to check is when the <transition> is placed
  50966. // as the root node of a child component. In that case we need to check
  50967. // <transition>'s parent for appear check.
  50968. var context = activeInstance;
  50969. var transitionNode = activeInstance.$vnode;
  50970. while (transitionNode && transitionNode.parent) {
  50971. context = transitionNode.context;
  50972. transitionNode = transitionNode.parent;
  50973. }
  50974. var isAppear = !context._isMounted || !vnode.isRootInsert;
  50975. if (isAppear && !appear && appear !== '') {
  50976. return
  50977. }
  50978. var startClass = isAppear && appearClass
  50979. ? appearClass
  50980. : enterClass;
  50981. var activeClass = isAppear && appearActiveClass
  50982. ? appearActiveClass
  50983. : enterActiveClass;
  50984. var toClass = isAppear && appearToClass
  50985. ? appearToClass
  50986. : enterToClass;
  50987. var beforeEnterHook = isAppear
  50988. ? (beforeAppear || beforeEnter)
  50989. : beforeEnter;
  50990. var enterHook = isAppear
  50991. ? (typeof appear === 'function' ? appear : enter)
  50992. : enter;
  50993. var afterEnterHook = isAppear
  50994. ? (afterAppear || afterEnter)
  50995. : afterEnter;
  50996. var enterCancelledHook = isAppear
  50997. ? (appearCancelled || enterCancelled)
  50998. : enterCancelled;
  50999. var explicitEnterDuration = toNumber(
  51000. isObject(duration)
  51001. ? duration.enter
  51002. : duration
  51003. );
  51004. if (explicitEnterDuration != null) {
  51005. checkDuration(explicitEnterDuration, 'enter', vnode);
  51006. }
  51007. var expectsCSS = css !== false && !isIE9;
  51008. var userWantsControl = getHookArgumentsLength(enterHook);
  51009. var cb = el._enterCb = once(function () {
  51010. if (expectsCSS) {
  51011. removeTransitionClass(el, toClass);
  51012. removeTransitionClass(el, activeClass);
  51013. }
  51014. if (cb.cancelled) {
  51015. if (expectsCSS) {
  51016. removeTransitionClass(el, startClass);
  51017. }
  51018. enterCancelledHook && enterCancelledHook(el);
  51019. } else {
  51020. afterEnterHook && afterEnterHook(el);
  51021. }
  51022. el._enterCb = null;
  51023. });
  51024. if (!vnode.data.show) {
  51025. // remove pending leave element on enter by injecting an insert hook
  51026. mergeVNodeHook(vnode, 'insert', function () {
  51027. var parent = el.parentNode;
  51028. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  51029. if (pendingNode &&
  51030. pendingNode.tag === vnode.tag &&
  51031. pendingNode.elm._leaveCb
  51032. ) {
  51033. pendingNode.elm._leaveCb();
  51034. }
  51035. enterHook && enterHook(el, cb);
  51036. });
  51037. }
  51038. // start enter transition
  51039. beforeEnterHook && beforeEnterHook(el);
  51040. if (expectsCSS) {
  51041. addTransitionClass(el, startClass);
  51042. addTransitionClass(el, activeClass);
  51043. nextFrame(function () {
  51044. removeTransitionClass(el, startClass);
  51045. if (!cb.cancelled) {
  51046. addTransitionClass(el, toClass);
  51047. if (!userWantsControl) {
  51048. if (isValidDuration(explicitEnterDuration)) {
  51049. setTimeout(cb, explicitEnterDuration);
  51050. } else {
  51051. whenTransitionEnds(el, type, cb);
  51052. }
  51053. }
  51054. }
  51055. });
  51056. }
  51057. if (vnode.data.show) {
  51058. toggleDisplay && toggleDisplay();
  51059. enterHook && enterHook(el, cb);
  51060. }
  51061. if (!expectsCSS && !userWantsControl) {
  51062. cb();
  51063. }
  51064. }
  51065. function leave (vnode, rm) {
  51066. var el = vnode.elm;
  51067. // call enter callback now
  51068. if (isDef(el._enterCb)) {
  51069. el._enterCb.cancelled = true;
  51070. el._enterCb();
  51071. }
  51072. var data = resolveTransition(vnode.data.transition);
  51073. if (isUndef(data) || el.nodeType !== 1) {
  51074. return rm()
  51075. }
  51076. /* istanbul ignore if */
  51077. if (isDef(el._leaveCb)) {
  51078. return
  51079. }
  51080. var css = data.css;
  51081. var type = data.type;
  51082. var leaveClass = data.leaveClass;
  51083. var leaveToClass = data.leaveToClass;
  51084. var leaveActiveClass = data.leaveActiveClass;
  51085. var beforeLeave = data.beforeLeave;
  51086. var leave = data.leave;
  51087. var afterLeave = data.afterLeave;
  51088. var leaveCancelled = data.leaveCancelled;
  51089. var delayLeave = data.delayLeave;
  51090. var duration = data.duration;
  51091. var expectsCSS = css !== false && !isIE9;
  51092. var userWantsControl = getHookArgumentsLength(leave);
  51093. var explicitLeaveDuration = toNumber(
  51094. isObject(duration)
  51095. ? duration.leave
  51096. : duration
  51097. );
  51098. if (isDef(explicitLeaveDuration)) {
  51099. checkDuration(explicitLeaveDuration, 'leave', vnode);
  51100. }
  51101. var cb = el._leaveCb = once(function () {
  51102. if (el.parentNode && el.parentNode._pending) {
  51103. el.parentNode._pending[vnode.key] = null;
  51104. }
  51105. if (expectsCSS) {
  51106. removeTransitionClass(el, leaveToClass);
  51107. removeTransitionClass(el, leaveActiveClass);
  51108. }
  51109. if (cb.cancelled) {
  51110. if (expectsCSS) {
  51111. removeTransitionClass(el, leaveClass);
  51112. }
  51113. leaveCancelled && leaveCancelled(el);
  51114. } else {
  51115. rm();
  51116. afterLeave && afterLeave(el);
  51117. }
  51118. el._leaveCb = null;
  51119. });
  51120. if (delayLeave) {
  51121. delayLeave(performLeave);
  51122. } else {
  51123. performLeave();
  51124. }
  51125. function performLeave () {
  51126. // the delayed leave may have already been cancelled
  51127. if (cb.cancelled) {
  51128. return
  51129. }
  51130. // record leaving element
  51131. if (!vnode.data.show && el.parentNode) {
  51132. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  51133. }
  51134. beforeLeave && beforeLeave(el);
  51135. if (expectsCSS) {
  51136. addTransitionClass(el, leaveClass);
  51137. addTransitionClass(el, leaveActiveClass);
  51138. nextFrame(function () {
  51139. removeTransitionClass(el, leaveClass);
  51140. if (!cb.cancelled) {
  51141. addTransitionClass(el, leaveToClass);
  51142. if (!userWantsControl) {
  51143. if (isValidDuration(explicitLeaveDuration)) {
  51144. setTimeout(cb, explicitLeaveDuration);
  51145. } else {
  51146. whenTransitionEnds(el, type, cb);
  51147. }
  51148. }
  51149. }
  51150. });
  51151. }
  51152. leave && leave(el, cb);
  51153. if (!expectsCSS && !userWantsControl) {
  51154. cb();
  51155. }
  51156. }
  51157. }
  51158. // only used in dev mode
  51159. function checkDuration (val, name, vnode) {
  51160. if (typeof val !== 'number') {
  51161. warn(
  51162. "<transition> explicit " + name + " duration is not a valid number - " +
  51163. "got " + (JSON.stringify(val)) + ".",
  51164. vnode.context
  51165. );
  51166. } else if (isNaN(val)) {
  51167. warn(
  51168. "<transition> explicit " + name + " duration is NaN - " +
  51169. 'the duration expression might be incorrect.',
  51170. vnode.context
  51171. );
  51172. }
  51173. }
  51174. function isValidDuration (val) {
  51175. return typeof val === 'number' && !isNaN(val)
  51176. }
  51177. /**
  51178. * Normalize a transition hook's argument length. The hook may be:
  51179. * - a merged hook (invoker) with the original in .fns
  51180. * - a wrapped component method (check ._length)
  51181. * - a plain function (.length)
  51182. */
  51183. function getHookArgumentsLength (fn) {
  51184. if (isUndef(fn)) {
  51185. return false
  51186. }
  51187. var invokerFns = fn.fns;
  51188. if (isDef(invokerFns)) {
  51189. // invoker
  51190. return getHookArgumentsLength(
  51191. Array.isArray(invokerFns)
  51192. ? invokerFns[0]
  51193. : invokerFns
  51194. )
  51195. } else {
  51196. return (fn._length || fn.length) > 1
  51197. }
  51198. }
  51199. function _enter (_, vnode) {
  51200. if (vnode.data.show !== true) {
  51201. enter(vnode);
  51202. }
  51203. }
  51204. var transition = inBrowser ? {
  51205. create: _enter,
  51206. activate: _enter,
  51207. remove: function remove$$1 (vnode, rm) {
  51208. /* istanbul ignore else */
  51209. if (vnode.data.show !== true) {
  51210. leave(vnode, rm);
  51211. } else {
  51212. rm();
  51213. }
  51214. }
  51215. } : {};
  51216. var platformModules = [
  51217. attrs,
  51218. klass,
  51219. events,
  51220. domProps,
  51221. style,
  51222. transition
  51223. ];
  51224. /* */
  51225. // the directive module should be applied last, after all
  51226. // built-in modules have been applied.
  51227. var modules = platformModules.concat(baseModules);
  51228. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  51229. /**
  51230. * Not type checking this file because flow doesn't like attaching
  51231. * properties to Elements.
  51232. */
  51233. /* istanbul ignore if */
  51234. if (isIE9) {
  51235. // http://www.matts411.com/post/internet-explorer-9-oninput/
  51236. document.addEventListener('selectionchange', function () {
  51237. var el = document.activeElement;
  51238. if (el && el.vmodel) {
  51239. trigger(el, 'input');
  51240. }
  51241. });
  51242. }
  51243. var directive = {
  51244. inserted: function inserted (el, binding, vnode, oldVnode) {
  51245. if (vnode.tag === 'select') {
  51246. // #6903
  51247. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  51248. mergeVNodeHook(vnode, 'postpatch', function () {
  51249. directive.componentUpdated(el, binding, vnode);
  51250. });
  51251. } else {
  51252. setSelected(el, binding, vnode.context);
  51253. }
  51254. el._vOptions = [].map.call(el.options, getValue);
  51255. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  51256. el._vModifiers = binding.modifiers;
  51257. if (!binding.modifiers.lazy) {
  51258. el.addEventListener('compositionstart', onCompositionStart);
  51259. el.addEventListener('compositionend', onCompositionEnd);
  51260. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  51261. // switching focus before confirming composition choice
  51262. // this also fixes the issue where some browsers e.g. iOS Chrome
  51263. // fires "change" instead of "input" on autocomplete.
  51264. el.addEventListener('change', onCompositionEnd);
  51265. /* istanbul ignore if */
  51266. if (isIE9) {
  51267. el.vmodel = true;
  51268. }
  51269. }
  51270. }
  51271. },
  51272. componentUpdated: function componentUpdated (el, binding, vnode) {
  51273. if (vnode.tag === 'select') {
  51274. setSelected(el, binding, vnode.context);
  51275. // in case the options rendered by v-for have changed,
  51276. // it's possible that the value is out-of-sync with the rendered options.
  51277. // detect such cases and filter out values that no longer has a matching
  51278. // option in the DOM.
  51279. var prevOptions = el._vOptions;
  51280. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  51281. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  51282. // trigger change event if
  51283. // no matching option found for at least one value
  51284. var needReset = el.multiple
  51285. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  51286. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  51287. if (needReset) {
  51288. trigger(el, 'change');
  51289. }
  51290. }
  51291. }
  51292. }
  51293. };
  51294. function setSelected (el, binding, vm) {
  51295. actuallySetSelected(el, binding, vm);
  51296. /* istanbul ignore if */
  51297. if (isIE || isEdge) {
  51298. setTimeout(function () {
  51299. actuallySetSelected(el, binding, vm);
  51300. }, 0);
  51301. }
  51302. }
  51303. function actuallySetSelected (el, binding, vm) {
  51304. var value = binding.value;
  51305. var isMultiple = el.multiple;
  51306. if (isMultiple && !Array.isArray(value)) {
  51307. warn(
  51308. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  51309. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  51310. vm
  51311. );
  51312. return
  51313. }
  51314. var selected, option;
  51315. for (var i = 0, l = el.options.length; i < l; i++) {
  51316. option = el.options[i];
  51317. if (isMultiple) {
  51318. selected = looseIndexOf(value, getValue(option)) > -1;
  51319. if (option.selected !== selected) {
  51320. option.selected = selected;
  51321. }
  51322. } else {
  51323. if (looseEqual(getValue(option), value)) {
  51324. if (el.selectedIndex !== i) {
  51325. el.selectedIndex = i;
  51326. }
  51327. return
  51328. }
  51329. }
  51330. }
  51331. if (!isMultiple) {
  51332. el.selectedIndex = -1;
  51333. }
  51334. }
  51335. function hasNoMatchingOption (value, options) {
  51336. return options.every(function (o) { return !looseEqual(o, value); })
  51337. }
  51338. function getValue (option) {
  51339. return '_value' in option
  51340. ? option._value
  51341. : option.value
  51342. }
  51343. function onCompositionStart (e) {
  51344. e.target.composing = true;
  51345. }
  51346. function onCompositionEnd (e) {
  51347. // prevent triggering an input event for no reason
  51348. if (!e.target.composing) { return }
  51349. e.target.composing = false;
  51350. trigger(e.target, 'input');
  51351. }
  51352. function trigger (el, type) {
  51353. var e = document.createEvent('HTMLEvents');
  51354. e.initEvent(type, true, true);
  51355. el.dispatchEvent(e);
  51356. }
  51357. /* */
  51358. // recursively search for possible transition defined inside the component root
  51359. function locateNode (vnode) {
  51360. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  51361. ? locateNode(vnode.componentInstance._vnode)
  51362. : vnode
  51363. }
  51364. var show = {
  51365. bind: function bind (el, ref, vnode) {
  51366. var value = ref.value;
  51367. vnode = locateNode(vnode);
  51368. var transition$$1 = vnode.data && vnode.data.transition;
  51369. var originalDisplay = el.__vOriginalDisplay =
  51370. el.style.display === 'none' ? '' : el.style.display;
  51371. if (value && transition$$1) {
  51372. vnode.data.show = true;
  51373. enter(vnode, function () {
  51374. el.style.display = originalDisplay;
  51375. });
  51376. } else {
  51377. el.style.display = value ? originalDisplay : 'none';
  51378. }
  51379. },
  51380. update: function update (el, ref, vnode) {
  51381. var value = ref.value;
  51382. var oldValue = ref.oldValue;
  51383. /* istanbul ignore if */
  51384. if (!value === !oldValue) { return }
  51385. vnode = locateNode(vnode);
  51386. var transition$$1 = vnode.data && vnode.data.transition;
  51387. if (transition$$1) {
  51388. vnode.data.show = true;
  51389. if (value) {
  51390. enter(vnode, function () {
  51391. el.style.display = el.__vOriginalDisplay;
  51392. });
  51393. } else {
  51394. leave(vnode, function () {
  51395. el.style.display = 'none';
  51396. });
  51397. }
  51398. } else {
  51399. el.style.display = value ? el.__vOriginalDisplay : 'none';
  51400. }
  51401. },
  51402. unbind: function unbind (
  51403. el,
  51404. binding,
  51405. vnode,
  51406. oldVnode,
  51407. isDestroy
  51408. ) {
  51409. if (!isDestroy) {
  51410. el.style.display = el.__vOriginalDisplay;
  51411. }
  51412. }
  51413. };
  51414. var platformDirectives = {
  51415. model: directive,
  51416. show: show
  51417. };
  51418. /* */
  51419. var transitionProps = {
  51420. name: String,
  51421. appear: Boolean,
  51422. css: Boolean,
  51423. mode: String,
  51424. type: String,
  51425. enterClass: String,
  51426. leaveClass: String,
  51427. enterToClass: String,
  51428. leaveToClass: String,
  51429. enterActiveClass: String,
  51430. leaveActiveClass: String,
  51431. appearClass: String,
  51432. appearActiveClass: String,
  51433. appearToClass: String,
  51434. duration: [Number, String, Object]
  51435. };
  51436. // in case the child is also an abstract component, e.g. <keep-alive>
  51437. // we want to recursively retrieve the real component to be rendered
  51438. function getRealChild (vnode) {
  51439. var compOptions = vnode && vnode.componentOptions;
  51440. if (compOptions && compOptions.Ctor.options.abstract) {
  51441. return getRealChild(getFirstComponentChild(compOptions.children))
  51442. } else {
  51443. return vnode
  51444. }
  51445. }
  51446. function extractTransitionData (comp) {
  51447. var data = {};
  51448. var options = comp.$options;
  51449. // props
  51450. for (var key in options.propsData) {
  51451. data[key] = comp[key];
  51452. }
  51453. // events.
  51454. // extract listeners and pass them directly to the transition methods
  51455. var listeners = options._parentListeners;
  51456. for (var key$1 in listeners) {
  51457. data[camelize(key$1)] = listeners[key$1];
  51458. }
  51459. return data
  51460. }
  51461. function placeholder (h, rawChild) {
  51462. if (/\d-keep-alive$/.test(rawChild.tag)) {
  51463. return h('keep-alive', {
  51464. props: rawChild.componentOptions.propsData
  51465. })
  51466. }
  51467. }
  51468. function hasParentTransition (vnode) {
  51469. while ((vnode = vnode.parent)) {
  51470. if (vnode.data.transition) {
  51471. return true
  51472. }
  51473. }
  51474. }
  51475. function isSameChild (child, oldChild) {
  51476. return oldChild.key === child.key && oldChild.tag === child.tag
  51477. }
  51478. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  51479. var isVShowDirective = function (d) { return d.name === 'show'; };
  51480. var Transition = {
  51481. name: 'transition',
  51482. props: transitionProps,
  51483. abstract: true,
  51484. render: function render (h) {
  51485. var this$1 = this;
  51486. var children = this.$slots.default;
  51487. if (!children) {
  51488. return
  51489. }
  51490. // filter out text nodes (possible whitespaces)
  51491. children = children.filter(isNotTextNode);
  51492. /* istanbul ignore if */
  51493. if (!children.length) {
  51494. return
  51495. }
  51496. // warn multiple elements
  51497. if (children.length > 1) {
  51498. warn(
  51499. '<transition> can only be used on a single element. Use ' +
  51500. '<transition-group> for lists.',
  51501. this.$parent
  51502. );
  51503. }
  51504. var mode = this.mode;
  51505. // warn invalid mode
  51506. if (mode && mode !== 'in-out' && mode !== 'out-in'
  51507. ) {
  51508. warn(
  51509. 'invalid <transition> mode: ' + mode,
  51510. this.$parent
  51511. );
  51512. }
  51513. var rawChild = children[0];
  51514. // if this is a component root node and the component's
  51515. // parent container node also has transition, skip.
  51516. if (hasParentTransition(this.$vnode)) {
  51517. return rawChild
  51518. }
  51519. // apply transition data to child
  51520. // use getRealChild() to ignore abstract components e.g. keep-alive
  51521. var child = getRealChild(rawChild);
  51522. /* istanbul ignore if */
  51523. if (!child) {
  51524. return rawChild
  51525. }
  51526. if (this._leaving) {
  51527. return placeholder(h, rawChild)
  51528. }
  51529. // ensure a key that is unique to the vnode type and to this transition
  51530. // component instance. This key will be used to remove pending leaving nodes
  51531. // during entering.
  51532. var id = "__transition-" + (this._uid) + "-";
  51533. child.key = child.key == null
  51534. ? child.isComment
  51535. ? id + 'comment'
  51536. : id + child.tag
  51537. : isPrimitive(child.key)
  51538. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  51539. : child.key;
  51540. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  51541. var oldRawChild = this._vnode;
  51542. var oldChild = getRealChild(oldRawChild);
  51543. // mark v-show
  51544. // so that the transition module can hand over the control to the directive
  51545. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  51546. child.data.show = true;
  51547. }
  51548. if (
  51549. oldChild &&
  51550. oldChild.data &&
  51551. !isSameChild(child, oldChild) &&
  51552. !isAsyncPlaceholder(oldChild) &&
  51553. // #6687 component root is a comment node
  51554. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  51555. ) {
  51556. // replace old child transition data with fresh one
  51557. // important for dynamic transitions!
  51558. var oldData = oldChild.data.transition = extend({}, data);
  51559. // handle transition mode
  51560. if (mode === 'out-in') {
  51561. // return placeholder node and queue update when leave finishes
  51562. this._leaving = true;
  51563. mergeVNodeHook(oldData, 'afterLeave', function () {
  51564. this$1._leaving = false;
  51565. this$1.$forceUpdate();
  51566. });
  51567. return placeholder(h, rawChild)
  51568. } else if (mode === 'in-out') {
  51569. if (isAsyncPlaceholder(child)) {
  51570. return oldRawChild
  51571. }
  51572. var delayedLeave;
  51573. var performLeave = function () { delayedLeave(); };
  51574. mergeVNodeHook(data, 'afterEnter', performLeave);
  51575. mergeVNodeHook(data, 'enterCancelled', performLeave);
  51576. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  51577. }
  51578. }
  51579. return rawChild
  51580. }
  51581. };
  51582. /* */
  51583. var props = extend({
  51584. tag: String,
  51585. moveClass: String
  51586. }, transitionProps);
  51587. delete props.mode;
  51588. var TransitionGroup = {
  51589. props: props,
  51590. beforeMount: function beforeMount () {
  51591. var this$1 = this;
  51592. var update = this._update;
  51593. this._update = function (vnode, hydrating) {
  51594. var restoreActiveInstance = setActiveInstance(this$1);
  51595. // force removing pass
  51596. this$1.__patch__(
  51597. this$1._vnode,
  51598. this$1.kept,
  51599. false, // hydrating
  51600. true // removeOnly (!important, avoids unnecessary moves)
  51601. );
  51602. this$1._vnode = this$1.kept;
  51603. restoreActiveInstance();
  51604. update.call(this$1, vnode, hydrating);
  51605. };
  51606. },
  51607. render: function render (h) {
  51608. var tag = this.tag || this.$vnode.data.tag || 'span';
  51609. var map = Object.create(null);
  51610. var prevChildren = this.prevChildren = this.children;
  51611. var rawChildren = this.$slots.default || [];
  51612. var children = this.children = [];
  51613. var transitionData = extractTransitionData(this);
  51614. for (var i = 0; i < rawChildren.length; i++) {
  51615. var c = rawChildren[i];
  51616. if (c.tag) {
  51617. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  51618. children.push(c);
  51619. map[c.key] = c
  51620. ;(c.data || (c.data = {})).transition = transitionData;
  51621. } else {
  51622. var opts = c.componentOptions;
  51623. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  51624. warn(("<transition-group> children must be keyed: <" + name + ">"));
  51625. }
  51626. }
  51627. }
  51628. if (prevChildren) {
  51629. var kept = [];
  51630. var removed = [];
  51631. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  51632. var c$1 = prevChildren[i$1];
  51633. c$1.data.transition = transitionData;
  51634. c$1.data.pos = c$1.elm.getBoundingClientRect();
  51635. if (map[c$1.key]) {
  51636. kept.push(c$1);
  51637. } else {
  51638. removed.push(c$1);
  51639. }
  51640. }
  51641. this.kept = h(tag, null, kept);
  51642. this.removed = removed;
  51643. }
  51644. return h(tag, null, children)
  51645. },
  51646. updated: function updated () {
  51647. var children = this.prevChildren;
  51648. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  51649. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  51650. return
  51651. }
  51652. // we divide the work into three loops to avoid mixing DOM reads and writes
  51653. // in each iteration - which helps prevent layout thrashing.
  51654. children.forEach(callPendingCbs);
  51655. children.forEach(recordPosition);
  51656. children.forEach(applyTranslation);
  51657. // force reflow to put everything in position
  51658. // assign to this to avoid being removed in tree-shaking
  51659. // $flow-disable-line
  51660. this._reflow = document.body.offsetHeight;
  51661. children.forEach(function (c) {
  51662. if (c.data.moved) {
  51663. var el = c.elm;
  51664. var s = el.style;
  51665. addTransitionClass(el, moveClass);
  51666. s.transform = s.WebkitTransform = s.transitionDuration = '';
  51667. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  51668. if (e && e.target !== el) {
  51669. return
  51670. }
  51671. if (!e || /transform$/.test(e.propertyName)) {
  51672. el.removeEventListener(transitionEndEvent, cb);
  51673. el._moveCb = null;
  51674. removeTransitionClass(el, moveClass);
  51675. }
  51676. });
  51677. }
  51678. });
  51679. },
  51680. methods: {
  51681. hasMove: function hasMove (el, moveClass) {
  51682. /* istanbul ignore if */
  51683. if (!hasTransition) {
  51684. return false
  51685. }
  51686. /* istanbul ignore if */
  51687. if (this._hasMove) {
  51688. return this._hasMove
  51689. }
  51690. // Detect whether an element with the move class applied has
  51691. // CSS transitions. Since the element may be inside an entering
  51692. // transition at this very moment, we make a clone of it and remove
  51693. // all other transition classes applied to ensure only the move class
  51694. // is applied.
  51695. var clone = el.cloneNode();
  51696. if (el._transitionClasses) {
  51697. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  51698. }
  51699. addClass(clone, moveClass);
  51700. clone.style.display = 'none';
  51701. this.$el.appendChild(clone);
  51702. var info = getTransitionInfo(clone);
  51703. this.$el.removeChild(clone);
  51704. return (this._hasMove = info.hasTransform)
  51705. }
  51706. }
  51707. };
  51708. function callPendingCbs (c) {
  51709. /* istanbul ignore if */
  51710. if (c.elm._moveCb) {
  51711. c.elm._moveCb();
  51712. }
  51713. /* istanbul ignore if */
  51714. if (c.elm._enterCb) {
  51715. c.elm._enterCb();
  51716. }
  51717. }
  51718. function recordPosition (c) {
  51719. c.data.newPos = c.elm.getBoundingClientRect();
  51720. }
  51721. function applyTranslation (c) {
  51722. var oldPos = c.data.pos;
  51723. var newPos = c.data.newPos;
  51724. var dx = oldPos.left - newPos.left;
  51725. var dy = oldPos.top - newPos.top;
  51726. if (dx || dy) {
  51727. c.data.moved = true;
  51728. var s = c.elm.style;
  51729. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  51730. s.transitionDuration = '0s';
  51731. }
  51732. }
  51733. var platformComponents = {
  51734. Transition: Transition,
  51735. TransitionGroup: TransitionGroup
  51736. };
  51737. /* */
  51738. // install platform specific utils
  51739. Vue.config.mustUseProp = mustUseProp;
  51740. Vue.config.isReservedTag = isReservedTag;
  51741. Vue.config.isReservedAttr = isReservedAttr;
  51742. Vue.config.getTagNamespace = getTagNamespace;
  51743. Vue.config.isUnknownElement = isUnknownElement;
  51744. // install platform runtime directives & components
  51745. extend(Vue.options.directives, platformDirectives);
  51746. extend(Vue.options.components, platformComponents);
  51747. // install platform patch function
  51748. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  51749. // public mount method
  51750. Vue.prototype.$mount = function (
  51751. el,
  51752. hydrating
  51753. ) {
  51754. el = el && inBrowser ? query(el) : undefined;
  51755. return mountComponent(this, el, hydrating)
  51756. };
  51757. // devtools global hook
  51758. /* istanbul ignore next */
  51759. if (inBrowser) {
  51760. setTimeout(function () {
  51761. if (config.devtools) {
  51762. if (devtools) {
  51763. devtools.emit('init', Vue);
  51764. } else {
  51765. console[console.info ? 'info' : 'log'](
  51766. 'Download the Vue Devtools extension for a better development experience:\n' +
  51767. 'https://github.com/vuejs/vue-devtools'
  51768. );
  51769. }
  51770. }
  51771. if (config.productionTip !== false &&
  51772. typeof console !== 'undefined'
  51773. ) {
  51774. console[console.info ? 'info' : 'log'](
  51775. "You are running Vue in development mode.\n" +
  51776. "Make sure to turn on production mode when deploying for production.\n" +
  51777. "See more tips at https://vuejs.org/guide/deployment.html"
  51778. );
  51779. }
  51780. }, 0);
  51781. }
  51782. /* */
  51783. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  51784. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  51785. var buildRegex = cached(function (delimiters) {
  51786. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  51787. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  51788. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  51789. });
  51790. function parseText (
  51791. text,
  51792. delimiters
  51793. ) {
  51794. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  51795. if (!tagRE.test(text)) {
  51796. return
  51797. }
  51798. var tokens = [];
  51799. var rawTokens = [];
  51800. var lastIndex = tagRE.lastIndex = 0;
  51801. var match, index, tokenValue;
  51802. while ((match = tagRE.exec(text))) {
  51803. index = match.index;
  51804. // push text token
  51805. if (index > lastIndex) {
  51806. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  51807. tokens.push(JSON.stringify(tokenValue));
  51808. }
  51809. // tag token
  51810. var exp = parseFilters(match[1].trim());
  51811. tokens.push(("_s(" + exp + ")"));
  51812. rawTokens.push({ '@binding': exp });
  51813. lastIndex = index + match[0].length;
  51814. }
  51815. if (lastIndex < text.length) {
  51816. rawTokens.push(tokenValue = text.slice(lastIndex));
  51817. tokens.push(JSON.stringify(tokenValue));
  51818. }
  51819. return {
  51820. expression: tokens.join('+'),
  51821. tokens: rawTokens
  51822. }
  51823. }
  51824. /* */
  51825. function transformNode (el, options) {
  51826. var warn = options.warn || baseWarn;
  51827. var staticClass = getAndRemoveAttr(el, 'class');
  51828. if (staticClass) {
  51829. var res = parseText(staticClass, options.delimiters);
  51830. if (res) {
  51831. warn(
  51832. "class=\"" + staticClass + "\": " +
  51833. 'Interpolation inside attributes has been removed. ' +
  51834. 'Use v-bind or the colon shorthand instead. For example, ' +
  51835. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  51836. el.rawAttrsMap['class']
  51837. );
  51838. }
  51839. }
  51840. if (staticClass) {
  51841. el.staticClass = JSON.stringify(staticClass);
  51842. }
  51843. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  51844. if (classBinding) {
  51845. el.classBinding = classBinding;
  51846. }
  51847. }
  51848. function genData (el) {
  51849. var data = '';
  51850. if (el.staticClass) {
  51851. data += "staticClass:" + (el.staticClass) + ",";
  51852. }
  51853. if (el.classBinding) {
  51854. data += "class:" + (el.classBinding) + ",";
  51855. }
  51856. return data
  51857. }
  51858. var klass$1 = {
  51859. staticKeys: ['staticClass'],
  51860. transformNode: transformNode,
  51861. genData: genData
  51862. };
  51863. /* */
  51864. function transformNode$1 (el, options) {
  51865. var warn = options.warn || baseWarn;
  51866. var staticStyle = getAndRemoveAttr(el, 'style');
  51867. if (staticStyle) {
  51868. /* istanbul ignore if */
  51869. {
  51870. var res = parseText(staticStyle, options.delimiters);
  51871. if (res) {
  51872. warn(
  51873. "style=\"" + staticStyle + "\": " +
  51874. 'Interpolation inside attributes has been removed. ' +
  51875. 'Use v-bind or the colon shorthand instead. For example, ' +
  51876. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  51877. el.rawAttrsMap['style']
  51878. );
  51879. }
  51880. }
  51881. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  51882. }
  51883. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  51884. if (styleBinding) {
  51885. el.styleBinding = styleBinding;
  51886. }
  51887. }
  51888. function genData$1 (el) {
  51889. var data = '';
  51890. if (el.staticStyle) {
  51891. data += "staticStyle:" + (el.staticStyle) + ",";
  51892. }
  51893. if (el.styleBinding) {
  51894. data += "style:(" + (el.styleBinding) + "),";
  51895. }
  51896. return data
  51897. }
  51898. var style$1 = {
  51899. staticKeys: ['staticStyle'],
  51900. transformNode: transformNode$1,
  51901. genData: genData$1
  51902. };
  51903. /* */
  51904. var decoder;
  51905. var he = {
  51906. decode: function decode (html) {
  51907. decoder = decoder || document.createElement('div');
  51908. decoder.innerHTML = html;
  51909. return decoder.textContent
  51910. }
  51911. };
  51912. /* */
  51913. var isUnaryTag = makeMap(
  51914. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  51915. 'link,meta,param,source,track,wbr'
  51916. );
  51917. // Elements that you can, intentionally, leave open
  51918. // (and which close themselves)
  51919. var canBeLeftOpenTag = makeMap(
  51920. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  51921. );
  51922. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  51923. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  51924. var isNonPhrasingTag = makeMap(
  51925. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  51926. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  51927. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  51928. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  51929. 'title,tr,track'
  51930. );
  51931. /**
  51932. * Not type-checking this file because it's mostly vendor code.
  51933. */
  51934. // Regular Expressions for parsing tags and attributes
  51935. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51936. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51937. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  51938. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  51939. var startTagOpen = new RegExp(("^<" + qnameCapture));
  51940. var startTagClose = /^\s*(\/?)>/;
  51941. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  51942. var doctype = /^<!DOCTYPE [^>]+>/i;
  51943. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  51944. var comment = /^<!\--/;
  51945. var conditionalComment = /^<!\[/;
  51946. // Special Elements (can contain anything)
  51947. var isPlainTextElement = makeMap('script,style,textarea', true);
  51948. var reCache = {};
  51949. var decodingMap = {
  51950. '&lt;': '<',
  51951. '&gt;': '>',
  51952. '&quot;': '"',
  51953. '&amp;': '&',
  51954. '&#10;': '\n',
  51955. '&#9;': '\t',
  51956. '&#39;': "'"
  51957. };
  51958. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  51959. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  51960. // #5992
  51961. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  51962. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  51963. function decodeAttr (value, shouldDecodeNewlines) {
  51964. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  51965. return value.replace(re, function (match) { return decodingMap[match]; })
  51966. }
  51967. function parseHTML (html, options) {
  51968. var stack = [];
  51969. var expectHTML = options.expectHTML;
  51970. var isUnaryTag$$1 = options.isUnaryTag || no;
  51971. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  51972. var index = 0;
  51973. var last, lastTag;
  51974. while (html) {
  51975. last = html;
  51976. // Make sure we're not in a plaintext content element like script/style
  51977. if (!lastTag || !isPlainTextElement(lastTag)) {
  51978. var textEnd = html.indexOf('<');
  51979. if (textEnd === 0) {
  51980. // Comment:
  51981. if (comment.test(html)) {
  51982. var commentEnd = html.indexOf('-->');
  51983. if (commentEnd >= 0) {
  51984. if (options.shouldKeepComment) {
  51985. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  51986. }
  51987. advance(commentEnd + 3);
  51988. continue
  51989. }
  51990. }
  51991. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  51992. if (conditionalComment.test(html)) {
  51993. var conditionalEnd = html.indexOf(']>');
  51994. if (conditionalEnd >= 0) {
  51995. advance(conditionalEnd + 2);
  51996. continue
  51997. }
  51998. }
  51999. // Doctype:
  52000. var doctypeMatch = html.match(doctype);
  52001. if (doctypeMatch) {
  52002. advance(doctypeMatch[0].length);
  52003. continue
  52004. }
  52005. // End tag:
  52006. var endTagMatch = html.match(endTag);
  52007. if (endTagMatch) {
  52008. var curIndex = index;
  52009. advance(endTagMatch[0].length);
  52010. parseEndTag(endTagMatch[1], curIndex, index);
  52011. continue
  52012. }
  52013. // Start tag:
  52014. var startTagMatch = parseStartTag();
  52015. if (startTagMatch) {
  52016. handleStartTag(startTagMatch);
  52017. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  52018. advance(1);
  52019. }
  52020. continue
  52021. }
  52022. }
  52023. var text = (void 0), rest = (void 0), next = (void 0);
  52024. if (textEnd >= 0) {
  52025. rest = html.slice(textEnd);
  52026. while (
  52027. !endTag.test(rest) &&
  52028. !startTagOpen.test(rest) &&
  52029. !comment.test(rest) &&
  52030. !conditionalComment.test(rest)
  52031. ) {
  52032. // < in plain text, be forgiving and treat it as text
  52033. next = rest.indexOf('<', 1);
  52034. if (next < 0) { break }
  52035. textEnd += next;
  52036. rest = html.slice(textEnd);
  52037. }
  52038. text = html.substring(0, textEnd);
  52039. }
  52040. if (textEnd < 0) {
  52041. text = html;
  52042. }
  52043. if (text) {
  52044. advance(text.length);
  52045. }
  52046. if (options.chars && text) {
  52047. options.chars(text, index - text.length, index);
  52048. }
  52049. } else {
  52050. var endTagLength = 0;
  52051. var stackedTag = lastTag.toLowerCase();
  52052. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  52053. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  52054. endTagLength = endTag.length;
  52055. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  52056. text = text
  52057. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  52058. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  52059. }
  52060. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  52061. text = text.slice(1);
  52062. }
  52063. if (options.chars) {
  52064. options.chars(text);
  52065. }
  52066. return ''
  52067. });
  52068. index += html.length - rest$1.length;
  52069. html = rest$1;
  52070. parseEndTag(stackedTag, index - endTagLength, index);
  52071. }
  52072. if (html === last) {
  52073. options.chars && options.chars(html);
  52074. if (!stack.length && options.warn) {
  52075. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  52076. }
  52077. break
  52078. }
  52079. }
  52080. // Clean up any remaining tags
  52081. parseEndTag();
  52082. function advance (n) {
  52083. index += n;
  52084. html = html.substring(n);
  52085. }
  52086. function parseStartTag () {
  52087. var start = html.match(startTagOpen);
  52088. if (start) {
  52089. var match = {
  52090. tagName: start[1],
  52091. attrs: [],
  52092. start: index
  52093. };
  52094. advance(start[0].length);
  52095. var end, attr;
  52096. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  52097. attr.start = index;
  52098. advance(attr[0].length);
  52099. attr.end = index;
  52100. match.attrs.push(attr);
  52101. }
  52102. if (end) {
  52103. match.unarySlash = end[1];
  52104. advance(end[0].length);
  52105. match.end = index;
  52106. return match
  52107. }
  52108. }
  52109. }
  52110. function handleStartTag (match) {
  52111. var tagName = match.tagName;
  52112. var unarySlash = match.unarySlash;
  52113. if (expectHTML) {
  52114. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  52115. parseEndTag(lastTag);
  52116. }
  52117. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  52118. parseEndTag(tagName);
  52119. }
  52120. }
  52121. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  52122. var l = match.attrs.length;
  52123. var attrs = new Array(l);
  52124. for (var i = 0; i < l; i++) {
  52125. var args = match.attrs[i];
  52126. var value = args[3] || args[4] || args[5] || '';
  52127. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  52128. ? options.shouldDecodeNewlinesForHref
  52129. : options.shouldDecodeNewlines;
  52130. attrs[i] = {
  52131. name: args[1],
  52132. value: decodeAttr(value, shouldDecodeNewlines)
  52133. };
  52134. if (options.outputSourceRange) {
  52135. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  52136. attrs[i].end = args.end;
  52137. }
  52138. }
  52139. if (!unary) {
  52140. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  52141. lastTag = tagName;
  52142. }
  52143. if (options.start) {
  52144. options.start(tagName, attrs, unary, match.start, match.end);
  52145. }
  52146. }
  52147. function parseEndTag (tagName, start, end) {
  52148. var pos, lowerCasedTagName;
  52149. if (start == null) { start = index; }
  52150. if (end == null) { end = index; }
  52151. // Find the closest opened tag of the same type
  52152. if (tagName) {
  52153. lowerCasedTagName = tagName.toLowerCase();
  52154. for (pos = stack.length - 1; pos >= 0; pos--) {
  52155. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  52156. break
  52157. }
  52158. }
  52159. } else {
  52160. // If no tag name is provided, clean shop
  52161. pos = 0;
  52162. }
  52163. if (pos >= 0) {
  52164. // Close all the open elements, up the stack
  52165. for (var i = stack.length - 1; i >= pos; i--) {
  52166. if (i > pos || !tagName &&
  52167. options.warn
  52168. ) {
  52169. options.warn(
  52170. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  52171. { start: stack[i].start, end: stack[i].end }
  52172. );
  52173. }
  52174. if (options.end) {
  52175. options.end(stack[i].tag, start, end);
  52176. }
  52177. }
  52178. // Remove the open elements from the stack
  52179. stack.length = pos;
  52180. lastTag = pos && stack[pos - 1].tag;
  52181. } else if (lowerCasedTagName === 'br') {
  52182. if (options.start) {
  52183. options.start(tagName, [], true, start, end);
  52184. }
  52185. } else if (lowerCasedTagName === 'p') {
  52186. if (options.start) {
  52187. options.start(tagName, [], false, start, end);
  52188. }
  52189. if (options.end) {
  52190. options.end(tagName, start, end);
  52191. }
  52192. }
  52193. }
  52194. }
  52195. /* */
  52196. var onRE = /^@|^v-on:/;
  52197. var dirRE = /^v-|^@|^:|^#/;
  52198. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  52199. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  52200. var stripParensRE = /^\(|\)$/g;
  52201. var dynamicArgRE = /^\[.*\]$/;
  52202. var argRE = /:(.*)$/;
  52203. var bindRE = /^:|^\.|^v-bind:/;
  52204. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  52205. var slotRE = /^v-slot(:|$)|^#/;
  52206. var lineBreakRE = /[\r\n]/;
  52207. var whitespaceRE$1 = /\s+/g;
  52208. var invalidAttributeRE = /[\s"'<>\/=]/;
  52209. var decodeHTMLCached = cached(he.decode);
  52210. var emptySlotScopeToken = "_empty_";
  52211. // configurable state
  52212. var warn$2;
  52213. var delimiters;
  52214. var transforms;
  52215. var preTransforms;
  52216. var postTransforms;
  52217. var platformIsPreTag;
  52218. var platformMustUseProp;
  52219. var platformGetTagNamespace;
  52220. var maybeComponent;
  52221. function createASTElement (
  52222. tag,
  52223. attrs,
  52224. parent
  52225. ) {
  52226. return {
  52227. type: 1,
  52228. tag: tag,
  52229. attrsList: attrs,
  52230. attrsMap: makeAttrsMap(attrs),
  52231. rawAttrsMap: {},
  52232. parent: parent,
  52233. children: []
  52234. }
  52235. }
  52236. /**
  52237. * Convert HTML string to AST.
  52238. */
  52239. function parse (
  52240. template,
  52241. options
  52242. ) {
  52243. warn$2 = options.warn || baseWarn;
  52244. platformIsPreTag = options.isPreTag || no;
  52245. platformMustUseProp = options.mustUseProp || no;
  52246. platformGetTagNamespace = options.getTagNamespace || no;
  52247. var isReservedTag = options.isReservedTag || no;
  52248. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  52249. transforms = pluckModuleFunction(options.modules, 'transformNode');
  52250. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  52251. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  52252. delimiters = options.delimiters;
  52253. var stack = [];
  52254. var preserveWhitespace = options.preserveWhitespace !== false;
  52255. var whitespaceOption = options.whitespace;
  52256. var root;
  52257. var currentParent;
  52258. var inVPre = false;
  52259. var inPre = false;
  52260. var warned = false;
  52261. function warnOnce (msg, range) {
  52262. if (!warned) {
  52263. warned = true;
  52264. warn$2(msg, range);
  52265. }
  52266. }
  52267. function closeElement (element) {
  52268. trimEndingWhitespace(element);
  52269. if (!inVPre && !element.processed) {
  52270. element = processElement(element, options);
  52271. }
  52272. // tree management
  52273. if (!stack.length && element !== root) {
  52274. // allow root elements with v-if, v-else-if and v-else
  52275. if (root.if && (element.elseif || element.else)) {
  52276. {
  52277. checkRootConstraints(element);
  52278. }
  52279. addIfCondition(root, {
  52280. exp: element.elseif,
  52281. block: element
  52282. });
  52283. } else {
  52284. warnOnce(
  52285. "Component template should contain exactly one root element. " +
  52286. "If you are using v-if on multiple elements, " +
  52287. "use v-else-if to chain them instead.",
  52288. { start: element.start }
  52289. );
  52290. }
  52291. }
  52292. if (currentParent && !element.forbidden) {
  52293. if (element.elseif || element.else) {
  52294. processIfConditions(element, currentParent);
  52295. } else {
  52296. if (element.slotScope) {
  52297. // scoped slot
  52298. // keep it in the children list so that v-else(-if) conditions can
  52299. // find it as the prev node.
  52300. var name = element.slotTarget || '"default"'
  52301. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  52302. }
  52303. currentParent.children.push(element);
  52304. element.parent = currentParent;
  52305. }
  52306. }
  52307. // final children cleanup
  52308. // filter out scoped slots
  52309. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  52310. // remove trailing whitespace node again
  52311. trimEndingWhitespace(element);
  52312. // check pre state
  52313. if (element.pre) {
  52314. inVPre = false;
  52315. }
  52316. if (platformIsPreTag(element.tag)) {
  52317. inPre = false;
  52318. }
  52319. // apply post-transforms
  52320. for (var i = 0; i < postTransforms.length; i++) {
  52321. postTransforms[i](element, options);
  52322. }
  52323. }
  52324. function trimEndingWhitespace (el) {
  52325. // remove trailing whitespace node
  52326. if (!inPre) {
  52327. var lastNode;
  52328. while (
  52329. (lastNode = el.children[el.children.length - 1]) &&
  52330. lastNode.type === 3 &&
  52331. lastNode.text === ' '
  52332. ) {
  52333. el.children.pop();
  52334. }
  52335. }
  52336. }
  52337. function checkRootConstraints (el) {
  52338. if (el.tag === 'slot' || el.tag === 'template') {
  52339. warnOnce(
  52340. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  52341. 'contain multiple nodes.',
  52342. { start: el.start }
  52343. );
  52344. }
  52345. if (el.attrsMap.hasOwnProperty('v-for')) {
  52346. warnOnce(
  52347. 'Cannot use v-for on stateful component root element because ' +
  52348. 'it renders multiple elements.',
  52349. el.rawAttrsMap['v-for']
  52350. );
  52351. }
  52352. }
  52353. parseHTML(template, {
  52354. warn: warn$2,
  52355. expectHTML: options.expectHTML,
  52356. isUnaryTag: options.isUnaryTag,
  52357. canBeLeftOpenTag: options.canBeLeftOpenTag,
  52358. shouldDecodeNewlines: options.shouldDecodeNewlines,
  52359. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  52360. shouldKeepComment: options.comments,
  52361. outputSourceRange: options.outputSourceRange,
  52362. start: function start (tag, attrs, unary, start$1, end) {
  52363. // check namespace.
  52364. // inherit parent ns if there is one
  52365. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  52366. // handle IE svg bug
  52367. /* istanbul ignore if */
  52368. if (isIE && ns === 'svg') {
  52369. attrs = guardIESVGBug(attrs);
  52370. }
  52371. var element = createASTElement(tag, attrs, currentParent);
  52372. if (ns) {
  52373. element.ns = ns;
  52374. }
  52375. {
  52376. if (options.outputSourceRange) {
  52377. element.start = start$1;
  52378. element.end = end;
  52379. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  52380. cumulated[attr.name] = attr;
  52381. return cumulated
  52382. }, {});
  52383. }
  52384. attrs.forEach(function (attr) {
  52385. if (invalidAttributeRE.test(attr.name)) {
  52386. warn$2(
  52387. "Invalid dynamic argument expression: attribute names cannot contain " +
  52388. "spaces, quotes, <, >, / or =.",
  52389. {
  52390. start: attr.start + attr.name.indexOf("["),
  52391. end: attr.start + attr.name.length
  52392. }
  52393. );
  52394. }
  52395. });
  52396. }
  52397. if (isForbiddenTag(element) && !isServerRendering()) {
  52398. element.forbidden = true;
  52399. warn$2(
  52400. 'Templates should only be responsible for mapping the state to the ' +
  52401. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  52402. "<" + tag + ">" + ', as they will not be parsed.',
  52403. { start: element.start }
  52404. );
  52405. }
  52406. // apply pre-transforms
  52407. for (var i = 0; i < preTransforms.length; i++) {
  52408. element = preTransforms[i](element, options) || element;
  52409. }
  52410. if (!inVPre) {
  52411. processPre(element);
  52412. if (element.pre) {
  52413. inVPre = true;
  52414. }
  52415. }
  52416. if (platformIsPreTag(element.tag)) {
  52417. inPre = true;
  52418. }
  52419. if (inVPre) {
  52420. processRawAttrs(element);
  52421. } else if (!element.processed) {
  52422. // structural directives
  52423. processFor(element);
  52424. processIf(element);
  52425. processOnce(element);
  52426. }
  52427. if (!root) {
  52428. root = element;
  52429. {
  52430. checkRootConstraints(root);
  52431. }
  52432. }
  52433. if (!unary) {
  52434. currentParent = element;
  52435. stack.push(element);
  52436. } else {
  52437. closeElement(element);
  52438. }
  52439. },
  52440. end: function end (tag, start, end$1) {
  52441. var element = stack[stack.length - 1];
  52442. // pop stack
  52443. stack.length -= 1;
  52444. currentParent = stack[stack.length - 1];
  52445. if (options.outputSourceRange) {
  52446. element.end = end$1;
  52447. }
  52448. closeElement(element);
  52449. },
  52450. chars: function chars (text, start, end) {
  52451. if (!currentParent) {
  52452. {
  52453. if (text === template) {
  52454. warnOnce(
  52455. 'Component template requires a root element, rather than just text.',
  52456. { start: start }
  52457. );
  52458. } else if ((text = text.trim())) {
  52459. warnOnce(
  52460. ("text \"" + text + "\" outside root element will be ignored."),
  52461. { start: start }
  52462. );
  52463. }
  52464. }
  52465. return
  52466. }
  52467. // IE textarea placeholder bug
  52468. /* istanbul ignore if */
  52469. if (isIE &&
  52470. currentParent.tag === 'textarea' &&
  52471. currentParent.attrsMap.placeholder === text
  52472. ) {
  52473. return
  52474. }
  52475. var children = currentParent.children;
  52476. if (inPre || text.trim()) {
  52477. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  52478. } else if (!children.length) {
  52479. // remove the whitespace-only node right after an opening tag
  52480. text = '';
  52481. } else if (whitespaceOption) {
  52482. if (whitespaceOption === 'condense') {
  52483. // in condense mode, remove the whitespace node if it contains
  52484. // line break, otherwise condense to a single space
  52485. text = lineBreakRE.test(text) ? '' : ' ';
  52486. } else {
  52487. text = ' ';
  52488. }
  52489. } else {
  52490. text = preserveWhitespace ? ' ' : '';
  52491. }
  52492. if (text) {
  52493. if (!inPre && whitespaceOption === 'condense') {
  52494. // condense consecutive whitespaces into single space
  52495. text = text.replace(whitespaceRE$1, ' ');
  52496. }
  52497. var res;
  52498. var child;
  52499. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  52500. child = {
  52501. type: 2,
  52502. expression: res.expression,
  52503. tokens: res.tokens,
  52504. text: text
  52505. };
  52506. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  52507. child = {
  52508. type: 3,
  52509. text: text
  52510. };
  52511. }
  52512. if (child) {
  52513. if (options.outputSourceRange) {
  52514. child.start = start;
  52515. child.end = end;
  52516. }
  52517. children.push(child);
  52518. }
  52519. }
  52520. },
  52521. comment: function comment (text, start, end) {
  52522. // adding anyting as a sibling to the root node is forbidden
  52523. // comments should still be allowed, but ignored
  52524. if (currentParent) {
  52525. var child = {
  52526. type: 3,
  52527. text: text,
  52528. isComment: true
  52529. };
  52530. if (options.outputSourceRange) {
  52531. child.start = start;
  52532. child.end = end;
  52533. }
  52534. currentParent.children.push(child);
  52535. }
  52536. }
  52537. });
  52538. return root
  52539. }
  52540. function processPre (el) {
  52541. if (getAndRemoveAttr(el, 'v-pre') != null) {
  52542. el.pre = true;
  52543. }
  52544. }
  52545. function processRawAttrs (el) {
  52546. var list = el.attrsList;
  52547. var len = list.length;
  52548. if (len) {
  52549. var attrs = el.attrs = new Array(len);
  52550. for (var i = 0; i < len; i++) {
  52551. attrs[i] = {
  52552. name: list[i].name,
  52553. value: JSON.stringify(list[i].value)
  52554. };
  52555. if (list[i].start != null) {
  52556. attrs[i].start = list[i].start;
  52557. attrs[i].end = list[i].end;
  52558. }
  52559. }
  52560. } else if (!el.pre) {
  52561. // non root node in pre blocks with no attributes
  52562. el.plain = true;
  52563. }
  52564. }
  52565. function processElement (
  52566. element,
  52567. options
  52568. ) {
  52569. processKey(element);
  52570. // determine whether this is a plain element after
  52571. // removing structural attributes
  52572. element.plain = (
  52573. !element.key &&
  52574. !element.scopedSlots &&
  52575. !element.attrsList.length
  52576. );
  52577. processRef(element);
  52578. processSlotContent(element);
  52579. processSlotOutlet(element);
  52580. processComponent(element);
  52581. for (var i = 0; i < transforms.length; i++) {
  52582. element = transforms[i](element, options) || element;
  52583. }
  52584. processAttrs(element);
  52585. return element
  52586. }
  52587. function processKey (el) {
  52588. var exp = getBindingAttr(el, 'key');
  52589. if (exp) {
  52590. {
  52591. if (el.tag === 'template') {
  52592. warn$2(
  52593. "<template> cannot be keyed. Place the key on real elements instead.",
  52594. getRawBindingAttr(el, 'key')
  52595. );
  52596. }
  52597. if (el.for) {
  52598. var iterator = el.iterator2 || el.iterator1;
  52599. var parent = el.parent;
  52600. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  52601. warn$2(
  52602. "Do not use v-for index as key on <transition-group> children, " +
  52603. "this is the same as not using keys.",
  52604. getRawBindingAttr(el, 'key'),
  52605. true /* tip */
  52606. );
  52607. }
  52608. }
  52609. }
  52610. el.key = exp;
  52611. }
  52612. }
  52613. function processRef (el) {
  52614. var ref = getBindingAttr(el, 'ref');
  52615. if (ref) {
  52616. el.ref = ref;
  52617. el.refInFor = checkInFor(el);
  52618. }
  52619. }
  52620. function processFor (el) {
  52621. var exp;
  52622. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  52623. var res = parseFor(exp);
  52624. if (res) {
  52625. extend(el, res);
  52626. } else {
  52627. warn$2(
  52628. ("Invalid v-for expression: " + exp),
  52629. el.rawAttrsMap['v-for']
  52630. );
  52631. }
  52632. }
  52633. }
  52634. function parseFor (exp) {
  52635. var inMatch = exp.match(forAliasRE);
  52636. if (!inMatch) { return }
  52637. var res = {};
  52638. res.for = inMatch[2].trim();
  52639. var alias = inMatch[1].trim().replace(stripParensRE, '');
  52640. var iteratorMatch = alias.match(forIteratorRE);
  52641. if (iteratorMatch) {
  52642. res.alias = alias.replace(forIteratorRE, '').trim();
  52643. res.iterator1 = iteratorMatch[1].trim();
  52644. if (iteratorMatch[2]) {
  52645. res.iterator2 = iteratorMatch[2].trim();
  52646. }
  52647. } else {
  52648. res.alias = alias;
  52649. }
  52650. return res
  52651. }
  52652. function processIf (el) {
  52653. var exp = getAndRemoveAttr(el, 'v-if');
  52654. if (exp) {
  52655. el.if = exp;
  52656. addIfCondition(el, {
  52657. exp: exp,
  52658. block: el
  52659. });
  52660. } else {
  52661. if (getAndRemoveAttr(el, 'v-else') != null) {
  52662. el.else = true;
  52663. }
  52664. var elseif = getAndRemoveAttr(el, 'v-else-if');
  52665. if (elseif) {
  52666. el.elseif = elseif;
  52667. }
  52668. }
  52669. }
  52670. function processIfConditions (el, parent) {
  52671. var prev = findPrevElement(parent.children);
  52672. if (prev && prev.if) {
  52673. addIfCondition(prev, {
  52674. exp: el.elseif,
  52675. block: el
  52676. });
  52677. } else {
  52678. warn$2(
  52679. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  52680. "used on element <" + (el.tag) + "> without corresponding v-if.",
  52681. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  52682. );
  52683. }
  52684. }
  52685. function findPrevElement (children) {
  52686. var i = children.length;
  52687. while (i--) {
  52688. if (children[i].type === 1) {
  52689. return children[i]
  52690. } else {
  52691. if (children[i].text !== ' ') {
  52692. warn$2(
  52693. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  52694. "will be ignored.",
  52695. children[i]
  52696. );
  52697. }
  52698. children.pop();
  52699. }
  52700. }
  52701. }
  52702. function addIfCondition (el, condition) {
  52703. if (!el.ifConditions) {
  52704. el.ifConditions = [];
  52705. }
  52706. el.ifConditions.push(condition);
  52707. }
  52708. function processOnce (el) {
  52709. var once$$1 = getAndRemoveAttr(el, 'v-once');
  52710. if (once$$1 != null) {
  52711. el.once = true;
  52712. }
  52713. }
  52714. // handle content being passed to a component as slot,
  52715. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  52716. function processSlotContent (el) {
  52717. var slotScope;
  52718. if (el.tag === 'template') {
  52719. slotScope = getAndRemoveAttr(el, 'scope');
  52720. /* istanbul ignore if */
  52721. if (slotScope) {
  52722. warn$2(
  52723. "the \"scope\" attribute for scoped slots have been deprecated and " +
  52724. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  52725. "can also be used on plain elements in addition to <template> to " +
  52726. "denote scoped slots.",
  52727. el.rawAttrsMap['scope'],
  52728. true
  52729. );
  52730. }
  52731. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  52732. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  52733. /* istanbul ignore if */
  52734. if (el.attrsMap['v-for']) {
  52735. warn$2(
  52736. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  52737. "(v-for takes higher priority). Use a wrapper <template> for the " +
  52738. "scoped slot to make it clearer.",
  52739. el.rawAttrsMap['slot-scope'],
  52740. true
  52741. );
  52742. }
  52743. el.slotScope = slotScope;
  52744. }
  52745. // slot="xxx"
  52746. var slotTarget = getBindingAttr(el, 'slot');
  52747. if (slotTarget) {
  52748. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  52749. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  52750. // preserve slot as an attribute for native shadow DOM compat
  52751. // only for non-scoped slots.
  52752. if (el.tag !== 'template' && !el.slotScope) {
  52753. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  52754. }
  52755. }
  52756. // 2.6 v-slot syntax
  52757. {
  52758. if (el.tag === 'template') {
  52759. // v-slot on <template>
  52760. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  52761. if (slotBinding) {
  52762. {
  52763. if (el.slotTarget || el.slotScope) {
  52764. warn$2(
  52765. "Unexpected mixed usage of different slot syntaxes.",
  52766. el
  52767. );
  52768. }
  52769. if (el.parent && !maybeComponent(el.parent)) {
  52770. warn$2(
  52771. "<template v-slot> can only appear at the root level inside " +
  52772. "the receiving component",
  52773. el
  52774. );
  52775. }
  52776. }
  52777. var ref = getSlotName(slotBinding);
  52778. var name = ref.name;
  52779. var dynamic = ref.dynamic;
  52780. el.slotTarget = name;
  52781. el.slotTargetDynamic = dynamic;
  52782. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  52783. }
  52784. } else {
  52785. // v-slot on component, denotes default slot
  52786. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  52787. if (slotBinding$1) {
  52788. {
  52789. if (!maybeComponent(el)) {
  52790. warn$2(
  52791. "v-slot can only be used on components or <template>.",
  52792. slotBinding$1
  52793. );
  52794. }
  52795. if (el.slotScope || el.slotTarget) {
  52796. warn$2(
  52797. "Unexpected mixed usage of different slot syntaxes.",
  52798. el
  52799. );
  52800. }
  52801. if (el.scopedSlots) {
  52802. warn$2(
  52803. "To avoid scope ambiguity, the default slot should also use " +
  52804. "<template> syntax when there are other named slots.",
  52805. slotBinding$1
  52806. );
  52807. }
  52808. }
  52809. // add the component's children to its default slot
  52810. var slots = el.scopedSlots || (el.scopedSlots = {});
  52811. var ref$1 = getSlotName(slotBinding$1);
  52812. var name$1 = ref$1.name;
  52813. var dynamic$1 = ref$1.dynamic;
  52814. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  52815. slotContainer.slotTarget = name$1;
  52816. slotContainer.slotTargetDynamic = dynamic$1;
  52817. slotContainer.children = el.children.filter(function (c) {
  52818. if (!c.slotScope) {
  52819. c.parent = slotContainer;
  52820. return true
  52821. }
  52822. });
  52823. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  52824. // remove children as they are returned from scopedSlots now
  52825. el.children = [];
  52826. // mark el non-plain so data gets generated
  52827. el.plain = false;
  52828. }
  52829. }
  52830. }
  52831. }
  52832. function getSlotName (binding) {
  52833. var name = binding.name.replace(slotRE, '');
  52834. if (!name) {
  52835. if (binding.name[0] !== '#') {
  52836. name = 'default';
  52837. } else {
  52838. warn$2(
  52839. "v-slot shorthand syntax requires a slot name.",
  52840. binding
  52841. );
  52842. }
  52843. }
  52844. return dynamicArgRE.test(name)
  52845. // dynamic [name]
  52846. ? { name: name.slice(1, -1), dynamic: true }
  52847. // static name
  52848. : { name: ("\"" + name + "\""), dynamic: false }
  52849. }
  52850. // handle <slot/> outlets
  52851. function processSlotOutlet (el) {
  52852. if (el.tag === 'slot') {
  52853. el.slotName = getBindingAttr(el, 'name');
  52854. if (el.key) {
  52855. warn$2(
  52856. "`key` does not work on <slot> because slots are abstract outlets " +
  52857. "and can possibly expand into multiple elements. " +
  52858. "Use the key on a wrapping element instead.",
  52859. getRawBindingAttr(el, 'key')
  52860. );
  52861. }
  52862. }
  52863. }
  52864. function processComponent (el) {
  52865. var binding;
  52866. if ((binding = getBindingAttr(el, 'is'))) {
  52867. el.component = binding;
  52868. }
  52869. if (getAndRemoveAttr(el, 'inline-template') != null) {
  52870. el.inlineTemplate = true;
  52871. }
  52872. }
  52873. function processAttrs (el) {
  52874. var list = el.attrsList;
  52875. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  52876. for (i = 0, l = list.length; i < l; i++) {
  52877. name = rawName = list[i].name;
  52878. value = list[i].value;
  52879. if (dirRE.test(name)) {
  52880. // mark element as dynamic
  52881. el.hasBindings = true;
  52882. // modifiers
  52883. modifiers = parseModifiers(name.replace(dirRE, ''));
  52884. // support .foo shorthand syntax for the .prop modifier
  52885. if (modifiers) {
  52886. name = name.replace(modifierRE, '');
  52887. }
  52888. if (bindRE.test(name)) { // v-bind
  52889. name = name.replace(bindRE, '');
  52890. value = parseFilters(value);
  52891. isDynamic = dynamicArgRE.test(name);
  52892. if (isDynamic) {
  52893. name = name.slice(1, -1);
  52894. }
  52895. if (
  52896. value.trim().length === 0
  52897. ) {
  52898. warn$2(
  52899. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  52900. );
  52901. }
  52902. if (modifiers) {
  52903. if (modifiers.prop && !isDynamic) {
  52904. name = camelize(name);
  52905. if (name === 'innerHtml') { name = 'innerHTML'; }
  52906. }
  52907. if (modifiers.camel && !isDynamic) {
  52908. name = camelize(name);
  52909. }
  52910. if (modifiers.sync) {
  52911. syncGen = genAssignmentCode(value, "$event");
  52912. if (!isDynamic) {
  52913. addHandler(
  52914. el,
  52915. ("update:" + (camelize(name))),
  52916. syncGen,
  52917. null,
  52918. false,
  52919. warn$2,
  52920. list[i]
  52921. );
  52922. if (hyphenate(name) !== camelize(name)) {
  52923. addHandler(
  52924. el,
  52925. ("update:" + (hyphenate(name))),
  52926. syncGen,
  52927. null,
  52928. false,
  52929. warn$2,
  52930. list[i]
  52931. );
  52932. }
  52933. } else {
  52934. // handler w/ dynamic event name
  52935. addHandler(
  52936. el,
  52937. ("\"update:\"+(" + name + ")"),
  52938. syncGen,
  52939. null,
  52940. false,
  52941. warn$2,
  52942. list[i],
  52943. true // dynamic
  52944. );
  52945. }
  52946. }
  52947. }
  52948. if ((modifiers && modifiers.prop) || (
  52949. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  52950. )) {
  52951. addProp(el, name, value, list[i], isDynamic);
  52952. } else {
  52953. addAttr(el, name, value, list[i], isDynamic);
  52954. }
  52955. } else if (onRE.test(name)) { // v-on
  52956. name = name.replace(onRE, '');
  52957. isDynamic = dynamicArgRE.test(name);
  52958. if (isDynamic) {
  52959. name = name.slice(1, -1);
  52960. }
  52961. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  52962. } else { // normal directives
  52963. name = name.replace(dirRE, '');
  52964. // parse arg
  52965. var argMatch = name.match(argRE);
  52966. var arg = argMatch && argMatch[1];
  52967. isDynamic = false;
  52968. if (arg) {
  52969. name = name.slice(0, -(arg.length + 1));
  52970. if (dynamicArgRE.test(arg)) {
  52971. arg = arg.slice(1, -1);
  52972. isDynamic = true;
  52973. }
  52974. }
  52975. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  52976. if (name === 'model') {
  52977. checkForAliasModel(el, value);
  52978. }
  52979. }
  52980. } else {
  52981. // literal attribute
  52982. {
  52983. var res = parseText(value, delimiters);
  52984. if (res) {
  52985. warn$2(
  52986. name + "=\"" + value + "\": " +
  52987. 'Interpolation inside attributes has been removed. ' +
  52988. 'Use v-bind or the colon shorthand instead. For example, ' +
  52989. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  52990. list[i]
  52991. );
  52992. }
  52993. }
  52994. addAttr(el, name, JSON.stringify(value), list[i]);
  52995. // #6887 firefox doesn't update muted state if set via attribute
  52996. // even immediately after element creation
  52997. if (!el.component &&
  52998. name === 'muted' &&
  52999. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  53000. addProp(el, name, 'true', list[i]);
  53001. }
  53002. }
  53003. }
  53004. }
  53005. function checkInFor (el) {
  53006. var parent = el;
  53007. while (parent) {
  53008. if (parent.for !== undefined) {
  53009. return true
  53010. }
  53011. parent = parent.parent;
  53012. }
  53013. return false
  53014. }
  53015. function parseModifiers (name) {
  53016. var match = name.match(modifierRE);
  53017. if (match) {
  53018. var ret = {};
  53019. match.forEach(function (m) { ret[m.slice(1)] = true; });
  53020. return ret
  53021. }
  53022. }
  53023. function makeAttrsMap (attrs) {
  53024. var map = {};
  53025. for (var i = 0, l = attrs.length; i < l; i++) {
  53026. if (
  53027. map[attrs[i].name] && !isIE && !isEdge
  53028. ) {
  53029. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  53030. }
  53031. map[attrs[i].name] = attrs[i].value;
  53032. }
  53033. return map
  53034. }
  53035. // for script (e.g. type="x/template") or style, do not decode content
  53036. function isTextTag (el) {
  53037. return el.tag === 'script' || el.tag === 'style'
  53038. }
  53039. function isForbiddenTag (el) {
  53040. return (
  53041. el.tag === 'style' ||
  53042. (el.tag === 'script' && (
  53043. !el.attrsMap.type ||
  53044. el.attrsMap.type === 'text/javascript'
  53045. ))
  53046. )
  53047. }
  53048. var ieNSBug = /^xmlns:NS\d+/;
  53049. var ieNSPrefix = /^NS\d+:/;
  53050. /* istanbul ignore next */
  53051. function guardIESVGBug (attrs) {
  53052. var res = [];
  53053. for (var i = 0; i < attrs.length; i++) {
  53054. var attr = attrs[i];
  53055. if (!ieNSBug.test(attr.name)) {
  53056. attr.name = attr.name.replace(ieNSPrefix, '');
  53057. res.push(attr);
  53058. }
  53059. }
  53060. return res
  53061. }
  53062. function checkForAliasModel (el, value) {
  53063. var _el = el;
  53064. while (_el) {
  53065. if (_el.for && _el.alias === value) {
  53066. warn$2(
  53067. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  53068. "You are binding v-model directly to a v-for iteration alias. " +
  53069. "This will not be able to modify the v-for source array because " +
  53070. "writing to the alias is like modifying a function local variable. " +
  53071. "Consider using an array of objects and use v-model on an object property instead.",
  53072. el.rawAttrsMap['v-model']
  53073. );
  53074. }
  53075. _el = _el.parent;
  53076. }
  53077. }
  53078. /* */
  53079. function preTransformNode (el, options) {
  53080. if (el.tag === 'input') {
  53081. var map = el.attrsMap;
  53082. if (!map['v-model']) {
  53083. return
  53084. }
  53085. var typeBinding;
  53086. if (map[':type'] || map['v-bind:type']) {
  53087. typeBinding = getBindingAttr(el, 'type');
  53088. }
  53089. if (!map.type && !typeBinding && map['v-bind']) {
  53090. typeBinding = "(" + (map['v-bind']) + ").type";
  53091. }
  53092. if (typeBinding) {
  53093. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  53094. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  53095. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  53096. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  53097. // 1. checkbox
  53098. var branch0 = cloneASTElement(el);
  53099. // process for on the main node
  53100. processFor(branch0);
  53101. addRawAttr(branch0, 'type', 'checkbox');
  53102. processElement(branch0, options);
  53103. branch0.processed = true; // prevent it from double-processed
  53104. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  53105. addIfCondition(branch0, {
  53106. exp: branch0.if,
  53107. block: branch0
  53108. });
  53109. // 2. add radio else-if condition
  53110. var branch1 = cloneASTElement(el);
  53111. getAndRemoveAttr(branch1, 'v-for', true);
  53112. addRawAttr(branch1, 'type', 'radio');
  53113. processElement(branch1, options);
  53114. addIfCondition(branch0, {
  53115. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  53116. block: branch1
  53117. });
  53118. // 3. other
  53119. var branch2 = cloneASTElement(el);
  53120. getAndRemoveAttr(branch2, 'v-for', true);
  53121. addRawAttr(branch2, ':type', typeBinding);
  53122. processElement(branch2, options);
  53123. addIfCondition(branch0, {
  53124. exp: ifCondition,
  53125. block: branch2
  53126. });
  53127. if (hasElse) {
  53128. branch0.else = true;
  53129. } else if (elseIfCondition) {
  53130. branch0.elseif = elseIfCondition;
  53131. }
  53132. return branch0
  53133. }
  53134. }
  53135. }
  53136. function cloneASTElement (el) {
  53137. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  53138. }
  53139. var model$1 = {
  53140. preTransformNode: preTransformNode
  53141. };
  53142. var modules$1 = [
  53143. klass$1,
  53144. style$1,
  53145. model$1
  53146. ];
  53147. /* */
  53148. function text (el, dir) {
  53149. if (dir.value) {
  53150. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  53151. }
  53152. }
  53153. /* */
  53154. function html (el, dir) {
  53155. if (dir.value) {
  53156. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  53157. }
  53158. }
  53159. var directives$1 = {
  53160. model: model,
  53161. text: text,
  53162. html: html
  53163. };
  53164. /* */
  53165. var baseOptions = {
  53166. expectHTML: true,
  53167. modules: modules$1,
  53168. directives: directives$1,
  53169. isPreTag: isPreTag,
  53170. isUnaryTag: isUnaryTag,
  53171. mustUseProp: mustUseProp,
  53172. canBeLeftOpenTag: canBeLeftOpenTag,
  53173. isReservedTag: isReservedTag,
  53174. getTagNamespace: getTagNamespace,
  53175. staticKeys: genStaticKeys(modules$1)
  53176. };
  53177. /* */
  53178. var isStaticKey;
  53179. var isPlatformReservedTag;
  53180. var genStaticKeysCached = cached(genStaticKeys$1);
  53181. /**
  53182. * Goal of the optimizer: walk the generated template AST tree
  53183. * and detect sub-trees that are purely static, i.e. parts of
  53184. * the DOM that never needs to change.
  53185. *
  53186. * Once we detect these sub-trees, we can:
  53187. *
  53188. * 1. Hoist them into constants, so that we no longer need to
  53189. * create fresh nodes for them on each re-render;
  53190. * 2. Completely skip them in the patching process.
  53191. */
  53192. function optimize (root, options) {
  53193. if (!root) { return }
  53194. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  53195. isPlatformReservedTag = options.isReservedTag || no;
  53196. // first pass: mark all non-static nodes.
  53197. markStatic$1(root);
  53198. // second pass: mark static roots.
  53199. markStaticRoots(root, false);
  53200. }
  53201. function genStaticKeys$1 (keys) {
  53202. return makeMap(
  53203. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  53204. (keys ? ',' + keys : '')
  53205. )
  53206. }
  53207. function markStatic$1 (node) {
  53208. node.static = isStatic(node);
  53209. if (node.type === 1) {
  53210. // do not make component slot content static. this avoids
  53211. // 1. components not able to mutate slot nodes
  53212. // 2. static slot content fails for hot-reloading
  53213. if (
  53214. !isPlatformReservedTag(node.tag) &&
  53215. node.tag !== 'slot' &&
  53216. node.attrsMap['inline-template'] == null
  53217. ) {
  53218. return
  53219. }
  53220. for (var i = 0, l = node.children.length; i < l; i++) {
  53221. var child = node.children[i];
  53222. markStatic$1(child);
  53223. if (!child.static) {
  53224. node.static = false;
  53225. }
  53226. }
  53227. if (node.ifConditions) {
  53228. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  53229. var block = node.ifConditions[i$1].block;
  53230. markStatic$1(block);
  53231. if (!block.static) {
  53232. node.static = false;
  53233. }
  53234. }
  53235. }
  53236. }
  53237. }
  53238. function markStaticRoots (node, isInFor) {
  53239. if (node.type === 1) {
  53240. if (node.static || node.once) {
  53241. node.staticInFor = isInFor;
  53242. }
  53243. // For a node to qualify as a static root, it should have children that
  53244. // are not just static text. Otherwise the cost of hoisting out will
  53245. // outweigh the benefits and it's better off to just always render it fresh.
  53246. if (node.static && node.children.length && !(
  53247. node.children.length === 1 &&
  53248. node.children[0].type === 3
  53249. )) {
  53250. node.staticRoot = true;
  53251. return
  53252. } else {
  53253. node.staticRoot = false;
  53254. }
  53255. if (node.children) {
  53256. for (var i = 0, l = node.children.length; i < l; i++) {
  53257. markStaticRoots(node.children[i], isInFor || !!node.for);
  53258. }
  53259. }
  53260. if (node.ifConditions) {
  53261. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  53262. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  53263. }
  53264. }
  53265. }
  53266. }
  53267. function isStatic (node) {
  53268. if (node.type === 2) { // expression
  53269. return false
  53270. }
  53271. if (node.type === 3) { // text
  53272. return true
  53273. }
  53274. return !!(node.pre || (
  53275. !node.hasBindings && // no dynamic bindings
  53276. !node.if && !node.for && // not v-if or v-for or v-else
  53277. !isBuiltInTag(node.tag) && // not a built-in
  53278. isPlatformReservedTag(node.tag) && // not a component
  53279. !isDirectChildOfTemplateFor(node) &&
  53280. Object.keys(node).every(isStaticKey)
  53281. ))
  53282. }
  53283. function isDirectChildOfTemplateFor (node) {
  53284. while (node.parent) {
  53285. node = node.parent;
  53286. if (node.tag !== 'template') {
  53287. return false
  53288. }
  53289. if (node.for) {
  53290. return true
  53291. }
  53292. }
  53293. return false
  53294. }
  53295. /* */
  53296. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  53297. var fnInvokeRE = /\([^)]*?\);*$/;
  53298. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  53299. // KeyboardEvent.keyCode aliases
  53300. var keyCodes = {
  53301. esc: 27,
  53302. tab: 9,
  53303. enter: 13,
  53304. space: 32,
  53305. up: 38,
  53306. left: 37,
  53307. right: 39,
  53308. down: 40,
  53309. 'delete': [8, 46]
  53310. };
  53311. // KeyboardEvent.key aliases
  53312. var keyNames = {
  53313. // #7880: IE11 and Edge use `Esc` for Escape key name.
  53314. esc: ['Esc', 'Escape'],
  53315. tab: 'Tab',
  53316. enter: 'Enter',
  53317. // #9112: IE11 uses `Spacebar` for Space key name.
  53318. space: [' ', 'Spacebar'],
  53319. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  53320. up: ['Up', 'ArrowUp'],
  53321. left: ['Left', 'ArrowLeft'],
  53322. right: ['Right', 'ArrowRight'],
  53323. down: ['Down', 'ArrowDown'],
  53324. // #9112: IE11 uses `Del` for Delete key name.
  53325. 'delete': ['Backspace', 'Delete', 'Del']
  53326. };
  53327. // #4868: modifiers that prevent the execution of the listener
  53328. // need to explicitly return null so that we can determine whether to remove
  53329. // the listener for .once
  53330. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  53331. var modifierCode = {
  53332. stop: '$event.stopPropagation();',
  53333. prevent: '$event.preventDefault();',
  53334. self: genGuard("$event.target !== $event.currentTarget"),
  53335. ctrl: genGuard("!$event.ctrlKey"),
  53336. shift: genGuard("!$event.shiftKey"),
  53337. alt: genGuard("!$event.altKey"),
  53338. meta: genGuard("!$event.metaKey"),
  53339. left: genGuard("'button' in $event && $event.button !== 0"),
  53340. middle: genGuard("'button' in $event && $event.button !== 1"),
  53341. right: genGuard("'button' in $event && $event.button !== 2")
  53342. };
  53343. function genHandlers (
  53344. events,
  53345. isNative
  53346. ) {
  53347. var prefix = isNative ? 'nativeOn:' : 'on:';
  53348. var staticHandlers = "";
  53349. var dynamicHandlers = "";
  53350. for (var name in events) {
  53351. var handlerCode = genHandler(events[name]);
  53352. if (events[name] && events[name].dynamic) {
  53353. dynamicHandlers += name + "," + handlerCode + ",";
  53354. } else {
  53355. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  53356. }
  53357. }
  53358. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  53359. if (dynamicHandlers) {
  53360. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  53361. } else {
  53362. return prefix + staticHandlers
  53363. }
  53364. }
  53365. function genHandler (handler) {
  53366. if (!handler) {
  53367. return 'function(){}'
  53368. }
  53369. if (Array.isArray(handler)) {
  53370. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  53371. }
  53372. var isMethodPath = simplePathRE.test(handler.value);
  53373. var isFunctionExpression = fnExpRE.test(handler.value);
  53374. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  53375. if (!handler.modifiers) {
  53376. if (isMethodPath || isFunctionExpression) {
  53377. return handler.value
  53378. }
  53379. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  53380. } else {
  53381. var code = '';
  53382. var genModifierCode = '';
  53383. var keys = [];
  53384. for (var key in handler.modifiers) {
  53385. if (modifierCode[key]) {
  53386. genModifierCode += modifierCode[key];
  53387. // left/right
  53388. if (keyCodes[key]) {
  53389. keys.push(key);
  53390. }
  53391. } else if (key === 'exact') {
  53392. var modifiers = (handler.modifiers);
  53393. genModifierCode += genGuard(
  53394. ['ctrl', 'shift', 'alt', 'meta']
  53395. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  53396. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  53397. .join('||')
  53398. );
  53399. } else {
  53400. keys.push(key);
  53401. }
  53402. }
  53403. if (keys.length) {
  53404. code += genKeyFilter(keys);
  53405. }
  53406. // Make sure modifiers like prevent and stop get executed after key filtering
  53407. if (genModifierCode) {
  53408. code += genModifierCode;
  53409. }
  53410. var handlerCode = isMethodPath
  53411. ? ("return " + (handler.value) + "($event)")
  53412. : isFunctionExpression
  53413. ? ("return (" + (handler.value) + ")($event)")
  53414. : isFunctionInvocation
  53415. ? ("return " + (handler.value))
  53416. : handler.value;
  53417. return ("function($event){" + code + handlerCode + "}")
  53418. }
  53419. }
  53420. function genKeyFilter (keys) {
  53421. return (
  53422. // make sure the key filters only apply to KeyboardEvents
  53423. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  53424. // key events that do not have keyCode property...
  53425. "if(!$event.type.indexOf('key')&&" +
  53426. (keys.map(genFilterCode).join('&&')) + ")return null;"
  53427. )
  53428. }
  53429. function genFilterCode (key) {
  53430. var keyVal = parseInt(key, 10);
  53431. if (keyVal) {
  53432. return ("$event.keyCode!==" + keyVal)
  53433. }
  53434. var keyCode = keyCodes[key];
  53435. var keyName = keyNames[key];
  53436. return (
  53437. "_k($event.keyCode," +
  53438. (JSON.stringify(key)) + "," +
  53439. (JSON.stringify(keyCode)) + "," +
  53440. "$event.key," +
  53441. "" + (JSON.stringify(keyName)) +
  53442. ")"
  53443. )
  53444. }
  53445. /* */
  53446. function on (el, dir) {
  53447. if (dir.modifiers) {
  53448. warn("v-on without argument does not support modifiers.");
  53449. }
  53450. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  53451. }
  53452. /* */
  53453. function bind$1 (el, dir) {
  53454. el.wrapData = function (code) {
  53455. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  53456. };
  53457. }
  53458. /* */
  53459. var baseDirectives = {
  53460. on: on,
  53461. bind: bind$1,
  53462. cloak: noop
  53463. };
  53464. /* */
  53465. var CodegenState = function CodegenState (options) {
  53466. this.options = options;
  53467. this.warn = options.warn || baseWarn;
  53468. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  53469. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  53470. this.directives = extend(extend({}, baseDirectives), options.directives);
  53471. var isReservedTag = options.isReservedTag || no;
  53472. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  53473. this.onceId = 0;
  53474. this.staticRenderFns = [];
  53475. this.pre = false;
  53476. };
  53477. function generate (
  53478. ast,
  53479. options
  53480. ) {
  53481. var state = new CodegenState(options);
  53482. var code = ast ? genElement(ast, state) : '_c("div")';
  53483. return {
  53484. render: ("with(this){return " + code + "}"),
  53485. staticRenderFns: state.staticRenderFns
  53486. }
  53487. }
  53488. function genElement (el, state) {
  53489. if (el.parent) {
  53490. el.pre = el.pre || el.parent.pre;
  53491. }
  53492. if (el.staticRoot && !el.staticProcessed) {
  53493. return genStatic(el, state)
  53494. } else if (el.once && !el.onceProcessed) {
  53495. return genOnce(el, state)
  53496. } else if (el.for && !el.forProcessed) {
  53497. return genFor(el, state)
  53498. } else if (el.if && !el.ifProcessed) {
  53499. return genIf(el, state)
  53500. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  53501. return genChildren(el, state) || 'void 0'
  53502. } else if (el.tag === 'slot') {
  53503. return genSlot(el, state)
  53504. } else {
  53505. // component or element
  53506. var code;
  53507. if (el.component) {
  53508. code = genComponent(el.component, el, state);
  53509. } else {
  53510. var data;
  53511. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  53512. data = genData$2(el, state);
  53513. }
  53514. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53515. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  53516. }
  53517. // module transforms
  53518. for (var i = 0; i < state.transforms.length; i++) {
  53519. code = state.transforms[i](el, code);
  53520. }
  53521. return code
  53522. }
  53523. }
  53524. // hoist static sub-trees out
  53525. function genStatic (el, state) {
  53526. el.staticProcessed = true;
  53527. // Some elements (templates) need to behave differently inside of a v-pre
  53528. // node. All pre nodes are static roots, so we can use this as a location to
  53529. // wrap a state change and reset it upon exiting the pre node.
  53530. var originalPreState = state.pre;
  53531. if (el.pre) {
  53532. state.pre = el.pre;
  53533. }
  53534. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  53535. state.pre = originalPreState;
  53536. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  53537. }
  53538. // v-once
  53539. function genOnce (el, state) {
  53540. el.onceProcessed = true;
  53541. if (el.if && !el.ifProcessed) {
  53542. return genIf(el, state)
  53543. } else if (el.staticInFor) {
  53544. var key = '';
  53545. var parent = el.parent;
  53546. while (parent) {
  53547. if (parent.for) {
  53548. key = parent.key;
  53549. break
  53550. }
  53551. parent = parent.parent;
  53552. }
  53553. if (!key) {
  53554. state.warn(
  53555. "v-once can only be used inside v-for that is keyed. ",
  53556. el.rawAttrsMap['v-once']
  53557. );
  53558. return genElement(el, state)
  53559. }
  53560. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  53561. } else {
  53562. return genStatic(el, state)
  53563. }
  53564. }
  53565. function genIf (
  53566. el,
  53567. state,
  53568. altGen,
  53569. altEmpty
  53570. ) {
  53571. el.ifProcessed = true; // avoid recursion
  53572. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  53573. }
  53574. function genIfConditions (
  53575. conditions,
  53576. state,
  53577. altGen,
  53578. altEmpty
  53579. ) {
  53580. if (!conditions.length) {
  53581. return altEmpty || '_e()'
  53582. }
  53583. var condition = conditions.shift();
  53584. if (condition.exp) {
  53585. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  53586. } else {
  53587. return ("" + (genTernaryExp(condition.block)))
  53588. }
  53589. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  53590. function genTernaryExp (el) {
  53591. return altGen
  53592. ? altGen(el, state)
  53593. : el.once
  53594. ? genOnce(el, state)
  53595. : genElement(el, state)
  53596. }
  53597. }
  53598. function genFor (
  53599. el,
  53600. state,
  53601. altGen,
  53602. altHelper
  53603. ) {
  53604. var exp = el.for;
  53605. var alias = el.alias;
  53606. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  53607. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  53608. if (state.maybeComponent(el) &&
  53609. el.tag !== 'slot' &&
  53610. el.tag !== 'template' &&
  53611. !el.key
  53612. ) {
  53613. state.warn(
  53614. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  53615. "v-for should have explicit keys. " +
  53616. "See https://vuejs.org/guide/list.html#key for more info.",
  53617. el.rawAttrsMap['v-for'],
  53618. true /* tip */
  53619. );
  53620. }
  53621. el.forProcessed = true; // avoid recursion
  53622. return (altHelper || '_l') + "((" + exp + ")," +
  53623. "function(" + alias + iterator1 + iterator2 + "){" +
  53624. "return " + ((altGen || genElement)(el, state)) +
  53625. '})'
  53626. }
  53627. function genData$2 (el, state) {
  53628. var data = '{';
  53629. // directives first.
  53630. // directives may mutate the el's other properties before they are generated.
  53631. var dirs = genDirectives(el, state);
  53632. if (dirs) { data += dirs + ','; }
  53633. // key
  53634. if (el.key) {
  53635. data += "key:" + (el.key) + ",";
  53636. }
  53637. // ref
  53638. if (el.ref) {
  53639. data += "ref:" + (el.ref) + ",";
  53640. }
  53641. if (el.refInFor) {
  53642. data += "refInFor:true,";
  53643. }
  53644. // pre
  53645. if (el.pre) {
  53646. data += "pre:true,";
  53647. }
  53648. // record original tag name for components using "is" attribute
  53649. if (el.component) {
  53650. data += "tag:\"" + (el.tag) + "\",";
  53651. }
  53652. // module data generation functions
  53653. for (var i = 0; i < state.dataGenFns.length; i++) {
  53654. data += state.dataGenFns[i](el);
  53655. }
  53656. // attributes
  53657. if (el.attrs) {
  53658. data += "attrs:" + (genProps(el.attrs)) + ",";
  53659. }
  53660. // DOM props
  53661. if (el.props) {
  53662. data += "domProps:" + (genProps(el.props)) + ",";
  53663. }
  53664. // event handlers
  53665. if (el.events) {
  53666. data += (genHandlers(el.events, false)) + ",";
  53667. }
  53668. if (el.nativeEvents) {
  53669. data += (genHandlers(el.nativeEvents, true)) + ",";
  53670. }
  53671. // slot target
  53672. // only for non-scoped slots
  53673. if (el.slotTarget && !el.slotScope) {
  53674. data += "slot:" + (el.slotTarget) + ",";
  53675. }
  53676. // scoped slots
  53677. if (el.scopedSlots) {
  53678. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  53679. }
  53680. // component v-model
  53681. if (el.model) {
  53682. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  53683. }
  53684. // inline-template
  53685. if (el.inlineTemplate) {
  53686. var inlineTemplate = genInlineTemplate(el, state);
  53687. if (inlineTemplate) {
  53688. data += inlineTemplate + ",";
  53689. }
  53690. }
  53691. data = data.replace(/,$/, '') + '}';
  53692. // v-bind dynamic argument wrap
  53693. // v-bind with dynamic arguments must be applied using the same v-bind object
  53694. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  53695. if (el.dynamicAttrs) {
  53696. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  53697. }
  53698. // v-bind data wrap
  53699. if (el.wrapData) {
  53700. data = el.wrapData(data);
  53701. }
  53702. // v-on data wrap
  53703. if (el.wrapListeners) {
  53704. data = el.wrapListeners(data);
  53705. }
  53706. return data
  53707. }
  53708. function genDirectives (el, state) {
  53709. var dirs = el.directives;
  53710. if (!dirs) { return }
  53711. var res = 'directives:[';
  53712. var hasRuntime = false;
  53713. var i, l, dir, needRuntime;
  53714. for (i = 0, l = dirs.length; i < l; i++) {
  53715. dir = dirs[i];
  53716. needRuntime = true;
  53717. var gen = state.directives[dir.name];
  53718. if (gen) {
  53719. // compile-time directive that manipulates AST.
  53720. // returns true if it also needs a runtime counterpart.
  53721. needRuntime = !!gen(el, dir, state.warn);
  53722. }
  53723. if (needRuntime) {
  53724. hasRuntime = true;
  53725. 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))) : '') + "},";
  53726. }
  53727. }
  53728. if (hasRuntime) {
  53729. return res.slice(0, -1) + ']'
  53730. }
  53731. }
  53732. function genInlineTemplate (el, state) {
  53733. var ast = el.children[0];
  53734. if (el.children.length !== 1 || ast.type !== 1) {
  53735. state.warn(
  53736. 'Inline-template components must have exactly one child element.',
  53737. { start: el.start }
  53738. );
  53739. }
  53740. if (ast && ast.type === 1) {
  53741. var inlineRenderFns = generate(ast, state.options);
  53742. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  53743. }
  53744. }
  53745. function genScopedSlots (
  53746. el,
  53747. slots,
  53748. state
  53749. ) {
  53750. // by default scoped slots are considered "stable", this allows child
  53751. // components with only scoped slots to skip forced updates from parent.
  53752. // but in some cases we have to bail-out of this optimization
  53753. // for example if the slot contains dynamic names, has v-if or v-for on them...
  53754. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  53755. var slot = slots[key];
  53756. return (
  53757. slot.slotTargetDynamic ||
  53758. slot.if ||
  53759. slot.for ||
  53760. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  53761. )
  53762. });
  53763. // #9534: if a component with scoped slots is inside a conditional branch,
  53764. // it's possible for the same component to be reused but with different
  53765. // compiled slot content. To avoid that, we generate a unique key based on
  53766. // the generated code of all the slot contents.
  53767. var needsKey = !!el.if;
  53768. // OR when it is inside another scoped slot or v-for (the reactivity may be
  53769. // disconnected due to the intermediate scope variable)
  53770. // #9438, #9506
  53771. // TODO: this can be further optimized by properly analyzing in-scope bindings
  53772. // and skip force updating ones that do not actually use scope variables.
  53773. if (!needsForceUpdate) {
  53774. var parent = el.parent;
  53775. while (parent) {
  53776. if (
  53777. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  53778. parent.for
  53779. ) {
  53780. needsForceUpdate = true;
  53781. break
  53782. }
  53783. if (parent.if) {
  53784. needsKey = true;
  53785. }
  53786. parent = parent.parent;
  53787. }
  53788. }
  53789. var generatedSlots = Object.keys(slots)
  53790. .map(function (key) { return genScopedSlot(slots[key], state); })
  53791. .join(',');
  53792. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  53793. }
  53794. function hash(str) {
  53795. var hash = 5381;
  53796. var i = str.length;
  53797. while(i) {
  53798. hash = (hash * 33) ^ str.charCodeAt(--i);
  53799. }
  53800. return hash >>> 0
  53801. }
  53802. function containsSlotChild (el) {
  53803. if (el.type === 1) {
  53804. if (el.tag === 'slot') {
  53805. return true
  53806. }
  53807. return el.children.some(containsSlotChild)
  53808. }
  53809. return false
  53810. }
  53811. function genScopedSlot (
  53812. el,
  53813. state
  53814. ) {
  53815. var isLegacySyntax = el.attrsMap['slot-scope'];
  53816. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  53817. return genIf(el, state, genScopedSlot, "null")
  53818. }
  53819. if (el.for && !el.forProcessed) {
  53820. return genFor(el, state, genScopedSlot)
  53821. }
  53822. var slotScope = el.slotScope === emptySlotScopeToken
  53823. ? ""
  53824. : String(el.slotScope);
  53825. var fn = "function(" + slotScope + "){" +
  53826. "return " + (el.tag === 'template'
  53827. ? el.if && isLegacySyntax
  53828. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  53829. : genChildren(el, state) || 'undefined'
  53830. : genElement(el, state)) + "}";
  53831. // reverse proxy v-slot without scope on this.$slots
  53832. var reverseProxy = slotScope ? "" : ",proxy:true";
  53833. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  53834. }
  53835. function genChildren (
  53836. el,
  53837. state,
  53838. checkSkip,
  53839. altGenElement,
  53840. altGenNode
  53841. ) {
  53842. var children = el.children;
  53843. if (children.length) {
  53844. var el$1 = children[0];
  53845. // optimize single v-for
  53846. if (children.length === 1 &&
  53847. el$1.for &&
  53848. el$1.tag !== 'template' &&
  53849. el$1.tag !== 'slot'
  53850. ) {
  53851. var normalizationType = checkSkip
  53852. ? state.maybeComponent(el$1) ? ",1" : ",0"
  53853. : "";
  53854. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  53855. }
  53856. var normalizationType$1 = checkSkip
  53857. ? getNormalizationType(children, state.maybeComponent)
  53858. : 0;
  53859. var gen = altGenNode || genNode;
  53860. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  53861. }
  53862. }
  53863. // determine the normalization needed for the children array.
  53864. // 0: no normalization needed
  53865. // 1: simple normalization needed (possible 1-level deep nested array)
  53866. // 2: full normalization needed
  53867. function getNormalizationType (
  53868. children,
  53869. maybeComponent
  53870. ) {
  53871. var res = 0;
  53872. for (var i = 0; i < children.length; i++) {
  53873. var el = children[i];
  53874. if (el.type !== 1) {
  53875. continue
  53876. }
  53877. if (needsNormalization(el) ||
  53878. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  53879. res = 2;
  53880. break
  53881. }
  53882. if (maybeComponent(el) ||
  53883. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  53884. res = 1;
  53885. }
  53886. }
  53887. return res
  53888. }
  53889. function needsNormalization (el) {
  53890. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  53891. }
  53892. function genNode (node, state) {
  53893. if (node.type === 1) {
  53894. return genElement(node, state)
  53895. } else if (node.type === 3 && node.isComment) {
  53896. return genComment(node)
  53897. } else {
  53898. return genText(node)
  53899. }
  53900. }
  53901. function genText (text) {
  53902. return ("_v(" + (text.type === 2
  53903. ? text.expression // no need for () because already wrapped in _s()
  53904. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  53905. }
  53906. function genComment (comment) {
  53907. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  53908. }
  53909. function genSlot (el, state) {
  53910. var slotName = el.slotName || '"default"';
  53911. var children = genChildren(el, state);
  53912. var res = "_t(" + slotName + (children ? ("," + children) : '');
  53913. var attrs = el.attrs || el.dynamicAttrs
  53914. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  53915. // slot props are camelized
  53916. name: camelize(attr.name),
  53917. value: attr.value,
  53918. dynamic: attr.dynamic
  53919. }); }))
  53920. : null;
  53921. var bind$$1 = el.attrsMap['v-bind'];
  53922. if ((attrs || bind$$1) && !children) {
  53923. res += ",null";
  53924. }
  53925. if (attrs) {
  53926. res += "," + attrs;
  53927. }
  53928. if (bind$$1) {
  53929. res += (attrs ? '' : ',null') + "," + bind$$1;
  53930. }
  53931. return res + ')'
  53932. }
  53933. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  53934. function genComponent (
  53935. componentName,
  53936. el,
  53937. state
  53938. ) {
  53939. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53940. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  53941. }
  53942. function genProps (props) {
  53943. var staticProps = "";
  53944. var dynamicProps = "";
  53945. for (var i = 0; i < props.length; i++) {
  53946. var prop = props[i];
  53947. var value = transformSpecialNewlines(prop.value);
  53948. if (prop.dynamic) {
  53949. dynamicProps += (prop.name) + "," + value + ",";
  53950. } else {
  53951. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  53952. }
  53953. }
  53954. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  53955. if (dynamicProps) {
  53956. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  53957. } else {
  53958. return staticProps
  53959. }
  53960. }
  53961. // #3895, #4268
  53962. function transformSpecialNewlines (text) {
  53963. return text
  53964. .replace(/\u2028/g, '\\u2028')
  53965. .replace(/\u2029/g, '\\u2029')
  53966. }
  53967. /* */
  53968. // these keywords should not appear inside expressions, but operators like
  53969. // typeof, instanceof and in are allowed
  53970. var prohibitedKeywordRE = new RegExp('\\b' + (
  53971. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  53972. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  53973. 'extends,finally,continue,debugger,function,arguments'
  53974. ).split(',').join('\\b|\\b') + '\\b');
  53975. // these unary operators should not be used as property/method names
  53976. var unaryOperatorsRE = new RegExp('\\b' + (
  53977. 'delete,typeof,void'
  53978. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  53979. // strip strings in expressions
  53980. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  53981. // detect problematic expressions in a template
  53982. function detectErrors (ast, warn) {
  53983. if (ast) {
  53984. checkNode(ast, warn);
  53985. }
  53986. }
  53987. function checkNode (node, warn) {
  53988. if (node.type === 1) {
  53989. for (var name in node.attrsMap) {
  53990. if (dirRE.test(name)) {
  53991. var value = node.attrsMap[name];
  53992. if (value) {
  53993. var range = node.rawAttrsMap[name];
  53994. if (name === 'v-for') {
  53995. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  53996. } else if (name === 'v-slot' || name[0] === '#') {
  53997. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  53998. } else if (onRE.test(name)) {
  53999. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  54000. } else {
  54001. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  54002. }
  54003. }
  54004. }
  54005. }
  54006. if (node.children) {
  54007. for (var i = 0; i < node.children.length; i++) {
  54008. checkNode(node.children[i], warn);
  54009. }
  54010. }
  54011. } else if (node.type === 2) {
  54012. checkExpression(node.expression, node.text, warn, node);
  54013. }
  54014. }
  54015. function checkEvent (exp, text, warn, range) {
  54016. var stripped = exp.replace(stripStringRE, '');
  54017. var keywordMatch = stripped.match(unaryOperatorsRE);
  54018. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  54019. warn(
  54020. "avoid using JavaScript unary operator as property name: " +
  54021. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  54022. range
  54023. );
  54024. }
  54025. checkExpression(exp, text, warn, range);
  54026. }
  54027. function checkFor (node, text, warn, range) {
  54028. checkExpression(node.for || '', text, warn, range);
  54029. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  54030. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  54031. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  54032. }
  54033. function checkIdentifier (
  54034. ident,
  54035. type,
  54036. text,
  54037. warn,
  54038. range
  54039. ) {
  54040. if (typeof ident === 'string') {
  54041. try {
  54042. new Function(("var " + ident + "=_"));
  54043. } catch (e) {
  54044. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  54045. }
  54046. }
  54047. }
  54048. function checkExpression (exp, text, warn, range) {
  54049. try {
  54050. new Function(("return " + exp));
  54051. } catch (e) {
  54052. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  54053. if (keywordMatch) {
  54054. warn(
  54055. "avoid using JavaScript keyword as property name: " +
  54056. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  54057. range
  54058. );
  54059. } else {
  54060. warn(
  54061. "invalid expression: " + (e.message) + " in\n\n" +
  54062. " " + exp + "\n\n" +
  54063. " Raw expression: " + (text.trim()) + "\n",
  54064. range
  54065. );
  54066. }
  54067. }
  54068. }
  54069. function checkFunctionParameterExpression (exp, text, warn, range) {
  54070. try {
  54071. new Function(exp, '');
  54072. } catch (e) {
  54073. warn(
  54074. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  54075. " " + exp + "\n\n" +
  54076. " Raw expression: " + (text.trim()) + "\n",
  54077. range
  54078. );
  54079. }
  54080. }
  54081. /* */
  54082. var range = 2;
  54083. function generateCodeFrame (
  54084. source,
  54085. start,
  54086. end
  54087. ) {
  54088. if ( start === void 0 ) start = 0;
  54089. if ( end === void 0 ) end = source.length;
  54090. var lines = source.split(/\r?\n/);
  54091. var count = 0;
  54092. var res = [];
  54093. for (var i = 0; i < lines.length; i++) {
  54094. count += lines[i].length + 1;
  54095. if (count >= start) {
  54096. for (var j = i - range; j <= i + range || end > count; j++) {
  54097. if (j < 0 || j >= lines.length) { continue }
  54098. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  54099. var lineLength = lines[j].length;
  54100. if (j === i) {
  54101. // push underline
  54102. var pad = start - (count - lineLength) + 1;
  54103. var length = end > count ? lineLength - pad : end - start;
  54104. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  54105. } else if (j > i) {
  54106. if (end > count) {
  54107. var length$1 = Math.min(end - count, lineLength);
  54108. res.push(" | " + repeat$1("^", length$1));
  54109. }
  54110. count += lineLength + 1;
  54111. }
  54112. }
  54113. break
  54114. }
  54115. }
  54116. return res.join('\n')
  54117. }
  54118. function repeat$1 (str, n) {
  54119. var result = '';
  54120. if (n > 0) {
  54121. while (true) { // eslint-disable-line
  54122. if (n & 1) { result += str; }
  54123. n >>>= 1;
  54124. if (n <= 0) { break }
  54125. str += str;
  54126. }
  54127. }
  54128. return result
  54129. }
  54130. /* */
  54131. function createFunction (code, errors) {
  54132. try {
  54133. return new Function(code)
  54134. } catch (err) {
  54135. errors.push({ err: err, code: code });
  54136. return noop
  54137. }
  54138. }
  54139. function createCompileToFunctionFn (compile) {
  54140. var cache = Object.create(null);
  54141. return function compileToFunctions (
  54142. template,
  54143. options,
  54144. vm
  54145. ) {
  54146. options = extend({}, options);
  54147. var warn$$1 = options.warn || warn;
  54148. delete options.warn;
  54149. /* istanbul ignore if */
  54150. {
  54151. // detect possible CSP restriction
  54152. try {
  54153. new Function('return 1');
  54154. } catch (e) {
  54155. if (e.toString().match(/unsafe-eval|CSP/)) {
  54156. warn$$1(
  54157. 'It seems you are using the standalone build of Vue.js in an ' +
  54158. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  54159. 'The template compiler cannot work in this environment. Consider ' +
  54160. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  54161. 'templates into render functions.'
  54162. );
  54163. }
  54164. }
  54165. }
  54166. // check cache
  54167. var key = options.delimiters
  54168. ? String(options.delimiters) + template
  54169. : template;
  54170. if (cache[key]) {
  54171. return cache[key]
  54172. }
  54173. // compile
  54174. var compiled = compile(template, options);
  54175. // check compilation errors/tips
  54176. {
  54177. if (compiled.errors && compiled.errors.length) {
  54178. if (options.outputSourceRange) {
  54179. compiled.errors.forEach(function (e) {
  54180. warn$$1(
  54181. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  54182. generateCodeFrame(template, e.start, e.end),
  54183. vm
  54184. );
  54185. });
  54186. } else {
  54187. warn$$1(
  54188. "Error compiling template:\n\n" + template + "\n\n" +
  54189. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  54190. vm
  54191. );
  54192. }
  54193. }
  54194. if (compiled.tips && compiled.tips.length) {
  54195. if (options.outputSourceRange) {
  54196. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  54197. } else {
  54198. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  54199. }
  54200. }
  54201. }
  54202. // turn code into functions
  54203. var res = {};
  54204. var fnGenErrors = [];
  54205. res.render = createFunction(compiled.render, fnGenErrors);
  54206. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  54207. return createFunction(code, fnGenErrors)
  54208. });
  54209. // check function generation errors.
  54210. // this should only happen if there is a bug in the compiler itself.
  54211. // mostly for codegen development use
  54212. /* istanbul ignore if */
  54213. {
  54214. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  54215. warn$$1(
  54216. "Failed to generate render function:\n\n" +
  54217. fnGenErrors.map(function (ref) {
  54218. var err = ref.err;
  54219. var code = ref.code;
  54220. return ((err.toString()) + " in\n\n" + code + "\n");
  54221. }).join('\n'),
  54222. vm
  54223. );
  54224. }
  54225. }
  54226. return (cache[key] = res)
  54227. }
  54228. }
  54229. /* */
  54230. function createCompilerCreator (baseCompile) {
  54231. return function createCompiler (baseOptions) {
  54232. function compile (
  54233. template,
  54234. options
  54235. ) {
  54236. var finalOptions = Object.create(baseOptions);
  54237. var errors = [];
  54238. var tips = [];
  54239. var warn = function (msg, range, tip) {
  54240. (tip ? tips : errors).push(msg);
  54241. };
  54242. if (options) {
  54243. if (options.outputSourceRange) {
  54244. // $flow-disable-line
  54245. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  54246. warn = function (msg, range, tip) {
  54247. var data = { msg: msg };
  54248. if (range) {
  54249. if (range.start != null) {
  54250. data.start = range.start + leadingSpaceLength;
  54251. }
  54252. if (range.end != null) {
  54253. data.end = range.end + leadingSpaceLength;
  54254. }
  54255. }
  54256. (tip ? tips : errors).push(data);
  54257. };
  54258. }
  54259. // merge custom modules
  54260. if (options.modules) {
  54261. finalOptions.modules =
  54262. (baseOptions.modules || []).concat(options.modules);
  54263. }
  54264. // merge custom directives
  54265. if (options.directives) {
  54266. finalOptions.directives = extend(
  54267. Object.create(baseOptions.directives || null),
  54268. options.directives
  54269. );
  54270. }
  54271. // copy other options
  54272. for (var key in options) {
  54273. if (key !== 'modules' && key !== 'directives') {
  54274. finalOptions[key] = options[key];
  54275. }
  54276. }
  54277. }
  54278. finalOptions.warn = warn;
  54279. var compiled = baseCompile(template.trim(), finalOptions);
  54280. {
  54281. detectErrors(compiled.ast, warn);
  54282. }
  54283. compiled.errors = errors;
  54284. compiled.tips = tips;
  54285. return compiled
  54286. }
  54287. return {
  54288. compile: compile,
  54289. compileToFunctions: createCompileToFunctionFn(compile)
  54290. }
  54291. }
  54292. }
  54293. /* */
  54294. // `createCompilerCreator` allows creating compilers that use alternative
  54295. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  54296. // Here we just export a default compiler using the default parts.
  54297. var createCompiler = createCompilerCreator(function baseCompile (
  54298. template,
  54299. options
  54300. ) {
  54301. var ast = parse(template.trim(), options);
  54302. if (options.optimize !== false) {
  54303. optimize(ast, options);
  54304. }
  54305. var code = generate(ast, options);
  54306. return {
  54307. ast: ast,
  54308. render: code.render,
  54309. staticRenderFns: code.staticRenderFns
  54310. }
  54311. });
  54312. /* */
  54313. var ref$1 = createCompiler(baseOptions);
  54314. var compile = ref$1.compile;
  54315. var compileToFunctions = ref$1.compileToFunctions;
  54316. /* */
  54317. // check whether current browser encodes a char inside attribute values
  54318. var div;
  54319. function getShouldDecode (href) {
  54320. div = div || document.createElement('div');
  54321. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  54322. return div.innerHTML.indexOf('&#10;') > 0
  54323. }
  54324. // #3663: IE encodes newlines inside attribute values while other browsers don't
  54325. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  54326. // #6828: chrome encodes content in a[href]
  54327. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  54328. /* */
  54329. var idToTemplate = cached(function (id) {
  54330. var el = query(id);
  54331. return el && el.innerHTML
  54332. });
  54333. var mount = Vue.prototype.$mount;
  54334. Vue.prototype.$mount = function (
  54335. el,
  54336. hydrating
  54337. ) {
  54338. el = el && query(el);
  54339. /* istanbul ignore if */
  54340. if (el === document.body || el === document.documentElement) {
  54341. warn(
  54342. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  54343. );
  54344. return this
  54345. }
  54346. var options = this.$options;
  54347. // resolve template/el and convert to render function
  54348. if (!options.render) {
  54349. var template = options.template;
  54350. if (template) {
  54351. if (typeof template === 'string') {
  54352. if (template.charAt(0) === '#') {
  54353. template = idToTemplate(template);
  54354. /* istanbul ignore if */
  54355. if (!template) {
  54356. warn(
  54357. ("Template element not found or is empty: " + (options.template)),
  54358. this
  54359. );
  54360. }
  54361. }
  54362. } else if (template.nodeType) {
  54363. template = template.innerHTML;
  54364. } else {
  54365. {
  54366. warn('invalid template option:' + template, this);
  54367. }
  54368. return this
  54369. }
  54370. } else if (el) {
  54371. template = getOuterHTML(el);
  54372. }
  54373. if (template) {
  54374. /* istanbul ignore if */
  54375. if (config.performance && mark) {
  54376. mark('compile');
  54377. }
  54378. var ref = compileToFunctions(template, {
  54379. outputSourceRange: "development" !== 'production',
  54380. shouldDecodeNewlines: shouldDecodeNewlines,
  54381. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  54382. delimiters: options.delimiters,
  54383. comments: options.comments
  54384. }, this);
  54385. var render = ref.render;
  54386. var staticRenderFns = ref.staticRenderFns;
  54387. options.render = render;
  54388. options.staticRenderFns = staticRenderFns;
  54389. /* istanbul ignore if */
  54390. if (config.performance && mark) {
  54391. mark('compile end');
  54392. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  54393. }
  54394. }
  54395. }
  54396. return mount.call(this, el, hydrating)
  54397. };
  54398. /**
  54399. * Get outerHTML of elements, taking care
  54400. * of SVG elements in IE as well.
  54401. */
  54402. function getOuterHTML (el) {
  54403. if (el.outerHTML) {
  54404. return el.outerHTML
  54405. } else {
  54406. var container = document.createElement('div');
  54407. container.appendChild(el.cloneNode(true));
  54408. return container.innerHTML
  54409. }
  54410. }
  54411. Vue.compile = compileToFunctions;
  54412. module.exports = Vue;
  54413. /* 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))
  54414. /***/ }),
  54415. /***/ "./node_modules/vue/dist/vue.common.js":
  54416. /*!*********************************************!*\
  54417. !*** ./node_modules/vue/dist/vue.common.js ***!
  54418. \*********************************************/
  54419. /*! no static exports found */
  54420. /***/ (function(module, exports, __webpack_require__) {
  54421. if (false) {} else {
  54422. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  54423. }
  54424. /***/ }),
  54425. /***/ "./node_modules/webpack/buildin/global.js":
  54426. /*!***********************************!*\
  54427. !*** (webpack)/buildin/global.js ***!
  54428. \***********************************/
  54429. /*! no static exports found */
  54430. /***/ (function(module, exports) {
  54431. var g;
  54432. // This works in non-strict mode
  54433. g = (function() {
  54434. return this;
  54435. })();
  54436. try {
  54437. // This works if eval is allowed (see CSP)
  54438. g = g || new Function("return this")();
  54439. } catch (e) {
  54440. // This works if the window reference is available
  54441. if (typeof window === "object") g = window;
  54442. }
  54443. // g can still be undefined, but nothing to do about it...
  54444. // We return undefined, instead of nothing here, so it's
  54445. // easier to handle this case. if(!global) { ...}
  54446. module.exports = g;
  54447. /***/ }),
  54448. /***/ "./node_modules/webpack/buildin/module.js":
  54449. /*!***********************************!*\
  54450. !*** (webpack)/buildin/module.js ***!
  54451. \***********************************/
  54452. /*! no static exports found */
  54453. /***/ (function(module, exports) {
  54454. module.exports = function(module) {
  54455. if (!module.webpackPolyfill) {
  54456. module.deprecate = function() {};
  54457. module.paths = [];
  54458. // module.parent = undefined by default
  54459. if (!module.children) module.children = [];
  54460. Object.defineProperty(module, "loaded", {
  54461. enumerable: true,
  54462. get: function() {
  54463. return module.l;
  54464. }
  54465. });
  54466. Object.defineProperty(module, "id", {
  54467. enumerable: true,
  54468. get: function() {
  54469. return module.i;
  54470. }
  54471. });
  54472. module.webpackPolyfill = 1;
  54473. }
  54474. return module;
  54475. };
  54476. /***/ }),
  54477. /***/ "./resources/js/app.js":
  54478. /*!*****************************!*\
  54479. !*** ./resources/js/app.js ***!
  54480. \*****************************/
  54481. /*! no static exports found */
  54482. /***/ (function(module, exports, __webpack_require__) {
  54483. /**
  54484. * First we will load all of this project's JavaScript dependencies which
  54485. * includes Vue and other libraries. It is a great starting point when
  54486. * building robust, powerful web applications using Vue and Laravel.
  54487. */
  54488. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  54489. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  54490. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  54491. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  54492. /**
  54493. * The following block of code may be used to automatically register your
  54494. * Vue components. It will recursively scan this directory for the Vue
  54495. * components and automatically register them with their "basename".
  54496. *
  54497. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  54498. */
  54499. // const files = require.context('./', true, /\.vue$/i)
  54500. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  54501. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  54502. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  54503. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  54504. Vue.component('credential', __webpack_require__(/*! ./components/credential.vue */ "./resources/js/components/credential.vue")["default"]);
  54505. Vue.component('notes', __webpack_require__(/*! ./components/notes.vue */ "./resources/js/components/notes.vue")["default"]);
  54506. Vue.component('modal', __webpack_require__(/*! ./components/modal.vue */ "./resources/js/components/modal.vue")["default"]);
  54507. /**
  54508. * Next, we will create a fresh Vue application instance and attach it to
  54509. * the page. Then, you may begin adding components to this application
  54510. * or customize the JavaScript scaffolding to fit your unique needs.
  54511. */
  54512. var app = new Vue({
  54513. el: '#app'
  54514. });
  54515. $(function () {
  54516. $('[data-toggle="tooltip"]').tooltip();
  54517. });
  54518. var clipboard = new Clipboard('.btn-clip');
  54519. clipboard.on('success', function (e) {
  54520. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  54521. position: "right",
  54522. className: 'success'
  54523. });
  54524. e.clearSelection();
  54525. });
  54526. /***/ }),
  54527. /***/ "./resources/js/bootstrap.js":
  54528. /*!***********************************!*\
  54529. !*** ./resources/js/bootstrap.js ***!
  54530. \***********************************/
  54531. /*! no exports provided */
  54532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54533. "use strict";
  54534. __webpack_require__.r(__webpack_exports__);
  54535. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  54536. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  54537. /**
  54538. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  54539. * for JavaScript based Bootstrap features such as modals and tabs. This
  54540. * code may be modified to fit the specific needs of your application.
  54541. */
  54542. try {
  54543. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  54544. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  54545. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  54546. } catch (e) {}
  54547. /**
  54548. * We'll load the axios HTTP library which allows us to easily issue requests
  54549. * to our Laravel back-end. This library automatically handles sending the
  54550. * CSRF token as a header based on the value of the "XSRF" token cookie.
  54551. */
  54552. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  54553. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  54554. /**
  54555. * Echo exposes an expressive API for subscribing to channels and listening
  54556. * for events that are broadcast by Laravel. Echo and event broadcasting
  54557. * allows your team to easily build robust real-time web applications.
  54558. */
  54559. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  54560. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  54561. broadcaster: 'pusher',
  54562. key: "upccrt",
  54563. wsHost: window.location.hostname,
  54564. wsPort: 6001,
  54565. disableStats: true
  54566. });
  54567. /***/ }),
  54568. /***/ "./resources/js/components/ExampleComponent.vue":
  54569. /*!******************************************************!*\
  54570. !*** ./resources/js/components/ExampleComponent.vue ***!
  54571. \******************************************************/
  54572. /*! exports provided: default */
  54573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54574. "use strict";
  54575. __webpack_require__.r(__webpack_exports__);
  54576. /* 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&");
  54577. /* 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&");
  54578. /* 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");
  54579. /* normalize component */
  54580. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54581. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54582. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  54583. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54584. false,
  54585. null,
  54586. null,
  54587. null
  54588. )
  54589. /* hot reload */
  54590. if (false) { var api; }
  54591. component.options.__file = "resources/js/components/ExampleComponent.vue"
  54592. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54593. /***/ }),
  54594. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  54595. /*!*******************************************************************************!*\
  54596. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  54597. \*******************************************************************************/
  54598. /*! exports provided: default */
  54599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54600. "use strict";
  54601. __webpack_require__.r(__webpack_exports__);
  54602. /* 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&");
  54603. /* 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"]);
  54604. /***/ }),
  54605. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  54606. /*!*************************************************************************************!*\
  54607. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  54608. \*************************************************************************************/
  54609. /*! exports provided: render, staticRenderFns */
  54610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54611. "use strict";
  54612. __webpack_require__.r(__webpack_exports__);
  54613. /* 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&");
  54614. /* 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"]; });
  54615. /* 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"]; });
  54616. /***/ }),
  54617. /***/ "./resources/js/components/assetinfo.vue":
  54618. /*!***********************************************!*\
  54619. !*** ./resources/js/components/assetinfo.vue ***!
  54620. \***********************************************/
  54621. /*! exports provided: default */
  54622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54623. "use strict";
  54624. __webpack_require__.r(__webpack_exports__);
  54625. /* 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&");
  54626. /* 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&");
  54627. /* 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");
  54628. /* normalize component */
  54629. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54630. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54631. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  54632. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54633. false,
  54634. null,
  54635. null,
  54636. null
  54637. )
  54638. /* hot reload */
  54639. if (false) { var api; }
  54640. component.options.__file = "resources/js/components/assetinfo.vue"
  54641. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54642. /***/ }),
  54643. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  54644. /*!************************************************************************!*\
  54645. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  54646. \************************************************************************/
  54647. /*! exports provided: default */
  54648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54649. "use strict";
  54650. __webpack_require__.r(__webpack_exports__);
  54651. /* 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&");
  54652. /* 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"]);
  54653. /***/ }),
  54654. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  54655. /*!******************************************************************************!*\
  54656. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  54657. \******************************************************************************/
  54658. /*! exports provided: render, staticRenderFns */
  54659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54660. "use strict";
  54661. __webpack_require__.r(__webpack_exports__);
  54662. /* 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&");
  54663. /* 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"]; });
  54664. /* 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"]; });
  54665. /***/ }),
  54666. /***/ "./resources/js/components/credential.vue":
  54667. /*!************************************************!*\
  54668. !*** ./resources/js/components/credential.vue ***!
  54669. \************************************************/
  54670. /*! exports provided: default */
  54671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54672. "use strict";
  54673. __webpack_require__.r(__webpack_exports__);
  54674. /* 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&");
  54675. /* 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&");
  54676. /* 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");
  54677. /* normalize component */
  54678. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54679. _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54680. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"],
  54681. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54682. false,
  54683. null,
  54684. null,
  54685. null
  54686. )
  54687. /* hot reload */
  54688. if (false) { var api; }
  54689. component.options.__file = "resources/js/components/credential.vue"
  54690. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54691. /***/ }),
  54692. /***/ "./resources/js/components/credential.vue?vue&type=script&lang=js&":
  54693. /*!*************************************************************************!*\
  54694. !*** ./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  54695. \*************************************************************************/
  54696. /*! exports provided: default */
  54697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54698. "use strict";
  54699. __webpack_require__.r(__webpack_exports__);
  54700. /* 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&");
  54701. /* 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"]);
  54702. /***/ }),
  54703. /***/ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  54704. /*!*******************************************************************************!*\
  54705. !*** ./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  54706. \*******************************************************************************/
  54707. /*! exports provided: render, staticRenderFns */
  54708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54709. "use strict";
  54710. __webpack_require__.r(__webpack_exports__);
  54711. /* 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&");
  54712. /* 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"]; });
  54713. /* 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"]; });
  54714. /***/ }),
  54715. /***/ "./resources/js/components/modal.vue":
  54716. /*!*******************************************!*\
  54717. !*** ./resources/js/components/modal.vue ***!
  54718. \*******************************************/
  54719. /*! exports provided: default */
  54720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54721. "use strict";
  54722. __webpack_require__.r(__webpack_exports__);
  54723. /* 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&");
  54724. /* 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");
  54725. var script = {}
  54726. /* normalize component */
  54727. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_1__["default"])(
  54728. script,
  54729. _modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["render"],
  54730. _modal_vue_vue_type_template_id_478d961c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54731. false,
  54732. null,
  54733. null,
  54734. null
  54735. )
  54736. /* hot reload */
  54737. if (false) { var api; }
  54738. component.options.__file = "resources/js/components/modal.vue"
  54739. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54740. /***/ }),
  54741. /***/ "./resources/js/components/modal.vue?vue&type=template&id=478d961c&":
  54742. /*!**************************************************************************!*\
  54743. !*** ./resources/js/components/modal.vue?vue&type=template&id=478d961c& ***!
  54744. \**************************************************************************/
  54745. /*! exports provided: render, staticRenderFns */
  54746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54747. "use strict";
  54748. __webpack_require__.r(__webpack_exports__);
  54749. /* 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&");
  54750. /* 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"]; });
  54751. /* 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"]; });
  54752. /***/ }),
  54753. /***/ "./resources/js/components/notes.vue":
  54754. /*!*******************************************!*\
  54755. !*** ./resources/js/components/notes.vue ***!
  54756. \*******************************************/
  54757. /*! exports provided: default */
  54758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54759. "use strict";
  54760. __webpack_require__.r(__webpack_exports__);
  54761. /* 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&");
  54762. /* 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&");
  54763. /* 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");
  54764. /* normalize component */
  54765. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54766. _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54767. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"],
  54768. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54769. false,
  54770. null,
  54771. null,
  54772. null
  54773. )
  54774. /* hot reload */
  54775. if (false) { var api; }
  54776. component.options.__file = "resources/js/components/notes.vue"
  54777. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54778. /***/ }),
  54779. /***/ "./resources/js/components/notes.vue?vue&type=script&lang=js&":
  54780. /*!********************************************************************!*\
  54781. !*** ./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  54782. \********************************************************************/
  54783. /*! exports provided: default */
  54784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54785. "use strict";
  54786. __webpack_require__.r(__webpack_exports__);
  54787. /* 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&");
  54788. /* 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"]);
  54789. /***/ }),
  54790. /***/ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  54791. /*!**************************************************************************!*\
  54792. !*** ./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  54793. \**************************************************************************/
  54794. /*! exports provided: render, staticRenderFns */
  54795. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54796. "use strict";
  54797. __webpack_require__.r(__webpack_exports__);
  54798. /* 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&");
  54799. /* 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"]; });
  54800. /* 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"]; });
  54801. /***/ }),
  54802. /***/ "./resources/js/components/woinfo.vue":
  54803. /*!********************************************!*\
  54804. !*** ./resources/js/components/woinfo.vue ***!
  54805. \********************************************/
  54806. /*! exports provided: default */
  54807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54808. "use strict";
  54809. __webpack_require__.r(__webpack_exports__);
  54810. /* 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&");
  54811. /* 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&");
  54812. /* 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");
  54813. /* normalize component */
  54814. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54815. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54816. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  54817. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54818. false,
  54819. null,
  54820. null,
  54821. null
  54822. )
  54823. /* hot reload */
  54824. if (false) { var api; }
  54825. component.options.__file = "resources/js/components/woinfo.vue"
  54826. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54827. /***/ }),
  54828. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  54829. /*!*********************************************************************!*\
  54830. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  54831. \*********************************************************************/
  54832. /*! exports provided: default */
  54833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54834. "use strict";
  54835. __webpack_require__.r(__webpack_exports__);
  54836. /* 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&");
  54837. /* 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"]);
  54838. /***/ }),
  54839. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  54840. /*!***************************************************************************!*\
  54841. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  54842. \***************************************************************************/
  54843. /*! exports provided: render, staticRenderFns */
  54844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54845. "use strict";
  54846. __webpack_require__.r(__webpack_exports__);
  54847. /* 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&");
  54848. /* 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"]; });
  54849. /* 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"]; });
  54850. /***/ }),
  54851. /***/ "./resources/js/mixins/dateMixin.js":
  54852. /*!******************************************!*\
  54853. !*** ./resources/js/mixins/dateMixin.js ***!
  54854. \******************************************/
  54855. /*! exports provided: default */
  54856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54857. "use strict";
  54858. __webpack_require__.r(__webpack_exports__);
  54859. /* harmony default export */ __webpack_exports__["default"] = ({
  54860. methods: {
  54861. treatAsUTC: function treatAsUTC(date) {
  54862. var result = new Date(date);
  54863. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  54864. return result;
  54865. },
  54866. daysSinceToday: function daysSinceToday(date) {
  54867. var currentDate = new Date();
  54868. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  54869. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  54870. },
  54871. getHRDate: function getHRDate(dateString) {
  54872. var date = new Date(dateString);
  54873. return date.toLocaleString('default', {
  54874. month: 'short',
  54875. day: 'numeric',
  54876. year: 'numeric',
  54877. hour: 'numeric',
  54878. minute: 'numeric'
  54879. });
  54880. },
  54881. isZero: function isZero(dateString) {
  54882. return dateString === '0000-00-00 00:00:00';
  54883. }
  54884. }
  54885. });
  54886. /***/ }),
  54887. /***/ "./resources/js/notify.min.js":
  54888. /*!************************************!*\
  54889. !*** ./resources/js/notify.min.js ***!
  54890. \************************************/
  54891. /*! no static exports found */
  54892. /***/ (function(module, exports, __webpack_require__) {
  54893. 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); }
  54894. (function (e) {
  54895. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  54896. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  54897. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  54898. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  54899. })(function (e) {
  54900. function A(t, n, i) {
  54901. typeof i == "string" && (i = {
  54902. className: i
  54903. }), 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);
  54904. }
  54905. var t = [].indexOf || function (e) {
  54906. for (var t = 0, n = this.length; t < n; t++) {
  54907. if (t in this && this[t] === e) return t;
  54908. }
  54909. return -1;
  54910. },
  54911. n = "notify",
  54912. r = n + "js",
  54913. i = n + "!blank",
  54914. s = {
  54915. t: "top",
  54916. m: "middle",
  54917. b: "bottom",
  54918. l: "left",
  54919. c: "center",
  54920. r: "right"
  54921. },
  54922. o = ["l", "c", "r"],
  54923. u = ["t", "m", "b"],
  54924. a = ["t", "b", "l", "r"],
  54925. f = {
  54926. t: "b",
  54927. m: null,
  54928. b: "t",
  54929. l: "r",
  54930. c: null,
  54931. r: "l"
  54932. },
  54933. l = function l(t) {
  54934. var n;
  54935. return n = [], e.each(t.split(/\W+/), function (e, t) {
  54936. var r;
  54937. r = t.toLowerCase().charAt(0);
  54938. if (s[r]) return n.push(r);
  54939. }), n;
  54940. },
  54941. c = {},
  54942. h = {
  54943. name: "core",
  54944. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  54945. 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}"
  54946. },
  54947. p = {
  54948. "border-radius": ["-webkit-", "-moz-"]
  54949. },
  54950. d = function d(e) {
  54951. return c[e];
  54952. },
  54953. v = function v(e) {
  54954. if (!e) throw "Missing Style name";
  54955. c[e] && delete c[e];
  54956. },
  54957. m = function m(t, i) {
  54958. if (!t) throw "Missing Style name";
  54959. if (!i) throw "Missing Style definition";
  54960. if (!i.html) throw "Missing Style HTML";
  54961. var s = c[t];
  54962. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  54963. var o = "";
  54964. i.classes && e.each(i.classes, function (t, n) {
  54965. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  54966. return p[t] && e.each(p[t], function (e, r) {
  54967. return o += " " + r + t + ": " + n + ";\n";
  54968. }), o += " " + t + ": " + n + ";\n";
  54969. }), o += "}\n";
  54970. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  54971. var u = {},
  54972. a = e(i.html);
  54973. y("html", a, u), y("text", a, u), i.fields = u;
  54974. },
  54975. g = function g(t) {
  54976. var n, r, i;
  54977. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  54978. try {
  54979. r.html(t);
  54980. } catch (s) {
  54981. r[0].styleSheet.cssText = t;
  54982. }
  54983. return r;
  54984. },
  54985. y = function y(t, n, r) {
  54986. var s;
  54987. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  54988. var n;
  54989. n = e(this).attr(s), n || (n = i), r[n] = t;
  54990. });
  54991. },
  54992. b = function b(e, t) {
  54993. return e.is(t) ? e : e.find(t);
  54994. },
  54995. w = {
  54996. clickToHide: !0,
  54997. autoHide: !0,
  54998. autoHideDelay: 5e3,
  54999. arrowShow: !0,
  55000. arrowSize: 5,
  55001. breakNewLines: !0,
  55002. elementPosition: "bottom",
  55003. globalPosition: "top right",
  55004. style: "bootstrap",
  55005. className: "error",
  55006. showAnimation: "slideDown",
  55007. showDuration: 400,
  55008. hideAnimation: "slideUp",
  55009. hideDuration: 200,
  55010. gap: 5
  55011. },
  55012. E = function E(t, n) {
  55013. var r;
  55014. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  55015. },
  55016. S = function S(t) {
  55017. return e.extend(w, t);
  55018. },
  55019. x = function x(t) {
  55020. return e("<" + t + "></" + t + ">");
  55021. },
  55022. T = {},
  55023. N = function N(t) {
  55024. var n;
  55025. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  55026. return e(r).attr("name") === t.attr("name");
  55027. }), t = n.first()), t;
  55028. },
  55029. C = function C(e, t, n) {
  55030. var r, i;
  55031. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  55032. if (isNaN(n)) return;
  55033. 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;
  55034. },
  55035. k = function k(e, t, n) {
  55036. if (e === "l" || e === "t") return 0;
  55037. if (e === "c" || e === "m") return n / 2 - t / 2;
  55038. if (e === "r" || e === "b") return n - t;
  55039. throw "Invalid alignment";
  55040. },
  55041. L = function L(e) {
  55042. return L.e = L.e || x("div"), L.e.text(e).html();
  55043. };
  55044. A.prototype.loadHTML = function () {
  55045. var t;
  55046. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  55047. }, A.prototype.show = function (e, t) {
  55048. var n, r, i, s, o;
  55049. r = function (n) {
  55050. return function () {
  55051. !e && !n.elem && n.destroy();
  55052. if (t) return t();
  55053. };
  55054. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  55055. 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 {
  55056. if (!!o || !!e) return r();
  55057. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  55058. }
  55059. return n.push(r), i[s].apply(i, n);
  55060. }, A.prototype.setGlobalPosition = function () {
  55061. var t = this.getPosition(),
  55062. n = t[0],
  55063. i = t[1],
  55064. o = s[n],
  55065. u = s[i],
  55066. a = n + "|" + i,
  55067. f = T[a];
  55068. if (!f || !document.body.contains(f[0])) {
  55069. f = T[a] = x("div");
  55070. var l = {};
  55071. 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);
  55072. }
  55073. return f.prepend(this.wrapper);
  55074. }, A.prototype.setElementPosition = function () {
  55075. 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;
  55076. 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"];
  55077. for (w = 0, S = B.length; w < S; w++) {
  55078. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  55079. }
  55080. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  55081. if (!this.options.arrowShow) this.arrow.hide();else {
  55082. 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";
  55083. for (E = 0, x = a.length; E < x; E++) {
  55084. D = a[E], P = s[D];
  55085. if (D === L) continue;
  55086. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  55087. }
  55088. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  55089. }
  55090. 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);
  55091. if (r) return this.arrow.removeAttr("style").css(r);
  55092. }, A.prototype.getPosition = function () {
  55093. var e, n, r, i, s, f, c, h;
  55094. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  55095. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  55096. 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";
  55097. return e.length === 2 && (e[2] = e[1]), e;
  55098. }, A.prototype.getStyle = function (e) {
  55099. var t;
  55100. e || (e = this.options.style), e || (e = "default"), t = c[e];
  55101. if (!t) throw "Missing style: " + e;
  55102. return t;
  55103. }, A.prototype.updateClasses = function () {
  55104. var t, n;
  55105. 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) {
  55106. return r + "-" + n.name + "-" + e;
  55107. }).join(" "), this.userContainer.attr("class", t);
  55108. }, A.prototype.run = function (t, n) {
  55109. var r, s, o, u, a;
  55110. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  55111. if (this.container && !t) {
  55112. this.show(!1);
  55113. return;
  55114. }
  55115. if (!this.container && !t) return;
  55116. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  55117. for (o in s) {
  55118. r = s[o], u = this.userFields[o];
  55119. if (!u) continue;
  55120. 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);
  55121. }
  55122. 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));
  55123. }, A.prototype.destroy = function () {
  55124. this.wrapper.data(r, null), this.wrapper.remove();
  55125. }, e[n] = function (t, r, i) {
  55126. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  55127. }, e.fn[n] = function (t, n) {
  55128. return e(this).each(function () {
  55129. var i = N(e(this)).data(r);
  55130. i && i.destroy();
  55131. var s = new A(e(this), t, n);
  55132. }), this;
  55133. }, e.extend(e[n], {
  55134. defaults: S,
  55135. addStyle: m,
  55136. removeStyle: v,
  55137. pluginOptions: w,
  55138. getStyle: d,
  55139. insertCSS: g
  55140. }), m("bootstrap", {
  55141. html: "<div>\n<span data-notify-text></span>\n</div>",
  55142. classes: {
  55143. base: {
  55144. "font-weight": "bold",
  55145. padding: "8px 15px 8px 14px",
  55146. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  55147. "background-color": "#fcf8e3",
  55148. border: "1px solid #fbeed5",
  55149. "border-radius": "4px",
  55150. "white-space": "nowrap",
  55151. "padding-left": "25px",
  55152. "background-repeat": "no-repeat",
  55153. "background-position": "3px 7px"
  55154. },
  55155. error: {
  55156. color: "#B94A48",
  55157. "background-color": "#F2DEDE",
  55158. "border-color": "#EED3D7",
  55159. "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=)"
  55160. },
  55161. success: {
  55162. color: "#468847",
  55163. "background-color": "#DFF0D8",
  55164. "border-color": "#D6E9C6",
  55165. "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==)"
  55166. },
  55167. info: {
  55168. color: "#3A87AD",
  55169. "background-color": "#D9EDF7",
  55170. "border-color": "#BCE8F1",
  55171. "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=)"
  55172. },
  55173. warn: {
  55174. color: "#C09853",
  55175. "background-color": "#FCF8E3",
  55176. "border-color": "#FBEED5",
  55177. "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)"
  55178. }
  55179. }
  55180. }), e(function () {
  55181. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  55182. e(this).trigger("notify-hide");
  55183. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  55184. var n = e(this).data(r);
  55185. n && n.show(!1);
  55186. });
  55187. });
  55188. });
  55189. /***/ }),
  55190. /***/ "./resources/sass/app.scss":
  55191. /*!*********************************!*\
  55192. !*** ./resources/sass/app.scss ***!
  55193. \*********************************/
  55194. /*! no static exports found */
  55195. /***/ (function(module, exports) {
  55196. // removed by extract-text-webpack-plugin
  55197. /***/ }),
  55198. /***/ 0:
  55199. /*!*************************************************************!*\
  55200. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  55201. \*************************************************************/
  55202. /*! no static exports found */
  55203. /***/ (function(module, exports, __webpack_require__) {
  55204. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  55205. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  55206. /***/ })
  55207. /******/ });