main.min.js 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903
  1. /*!
  2. * jQuery JavaScript Library v3.4.1
  3. * https://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * https://sizzlejs.com/
  7. *
  8. * Copyright JS Foundation and other contributors
  9. * Released under the MIT license
  10. * https://jquery.org/license
  11. *
  12. * Date: 2019-05-01T21:04Z
  13. */
  14. ( function( global, factory ) {
  15. "use strict";
  16. if ( typeof module === "object" && typeof module.exports === "object" ) {
  17. // For CommonJS and CommonJS-like environments where a proper `window`
  18. // is present, execute the factory and get jQuery.
  19. // For environments that do not have a `window` with a `document`
  20. // (such as Node.js), expose a factory as module.exports.
  21. // This accentuates the need for the creation of a real `window`.
  22. // e.g. var jQuery = require("jquery")(window);
  23. // See ticket #14549 for more info.
  24. module.exports = global.document ?
  25. factory( global, true ) :
  26. function( w ) {
  27. if ( !w.document ) {
  28. throw new Error( "jQuery requires a window with a document" );
  29. }
  30. return factory( w );
  31. };
  32. } else {
  33. factory( global );
  34. }
  35. // Pass this if window is not defined yet
  36. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  37. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  38. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  39. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  40. // enough that all such attempts are guarded in a try block.
  41. var arr = [];
  42. var document = window.document;
  43. var getProto = Object.getPrototypeOf;
  44. var slice = arr.slice;
  45. var concat = arr.concat;
  46. var push = arr.push;
  47. var indexOf = arr.indexOf;
  48. var class2type = {};
  49. var toString = class2type.toString;
  50. var hasOwn = class2type.hasOwnProperty;
  51. var fnToString = hasOwn.toString;
  52. var ObjectFunctionString = fnToString.call( Object );
  53. var support = {};
  54. var isFunction = function isFunction( obj ) {
  55. // Support: Chrome <=57, Firefox <=52
  56. // In some browsers, typeof returns "function" for HTML <object> elements
  57. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  58. // We don't want to classify *any* DOM node as a function.
  59. return typeof obj === "function" && typeof obj.nodeType !== "number";
  60. };
  61. var isWindow = function isWindow( obj ) {
  62. return obj != null && obj === obj.window;
  63. };
  64. var preservedScriptAttributes = {
  65. type: true,
  66. src: true,
  67. nonce: true,
  68. noModule: true
  69. };
  70. function DOMEval( code, node, doc ) {
  71. doc = doc || document;
  72. var i, val,
  73. script = doc.createElement( "script" );
  74. script.text = code;
  75. if ( node ) {
  76. for ( i in preservedScriptAttributes ) {
  77. // Support: Firefox 64+, Edge 18+
  78. // Some browsers don't support the "nonce" property on scripts.
  79. // On the other hand, just using `getAttribute` is not enough as
  80. // the `nonce` attribute is reset to an empty string whenever it
  81. // becomes browsing-context connected.
  82. // See https://github.com/whatwg/html/issues/2369
  83. // See https://html.spec.whatwg.org/#nonce-attributes
  84. // The `node.getAttribute` check was added for the sake of
  85. // `jQuery.globalEval` so that it can fake a nonce-containing node
  86. // via an object.
  87. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  88. if ( val ) {
  89. script.setAttribute( i, val );
  90. }
  91. }
  92. }
  93. doc.head.appendChild( script ).parentNode.removeChild( script );
  94. }
  95. function toType( obj ) {
  96. if ( obj == null ) {
  97. return obj + "";
  98. }
  99. // Support: Android <=2.3 only (functionish RegExp)
  100. return typeof obj === "object" || typeof obj === "function" ?
  101. class2type[ toString.call( obj ) ] || "object" :
  102. typeof obj;
  103. }
  104. /* global Symbol */
  105. // Defining this global in .eslintrc.json would create a danger of using the global
  106. // unguarded in another place, it seems safer to define global only for this module
  107. var
  108. version = "3.4.1",
  109. // Define a local copy of jQuery
  110. jQuery = function( selector, context ) {
  111. // The jQuery object is actually just the init constructor 'enhanced'
  112. // Need init if jQuery is called (just allow error to be thrown if not included)
  113. return new jQuery.fn.init( selector, context );
  114. },
  115. // Support: Android <=4.0 only
  116. // Make sure we trim BOM and NBSP
  117. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  118. jQuery.fn = jQuery.prototype = {
  119. // The current version of jQuery being used
  120. jquery: version,
  121. constructor: jQuery,
  122. // The default length of a jQuery object is 0
  123. length: 0,
  124. toArray: function() {
  125. return slice.call( this );
  126. },
  127. // Get the Nth element in the matched element set OR
  128. // Get the whole matched element set as a clean array
  129. get: function( num ) {
  130. // Return all the elements in a clean array
  131. if ( num == null ) {
  132. return slice.call( this );
  133. }
  134. // Return just the one element from the set
  135. return num < 0 ? this[ num + this.length ] : this[ num ];
  136. },
  137. // Take an array of elements and push it onto the stack
  138. // (returning the new matched element set)
  139. pushStack: function( elems ) {
  140. // Build a new jQuery matched element set
  141. var ret = jQuery.merge( this.constructor(), elems );
  142. // Add the old object onto the stack (as a reference)
  143. ret.prevObject = this;
  144. // Return the newly-formed element set
  145. return ret;
  146. },
  147. // Execute a callback for every element in the matched set.
  148. each: function( callback ) {
  149. return jQuery.each( this, callback );
  150. },
  151. map: function( callback ) {
  152. return this.pushStack( jQuery.map( this, function( elem, i ) {
  153. return callback.call( elem, i, elem );
  154. } ) );
  155. },
  156. slice: function() {
  157. return this.pushStack( slice.apply( this, arguments ) );
  158. },
  159. first: function() {
  160. return this.eq( 0 );
  161. },
  162. last: function() {
  163. return this.eq( -1 );
  164. },
  165. eq: function( i ) {
  166. var len = this.length,
  167. j = +i + ( i < 0 ? len : 0 );
  168. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  169. },
  170. end: function() {
  171. return this.prevObject || this.constructor();
  172. },
  173. // For internal use only.
  174. // Behaves like an Array's method, not like a jQuery method.
  175. push: push,
  176. sort: arr.sort,
  177. splice: arr.splice
  178. };
  179. jQuery.extend = jQuery.fn.extend = function() {
  180. var options, name, src, copy, copyIsArray, clone,
  181. target = arguments[ 0 ] || {},
  182. i = 1,
  183. length = arguments.length,
  184. deep = false;
  185. // Handle a deep copy situation
  186. if ( typeof target === "boolean" ) {
  187. deep = target;
  188. // Skip the boolean and the target
  189. target = arguments[ i ] || {};
  190. i++;
  191. }
  192. // Handle case when target is a string or something (possible in deep copy)
  193. if ( typeof target !== "object" && !isFunction( target ) ) {
  194. target = {};
  195. }
  196. // Extend jQuery itself if only one argument is passed
  197. if ( i === length ) {
  198. target = this;
  199. i--;
  200. }
  201. for ( ; i < length; i++ ) {
  202. // Only deal with non-null/undefined values
  203. if ( ( options = arguments[ i ] ) != null ) {
  204. // Extend the base object
  205. for ( name in options ) {
  206. copy = options[ name ];
  207. // Prevent Object.prototype pollution
  208. // Prevent never-ending loop
  209. if ( name === "__proto__" || target === copy ) {
  210. continue;
  211. }
  212. // Recurse if we're merging plain objects or arrays
  213. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  214. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  215. src = target[ name ];
  216. // Ensure proper type for the source value
  217. if ( copyIsArray && !Array.isArray( src ) ) {
  218. clone = [];
  219. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  220. clone = {};
  221. } else {
  222. clone = src;
  223. }
  224. copyIsArray = false;
  225. // Never move original objects, clone them
  226. target[ name ] = jQuery.extend( deep, clone, copy );
  227. // Don't bring in undefined values
  228. } else if ( copy !== undefined ) {
  229. target[ name ] = copy;
  230. }
  231. }
  232. }
  233. }
  234. // Return the modified object
  235. return target;
  236. };
  237. jQuery.extend( {
  238. // Unique for each copy of jQuery on the page
  239. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  240. // Assume jQuery is ready without the ready module
  241. isReady: true,
  242. error: function( msg ) {
  243. throw new Error( msg );
  244. },
  245. noop: function() {},
  246. isPlainObject: function( obj ) {
  247. var proto, Ctor;
  248. // Detect obvious negatives
  249. // Use toString instead of jQuery.type to catch host objects
  250. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  251. return false;
  252. }
  253. proto = getProto( obj );
  254. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  255. if ( !proto ) {
  256. return true;
  257. }
  258. // Objects with prototype are plain iff they were constructed by a global Object function
  259. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  260. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  261. },
  262. isEmptyObject: function( obj ) {
  263. var name;
  264. for ( name in obj ) {
  265. return false;
  266. }
  267. return true;
  268. },
  269. // Evaluates a script in a global context
  270. globalEval: function( code, options ) {
  271. DOMEval( code, { nonce: options && options.nonce } );
  272. },
  273. each: function( obj, callback ) {
  274. var length, i = 0;
  275. if ( isArrayLike( obj ) ) {
  276. length = obj.length;
  277. for ( ; i < length; i++ ) {
  278. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  279. break;
  280. }
  281. }
  282. } else {
  283. for ( i in obj ) {
  284. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  285. break;
  286. }
  287. }
  288. }
  289. return obj;
  290. },
  291. // Support: Android <=4.0 only
  292. trim: function( text ) {
  293. return text == null ?
  294. "" :
  295. ( text + "" ).replace( rtrim, "" );
  296. },
  297. // results is for internal usage only
  298. makeArray: function( arr, results ) {
  299. var ret = results || [];
  300. if ( arr != null ) {
  301. if ( isArrayLike( Object( arr ) ) ) {
  302. jQuery.merge( ret,
  303. typeof arr === "string" ?
  304. [ arr ] : arr
  305. );
  306. } else {
  307. push.call( ret, arr );
  308. }
  309. }
  310. return ret;
  311. },
  312. inArray: function( elem, arr, i ) {
  313. return arr == null ? -1 : indexOf.call( arr, elem, i );
  314. },
  315. // Support: Android <=4.0 only, PhantomJS 1 only
  316. // push.apply(_, arraylike) throws on ancient WebKit
  317. merge: function( first, second ) {
  318. var len = +second.length,
  319. j = 0,
  320. i = first.length;
  321. for ( ; j < len; j++ ) {
  322. first[ i++ ] = second[ j ];
  323. }
  324. first.length = i;
  325. return first;
  326. },
  327. grep: function( elems, callback, invert ) {
  328. var callbackInverse,
  329. matches = [],
  330. i = 0,
  331. length = elems.length,
  332. callbackExpect = !invert;
  333. // Go through the array, only saving the items
  334. // that pass the validator function
  335. for ( ; i < length; i++ ) {
  336. callbackInverse = !callback( elems[ i ], i );
  337. if ( callbackInverse !== callbackExpect ) {
  338. matches.push( elems[ i ] );
  339. }
  340. }
  341. return matches;
  342. },
  343. // arg is for internal usage only
  344. map: function( elems, callback, arg ) {
  345. var length, value,
  346. i = 0,
  347. ret = [];
  348. // Go through the array, translating each of the items to their new values
  349. if ( isArrayLike( elems ) ) {
  350. length = elems.length;
  351. for ( ; i < length; i++ ) {
  352. value = callback( elems[ i ], i, arg );
  353. if ( value != null ) {
  354. ret.push( value );
  355. }
  356. }
  357. // Go through every key on the object,
  358. } else {
  359. for ( i in elems ) {
  360. value = callback( elems[ i ], i, arg );
  361. if ( value != null ) {
  362. ret.push( value );
  363. }
  364. }
  365. }
  366. // Flatten any nested arrays
  367. return concat.apply( [], ret );
  368. },
  369. // A global GUID counter for objects
  370. guid: 1,
  371. // jQuery.support is not used in Core but other projects attach their
  372. // properties to it so it needs to exist.
  373. support: support
  374. } );
  375. if ( typeof Symbol === "function" ) {
  376. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  377. }
  378. // Populate the class2type map
  379. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  380. function( i, name ) {
  381. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  382. } );
  383. function isArrayLike( obj ) {
  384. // Support: real iOS 8.2 only (not reproducible in simulator)
  385. // `in` check used to prevent JIT error (gh-2145)
  386. // hasOwn isn't used here due to false negatives
  387. // regarding Nodelist length in IE
  388. var length = !!obj && "length" in obj && obj.length,
  389. type = toType( obj );
  390. if ( isFunction( obj ) || isWindow( obj ) ) {
  391. return false;
  392. }
  393. return type === "array" || length === 0 ||
  394. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  395. }
  396. var Sizzle =
  397. /*!
  398. * Sizzle CSS Selector Engine v2.3.4
  399. * https://sizzlejs.com/
  400. *
  401. * Copyright JS Foundation and other contributors
  402. * Released under the MIT license
  403. * https://js.foundation/
  404. *
  405. * Date: 2019-04-08
  406. */
  407. (function( window ) {
  408. var i,
  409. support,
  410. Expr,
  411. getText,
  412. isXML,
  413. tokenize,
  414. compile,
  415. select,
  416. outermostContext,
  417. sortInput,
  418. hasDuplicate,
  419. // Local document vars
  420. setDocument,
  421. document,
  422. docElem,
  423. documentIsHTML,
  424. rbuggyQSA,
  425. rbuggyMatches,
  426. matches,
  427. contains,
  428. // Instance-specific data
  429. expando = "sizzle" + 1 * new Date(),
  430. preferredDoc = window.document,
  431. dirruns = 0,
  432. done = 0,
  433. classCache = createCache(),
  434. tokenCache = createCache(),
  435. compilerCache = createCache(),
  436. nonnativeSelectorCache = createCache(),
  437. sortOrder = function( a, b ) {
  438. if ( a === b ) {
  439. hasDuplicate = true;
  440. }
  441. return 0;
  442. },
  443. // Instance methods
  444. hasOwn = ({}).hasOwnProperty,
  445. arr = [],
  446. pop = arr.pop,
  447. push_native = arr.push,
  448. push = arr.push,
  449. slice = arr.slice,
  450. // Use a stripped-down indexOf as it's faster than native
  451. // https://jsperf.com/thor-indexof-vs-for/5
  452. indexOf = function( list, elem ) {
  453. var i = 0,
  454. len = list.length;
  455. for ( ; i < len; i++ ) {
  456. if ( list[i] === elem ) {
  457. return i;
  458. }
  459. }
  460. return -1;
  461. },
  462. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  463. // Regular expressions
  464. // http://www.w3.org/TR/css3-selectors/#whitespace
  465. whitespace = "[\\x20\\t\\r\\n\\f]",
  466. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  467. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  468. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  469. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  470. // Operator (capture 2)
  471. "*([*^$|!~]?=)" + whitespace +
  472. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  473. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  474. "*\\]",
  475. pseudos = ":(" + identifier + ")(?:\\((" +
  476. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  477. // 1. quoted (capture 3; capture 4 or capture 5)
  478. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  479. // 2. simple (capture 6)
  480. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  481. // 3. anything else (capture 2)
  482. ".*" +
  483. ")\\)|)",
  484. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  485. rwhitespace = new RegExp( whitespace + "+", "g" ),
  486. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  487. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  488. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  489. rdescend = new RegExp( whitespace + "|>" ),
  490. rpseudo = new RegExp( pseudos ),
  491. ridentifier = new RegExp( "^" + identifier + "$" ),
  492. matchExpr = {
  493. "ID": new RegExp( "^#(" + identifier + ")" ),
  494. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  495. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  496. "ATTR": new RegExp( "^" + attributes ),
  497. "PSEUDO": new RegExp( "^" + pseudos ),
  498. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  499. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  500. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  501. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  502. // For use in libraries implementing .is()
  503. // We use this for POS matching in `select`
  504. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  505. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  506. },
  507. rhtml = /HTML$/i,
  508. rinputs = /^(?:input|select|textarea|button)$/i,
  509. rheader = /^h\d$/i,
  510. rnative = /^[^{]+\{\s*\[native \w/,
  511. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  512. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  513. rsibling = /[+~]/,
  514. // CSS escapes
  515. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  516. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  517. funescape = function( _, escaped, escapedWhitespace ) {
  518. var high = "0x" + escaped - 0x10000;
  519. // NaN means non-codepoint
  520. // Support: Firefox<24
  521. // Workaround erroneous numeric interpretation of +"0x"
  522. return high !== high || escapedWhitespace ?
  523. escaped :
  524. high < 0 ?
  525. // BMP codepoint
  526. String.fromCharCode( high + 0x10000 ) :
  527. // Supplemental Plane codepoint (surrogate pair)
  528. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  529. },
  530. // CSS string/identifier serialization
  531. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  532. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  533. fcssescape = function( ch, asCodePoint ) {
  534. if ( asCodePoint ) {
  535. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  536. if ( ch === "\0" ) {
  537. return "\uFFFD";
  538. }
  539. // Control characters and (dependent upon position) numbers get escaped as code points
  540. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  541. }
  542. // Other potentially-special ASCII characters get backslash-escaped
  543. return "\\" + ch;
  544. },
  545. // Used for iframes
  546. // See setDocument()
  547. // Removing the function wrapper causes a "Permission Denied"
  548. // error in IE
  549. unloadHandler = function() {
  550. setDocument();
  551. },
  552. inDisabledFieldset = addCombinator(
  553. function( elem ) {
  554. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  555. },
  556. { dir: "parentNode", next: "legend" }
  557. );
  558. // Optimize for push.apply( _, NodeList )
  559. try {
  560. push.apply(
  561. (arr = slice.call( preferredDoc.childNodes )),
  562. preferredDoc.childNodes
  563. );
  564. // Support: Android<4.0
  565. // Detect silently failing push.apply
  566. arr[ preferredDoc.childNodes.length ].nodeType;
  567. } catch ( e ) {
  568. push = { apply: arr.length ?
  569. // Leverage slice if possible
  570. function( target, els ) {
  571. push_native.apply( target, slice.call(els) );
  572. } :
  573. // Support: IE<9
  574. // Otherwise append directly
  575. function( target, els ) {
  576. var j = target.length,
  577. i = 0;
  578. // Can't trust NodeList.length
  579. while ( (target[j++] = els[i++]) ) {}
  580. target.length = j - 1;
  581. }
  582. };
  583. }
  584. function Sizzle( selector, context, results, seed ) {
  585. var m, i, elem, nid, match, groups, newSelector,
  586. newContext = context && context.ownerDocument,
  587. // nodeType defaults to 9, since context defaults to document
  588. nodeType = context ? context.nodeType : 9;
  589. results = results || [];
  590. // Return early from calls with invalid selector or context
  591. if ( typeof selector !== "string" || !selector ||
  592. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  593. return results;
  594. }
  595. // Try to shortcut find operations (as opposed to filters) in HTML documents
  596. if ( !seed ) {
  597. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  598. setDocument( context );
  599. }
  600. context = context || document;
  601. if ( documentIsHTML ) {
  602. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  603. // (excepting DocumentFragment context, where the methods don't exist)
  604. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  605. // ID selector
  606. if ( (m = match[1]) ) {
  607. // Document context
  608. if ( nodeType === 9 ) {
  609. if ( (elem = context.getElementById( m )) ) {
  610. // Support: IE, Opera, Webkit
  611. // TODO: identify versions
  612. // getElementById can match elements by name instead of ID
  613. if ( elem.id === m ) {
  614. results.push( elem );
  615. return results;
  616. }
  617. } else {
  618. return results;
  619. }
  620. // Element context
  621. } else {
  622. // Support: IE, Opera, Webkit
  623. // TODO: identify versions
  624. // getElementById can match elements by name instead of ID
  625. if ( newContext && (elem = newContext.getElementById( m )) &&
  626. contains( context, elem ) &&
  627. elem.id === m ) {
  628. results.push( elem );
  629. return results;
  630. }
  631. }
  632. // Type selector
  633. } else if ( match[2] ) {
  634. push.apply( results, context.getElementsByTagName( selector ) );
  635. return results;
  636. // Class selector
  637. } else if ( (m = match[3]) && support.getElementsByClassName &&
  638. context.getElementsByClassName ) {
  639. push.apply( results, context.getElementsByClassName( m ) );
  640. return results;
  641. }
  642. }
  643. // Take advantage of querySelectorAll
  644. if ( support.qsa &&
  645. !nonnativeSelectorCache[ selector + " " ] &&
  646. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  647. // Support: IE 8 only
  648. // Exclude object elements
  649. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  650. newSelector = selector;
  651. newContext = context;
  652. // qSA considers elements outside a scoping root when evaluating child or
  653. // descendant combinators, which is not what we want.
  654. // In such cases, we work around the behavior by prefixing every selector in the
  655. // list with an ID selector referencing the scope context.
  656. // Thanks to Andrew Dupont for this technique.
  657. if ( nodeType === 1 && rdescend.test( selector ) ) {
  658. // Capture the context ID, setting it first if necessary
  659. if ( (nid = context.getAttribute( "id" )) ) {
  660. nid = nid.replace( rcssescape, fcssescape );
  661. } else {
  662. context.setAttribute( "id", (nid = expando) );
  663. }
  664. // Prefix every selector in the list
  665. groups = tokenize( selector );
  666. i = groups.length;
  667. while ( i-- ) {
  668. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  669. }
  670. newSelector = groups.join( "," );
  671. // Expand context for sibling selectors
  672. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  673. context;
  674. }
  675. try {
  676. push.apply( results,
  677. newContext.querySelectorAll( newSelector )
  678. );
  679. return results;
  680. } catch ( qsaError ) {
  681. nonnativeSelectorCache( selector, true );
  682. } finally {
  683. if ( nid === expando ) {
  684. context.removeAttribute( "id" );
  685. }
  686. }
  687. }
  688. }
  689. }
  690. // All others
  691. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  692. }
  693. /**
  694. * Create key-value caches of limited size
  695. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  696. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  697. * deleting the oldest entry
  698. */
  699. function createCache() {
  700. var keys = [];
  701. function cache( key, value ) {
  702. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  703. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  704. // Only keep the most recent entries
  705. delete cache[ keys.shift() ];
  706. }
  707. return (cache[ key + " " ] = value);
  708. }
  709. return cache;
  710. }
  711. /**
  712. * Mark a function for special use by Sizzle
  713. * @param {Function} fn The function to mark
  714. */
  715. function markFunction( fn ) {
  716. fn[ expando ] = true;
  717. return fn;
  718. }
  719. /**
  720. * Support testing using an element
  721. * @param {Function} fn Passed the created element and returns a boolean result
  722. */
  723. function assert( fn ) {
  724. var el = document.createElement("fieldset");
  725. try {
  726. return !!fn( el );
  727. } catch (e) {
  728. return false;
  729. } finally {
  730. // Remove from its parent by default
  731. if ( el.parentNode ) {
  732. el.parentNode.removeChild( el );
  733. }
  734. // release memory in IE
  735. el = null;
  736. }
  737. }
  738. /**
  739. * Adds the same handler for all of the specified attrs
  740. * @param {String} attrs Pipe-separated list of attributes
  741. * @param {Function} handler The method that will be applied
  742. */
  743. function addHandle( attrs, handler ) {
  744. var arr = attrs.split("|"),
  745. i = arr.length;
  746. while ( i-- ) {
  747. Expr.attrHandle[ arr[i] ] = handler;
  748. }
  749. }
  750. /**
  751. * Checks document order of two siblings
  752. * @param {Element} a
  753. * @param {Element} b
  754. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  755. */
  756. function siblingCheck( a, b ) {
  757. var cur = b && a,
  758. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  759. a.sourceIndex - b.sourceIndex;
  760. // Use IE sourceIndex if available on both nodes
  761. if ( diff ) {
  762. return diff;
  763. }
  764. // Check if b follows a
  765. if ( cur ) {
  766. while ( (cur = cur.nextSibling) ) {
  767. if ( cur === b ) {
  768. return -1;
  769. }
  770. }
  771. }
  772. return a ? 1 : -1;
  773. }
  774. /**
  775. * Returns a function to use in pseudos for input types
  776. * @param {String} type
  777. */
  778. function createInputPseudo( type ) {
  779. return function( elem ) {
  780. var name = elem.nodeName.toLowerCase();
  781. return name === "input" && elem.type === type;
  782. };
  783. }
  784. /**
  785. * Returns a function to use in pseudos for buttons
  786. * @param {String} type
  787. */
  788. function createButtonPseudo( type ) {
  789. return function( elem ) {
  790. var name = elem.nodeName.toLowerCase();
  791. return (name === "input" || name === "button") && elem.type === type;
  792. };
  793. }
  794. /**
  795. * Returns a function to use in pseudos for :enabled/:disabled
  796. * @param {Boolean} disabled true for :disabled; false for :enabled
  797. */
  798. function createDisabledPseudo( disabled ) {
  799. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  800. return function( elem ) {
  801. // Only certain elements can match :enabled or :disabled
  802. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  803. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  804. if ( "form" in elem ) {
  805. // Check for inherited disabledness on relevant non-disabled elements:
  806. // * listed form-associated elements in a disabled fieldset
  807. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  808. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  809. // * option elements in a disabled optgroup
  810. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  811. // All such elements have a "form" property.
  812. if ( elem.parentNode && elem.disabled === false ) {
  813. // Option elements defer to a parent optgroup if present
  814. if ( "label" in elem ) {
  815. if ( "label" in elem.parentNode ) {
  816. return elem.parentNode.disabled === disabled;
  817. } else {
  818. return elem.disabled === disabled;
  819. }
  820. }
  821. // Support: IE 6 - 11
  822. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  823. return elem.isDisabled === disabled ||
  824. // Where there is no isDisabled, check manually
  825. /* jshint -W018 */
  826. elem.isDisabled !== !disabled &&
  827. inDisabledFieldset( elem ) === disabled;
  828. }
  829. return elem.disabled === disabled;
  830. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  831. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  832. // even exist on them, let alone have a boolean value.
  833. } else if ( "label" in elem ) {
  834. return elem.disabled === disabled;
  835. }
  836. // Remaining elements are neither :enabled nor :disabled
  837. return false;
  838. };
  839. }
  840. /**
  841. * Returns a function to use in pseudos for positionals
  842. * @param {Function} fn
  843. */
  844. function createPositionalPseudo( fn ) {
  845. return markFunction(function( argument ) {
  846. argument = +argument;
  847. return markFunction(function( seed, matches ) {
  848. var j,
  849. matchIndexes = fn( [], seed.length, argument ),
  850. i = matchIndexes.length;
  851. // Match elements found at the specified indexes
  852. while ( i-- ) {
  853. if ( seed[ (j = matchIndexes[i]) ] ) {
  854. seed[j] = !(matches[j] = seed[j]);
  855. }
  856. }
  857. });
  858. });
  859. }
  860. /**
  861. * Checks a node for validity as a Sizzle context
  862. * @param {Element|Object=} context
  863. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  864. */
  865. function testContext( context ) {
  866. return context && typeof context.getElementsByTagName !== "undefined" && context;
  867. }
  868. // Expose support vars for convenience
  869. support = Sizzle.support = {};
  870. /**
  871. * Detects XML nodes
  872. * @param {Element|Object} elem An element or a document
  873. * @returns {Boolean} True iff elem is a non-HTML XML node
  874. */
  875. isXML = Sizzle.isXML = function( elem ) {
  876. var namespace = elem.namespaceURI,
  877. docElem = (elem.ownerDocument || elem).documentElement;
  878. // Support: IE <=8
  879. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  880. // https://bugs.jquery.com/ticket/4833
  881. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  882. };
  883. /**
  884. * Sets document-related variables once based on the current document
  885. * @param {Element|Object} [doc] An element or document object to use to set the document
  886. * @returns {Object} Returns the current document
  887. */
  888. setDocument = Sizzle.setDocument = function( node ) {
  889. var hasCompare, subWindow,
  890. doc = node ? node.ownerDocument || node : preferredDoc;
  891. // Return early if doc is invalid or already selected
  892. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  893. return document;
  894. }
  895. // Update global variables
  896. document = doc;
  897. docElem = document.documentElement;
  898. documentIsHTML = !isXML( document );
  899. // Support: IE 9-11, Edge
  900. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  901. if ( preferredDoc !== document &&
  902. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  903. // Support: IE 11, Edge
  904. if ( subWindow.addEventListener ) {
  905. subWindow.addEventListener( "unload", unloadHandler, false );
  906. // Support: IE 9 - 10 only
  907. } else if ( subWindow.attachEvent ) {
  908. subWindow.attachEvent( "onunload", unloadHandler );
  909. }
  910. }
  911. /* Attributes
  912. ---------------------------------------------------------------------- */
  913. // Support: IE<8
  914. // Verify that getAttribute really returns attributes and not properties
  915. // (excepting IE8 booleans)
  916. support.attributes = assert(function( el ) {
  917. el.className = "i";
  918. return !el.getAttribute("className");
  919. });
  920. /* getElement(s)By*
  921. ---------------------------------------------------------------------- */
  922. // Check if getElementsByTagName("*") returns only elements
  923. support.getElementsByTagName = assert(function( el ) {
  924. el.appendChild( document.createComment("") );
  925. return !el.getElementsByTagName("*").length;
  926. });
  927. // Support: IE<9
  928. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  929. // Support: IE<10
  930. // Check if getElementById returns elements by name
  931. // The broken getElementById methods don't pick up programmatically-set names,
  932. // so use a roundabout getElementsByName test
  933. support.getById = assert(function( el ) {
  934. docElem.appendChild( el ).id = expando;
  935. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  936. });
  937. // ID filter and find
  938. if ( support.getById ) {
  939. Expr.filter["ID"] = function( id ) {
  940. var attrId = id.replace( runescape, funescape );
  941. return function( elem ) {
  942. return elem.getAttribute("id") === attrId;
  943. };
  944. };
  945. Expr.find["ID"] = function( id, context ) {
  946. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  947. var elem = context.getElementById( id );
  948. return elem ? [ elem ] : [];
  949. }
  950. };
  951. } else {
  952. Expr.filter["ID"] = function( id ) {
  953. var attrId = id.replace( runescape, funescape );
  954. return function( elem ) {
  955. var node = typeof elem.getAttributeNode !== "undefined" &&
  956. elem.getAttributeNode("id");
  957. return node && node.value === attrId;
  958. };
  959. };
  960. // Support: IE 6 - 7 only
  961. // getElementById is not reliable as a find shortcut
  962. Expr.find["ID"] = function( id, context ) {
  963. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  964. var node, i, elems,
  965. elem = context.getElementById( id );
  966. if ( elem ) {
  967. // Verify the id attribute
  968. node = elem.getAttributeNode("id");
  969. if ( node && node.value === id ) {
  970. return [ elem ];
  971. }
  972. // Fall back on getElementsByName
  973. elems = context.getElementsByName( id );
  974. i = 0;
  975. while ( (elem = elems[i++]) ) {
  976. node = elem.getAttributeNode("id");
  977. if ( node && node.value === id ) {
  978. return [ elem ];
  979. }
  980. }
  981. }
  982. return [];
  983. }
  984. };
  985. }
  986. // Tag
  987. Expr.find["TAG"] = support.getElementsByTagName ?
  988. function( tag, context ) {
  989. if ( typeof context.getElementsByTagName !== "undefined" ) {
  990. return context.getElementsByTagName( tag );
  991. // DocumentFragment nodes don't have gEBTN
  992. } else if ( support.qsa ) {
  993. return context.querySelectorAll( tag );
  994. }
  995. } :
  996. function( tag, context ) {
  997. var elem,
  998. tmp = [],
  999. i = 0,
  1000. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  1001. results = context.getElementsByTagName( tag );
  1002. // Filter out possible comments
  1003. if ( tag === "*" ) {
  1004. while ( (elem = results[i++]) ) {
  1005. if ( elem.nodeType === 1 ) {
  1006. tmp.push( elem );
  1007. }
  1008. }
  1009. return tmp;
  1010. }
  1011. return results;
  1012. };
  1013. // Class
  1014. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  1015. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  1016. return context.getElementsByClassName( className );
  1017. }
  1018. };
  1019. /* QSA/matchesSelector
  1020. ---------------------------------------------------------------------- */
  1021. // QSA and matchesSelector support
  1022. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1023. rbuggyMatches = [];
  1024. // qSa(:focus) reports false when true (Chrome 21)
  1025. // We allow this because of a bug in IE8/9 that throws an error
  1026. // whenever `document.activeElement` is accessed on an iframe
  1027. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1028. // See https://bugs.jquery.com/ticket/13378
  1029. rbuggyQSA = [];
  1030. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  1031. // Build QSA regex
  1032. // Regex strategy adopted from Diego Perini
  1033. assert(function( el ) {
  1034. // Select is set to empty string on purpose
  1035. // This is to test IE's treatment of not explicitly
  1036. // setting a boolean content attribute,
  1037. // since its presence should be enough
  1038. // https://bugs.jquery.com/ticket/12359
  1039. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  1040. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  1041. "<option selected=''></option></select>";
  1042. // Support: IE8, Opera 11-12.16
  1043. // Nothing should be selected when empty strings follow ^= or $= or *=
  1044. // The test attribute must be unknown in Opera but "safe" for WinRT
  1045. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1046. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  1047. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1048. }
  1049. // Support: IE8
  1050. // Boolean attributes and "value" are not treated correctly
  1051. if ( !el.querySelectorAll("[selected]").length ) {
  1052. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1053. }
  1054. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  1055. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  1056. rbuggyQSA.push("~=");
  1057. }
  1058. // Webkit/Opera - :checked should return selected option elements
  1059. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1060. // IE8 throws error here and will not see later tests
  1061. if ( !el.querySelectorAll(":checked").length ) {
  1062. rbuggyQSA.push(":checked");
  1063. }
  1064. // Support: Safari 8+, iOS 8+
  1065. // https://bugs.webkit.org/show_bug.cgi?id=136851
  1066. // In-page `selector#id sibling-combinator selector` fails
  1067. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  1068. rbuggyQSA.push(".#.+[+~]");
  1069. }
  1070. });
  1071. assert(function( el ) {
  1072. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  1073. "<select disabled='disabled'><option/></select>";
  1074. // Support: Windows 8 Native Apps
  1075. // The type and name attributes are restricted during .innerHTML assignment
  1076. var input = document.createElement("input");
  1077. input.setAttribute( "type", "hidden" );
  1078. el.appendChild( input ).setAttribute( "name", "D" );
  1079. // Support: IE8
  1080. // Enforce case-sensitivity of name attribute
  1081. if ( el.querySelectorAll("[name=d]").length ) {
  1082. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1083. }
  1084. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1085. // IE8 throws error here and will not see later tests
  1086. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  1087. rbuggyQSA.push( ":enabled", ":disabled" );
  1088. }
  1089. // Support: IE9-11+
  1090. // IE's :disabled selector does not pick up the children of disabled fieldsets
  1091. docElem.appendChild( el ).disabled = true;
  1092. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  1093. rbuggyQSA.push( ":enabled", ":disabled" );
  1094. }
  1095. // Opera 10-11 does not throw on post-comma invalid pseudos
  1096. el.querySelectorAll("*,:x");
  1097. rbuggyQSA.push(",.*:");
  1098. });
  1099. }
  1100. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1101. docElem.webkitMatchesSelector ||
  1102. docElem.mozMatchesSelector ||
  1103. docElem.oMatchesSelector ||
  1104. docElem.msMatchesSelector) )) ) {
  1105. assert(function( el ) {
  1106. // Check to see if it's possible to do matchesSelector
  1107. // on a disconnected node (IE 9)
  1108. support.disconnectedMatch = matches.call( el, "*" );
  1109. // This should fail with an exception
  1110. // Gecko does not error, returns false instead
  1111. matches.call( el, "[s!='']:x" );
  1112. rbuggyMatches.push( "!=", pseudos );
  1113. });
  1114. }
  1115. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1116. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1117. /* Contains
  1118. ---------------------------------------------------------------------- */
  1119. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1120. // Element contains another
  1121. // Purposefully self-exclusive
  1122. // As in, an element does not contain itself
  1123. contains = hasCompare || rnative.test( docElem.contains ) ?
  1124. function( a, b ) {
  1125. var adown = a.nodeType === 9 ? a.documentElement : a,
  1126. bup = b && b.parentNode;
  1127. return a === bup || !!( bup && bup.nodeType === 1 && (
  1128. adown.contains ?
  1129. adown.contains( bup ) :
  1130. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1131. ));
  1132. } :
  1133. function( a, b ) {
  1134. if ( b ) {
  1135. while ( (b = b.parentNode) ) {
  1136. if ( b === a ) {
  1137. return true;
  1138. }
  1139. }
  1140. }
  1141. return false;
  1142. };
  1143. /* Sorting
  1144. ---------------------------------------------------------------------- */
  1145. // Document order sorting
  1146. sortOrder = hasCompare ?
  1147. function( a, b ) {
  1148. // Flag for duplicate removal
  1149. if ( a === b ) {
  1150. hasDuplicate = true;
  1151. return 0;
  1152. }
  1153. // Sort on method existence if only one input has compareDocumentPosition
  1154. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1155. if ( compare ) {
  1156. return compare;
  1157. }
  1158. // Calculate position if both inputs belong to the same document
  1159. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1160. a.compareDocumentPosition( b ) :
  1161. // Otherwise we know they are disconnected
  1162. 1;
  1163. // Disconnected nodes
  1164. if ( compare & 1 ||
  1165. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1166. // Choose the first element that is related to our preferred document
  1167. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1168. return -1;
  1169. }
  1170. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1171. return 1;
  1172. }
  1173. // Maintain original order
  1174. return sortInput ?
  1175. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1176. 0;
  1177. }
  1178. return compare & 4 ? -1 : 1;
  1179. } :
  1180. function( a, b ) {
  1181. // Exit early if the nodes are identical
  1182. if ( a === b ) {
  1183. hasDuplicate = true;
  1184. return 0;
  1185. }
  1186. var cur,
  1187. i = 0,
  1188. aup = a.parentNode,
  1189. bup = b.parentNode,
  1190. ap = [ a ],
  1191. bp = [ b ];
  1192. // Parentless nodes are either documents or disconnected
  1193. if ( !aup || !bup ) {
  1194. return a === document ? -1 :
  1195. b === document ? 1 :
  1196. aup ? -1 :
  1197. bup ? 1 :
  1198. sortInput ?
  1199. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1200. 0;
  1201. // If the nodes are siblings, we can do a quick check
  1202. } else if ( aup === bup ) {
  1203. return siblingCheck( a, b );
  1204. }
  1205. // Otherwise we need full lists of their ancestors for comparison
  1206. cur = a;
  1207. while ( (cur = cur.parentNode) ) {
  1208. ap.unshift( cur );
  1209. }
  1210. cur = b;
  1211. while ( (cur = cur.parentNode) ) {
  1212. bp.unshift( cur );
  1213. }
  1214. // Walk down the tree looking for a discrepancy
  1215. while ( ap[i] === bp[i] ) {
  1216. i++;
  1217. }
  1218. return i ?
  1219. // Do a sibling check if the nodes have a common ancestor
  1220. siblingCheck( ap[i], bp[i] ) :
  1221. // Otherwise nodes in our document sort first
  1222. ap[i] === preferredDoc ? -1 :
  1223. bp[i] === preferredDoc ? 1 :
  1224. 0;
  1225. };
  1226. return document;
  1227. };
  1228. Sizzle.matches = function( expr, elements ) {
  1229. return Sizzle( expr, null, null, elements );
  1230. };
  1231. Sizzle.matchesSelector = function( elem, expr ) {
  1232. // Set document vars if needed
  1233. if ( ( elem.ownerDocument || elem ) !== document ) {
  1234. setDocument( elem );
  1235. }
  1236. if ( support.matchesSelector && documentIsHTML &&
  1237. !nonnativeSelectorCache[ expr + " " ] &&
  1238. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1239. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1240. try {
  1241. var ret = matches.call( elem, expr );
  1242. // IE 9's matchesSelector returns false on disconnected nodes
  1243. if ( ret || support.disconnectedMatch ||
  1244. // As well, disconnected nodes are said to be in a document
  1245. // fragment in IE 9
  1246. elem.document && elem.document.nodeType !== 11 ) {
  1247. return ret;
  1248. }
  1249. } catch (e) {
  1250. nonnativeSelectorCache( expr, true );
  1251. }
  1252. }
  1253. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1254. };
  1255. Sizzle.contains = function( context, elem ) {
  1256. // Set document vars if needed
  1257. if ( ( context.ownerDocument || context ) !== document ) {
  1258. setDocument( context );
  1259. }
  1260. return contains( context, elem );
  1261. };
  1262. Sizzle.attr = function( elem, name ) {
  1263. // Set document vars if needed
  1264. if ( ( elem.ownerDocument || elem ) !== document ) {
  1265. setDocument( elem );
  1266. }
  1267. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1268. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1269. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1270. fn( elem, name, !documentIsHTML ) :
  1271. undefined;
  1272. return val !== undefined ?
  1273. val :
  1274. support.attributes || !documentIsHTML ?
  1275. elem.getAttribute( name ) :
  1276. (val = elem.getAttributeNode(name)) && val.specified ?
  1277. val.value :
  1278. null;
  1279. };
  1280. Sizzle.escape = function( sel ) {
  1281. return (sel + "").replace( rcssescape, fcssescape );
  1282. };
  1283. Sizzle.error = function( msg ) {
  1284. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1285. };
  1286. /**
  1287. * Document sorting and removing duplicates
  1288. * @param {ArrayLike} results
  1289. */
  1290. Sizzle.uniqueSort = function( results ) {
  1291. var elem,
  1292. duplicates = [],
  1293. j = 0,
  1294. i = 0;
  1295. // Unless we *know* we can detect duplicates, assume their presence
  1296. hasDuplicate = !support.detectDuplicates;
  1297. sortInput = !support.sortStable && results.slice( 0 );
  1298. results.sort( sortOrder );
  1299. if ( hasDuplicate ) {
  1300. while ( (elem = results[i++]) ) {
  1301. if ( elem === results[ i ] ) {
  1302. j = duplicates.push( i );
  1303. }
  1304. }
  1305. while ( j-- ) {
  1306. results.splice( duplicates[ j ], 1 );
  1307. }
  1308. }
  1309. // Clear input after sorting to release objects
  1310. // See https://github.com/jquery/sizzle/pull/225
  1311. sortInput = null;
  1312. return results;
  1313. };
  1314. /**
  1315. * Utility function for retrieving the text value of an array of DOM nodes
  1316. * @param {Array|Element} elem
  1317. */
  1318. getText = Sizzle.getText = function( elem ) {
  1319. var node,
  1320. ret = "",
  1321. i = 0,
  1322. nodeType = elem.nodeType;
  1323. if ( !nodeType ) {
  1324. // If no nodeType, this is expected to be an array
  1325. while ( (node = elem[i++]) ) {
  1326. // Do not traverse comment nodes
  1327. ret += getText( node );
  1328. }
  1329. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1330. // Use textContent for elements
  1331. // innerText usage removed for consistency of new lines (jQuery #11153)
  1332. if ( typeof elem.textContent === "string" ) {
  1333. return elem.textContent;
  1334. } else {
  1335. // Traverse its children
  1336. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1337. ret += getText( elem );
  1338. }
  1339. }
  1340. } else if ( nodeType === 3 || nodeType === 4 ) {
  1341. return elem.nodeValue;
  1342. }
  1343. // Do not include comment or processing instruction nodes
  1344. return ret;
  1345. };
  1346. Expr = Sizzle.selectors = {
  1347. // Can be adjusted by the user
  1348. cacheLength: 50,
  1349. createPseudo: markFunction,
  1350. match: matchExpr,
  1351. attrHandle: {},
  1352. find: {},
  1353. relative: {
  1354. ">": { dir: "parentNode", first: true },
  1355. " ": { dir: "parentNode" },
  1356. "+": { dir: "previousSibling", first: true },
  1357. "~": { dir: "previousSibling" }
  1358. },
  1359. preFilter: {
  1360. "ATTR": function( match ) {
  1361. match[1] = match[1].replace( runescape, funescape );
  1362. // Move the given value to match[3] whether quoted or unquoted
  1363. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1364. if ( match[2] === "~=" ) {
  1365. match[3] = " " + match[3] + " ";
  1366. }
  1367. return match.slice( 0, 4 );
  1368. },
  1369. "CHILD": function( match ) {
  1370. /* matches from matchExpr["CHILD"]
  1371. 1 type (only|nth|...)
  1372. 2 what (child|of-type)
  1373. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1374. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1375. 5 sign of xn-component
  1376. 6 x of xn-component
  1377. 7 sign of y-component
  1378. 8 y of y-component
  1379. */
  1380. match[1] = match[1].toLowerCase();
  1381. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1382. // nth-* requires argument
  1383. if ( !match[3] ) {
  1384. Sizzle.error( match[0] );
  1385. }
  1386. // numeric x and y parameters for Expr.filter.CHILD
  1387. // remember that false/true cast respectively to 0/1
  1388. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1389. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1390. // other types prohibit arguments
  1391. } else if ( match[3] ) {
  1392. Sizzle.error( match[0] );
  1393. }
  1394. return match;
  1395. },
  1396. "PSEUDO": function( match ) {
  1397. var excess,
  1398. unquoted = !match[6] && match[2];
  1399. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1400. return null;
  1401. }
  1402. // Accept quoted arguments as-is
  1403. if ( match[3] ) {
  1404. match[2] = match[4] || match[5] || "";
  1405. // Strip excess characters from unquoted arguments
  1406. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1407. // Get excess from tokenize (recursively)
  1408. (excess = tokenize( unquoted, true )) &&
  1409. // advance to the next closing parenthesis
  1410. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1411. // excess is a negative index
  1412. match[0] = match[0].slice( 0, excess );
  1413. match[2] = unquoted.slice( 0, excess );
  1414. }
  1415. // Return only captures needed by the pseudo filter method (type and argument)
  1416. return match.slice( 0, 3 );
  1417. }
  1418. },
  1419. filter: {
  1420. "TAG": function( nodeNameSelector ) {
  1421. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1422. return nodeNameSelector === "*" ?
  1423. function() { return true; } :
  1424. function( elem ) {
  1425. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1426. };
  1427. },
  1428. "CLASS": function( className ) {
  1429. var pattern = classCache[ className + " " ];
  1430. return pattern ||
  1431. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1432. classCache( className, function( elem ) {
  1433. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  1434. });
  1435. },
  1436. "ATTR": function( name, operator, check ) {
  1437. return function( elem ) {
  1438. var result = Sizzle.attr( elem, name );
  1439. if ( result == null ) {
  1440. return operator === "!=";
  1441. }
  1442. if ( !operator ) {
  1443. return true;
  1444. }
  1445. result += "";
  1446. return operator === "=" ? result === check :
  1447. operator === "!=" ? result !== check :
  1448. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1449. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1450. operator === "$=" ? check && result.slice( -check.length ) === check :
  1451. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  1452. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1453. false;
  1454. };
  1455. },
  1456. "CHILD": function( type, what, argument, first, last ) {
  1457. var simple = type.slice( 0, 3 ) !== "nth",
  1458. forward = type.slice( -4 ) !== "last",
  1459. ofType = what === "of-type";
  1460. return first === 1 && last === 0 ?
  1461. // Shortcut for :nth-*(n)
  1462. function( elem ) {
  1463. return !!elem.parentNode;
  1464. } :
  1465. function( elem, context, xml ) {
  1466. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  1467. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1468. parent = elem.parentNode,
  1469. name = ofType && elem.nodeName.toLowerCase(),
  1470. useCache = !xml && !ofType,
  1471. diff = false;
  1472. if ( parent ) {
  1473. // :(first|last|only)-(child|of-type)
  1474. if ( simple ) {
  1475. while ( dir ) {
  1476. node = elem;
  1477. while ( (node = node[ dir ]) ) {
  1478. if ( ofType ?
  1479. node.nodeName.toLowerCase() === name :
  1480. node.nodeType === 1 ) {
  1481. return false;
  1482. }
  1483. }
  1484. // Reverse direction for :only-* (if we haven't yet done so)
  1485. start = dir = type === "only" && !start && "nextSibling";
  1486. }
  1487. return true;
  1488. }
  1489. start = [ forward ? parent.firstChild : parent.lastChild ];
  1490. // non-xml :nth-child(...) stores cache data on `parent`
  1491. if ( forward && useCache ) {
  1492. // Seek `elem` from a previously-cached index
  1493. // ...in a gzip-friendly way
  1494. node = parent;
  1495. outerCache = node[ expando ] || (node[ expando ] = {});
  1496. // Support: IE <9 only
  1497. // Defend against cloned attroperties (jQuery gh-1709)
  1498. uniqueCache = outerCache[ node.uniqueID ] ||
  1499. (outerCache[ node.uniqueID ] = {});
  1500. cache = uniqueCache[ type ] || [];
  1501. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1502. diff = nodeIndex && cache[ 2 ];
  1503. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1504. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1505. // Fallback to seeking `elem` from the start
  1506. (diff = nodeIndex = 0) || start.pop()) ) {
  1507. // When found, cache indexes on `parent` and break
  1508. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1509. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  1510. break;
  1511. }
  1512. }
  1513. } else {
  1514. // Use previously-cached element index if available
  1515. if ( useCache ) {
  1516. // ...in a gzip-friendly way
  1517. node = elem;
  1518. outerCache = node[ expando ] || (node[ expando ] = {});
  1519. // Support: IE <9 only
  1520. // Defend against cloned attroperties (jQuery gh-1709)
  1521. uniqueCache = outerCache[ node.uniqueID ] ||
  1522. (outerCache[ node.uniqueID ] = {});
  1523. cache = uniqueCache[ type ] || [];
  1524. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1525. diff = nodeIndex;
  1526. }
  1527. // xml :nth-child(...)
  1528. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1529. if ( diff === false ) {
  1530. // Use the same loop as above to seek `elem` from the start
  1531. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1532. (diff = nodeIndex = 0) || start.pop()) ) {
  1533. if ( ( ofType ?
  1534. node.nodeName.toLowerCase() === name :
  1535. node.nodeType === 1 ) &&
  1536. ++diff ) {
  1537. // Cache the index of each encountered element
  1538. if ( useCache ) {
  1539. outerCache = node[ expando ] || (node[ expando ] = {});
  1540. // Support: IE <9 only
  1541. // Defend against cloned attroperties (jQuery gh-1709)
  1542. uniqueCache = outerCache[ node.uniqueID ] ||
  1543. (outerCache[ node.uniqueID ] = {});
  1544. uniqueCache[ type ] = [ dirruns, diff ];
  1545. }
  1546. if ( node === elem ) {
  1547. break;
  1548. }
  1549. }
  1550. }
  1551. }
  1552. }
  1553. // Incorporate the offset, then check against cycle size
  1554. diff -= last;
  1555. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1556. }
  1557. };
  1558. },
  1559. "PSEUDO": function( pseudo, argument ) {
  1560. // pseudo-class names are case-insensitive
  1561. // http://www.w3.org/TR/selectors/#pseudo-classes
  1562. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1563. // Remember that setFilters inherits from pseudos
  1564. var args,
  1565. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1566. Sizzle.error( "unsupported pseudo: " + pseudo );
  1567. // The user may use createPseudo to indicate that
  1568. // arguments are needed to create the filter function
  1569. // just as Sizzle does
  1570. if ( fn[ expando ] ) {
  1571. return fn( argument );
  1572. }
  1573. // But maintain support for old signatures
  1574. if ( fn.length > 1 ) {
  1575. args = [ pseudo, pseudo, "", argument ];
  1576. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1577. markFunction(function( seed, matches ) {
  1578. var idx,
  1579. matched = fn( seed, argument ),
  1580. i = matched.length;
  1581. while ( i-- ) {
  1582. idx = indexOf( seed, matched[i] );
  1583. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1584. }
  1585. }) :
  1586. function( elem ) {
  1587. return fn( elem, 0, args );
  1588. };
  1589. }
  1590. return fn;
  1591. }
  1592. },
  1593. pseudos: {
  1594. // Potentially complex pseudos
  1595. "not": markFunction(function( selector ) {
  1596. // Trim the selector passed to compile
  1597. // to avoid treating leading and trailing
  1598. // spaces as combinators
  1599. var input = [],
  1600. results = [],
  1601. matcher = compile( selector.replace( rtrim, "$1" ) );
  1602. return matcher[ expando ] ?
  1603. markFunction(function( seed, matches, context, xml ) {
  1604. var elem,
  1605. unmatched = matcher( seed, null, xml, [] ),
  1606. i = seed.length;
  1607. // Match elements unmatched by `matcher`
  1608. while ( i-- ) {
  1609. if ( (elem = unmatched[i]) ) {
  1610. seed[i] = !(matches[i] = elem);
  1611. }
  1612. }
  1613. }) :
  1614. function( elem, context, xml ) {
  1615. input[0] = elem;
  1616. matcher( input, null, xml, results );
  1617. // Don't keep the element (issue #299)
  1618. input[0] = null;
  1619. return !results.pop();
  1620. };
  1621. }),
  1622. "has": markFunction(function( selector ) {
  1623. return function( elem ) {
  1624. return Sizzle( selector, elem ).length > 0;
  1625. };
  1626. }),
  1627. "contains": markFunction(function( text ) {
  1628. text = text.replace( runescape, funescape );
  1629. return function( elem ) {
  1630. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  1631. };
  1632. }),
  1633. // "Whether an element is represented by a :lang() selector
  1634. // is based solely on the element's language value
  1635. // being equal to the identifier C,
  1636. // or beginning with the identifier C immediately followed by "-".
  1637. // The matching of C against the element's language value is performed case-insensitively.
  1638. // The identifier C does not have to be a valid language name."
  1639. // http://www.w3.org/TR/selectors/#lang-pseudo
  1640. "lang": markFunction( function( lang ) {
  1641. // lang value must be a valid identifier
  1642. if ( !ridentifier.test(lang || "") ) {
  1643. Sizzle.error( "unsupported lang: " + lang );
  1644. }
  1645. lang = lang.replace( runescape, funescape ).toLowerCase();
  1646. return function( elem ) {
  1647. var elemLang;
  1648. do {
  1649. if ( (elemLang = documentIsHTML ?
  1650. elem.lang :
  1651. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1652. elemLang = elemLang.toLowerCase();
  1653. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1654. }
  1655. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1656. return false;
  1657. };
  1658. }),
  1659. // Miscellaneous
  1660. "target": function( elem ) {
  1661. var hash = window.location && window.location.hash;
  1662. return hash && hash.slice( 1 ) === elem.id;
  1663. },
  1664. "root": function( elem ) {
  1665. return elem === docElem;
  1666. },
  1667. "focus": function( elem ) {
  1668. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1669. },
  1670. // Boolean properties
  1671. "enabled": createDisabledPseudo( false ),
  1672. "disabled": createDisabledPseudo( true ),
  1673. "checked": function( elem ) {
  1674. // In CSS3, :checked should return both checked and selected elements
  1675. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1676. var nodeName = elem.nodeName.toLowerCase();
  1677. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1678. },
  1679. "selected": function( elem ) {
  1680. // Accessing this property makes selected-by-default
  1681. // options in Safari work properly
  1682. if ( elem.parentNode ) {
  1683. elem.parentNode.selectedIndex;
  1684. }
  1685. return elem.selected === true;
  1686. },
  1687. // Contents
  1688. "empty": function( elem ) {
  1689. // http://www.w3.org/TR/selectors/#empty-pseudo
  1690. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1691. // but not by others (comment: 8; processing instruction: 7; etc.)
  1692. // nodeType < 6 works because attributes (2) do not appear as children
  1693. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1694. if ( elem.nodeType < 6 ) {
  1695. return false;
  1696. }
  1697. }
  1698. return true;
  1699. },
  1700. "parent": function( elem ) {
  1701. return !Expr.pseudos["empty"]( elem );
  1702. },
  1703. // Element/input types
  1704. "header": function( elem ) {
  1705. return rheader.test( elem.nodeName );
  1706. },
  1707. "input": function( elem ) {
  1708. return rinputs.test( elem.nodeName );
  1709. },
  1710. "button": function( elem ) {
  1711. var name = elem.nodeName.toLowerCase();
  1712. return name === "input" && elem.type === "button" || name === "button";
  1713. },
  1714. "text": function( elem ) {
  1715. var attr;
  1716. return elem.nodeName.toLowerCase() === "input" &&
  1717. elem.type === "text" &&
  1718. // Support: IE<8
  1719. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1720. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1721. },
  1722. // Position-in-collection
  1723. "first": createPositionalPseudo(function() {
  1724. return [ 0 ];
  1725. }),
  1726. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1727. return [ length - 1 ];
  1728. }),
  1729. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1730. return [ argument < 0 ? argument + length : argument ];
  1731. }),
  1732. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1733. var i = 0;
  1734. for ( ; i < length; i += 2 ) {
  1735. matchIndexes.push( i );
  1736. }
  1737. return matchIndexes;
  1738. }),
  1739. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1740. var i = 1;
  1741. for ( ; i < length; i += 2 ) {
  1742. matchIndexes.push( i );
  1743. }
  1744. return matchIndexes;
  1745. }),
  1746. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1747. var i = argument < 0 ?
  1748. argument + length :
  1749. argument > length ?
  1750. length :
  1751. argument;
  1752. for ( ; --i >= 0; ) {
  1753. matchIndexes.push( i );
  1754. }
  1755. return matchIndexes;
  1756. }),
  1757. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1758. var i = argument < 0 ? argument + length : argument;
  1759. for ( ; ++i < length; ) {
  1760. matchIndexes.push( i );
  1761. }
  1762. return matchIndexes;
  1763. })
  1764. }
  1765. };
  1766. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1767. // Add button/input type pseudos
  1768. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1769. Expr.pseudos[ i ] = createInputPseudo( i );
  1770. }
  1771. for ( i in { submit: true, reset: true } ) {
  1772. Expr.pseudos[ i ] = createButtonPseudo( i );
  1773. }
  1774. // Easy API for creating new setFilters
  1775. function setFilters() {}
  1776. setFilters.prototype = Expr.filters = Expr.pseudos;
  1777. Expr.setFilters = new setFilters();
  1778. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1779. var matched, match, tokens, type,
  1780. soFar, groups, preFilters,
  1781. cached = tokenCache[ selector + " " ];
  1782. if ( cached ) {
  1783. return parseOnly ? 0 : cached.slice( 0 );
  1784. }
  1785. soFar = selector;
  1786. groups = [];
  1787. preFilters = Expr.preFilter;
  1788. while ( soFar ) {
  1789. // Comma and first run
  1790. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1791. if ( match ) {
  1792. // Don't consume trailing commas as valid
  1793. soFar = soFar.slice( match[0].length ) || soFar;
  1794. }
  1795. groups.push( (tokens = []) );
  1796. }
  1797. matched = false;
  1798. // Combinators
  1799. if ( (match = rcombinators.exec( soFar )) ) {
  1800. matched = match.shift();
  1801. tokens.push({
  1802. value: matched,
  1803. // Cast descendant combinators to space
  1804. type: match[0].replace( rtrim, " " )
  1805. });
  1806. soFar = soFar.slice( matched.length );
  1807. }
  1808. // Filters
  1809. for ( type in Expr.filter ) {
  1810. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1811. (match = preFilters[ type ]( match ))) ) {
  1812. matched = match.shift();
  1813. tokens.push({
  1814. value: matched,
  1815. type: type,
  1816. matches: match
  1817. });
  1818. soFar = soFar.slice( matched.length );
  1819. }
  1820. }
  1821. if ( !matched ) {
  1822. break;
  1823. }
  1824. }
  1825. // Return the length of the invalid excess
  1826. // if we're just parsing
  1827. // Otherwise, throw an error or return tokens
  1828. return parseOnly ?
  1829. soFar.length :
  1830. soFar ?
  1831. Sizzle.error( selector ) :
  1832. // Cache the tokens
  1833. tokenCache( selector, groups ).slice( 0 );
  1834. };
  1835. function toSelector( tokens ) {
  1836. var i = 0,
  1837. len = tokens.length,
  1838. selector = "";
  1839. for ( ; i < len; i++ ) {
  1840. selector += tokens[i].value;
  1841. }
  1842. return selector;
  1843. }
  1844. function addCombinator( matcher, combinator, base ) {
  1845. var dir = combinator.dir,
  1846. skip = combinator.next,
  1847. key = skip || dir,
  1848. checkNonElements = base && key === "parentNode",
  1849. doneName = done++;
  1850. return combinator.first ?
  1851. // Check against closest ancestor/preceding element
  1852. function( elem, context, xml ) {
  1853. while ( (elem = elem[ dir ]) ) {
  1854. if ( elem.nodeType === 1 || checkNonElements ) {
  1855. return matcher( elem, context, xml );
  1856. }
  1857. }
  1858. return false;
  1859. } :
  1860. // Check against all ancestor/preceding elements
  1861. function( elem, context, xml ) {
  1862. var oldCache, uniqueCache, outerCache,
  1863. newCache = [ dirruns, doneName ];
  1864. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  1865. if ( xml ) {
  1866. while ( (elem = elem[ dir ]) ) {
  1867. if ( elem.nodeType === 1 || checkNonElements ) {
  1868. if ( matcher( elem, context, xml ) ) {
  1869. return true;
  1870. }
  1871. }
  1872. }
  1873. } else {
  1874. while ( (elem = elem[ dir ]) ) {
  1875. if ( elem.nodeType === 1 || checkNonElements ) {
  1876. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1877. // Support: IE <9 only
  1878. // Defend against cloned attroperties (jQuery gh-1709)
  1879. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  1880. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  1881. elem = elem[ dir ] || elem;
  1882. } else if ( (oldCache = uniqueCache[ key ]) &&
  1883. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1884. // Assign to newCache so results back-propagate to previous elements
  1885. return (newCache[ 2 ] = oldCache[ 2 ]);
  1886. } else {
  1887. // Reuse newcache so results back-propagate to previous elements
  1888. uniqueCache[ key ] = newCache;
  1889. // A match means we're done; a fail means we have to keep checking
  1890. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1891. return true;
  1892. }
  1893. }
  1894. }
  1895. }
  1896. }
  1897. return false;
  1898. };
  1899. }
  1900. function elementMatcher( matchers ) {
  1901. return matchers.length > 1 ?
  1902. function( elem, context, xml ) {
  1903. var i = matchers.length;
  1904. while ( i-- ) {
  1905. if ( !matchers[i]( elem, context, xml ) ) {
  1906. return false;
  1907. }
  1908. }
  1909. return true;
  1910. } :
  1911. matchers[0];
  1912. }
  1913. function multipleContexts( selector, contexts, results ) {
  1914. var i = 0,
  1915. len = contexts.length;
  1916. for ( ; i < len; i++ ) {
  1917. Sizzle( selector, contexts[i], results );
  1918. }
  1919. return results;
  1920. }
  1921. function condense( unmatched, map, filter, context, xml ) {
  1922. var elem,
  1923. newUnmatched = [],
  1924. i = 0,
  1925. len = unmatched.length,
  1926. mapped = map != null;
  1927. for ( ; i < len; i++ ) {
  1928. if ( (elem = unmatched[i]) ) {
  1929. if ( !filter || filter( elem, context, xml ) ) {
  1930. newUnmatched.push( elem );
  1931. if ( mapped ) {
  1932. map.push( i );
  1933. }
  1934. }
  1935. }
  1936. }
  1937. return newUnmatched;
  1938. }
  1939. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1940. if ( postFilter && !postFilter[ expando ] ) {
  1941. postFilter = setMatcher( postFilter );
  1942. }
  1943. if ( postFinder && !postFinder[ expando ] ) {
  1944. postFinder = setMatcher( postFinder, postSelector );
  1945. }
  1946. return markFunction(function( seed, results, context, xml ) {
  1947. var temp, i, elem,
  1948. preMap = [],
  1949. postMap = [],
  1950. preexisting = results.length,
  1951. // Get initial elements from seed or context
  1952. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1953. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1954. matcherIn = preFilter && ( seed || !selector ) ?
  1955. condense( elems, preMap, preFilter, context, xml ) :
  1956. elems,
  1957. matcherOut = matcher ?
  1958. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1959. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1960. // ...intermediate processing is necessary
  1961. [] :
  1962. // ...otherwise use results directly
  1963. results :
  1964. matcherIn;
  1965. // Find primary matches
  1966. if ( matcher ) {
  1967. matcher( matcherIn, matcherOut, context, xml );
  1968. }
  1969. // Apply postFilter
  1970. if ( postFilter ) {
  1971. temp = condense( matcherOut, postMap );
  1972. postFilter( temp, [], context, xml );
  1973. // Un-match failing elements by moving them back to matcherIn
  1974. i = temp.length;
  1975. while ( i-- ) {
  1976. if ( (elem = temp[i]) ) {
  1977. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1978. }
  1979. }
  1980. }
  1981. if ( seed ) {
  1982. if ( postFinder || preFilter ) {
  1983. if ( postFinder ) {
  1984. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1985. temp = [];
  1986. i = matcherOut.length;
  1987. while ( i-- ) {
  1988. if ( (elem = matcherOut[i]) ) {
  1989. // Restore matcherIn since elem is not yet a final match
  1990. temp.push( (matcherIn[i] = elem) );
  1991. }
  1992. }
  1993. postFinder( null, (matcherOut = []), temp, xml );
  1994. }
  1995. // Move matched elements from seed to results to keep them synchronized
  1996. i = matcherOut.length;
  1997. while ( i-- ) {
  1998. if ( (elem = matcherOut[i]) &&
  1999. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  2000. seed[temp] = !(results[temp] = elem);
  2001. }
  2002. }
  2003. }
  2004. // Add elements to results, through postFinder if defined
  2005. } else {
  2006. matcherOut = condense(
  2007. matcherOut === results ?
  2008. matcherOut.splice( preexisting, matcherOut.length ) :
  2009. matcherOut
  2010. );
  2011. if ( postFinder ) {
  2012. postFinder( null, results, matcherOut, xml );
  2013. } else {
  2014. push.apply( results, matcherOut );
  2015. }
  2016. }
  2017. });
  2018. }
  2019. function matcherFromTokens( tokens ) {
  2020. var checkContext, matcher, j,
  2021. len = tokens.length,
  2022. leadingRelative = Expr.relative[ tokens[0].type ],
  2023. implicitRelative = leadingRelative || Expr.relative[" "],
  2024. i = leadingRelative ? 1 : 0,
  2025. // The foundational matcher ensures that elements are reachable from top-level context(s)
  2026. matchContext = addCombinator( function( elem ) {
  2027. return elem === checkContext;
  2028. }, implicitRelative, true ),
  2029. matchAnyContext = addCombinator( function( elem ) {
  2030. return indexOf( checkContext, elem ) > -1;
  2031. }, implicitRelative, true ),
  2032. matchers = [ function( elem, context, xml ) {
  2033. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  2034. (checkContext = context).nodeType ?
  2035. matchContext( elem, context, xml ) :
  2036. matchAnyContext( elem, context, xml ) );
  2037. // Avoid hanging onto element (issue #299)
  2038. checkContext = null;
  2039. return ret;
  2040. } ];
  2041. for ( ; i < len; i++ ) {
  2042. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  2043. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  2044. } else {
  2045. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  2046. // Return special upon seeing a positional matcher
  2047. if ( matcher[ expando ] ) {
  2048. // Find the next relative operator (if any) for proper handling
  2049. j = ++i;
  2050. for ( ; j < len; j++ ) {
  2051. if ( Expr.relative[ tokens[j].type ] ) {
  2052. break;
  2053. }
  2054. }
  2055. return setMatcher(
  2056. i > 1 && elementMatcher( matchers ),
  2057. i > 1 && toSelector(
  2058. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2059. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  2060. ).replace( rtrim, "$1" ),
  2061. matcher,
  2062. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  2063. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  2064. j < len && toSelector( tokens )
  2065. );
  2066. }
  2067. matchers.push( matcher );
  2068. }
  2069. }
  2070. return elementMatcher( matchers );
  2071. }
  2072. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2073. var bySet = setMatchers.length > 0,
  2074. byElement = elementMatchers.length > 0,
  2075. superMatcher = function( seed, context, xml, results, outermost ) {
  2076. var elem, j, matcher,
  2077. matchedCount = 0,
  2078. i = "0",
  2079. unmatched = seed && [],
  2080. setMatched = [],
  2081. contextBackup = outermostContext,
  2082. // We must always have either seed elements or outermost context
  2083. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2084. // Use integer dirruns iff this is the outermost matcher
  2085. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2086. len = elems.length;
  2087. if ( outermost ) {
  2088. outermostContext = context === document || context || outermost;
  2089. }
  2090. // Add elements passing elementMatchers directly to results
  2091. // Support: IE<9, Safari
  2092. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2093. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2094. if ( byElement && elem ) {
  2095. j = 0;
  2096. if ( !context && elem.ownerDocument !== document ) {
  2097. setDocument( elem );
  2098. xml = !documentIsHTML;
  2099. }
  2100. while ( (matcher = elementMatchers[j++]) ) {
  2101. if ( matcher( elem, context || document, xml) ) {
  2102. results.push( elem );
  2103. break;
  2104. }
  2105. }
  2106. if ( outermost ) {
  2107. dirruns = dirrunsUnique;
  2108. }
  2109. }
  2110. // Track unmatched elements for set filters
  2111. if ( bySet ) {
  2112. // They will have gone through all possible matchers
  2113. if ( (elem = !matcher && elem) ) {
  2114. matchedCount--;
  2115. }
  2116. // Lengthen the array for every element, matched or not
  2117. if ( seed ) {
  2118. unmatched.push( elem );
  2119. }
  2120. }
  2121. }
  2122. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  2123. // makes the latter nonnegative.
  2124. matchedCount += i;
  2125. // Apply set filters to unmatched elements
  2126. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  2127. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  2128. // no element matchers and no seed.
  2129. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  2130. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  2131. // numerically zero.
  2132. if ( bySet && i !== matchedCount ) {
  2133. j = 0;
  2134. while ( (matcher = setMatchers[j++]) ) {
  2135. matcher( unmatched, setMatched, context, xml );
  2136. }
  2137. if ( seed ) {
  2138. // Reintegrate element matches to eliminate the need for sorting
  2139. if ( matchedCount > 0 ) {
  2140. while ( i-- ) {
  2141. if ( !(unmatched[i] || setMatched[i]) ) {
  2142. setMatched[i] = pop.call( results );
  2143. }
  2144. }
  2145. }
  2146. // Discard index placeholder values to get only actual matches
  2147. setMatched = condense( setMatched );
  2148. }
  2149. // Add matches to results
  2150. push.apply( results, setMatched );
  2151. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2152. if ( outermost && !seed && setMatched.length > 0 &&
  2153. ( matchedCount + setMatchers.length ) > 1 ) {
  2154. Sizzle.uniqueSort( results );
  2155. }
  2156. }
  2157. // Override manipulation of globals by nested matchers
  2158. if ( outermost ) {
  2159. dirruns = dirrunsUnique;
  2160. outermostContext = contextBackup;
  2161. }
  2162. return unmatched;
  2163. };
  2164. return bySet ?
  2165. markFunction( superMatcher ) :
  2166. superMatcher;
  2167. }
  2168. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2169. var i,
  2170. setMatchers = [],
  2171. elementMatchers = [],
  2172. cached = compilerCache[ selector + " " ];
  2173. if ( !cached ) {
  2174. // Generate a function of recursive functions that can be used to check each element
  2175. if ( !match ) {
  2176. match = tokenize( selector );
  2177. }
  2178. i = match.length;
  2179. while ( i-- ) {
  2180. cached = matcherFromTokens( match[i] );
  2181. if ( cached[ expando ] ) {
  2182. setMatchers.push( cached );
  2183. } else {
  2184. elementMatchers.push( cached );
  2185. }
  2186. }
  2187. // Cache the compiled function
  2188. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2189. // Save selector and tokenization
  2190. cached.selector = selector;
  2191. }
  2192. return cached;
  2193. };
  2194. /**
  2195. * A low-level selection function that works with Sizzle's compiled
  2196. * selector functions
  2197. * @param {String|Function} selector A selector or a pre-compiled
  2198. * selector function built with Sizzle.compile
  2199. * @param {Element} context
  2200. * @param {Array} [results]
  2201. * @param {Array} [seed] A set of elements to match against
  2202. */
  2203. select = Sizzle.select = function( selector, context, results, seed ) {
  2204. var i, tokens, token, type, find,
  2205. compiled = typeof selector === "function" && selector,
  2206. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2207. results = results || [];
  2208. // Try to minimize operations if there is only one selector in the list and no seed
  2209. // (the latter of which guarantees us context)
  2210. if ( match.length === 1 ) {
  2211. // Reduce context if the leading compound selector is an ID
  2212. tokens = match[0] = match[0].slice( 0 );
  2213. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2214. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  2215. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2216. if ( !context ) {
  2217. return results;
  2218. // Precompiled matchers will still verify ancestry, so step up a level
  2219. } else if ( compiled ) {
  2220. context = context.parentNode;
  2221. }
  2222. selector = selector.slice( tokens.shift().value.length );
  2223. }
  2224. // Fetch a seed set for right-to-left matching
  2225. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2226. while ( i-- ) {
  2227. token = tokens[i];
  2228. // Abort if we hit a combinator
  2229. if ( Expr.relative[ (type = token.type) ] ) {
  2230. break;
  2231. }
  2232. if ( (find = Expr.find[ type ]) ) {
  2233. // Search, expanding context for leading sibling combinators
  2234. if ( (seed = find(
  2235. token.matches[0].replace( runescape, funescape ),
  2236. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2237. )) ) {
  2238. // If seed is empty or no tokens remain, we can return early
  2239. tokens.splice( i, 1 );
  2240. selector = seed.length && toSelector( tokens );
  2241. if ( !selector ) {
  2242. push.apply( results, seed );
  2243. return results;
  2244. }
  2245. break;
  2246. }
  2247. }
  2248. }
  2249. }
  2250. // Compile and execute a filtering function if one is not provided
  2251. // Provide `match` to avoid retokenization if we modified the selector above
  2252. ( compiled || compile( selector, match ) )(
  2253. seed,
  2254. context,
  2255. !documentIsHTML,
  2256. results,
  2257. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  2258. );
  2259. return results;
  2260. };
  2261. // One-time assignments
  2262. // Sort stability
  2263. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2264. // Support: Chrome 14-35+
  2265. // Always assume duplicates if they aren't passed to the comparison function
  2266. support.detectDuplicates = !!hasDuplicate;
  2267. // Initialize against the default document
  2268. setDocument();
  2269. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2270. // Detached nodes confoundingly follow *each other*
  2271. support.sortDetached = assert(function( el ) {
  2272. // Should return 1, but returns 4 (following)
  2273. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  2274. });
  2275. // Support: IE<8
  2276. // Prevent attribute/property "interpolation"
  2277. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2278. if ( !assert(function( el ) {
  2279. el.innerHTML = "<a href='#'></a>";
  2280. return el.firstChild.getAttribute("href") === "#" ;
  2281. }) ) {
  2282. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2283. if ( !isXML ) {
  2284. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2285. }
  2286. });
  2287. }
  2288. // Support: IE<9
  2289. // Use defaultValue in place of getAttribute("value")
  2290. if ( !support.attributes || !assert(function( el ) {
  2291. el.innerHTML = "<input/>";
  2292. el.firstChild.setAttribute( "value", "" );
  2293. return el.firstChild.getAttribute( "value" ) === "";
  2294. }) ) {
  2295. addHandle( "value", function( elem, name, isXML ) {
  2296. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2297. return elem.defaultValue;
  2298. }
  2299. });
  2300. }
  2301. // Support: IE<9
  2302. // Use getAttributeNode to fetch booleans when getAttribute lies
  2303. if ( !assert(function( el ) {
  2304. return el.getAttribute("disabled") == null;
  2305. }) ) {
  2306. addHandle( booleans, function( elem, name, isXML ) {
  2307. var val;
  2308. if ( !isXML ) {
  2309. return elem[ name ] === true ? name.toLowerCase() :
  2310. (val = elem.getAttributeNode( name )) && val.specified ?
  2311. val.value :
  2312. null;
  2313. }
  2314. });
  2315. }
  2316. return Sizzle;
  2317. })( window );
  2318. jQuery.find = Sizzle;
  2319. jQuery.expr = Sizzle.selectors;
  2320. // Deprecated
  2321. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  2322. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  2323. jQuery.text = Sizzle.getText;
  2324. jQuery.isXMLDoc = Sizzle.isXML;
  2325. jQuery.contains = Sizzle.contains;
  2326. jQuery.escapeSelector = Sizzle.escape;
  2327. var dir = function( elem, dir, until ) {
  2328. var matched = [],
  2329. truncate = until !== undefined;
  2330. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  2331. if ( elem.nodeType === 1 ) {
  2332. if ( truncate && jQuery( elem ).is( until ) ) {
  2333. break;
  2334. }
  2335. matched.push( elem );
  2336. }
  2337. }
  2338. return matched;
  2339. };
  2340. var siblings = function( n, elem ) {
  2341. var matched = [];
  2342. for ( ; n; n = n.nextSibling ) {
  2343. if ( n.nodeType === 1 && n !== elem ) {
  2344. matched.push( n );
  2345. }
  2346. }
  2347. return matched;
  2348. };
  2349. var rneedsContext = jQuery.expr.match.needsContext;
  2350. function nodeName( elem, name ) {
  2351. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  2352. };
  2353. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  2354. // Implement the identical functionality for filter and not
  2355. function winnow( elements, qualifier, not ) {
  2356. if ( isFunction( qualifier ) ) {
  2357. return jQuery.grep( elements, function( elem, i ) {
  2358. return !!qualifier.call( elem, i, elem ) !== not;
  2359. } );
  2360. }
  2361. // Single element
  2362. if ( qualifier.nodeType ) {
  2363. return jQuery.grep( elements, function( elem ) {
  2364. return ( elem === qualifier ) !== not;
  2365. } );
  2366. }
  2367. // Arraylike of elements (jQuery, arguments, Array)
  2368. if ( typeof qualifier !== "string" ) {
  2369. return jQuery.grep( elements, function( elem ) {
  2370. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  2371. } );
  2372. }
  2373. // Filtered directly for both simple and complex selectors
  2374. return jQuery.filter( qualifier, elements, not );
  2375. }
  2376. jQuery.filter = function( expr, elems, not ) {
  2377. var elem = elems[ 0 ];
  2378. if ( not ) {
  2379. expr = ":not(" + expr + ")";
  2380. }
  2381. if ( elems.length === 1 && elem.nodeType === 1 ) {
  2382. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  2383. }
  2384. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2385. return elem.nodeType === 1;
  2386. } ) );
  2387. };
  2388. jQuery.fn.extend( {
  2389. find: function( selector ) {
  2390. var i, ret,
  2391. len = this.length,
  2392. self = this;
  2393. if ( typeof selector !== "string" ) {
  2394. return this.pushStack( jQuery( selector ).filter( function() {
  2395. for ( i = 0; i < len; i++ ) {
  2396. if ( jQuery.contains( self[ i ], this ) ) {
  2397. return true;
  2398. }
  2399. }
  2400. } ) );
  2401. }
  2402. ret = this.pushStack( [] );
  2403. for ( i = 0; i < len; i++ ) {
  2404. jQuery.find( selector, self[ i ], ret );
  2405. }
  2406. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  2407. },
  2408. filter: function( selector ) {
  2409. return this.pushStack( winnow( this, selector || [], false ) );
  2410. },
  2411. not: function( selector ) {
  2412. return this.pushStack( winnow( this, selector || [], true ) );
  2413. },
  2414. is: function( selector ) {
  2415. return !!winnow(
  2416. this,
  2417. // If this is a positional/relative selector, check membership in the returned set
  2418. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2419. typeof selector === "string" && rneedsContext.test( selector ) ?
  2420. jQuery( selector ) :
  2421. selector || [],
  2422. false
  2423. ).length;
  2424. }
  2425. } );
  2426. // Initialize a jQuery object
  2427. // A central reference to the root jQuery(document)
  2428. var rootjQuery,
  2429. // A simple way to check for HTML strings
  2430. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2431. // Strict HTML recognition (#11290: must start with <)
  2432. // Shortcut simple #id case for speed
  2433. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  2434. init = jQuery.fn.init = function( selector, context, root ) {
  2435. var match, elem;
  2436. // HANDLE: $(""), $(null), $(undefined), $(false)
  2437. if ( !selector ) {
  2438. return this;
  2439. }
  2440. // Method init() accepts an alternate rootjQuery
  2441. // so migrate can support jQuery.sub (gh-2101)
  2442. root = root || rootjQuery;
  2443. // Handle HTML strings
  2444. if ( typeof selector === "string" ) {
  2445. if ( selector[ 0 ] === "<" &&
  2446. selector[ selector.length - 1 ] === ">" &&
  2447. selector.length >= 3 ) {
  2448. // Assume that strings that start and end with <> are HTML and skip the regex check
  2449. match = [ null, selector, null ];
  2450. } else {
  2451. match = rquickExpr.exec( selector );
  2452. }
  2453. // Match html or make sure no context is specified for #id
  2454. if ( match && ( match[ 1 ] || !context ) ) {
  2455. // HANDLE: $(html) -> $(array)
  2456. if ( match[ 1 ] ) {
  2457. context = context instanceof jQuery ? context[ 0 ] : context;
  2458. // Option to run scripts is true for back-compat
  2459. // Intentionally let the error be thrown if parseHTML is not present
  2460. jQuery.merge( this, jQuery.parseHTML(
  2461. match[ 1 ],
  2462. context && context.nodeType ? context.ownerDocument || context : document,
  2463. true
  2464. ) );
  2465. // HANDLE: $(html, props)
  2466. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  2467. for ( match in context ) {
  2468. // Properties of context are called as methods if possible
  2469. if ( isFunction( this[ match ] ) ) {
  2470. this[ match ]( context[ match ] );
  2471. // ...and otherwise set as attributes
  2472. } else {
  2473. this.attr( match, context[ match ] );
  2474. }
  2475. }
  2476. }
  2477. return this;
  2478. // HANDLE: $(#id)
  2479. } else {
  2480. elem = document.getElementById( match[ 2 ] );
  2481. if ( elem ) {
  2482. // Inject the element directly into the jQuery object
  2483. this[ 0 ] = elem;
  2484. this.length = 1;
  2485. }
  2486. return this;
  2487. }
  2488. // HANDLE: $(expr, $(...))
  2489. } else if ( !context || context.jquery ) {
  2490. return ( context || root ).find( selector );
  2491. // HANDLE: $(expr, context)
  2492. // (which is just equivalent to: $(context).find(expr)
  2493. } else {
  2494. return this.constructor( context ).find( selector );
  2495. }
  2496. // HANDLE: $(DOMElement)
  2497. } else if ( selector.nodeType ) {
  2498. this[ 0 ] = selector;
  2499. this.length = 1;
  2500. return this;
  2501. // HANDLE: $(function)
  2502. // Shortcut for document ready
  2503. } else if ( isFunction( selector ) ) {
  2504. return root.ready !== undefined ?
  2505. root.ready( selector ) :
  2506. // Execute immediately if ready is not present
  2507. selector( jQuery );
  2508. }
  2509. return jQuery.makeArray( selector, this );
  2510. };
  2511. // Give the init function the jQuery prototype for later instantiation
  2512. init.prototype = jQuery.fn;
  2513. // Initialize central reference
  2514. rootjQuery = jQuery( document );
  2515. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2516. // Methods guaranteed to produce a unique set when starting from a unique set
  2517. guaranteedUnique = {
  2518. children: true,
  2519. contents: true,
  2520. next: true,
  2521. prev: true
  2522. };
  2523. jQuery.fn.extend( {
  2524. has: function( target ) {
  2525. var targets = jQuery( target, this ),
  2526. l = targets.length;
  2527. return this.filter( function() {
  2528. var i = 0;
  2529. for ( ; i < l; i++ ) {
  2530. if ( jQuery.contains( this, targets[ i ] ) ) {
  2531. return true;
  2532. }
  2533. }
  2534. } );
  2535. },
  2536. closest: function( selectors, context ) {
  2537. var cur,
  2538. i = 0,
  2539. l = this.length,
  2540. matched = [],
  2541. targets = typeof selectors !== "string" && jQuery( selectors );
  2542. // Positional selectors never match, since there's no _selection_ context
  2543. if ( !rneedsContext.test( selectors ) ) {
  2544. for ( ; i < l; i++ ) {
  2545. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  2546. // Always skip document fragments
  2547. if ( cur.nodeType < 11 && ( targets ?
  2548. targets.index( cur ) > -1 :
  2549. // Don't pass non-elements to Sizzle
  2550. cur.nodeType === 1 &&
  2551. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  2552. matched.push( cur );
  2553. break;
  2554. }
  2555. }
  2556. }
  2557. }
  2558. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  2559. },
  2560. // Determine the position of an element within the set
  2561. index: function( elem ) {
  2562. // No argument, return index in parent
  2563. if ( !elem ) {
  2564. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  2565. }
  2566. // Index in selector
  2567. if ( typeof elem === "string" ) {
  2568. return indexOf.call( jQuery( elem ), this[ 0 ] );
  2569. }
  2570. // Locate the position of the desired element
  2571. return indexOf.call( this,
  2572. // If it receives a jQuery object, the first element is used
  2573. elem.jquery ? elem[ 0 ] : elem
  2574. );
  2575. },
  2576. add: function( selector, context ) {
  2577. return this.pushStack(
  2578. jQuery.uniqueSort(
  2579. jQuery.merge( this.get(), jQuery( selector, context ) )
  2580. )
  2581. );
  2582. },
  2583. addBack: function( selector ) {
  2584. return this.add( selector == null ?
  2585. this.prevObject : this.prevObject.filter( selector )
  2586. );
  2587. }
  2588. } );
  2589. function sibling( cur, dir ) {
  2590. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  2591. return cur;
  2592. }
  2593. jQuery.each( {
  2594. parent: function( elem ) {
  2595. var parent = elem.parentNode;
  2596. return parent && parent.nodeType !== 11 ? parent : null;
  2597. },
  2598. parents: function( elem ) {
  2599. return dir( elem, "parentNode" );
  2600. },
  2601. parentsUntil: function( elem, i, until ) {
  2602. return dir( elem, "parentNode", until );
  2603. },
  2604. next: function( elem ) {
  2605. return sibling( elem, "nextSibling" );
  2606. },
  2607. prev: function( elem ) {
  2608. return sibling( elem, "previousSibling" );
  2609. },
  2610. nextAll: function( elem ) {
  2611. return dir( elem, "nextSibling" );
  2612. },
  2613. prevAll: function( elem ) {
  2614. return dir( elem, "previousSibling" );
  2615. },
  2616. nextUntil: function( elem, i, until ) {
  2617. return dir( elem, "nextSibling", until );
  2618. },
  2619. prevUntil: function( elem, i, until ) {
  2620. return dir( elem, "previousSibling", until );
  2621. },
  2622. siblings: function( elem ) {
  2623. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  2624. },
  2625. children: function( elem ) {
  2626. return siblings( elem.firstChild );
  2627. },
  2628. contents: function( elem ) {
  2629. if ( typeof elem.contentDocument !== "undefined" ) {
  2630. return elem.contentDocument;
  2631. }
  2632. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  2633. // Treat the template element as a regular one in browsers that
  2634. // don't support it.
  2635. if ( nodeName( elem, "template" ) ) {
  2636. elem = elem.content || elem;
  2637. }
  2638. return jQuery.merge( [], elem.childNodes );
  2639. }
  2640. }, function( name, fn ) {
  2641. jQuery.fn[ name ] = function( until, selector ) {
  2642. var matched = jQuery.map( this, fn, until );
  2643. if ( name.slice( -5 ) !== "Until" ) {
  2644. selector = until;
  2645. }
  2646. if ( selector && typeof selector === "string" ) {
  2647. matched = jQuery.filter( selector, matched );
  2648. }
  2649. if ( this.length > 1 ) {
  2650. // Remove duplicates
  2651. if ( !guaranteedUnique[ name ] ) {
  2652. jQuery.uniqueSort( matched );
  2653. }
  2654. // Reverse order for parents* and prev-derivatives
  2655. if ( rparentsprev.test( name ) ) {
  2656. matched.reverse();
  2657. }
  2658. }
  2659. return this.pushStack( matched );
  2660. };
  2661. } );
  2662. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  2663. // Convert String-formatted options into Object-formatted ones
  2664. function createOptions( options ) {
  2665. var object = {};
  2666. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  2667. object[ flag ] = true;
  2668. } );
  2669. return object;
  2670. }
  2671. /*
  2672. * Create a callback list using the following parameters:
  2673. *
  2674. * options: an optional list of space-separated options that will change how
  2675. * the callback list behaves or a more traditional option object
  2676. *
  2677. * By default a callback list will act like an event callback list and can be
  2678. * "fired" multiple times.
  2679. *
  2680. * Possible options:
  2681. *
  2682. * once: will ensure the callback list can only be fired once (like a Deferred)
  2683. *
  2684. * memory: will keep track of previous values and will call any callback added
  2685. * after the list has been fired right away with the latest "memorized"
  2686. * values (like a Deferred)
  2687. *
  2688. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2689. *
  2690. * stopOnFalse: interrupt callings when a callback returns false
  2691. *
  2692. */
  2693. jQuery.Callbacks = function( options ) {
  2694. // Convert options from String-formatted to Object-formatted if needed
  2695. // (we check in cache first)
  2696. options = typeof options === "string" ?
  2697. createOptions( options ) :
  2698. jQuery.extend( {}, options );
  2699. var // Flag to know if list is currently firing
  2700. firing,
  2701. // Last fire value for non-forgettable lists
  2702. memory,
  2703. // Flag to know if list was already fired
  2704. fired,
  2705. // Flag to prevent firing
  2706. locked,
  2707. // Actual callback list
  2708. list = [],
  2709. // Queue of execution data for repeatable lists
  2710. queue = [],
  2711. // Index of currently firing callback (modified by add/remove as needed)
  2712. firingIndex = -1,
  2713. // Fire callbacks
  2714. fire = function() {
  2715. // Enforce single-firing
  2716. locked = locked || options.once;
  2717. // Execute callbacks for all pending executions,
  2718. // respecting firingIndex overrides and runtime changes
  2719. fired = firing = true;
  2720. for ( ; queue.length; firingIndex = -1 ) {
  2721. memory = queue.shift();
  2722. while ( ++firingIndex < list.length ) {
  2723. // Run callback and check for early termination
  2724. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  2725. options.stopOnFalse ) {
  2726. // Jump to end and forget the data so .add doesn't re-fire
  2727. firingIndex = list.length;
  2728. memory = false;
  2729. }
  2730. }
  2731. }
  2732. // Forget the data if we're done with it
  2733. if ( !options.memory ) {
  2734. memory = false;
  2735. }
  2736. firing = false;
  2737. // Clean up if we're done firing for good
  2738. if ( locked ) {
  2739. // Keep an empty list if we have data for future add calls
  2740. if ( memory ) {
  2741. list = [];
  2742. // Otherwise, this object is spent
  2743. } else {
  2744. list = "";
  2745. }
  2746. }
  2747. },
  2748. // Actual Callbacks object
  2749. self = {
  2750. // Add a callback or a collection of callbacks to the list
  2751. add: function() {
  2752. if ( list ) {
  2753. // If we have memory from a past run, we should fire after adding
  2754. if ( memory && !firing ) {
  2755. firingIndex = list.length - 1;
  2756. queue.push( memory );
  2757. }
  2758. ( function add( args ) {
  2759. jQuery.each( args, function( _, arg ) {
  2760. if ( isFunction( arg ) ) {
  2761. if ( !options.unique || !self.has( arg ) ) {
  2762. list.push( arg );
  2763. }
  2764. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  2765. // Inspect recursively
  2766. add( arg );
  2767. }
  2768. } );
  2769. } )( arguments );
  2770. if ( memory && !firing ) {
  2771. fire();
  2772. }
  2773. }
  2774. return this;
  2775. },
  2776. // Remove a callback from the list
  2777. remove: function() {
  2778. jQuery.each( arguments, function( _, arg ) {
  2779. var index;
  2780. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2781. list.splice( index, 1 );
  2782. // Handle firing indexes
  2783. if ( index <= firingIndex ) {
  2784. firingIndex--;
  2785. }
  2786. }
  2787. } );
  2788. return this;
  2789. },
  2790. // Check if a given callback is in the list.
  2791. // If no argument is given, return whether or not list has callbacks attached.
  2792. has: function( fn ) {
  2793. return fn ?
  2794. jQuery.inArray( fn, list ) > -1 :
  2795. list.length > 0;
  2796. },
  2797. // Remove all callbacks from the list
  2798. empty: function() {
  2799. if ( list ) {
  2800. list = [];
  2801. }
  2802. return this;
  2803. },
  2804. // Disable .fire and .add
  2805. // Abort any current/pending executions
  2806. // Clear all callbacks and values
  2807. disable: function() {
  2808. locked = queue = [];
  2809. list = memory = "";
  2810. return this;
  2811. },
  2812. disabled: function() {
  2813. return !list;
  2814. },
  2815. // Disable .fire
  2816. // Also disable .add unless we have memory (since it would have no effect)
  2817. // Abort any pending executions
  2818. lock: function() {
  2819. locked = queue = [];
  2820. if ( !memory && !firing ) {
  2821. list = memory = "";
  2822. }
  2823. return this;
  2824. },
  2825. locked: function() {
  2826. return !!locked;
  2827. },
  2828. // Call all callbacks with the given context and arguments
  2829. fireWith: function( context, args ) {
  2830. if ( !locked ) {
  2831. args = args || [];
  2832. args = [ context, args.slice ? args.slice() : args ];
  2833. queue.push( args );
  2834. if ( !firing ) {
  2835. fire();
  2836. }
  2837. }
  2838. return this;
  2839. },
  2840. // Call all the callbacks with the given arguments
  2841. fire: function() {
  2842. self.fireWith( this, arguments );
  2843. return this;
  2844. },
  2845. // To know if the callbacks have already been called at least once
  2846. fired: function() {
  2847. return !!fired;
  2848. }
  2849. };
  2850. return self;
  2851. };
  2852. function Identity( v ) {
  2853. return v;
  2854. }
  2855. function Thrower( ex ) {
  2856. throw ex;
  2857. }
  2858. function adoptValue( value, resolve, reject, noValue ) {
  2859. var method;
  2860. try {
  2861. // Check for promise aspect first to privilege synchronous behavior
  2862. if ( value && isFunction( ( method = value.promise ) ) ) {
  2863. method.call( value ).done( resolve ).fail( reject );
  2864. // Other thenables
  2865. } else if ( value && isFunction( ( method = value.then ) ) ) {
  2866. method.call( value, resolve, reject );
  2867. // Other non-thenables
  2868. } else {
  2869. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  2870. // * false: [ value ].slice( 0 ) => resolve( value )
  2871. // * true: [ value ].slice( 1 ) => resolve()
  2872. resolve.apply( undefined, [ value ].slice( noValue ) );
  2873. }
  2874. // For Promises/A+, convert exceptions into rejections
  2875. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  2876. // Deferred#then to conditionally suppress rejection.
  2877. } catch ( value ) {
  2878. // Support: Android 4.0 only
  2879. // Strict mode functions invoked without .call/.apply get global-object context
  2880. reject.apply( undefined, [ value ] );
  2881. }
  2882. }
  2883. jQuery.extend( {
  2884. Deferred: function( func ) {
  2885. var tuples = [
  2886. // action, add listener, callbacks,
  2887. // ... .then handlers, argument index, [final state]
  2888. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  2889. jQuery.Callbacks( "memory" ), 2 ],
  2890. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  2891. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  2892. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  2893. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  2894. ],
  2895. state = "pending",
  2896. promise = {
  2897. state: function() {
  2898. return state;
  2899. },
  2900. always: function() {
  2901. deferred.done( arguments ).fail( arguments );
  2902. return this;
  2903. },
  2904. "catch": function( fn ) {
  2905. return promise.then( null, fn );
  2906. },
  2907. // Keep pipe for back-compat
  2908. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  2909. var fns = arguments;
  2910. return jQuery.Deferred( function( newDefer ) {
  2911. jQuery.each( tuples, function( i, tuple ) {
  2912. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  2913. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  2914. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  2915. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  2916. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  2917. deferred[ tuple[ 1 ] ]( function() {
  2918. var returned = fn && fn.apply( this, arguments );
  2919. if ( returned && isFunction( returned.promise ) ) {
  2920. returned.promise()
  2921. .progress( newDefer.notify )
  2922. .done( newDefer.resolve )
  2923. .fail( newDefer.reject );
  2924. } else {
  2925. newDefer[ tuple[ 0 ] + "With" ](
  2926. this,
  2927. fn ? [ returned ] : arguments
  2928. );
  2929. }
  2930. } );
  2931. } );
  2932. fns = null;
  2933. } ).promise();
  2934. },
  2935. then: function( onFulfilled, onRejected, onProgress ) {
  2936. var maxDepth = 0;
  2937. function resolve( depth, deferred, handler, special ) {
  2938. return function() {
  2939. var that = this,
  2940. args = arguments,
  2941. mightThrow = function() {
  2942. var returned, then;
  2943. // Support: Promises/A+ section 2.3.3.3.3
  2944. // https://promisesaplus.com/#point-59
  2945. // Ignore double-resolution attempts
  2946. if ( depth < maxDepth ) {
  2947. return;
  2948. }
  2949. returned = handler.apply( that, args );
  2950. // Support: Promises/A+ section 2.3.1
  2951. // https://promisesaplus.com/#point-48
  2952. if ( returned === deferred.promise() ) {
  2953. throw new TypeError( "Thenable self-resolution" );
  2954. }
  2955. // Support: Promises/A+ sections 2.3.3.1, 3.5
  2956. // https://promisesaplus.com/#point-54
  2957. // https://promisesaplus.com/#point-75
  2958. // Retrieve `then` only once
  2959. then = returned &&
  2960. // Support: Promises/A+ section 2.3.4
  2961. // https://promisesaplus.com/#point-64
  2962. // Only check objects and functions for thenability
  2963. ( typeof returned === "object" ||
  2964. typeof returned === "function" ) &&
  2965. returned.then;
  2966. // Handle a returned thenable
  2967. if ( isFunction( then ) ) {
  2968. // Special processors (notify) just wait for resolution
  2969. if ( special ) {
  2970. then.call(
  2971. returned,
  2972. resolve( maxDepth, deferred, Identity, special ),
  2973. resolve( maxDepth, deferred, Thrower, special )
  2974. );
  2975. // Normal processors (resolve) also hook into progress
  2976. } else {
  2977. // ...and disregard older resolution values
  2978. maxDepth++;
  2979. then.call(
  2980. returned,
  2981. resolve( maxDepth, deferred, Identity, special ),
  2982. resolve( maxDepth, deferred, Thrower, special ),
  2983. resolve( maxDepth, deferred, Identity,
  2984. deferred.notifyWith )
  2985. );
  2986. }
  2987. // Handle all other returned values
  2988. } else {
  2989. // Only substitute handlers pass on context
  2990. // and multiple values (non-spec behavior)
  2991. if ( handler !== Identity ) {
  2992. that = undefined;
  2993. args = [ returned ];
  2994. }
  2995. // Process the value(s)
  2996. // Default process is resolve
  2997. ( special || deferred.resolveWith )( that, args );
  2998. }
  2999. },
  3000. // Only normal processors (resolve) catch and reject exceptions
  3001. process = special ?
  3002. mightThrow :
  3003. function() {
  3004. try {
  3005. mightThrow();
  3006. } catch ( e ) {
  3007. if ( jQuery.Deferred.exceptionHook ) {
  3008. jQuery.Deferred.exceptionHook( e,
  3009. process.stackTrace );
  3010. }
  3011. // Support: Promises/A+ section 2.3.3.3.4.1
  3012. // https://promisesaplus.com/#point-61
  3013. // Ignore post-resolution exceptions
  3014. if ( depth + 1 >= maxDepth ) {
  3015. // Only substitute handlers pass on context
  3016. // and multiple values (non-spec behavior)
  3017. if ( handler !== Thrower ) {
  3018. that = undefined;
  3019. args = [ e ];
  3020. }
  3021. deferred.rejectWith( that, args );
  3022. }
  3023. }
  3024. };
  3025. // Support: Promises/A+ section 2.3.3.3.1
  3026. // https://promisesaplus.com/#point-57
  3027. // Re-resolve promises immediately to dodge false rejection from
  3028. // subsequent errors
  3029. if ( depth ) {
  3030. process();
  3031. } else {
  3032. // Call an optional hook to record the stack, in case of exception
  3033. // since it's otherwise lost when execution goes async
  3034. if ( jQuery.Deferred.getStackHook ) {
  3035. process.stackTrace = jQuery.Deferred.getStackHook();
  3036. }
  3037. window.setTimeout( process );
  3038. }
  3039. };
  3040. }
  3041. return jQuery.Deferred( function( newDefer ) {
  3042. // progress_handlers.add( ... )
  3043. tuples[ 0 ][ 3 ].add(
  3044. resolve(
  3045. 0,
  3046. newDefer,
  3047. isFunction( onProgress ) ?
  3048. onProgress :
  3049. Identity,
  3050. newDefer.notifyWith
  3051. )
  3052. );
  3053. // fulfilled_handlers.add( ... )
  3054. tuples[ 1 ][ 3 ].add(
  3055. resolve(
  3056. 0,
  3057. newDefer,
  3058. isFunction( onFulfilled ) ?
  3059. onFulfilled :
  3060. Identity
  3061. )
  3062. );
  3063. // rejected_handlers.add( ... )
  3064. tuples[ 2 ][ 3 ].add(
  3065. resolve(
  3066. 0,
  3067. newDefer,
  3068. isFunction( onRejected ) ?
  3069. onRejected :
  3070. Thrower
  3071. )
  3072. );
  3073. } ).promise();
  3074. },
  3075. // Get a promise for this deferred
  3076. // If obj is provided, the promise aspect is added to the object
  3077. promise: function( obj ) {
  3078. return obj != null ? jQuery.extend( obj, promise ) : promise;
  3079. }
  3080. },
  3081. deferred = {};
  3082. // Add list-specific methods
  3083. jQuery.each( tuples, function( i, tuple ) {
  3084. var list = tuple[ 2 ],
  3085. stateString = tuple[ 5 ];
  3086. // promise.progress = list.add
  3087. // promise.done = list.add
  3088. // promise.fail = list.add
  3089. promise[ tuple[ 1 ] ] = list.add;
  3090. // Handle state
  3091. if ( stateString ) {
  3092. list.add(
  3093. function() {
  3094. // state = "resolved" (i.e., fulfilled)
  3095. // state = "rejected"
  3096. state = stateString;
  3097. },
  3098. // rejected_callbacks.disable
  3099. // fulfilled_callbacks.disable
  3100. tuples[ 3 - i ][ 2 ].disable,
  3101. // rejected_handlers.disable
  3102. // fulfilled_handlers.disable
  3103. tuples[ 3 - i ][ 3 ].disable,
  3104. // progress_callbacks.lock
  3105. tuples[ 0 ][ 2 ].lock,
  3106. // progress_handlers.lock
  3107. tuples[ 0 ][ 3 ].lock
  3108. );
  3109. }
  3110. // progress_handlers.fire
  3111. // fulfilled_handlers.fire
  3112. // rejected_handlers.fire
  3113. list.add( tuple[ 3 ].fire );
  3114. // deferred.notify = function() { deferred.notifyWith(...) }
  3115. // deferred.resolve = function() { deferred.resolveWith(...) }
  3116. // deferred.reject = function() { deferred.rejectWith(...) }
  3117. deferred[ tuple[ 0 ] ] = function() {
  3118. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  3119. return this;
  3120. };
  3121. // deferred.notifyWith = list.fireWith
  3122. // deferred.resolveWith = list.fireWith
  3123. // deferred.rejectWith = list.fireWith
  3124. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  3125. } );
  3126. // Make the deferred a promise
  3127. promise.promise( deferred );
  3128. // Call given func if any
  3129. if ( func ) {
  3130. func.call( deferred, deferred );
  3131. }
  3132. // All done!
  3133. return deferred;
  3134. },
  3135. // Deferred helper
  3136. when: function( singleValue ) {
  3137. var
  3138. // count of uncompleted subordinates
  3139. remaining = arguments.length,
  3140. // count of unprocessed arguments
  3141. i = remaining,
  3142. // subordinate fulfillment data
  3143. resolveContexts = Array( i ),
  3144. resolveValues = slice.call( arguments ),
  3145. // the master Deferred
  3146. master = jQuery.Deferred(),
  3147. // subordinate callback factory
  3148. updateFunc = function( i ) {
  3149. return function( value ) {
  3150. resolveContexts[ i ] = this;
  3151. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  3152. if ( !( --remaining ) ) {
  3153. master.resolveWith( resolveContexts, resolveValues );
  3154. }
  3155. };
  3156. };
  3157. // Single- and empty arguments are adopted like Promise.resolve
  3158. if ( remaining <= 1 ) {
  3159. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  3160. !remaining );
  3161. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  3162. if ( master.state() === "pending" ||
  3163. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  3164. return master.then();
  3165. }
  3166. }
  3167. // Multiple arguments are aggregated like Promise.all array elements
  3168. while ( i-- ) {
  3169. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  3170. }
  3171. return master.promise();
  3172. }
  3173. } );
  3174. // These usually indicate a programmer mistake during development,
  3175. // warn about them ASAP rather than swallowing them by default.
  3176. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  3177. jQuery.Deferred.exceptionHook = function( error, stack ) {
  3178. // Support: IE 8 - 9 only
  3179. // Console exists when dev tools are open, which can happen at any time
  3180. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  3181. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  3182. }
  3183. };
  3184. jQuery.readyException = function( error ) {
  3185. window.setTimeout( function() {
  3186. throw error;
  3187. } );
  3188. };
  3189. // The deferred used on DOM ready
  3190. var readyList = jQuery.Deferred();
  3191. jQuery.fn.ready = function( fn ) {
  3192. readyList
  3193. .then( fn )
  3194. // Wrap jQuery.readyException in a function so that the lookup
  3195. // happens at the time of error handling instead of callback
  3196. // registration.
  3197. .catch( function( error ) {
  3198. jQuery.readyException( error );
  3199. } );
  3200. return this;
  3201. };
  3202. jQuery.extend( {
  3203. // Is the DOM ready to be used? Set to true once it occurs.
  3204. isReady: false,
  3205. // A counter to track how many items to wait for before
  3206. // the ready event fires. See #6781
  3207. readyWait: 1,
  3208. // Handle when the DOM is ready
  3209. ready: function( wait ) {
  3210. // Abort if there are pending holds or we're already ready
  3211. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  3212. return;
  3213. }
  3214. // Remember that the DOM is ready
  3215. jQuery.isReady = true;
  3216. // If a normal DOM Ready event fired, decrement, and wait if need be
  3217. if ( wait !== true && --jQuery.readyWait > 0 ) {
  3218. return;
  3219. }
  3220. // If there are functions bound, to execute
  3221. readyList.resolveWith( document, [ jQuery ] );
  3222. }
  3223. } );
  3224. jQuery.ready.then = readyList.then;
  3225. // The ready event handler and self cleanup method
  3226. function completed() {
  3227. document.removeEventListener( "DOMContentLoaded", completed );
  3228. window.removeEventListener( "load", completed );
  3229. jQuery.ready();
  3230. }
  3231. // Catch cases where $(document).ready() is called
  3232. // after the browser event has already occurred.
  3233. // Support: IE <=9 - 10 only
  3234. // Older IE sometimes signals "interactive" too soon
  3235. if ( document.readyState === "complete" ||
  3236. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  3237. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3238. window.setTimeout( jQuery.ready );
  3239. } else {
  3240. // Use the handy event callback
  3241. document.addEventListener( "DOMContentLoaded", completed );
  3242. // A fallback to window.onload, that will always work
  3243. window.addEventListener( "load", completed );
  3244. }
  3245. // Multifunctional method to get and set values of a collection
  3246. // The value/s can optionally be executed if it's a function
  3247. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3248. var i = 0,
  3249. len = elems.length,
  3250. bulk = key == null;
  3251. // Sets many values
  3252. if ( toType( key ) === "object" ) {
  3253. chainable = true;
  3254. for ( i in key ) {
  3255. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  3256. }
  3257. // Sets one value
  3258. } else if ( value !== undefined ) {
  3259. chainable = true;
  3260. if ( !isFunction( value ) ) {
  3261. raw = true;
  3262. }
  3263. if ( bulk ) {
  3264. // Bulk operations run against the entire set
  3265. if ( raw ) {
  3266. fn.call( elems, value );
  3267. fn = null;
  3268. // ...except when executing function values
  3269. } else {
  3270. bulk = fn;
  3271. fn = function( elem, key, value ) {
  3272. return bulk.call( jQuery( elem ), value );
  3273. };
  3274. }
  3275. }
  3276. if ( fn ) {
  3277. for ( ; i < len; i++ ) {
  3278. fn(
  3279. elems[ i ], key, raw ?
  3280. value :
  3281. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  3282. );
  3283. }
  3284. }
  3285. }
  3286. if ( chainable ) {
  3287. return elems;
  3288. }
  3289. // Gets
  3290. if ( bulk ) {
  3291. return fn.call( elems );
  3292. }
  3293. return len ? fn( elems[ 0 ], key ) : emptyGet;
  3294. };
  3295. // Matches dashed string for camelizing
  3296. var rmsPrefix = /^-ms-/,
  3297. rdashAlpha = /-([a-z])/g;
  3298. // Used by camelCase as callback to replace()
  3299. function fcamelCase( all, letter ) {
  3300. return letter.toUpperCase();
  3301. }
  3302. // Convert dashed to camelCase; used by the css and data modules
  3303. // Support: IE <=9 - 11, Edge 12 - 15
  3304. // Microsoft forgot to hump their vendor prefix (#9572)
  3305. function camelCase( string ) {
  3306. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  3307. }
  3308. var acceptData = function( owner ) {
  3309. // Accepts only:
  3310. // - Node
  3311. // - Node.ELEMENT_NODE
  3312. // - Node.DOCUMENT_NODE
  3313. // - Object
  3314. // - Any
  3315. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  3316. };
  3317. function Data() {
  3318. this.expando = jQuery.expando + Data.uid++;
  3319. }
  3320. Data.uid = 1;
  3321. Data.prototype = {
  3322. cache: function( owner ) {
  3323. // Check if the owner object already has a cache
  3324. var value = owner[ this.expando ];
  3325. // If not, create one
  3326. if ( !value ) {
  3327. value = {};
  3328. // We can accept data for non-element nodes in modern browsers,
  3329. // but we should not, see #8335.
  3330. // Always return an empty object.
  3331. if ( acceptData( owner ) ) {
  3332. // If it is a node unlikely to be stringify-ed or looped over
  3333. // use plain assignment
  3334. if ( owner.nodeType ) {
  3335. owner[ this.expando ] = value;
  3336. // Otherwise secure it in a non-enumerable property
  3337. // configurable must be true to allow the property to be
  3338. // deleted when data is removed
  3339. } else {
  3340. Object.defineProperty( owner, this.expando, {
  3341. value: value,
  3342. configurable: true
  3343. } );
  3344. }
  3345. }
  3346. }
  3347. return value;
  3348. },
  3349. set: function( owner, data, value ) {
  3350. var prop,
  3351. cache = this.cache( owner );
  3352. // Handle: [ owner, key, value ] args
  3353. // Always use camelCase key (gh-2257)
  3354. if ( typeof data === "string" ) {
  3355. cache[ camelCase( data ) ] = value;
  3356. // Handle: [ owner, { properties } ] args
  3357. } else {
  3358. // Copy the properties one-by-one to the cache object
  3359. for ( prop in data ) {
  3360. cache[ camelCase( prop ) ] = data[ prop ];
  3361. }
  3362. }
  3363. return cache;
  3364. },
  3365. get: function( owner, key ) {
  3366. return key === undefined ?
  3367. this.cache( owner ) :
  3368. // Always use camelCase key (gh-2257)
  3369. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  3370. },
  3371. access: function( owner, key, value ) {
  3372. // In cases where either:
  3373. //
  3374. // 1. No key was specified
  3375. // 2. A string key was specified, but no value provided
  3376. //
  3377. // Take the "read" path and allow the get method to determine
  3378. // which value to return, respectively either:
  3379. //
  3380. // 1. The entire cache object
  3381. // 2. The data stored at the key
  3382. //
  3383. if ( key === undefined ||
  3384. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  3385. return this.get( owner, key );
  3386. }
  3387. // When the key is not a string, or both a key and value
  3388. // are specified, set or extend (existing objects) with either:
  3389. //
  3390. // 1. An object of properties
  3391. // 2. A key and value
  3392. //
  3393. this.set( owner, key, value );
  3394. // Since the "set" path can have two possible entry points
  3395. // return the expected data based on which path was taken[*]
  3396. return value !== undefined ? value : key;
  3397. },
  3398. remove: function( owner, key ) {
  3399. var i,
  3400. cache = owner[ this.expando ];
  3401. if ( cache === undefined ) {
  3402. return;
  3403. }
  3404. if ( key !== undefined ) {
  3405. // Support array or space separated string of keys
  3406. if ( Array.isArray( key ) ) {
  3407. // If key is an array of keys...
  3408. // We always set camelCase keys, so remove that.
  3409. key = key.map( camelCase );
  3410. } else {
  3411. key = camelCase( key );
  3412. // If a key with the spaces exists, use it.
  3413. // Otherwise, create an array by matching non-whitespace
  3414. key = key in cache ?
  3415. [ key ] :
  3416. ( key.match( rnothtmlwhite ) || [] );
  3417. }
  3418. i = key.length;
  3419. while ( i-- ) {
  3420. delete cache[ key[ i ] ];
  3421. }
  3422. }
  3423. // Remove the expando if there's no more data
  3424. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  3425. // Support: Chrome <=35 - 45
  3426. // Webkit & Blink performance suffers when deleting properties
  3427. // from DOM nodes, so set to undefined instead
  3428. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  3429. if ( owner.nodeType ) {
  3430. owner[ this.expando ] = undefined;
  3431. } else {
  3432. delete owner[ this.expando ];
  3433. }
  3434. }
  3435. },
  3436. hasData: function( owner ) {
  3437. var cache = owner[ this.expando ];
  3438. return cache !== undefined && !jQuery.isEmptyObject( cache );
  3439. }
  3440. };
  3441. var dataPriv = new Data();
  3442. var dataUser = new Data();
  3443. // Implementation Summary
  3444. //
  3445. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  3446. // 2. Improve the module's maintainability by reducing the storage
  3447. // paths to a single mechanism.
  3448. // 3. Use the same single mechanism to support "private" and "user" data.
  3449. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  3450. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  3451. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  3452. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3453. rmultiDash = /[A-Z]/g;
  3454. function getData( data ) {
  3455. if ( data === "true" ) {
  3456. return true;
  3457. }
  3458. if ( data === "false" ) {
  3459. return false;
  3460. }
  3461. if ( data === "null" ) {
  3462. return null;
  3463. }
  3464. // Only convert to a number if it doesn't change the string
  3465. if ( data === +data + "" ) {
  3466. return +data;
  3467. }
  3468. if ( rbrace.test( data ) ) {
  3469. return JSON.parse( data );
  3470. }
  3471. return data;
  3472. }
  3473. function dataAttr( elem, key, data ) {
  3474. var name;
  3475. // If nothing was found internally, try to fetch any
  3476. // data from the HTML5 data-* attribute
  3477. if ( data === undefined && elem.nodeType === 1 ) {
  3478. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  3479. data = elem.getAttribute( name );
  3480. if ( typeof data === "string" ) {
  3481. try {
  3482. data = getData( data );
  3483. } catch ( e ) {}
  3484. // Make sure we set the data so it isn't changed later
  3485. dataUser.set( elem, key, data );
  3486. } else {
  3487. data = undefined;
  3488. }
  3489. }
  3490. return data;
  3491. }
  3492. jQuery.extend( {
  3493. hasData: function( elem ) {
  3494. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  3495. },
  3496. data: function( elem, name, data ) {
  3497. return dataUser.access( elem, name, data );
  3498. },
  3499. removeData: function( elem, name ) {
  3500. dataUser.remove( elem, name );
  3501. },
  3502. // TODO: Now that all calls to _data and _removeData have been replaced
  3503. // with direct calls to dataPriv methods, these can be deprecated.
  3504. _data: function( elem, name, data ) {
  3505. return dataPriv.access( elem, name, data );
  3506. },
  3507. _removeData: function( elem, name ) {
  3508. dataPriv.remove( elem, name );
  3509. }
  3510. } );
  3511. jQuery.fn.extend( {
  3512. data: function( key, value ) {
  3513. var i, name, data,
  3514. elem = this[ 0 ],
  3515. attrs = elem && elem.attributes;
  3516. // Gets all values
  3517. if ( key === undefined ) {
  3518. if ( this.length ) {
  3519. data = dataUser.get( elem );
  3520. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  3521. i = attrs.length;
  3522. while ( i-- ) {
  3523. // Support: IE 11 only
  3524. // The attrs elements can be null (#14894)
  3525. if ( attrs[ i ] ) {
  3526. name = attrs[ i ].name;
  3527. if ( name.indexOf( "data-" ) === 0 ) {
  3528. name = camelCase( name.slice( 5 ) );
  3529. dataAttr( elem, name, data[ name ] );
  3530. }
  3531. }
  3532. }
  3533. dataPriv.set( elem, "hasDataAttrs", true );
  3534. }
  3535. }
  3536. return data;
  3537. }
  3538. // Sets multiple values
  3539. if ( typeof key === "object" ) {
  3540. return this.each( function() {
  3541. dataUser.set( this, key );
  3542. } );
  3543. }
  3544. return access( this, function( value ) {
  3545. var data;
  3546. // The calling jQuery object (element matches) is not empty
  3547. // (and therefore has an element appears at this[ 0 ]) and the
  3548. // `value` parameter was not undefined. An empty jQuery object
  3549. // will result in `undefined` for elem = this[ 0 ] which will
  3550. // throw an exception if an attempt to read a data cache is made.
  3551. if ( elem && value === undefined ) {
  3552. // Attempt to get data from the cache
  3553. // The key will always be camelCased in Data
  3554. data = dataUser.get( elem, key );
  3555. if ( data !== undefined ) {
  3556. return data;
  3557. }
  3558. // Attempt to "discover" the data in
  3559. // HTML5 custom data-* attrs
  3560. data = dataAttr( elem, key );
  3561. if ( data !== undefined ) {
  3562. return data;
  3563. }
  3564. // We tried really hard, but the data doesn't exist.
  3565. return;
  3566. }
  3567. // Set the data...
  3568. this.each( function() {
  3569. // We always store the camelCased key
  3570. dataUser.set( this, key, value );
  3571. } );
  3572. }, null, value, arguments.length > 1, null, true );
  3573. },
  3574. removeData: function( key ) {
  3575. return this.each( function() {
  3576. dataUser.remove( this, key );
  3577. } );
  3578. }
  3579. } );
  3580. jQuery.extend( {
  3581. queue: function( elem, type, data ) {
  3582. var queue;
  3583. if ( elem ) {
  3584. type = ( type || "fx" ) + "queue";
  3585. queue = dataPriv.get( elem, type );
  3586. // Speed up dequeue by getting out quickly if this is just a lookup
  3587. if ( data ) {
  3588. if ( !queue || Array.isArray( data ) ) {
  3589. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  3590. } else {
  3591. queue.push( data );
  3592. }
  3593. }
  3594. return queue || [];
  3595. }
  3596. },
  3597. dequeue: function( elem, type ) {
  3598. type = type || "fx";
  3599. var queue = jQuery.queue( elem, type ),
  3600. startLength = queue.length,
  3601. fn = queue.shift(),
  3602. hooks = jQuery._queueHooks( elem, type ),
  3603. next = function() {
  3604. jQuery.dequeue( elem, type );
  3605. };
  3606. // If the fx queue is dequeued, always remove the progress sentinel
  3607. if ( fn === "inprogress" ) {
  3608. fn = queue.shift();
  3609. startLength--;
  3610. }
  3611. if ( fn ) {
  3612. // Add a progress sentinel to prevent the fx queue from being
  3613. // automatically dequeued
  3614. if ( type === "fx" ) {
  3615. queue.unshift( "inprogress" );
  3616. }
  3617. // Clear up the last queue stop function
  3618. delete hooks.stop;
  3619. fn.call( elem, next, hooks );
  3620. }
  3621. if ( !startLength && hooks ) {
  3622. hooks.empty.fire();
  3623. }
  3624. },
  3625. // Not public - generate a queueHooks object, or return the current one
  3626. _queueHooks: function( elem, type ) {
  3627. var key = type + "queueHooks";
  3628. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  3629. empty: jQuery.Callbacks( "once memory" ).add( function() {
  3630. dataPriv.remove( elem, [ type + "queue", key ] );
  3631. } )
  3632. } );
  3633. }
  3634. } );
  3635. jQuery.fn.extend( {
  3636. queue: function( type, data ) {
  3637. var setter = 2;
  3638. if ( typeof type !== "string" ) {
  3639. data = type;
  3640. type = "fx";
  3641. setter--;
  3642. }
  3643. if ( arguments.length < setter ) {
  3644. return jQuery.queue( this[ 0 ], type );
  3645. }
  3646. return data === undefined ?
  3647. this :
  3648. this.each( function() {
  3649. var queue = jQuery.queue( this, type, data );
  3650. // Ensure a hooks for this queue
  3651. jQuery._queueHooks( this, type );
  3652. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  3653. jQuery.dequeue( this, type );
  3654. }
  3655. } );
  3656. },
  3657. dequeue: function( type ) {
  3658. return this.each( function() {
  3659. jQuery.dequeue( this, type );
  3660. } );
  3661. },
  3662. clearQueue: function( type ) {
  3663. return this.queue( type || "fx", [] );
  3664. },
  3665. // Get a promise resolved when queues of a certain type
  3666. // are emptied (fx is the type by default)
  3667. promise: function( type, obj ) {
  3668. var tmp,
  3669. count = 1,
  3670. defer = jQuery.Deferred(),
  3671. elements = this,
  3672. i = this.length,
  3673. resolve = function() {
  3674. if ( !( --count ) ) {
  3675. defer.resolveWith( elements, [ elements ] );
  3676. }
  3677. };
  3678. if ( typeof type !== "string" ) {
  3679. obj = type;
  3680. type = undefined;
  3681. }
  3682. type = type || "fx";
  3683. while ( i-- ) {
  3684. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  3685. if ( tmp && tmp.empty ) {
  3686. count++;
  3687. tmp.empty.add( resolve );
  3688. }
  3689. }
  3690. resolve();
  3691. return defer.promise( obj );
  3692. }
  3693. } );
  3694. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  3695. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  3696. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3697. var documentElement = document.documentElement;
  3698. var isAttached = function( elem ) {
  3699. return jQuery.contains( elem.ownerDocument, elem );
  3700. },
  3701. composed = { composed: true };
  3702. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  3703. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  3704. // Support: iOS 10.0-10.2 only
  3705. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  3706. // leading to errors. We need to check for `getRootNode`.
  3707. if ( documentElement.getRootNode ) {
  3708. isAttached = function( elem ) {
  3709. return jQuery.contains( elem.ownerDocument, elem ) ||
  3710. elem.getRootNode( composed ) === elem.ownerDocument;
  3711. };
  3712. }
  3713. var isHiddenWithinTree = function( elem, el ) {
  3714. // isHiddenWithinTree might be called from jQuery#filter function;
  3715. // in that case, element will be second argument
  3716. elem = el || elem;
  3717. // Inline style trumps all
  3718. return elem.style.display === "none" ||
  3719. elem.style.display === "" &&
  3720. // Otherwise, check computed style
  3721. // Support: Firefox <=43 - 45
  3722. // Disconnected elements can have computed display: none, so first confirm that elem is
  3723. // in the document.
  3724. isAttached( elem ) &&
  3725. jQuery.css( elem, "display" ) === "none";
  3726. };
  3727. var swap = function( elem, options, callback, args ) {
  3728. var ret, name,
  3729. old = {};
  3730. // Remember the old values, and insert the new ones
  3731. for ( name in options ) {
  3732. old[ name ] = elem.style[ name ];
  3733. elem.style[ name ] = options[ name ];
  3734. }
  3735. ret = callback.apply( elem, args || [] );
  3736. // Revert the old values
  3737. for ( name in options ) {
  3738. elem.style[ name ] = old[ name ];
  3739. }
  3740. return ret;
  3741. };
  3742. function adjustCSS( elem, prop, valueParts, tween ) {
  3743. var adjusted, scale,
  3744. maxIterations = 20,
  3745. currentValue = tween ?
  3746. function() {
  3747. return tween.cur();
  3748. } :
  3749. function() {
  3750. return jQuery.css( elem, prop, "" );
  3751. },
  3752. initial = currentValue(),
  3753. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  3754. // Starting value computation is required for potential unit mismatches
  3755. initialInUnit = elem.nodeType &&
  3756. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  3757. rcssNum.exec( jQuery.css( elem, prop ) );
  3758. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  3759. // Support: Firefox <=54
  3760. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  3761. initial = initial / 2;
  3762. // Trust units reported by jQuery.css
  3763. unit = unit || initialInUnit[ 3 ];
  3764. // Iteratively approximate from a nonzero starting point
  3765. initialInUnit = +initial || 1;
  3766. while ( maxIterations-- ) {
  3767. // Evaluate and update our best guess (doubling guesses that zero out).
  3768. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  3769. jQuery.style( elem, prop, initialInUnit + unit );
  3770. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  3771. maxIterations = 0;
  3772. }
  3773. initialInUnit = initialInUnit / scale;
  3774. }
  3775. initialInUnit = initialInUnit * 2;
  3776. jQuery.style( elem, prop, initialInUnit + unit );
  3777. // Make sure we update the tween properties later on
  3778. valueParts = valueParts || [];
  3779. }
  3780. if ( valueParts ) {
  3781. initialInUnit = +initialInUnit || +initial || 0;
  3782. // Apply relative offset (+=/-=) if specified
  3783. adjusted = valueParts[ 1 ] ?
  3784. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  3785. +valueParts[ 2 ];
  3786. if ( tween ) {
  3787. tween.unit = unit;
  3788. tween.start = initialInUnit;
  3789. tween.end = adjusted;
  3790. }
  3791. }
  3792. return adjusted;
  3793. }
  3794. var defaultDisplayMap = {};
  3795. function getDefaultDisplay( elem ) {
  3796. var temp,
  3797. doc = elem.ownerDocument,
  3798. nodeName = elem.nodeName,
  3799. display = defaultDisplayMap[ nodeName ];
  3800. if ( display ) {
  3801. return display;
  3802. }
  3803. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  3804. display = jQuery.css( temp, "display" );
  3805. temp.parentNode.removeChild( temp );
  3806. if ( display === "none" ) {
  3807. display = "block";
  3808. }
  3809. defaultDisplayMap[ nodeName ] = display;
  3810. return display;
  3811. }
  3812. function showHide( elements, show ) {
  3813. var display, elem,
  3814. values = [],
  3815. index = 0,
  3816. length = elements.length;
  3817. // Determine new display value for elements that need to change
  3818. for ( ; index < length; index++ ) {
  3819. elem = elements[ index ];
  3820. if ( !elem.style ) {
  3821. continue;
  3822. }
  3823. display = elem.style.display;
  3824. if ( show ) {
  3825. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  3826. // check is required in this first loop unless we have a nonempty display value (either
  3827. // inline or about-to-be-restored)
  3828. if ( display === "none" ) {
  3829. values[ index ] = dataPriv.get( elem, "display" ) || null;
  3830. if ( !values[ index ] ) {
  3831. elem.style.display = "";
  3832. }
  3833. }
  3834. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  3835. values[ index ] = getDefaultDisplay( elem );
  3836. }
  3837. } else {
  3838. if ( display !== "none" ) {
  3839. values[ index ] = "none";
  3840. // Remember what we're overwriting
  3841. dataPriv.set( elem, "display", display );
  3842. }
  3843. }
  3844. }
  3845. // Set the display of the elements in a second loop to avoid constant reflow
  3846. for ( index = 0; index < length; index++ ) {
  3847. if ( values[ index ] != null ) {
  3848. elements[ index ].style.display = values[ index ];
  3849. }
  3850. }
  3851. return elements;
  3852. }
  3853. jQuery.fn.extend( {
  3854. show: function() {
  3855. return showHide( this, true );
  3856. },
  3857. hide: function() {
  3858. return showHide( this );
  3859. },
  3860. toggle: function( state ) {
  3861. if ( typeof state === "boolean" ) {
  3862. return state ? this.show() : this.hide();
  3863. }
  3864. return this.each( function() {
  3865. if ( isHiddenWithinTree( this ) ) {
  3866. jQuery( this ).show();
  3867. } else {
  3868. jQuery( this ).hide();
  3869. }
  3870. } );
  3871. }
  3872. } );
  3873. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  3874. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  3875. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  3876. // We have to close these tags to support XHTML (#13200)
  3877. var wrapMap = {
  3878. // Support: IE <=9 only
  3879. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  3880. // XHTML parsers do not magically insert elements in the
  3881. // same way that tag soup parsers do. So we cannot shorten
  3882. // this by omitting <tbody> or other required elements.
  3883. thead: [ 1, "<table>", "</table>" ],
  3884. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  3885. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  3886. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  3887. _default: [ 0, "", "" ]
  3888. };
  3889. // Support: IE <=9 only
  3890. wrapMap.optgroup = wrapMap.option;
  3891. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  3892. wrapMap.th = wrapMap.td;
  3893. function getAll( context, tag ) {
  3894. // Support: IE <=9 - 11 only
  3895. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  3896. var ret;
  3897. if ( typeof context.getElementsByTagName !== "undefined" ) {
  3898. ret = context.getElementsByTagName( tag || "*" );
  3899. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  3900. ret = context.querySelectorAll( tag || "*" );
  3901. } else {
  3902. ret = [];
  3903. }
  3904. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  3905. return jQuery.merge( [ context ], ret );
  3906. }
  3907. return ret;
  3908. }
  3909. // Mark scripts as having already been evaluated
  3910. function setGlobalEval( elems, refElements ) {
  3911. var i = 0,
  3912. l = elems.length;
  3913. for ( ; i < l; i++ ) {
  3914. dataPriv.set(
  3915. elems[ i ],
  3916. "globalEval",
  3917. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  3918. );
  3919. }
  3920. }
  3921. var rhtml = /<|&#?\w+;/;
  3922. function buildFragment( elems, context, scripts, selection, ignored ) {
  3923. var elem, tmp, tag, wrap, attached, j,
  3924. fragment = context.createDocumentFragment(),
  3925. nodes = [],
  3926. i = 0,
  3927. l = elems.length;
  3928. for ( ; i < l; i++ ) {
  3929. elem = elems[ i ];
  3930. if ( elem || elem === 0 ) {
  3931. // Add nodes directly
  3932. if ( toType( elem ) === "object" ) {
  3933. // Support: Android <=4.0 only, PhantomJS 1 only
  3934. // push.apply(_, arraylike) throws on ancient WebKit
  3935. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  3936. // Convert non-html into a text node
  3937. } else if ( !rhtml.test( elem ) ) {
  3938. nodes.push( context.createTextNode( elem ) );
  3939. // Convert html into DOM nodes
  3940. } else {
  3941. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  3942. // Deserialize a standard representation
  3943. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  3944. wrap = wrapMap[ tag ] || wrapMap._default;
  3945. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  3946. // Descend through wrappers to the right content
  3947. j = wrap[ 0 ];
  3948. while ( j-- ) {
  3949. tmp = tmp.lastChild;
  3950. }
  3951. // Support: Android <=4.0 only, PhantomJS 1 only
  3952. // push.apply(_, arraylike) throws on ancient WebKit
  3953. jQuery.merge( nodes, tmp.childNodes );
  3954. // Remember the top-level container
  3955. tmp = fragment.firstChild;
  3956. // Ensure the created nodes are orphaned (#12392)
  3957. tmp.textContent = "";
  3958. }
  3959. }
  3960. }
  3961. // Remove wrapper from fragment
  3962. fragment.textContent = "";
  3963. i = 0;
  3964. while ( ( elem = nodes[ i++ ] ) ) {
  3965. // Skip elements already in the context collection (trac-4087)
  3966. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  3967. if ( ignored ) {
  3968. ignored.push( elem );
  3969. }
  3970. continue;
  3971. }
  3972. attached = isAttached( elem );
  3973. // Append to fragment
  3974. tmp = getAll( fragment.appendChild( elem ), "script" );
  3975. // Preserve script evaluation history
  3976. if ( attached ) {
  3977. setGlobalEval( tmp );
  3978. }
  3979. // Capture executables
  3980. if ( scripts ) {
  3981. j = 0;
  3982. while ( ( elem = tmp[ j++ ] ) ) {
  3983. if ( rscriptType.test( elem.type || "" ) ) {
  3984. scripts.push( elem );
  3985. }
  3986. }
  3987. }
  3988. }
  3989. return fragment;
  3990. }
  3991. ( function() {
  3992. var fragment = document.createDocumentFragment(),
  3993. div = fragment.appendChild( document.createElement( "div" ) ),
  3994. input = document.createElement( "input" );
  3995. // Support: Android 4.0 - 4.3 only
  3996. // Check state lost if the name is set (#11217)
  3997. // Support: Windows Web Apps (WWA)
  3998. // `name` and `type` must use .setAttribute for WWA (#14901)
  3999. input.setAttribute( "type", "radio" );
  4000. input.setAttribute( "checked", "checked" );
  4001. input.setAttribute( "name", "t" );
  4002. div.appendChild( input );
  4003. // Support: Android <=4.1 only
  4004. // Older WebKit doesn't clone checked state correctly in fragments
  4005. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  4006. // Support: IE <=11 only
  4007. // Make sure textarea (and checkbox) defaultValue is properly cloned
  4008. div.innerHTML = "<textarea>x</textarea>";
  4009. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  4010. } )();
  4011. var
  4012. rkeyEvent = /^key/,
  4013. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  4014. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  4015. function returnTrue() {
  4016. return true;
  4017. }
  4018. function returnFalse() {
  4019. return false;
  4020. }
  4021. // Support: IE <=9 - 11+
  4022. // focus() and blur() are asynchronous, except when they are no-op.
  4023. // So expect focus to be synchronous when the element is already active,
  4024. // and blur to be synchronous when the element is not already active.
  4025. // (focus and blur are always synchronous in other supported browsers,
  4026. // this just defines when we can count on it).
  4027. function expectSync( elem, type ) {
  4028. return ( elem === safeActiveElement() ) === ( type === "focus" );
  4029. }
  4030. // Support: IE <=9 only
  4031. // Accessing document.activeElement can throw unexpectedly
  4032. // https://bugs.jquery.com/ticket/13393
  4033. function safeActiveElement() {
  4034. try {
  4035. return document.activeElement;
  4036. } catch ( err ) { }
  4037. }
  4038. function on( elem, types, selector, data, fn, one ) {
  4039. var origFn, type;
  4040. // Types can be a map of types/handlers
  4041. if ( typeof types === "object" ) {
  4042. // ( types-Object, selector, data )
  4043. if ( typeof selector !== "string" ) {
  4044. // ( types-Object, data )
  4045. data = data || selector;
  4046. selector = undefined;
  4047. }
  4048. for ( type in types ) {
  4049. on( elem, type, selector, data, types[ type ], one );
  4050. }
  4051. return elem;
  4052. }
  4053. if ( data == null && fn == null ) {
  4054. // ( types, fn )
  4055. fn = selector;
  4056. data = selector = undefined;
  4057. } else if ( fn == null ) {
  4058. if ( typeof selector === "string" ) {
  4059. // ( types, selector, fn )
  4060. fn = data;
  4061. data = undefined;
  4062. } else {
  4063. // ( types, data, fn )
  4064. fn = data;
  4065. data = selector;
  4066. selector = undefined;
  4067. }
  4068. }
  4069. if ( fn === false ) {
  4070. fn = returnFalse;
  4071. } else if ( !fn ) {
  4072. return elem;
  4073. }
  4074. if ( one === 1 ) {
  4075. origFn = fn;
  4076. fn = function( event ) {
  4077. // Can use an empty set, since event contains the info
  4078. jQuery().off( event );
  4079. return origFn.apply( this, arguments );
  4080. };
  4081. // Use same guid so caller can remove using origFn
  4082. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4083. }
  4084. return elem.each( function() {
  4085. jQuery.event.add( this, types, fn, data, selector );
  4086. } );
  4087. }
  4088. /*
  4089. * Helper functions for managing events -- not part of the public interface.
  4090. * Props to Dean Edwards' addEvent library for many of the ideas.
  4091. */
  4092. jQuery.event = {
  4093. global: {},
  4094. add: function( elem, types, handler, data, selector ) {
  4095. var handleObjIn, eventHandle, tmp,
  4096. events, t, handleObj,
  4097. special, handlers, type, namespaces, origType,
  4098. elemData = dataPriv.get( elem );
  4099. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  4100. if ( !elemData ) {
  4101. return;
  4102. }
  4103. // Caller can pass in an object of custom data in lieu of the handler
  4104. if ( handler.handler ) {
  4105. handleObjIn = handler;
  4106. handler = handleObjIn.handler;
  4107. selector = handleObjIn.selector;
  4108. }
  4109. // Ensure that invalid selectors throw exceptions at attach time
  4110. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  4111. if ( selector ) {
  4112. jQuery.find.matchesSelector( documentElement, selector );
  4113. }
  4114. // Make sure that the handler has a unique ID, used to find/remove it later
  4115. if ( !handler.guid ) {
  4116. handler.guid = jQuery.guid++;
  4117. }
  4118. // Init the element's event structure and main handler, if this is the first
  4119. if ( !( events = elemData.events ) ) {
  4120. events = elemData.events = {};
  4121. }
  4122. if ( !( eventHandle = elemData.handle ) ) {
  4123. eventHandle = elemData.handle = function( e ) {
  4124. // Discard the second event of a jQuery.event.trigger() and
  4125. // when an event is called after a page has unloaded
  4126. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  4127. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  4128. };
  4129. }
  4130. // Handle multiple events separated by a space
  4131. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  4132. t = types.length;
  4133. while ( t-- ) {
  4134. tmp = rtypenamespace.exec( types[ t ] ) || [];
  4135. type = origType = tmp[ 1 ];
  4136. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  4137. // There *must* be a type, no attaching namespace-only handlers
  4138. if ( !type ) {
  4139. continue;
  4140. }
  4141. // If event changes its type, use the special event handlers for the changed type
  4142. special = jQuery.event.special[ type ] || {};
  4143. // If selector defined, determine special event api type, otherwise given type
  4144. type = ( selector ? special.delegateType : special.bindType ) || type;
  4145. // Update special based on newly reset type
  4146. special = jQuery.event.special[ type ] || {};
  4147. // handleObj is passed to all event handlers
  4148. handleObj = jQuery.extend( {
  4149. type: type,
  4150. origType: origType,
  4151. data: data,
  4152. handler: handler,
  4153. guid: handler.guid,
  4154. selector: selector,
  4155. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  4156. namespace: namespaces.join( "." )
  4157. }, handleObjIn );
  4158. // Init the event handler queue if we're the first
  4159. if ( !( handlers = events[ type ] ) ) {
  4160. handlers = events[ type ] = [];
  4161. handlers.delegateCount = 0;
  4162. // Only use addEventListener if the special events handler returns false
  4163. if ( !special.setup ||
  4164. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  4165. if ( elem.addEventListener ) {
  4166. elem.addEventListener( type, eventHandle );
  4167. }
  4168. }
  4169. }
  4170. if ( special.add ) {
  4171. special.add.call( elem, handleObj );
  4172. if ( !handleObj.handler.guid ) {
  4173. handleObj.handler.guid = handler.guid;
  4174. }
  4175. }
  4176. // Add to the element's handler list, delegates in front
  4177. if ( selector ) {
  4178. handlers.splice( handlers.delegateCount++, 0, handleObj );
  4179. } else {
  4180. handlers.push( handleObj );
  4181. }
  4182. // Keep track of which events have ever been used, for event optimization
  4183. jQuery.event.global[ type ] = true;
  4184. }
  4185. },
  4186. // Detach an event or set of events from an element
  4187. remove: function( elem, types, handler, selector, mappedTypes ) {
  4188. var j, origCount, tmp,
  4189. events, t, handleObj,
  4190. special, handlers, type, namespaces, origType,
  4191. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  4192. if ( !elemData || !( events = elemData.events ) ) {
  4193. return;
  4194. }
  4195. // Once for each type.namespace in types; type may be omitted
  4196. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  4197. t = types.length;
  4198. while ( t-- ) {
  4199. tmp = rtypenamespace.exec( types[ t ] ) || [];
  4200. type = origType = tmp[ 1 ];
  4201. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  4202. // Unbind all events (on this namespace, if provided) for the element
  4203. if ( !type ) {
  4204. for ( type in events ) {
  4205. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  4206. }
  4207. continue;
  4208. }
  4209. special = jQuery.event.special[ type ] || {};
  4210. type = ( selector ? special.delegateType : special.bindType ) || type;
  4211. handlers = events[ type ] || [];
  4212. tmp = tmp[ 2 ] &&
  4213. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  4214. // Remove matching events
  4215. origCount = j = handlers.length;
  4216. while ( j-- ) {
  4217. handleObj = handlers[ j ];
  4218. if ( ( mappedTypes || origType === handleObj.origType ) &&
  4219. ( !handler || handler.guid === handleObj.guid ) &&
  4220. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  4221. ( !selector || selector === handleObj.selector ||
  4222. selector === "**" && handleObj.selector ) ) {
  4223. handlers.splice( j, 1 );
  4224. if ( handleObj.selector ) {
  4225. handlers.delegateCount--;
  4226. }
  4227. if ( special.remove ) {
  4228. special.remove.call( elem, handleObj );
  4229. }
  4230. }
  4231. }
  4232. // Remove generic event handler if we removed something and no more handlers exist
  4233. // (avoids potential for endless recursion during removal of special event handlers)
  4234. if ( origCount && !handlers.length ) {
  4235. if ( !special.teardown ||
  4236. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  4237. jQuery.removeEvent( elem, type, elemData.handle );
  4238. }
  4239. delete events[ type ];
  4240. }
  4241. }
  4242. // Remove data and the expando if it's no longer used
  4243. if ( jQuery.isEmptyObject( events ) ) {
  4244. dataPriv.remove( elem, "handle events" );
  4245. }
  4246. },
  4247. dispatch: function( nativeEvent ) {
  4248. // Make a writable jQuery.Event from the native event object
  4249. var event = jQuery.event.fix( nativeEvent );
  4250. var i, j, ret, matched, handleObj, handlerQueue,
  4251. args = new Array( arguments.length ),
  4252. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  4253. special = jQuery.event.special[ event.type ] || {};
  4254. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4255. args[ 0 ] = event;
  4256. for ( i = 1; i < arguments.length; i++ ) {
  4257. args[ i ] = arguments[ i ];
  4258. }
  4259. event.delegateTarget = this;
  4260. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4261. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4262. return;
  4263. }
  4264. // Determine handlers
  4265. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  4266. // Run delegates first; they may want to stop propagation beneath us
  4267. i = 0;
  4268. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  4269. event.currentTarget = matched.elem;
  4270. j = 0;
  4271. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  4272. !event.isImmediatePropagationStopped() ) {
  4273. // If the event is namespaced, then each handler is only invoked if it is
  4274. // specially universal or its namespaces are a superset of the event's.
  4275. if ( !event.rnamespace || handleObj.namespace === false ||
  4276. event.rnamespace.test( handleObj.namespace ) ) {
  4277. event.handleObj = handleObj;
  4278. event.data = handleObj.data;
  4279. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  4280. handleObj.handler ).apply( matched.elem, args );
  4281. if ( ret !== undefined ) {
  4282. if ( ( event.result = ret ) === false ) {
  4283. event.preventDefault();
  4284. event.stopPropagation();
  4285. }
  4286. }
  4287. }
  4288. }
  4289. }
  4290. // Call the postDispatch hook for the mapped type
  4291. if ( special.postDispatch ) {
  4292. special.postDispatch.call( this, event );
  4293. }
  4294. return event.result;
  4295. },
  4296. handlers: function( event, handlers ) {
  4297. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  4298. handlerQueue = [],
  4299. delegateCount = handlers.delegateCount,
  4300. cur = event.target;
  4301. // Find delegate handlers
  4302. if ( delegateCount &&
  4303. // Support: IE <=9
  4304. // Black-hole SVG <use> instance trees (trac-13180)
  4305. cur.nodeType &&
  4306. // Support: Firefox <=42
  4307. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  4308. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  4309. // Support: IE 11 only
  4310. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  4311. !( event.type === "click" && event.button >= 1 ) ) {
  4312. for ( ; cur !== this; cur = cur.parentNode || this ) {
  4313. // Don't check non-elements (#13208)
  4314. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4315. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  4316. matchedHandlers = [];
  4317. matchedSelectors = {};
  4318. for ( i = 0; i < delegateCount; i++ ) {
  4319. handleObj = handlers[ i ];
  4320. // Don't conflict with Object.prototype properties (#13203)
  4321. sel = handleObj.selector + " ";
  4322. if ( matchedSelectors[ sel ] === undefined ) {
  4323. matchedSelectors[ sel ] = handleObj.needsContext ?
  4324. jQuery( sel, this ).index( cur ) > -1 :
  4325. jQuery.find( sel, this, null, [ cur ] ).length;
  4326. }
  4327. if ( matchedSelectors[ sel ] ) {
  4328. matchedHandlers.push( handleObj );
  4329. }
  4330. }
  4331. if ( matchedHandlers.length ) {
  4332. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  4333. }
  4334. }
  4335. }
  4336. }
  4337. // Add the remaining (directly-bound) handlers
  4338. cur = this;
  4339. if ( delegateCount < handlers.length ) {
  4340. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  4341. }
  4342. return handlerQueue;
  4343. },
  4344. addProp: function( name, hook ) {
  4345. Object.defineProperty( jQuery.Event.prototype, name, {
  4346. enumerable: true,
  4347. configurable: true,
  4348. get: isFunction( hook ) ?
  4349. function() {
  4350. if ( this.originalEvent ) {
  4351. return hook( this.originalEvent );
  4352. }
  4353. } :
  4354. function() {
  4355. if ( this.originalEvent ) {
  4356. return this.originalEvent[ name ];
  4357. }
  4358. },
  4359. set: function( value ) {
  4360. Object.defineProperty( this, name, {
  4361. enumerable: true,
  4362. configurable: true,
  4363. writable: true,
  4364. value: value
  4365. } );
  4366. }
  4367. } );
  4368. },
  4369. fix: function( originalEvent ) {
  4370. return originalEvent[ jQuery.expando ] ?
  4371. originalEvent :
  4372. new jQuery.Event( originalEvent );
  4373. },
  4374. special: {
  4375. load: {
  4376. // Prevent triggered image.load events from bubbling to window.load
  4377. noBubble: true
  4378. },
  4379. click: {
  4380. // Utilize native event to ensure correct state for checkable inputs
  4381. setup: function( data ) {
  4382. // For mutual compressibility with _default, replace `this` access with a local var.
  4383. // `|| data` is dead code meant only to preserve the variable through minification.
  4384. var el = this || data;
  4385. // Claim the first handler
  4386. if ( rcheckableType.test( el.type ) &&
  4387. el.click && nodeName( el, "input" ) ) {
  4388. // dataPriv.set( el, "click", ... )
  4389. leverageNative( el, "click", returnTrue );
  4390. }
  4391. // Return false to allow normal processing in the caller
  4392. return false;
  4393. },
  4394. trigger: function( data ) {
  4395. // For mutual compressibility with _default, replace `this` access with a local var.
  4396. // `|| data` is dead code meant only to preserve the variable through minification.
  4397. var el = this || data;
  4398. // Force setup before triggering a click
  4399. if ( rcheckableType.test( el.type ) &&
  4400. el.click && nodeName( el, "input" ) ) {
  4401. leverageNative( el, "click" );
  4402. }
  4403. // Return non-false to allow normal event-path propagation
  4404. return true;
  4405. },
  4406. // For cross-browser consistency, suppress native .click() on links
  4407. // Also prevent it if we're currently inside a leveraged native-event stack
  4408. _default: function( event ) {
  4409. var target = event.target;
  4410. return rcheckableType.test( target.type ) &&
  4411. target.click && nodeName( target, "input" ) &&
  4412. dataPriv.get( target, "click" ) ||
  4413. nodeName( target, "a" );
  4414. }
  4415. },
  4416. beforeunload: {
  4417. postDispatch: function( event ) {
  4418. // Support: Firefox 20+
  4419. // Firefox doesn't alert if the returnValue field is not set.
  4420. if ( event.result !== undefined && event.originalEvent ) {
  4421. event.originalEvent.returnValue = event.result;
  4422. }
  4423. }
  4424. }
  4425. }
  4426. };
  4427. // Ensure the presence of an event listener that handles manually-triggered
  4428. // synthetic events by interrupting progress until reinvoked in response to
  4429. // *native* events that it fires directly, ensuring that state changes have
  4430. // already occurred before other listeners are invoked.
  4431. function leverageNative( el, type, expectSync ) {
  4432. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  4433. if ( !expectSync ) {
  4434. if ( dataPriv.get( el, type ) === undefined ) {
  4435. jQuery.event.add( el, type, returnTrue );
  4436. }
  4437. return;
  4438. }
  4439. // Register the controller as a special universal handler for all event namespaces
  4440. dataPriv.set( el, type, false );
  4441. jQuery.event.add( el, type, {
  4442. namespace: false,
  4443. handler: function( event ) {
  4444. var notAsync, result,
  4445. saved = dataPriv.get( this, type );
  4446. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  4447. // Interrupt processing of the outer synthetic .trigger()ed event
  4448. // Saved data should be false in such cases, but might be a leftover capture object
  4449. // from an async native handler (gh-4350)
  4450. if ( !saved.length ) {
  4451. // Store arguments for use when handling the inner native event
  4452. // There will always be at least one argument (an event object), so this array
  4453. // will not be confused with a leftover capture object.
  4454. saved = slice.call( arguments );
  4455. dataPriv.set( this, type, saved );
  4456. // Trigger the native event and capture its result
  4457. // Support: IE <=9 - 11+
  4458. // focus() and blur() are asynchronous
  4459. notAsync = expectSync( this, type );
  4460. this[ type ]();
  4461. result = dataPriv.get( this, type );
  4462. if ( saved !== result || notAsync ) {
  4463. dataPriv.set( this, type, false );
  4464. } else {
  4465. result = {};
  4466. }
  4467. if ( saved !== result ) {
  4468. // Cancel the outer synthetic event
  4469. event.stopImmediatePropagation();
  4470. event.preventDefault();
  4471. return result.value;
  4472. }
  4473. // If this is an inner synthetic event for an event with a bubbling surrogate
  4474. // (focus or blur), assume that the surrogate already propagated from triggering the
  4475. // native event and prevent that from happening again here.
  4476. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  4477. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  4478. // less bad than duplication.
  4479. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  4480. event.stopPropagation();
  4481. }
  4482. // If this is a native event triggered above, everything is now in order
  4483. // Fire an inner synthetic event with the original arguments
  4484. } else if ( saved.length ) {
  4485. // ...and capture the result
  4486. dataPriv.set( this, type, {
  4487. value: jQuery.event.trigger(
  4488. // Support: IE <=9 - 11+
  4489. // Extend with the prototype to reset the above stopImmediatePropagation()
  4490. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  4491. saved.slice( 1 ),
  4492. this
  4493. )
  4494. } );
  4495. // Abort handling of the native event
  4496. event.stopImmediatePropagation();
  4497. }
  4498. }
  4499. } );
  4500. }
  4501. jQuery.removeEvent = function( elem, type, handle ) {
  4502. // This "if" is needed for plain objects
  4503. if ( elem.removeEventListener ) {
  4504. elem.removeEventListener( type, handle );
  4505. }
  4506. };
  4507. jQuery.Event = function( src, props ) {
  4508. // Allow instantiation without the 'new' keyword
  4509. if ( !( this instanceof jQuery.Event ) ) {
  4510. return new jQuery.Event( src, props );
  4511. }
  4512. // Event object
  4513. if ( src && src.type ) {
  4514. this.originalEvent = src;
  4515. this.type = src.type;
  4516. // Events bubbling up the document may have been marked as prevented
  4517. // by a handler lower down the tree; reflect the correct value.
  4518. this.isDefaultPrevented = src.defaultPrevented ||
  4519. src.defaultPrevented === undefined &&
  4520. // Support: Android <=2.3 only
  4521. src.returnValue === false ?
  4522. returnTrue :
  4523. returnFalse;
  4524. // Create target properties
  4525. // Support: Safari <=6 - 7 only
  4526. // Target should not be a text node (#504, #13143)
  4527. this.target = ( src.target && src.target.nodeType === 3 ) ?
  4528. src.target.parentNode :
  4529. src.target;
  4530. this.currentTarget = src.currentTarget;
  4531. this.relatedTarget = src.relatedTarget;
  4532. // Event type
  4533. } else {
  4534. this.type = src;
  4535. }
  4536. // Put explicitly provided properties onto the event object
  4537. if ( props ) {
  4538. jQuery.extend( this, props );
  4539. }
  4540. // Create a timestamp if incoming event doesn't have one
  4541. this.timeStamp = src && src.timeStamp || Date.now();
  4542. // Mark it as fixed
  4543. this[ jQuery.expando ] = true;
  4544. };
  4545. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4546. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4547. jQuery.Event.prototype = {
  4548. constructor: jQuery.Event,
  4549. isDefaultPrevented: returnFalse,
  4550. isPropagationStopped: returnFalse,
  4551. isImmediatePropagationStopped: returnFalse,
  4552. isSimulated: false,
  4553. preventDefault: function() {
  4554. var e = this.originalEvent;
  4555. this.isDefaultPrevented = returnTrue;
  4556. if ( e && !this.isSimulated ) {
  4557. e.preventDefault();
  4558. }
  4559. },
  4560. stopPropagation: function() {
  4561. var e = this.originalEvent;
  4562. this.isPropagationStopped = returnTrue;
  4563. if ( e && !this.isSimulated ) {
  4564. e.stopPropagation();
  4565. }
  4566. },
  4567. stopImmediatePropagation: function() {
  4568. var e = this.originalEvent;
  4569. this.isImmediatePropagationStopped = returnTrue;
  4570. if ( e && !this.isSimulated ) {
  4571. e.stopImmediatePropagation();
  4572. }
  4573. this.stopPropagation();
  4574. }
  4575. };
  4576. // Includes all common event props including KeyEvent and MouseEvent specific props
  4577. jQuery.each( {
  4578. altKey: true,
  4579. bubbles: true,
  4580. cancelable: true,
  4581. changedTouches: true,
  4582. ctrlKey: true,
  4583. detail: true,
  4584. eventPhase: true,
  4585. metaKey: true,
  4586. pageX: true,
  4587. pageY: true,
  4588. shiftKey: true,
  4589. view: true,
  4590. "char": true,
  4591. code: true,
  4592. charCode: true,
  4593. key: true,
  4594. keyCode: true,
  4595. button: true,
  4596. buttons: true,
  4597. clientX: true,
  4598. clientY: true,
  4599. offsetX: true,
  4600. offsetY: true,
  4601. pointerId: true,
  4602. pointerType: true,
  4603. screenX: true,
  4604. screenY: true,
  4605. targetTouches: true,
  4606. toElement: true,
  4607. touches: true,
  4608. which: function( event ) {
  4609. var button = event.button;
  4610. // Add which for key events
  4611. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  4612. return event.charCode != null ? event.charCode : event.keyCode;
  4613. }
  4614. // Add which for click: 1 === left; 2 === middle; 3 === right
  4615. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  4616. if ( button & 1 ) {
  4617. return 1;
  4618. }
  4619. if ( button & 2 ) {
  4620. return 3;
  4621. }
  4622. if ( button & 4 ) {
  4623. return 2;
  4624. }
  4625. return 0;
  4626. }
  4627. return event.which;
  4628. }
  4629. }, jQuery.event.addProp );
  4630. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  4631. jQuery.event.special[ type ] = {
  4632. // Utilize native event if possible so blur/focus sequence is correct
  4633. setup: function() {
  4634. // Claim the first handler
  4635. // dataPriv.set( this, "focus", ... )
  4636. // dataPriv.set( this, "blur", ... )
  4637. leverageNative( this, type, expectSync );
  4638. // Return false to allow normal processing in the caller
  4639. return false;
  4640. },
  4641. trigger: function() {
  4642. // Force setup before trigger
  4643. leverageNative( this, type );
  4644. // Return non-false to allow normal event-path propagation
  4645. return true;
  4646. },
  4647. delegateType: delegateType
  4648. };
  4649. } );
  4650. // Create mouseenter/leave events using mouseover/out and event-time checks
  4651. // so that event delegation works in jQuery.
  4652. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  4653. //
  4654. // Support: Safari 7 only
  4655. // Safari sends mouseenter too often; see:
  4656. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  4657. // for the description of the bug (it existed in older Chrome versions as well).
  4658. jQuery.each( {
  4659. mouseenter: "mouseover",
  4660. mouseleave: "mouseout",
  4661. pointerenter: "pointerover",
  4662. pointerleave: "pointerout"
  4663. }, function( orig, fix ) {
  4664. jQuery.event.special[ orig ] = {
  4665. delegateType: fix,
  4666. bindType: fix,
  4667. handle: function( event ) {
  4668. var ret,
  4669. target = this,
  4670. related = event.relatedTarget,
  4671. handleObj = event.handleObj;
  4672. // For mouseenter/leave call the handler if related is outside the target.
  4673. // NB: No relatedTarget if the mouse left/entered the browser window
  4674. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  4675. event.type = handleObj.origType;
  4676. ret = handleObj.handler.apply( this, arguments );
  4677. event.type = fix;
  4678. }
  4679. return ret;
  4680. }
  4681. };
  4682. } );
  4683. jQuery.fn.extend( {
  4684. on: function( types, selector, data, fn ) {
  4685. return on( this, types, selector, data, fn );
  4686. },
  4687. one: function( types, selector, data, fn ) {
  4688. return on( this, types, selector, data, fn, 1 );
  4689. },
  4690. off: function( types, selector, fn ) {
  4691. var handleObj, type;
  4692. if ( types && types.preventDefault && types.handleObj ) {
  4693. // ( event ) dispatched jQuery.Event
  4694. handleObj = types.handleObj;
  4695. jQuery( types.delegateTarget ).off(
  4696. handleObj.namespace ?
  4697. handleObj.origType + "." + handleObj.namespace :
  4698. handleObj.origType,
  4699. handleObj.selector,
  4700. handleObj.handler
  4701. );
  4702. return this;
  4703. }
  4704. if ( typeof types === "object" ) {
  4705. // ( types-object [, selector] )
  4706. for ( type in types ) {
  4707. this.off( type, selector, types[ type ] );
  4708. }
  4709. return this;
  4710. }
  4711. if ( selector === false || typeof selector === "function" ) {
  4712. // ( types [, fn] )
  4713. fn = selector;
  4714. selector = undefined;
  4715. }
  4716. if ( fn === false ) {
  4717. fn = returnFalse;
  4718. }
  4719. return this.each( function() {
  4720. jQuery.event.remove( this, types, fn, selector );
  4721. } );
  4722. }
  4723. } );
  4724. var
  4725. /* eslint-disable max-len */
  4726. // See https://github.com/eslint/eslint/issues/3229
  4727. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  4728. /* eslint-enable */
  4729. // Support: IE <=10 - 11, Edge 12 - 13 only
  4730. // In IE/Edge using regex groups here causes severe slowdowns.
  4731. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  4732. rnoInnerhtml = /<script|<style|<link/i,
  4733. // checked="checked" or checked
  4734. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4735. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  4736. // Prefer a tbody over its parent table for containing new rows
  4737. function manipulationTarget( elem, content ) {
  4738. if ( nodeName( elem, "table" ) &&
  4739. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  4740. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  4741. }
  4742. return elem;
  4743. }
  4744. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4745. function disableScript( elem ) {
  4746. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  4747. return elem;
  4748. }
  4749. function restoreScript( elem ) {
  4750. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  4751. elem.type = elem.type.slice( 5 );
  4752. } else {
  4753. elem.removeAttribute( "type" );
  4754. }
  4755. return elem;
  4756. }
  4757. function cloneCopyEvent( src, dest ) {
  4758. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  4759. if ( dest.nodeType !== 1 ) {
  4760. return;
  4761. }
  4762. // 1. Copy private data: events, handlers, etc.
  4763. if ( dataPriv.hasData( src ) ) {
  4764. pdataOld = dataPriv.access( src );
  4765. pdataCur = dataPriv.set( dest, pdataOld );
  4766. events = pdataOld.events;
  4767. if ( events ) {
  4768. delete pdataCur.handle;
  4769. pdataCur.events = {};
  4770. for ( type in events ) {
  4771. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4772. jQuery.event.add( dest, type, events[ type ][ i ] );
  4773. }
  4774. }
  4775. }
  4776. }
  4777. // 2. Copy user data
  4778. if ( dataUser.hasData( src ) ) {
  4779. udataOld = dataUser.access( src );
  4780. udataCur = jQuery.extend( {}, udataOld );
  4781. dataUser.set( dest, udataCur );
  4782. }
  4783. }
  4784. // Fix IE bugs, see support tests
  4785. function fixInput( src, dest ) {
  4786. var nodeName = dest.nodeName.toLowerCase();
  4787. // Fails to persist the checked state of a cloned checkbox or radio button.
  4788. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4789. dest.checked = src.checked;
  4790. // Fails to return the selected option to the default selected state when cloning options
  4791. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4792. dest.defaultValue = src.defaultValue;
  4793. }
  4794. }
  4795. function domManip( collection, args, callback, ignored ) {
  4796. // Flatten any nested arrays
  4797. args = concat.apply( [], args );
  4798. var fragment, first, scripts, hasScripts, node, doc,
  4799. i = 0,
  4800. l = collection.length,
  4801. iNoClone = l - 1,
  4802. value = args[ 0 ],
  4803. valueIsFunction = isFunction( value );
  4804. // We can't cloneNode fragments that contain checked, in WebKit
  4805. if ( valueIsFunction ||
  4806. ( l > 1 && typeof value === "string" &&
  4807. !support.checkClone && rchecked.test( value ) ) ) {
  4808. return collection.each( function( index ) {
  4809. var self = collection.eq( index );
  4810. if ( valueIsFunction ) {
  4811. args[ 0 ] = value.call( this, index, self.html() );
  4812. }
  4813. domManip( self, args, callback, ignored );
  4814. } );
  4815. }
  4816. if ( l ) {
  4817. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  4818. first = fragment.firstChild;
  4819. if ( fragment.childNodes.length === 1 ) {
  4820. fragment = first;
  4821. }
  4822. // Require either new content or an interest in ignored elements to invoke the callback
  4823. if ( first || ignored ) {
  4824. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4825. hasScripts = scripts.length;
  4826. // Use the original fragment for the last item
  4827. // instead of the first because it can end up
  4828. // being emptied incorrectly in certain situations (#8070).
  4829. for ( ; i < l; i++ ) {
  4830. node = fragment;
  4831. if ( i !== iNoClone ) {
  4832. node = jQuery.clone( node, true, true );
  4833. // Keep references to cloned scripts for later restoration
  4834. if ( hasScripts ) {
  4835. // Support: Android <=4.0 only, PhantomJS 1 only
  4836. // push.apply(_, arraylike) throws on ancient WebKit
  4837. jQuery.merge( scripts, getAll( node, "script" ) );
  4838. }
  4839. }
  4840. callback.call( collection[ i ], node, i );
  4841. }
  4842. if ( hasScripts ) {
  4843. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4844. // Reenable scripts
  4845. jQuery.map( scripts, restoreScript );
  4846. // Evaluate executable scripts on first document insertion
  4847. for ( i = 0; i < hasScripts; i++ ) {
  4848. node = scripts[ i ];
  4849. if ( rscriptType.test( node.type || "" ) &&
  4850. !dataPriv.access( node, "globalEval" ) &&
  4851. jQuery.contains( doc, node ) ) {
  4852. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  4853. // Optional AJAX dependency, but won't run scripts if not present
  4854. if ( jQuery._evalUrl && !node.noModule ) {
  4855. jQuery._evalUrl( node.src, {
  4856. nonce: node.nonce || node.getAttribute( "nonce" )
  4857. } );
  4858. }
  4859. } else {
  4860. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  4861. }
  4862. }
  4863. }
  4864. }
  4865. }
  4866. }
  4867. return collection;
  4868. }
  4869. function remove( elem, selector, keepData ) {
  4870. var node,
  4871. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  4872. i = 0;
  4873. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  4874. if ( !keepData && node.nodeType === 1 ) {
  4875. jQuery.cleanData( getAll( node ) );
  4876. }
  4877. if ( node.parentNode ) {
  4878. if ( keepData && isAttached( node ) ) {
  4879. setGlobalEval( getAll( node, "script" ) );
  4880. }
  4881. node.parentNode.removeChild( node );
  4882. }
  4883. }
  4884. return elem;
  4885. }
  4886. jQuery.extend( {
  4887. htmlPrefilter: function( html ) {
  4888. return html.replace( rxhtmlTag, "<$1></$2>" );
  4889. },
  4890. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4891. var i, l, srcElements, destElements,
  4892. clone = elem.cloneNode( true ),
  4893. inPage = isAttached( elem );
  4894. // Fix IE cloning issues
  4895. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  4896. !jQuery.isXMLDoc( elem ) ) {
  4897. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  4898. destElements = getAll( clone );
  4899. srcElements = getAll( elem );
  4900. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4901. fixInput( srcElements[ i ], destElements[ i ] );
  4902. }
  4903. }
  4904. // Copy the events from the original to the clone
  4905. if ( dataAndEvents ) {
  4906. if ( deepDataAndEvents ) {
  4907. srcElements = srcElements || getAll( elem );
  4908. destElements = destElements || getAll( clone );
  4909. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4910. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  4911. }
  4912. } else {
  4913. cloneCopyEvent( elem, clone );
  4914. }
  4915. }
  4916. // Preserve script evaluation history
  4917. destElements = getAll( clone, "script" );
  4918. if ( destElements.length > 0 ) {
  4919. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4920. }
  4921. // Return the cloned set
  4922. return clone;
  4923. },
  4924. cleanData: function( elems ) {
  4925. var data, elem, type,
  4926. special = jQuery.event.special,
  4927. i = 0;
  4928. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  4929. if ( acceptData( elem ) ) {
  4930. if ( ( data = elem[ dataPriv.expando ] ) ) {
  4931. if ( data.events ) {
  4932. for ( type in data.events ) {
  4933. if ( special[ type ] ) {
  4934. jQuery.event.remove( elem, type );
  4935. // This is a shortcut to avoid jQuery.event.remove's overhead
  4936. } else {
  4937. jQuery.removeEvent( elem, type, data.handle );
  4938. }
  4939. }
  4940. }
  4941. // Support: Chrome <=35 - 45+
  4942. // Assign undefined instead of using delete, see Data#remove
  4943. elem[ dataPriv.expando ] = undefined;
  4944. }
  4945. if ( elem[ dataUser.expando ] ) {
  4946. // Support: Chrome <=35 - 45+
  4947. // Assign undefined instead of using delete, see Data#remove
  4948. elem[ dataUser.expando ] = undefined;
  4949. }
  4950. }
  4951. }
  4952. }
  4953. } );
  4954. jQuery.fn.extend( {
  4955. detach: function( selector ) {
  4956. return remove( this, selector, true );
  4957. },
  4958. remove: function( selector ) {
  4959. return remove( this, selector );
  4960. },
  4961. text: function( value ) {
  4962. return access( this, function( value ) {
  4963. return value === undefined ?
  4964. jQuery.text( this ) :
  4965. this.empty().each( function() {
  4966. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4967. this.textContent = value;
  4968. }
  4969. } );
  4970. }, null, value, arguments.length );
  4971. },
  4972. append: function() {
  4973. return domManip( this, arguments, function( elem ) {
  4974. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4975. var target = manipulationTarget( this, elem );
  4976. target.appendChild( elem );
  4977. }
  4978. } );
  4979. },
  4980. prepend: function() {
  4981. return domManip( this, arguments, function( elem ) {
  4982. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4983. var target = manipulationTarget( this, elem );
  4984. target.insertBefore( elem, target.firstChild );
  4985. }
  4986. } );
  4987. },
  4988. before: function() {
  4989. return domManip( this, arguments, function( elem ) {
  4990. if ( this.parentNode ) {
  4991. this.parentNode.insertBefore( elem, this );
  4992. }
  4993. } );
  4994. },
  4995. after: function() {
  4996. return domManip( this, arguments, function( elem ) {
  4997. if ( this.parentNode ) {
  4998. this.parentNode.insertBefore( elem, this.nextSibling );
  4999. }
  5000. } );
  5001. },
  5002. empty: function() {
  5003. var elem,
  5004. i = 0;
  5005. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  5006. if ( elem.nodeType === 1 ) {
  5007. // Prevent memory leaks
  5008. jQuery.cleanData( getAll( elem, false ) );
  5009. // Remove any remaining nodes
  5010. elem.textContent = "";
  5011. }
  5012. }
  5013. return this;
  5014. },
  5015. clone: function( dataAndEvents, deepDataAndEvents ) {
  5016. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  5017. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  5018. return this.map( function() {
  5019. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  5020. } );
  5021. },
  5022. html: function( value ) {
  5023. return access( this, function( value ) {
  5024. var elem = this[ 0 ] || {},
  5025. i = 0,
  5026. l = this.length;
  5027. if ( value === undefined && elem.nodeType === 1 ) {
  5028. return elem.innerHTML;
  5029. }
  5030. // See if we can take a shortcut and just use innerHTML
  5031. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  5032. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  5033. value = jQuery.htmlPrefilter( value );
  5034. try {
  5035. for ( ; i < l; i++ ) {
  5036. elem = this[ i ] || {};
  5037. // Remove element nodes and prevent memory leaks
  5038. if ( elem.nodeType === 1 ) {
  5039. jQuery.cleanData( getAll( elem, false ) );
  5040. elem.innerHTML = value;
  5041. }
  5042. }
  5043. elem = 0;
  5044. // If using innerHTML throws an exception, use the fallback method
  5045. } catch ( e ) {}
  5046. }
  5047. if ( elem ) {
  5048. this.empty().append( value );
  5049. }
  5050. }, null, value, arguments.length );
  5051. },
  5052. replaceWith: function() {
  5053. var ignored = [];
  5054. // Make the changes, replacing each non-ignored context element with the new content
  5055. return domManip( this, arguments, function( elem ) {
  5056. var parent = this.parentNode;
  5057. if ( jQuery.inArray( this, ignored ) < 0 ) {
  5058. jQuery.cleanData( getAll( this ) );
  5059. if ( parent ) {
  5060. parent.replaceChild( elem, this );
  5061. }
  5062. }
  5063. // Force callback invocation
  5064. }, ignored );
  5065. }
  5066. } );
  5067. jQuery.each( {
  5068. appendTo: "append",
  5069. prependTo: "prepend",
  5070. insertBefore: "before",
  5071. insertAfter: "after",
  5072. replaceAll: "replaceWith"
  5073. }, function( name, original ) {
  5074. jQuery.fn[ name ] = function( selector ) {
  5075. var elems,
  5076. ret = [],
  5077. insert = jQuery( selector ),
  5078. last = insert.length - 1,
  5079. i = 0;
  5080. for ( ; i <= last; i++ ) {
  5081. elems = i === last ? this : this.clone( true );
  5082. jQuery( insert[ i ] )[ original ]( elems );
  5083. // Support: Android <=4.0 only, PhantomJS 1 only
  5084. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  5085. push.apply( ret, elems.get() );
  5086. }
  5087. return this.pushStack( ret );
  5088. };
  5089. } );
  5090. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5091. var getStyles = function( elem ) {
  5092. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  5093. // IE throws on elements created in popups
  5094. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  5095. var view = elem.ownerDocument.defaultView;
  5096. if ( !view || !view.opener ) {
  5097. view = window;
  5098. }
  5099. return view.getComputedStyle( elem );
  5100. };
  5101. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  5102. ( function() {
  5103. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  5104. // so they're executed at the same time to save the second computation.
  5105. function computeStyleTests() {
  5106. // This is a singleton, we need to execute it only once
  5107. if ( !div ) {
  5108. return;
  5109. }
  5110. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  5111. "margin-top:1px;padding:0;border:0";
  5112. div.style.cssText =
  5113. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  5114. "margin:auto;border:1px;padding:1px;" +
  5115. "width:60%;top:1%";
  5116. documentElement.appendChild( container ).appendChild( div );
  5117. var divStyle = window.getComputedStyle( div );
  5118. pixelPositionVal = divStyle.top !== "1%";
  5119. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  5120. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  5121. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  5122. // Some styles come back with percentage values, even though they shouldn't
  5123. div.style.right = "60%";
  5124. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  5125. // Support: IE 9 - 11 only
  5126. // Detect misreporting of content dimensions for box-sizing:border-box elements
  5127. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  5128. // Support: IE 9 only
  5129. // Detect overflow:scroll screwiness (gh-3699)
  5130. // Support: Chrome <=64
  5131. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  5132. div.style.position = "absolute";
  5133. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  5134. documentElement.removeChild( container );
  5135. // Nullify the div so it wouldn't be stored in the memory and
  5136. // it will also be a sign that checks already performed
  5137. div = null;
  5138. }
  5139. function roundPixelMeasures( measure ) {
  5140. return Math.round( parseFloat( measure ) );
  5141. }
  5142. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  5143. reliableMarginLeftVal,
  5144. container = document.createElement( "div" ),
  5145. div = document.createElement( "div" );
  5146. // Finish early in limited (non-browser) environments
  5147. if ( !div.style ) {
  5148. return;
  5149. }
  5150. // Support: IE <=9 - 11 only
  5151. // Style of cloned element affects source element cloned (#8908)
  5152. div.style.backgroundClip = "content-box";
  5153. div.cloneNode( true ).style.backgroundClip = "";
  5154. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5155. jQuery.extend( support, {
  5156. boxSizingReliable: function() {
  5157. computeStyleTests();
  5158. return boxSizingReliableVal;
  5159. },
  5160. pixelBoxStyles: function() {
  5161. computeStyleTests();
  5162. return pixelBoxStylesVal;
  5163. },
  5164. pixelPosition: function() {
  5165. computeStyleTests();
  5166. return pixelPositionVal;
  5167. },
  5168. reliableMarginLeft: function() {
  5169. computeStyleTests();
  5170. return reliableMarginLeftVal;
  5171. },
  5172. scrollboxSize: function() {
  5173. computeStyleTests();
  5174. return scrollboxSizeVal;
  5175. }
  5176. } );
  5177. } )();
  5178. function curCSS( elem, name, computed ) {
  5179. var width, minWidth, maxWidth, ret,
  5180. // Support: Firefox 51+
  5181. // Retrieving style before computed somehow
  5182. // fixes an issue with getting wrong values
  5183. // on detached elements
  5184. style = elem.style;
  5185. computed = computed || getStyles( elem );
  5186. // getPropertyValue is needed for:
  5187. // .css('filter') (IE 9 only, #12537)
  5188. // .css('--customProperty) (#3144)
  5189. if ( computed ) {
  5190. ret = computed.getPropertyValue( name ) || computed[ name ];
  5191. if ( ret === "" && !isAttached( elem ) ) {
  5192. ret = jQuery.style( elem, name );
  5193. }
  5194. // A tribute to the "awesome hack by Dean Edwards"
  5195. // Android Browser returns percentage for some values,
  5196. // but width seems to be reliably pixels.
  5197. // This is against the CSSOM draft spec:
  5198. // https://drafts.csswg.org/cssom/#resolved-values
  5199. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  5200. // Remember the original values
  5201. width = style.width;
  5202. minWidth = style.minWidth;
  5203. maxWidth = style.maxWidth;
  5204. // Put in the new values to get a computed value out
  5205. style.minWidth = style.maxWidth = style.width = ret;
  5206. ret = computed.width;
  5207. // Revert the changed values
  5208. style.width = width;
  5209. style.minWidth = minWidth;
  5210. style.maxWidth = maxWidth;
  5211. }
  5212. }
  5213. return ret !== undefined ?
  5214. // Support: IE <=9 - 11 only
  5215. // IE returns zIndex value as an integer.
  5216. ret + "" :
  5217. ret;
  5218. }
  5219. function addGetHookIf( conditionFn, hookFn ) {
  5220. // Define the hook, we'll check on the first run if it's really needed.
  5221. return {
  5222. get: function() {
  5223. if ( conditionFn() ) {
  5224. // Hook not needed (or it's not possible to use it due
  5225. // to missing dependency), remove it.
  5226. delete this.get;
  5227. return;
  5228. }
  5229. // Hook needed; redefine it so that the support test is not executed again.
  5230. return ( this.get = hookFn ).apply( this, arguments );
  5231. }
  5232. };
  5233. }
  5234. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  5235. emptyStyle = document.createElement( "div" ).style,
  5236. vendorProps = {};
  5237. // Return a vendor-prefixed property or undefined
  5238. function vendorPropName( name ) {
  5239. // Check for vendor prefixed names
  5240. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  5241. i = cssPrefixes.length;
  5242. while ( i-- ) {
  5243. name = cssPrefixes[ i ] + capName;
  5244. if ( name in emptyStyle ) {
  5245. return name;
  5246. }
  5247. }
  5248. }
  5249. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  5250. function finalPropName( name ) {
  5251. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  5252. if ( final ) {
  5253. return final;
  5254. }
  5255. if ( name in emptyStyle ) {
  5256. return name;
  5257. }
  5258. return vendorProps[ name ] = vendorPropName( name ) || name;
  5259. }
  5260. var
  5261. // Swappable if display is none or starts with table
  5262. // except "table", "table-cell", or "table-caption"
  5263. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5264. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5265. rcustomProp = /^--/,
  5266. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5267. cssNormalTransform = {
  5268. letterSpacing: "0",
  5269. fontWeight: "400"
  5270. };
  5271. function setPositiveNumber( elem, value, subtract ) {
  5272. // Any relative (+/-) values have already been
  5273. // normalized at this point
  5274. var matches = rcssNum.exec( value );
  5275. return matches ?
  5276. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5277. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  5278. value;
  5279. }
  5280. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  5281. var i = dimension === "width" ? 1 : 0,
  5282. extra = 0,
  5283. delta = 0;
  5284. // Adjustment may not be necessary
  5285. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  5286. return 0;
  5287. }
  5288. for ( ; i < 4; i += 2 ) {
  5289. // Both box models exclude margin
  5290. if ( box === "margin" ) {
  5291. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  5292. }
  5293. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  5294. if ( !isBorderBox ) {
  5295. // Add padding
  5296. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5297. // For "border" or "margin", add border
  5298. if ( box !== "padding" ) {
  5299. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5300. // But still keep track of it otherwise
  5301. } else {
  5302. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5303. }
  5304. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  5305. // "padding" or "margin"
  5306. } else {
  5307. // For "content", subtract padding
  5308. if ( box === "content" ) {
  5309. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5310. }
  5311. // For "content" or "padding", subtract border
  5312. if ( box !== "margin" ) {
  5313. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5314. }
  5315. }
  5316. }
  5317. // Account for positive content-box scroll gutter when requested by providing computedVal
  5318. if ( !isBorderBox && computedVal >= 0 ) {
  5319. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  5320. // Assuming integer scroll gutter, subtract the rest and round down
  5321. delta += Math.max( 0, Math.ceil(
  5322. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  5323. computedVal -
  5324. delta -
  5325. extra -
  5326. 0.5
  5327. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  5328. // Use an explicit zero to avoid NaN (gh-3964)
  5329. ) ) || 0;
  5330. }
  5331. return delta;
  5332. }
  5333. function getWidthOrHeight( elem, dimension, extra ) {
  5334. // Start with computed style
  5335. var styles = getStyles( elem ),
  5336. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  5337. // Fake content-box until we know it's needed to know the true value.
  5338. boxSizingNeeded = !support.boxSizingReliable() || extra,
  5339. isBorderBox = boxSizingNeeded &&
  5340. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5341. valueIsBorderBox = isBorderBox,
  5342. val = curCSS( elem, dimension, styles ),
  5343. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  5344. // Support: Firefox <=54
  5345. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  5346. if ( rnumnonpx.test( val ) ) {
  5347. if ( !extra ) {
  5348. return val;
  5349. }
  5350. val = "auto";
  5351. }
  5352. // Fall back to offsetWidth/offsetHeight when value is "auto"
  5353. // This happens for inline elements with no explicit setting (gh-3571)
  5354. // Support: Android <=4.1 - 4.3 only
  5355. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  5356. // Support: IE 9-11 only
  5357. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  5358. // We use getClientRects() to check for hidden/disconnected.
  5359. // In those cases, the computed value can be trusted to be border-box
  5360. if ( ( !support.boxSizingReliable() && isBorderBox ||
  5361. val === "auto" ||
  5362. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  5363. elem.getClientRects().length ) {
  5364. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5365. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  5366. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  5367. // retrieved value as a content box dimension.
  5368. valueIsBorderBox = offsetProp in elem;
  5369. if ( valueIsBorderBox ) {
  5370. val = elem[ offsetProp ];
  5371. }
  5372. }
  5373. // Normalize "" and auto
  5374. val = parseFloat( val ) || 0;
  5375. // Adjust for the element's box model
  5376. return ( val +
  5377. boxModelAdjustment(
  5378. elem,
  5379. dimension,
  5380. extra || ( isBorderBox ? "border" : "content" ),
  5381. valueIsBorderBox,
  5382. styles,
  5383. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  5384. val
  5385. )
  5386. ) + "px";
  5387. }
  5388. jQuery.extend( {
  5389. // Add in style property hooks for overriding the default
  5390. // behavior of getting and setting a style property
  5391. cssHooks: {
  5392. opacity: {
  5393. get: function( elem, computed ) {
  5394. if ( computed ) {
  5395. // We should always get a number back from opacity
  5396. var ret = curCSS( elem, "opacity" );
  5397. return ret === "" ? "1" : ret;
  5398. }
  5399. }
  5400. }
  5401. },
  5402. // Don't automatically add "px" to these possibly-unitless properties
  5403. cssNumber: {
  5404. "animationIterationCount": true,
  5405. "columnCount": true,
  5406. "fillOpacity": true,
  5407. "flexGrow": true,
  5408. "flexShrink": true,
  5409. "fontWeight": true,
  5410. "gridArea": true,
  5411. "gridColumn": true,
  5412. "gridColumnEnd": true,
  5413. "gridColumnStart": true,
  5414. "gridRow": true,
  5415. "gridRowEnd": true,
  5416. "gridRowStart": true,
  5417. "lineHeight": true,
  5418. "opacity": true,
  5419. "order": true,
  5420. "orphans": true,
  5421. "widows": true,
  5422. "zIndex": true,
  5423. "zoom": true
  5424. },
  5425. // Add in properties whose names you wish to fix before
  5426. // setting or getting the value
  5427. cssProps: {},
  5428. // Get and set the style property on a DOM Node
  5429. style: function( elem, name, value, extra ) {
  5430. // Don't set styles on text and comment nodes
  5431. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5432. return;
  5433. }
  5434. // Make sure that we're working with the right name
  5435. var ret, type, hooks,
  5436. origName = camelCase( name ),
  5437. isCustomProp = rcustomProp.test( name ),
  5438. style = elem.style;
  5439. // Make sure that we're working with the right name. We don't
  5440. // want to query the value if it is a CSS custom property
  5441. // since they are user-defined.
  5442. if ( !isCustomProp ) {
  5443. name = finalPropName( origName );
  5444. }
  5445. // Gets hook for the prefixed version, then unprefixed version
  5446. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5447. // Check if we're setting a value
  5448. if ( value !== undefined ) {
  5449. type = typeof value;
  5450. // Convert "+=" or "-=" to relative numbers (#7345)
  5451. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  5452. value = adjustCSS( elem, name, ret );
  5453. // Fixes bug #9237
  5454. type = "number";
  5455. }
  5456. // Make sure that null and NaN values aren't set (#7116)
  5457. if ( value == null || value !== value ) {
  5458. return;
  5459. }
  5460. // If a number was passed in, add the unit (except for certain CSS properties)
  5461. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  5462. // "px" to a few hardcoded values.
  5463. if ( type === "number" && !isCustomProp ) {
  5464. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  5465. }
  5466. // background-* props affect original clone's values
  5467. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  5468. style[ name ] = "inherit";
  5469. }
  5470. // If a hook was provided, use that value, otherwise just set the specified value
  5471. if ( !hooks || !( "set" in hooks ) ||
  5472. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  5473. if ( isCustomProp ) {
  5474. style.setProperty( name, value );
  5475. } else {
  5476. style[ name ] = value;
  5477. }
  5478. }
  5479. } else {
  5480. // If a hook was provided get the non-computed value from there
  5481. if ( hooks && "get" in hooks &&
  5482. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  5483. return ret;
  5484. }
  5485. // Otherwise just get the value from the style object
  5486. return style[ name ];
  5487. }
  5488. },
  5489. css: function( elem, name, extra, styles ) {
  5490. var val, num, hooks,
  5491. origName = camelCase( name ),
  5492. isCustomProp = rcustomProp.test( name );
  5493. // Make sure that we're working with the right name. We don't
  5494. // want to modify the value if it is a CSS custom property
  5495. // since they are user-defined.
  5496. if ( !isCustomProp ) {
  5497. name = finalPropName( origName );
  5498. }
  5499. // Try prefixed name followed by the unprefixed name
  5500. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5501. // If a hook was provided get the computed value from there
  5502. if ( hooks && "get" in hooks ) {
  5503. val = hooks.get( elem, true, extra );
  5504. }
  5505. // Otherwise, if a way to get the computed value exists, use that
  5506. if ( val === undefined ) {
  5507. val = curCSS( elem, name, styles );
  5508. }
  5509. // Convert "normal" to computed value
  5510. if ( val === "normal" && name in cssNormalTransform ) {
  5511. val = cssNormalTransform[ name ];
  5512. }
  5513. // Make numeric if forced or a qualifier was provided and val looks numeric
  5514. if ( extra === "" || extra ) {
  5515. num = parseFloat( val );
  5516. return extra === true || isFinite( num ) ? num || 0 : val;
  5517. }
  5518. return val;
  5519. }
  5520. } );
  5521. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  5522. jQuery.cssHooks[ dimension ] = {
  5523. get: function( elem, computed, extra ) {
  5524. if ( computed ) {
  5525. // Certain elements can have dimension info if we invisibly show them
  5526. // but it must have a current display style that would benefit
  5527. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  5528. // Support: Safari 8+
  5529. // Table columns in Safari have non-zero offsetWidth & zero
  5530. // getBoundingClientRect().width unless display is changed.
  5531. // Support: IE <=11 only
  5532. // Running getBoundingClientRect on a disconnected node
  5533. // in IE throws an error.
  5534. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  5535. swap( elem, cssShow, function() {
  5536. return getWidthOrHeight( elem, dimension, extra );
  5537. } ) :
  5538. getWidthOrHeight( elem, dimension, extra );
  5539. }
  5540. },
  5541. set: function( elem, value, extra ) {
  5542. var matches,
  5543. styles = getStyles( elem ),
  5544. // Only read styles.position if the test has a chance to fail
  5545. // to avoid forcing a reflow.
  5546. scrollboxSizeBuggy = !support.scrollboxSize() &&
  5547. styles.position === "absolute",
  5548. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  5549. boxSizingNeeded = scrollboxSizeBuggy || extra,
  5550. isBorderBox = boxSizingNeeded &&
  5551. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5552. subtract = extra ?
  5553. boxModelAdjustment(
  5554. elem,
  5555. dimension,
  5556. extra,
  5557. isBorderBox,
  5558. styles
  5559. ) :
  5560. 0;
  5561. // Account for unreliable border-box dimensions by comparing offset* to computed and
  5562. // faking a content-box to get border and padding (gh-3699)
  5563. if ( isBorderBox && scrollboxSizeBuggy ) {
  5564. subtract -= Math.ceil(
  5565. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  5566. parseFloat( styles[ dimension ] ) -
  5567. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  5568. 0.5
  5569. );
  5570. }
  5571. // Convert to pixels if value adjustment is needed
  5572. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  5573. ( matches[ 3 ] || "px" ) !== "px" ) {
  5574. elem.style[ dimension ] = value;
  5575. value = jQuery.css( elem, dimension );
  5576. }
  5577. return setPositiveNumber( elem, value, subtract );
  5578. }
  5579. };
  5580. } );
  5581. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  5582. function( elem, computed ) {
  5583. if ( computed ) {
  5584. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  5585. elem.getBoundingClientRect().left -
  5586. swap( elem, { marginLeft: 0 }, function() {
  5587. return elem.getBoundingClientRect().left;
  5588. } )
  5589. ) + "px";
  5590. }
  5591. }
  5592. );
  5593. // These hooks are used by animate to expand properties
  5594. jQuery.each( {
  5595. margin: "",
  5596. padding: "",
  5597. border: "Width"
  5598. }, function( prefix, suffix ) {
  5599. jQuery.cssHooks[ prefix + suffix ] = {
  5600. expand: function( value ) {
  5601. var i = 0,
  5602. expanded = {},
  5603. // Assumes a single number if not a string
  5604. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  5605. for ( ; i < 4; i++ ) {
  5606. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5607. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5608. }
  5609. return expanded;
  5610. }
  5611. };
  5612. if ( prefix !== "margin" ) {
  5613. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5614. }
  5615. } );
  5616. jQuery.fn.extend( {
  5617. css: function( name, value ) {
  5618. return access( this, function( elem, name, value ) {
  5619. var styles, len,
  5620. map = {},
  5621. i = 0;
  5622. if ( Array.isArray( name ) ) {
  5623. styles = getStyles( elem );
  5624. len = name.length;
  5625. for ( ; i < len; i++ ) {
  5626. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5627. }
  5628. return map;
  5629. }
  5630. return value !== undefined ?
  5631. jQuery.style( elem, name, value ) :
  5632. jQuery.css( elem, name );
  5633. }, name, value, arguments.length > 1 );
  5634. }
  5635. } );
  5636. function Tween( elem, options, prop, end, easing ) {
  5637. return new Tween.prototype.init( elem, options, prop, end, easing );
  5638. }
  5639. jQuery.Tween = Tween;
  5640. Tween.prototype = {
  5641. constructor: Tween,
  5642. init: function( elem, options, prop, end, easing, unit ) {
  5643. this.elem = elem;
  5644. this.prop = prop;
  5645. this.easing = easing || jQuery.easing._default;
  5646. this.options = options;
  5647. this.start = this.now = this.cur();
  5648. this.end = end;
  5649. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5650. },
  5651. cur: function() {
  5652. var hooks = Tween.propHooks[ this.prop ];
  5653. return hooks && hooks.get ?
  5654. hooks.get( this ) :
  5655. Tween.propHooks._default.get( this );
  5656. },
  5657. run: function( percent ) {
  5658. var eased,
  5659. hooks = Tween.propHooks[ this.prop ];
  5660. if ( this.options.duration ) {
  5661. this.pos = eased = jQuery.easing[ this.easing ](
  5662. percent, this.options.duration * percent, 0, 1, this.options.duration
  5663. );
  5664. } else {
  5665. this.pos = eased = percent;
  5666. }
  5667. this.now = ( this.end - this.start ) * eased + this.start;
  5668. if ( this.options.step ) {
  5669. this.options.step.call( this.elem, this.now, this );
  5670. }
  5671. if ( hooks && hooks.set ) {
  5672. hooks.set( this );
  5673. } else {
  5674. Tween.propHooks._default.set( this );
  5675. }
  5676. return this;
  5677. }
  5678. };
  5679. Tween.prototype.init.prototype = Tween.prototype;
  5680. Tween.propHooks = {
  5681. _default: {
  5682. get: function( tween ) {
  5683. var result;
  5684. // Use a property on the element directly when it is not a DOM element,
  5685. // or when there is no matching style property that exists.
  5686. if ( tween.elem.nodeType !== 1 ||
  5687. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  5688. return tween.elem[ tween.prop ];
  5689. }
  5690. // Passing an empty string as a 3rd parameter to .css will automatically
  5691. // attempt a parseFloat and fallback to a string if the parse fails.
  5692. // Simple values such as "10px" are parsed to Float;
  5693. // complex values such as "rotate(1rad)" are returned as-is.
  5694. result = jQuery.css( tween.elem, tween.prop, "" );
  5695. // Empty strings, null, undefined and "auto" are converted to 0.
  5696. return !result || result === "auto" ? 0 : result;
  5697. },
  5698. set: function( tween ) {
  5699. // Use step hook for back compat.
  5700. // Use cssHook if its there.
  5701. // Use .style if available and use plain properties where available.
  5702. if ( jQuery.fx.step[ tween.prop ] ) {
  5703. jQuery.fx.step[ tween.prop ]( tween );
  5704. } else if ( tween.elem.nodeType === 1 && (
  5705. jQuery.cssHooks[ tween.prop ] ||
  5706. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  5707. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5708. } else {
  5709. tween.elem[ tween.prop ] = tween.now;
  5710. }
  5711. }
  5712. }
  5713. };
  5714. // Support: IE <=9 only
  5715. // Panic based approach to setting things on disconnected nodes
  5716. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5717. set: function( tween ) {
  5718. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5719. tween.elem[ tween.prop ] = tween.now;
  5720. }
  5721. }
  5722. };
  5723. jQuery.easing = {
  5724. linear: function( p ) {
  5725. return p;
  5726. },
  5727. swing: function( p ) {
  5728. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5729. },
  5730. _default: "swing"
  5731. };
  5732. jQuery.fx = Tween.prototype.init;
  5733. // Back compat <1.8 extension point
  5734. jQuery.fx.step = {};
  5735. var
  5736. fxNow, inProgress,
  5737. rfxtypes = /^(?:toggle|show|hide)$/,
  5738. rrun = /queueHooks$/;
  5739. function schedule() {
  5740. if ( inProgress ) {
  5741. if ( document.hidden === false && window.requestAnimationFrame ) {
  5742. window.requestAnimationFrame( schedule );
  5743. } else {
  5744. window.setTimeout( schedule, jQuery.fx.interval );
  5745. }
  5746. jQuery.fx.tick();
  5747. }
  5748. }
  5749. // Animations created synchronously will run synchronously
  5750. function createFxNow() {
  5751. window.setTimeout( function() {
  5752. fxNow = undefined;
  5753. } );
  5754. return ( fxNow = Date.now() );
  5755. }
  5756. // Generate parameters to create a standard animation
  5757. function genFx( type, includeWidth ) {
  5758. var which,
  5759. i = 0,
  5760. attrs = { height: type };
  5761. // If we include width, step value is 1 to do all cssExpand values,
  5762. // otherwise step value is 2 to skip over Left and Right
  5763. includeWidth = includeWidth ? 1 : 0;
  5764. for ( ; i < 4; i += 2 - includeWidth ) {
  5765. which = cssExpand[ i ];
  5766. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5767. }
  5768. if ( includeWidth ) {
  5769. attrs.opacity = attrs.width = type;
  5770. }
  5771. return attrs;
  5772. }
  5773. function createTween( value, prop, animation ) {
  5774. var tween,
  5775. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  5776. index = 0,
  5777. length = collection.length;
  5778. for ( ; index < length; index++ ) {
  5779. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  5780. // We're done with this property
  5781. return tween;
  5782. }
  5783. }
  5784. }
  5785. function defaultPrefilter( elem, props, opts ) {
  5786. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  5787. isBox = "width" in props || "height" in props,
  5788. anim = this,
  5789. orig = {},
  5790. style = elem.style,
  5791. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  5792. dataShow = dataPriv.get( elem, "fxshow" );
  5793. // Queue-skipping animations hijack the fx hooks
  5794. if ( !opts.queue ) {
  5795. hooks = jQuery._queueHooks( elem, "fx" );
  5796. if ( hooks.unqueued == null ) {
  5797. hooks.unqueued = 0;
  5798. oldfire = hooks.empty.fire;
  5799. hooks.empty.fire = function() {
  5800. if ( !hooks.unqueued ) {
  5801. oldfire();
  5802. }
  5803. };
  5804. }
  5805. hooks.unqueued++;
  5806. anim.always( function() {
  5807. // Ensure the complete handler is called before this completes
  5808. anim.always( function() {
  5809. hooks.unqueued--;
  5810. if ( !jQuery.queue( elem, "fx" ).length ) {
  5811. hooks.empty.fire();
  5812. }
  5813. } );
  5814. } );
  5815. }
  5816. // Detect show/hide animations
  5817. for ( prop in props ) {
  5818. value = props[ prop ];
  5819. if ( rfxtypes.test( value ) ) {
  5820. delete props[ prop ];
  5821. toggle = toggle || value === "toggle";
  5822. if ( value === ( hidden ? "hide" : "show" ) ) {
  5823. // Pretend to be hidden if this is a "show" and
  5824. // there is still data from a stopped show/hide
  5825. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5826. hidden = true;
  5827. // Ignore all other no-op show/hide data
  5828. } else {
  5829. continue;
  5830. }
  5831. }
  5832. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5833. }
  5834. }
  5835. // Bail out if this is a no-op like .hide().hide()
  5836. propTween = !jQuery.isEmptyObject( props );
  5837. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  5838. return;
  5839. }
  5840. // Restrict "overflow" and "display" styles during box animations
  5841. if ( isBox && elem.nodeType === 1 ) {
  5842. // Support: IE <=9 - 11, Edge 12 - 15
  5843. // Record all 3 overflow attributes because IE does not infer the shorthand
  5844. // from identically-valued overflowX and overflowY and Edge just mirrors
  5845. // the overflowX value there.
  5846. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5847. // Identify a display type, preferring old show/hide data over the CSS cascade
  5848. restoreDisplay = dataShow && dataShow.display;
  5849. if ( restoreDisplay == null ) {
  5850. restoreDisplay = dataPriv.get( elem, "display" );
  5851. }
  5852. display = jQuery.css( elem, "display" );
  5853. if ( display === "none" ) {
  5854. if ( restoreDisplay ) {
  5855. display = restoreDisplay;
  5856. } else {
  5857. // Get nonempty value(s) by temporarily forcing visibility
  5858. showHide( [ elem ], true );
  5859. restoreDisplay = elem.style.display || restoreDisplay;
  5860. display = jQuery.css( elem, "display" );
  5861. showHide( [ elem ] );
  5862. }
  5863. }
  5864. // Animate inline elements as inline-block
  5865. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  5866. if ( jQuery.css( elem, "float" ) === "none" ) {
  5867. // Restore the original display value at the end of pure show/hide animations
  5868. if ( !propTween ) {
  5869. anim.done( function() {
  5870. style.display = restoreDisplay;
  5871. } );
  5872. if ( restoreDisplay == null ) {
  5873. display = style.display;
  5874. restoreDisplay = display === "none" ? "" : display;
  5875. }
  5876. }
  5877. style.display = "inline-block";
  5878. }
  5879. }
  5880. }
  5881. if ( opts.overflow ) {
  5882. style.overflow = "hidden";
  5883. anim.always( function() {
  5884. style.overflow = opts.overflow[ 0 ];
  5885. style.overflowX = opts.overflow[ 1 ];
  5886. style.overflowY = opts.overflow[ 2 ];
  5887. } );
  5888. }
  5889. // Implement show/hide animations
  5890. propTween = false;
  5891. for ( prop in orig ) {
  5892. // General show/hide setup for this element animation
  5893. if ( !propTween ) {
  5894. if ( dataShow ) {
  5895. if ( "hidden" in dataShow ) {
  5896. hidden = dataShow.hidden;
  5897. }
  5898. } else {
  5899. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  5900. }
  5901. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  5902. if ( toggle ) {
  5903. dataShow.hidden = !hidden;
  5904. }
  5905. // Show elements before animating them
  5906. if ( hidden ) {
  5907. showHide( [ elem ], true );
  5908. }
  5909. /* eslint-disable no-loop-func */
  5910. anim.done( function() {
  5911. /* eslint-enable no-loop-func */
  5912. // The final step of a "hide" animation is actually hiding the element
  5913. if ( !hidden ) {
  5914. showHide( [ elem ] );
  5915. }
  5916. dataPriv.remove( elem, "fxshow" );
  5917. for ( prop in orig ) {
  5918. jQuery.style( elem, prop, orig[ prop ] );
  5919. }
  5920. } );
  5921. }
  5922. // Per-property setup
  5923. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  5924. if ( !( prop in dataShow ) ) {
  5925. dataShow[ prop ] = propTween.start;
  5926. if ( hidden ) {
  5927. propTween.end = propTween.start;
  5928. propTween.start = 0;
  5929. }
  5930. }
  5931. }
  5932. }
  5933. function propFilter( props, specialEasing ) {
  5934. var index, name, easing, value, hooks;
  5935. // camelCase, specialEasing and expand cssHook pass
  5936. for ( index in props ) {
  5937. name = camelCase( index );
  5938. easing = specialEasing[ name ];
  5939. value = props[ index ];
  5940. if ( Array.isArray( value ) ) {
  5941. easing = value[ 1 ];
  5942. value = props[ index ] = value[ 0 ];
  5943. }
  5944. if ( index !== name ) {
  5945. props[ name ] = value;
  5946. delete props[ index ];
  5947. }
  5948. hooks = jQuery.cssHooks[ name ];
  5949. if ( hooks && "expand" in hooks ) {
  5950. value = hooks.expand( value );
  5951. delete props[ name ];
  5952. // Not quite $.extend, this won't overwrite existing keys.
  5953. // Reusing 'index' because we have the correct "name"
  5954. for ( index in value ) {
  5955. if ( !( index in props ) ) {
  5956. props[ index ] = value[ index ];
  5957. specialEasing[ index ] = easing;
  5958. }
  5959. }
  5960. } else {
  5961. specialEasing[ name ] = easing;
  5962. }
  5963. }
  5964. }
  5965. function Animation( elem, properties, options ) {
  5966. var result,
  5967. stopped,
  5968. index = 0,
  5969. length = Animation.prefilters.length,
  5970. deferred = jQuery.Deferred().always( function() {
  5971. // Don't match elem in the :animated selector
  5972. delete tick.elem;
  5973. } ),
  5974. tick = function() {
  5975. if ( stopped ) {
  5976. return false;
  5977. }
  5978. var currentTime = fxNow || createFxNow(),
  5979. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  5980. // Support: Android 2.3 only
  5981. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  5982. temp = remaining / animation.duration || 0,
  5983. percent = 1 - temp,
  5984. index = 0,
  5985. length = animation.tweens.length;
  5986. for ( ; index < length; index++ ) {
  5987. animation.tweens[ index ].run( percent );
  5988. }
  5989. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  5990. // If there's more to do, yield
  5991. if ( percent < 1 && length ) {
  5992. return remaining;
  5993. }
  5994. // If this was an empty animation, synthesize a final progress notification
  5995. if ( !length ) {
  5996. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  5997. }
  5998. // Resolve the animation and report its conclusion
  5999. deferred.resolveWith( elem, [ animation ] );
  6000. return false;
  6001. },
  6002. animation = deferred.promise( {
  6003. elem: elem,
  6004. props: jQuery.extend( {}, properties ),
  6005. opts: jQuery.extend( true, {
  6006. specialEasing: {},
  6007. easing: jQuery.easing._default
  6008. }, options ),
  6009. originalProperties: properties,
  6010. originalOptions: options,
  6011. startTime: fxNow || createFxNow(),
  6012. duration: options.duration,
  6013. tweens: [],
  6014. createTween: function( prop, end ) {
  6015. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6016. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6017. animation.tweens.push( tween );
  6018. return tween;
  6019. },
  6020. stop: function( gotoEnd ) {
  6021. var index = 0,
  6022. // If we are going to the end, we want to run all the tweens
  6023. // otherwise we skip this part
  6024. length = gotoEnd ? animation.tweens.length : 0;
  6025. if ( stopped ) {
  6026. return this;
  6027. }
  6028. stopped = true;
  6029. for ( ; index < length; index++ ) {
  6030. animation.tweens[ index ].run( 1 );
  6031. }
  6032. // Resolve when we played the last frame; otherwise, reject
  6033. if ( gotoEnd ) {
  6034. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  6035. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6036. } else {
  6037. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6038. }
  6039. return this;
  6040. }
  6041. } ),
  6042. props = animation.props;
  6043. propFilter( props, animation.opts.specialEasing );
  6044. for ( ; index < length; index++ ) {
  6045. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  6046. if ( result ) {
  6047. if ( isFunction( result.stop ) ) {
  6048. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  6049. result.stop.bind( result );
  6050. }
  6051. return result;
  6052. }
  6053. }
  6054. jQuery.map( props, createTween, animation );
  6055. if ( isFunction( animation.opts.start ) ) {
  6056. animation.opts.start.call( elem, animation );
  6057. }
  6058. // Attach callbacks from options
  6059. animation
  6060. .progress( animation.opts.progress )
  6061. .done( animation.opts.done, animation.opts.complete )
  6062. .fail( animation.opts.fail )
  6063. .always( animation.opts.always );
  6064. jQuery.fx.timer(
  6065. jQuery.extend( tick, {
  6066. elem: elem,
  6067. anim: animation,
  6068. queue: animation.opts.queue
  6069. } )
  6070. );
  6071. return animation;
  6072. }
  6073. jQuery.Animation = jQuery.extend( Animation, {
  6074. tweeners: {
  6075. "*": [ function( prop, value ) {
  6076. var tween = this.createTween( prop, value );
  6077. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  6078. return tween;
  6079. } ]
  6080. },
  6081. tweener: function( props, callback ) {
  6082. if ( isFunction( props ) ) {
  6083. callback = props;
  6084. props = [ "*" ];
  6085. } else {
  6086. props = props.match( rnothtmlwhite );
  6087. }
  6088. var prop,
  6089. index = 0,
  6090. length = props.length;
  6091. for ( ; index < length; index++ ) {
  6092. prop = props[ index ];
  6093. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  6094. Animation.tweeners[ prop ].unshift( callback );
  6095. }
  6096. },
  6097. prefilters: [ defaultPrefilter ],
  6098. prefilter: function( callback, prepend ) {
  6099. if ( prepend ) {
  6100. Animation.prefilters.unshift( callback );
  6101. } else {
  6102. Animation.prefilters.push( callback );
  6103. }
  6104. }
  6105. } );
  6106. jQuery.speed = function( speed, easing, fn ) {
  6107. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6108. complete: fn || !fn && easing ||
  6109. isFunction( speed ) && speed,
  6110. duration: speed,
  6111. easing: fn && easing || easing && !isFunction( easing ) && easing
  6112. };
  6113. // Go to the end state if fx are off
  6114. if ( jQuery.fx.off ) {
  6115. opt.duration = 0;
  6116. } else {
  6117. if ( typeof opt.duration !== "number" ) {
  6118. if ( opt.duration in jQuery.fx.speeds ) {
  6119. opt.duration = jQuery.fx.speeds[ opt.duration ];
  6120. } else {
  6121. opt.duration = jQuery.fx.speeds._default;
  6122. }
  6123. }
  6124. }
  6125. // Normalize opt.queue - true/undefined/null -> "fx"
  6126. if ( opt.queue == null || opt.queue === true ) {
  6127. opt.queue = "fx";
  6128. }
  6129. // Queueing
  6130. opt.old = opt.complete;
  6131. opt.complete = function() {
  6132. if ( isFunction( opt.old ) ) {
  6133. opt.old.call( this );
  6134. }
  6135. if ( opt.queue ) {
  6136. jQuery.dequeue( this, opt.queue );
  6137. }
  6138. };
  6139. return opt;
  6140. };
  6141. jQuery.fn.extend( {
  6142. fadeTo: function( speed, to, easing, callback ) {
  6143. // Show any hidden elements after setting opacity to 0
  6144. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  6145. // Animate to the value specified
  6146. .end().animate( { opacity: to }, speed, easing, callback );
  6147. },
  6148. animate: function( prop, speed, easing, callback ) {
  6149. var empty = jQuery.isEmptyObject( prop ),
  6150. optall = jQuery.speed( speed, easing, callback ),
  6151. doAnimation = function() {
  6152. // Operate on a copy of prop so per-property easing won't be lost
  6153. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6154. // Empty animations, or finishing resolves immediately
  6155. if ( empty || dataPriv.get( this, "finish" ) ) {
  6156. anim.stop( true );
  6157. }
  6158. };
  6159. doAnimation.finish = doAnimation;
  6160. return empty || optall.queue === false ?
  6161. this.each( doAnimation ) :
  6162. this.queue( optall.queue, doAnimation );
  6163. },
  6164. stop: function( type, clearQueue, gotoEnd ) {
  6165. var stopQueue = function( hooks ) {
  6166. var stop = hooks.stop;
  6167. delete hooks.stop;
  6168. stop( gotoEnd );
  6169. };
  6170. if ( typeof type !== "string" ) {
  6171. gotoEnd = clearQueue;
  6172. clearQueue = type;
  6173. type = undefined;
  6174. }
  6175. if ( clearQueue && type !== false ) {
  6176. this.queue( type || "fx", [] );
  6177. }
  6178. return this.each( function() {
  6179. var dequeue = true,
  6180. index = type != null && type + "queueHooks",
  6181. timers = jQuery.timers,
  6182. data = dataPriv.get( this );
  6183. if ( index ) {
  6184. if ( data[ index ] && data[ index ].stop ) {
  6185. stopQueue( data[ index ] );
  6186. }
  6187. } else {
  6188. for ( index in data ) {
  6189. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6190. stopQueue( data[ index ] );
  6191. }
  6192. }
  6193. }
  6194. for ( index = timers.length; index--; ) {
  6195. if ( timers[ index ].elem === this &&
  6196. ( type == null || timers[ index ].queue === type ) ) {
  6197. timers[ index ].anim.stop( gotoEnd );
  6198. dequeue = false;
  6199. timers.splice( index, 1 );
  6200. }
  6201. }
  6202. // Start the next in the queue if the last step wasn't forced.
  6203. // Timers currently will call their complete callbacks, which
  6204. // will dequeue but only if they were gotoEnd.
  6205. if ( dequeue || !gotoEnd ) {
  6206. jQuery.dequeue( this, type );
  6207. }
  6208. } );
  6209. },
  6210. finish: function( type ) {
  6211. if ( type !== false ) {
  6212. type = type || "fx";
  6213. }
  6214. return this.each( function() {
  6215. var index,
  6216. data = dataPriv.get( this ),
  6217. queue = data[ type + "queue" ],
  6218. hooks = data[ type + "queueHooks" ],
  6219. timers = jQuery.timers,
  6220. length = queue ? queue.length : 0;
  6221. // Enable finishing flag on private data
  6222. data.finish = true;
  6223. // Empty the queue first
  6224. jQuery.queue( this, type, [] );
  6225. if ( hooks && hooks.stop ) {
  6226. hooks.stop.call( this, true );
  6227. }
  6228. // Look for any active animations, and finish them
  6229. for ( index = timers.length; index--; ) {
  6230. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6231. timers[ index ].anim.stop( true );
  6232. timers.splice( index, 1 );
  6233. }
  6234. }
  6235. // Look for any animations in the old queue and finish them
  6236. for ( index = 0; index < length; index++ ) {
  6237. if ( queue[ index ] && queue[ index ].finish ) {
  6238. queue[ index ].finish.call( this );
  6239. }
  6240. }
  6241. // Turn off finishing flag
  6242. delete data.finish;
  6243. } );
  6244. }
  6245. } );
  6246. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  6247. var cssFn = jQuery.fn[ name ];
  6248. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6249. return speed == null || typeof speed === "boolean" ?
  6250. cssFn.apply( this, arguments ) :
  6251. this.animate( genFx( name, true ), speed, easing, callback );
  6252. };
  6253. } );
  6254. // Generate shortcuts for custom animations
  6255. jQuery.each( {
  6256. slideDown: genFx( "show" ),
  6257. slideUp: genFx( "hide" ),
  6258. slideToggle: genFx( "toggle" ),
  6259. fadeIn: { opacity: "show" },
  6260. fadeOut: { opacity: "hide" },
  6261. fadeToggle: { opacity: "toggle" }
  6262. }, function( name, props ) {
  6263. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6264. return this.animate( props, speed, easing, callback );
  6265. };
  6266. } );
  6267. jQuery.timers = [];
  6268. jQuery.fx.tick = function() {
  6269. var timer,
  6270. i = 0,
  6271. timers = jQuery.timers;
  6272. fxNow = Date.now();
  6273. for ( ; i < timers.length; i++ ) {
  6274. timer = timers[ i ];
  6275. // Run the timer and safely remove it when done (allowing for external removal)
  6276. if ( !timer() && timers[ i ] === timer ) {
  6277. timers.splice( i--, 1 );
  6278. }
  6279. }
  6280. if ( !timers.length ) {
  6281. jQuery.fx.stop();
  6282. }
  6283. fxNow = undefined;
  6284. };
  6285. jQuery.fx.timer = function( timer ) {
  6286. jQuery.timers.push( timer );
  6287. jQuery.fx.start();
  6288. };
  6289. jQuery.fx.interval = 13;
  6290. jQuery.fx.start = function() {
  6291. if ( inProgress ) {
  6292. return;
  6293. }
  6294. inProgress = true;
  6295. schedule();
  6296. };
  6297. jQuery.fx.stop = function() {
  6298. inProgress = null;
  6299. };
  6300. jQuery.fx.speeds = {
  6301. slow: 600,
  6302. fast: 200,
  6303. // Default speed
  6304. _default: 400
  6305. };
  6306. // Based off of the plugin by Clint Helfers, with permission.
  6307. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  6308. jQuery.fn.delay = function( time, type ) {
  6309. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6310. type = type || "fx";
  6311. return this.queue( type, function( next, hooks ) {
  6312. var timeout = window.setTimeout( next, time );
  6313. hooks.stop = function() {
  6314. window.clearTimeout( timeout );
  6315. };
  6316. } );
  6317. };
  6318. ( function() {
  6319. var input = document.createElement( "input" ),
  6320. select = document.createElement( "select" ),
  6321. opt = select.appendChild( document.createElement( "option" ) );
  6322. input.type = "checkbox";
  6323. // Support: Android <=4.3 only
  6324. // Default value for a checkbox should be "on"
  6325. support.checkOn = input.value !== "";
  6326. // Support: IE <=11 only
  6327. // Must access selectedIndex to make default options select
  6328. support.optSelected = opt.selected;
  6329. // Support: IE <=11 only
  6330. // An input loses its value after becoming a radio
  6331. input = document.createElement( "input" );
  6332. input.value = "t";
  6333. input.type = "radio";
  6334. support.radioValue = input.value === "t";
  6335. } )();
  6336. var boolHook,
  6337. attrHandle = jQuery.expr.attrHandle;
  6338. jQuery.fn.extend( {
  6339. attr: function( name, value ) {
  6340. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6341. },
  6342. removeAttr: function( name ) {
  6343. return this.each( function() {
  6344. jQuery.removeAttr( this, name );
  6345. } );
  6346. }
  6347. } );
  6348. jQuery.extend( {
  6349. attr: function( elem, name, value ) {
  6350. var ret, hooks,
  6351. nType = elem.nodeType;
  6352. // Don't get/set attributes on text, comment and attribute nodes
  6353. if ( nType === 3 || nType === 8 || nType === 2 ) {
  6354. return;
  6355. }
  6356. // Fallback to prop when attributes are not supported
  6357. if ( typeof elem.getAttribute === "undefined" ) {
  6358. return jQuery.prop( elem, name, value );
  6359. }
  6360. // Attribute hooks are determined by the lowercase version
  6361. // Grab necessary hook if one is defined
  6362. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6363. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  6364. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  6365. }
  6366. if ( value !== undefined ) {
  6367. if ( value === null ) {
  6368. jQuery.removeAttr( elem, name );
  6369. return;
  6370. }
  6371. if ( hooks && "set" in hooks &&
  6372. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  6373. return ret;
  6374. }
  6375. elem.setAttribute( name, value + "" );
  6376. return value;
  6377. }
  6378. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  6379. return ret;
  6380. }
  6381. ret = jQuery.find.attr( elem, name );
  6382. // Non-existent attributes return null, we normalize to undefined
  6383. return ret == null ? undefined : ret;
  6384. },
  6385. attrHooks: {
  6386. type: {
  6387. set: function( elem, value ) {
  6388. if ( !support.radioValue && value === "radio" &&
  6389. nodeName( elem, "input" ) ) {
  6390. var val = elem.value;
  6391. elem.setAttribute( "type", value );
  6392. if ( val ) {
  6393. elem.value = val;
  6394. }
  6395. return value;
  6396. }
  6397. }
  6398. }
  6399. },
  6400. removeAttr: function( elem, value ) {
  6401. var name,
  6402. i = 0,
  6403. // Attribute names can contain non-HTML whitespace characters
  6404. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  6405. attrNames = value && value.match( rnothtmlwhite );
  6406. if ( attrNames && elem.nodeType === 1 ) {
  6407. while ( ( name = attrNames[ i++ ] ) ) {
  6408. elem.removeAttribute( name );
  6409. }
  6410. }
  6411. }
  6412. } );
  6413. // Hooks for boolean attributes
  6414. boolHook = {
  6415. set: function( elem, value, name ) {
  6416. if ( value === false ) {
  6417. // Remove boolean attributes when set to false
  6418. jQuery.removeAttr( elem, name );
  6419. } else {
  6420. elem.setAttribute( name, name );
  6421. }
  6422. return name;
  6423. }
  6424. };
  6425. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6426. var getter = attrHandle[ name ] || jQuery.find.attr;
  6427. attrHandle[ name ] = function( elem, name, isXML ) {
  6428. var ret, handle,
  6429. lowercaseName = name.toLowerCase();
  6430. if ( !isXML ) {
  6431. // Avoid an infinite loop by temporarily removing this function from the getter
  6432. handle = attrHandle[ lowercaseName ];
  6433. attrHandle[ lowercaseName ] = ret;
  6434. ret = getter( elem, name, isXML ) != null ?
  6435. lowercaseName :
  6436. null;
  6437. attrHandle[ lowercaseName ] = handle;
  6438. }
  6439. return ret;
  6440. };
  6441. } );
  6442. var rfocusable = /^(?:input|select|textarea|button)$/i,
  6443. rclickable = /^(?:a|area)$/i;
  6444. jQuery.fn.extend( {
  6445. prop: function( name, value ) {
  6446. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6447. },
  6448. removeProp: function( name ) {
  6449. return this.each( function() {
  6450. delete this[ jQuery.propFix[ name ] || name ];
  6451. } );
  6452. }
  6453. } );
  6454. jQuery.extend( {
  6455. prop: function( elem, name, value ) {
  6456. var ret, hooks,
  6457. nType = elem.nodeType;
  6458. // Don't get/set properties on text, comment and attribute nodes
  6459. if ( nType === 3 || nType === 8 || nType === 2 ) {
  6460. return;
  6461. }
  6462. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6463. // Fix name and attach hooks
  6464. name = jQuery.propFix[ name ] || name;
  6465. hooks = jQuery.propHooks[ name ];
  6466. }
  6467. if ( value !== undefined ) {
  6468. if ( hooks && "set" in hooks &&
  6469. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  6470. return ret;
  6471. }
  6472. return ( elem[ name ] = value );
  6473. }
  6474. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  6475. return ret;
  6476. }
  6477. return elem[ name ];
  6478. },
  6479. propHooks: {
  6480. tabIndex: {
  6481. get: function( elem ) {
  6482. // Support: IE <=9 - 11 only
  6483. // elem.tabIndex doesn't always return the
  6484. // correct value when it hasn't been explicitly set
  6485. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  6486. // Use proper attribute retrieval(#12072)
  6487. var tabindex = jQuery.find.attr( elem, "tabindex" );
  6488. if ( tabindex ) {
  6489. return parseInt( tabindex, 10 );
  6490. }
  6491. if (
  6492. rfocusable.test( elem.nodeName ) ||
  6493. rclickable.test( elem.nodeName ) &&
  6494. elem.href
  6495. ) {
  6496. return 0;
  6497. }
  6498. return -1;
  6499. }
  6500. }
  6501. },
  6502. propFix: {
  6503. "for": "htmlFor",
  6504. "class": "className"
  6505. }
  6506. } );
  6507. // Support: IE <=11 only
  6508. // Accessing the selectedIndex property
  6509. // forces the browser to respect setting selected
  6510. // on the option
  6511. // The getter ensures a default option is selected
  6512. // when in an optgroup
  6513. // eslint rule "no-unused-expressions" is disabled for this code
  6514. // since it considers such accessions noop
  6515. if ( !support.optSelected ) {
  6516. jQuery.propHooks.selected = {
  6517. get: function( elem ) {
  6518. /* eslint no-unused-expressions: "off" */
  6519. var parent = elem.parentNode;
  6520. if ( parent && parent.parentNode ) {
  6521. parent.parentNode.selectedIndex;
  6522. }
  6523. return null;
  6524. },
  6525. set: function( elem ) {
  6526. /* eslint no-unused-expressions: "off" */
  6527. var parent = elem.parentNode;
  6528. if ( parent ) {
  6529. parent.selectedIndex;
  6530. if ( parent.parentNode ) {
  6531. parent.parentNode.selectedIndex;
  6532. }
  6533. }
  6534. }
  6535. };
  6536. }
  6537. jQuery.each( [
  6538. "tabIndex",
  6539. "readOnly",
  6540. "maxLength",
  6541. "cellSpacing",
  6542. "cellPadding",
  6543. "rowSpan",
  6544. "colSpan",
  6545. "useMap",
  6546. "frameBorder",
  6547. "contentEditable"
  6548. ], function() {
  6549. jQuery.propFix[ this.toLowerCase() ] = this;
  6550. } );
  6551. // Strip and collapse whitespace according to HTML spec
  6552. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  6553. function stripAndCollapse( value ) {
  6554. var tokens = value.match( rnothtmlwhite ) || [];
  6555. return tokens.join( " " );
  6556. }
  6557. function getClass( elem ) {
  6558. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  6559. }
  6560. function classesToArray( value ) {
  6561. if ( Array.isArray( value ) ) {
  6562. return value;
  6563. }
  6564. if ( typeof value === "string" ) {
  6565. return value.match( rnothtmlwhite ) || [];
  6566. }
  6567. return [];
  6568. }
  6569. jQuery.fn.extend( {
  6570. addClass: function( value ) {
  6571. var classes, elem, cur, curValue, clazz, j, finalValue,
  6572. i = 0;
  6573. if ( isFunction( value ) ) {
  6574. return this.each( function( j ) {
  6575. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  6576. } );
  6577. }
  6578. classes = classesToArray( value );
  6579. if ( classes.length ) {
  6580. while ( ( elem = this[ i++ ] ) ) {
  6581. curValue = getClass( elem );
  6582. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  6583. if ( cur ) {
  6584. j = 0;
  6585. while ( ( clazz = classes[ j++ ] ) ) {
  6586. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6587. cur += clazz + " ";
  6588. }
  6589. }
  6590. // Only assign if different to avoid unneeded rendering.
  6591. finalValue = stripAndCollapse( cur );
  6592. if ( curValue !== finalValue ) {
  6593. elem.setAttribute( "class", finalValue );
  6594. }
  6595. }
  6596. }
  6597. }
  6598. return this;
  6599. },
  6600. removeClass: function( value ) {
  6601. var classes, elem, cur, curValue, clazz, j, finalValue,
  6602. i = 0;
  6603. if ( isFunction( value ) ) {
  6604. return this.each( function( j ) {
  6605. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  6606. } );
  6607. }
  6608. if ( !arguments.length ) {
  6609. return this.attr( "class", "" );
  6610. }
  6611. classes = classesToArray( value );
  6612. if ( classes.length ) {
  6613. while ( ( elem = this[ i++ ] ) ) {
  6614. curValue = getClass( elem );
  6615. // This expression is here for better compressibility (see addClass)
  6616. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  6617. if ( cur ) {
  6618. j = 0;
  6619. while ( ( clazz = classes[ j++ ] ) ) {
  6620. // Remove *all* instances
  6621. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  6622. cur = cur.replace( " " + clazz + " ", " " );
  6623. }
  6624. }
  6625. // Only assign if different to avoid unneeded rendering.
  6626. finalValue = stripAndCollapse( cur );
  6627. if ( curValue !== finalValue ) {
  6628. elem.setAttribute( "class", finalValue );
  6629. }
  6630. }
  6631. }
  6632. }
  6633. return this;
  6634. },
  6635. toggleClass: function( value, stateVal ) {
  6636. var type = typeof value,
  6637. isValidValue = type === "string" || Array.isArray( value );
  6638. if ( typeof stateVal === "boolean" && isValidValue ) {
  6639. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6640. }
  6641. if ( isFunction( value ) ) {
  6642. return this.each( function( i ) {
  6643. jQuery( this ).toggleClass(
  6644. value.call( this, i, getClass( this ), stateVal ),
  6645. stateVal
  6646. );
  6647. } );
  6648. }
  6649. return this.each( function() {
  6650. var className, i, self, classNames;
  6651. if ( isValidValue ) {
  6652. // Toggle individual class names
  6653. i = 0;
  6654. self = jQuery( this );
  6655. classNames = classesToArray( value );
  6656. while ( ( className = classNames[ i++ ] ) ) {
  6657. // Check each className given, space separated list
  6658. if ( self.hasClass( className ) ) {
  6659. self.removeClass( className );
  6660. } else {
  6661. self.addClass( className );
  6662. }
  6663. }
  6664. // Toggle whole class name
  6665. } else if ( value === undefined || type === "boolean" ) {
  6666. className = getClass( this );
  6667. if ( className ) {
  6668. // Store className if set
  6669. dataPriv.set( this, "__className__", className );
  6670. }
  6671. // If the element has a class name or if we're passed `false`,
  6672. // then remove the whole classname (if there was one, the above saved it).
  6673. // Otherwise bring back whatever was previously saved (if anything),
  6674. // falling back to the empty string if nothing was stored.
  6675. if ( this.setAttribute ) {
  6676. this.setAttribute( "class",
  6677. className || value === false ?
  6678. "" :
  6679. dataPriv.get( this, "__className__" ) || ""
  6680. );
  6681. }
  6682. }
  6683. } );
  6684. },
  6685. hasClass: function( selector ) {
  6686. var className, elem,
  6687. i = 0;
  6688. className = " " + selector + " ";
  6689. while ( ( elem = this[ i++ ] ) ) {
  6690. if ( elem.nodeType === 1 &&
  6691. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  6692. return true;
  6693. }
  6694. }
  6695. return false;
  6696. }
  6697. } );
  6698. var rreturn = /\r/g;
  6699. jQuery.fn.extend( {
  6700. val: function( value ) {
  6701. var hooks, ret, valueIsFunction,
  6702. elem = this[ 0 ];
  6703. if ( !arguments.length ) {
  6704. if ( elem ) {
  6705. hooks = jQuery.valHooks[ elem.type ] ||
  6706. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6707. if ( hooks &&
  6708. "get" in hooks &&
  6709. ( ret = hooks.get( elem, "value" ) ) !== undefined
  6710. ) {
  6711. return ret;
  6712. }
  6713. ret = elem.value;
  6714. // Handle most common string cases
  6715. if ( typeof ret === "string" ) {
  6716. return ret.replace( rreturn, "" );
  6717. }
  6718. // Handle cases where value is null/undef or number
  6719. return ret == null ? "" : ret;
  6720. }
  6721. return;
  6722. }
  6723. valueIsFunction = isFunction( value );
  6724. return this.each( function( i ) {
  6725. var val;
  6726. if ( this.nodeType !== 1 ) {
  6727. return;
  6728. }
  6729. if ( valueIsFunction ) {
  6730. val = value.call( this, i, jQuery( this ).val() );
  6731. } else {
  6732. val = value;
  6733. }
  6734. // Treat null/undefined as ""; convert numbers to string
  6735. if ( val == null ) {
  6736. val = "";
  6737. } else if ( typeof val === "number" ) {
  6738. val += "";
  6739. } else if ( Array.isArray( val ) ) {
  6740. val = jQuery.map( val, function( value ) {
  6741. return value == null ? "" : value + "";
  6742. } );
  6743. }
  6744. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6745. // If set returns undefined, fall back to normal setting
  6746. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  6747. this.value = val;
  6748. }
  6749. } );
  6750. }
  6751. } );
  6752. jQuery.extend( {
  6753. valHooks: {
  6754. option: {
  6755. get: function( elem ) {
  6756. var val = jQuery.find.attr( elem, "value" );
  6757. return val != null ?
  6758. val :
  6759. // Support: IE <=10 - 11 only
  6760. // option.text throws exceptions (#14686, #14858)
  6761. // Strip and collapse whitespace
  6762. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  6763. stripAndCollapse( jQuery.text( elem ) );
  6764. }
  6765. },
  6766. select: {
  6767. get: function( elem ) {
  6768. var value, option, i,
  6769. options = elem.options,
  6770. index = elem.selectedIndex,
  6771. one = elem.type === "select-one",
  6772. values = one ? null : [],
  6773. max = one ? index + 1 : options.length;
  6774. if ( index < 0 ) {
  6775. i = max;
  6776. } else {
  6777. i = one ? index : 0;
  6778. }
  6779. // Loop through all the selected options
  6780. for ( ; i < max; i++ ) {
  6781. option = options[ i ];
  6782. // Support: IE <=9 only
  6783. // IE8-9 doesn't update selected after form reset (#2551)
  6784. if ( ( option.selected || i === index ) &&
  6785. // Don't return options that are disabled or in a disabled optgroup
  6786. !option.disabled &&
  6787. ( !option.parentNode.disabled ||
  6788. !nodeName( option.parentNode, "optgroup" ) ) ) {
  6789. // Get the specific value for the option
  6790. value = jQuery( option ).val();
  6791. // We don't need an array for one selects
  6792. if ( one ) {
  6793. return value;
  6794. }
  6795. // Multi-Selects return an array
  6796. values.push( value );
  6797. }
  6798. }
  6799. return values;
  6800. },
  6801. set: function( elem, value ) {
  6802. var optionSet, option,
  6803. options = elem.options,
  6804. values = jQuery.makeArray( value ),
  6805. i = options.length;
  6806. while ( i-- ) {
  6807. option = options[ i ];
  6808. /* eslint-disable no-cond-assign */
  6809. if ( option.selected =
  6810. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  6811. ) {
  6812. optionSet = true;
  6813. }
  6814. /* eslint-enable no-cond-assign */
  6815. }
  6816. // Force browsers to behave consistently when non-matching value is set
  6817. if ( !optionSet ) {
  6818. elem.selectedIndex = -1;
  6819. }
  6820. return values;
  6821. }
  6822. }
  6823. }
  6824. } );
  6825. // Radios and checkboxes getter/setter
  6826. jQuery.each( [ "radio", "checkbox" ], function() {
  6827. jQuery.valHooks[ this ] = {
  6828. set: function( elem, value ) {
  6829. if ( Array.isArray( value ) ) {
  6830. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  6831. }
  6832. }
  6833. };
  6834. if ( !support.checkOn ) {
  6835. jQuery.valHooks[ this ].get = function( elem ) {
  6836. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  6837. };
  6838. }
  6839. } );
  6840. // Return jQuery for attributes-only inclusion
  6841. support.focusin = "onfocusin" in window;
  6842. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  6843. stopPropagationCallback = function( e ) {
  6844. e.stopPropagation();
  6845. };
  6846. jQuery.extend( jQuery.event, {
  6847. trigger: function( event, data, elem, onlyHandlers ) {
  6848. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  6849. eventPath = [ elem || document ],
  6850. type = hasOwn.call( event, "type" ) ? event.type : event,
  6851. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  6852. cur = lastElement = tmp = elem = elem || document;
  6853. // Don't do events on text and comment nodes
  6854. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  6855. return;
  6856. }
  6857. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  6858. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  6859. return;
  6860. }
  6861. if ( type.indexOf( "." ) > -1 ) {
  6862. // Namespaced trigger; create a regexp to match event type in handle()
  6863. namespaces = type.split( "." );
  6864. type = namespaces.shift();
  6865. namespaces.sort();
  6866. }
  6867. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  6868. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  6869. event = event[ jQuery.expando ] ?
  6870. event :
  6871. new jQuery.Event( type, typeof event === "object" && event );
  6872. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  6873. event.isTrigger = onlyHandlers ? 2 : 3;
  6874. event.namespace = namespaces.join( "." );
  6875. event.rnamespace = event.namespace ?
  6876. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  6877. null;
  6878. // Clean up the event in case it is being reused
  6879. event.result = undefined;
  6880. if ( !event.target ) {
  6881. event.target = elem;
  6882. }
  6883. // Clone any incoming data and prepend the event, creating the handler arg list
  6884. data = data == null ?
  6885. [ event ] :
  6886. jQuery.makeArray( data, [ event ] );
  6887. // Allow special events to draw outside the lines
  6888. special = jQuery.event.special[ type ] || {};
  6889. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  6890. return;
  6891. }
  6892. // Determine event propagation path in advance, per W3C events spec (#9951)
  6893. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  6894. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  6895. bubbleType = special.delegateType || type;
  6896. if ( !rfocusMorph.test( bubbleType + type ) ) {
  6897. cur = cur.parentNode;
  6898. }
  6899. for ( ; cur; cur = cur.parentNode ) {
  6900. eventPath.push( cur );
  6901. tmp = cur;
  6902. }
  6903. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  6904. if ( tmp === ( elem.ownerDocument || document ) ) {
  6905. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  6906. }
  6907. }
  6908. // Fire handlers on the event path
  6909. i = 0;
  6910. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  6911. lastElement = cur;
  6912. event.type = i > 1 ?
  6913. bubbleType :
  6914. special.bindType || type;
  6915. // jQuery handler
  6916. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  6917. dataPriv.get( cur, "handle" );
  6918. if ( handle ) {
  6919. handle.apply( cur, data );
  6920. }
  6921. // Native handler
  6922. handle = ontype && cur[ ontype ];
  6923. if ( handle && handle.apply && acceptData( cur ) ) {
  6924. event.result = handle.apply( cur, data );
  6925. if ( event.result === false ) {
  6926. event.preventDefault();
  6927. }
  6928. }
  6929. }
  6930. event.type = type;
  6931. // If nobody prevented the default action, do it now
  6932. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  6933. if ( ( !special._default ||
  6934. special._default.apply( eventPath.pop(), data ) === false ) &&
  6935. acceptData( elem ) ) {
  6936. // Call a native DOM method on the target with the same name as the event.
  6937. // Don't do default actions on window, that's where global variables be (#6170)
  6938. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  6939. // Don't re-trigger an onFOO event when we call its FOO() method
  6940. tmp = elem[ ontype ];
  6941. if ( tmp ) {
  6942. elem[ ontype ] = null;
  6943. }
  6944. // Prevent re-triggering of the same event, since we already bubbled it above
  6945. jQuery.event.triggered = type;
  6946. if ( event.isPropagationStopped() ) {
  6947. lastElement.addEventListener( type, stopPropagationCallback );
  6948. }
  6949. elem[ type ]();
  6950. if ( event.isPropagationStopped() ) {
  6951. lastElement.removeEventListener( type, stopPropagationCallback );
  6952. }
  6953. jQuery.event.triggered = undefined;
  6954. if ( tmp ) {
  6955. elem[ ontype ] = tmp;
  6956. }
  6957. }
  6958. }
  6959. }
  6960. return event.result;
  6961. },
  6962. // Piggyback on a donor event to simulate a different one
  6963. // Used only for `focus(in | out)` events
  6964. simulate: function( type, elem, event ) {
  6965. var e = jQuery.extend(
  6966. new jQuery.Event(),
  6967. event,
  6968. {
  6969. type: type,
  6970. isSimulated: true
  6971. }
  6972. );
  6973. jQuery.event.trigger( e, null, elem );
  6974. }
  6975. } );
  6976. jQuery.fn.extend( {
  6977. trigger: function( type, data ) {
  6978. return this.each( function() {
  6979. jQuery.event.trigger( type, data, this );
  6980. } );
  6981. },
  6982. triggerHandler: function( type, data ) {
  6983. var elem = this[ 0 ];
  6984. if ( elem ) {
  6985. return jQuery.event.trigger( type, data, elem, true );
  6986. }
  6987. }
  6988. } );
  6989. // Support: Firefox <=44
  6990. // Firefox doesn't have focus(in | out) events
  6991. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  6992. //
  6993. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  6994. // focus(in | out) events fire after focus & blur events,
  6995. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  6996. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  6997. if ( !support.focusin ) {
  6998. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  6999. // Attach a single capturing handler on the document while someone wants focusin/focusout
  7000. var handler = function( event ) {
  7001. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  7002. };
  7003. jQuery.event.special[ fix ] = {
  7004. setup: function() {
  7005. var doc = this.ownerDocument || this,
  7006. attaches = dataPriv.access( doc, fix );
  7007. if ( !attaches ) {
  7008. doc.addEventListener( orig, handler, true );
  7009. }
  7010. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  7011. },
  7012. teardown: function() {
  7013. var doc = this.ownerDocument || this,
  7014. attaches = dataPriv.access( doc, fix ) - 1;
  7015. if ( !attaches ) {
  7016. doc.removeEventListener( orig, handler, true );
  7017. dataPriv.remove( doc, fix );
  7018. } else {
  7019. dataPriv.access( doc, fix, attaches );
  7020. }
  7021. }
  7022. };
  7023. } );
  7024. }
  7025. var location = window.location;
  7026. var nonce = Date.now();
  7027. var rquery = ( /\?/ );
  7028. // Cross-browser xml parsing
  7029. jQuery.parseXML = function( data ) {
  7030. var xml;
  7031. if ( !data || typeof data !== "string" ) {
  7032. return null;
  7033. }
  7034. // Support: IE 9 - 11 only
  7035. // IE throws on parseFromString with invalid input.
  7036. try {
  7037. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  7038. } catch ( e ) {
  7039. xml = undefined;
  7040. }
  7041. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  7042. jQuery.error( "Invalid XML: " + data );
  7043. }
  7044. return xml;
  7045. };
  7046. var
  7047. rbracket = /\[\]$/,
  7048. rCRLF = /\r?\n/g,
  7049. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7050. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7051. function buildParams( prefix, obj, traditional, add ) {
  7052. var name;
  7053. if ( Array.isArray( obj ) ) {
  7054. // Serialize array item.
  7055. jQuery.each( obj, function( i, v ) {
  7056. if ( traditional || rbracket.test( prefix ) ) {
  7057. // Treat each array item as a scalar.
  7058. add( prefix, v );
  7059. } else {
  7060. // Item is non-scalar (array or object), encode its numeric index.
  7061. buildParams(
  7062. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  7063. v,
  7064. traditional,
  7065. add
  7066. );
  7067. }
  7068. } );
  7069. } else if ( !traditional && toType( obj ) === "object" ) {
  7070. // Serialize object item.
  7071. for ( name in obj ) {
  7072. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7073. }
  7074. } else {
  7075. // Serialize scalar item.
  7076. add( prefix, obj );
  7077. }
  7078. }
  7079. // Serialize an array of form elements or a set of
  7080. // key/values into a query string
  7081. jQuery.param = function( a, traditional ) {
  7082. var prefix,
  7083. s = [],
  7084. add = function( key, valueOrFunction ) {
  7085. // If value is a function, invoke it and use its return value
  7086. var value = isFunction( valueOrFunction ) ?
  7087. valueOrFunction() :
  7088. valueOrFunction;
  7089. s[ s.length ] = encodeURIComponent( key ) + "=" +
  7090. encodeURIComponent( value == null ? "" : value );
  7091. };
  7092. if ( a == null ) {
  7093. return "";
  7094. }
  7095. // If an array was passed in, assume that it is an array of form elements.
  7096. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7097. // Serialize the form elements
  7098. jQuery.each( a, function() {
  7099. add( this.name, this.value );
  7100. } );
  7101. } else {
  7102. // If traditional, encode the "old" way (the way 1.3.2 or older
  7103. // did it), otherwise encode params recursively.
  7104. for ( prefix in a ) {
  7105. buildParams( prefix, a[ prefix ], traditional, add );
  7106. }
  7107. }
  7108. // Return the resulting serialization
  7109. return s.join( "&" );
  7110. };
  7111. jQuery.fn.extend( {
  7112. serialize: function() {
  7113. return jQuery.param( this.serializeArray() );
  7114. },
  7115. serializeArray: function() {
  7116. return this.map( function() {
  7117. // Can add propHook for "elements" to filter or add form elements
  7118. var elements = jQuery.prop( this, "elements" );
  7119. return elements ? jQuery.makeArray( elements ) : this;
  7120. } )
  7121. .filter( function() {
  7122. var type = this.type;
  7123. // Use .is( ":disabled" ) so that fieldset[disabled] works
  7124. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7125. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7126. ( this.checked || !rcheckableType.test( type ) );
  7127. } )
  7128. .map( function( i, elem ) {
  7129. var val = jQuery( this ).val();
  7130. if ( val == null ) {
  7131. return null;
  7132. }
  7133. if ( Array.isArray( val ) ) {
  7134. return jQuery.map( val, function( val ) {
  7135. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7136. } );
  7137. }
  7138. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7139. } ).get();
  7140. }
  7141. } );
  7142. var
  7143. r20 = /%20/g,
  7144. rhash = /#.*$/,
  7145. rantiCache = /([?&])_=[^&]*/,
  7146. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  7147. // #7653, #8125, #8152: local protocol detection
  7148. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7149. rnoContent = /^(?:GET|HEAD)$/,
  7150. rprotocol = /^\/\//,
  7151. /* Prefilters
  7152. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7153. * 2) These are called:
  7154. * - BEFORE asking for a transport
  7155. * - AFTER param serialization (s.data is a string if s.processData is true)
  7156. * 3) key is the dataType
  7157. * 4) the catchall symbol "*" can be used
  7158. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7159. */
  7160. prefilters = {},
  7161. /* Transports bindings
  7162. * 1) key is the dataType
  7163. * 2) the catchall symbol "*" can be used
  7164. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7165. */
  7166. transports = {},
  7167. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7168. allTypes = "*/".concat( "*" ),
  7169. // Anchor tag for parsing the document origin
  7170. originAnchor = document.createElement( "a" );
  7171. originAnchor.href = location.href;
  7172. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7173. function addToPrefiltersOrTransports( structure ) {
  7174. // dataTypeExpression is optional and defaults to "*"
  7175. return function( dataTypeExpression, func ) {
  7176. if ( typeof dataTypeExpression !== "string" ) {
  7177. func = dataTypeExpression;
  7178. dataTypeExpression = "*";
  7179. }
  7180. var dataType,
  7181. i = 0,
  7182. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  7183. if ( isFunction( func ) ) {
  7184. // For each dataType in the dataTypeExpression
  7185. while ( ( dataType = dataTypes[ i++ ] ) ) {
  7186. // Prepend if requested
  7187. if ( dataType[ 0 ] === "+" ) {
  7188. dataType = dataType.slice( 1 ) || "*";
  7189. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  7190. // Otherwise append
  7191. } else {
  7192. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  7193. }
  7194. }
  7195. }
  7196. };
  7197. }
  7198. // Base inspection function for prefilters and transports
  7199. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7200. var inspected = {},
  7201. seekingTransport = ( structure === transports );
  7202. function inspect( dataType ) {
  7203. var selected;
  7204. inspected[ dataType ] = true;
  7205. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7206. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7207. if ( typeof dataTypeOrTransport === "string" &&
  7208. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7209. options.dataTypes.unshift( dataTypeOrTransport );
  7210. inspect( dataTypeOrTransport );
  7211. return false;
  7212. } else if ( seekingTransport ) {
  7213. return !( selected = dataTypeOrTransport );
  7214. }
  7215. } );
  7216. return selected;
  7217. }
  7218. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7219. }
  7220. // A special extend for ajax options
  7221. // that takes "flat" options (not to be deep extended)
  7222. // Fixes #9887
  7223. function ajaxExtend( target, src ) {
  7224. var key, deep,
  7225. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7226. for ( key in src ) {
  7227. if ( src[ key ] !== undefined ) {
  7228. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  7229. }
  7230. }
  7231. if ( deep ) {
  7232. jQuery.extend( true, target, deep );
  7233. }
  7234. return target;
  7235. }
  7236. /* Handles responses to an ajax request:
  7237. * - finds the right dataType (mediates between content-type and expected dataType)
  7238. * - returns the corresponding response
  7239. */
  7240. function ajaxHandleResponses( s, jqXHR, responses ) {
  7241. var ct, type, finalDataType, firstDataType,
  7242. contents = s.contents,
  7243. dataTypes = s.dataTypes;
  7244. // Remove auto dataType and get content-type in the process
  7245. while ( dataTypes[ 0 ] === "*" ) {
  7246. dataTypes.shift();
  7247. if ( ct === undefined ) {
  7248. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  7249. }
  7250. }
  7251. // Check if we're dealing with a known content-type
  7252. if ( ct ) {
  7253. for ( type in contents ) {
  7254. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7255. dataTypes.unshift( type );
  7256. break;
  7257. }
  7258. }
  7259. }
  7260. // Check to see if we have a response for the expected dataType
  7261. if ( dataTypes[ 0 ] in responses ) {
  7262. finalDataType = dataTypes[ 0 ];
  7263. } else {
  7264. // Try convertible dataTypes
  7265. for ( type in responses ) {
  7266. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  7267. finalDataType = type;
  7268. break;
  7269. }
  7270. if ( !firstDataType ) {
  7271. firstDataType = type;
  7272. }
  7273. }
  7274. // Or just use first one
  7275. finalDataType = finalDataType || firstDataType;
  7276. }
  7277. // If we found a dataType
  7278. // We add the dataType to the list if needed
  7279. // and return the corresponding response
  7280. if ( finalDataType ) {
  7281. if ( finalDataType !== dataTypes[ 0 ] ) {
  7282. dataTypes.unshift( finalDataType );
  7283. }
  7284. return responses[ finalDataType ];
  7285. }
  7286. }
  7287. /* Chain conversions given the request and the original response
  7288. * Also sets the responseXXX fields on the jqXHR instance
  7289. */
  7290. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7291. var conv2, current, conv, tmp, prev,
  7292. converters = {},
  7293. // Work with a copy of dataTypes in case we need to modify it for conversion
  7294. dataTypes = s.dataTypes.slice();
  7295. // Create converters map with lowercased keys
  7296. if ( dataTypes[ 1 ] ) {
  7297. for ( conv in s.converters ) {
  7298. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7299. }
  7300. }
  7301. current = dataTypes.shift();
  7302. // Convert to each sequential dataType
  7303. while ( current ) {
  7304. if ( s.responseFields[ current ] ) {
  7305. jqXHR[ s.responseFields[ current ] ] = response;
  7306. }
  7307. // Apply the dataFilter if provided
  7308. if ( !prev && isSuccess && s.dataFilter ) {
  7309. response = s.dataFilter( response, s.dataType );
  7310. }
  7311. prev = current;
  7312. current = dataTypes.shift();
  7313. if ( current ) {
  7314. // There's only work to do if current dataType is non-auto
  7315. if ( current === "*" ) {
  7316. current = prev;
  7317. // Convert response if prev dataType is non-auto and differs from current
  7318. } else if ( prev !== "*" && prev !== current ) {
  7319. // Seek a direct converter
  7320. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7321. // If none found, seek a pair
  7322. if ( !conv ) {
  7323. for ( conv2 in converters ) {
  7324. // If conv2 outputs current
  7325. tmp = conv2.split( " " );
  7326. if ( tmp[ 1 ] === current ) {
  7327. // If prev can be converted to accepted input
  7328. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7329. converters[ "* " + tmp[ 0 ] ];
  7330. if ( conv ) {
  7331. // Condense equivalence converters
  7332. if ( conv === true ) {
  7333. conv = converters[ conv2 ];
  7334. // Otherwise, insert the intermediate dataType
  7335. } else if ( converters[ conv2 ] !== true ) {
  7336. current = tmp[ 0 ];
  7337. dataTypes.unshift( tmp[ 1 ] );
  7338. }
  7339. break;
  7340. }
  7341. }
  7342. }
  7343. }
  7344. // Apply converter (if not an equivalence)
  7345. if ( conv !== true ) {
  7346. // Unless errors are allowed to bubble, catch and return them
  7347. if ( conv && s.throws ) {
  7348. response = conv( response );
  7349. } else {
  7350. try {
  7351. response = conv( response );
  7352. } catch ( e ) {
  7353. return {
  7354. state: "parsererror",
  7355. error: conv ? e : "No conversion from " + prev + " to " + current
  7356. };
  7357. }
  7358. }
  7359. }
  7360. }
  7361. }
  7362. }
  7363. return { state: "success", data: response };
  7364. }
  7365. jQuery.extend( {
  7366. // Counter for holding the number of active queries
  7367. active: 0,
  7368. // Last-Modified header cache for next request
  7369. lastModified: {},
  7370. etag: {},
  7371. ajaxSettings: {
  7372. url: location.href,
  7373. type: "GET",
  7374. isLocal: rlocalProtocol.test( location.protocol ),
  7375. global: true,
  7376. processData: true,
  7377. async: true,
  7378. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7379. /*
  7380. timeout: 0,
  7381. data: null,
  7382. dataType: null,
  7383. username: null,
  7384. password: null,
  7385. cache: null,
  7386. throws: false,
  7387. traditional: false,
  7388. headers: {},
  7389. */
  7390. accepts: {
  7391. "*": allTypes,
  7392. text: "text/plain",
  7393. html: "text/html",
  7394. xml: "application/xml, text/xml",
  7395. json: "application/json, text/javascript"
  7396. },
  7397. contents: {
  7398. xml: /\bxml\b/,
  7399. html: /\bhtml/,
  7400. json: /\bjson\b/
  7401. },
  7402. responseFields: {
  7403. xml: "responseXML",
  7404. text: "responseText",
  7405. json: "responseJSON"
  7406. },
  7407. // Data converters
  7408. // Keys separate source (or catchall "*") and destination types with a single space
  7409. converters: {
  7410. // Convert anything to text
  7411. "* text": String,
  7412. // Text to html (true = no transformation)
  7413. "text html": true,
  7414. // Evaluate text as a json expression
  7415. "text json": JSON.parse,
  7416. // Parse text as xml
  7417. "text xml": jQuery.parseXML
  7418. },
  7419. // For options that shouldn't be deep extended:
  7420. // you can add your own custom options here if
  7421. // and when you create one that shouldn't be
  7422. // deep extended (see ajaxExtend)
  7423. flatOptions: {
  7424. url: true,
  7425. context: true
  7426. }
  7427. },
  7428. // Creates a full fledged settings object into target
  7429. // with both ajaxSettings and settings fields.
  7430. // If target is omitted, writes into ajaxSettings.
  7431. ajaxSetup: function( target, settings ) {
  7432. return settings ?
  7433. // Building a settings object
  7434. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7435. // Extending ajaxSettings
  7436. ajaxExtend( jQuery.ajaxSettings, target );
  7437. },
  7438. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7439. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7440. // Main method
  7441. ajax: function( url, options ) {
  7442. // If url is an object, simulate pre-1.5 signature
  7443. if ( typeof url === "object" ) {
  7444. options = url;
  7445. url = undefined;
  7446. }
  7447. // Force options to be an object
  7448. options = options || {};
  7449. var transport,
  7450. // URL without anti-cache param
  7451. cacheURL,
  7452. // Response headers
  7453. responseHeadersString,
  7454. responseHeaders,
  7455. // timeout handle
  7456. timeoutTimer,
  7457. // Url cleanup var
  7458. urlAnchor,
  7459. // Request state (becomes false upon send and true upon completion)
  7460. completed,
  7461. // To know if global events are to be dispatched
  7462. fireGlobals,
  7463. // Loop variable
  7464. i,
  7465. // uncached part of the url
  7466. uncached,
  7467. // Create the final options object
  7468. s = jQuery.ajaxSetup( {}, options ),
  7469. // Callbacks context
  7470. callbackContext = s.context || s,
  7471. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7472. globalEventContext = s.context &&
  7473. ( callbackContext.nodeType || callbackContext.jquery ) ?
  7474. jQuery( callbackContext ) :
  7475. jQuery.event,
  7476. // Deferreds
  7477. deferred = jQuery.Deferred(),
  7478. completeDeferred = jQuery.Callbacks( "once memory" ),
  7479. // Status-dependent callbacks
  7480. statusCode = s.statusCode || {},
  7481. // Headers (they are sent all at once)
  7482. requestHeaders = {},
  7483. requestHeadersNames = {},
  7484. // Default abort message
  7485. strAbort = "canceled",
  7486. // Fake xhr
  7487. jqXHR = {
  7488. readyState: 0,
  7489. // Builds headers hashtable if needed
  7490. getResponseHeader: function( key ) {
  7491. var match;
  7492. if ( completed ) {
  7493. if ( !responseHeaders ) {
  7494. responseHeaders = {};
  7495. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  7496. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  7497. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  7498. .concat( match[ 2 ] );
  7499. }
  7500. }
  7501. match = responseHeaders[ key.toLowerCase() + " " ];
  7502. }
  7503. return match == null ? null : match.join( ", " );
  7504. },
  7505. // Raw string
  7506. getAllResponseHeaders: function() {
  7507. return completed ? responseHeadersString : null;
  7508. },
  7509. // Caches the header
  7510. setRequestHeader: function( name, value ) {
  7511. if ( completed == null ) {
  7512. name = requestHeadersNames[ name.toLowerCase() ] =
  7513. requestHeadersNames[ name.toLowerCase() ] || name;
  7514. requestHeaders[ name ] = value;
  7515. }
  7516. return this;
  7517. },
  7518. // Overrides response content-type header
  7519. overrideMimeType: function( type ) {
  7520. if ( completed == null ) {
  7521. s.mimeType = type;
  7522. }
  7523. return this;
  7524. },
  7525. // Status-dependent callbacks
  7526. statusCode: function( map ) {
  7527. var code;
  7528. if ( map ) {
  7529. if ( completed ) {
  7530. // Execute the appropriate callbacks
  7531. jqXHR.always( map[ jqXHR.status ] );
  7532. } else {
  7533. // Lazy-add the new callbacks in a way that preserves old ones
  7534. for ( code in map ) {
  7535. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7536. }
  7537. }
  7538. }
  7539. return this;
  7540. },
  7541. // Cancel the request
  7542. abort: function( statusText ) {
  7543. var finalText = statusText || strAbort;
  7544. if ( transport ) {
  7545. transport.abort( finalText );
  7546. }
  7547. done( 0, finalText );
  7548. return this;
  7549. }
  7550. };
  7551. // Attach deferreds
  7552. deferred.promise( jqXHR );
  7553. // Add protocol if not provided (prefilters might expect it)
  7554. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7555. // We also use the url parameter if available
  7556. s.url = ( ( url || s.url || location.href ) + "" )
  7557. .replace( rprotocol, location.protocol + "//" );
  7558. // Alias method option to type as per ticket #12004
  7559. s.type = options.method || options.type || s.method || s.type;
  7560. // Extract dataTypes list
  7561. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  7562. // A cross-domain request is in order when the origin doesn't match the current origin.
  7563. if ( s.crossDomain == null ) {
  7564. urlAnchor = document.createElement( "a" );
  7565. // Support: IE <=8 - 11, Edge 12 - 15
  7566. // IE throws exception on accessing the href property if url is malformed,
  7567. // e.g. http://example.com:80x/
  7568. try {
  7569. urlAnchor.href = s.url;
  7570. // Support: IE <=8 - 11 only
  7571. // Anchor's host property isn't correctly set when s.url is relative
  7572. urlAnchor.href = urlAnchor.href;
  7573. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  7574. urlAnchor.protocol + "//" + urlAnchor.host;
  7575. } catch ( e ) {
  7576. // If there is an error parsing the URL, assume it is crossDomain,
  7577. // it can be rejected by the transport if it is invalid
  7578. s.crossDomain = true;
  7579. }
  7580. }
  7581. // Convert data if not already a string
  7582. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7583. s.data = jQuery.param( s.data, s.traditional );
  7584. }
  7585. // Apply prefilters
  7586. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7587. // If request was aborted inside a prefilter, stop there
  7588. if ( completed ) {
  7589. return jqXHR;
  7590. }
  7591. // We can fire global events as of now if asked to
  7592. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  7593. fireGlobals = jQuery.event && s.global;
  7594. // Watch for a new set of requests
  7595. if ( fireGlobals && jQuery.active++ === 0 ) {
  7596. jQuery.event.trigger( "ajaxStart" );
  7597. }
  7598. // Uppercase the type
  7599. s.type = s.type.toUpperCase();
  7600. // Determine if request has content
  7601. s.hasContent = !rnoContent.test( s.type );
  7602. // Save the URL in case we're toying with the If-Modified-Since
  7603. // and/or If-None-Match header later on
  7604. // Remove hash to simplify url manipulation
  7605. cacheURL = s.url.replace( rhash, "" );
  7606. // More options handling for requests with no content
  7607. if ( !s.hasContent ) {
  7608. // Remember the hash so we can put it back
  7609. uncached = s.url.slice( cacheURL.length );
  7610. // If data is available and should be processed, append data to url
  7611. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  7612. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  7613. // #9682: remove data so that it's not used in an eventual retry
  7614. delete s.data;
  7615. }
  7616. // Add or update anti-cache param if needed
  7617. if ( s.cache === false ) {
  7618. cacheURL = cacheURL.replace( rantiCache, "$1" );
  7619. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  7620. }
  7621. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  7622. s.url = cacheURL + uncached;
  7623. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  7624. } else if ( s.data && s.processData &&
  7625. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  7626. s.data = s.data.replace( r20, "+" );
  7627. }
  7628. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7629. if ( s.ifModified ) {
  7630. if ( jQuery.lastModified[ cacheURL ] ) {
  7631. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7632. }
  7633. if ( jQuery.etag[ cacheURL ] ) {
  7634. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7635. }
  7636. }
  7637. // Set the correct header, if data is being sent
  7638. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7639. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7640. }
  7641. // Set the Accepts header for the server, depending on the dataType
  7642. jqXHR.setRequestHeader(
  7643. "Accept",
  7644. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  7645. s.accepts[ s.dataTypes[ 0 ] ] +
  7646. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7647. s.accepts[ "*" ]
  7648. );
  7649. // Check for headers option
  7650. for ( i in s.headers ) {
  7651. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7652. }
  7653. // Allow custom headers/mimetypes and early abort
  7654. if ( s.beforeSend &&
  7655. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  7656. // Abort if not done already and return
  7657. return jqXHR.abort();
  7658. }
  7659. // Aborting is no longer a cancellation
  7660. strAbort = "abort";
  7661. // Install callbacks on deferreds
  7662. completeDeferred.add( s.complete );
  7663. jqXHR.done( s.success );
  7664. jqXHR.fail( s.error );
  7665. // Get transport
  7666. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7667. // If no transport, we auto-abort
  7668. if ( !transport ) {
  7669. done( -1, "No Transport" );
  7670. } else {
  7671. jqXHR.readyState = 1;
  7672. // Send global event
  7673. if ( fireGlobals ) {
  7674. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7675. }
  7676. // If request was aborted inside ajaxSend, stop there
  7677. if ( completed ) {
  7678. return jqXHR;
  7679. }
  7680. // Timeout
  7681. if ( s.async && s.timeout > 0 ) {
  7682. timeoutTimer = window.setTimeout( function() {
  7683. jqXHR.abort( "timeout" );
  7684. }, s.timeout );
  7685. }
  7686. try {
  7687. completed = false;
  7688. transport.send( requestHeaders, done );
  7689. } catch ( e ) {
  7690. // Rethrow post-completion exceptions
  7691. if ( completed ) {
  7692. throw e;
  7693. }
  7694. // Propagate others as results
  7695. done( -1, e );
  7696. }
  7697. }
  7698. // Callback for when everything is done
  7699. function done( status, nativeStatusText, responses, headers ) {
  7700. var isSuccess, success, error, response, modified,
  7701. statusText = nativeStatusText;
  7702. // Ignore repeat invocations
  7703. if ( completed ) {
  7704. return;
  7705. }
  7706. completed = true;
  7707. // Clear timeout if it exists
  7708. if ( timeoutTimer ) {
  7709. window.clearTimeout( timeoutTimer );
  7710. }
  7711. // Dereference transport for early garbage collection
  7712. // (no matter how long the jqXHR object will be used)
  7713. transport = undefined;
  7714. // Cache response headers
  7715. responseHeadersString = headers || "";
  7716. // Set readyState
  7717. jqXHR.readyState = status > 0 ? 4 : 0;
  7718. // Determine if successful
  7719. isSuccess = status >= 200 && status < 300 || status === 304;
  7720. // Get response data
  7721. if ( responses ) {
  7722. response = ajaxHandleResponses( s, jqXHR, responses );
  7723. }
  7724. // Convert no matter what (that way responseXXX fields are always set)
  7725. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7726. // If successful, handle type chaining
  7727. if ( isSuccess ) {
  7728. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7729. if ( s.ifModified ) {
  7730. modified = jqXHR.getResponseHeader( "Last-Modified" );
  7731. if ( modified ) {
  7732. jQuery.lastModified[ cacheURL ] = modified;
  7733. }
  7734. modified = jqXHR.getResponseHeader( "etag" );
  7735. if ( modified ) {
  7736. jQuery.etag[ cacheURL ] = modified;
  7737. }
  7738. }
  7739. // if no content
  7740. if ( status === 204 || s.type === "HEAD" ) {
  7741. statusText = "nocontent";
  7742. // if not modified
  7743. } else if ( status === 304 ) {
  7744. statusText = "notmodified";
  7745. // If we have data, let's convert it
  7746. } else {
  7747. statusText = response.state;
  7748. success = response.data;
  7749. error = response.error;
  7750. isSuccess = !error;
  7751. }
  7752. } else {
  7753. // Extract error from statusText and normalize for non-aborts
  7754. error = statusText;
  7755. if ( status || !statusText ) {
  7756. statusText = "error";
  7757. if ( status < 0 ) {
  7758. status = 0;
  7759. }
  7760. }
  7761. }
  7762. // Set data for the fake xhr object
  7763. jqXHR.status = status;
  7764. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7765. // Success/Error
  7766. if ( isSuccess ) {
  7767. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7768. } else {
  7769. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7770. }
  7771. // Status-dependent callbacks
  7772. jqXHR.statusCode( statusCode );
  7773. statusCode = undefined;
  7774. if ( fireGlobals ) {
  7775. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7776. [ jqXHR, s, isSuccess ? success : error ] );
  7777. }
  7778. // Complete
  7779. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7780. if ( fireGlobals ) {
  7781. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7782. // Handle the global AJAX counter
  7783. if ( !( --jQuery.active ) ) {
  7784. jQuery.event.trigger( "ajaxStop" );
  7785. }
  7786. }
  7787. }
  7788. return jqXHR;
  7789. },
  7790. getJSON: function( url, data, callback ) {
  7791. return jQuery.get( url, data, callback, "json" );
  7792. },
  7793. getScript: function( url, callback ) {
  7794. return jQuery.get( url, undefined, callback, "script" );
  7795. }
  7796. } );
  7797. jQuery.each( [ "get", "post" ], function( i, method ) {
  7798. jQuery[ method ] = function( url, data, callback, type ) {
  7799. // Shift arguments if data argument was omitted
  7800. if ( isFunction( data ) ) {
  7801. type = type || callback;
  7802. callback = data;
  7803. data = undefined;
  7804. }
  7805. // The url can be an options object (which then must have .url)
  7806. return jQuery.ajax( jQuery.extend( {
  7807. url: url,
  7808. type: method,
  7809. dataType: type,
  7810. data: data,
  7811. success: callback
  7812. }, jQuery.isPlainObject( url ) && url ) );
  7813. };
  7814. } );
  7815. jQuery._evalUrl = function( url, options ) {
  7816. return jQuery.ajax( {
  7817. url: url,
  7818. // Make this explicit, since user can override this through ajaxSetup (#11264)
  7819. type: "GET",
  7820. dataType: "script",
  7821. cache: true,
  7822. async: false,
  7823. global: false,
  7824. // Only evaluate the response if it is successful (gh-4126)
  7825. // dataFilter is not invoked for failure responses, so using it instead
  7826. // of the default converter is kludgy but it works.
  7827. converters: {
  7828. "text script": function() {}
  7829. },
  7830. dataFilter: function( response ) {
  7831. jQuery.globalEval( response, options );
  7832. }
  7833. } );
  7834. };
  7835. jQuery.fn.extend( {
  7836. wrapAll: function( html ) {
  7837. var wrap;
  7838. if ( this[ 0 ] ) {
  7839. if ( isFunction( html ) ) {
  7840. html = html.call( this[ 0 ] );
  7841. }
  7842. // The elements to wrap the target around
  7843. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  7844. if ( this[ 0 ].parentNode ) {
  7845. wrap.insertBefore( this[ 0 ] );
  7846. }
  7847. wrap.map( function() {
  7848. var elem = this;
  7849. while ( elem.firstElementChild ) {
  7850. elem = elem.firstElementChild;
  7851. }
  7852. return elem;
  7853. } ).append( this );
  7854. }
  7855. return this;
  7856. },
  7857. wrapInner: function( html ) {
  7858. if ( isFunction( html ) ) {
  7859. return this.each( function( i ) {
  7860. jQuery( this ).wrapInner( html.call( this, i ) );
  7861. } );
  7862. }
  7863. return this.each( function() {
  7864. var self = jQuery( this ),
  7865. contents = self.contents();
  7866. if ( contents.length ) {
  7867. contents.wrapAll( html );
  7868. } else {
  7869. self.append( html );
  7870. }
  7871. } );
  7872. },
  7873. wrap: function( html ) {
  7874. var htmlIsFunction = isFunction( html );
  7875. return this.each( function( i ) {
  7876. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  7877. } );
  7878. },
  7879. unwrap: function( selector ) {
  7880. this.parent( selector ).not( "body" ).each( function() {
  7881. jQuery( this ).replaceWith( this.childNodes );
  7882. } );
  7883. return this;
  7884. }
  7885. } );
  7886. jQuery.expr.pseudos.hidden = function( elem ) {
  7887. return !jQuery.expr.pseudos.visible( elem );
  7888. };
  7889. jQuery.expr.pseudos.visible = function( elem ) {
  7890. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  7891. };
  7892. jQuery.ajaxSettings.xhr = function() {
  7893. try {
  7894. return new window.XMLHttpRequest();
  7895. } catch ( e ) {}
  7896. };
  7897. var xhrSuccessStatus = {
  7898. // File protocol always yields status code 0, assume 200
  7899. 0: 200,
  7900. // Support: IE <=9 only
  7901. // #1450: sometimes IE returns 1223 when it should be 204
  7902. 1223: 204
  7903. },
  7904. xhrSupported = jQuery.ajaxSettings.xhr();
  7905. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7906. support.ajax = xhrSupported = !!xhrSupported;
  7907. jQuery.ajaxTransport( function( options ) {
  7908. var callback, errorCallback;
  7909. // Cross domain only allowed if supported through XMLHttpRequest
  7910. if ( support.cors || xhrSupported && !options.crossDomain ) {
  7911. return {
  7912. send: function( headers, complete ) {
  7913. var i,
  7914. xhr = options.xhr();
  7915. xhr.open(
  7916. options.type,
  7917. options.url,
  7918. options.async,
  7919. options.username,
  7920. options.password
  7921. );
  7922. // Apply custom fields if provided
  7923. if ( options.xhrFields ) {
  7924. for ( i in options.xhrFields ) {
  7925. xhr[ i ] = options.xhrFields[ i ];
  7926. }
  7927. }
  7928. // Override mime type if needed
  7929. if ( options.mimeType && xhr.overrideMimeType ) {
  7930. xhr.overrideMimeType( options.mimeType );
  7931. }
  7932. // X-Requested-With header
  7933. // For cross-domain requests, seeing as conditions for a preflight are
  7934. // akin to a jigsaw puzzle, we simply never set it to be sure.
  7935. // (it can always be set on a per-request basis or even using ajaxSetup)
  7936. // For same-domain requests, won't change header if already provided.
  7937. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  7938. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  7939. }
  7940. // Set headers
  7941. for ( i in headers ) {
  7942. xhr.setRequestHeader( i, headers[ i ] );
  7943. }
  7944. // Callback
  7945. callback = function( type ) {
  7946. return function() {
  7947. if ( callback ) {
  7948. callback = errorCallback = xhr.onload =
  7949. xhr.onerror = xhr.onabort = xhr.ontimeout =
  7950. xhr.onreadystatechange = null;
  7951. if ( type === "abort" ) {
  7952. xhr.abort();
  7953. } else if ( type === "error" ) {
  7954. // Support: IE <=9 only
  7955. // On a manual native abort, IE9 throws
  7956. // errors on any property access that is not readyState
  7957. if ( typeof xhr.status !== "number" ) {
  7958. complete( 0, "error" );
  7959. } else {
  7960. complete(
  7961. // File: protocol always yields status 0; see #8605, #14207
  7962. xhr.status,
  7963. xhr.statusText
  7964. );
  7965. }
  7966. } else {
  7967. complete(
  7968. xhrSuccessStatus[ xhr.status ] || xhr.status,
  7969. xhr.statusText,
  7970. // Support: IE <=9 only
  7971. // IE9 has no XHR2 but throws on binary (trac-11426)
  7972. // For XHR2 non-text, let the caller handle it (gh-2498)
  7973. ( xhr.responseType || "text" ) !== "text" ||
  7974. typeof xhr.responseText !== "string" ?
  7975. { binary: xhr.response } :
  7976. { text: xhr.responseText },
  7977. xhr.getAllResponseHeaders()
  7978. );
  7979. }
  7980. }
  7981. };
  7982. };
  7983. // Listen to events
  7984. xhr.onload = callback();
  7985. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  7986. // Support: IE 9 only
  7987. // Use onreadystatechange to replace onabort
  7988. // to handle uncaught aborts
  7989. if ( xhr.onabort !== undefined ) {
  7990. xhr.onabort = errorCallback;
  7991. } else {
  7992. xhr.onreadystatechange = function() {
  7993. // Check readyState before timeout as it changes
  7994. if ( xhr.readyState === 4 ) {
  7995. // Allow onerror to be called first,
  7996. // but that will not handle a native abort
  7997. // Also, save errorCallback to a variable
  7998. // as xhr.onerror cannot be accessed
  7999. window.setTimeout( function() {
  8000. if ( callback ) {
  8001. errorCallback();
  8002. }
  8003. } );
  8004. }
  8005. };
  8006. }
  8007. // Create the abort callback
  8008. callback = callback( "abort" );
  8009. try {
  8010. // Do send the request (this may raise an exception)
  8011. xhr.send( options.hasContent && options.data || null );
  8012. } catch ( e ) {
  8013. // #14683: Only rethrow if this hasn't been notified as an error yet
  8014. if ( callback ) {
  8015. throw e;
  8016. }
  8017. }
  8018. },
  8019. abort: function() {
  8020. if ( callback ) {
  8021. callback();
  8022. }
  8023. }
  8024. };
  8025. }
  8026. } );
  8027. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  8028. jQuery.ajaxPrefilter( function( s ) {
  8029. if ( s.crossDomain ) {
  8030. s.contents.script = false;
  8031. }
  8032. } );
  8033. // Install script dataType
  8034. jQuery.ajaxSetup( {
  8035. accepts: {
  8036. script: "text/javascript, application/javascript, " +
  8037. "application/ecmascript, application/x-ecmascript"
  8038. },
  8039. contents: {
  8040. script: /\b(?:java|ecma)script\b/
  8041. },
  8042. converters: {
  8043. "text script": function( text ) {
  8044. jQuery.globalEval( text );
  8045. return text;
  8046. }
  8047. }
  8048. } );
  8049. // Handle cache's special case and crossDomain
  8050. jQuery.ajaxPrefilter( "script", function( s ) {
  8051. if ( s.cache === undefined ) {
  8052. s.cache = false;
  8053. }
  8054. if ( s.crossDomain ) {
  8055. s.type = "GET";
  8056. }
  8057. } );
  8058. // Bind script tag hack transport
  8059. jQuery.ajaxTransport( "script", function( s ) {
  8060. // This transport only deals with cross domain or forced-by-attrs requests
  8061. if ( s.crossDomain || s.scriptAttrs ) {
  8062. var script, callback;
  8063. return {
  8064. send: function( _, complete ) {
  8065. script = jQuery( "<script>" )
  8066. .attr( s.scriptAttrs || {} )
  8067. .prop( { charset: s.scriptCharset, src: s.url } )
  8068. .on( "load error", callback = function( evt ) {
  8069. script.remove();
  8070. callback = null;
  8071. if ( evt ) {
  8072. complete( evt.type === "error" ? 404 : 200, evt.type );
  8073. }
  8074. } );
  8075. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8076. document.head.appendChild( script[ 0 ] );
  8077. },
  8078. abort: function() {
  8079. if ( callback ) {
  8080. callback();
  8081. }
  8082. }
  8083. };
  8084. }
  8085. } );
  8086. var oldCallbacks = [],
  8087. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8088. // Default jsonp settings
  8089. jQuery.ajaxSetup( {
  8090. jsonp: "callback",
  8091. jsonpCallback: function() {
  8092. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8093. this[ callback ] = true;
  8094. return callback;
  8095. }
  8096. } );
  8097. // Detect, normalize options and install callbacks for jsonp requests
  8098. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8099. var callbackName, overwritten, responseContainer,
  8100. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8101. "url" :
  8102. typeof s.data === "string" &&
  8103. ( s.contentType || "" )
  8104. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  8105. rjsonp.test( s.data ) && "data"
  8106. );
  8107. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8108. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8109. // Get callback name, remembering preexisting value associated with it
  8110. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  8111. s.jsonpCallback() :
  8112. s.jsonpCallback;
  8113. // Insert callback into url or form data
  8114. if ( jsonProp ) {
  8115. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8116. } else if ( s.jsonp !== false ) {
  8117. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8118. }
  8119. // Use data converter to retrieve json after script execution
  8120. s.converters[ "script json" ] = function() {
  8121. if ( !responseContainer ) {
  8122. jQuery.error( callbackName + " was not called" );
  8123. }
  8124. return responseContainer[ 0 ];
  8125. };
  8126. // Force json dataType
  8127. s.dataTypes[ 0 ] = "json";
  8128. // Install callback
  8129. overwritten = window[ callbackName ];
  8130. window[ callbackName ] = function() {
  8131. responseContainer = arguments;
  8132. };
  8133. // Clean-up function (fires after converters)
  8134. jqXHR.always( function() {
  8135. // If previous value didn't exist - remove it
  8136. if ( overwritten === undefined ) {
  8137. jQuery( window ).removeProp( callbackName );
  8138. // Otherwise restore preexisting value
  8139. } else {
  8140. window[ callbackName ] = overwritten;
  8141. }
  8142. // Save back as free
  8143. if ( s[ callbackName ] ) {
  8144. // Make sure that re-using the options doesn't screw things around
  8145. s.jsonpCallback = originalSettings.jsonpCallback;
  8146. // Save the callback name for future use
  8147. oldCallbacks.push( callbackName );
  8148. }
  8149. // Call if it was a function and we have a response
  8150. if ( responseContainer && isFunction( overwritten ) ) {
  8151. overwritten( responseContainer[ 0 ] );
  8152. }
  8153. responseContainer = overwritten = undefined;
  8154. } );
  8155. // Delegate to script
  8156. return "script";
  8157. }
  8158. } );
  8159. // Support: Safari 8 only
  8160. // In Safari 8 documents created via document.implementation.createHTMLDocument
  8161. // collapse sibling forms: the second one becomes a child of the first one.
  8162. // Because of that, this security measure has to be disabled in Safari 8.
  8163. // https://bugs.webkit.org/show_bug.cgi?id=137337
  8164. support.createHTMLDocument = ( function() {
  8165. var body = document.implementation.createHTMLDocument( "" ).body;
  8166. body.innerHTML = "<form></form><form></form>";
  8167. return body.childNodes.length === 2;
  8168. } )();
  8169. // Argument "data" should be string of html
  8170. // context (optional): If specified, the fragment will be created in this context,
  8171. // defaults to document
  8172. // keepScripts (optional): If true, will include scripts passed in the html string
  8173. jQuery.parseHTML = function( data, context, keepScripts ) {
  8174. if ( typeof data !== "string" ) {
  8175. return [];
  8176. }
  8177. if ( typeof context === "boolean" ) {
  8178. keepScripts = context;
  8179. context = false;
  8180. }
  8181. var base, parsed, scripts;
  8182. if ( !context ) {
  8183. // Stop scripts or inline event handlers from being executed immediately
  8184. // by using document.implementation
  8185. if ( support.createHTMLDocument ) {
  8186. context = document.implementation.createHTMLDocument( "" );
  8187. // Set the base href for the created document
  8188. // so any parsed elements with URLs
  8189. // are based on the document's URL (gh-2965)
  8190. base = context.createElement( "base" );
  8191. base.href = document.location.href;
  8192. context.head.appendChild( base );
  8193. } else {
  8194. context = document;
  8195. }
  8196. }
  8197. parsed = rsingleTag.exec( data );
  8198. scripts = !keepScripts && [];
  8199. // Single tag
  8200. if ( parsed ) {
  8201. return [ context.createElement( parsed[ 1 ] ) ];
  8202. }
  8203. parsed = buildFragment( [ data ], context, scripts );
  8204. if ( scripts && scripts.length ) {
  8205. jQuery( scripts ).remove();
  8206. }
  8207. return jQuery.merge( [], parsed.childNodes );
  8208. };
  8209. /**
  8210. * Load a url into a page
  8211. */
  8212. jQuery.fn.load = function( url, params, callback ) {
  8213. var selector, type, response,
  8214. self = this,
  8215. off = url.indexOf( " " );
  8216. if ( off > -1 ) {
  8217. selector = stripAndCollapse( url.slice( off ) );
  8218. url = url.slice( 0, off );
  8219. }
  8220. // If it's a function
  8221. if ( isFunction( params ) ) {
  8222. // We assume that it's the callback
  8223. callback = params;
  8224. params = undefined;
  8225. // Otherwise, build a param string
  8226. } else if ( params && typeof params === "object" ) {
  8227. type = "POST";
  8228. }
  8229. // If we have elements to modify, make the request
  8230. if ( self.length > 0 ) {
  8231. jQuery.ajax( {
  8232. url: url,
  8233. // If "type" variable is undefined, then "GET" method will be used.
  8234. // Make value of this field explicit since
  8235. // user can override it through ajaxSetup method
  8236. type: type || "GET",
  8237. dataType: "html",
  8238. data: params
  8239. } ).done( function( responseText ) {
  8240. // Save response for use in complete callback
  8241. response = arguments;
  8242. self.html( selector ?
  8243. // If a selector was specified, locate the right elements in a dummy div
  8244. // Exclude scripts to avoid IE 'Permission Denied' errors
  8245. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8246. // Otherwise use the full result
  8247. responseText );
  8248. // If the request succeeds, this function gets "data", "status", "jqXHR"
  8249. // but they are ignored because response was set above.
  8250. // If it fails, this function gets "jqXHR", "status", "error"
  8251. } ).always( callback && function( jqXHR, status ) {
  8252. self.each( function() {
  8253. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  8254. } );
  8255. } );
  8256. }
  8257. return this;
  8258. };
  8259. // Attach a bunch of functions for handling common AJAX events
  8260. jQuery.each( [
  8261. "ajaxStart",
  8262. "ajaxStop",
  8263. "ajaxComplete",
  8264. "ajaxError",
  8265. "ajaxSuccess",
  8266. "ajaxSend"
  8267. ], function( i, type ) {
  8268. jQuery.fn[ type ] = function( fn ) {
  8269. return this.on( type, fn );
  8270. };
  8271. } );
  8272. jQuery.expr.pseudos.animated = function( elem ) {
  8273. return jQuery.grep( jQuery.timers, function( fn ) {
  8274. return elem === fn.elem;
  8275. } ).length;
  8276. };
  8277. jQuery.offset = {
  8278. setOffset: function( elem, options, i ) {
  8279. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8280. position = jQuery.css( elem, "position" ),
  8281. curElem = jQuery( elem ),
  8282. props = {};
  8283. // Set position first, in-case top/left are set even on static elem
  8284. if ( position === "static" ) {
  8285. elem.style.position = "relative";
  8286. }
  8287. curOffset = curElem.offset();
  8288. curCSSTop = jQuery.css( elem, "top" );
  8289. curCSSLeft = jQuery.css( elem, "left" );
  8290. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8291. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  8292. // Need to be able to calculate position if either
  8293. // top or left is auto and position is either absolute or fixed
  8294. if ( calculatePosition ) {
  8295. curPosition = curElem.position();
  8296. curTop = curPosition.top;
  8297. curLeft = curPosition.left;
  8298. } else {
  8299. curTop = parseFloat( curCSSTop ) || 0;
  8300. curLeft = parseFloat( curCSSLeft ) || 0;
  8301. }
  8302. if ( isFunction( options ) ) {
  8303. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  8304. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  8305. }
  8306. if ( options.top != null ) {
  8307. props.top = ( options.top - curOffset.top ) + curTop;
  8308. }
  8309. if ( options.left != null ) {
  8310. props.left = ( options.left - curOffset.left ) + curLeft;
  8311. }
  8312. if ( "using" in options ) {
  8313. options.using.call( elem, props );
  8314. } else {
  8315. curElem.css( props );
  8316. }
  8317. }
  8318. };
  8319. jQuery.fn.extend( {
  8320. // offset() relates an element's border box to the document origin
  8321. offset: function( options ) {
  8322. // Preserve chaining for setter
  8323. if ( arguments.length ) {
  8324. return options === undefined ?
  8325. this :
  8326. this.each( function( i ) {
  8327. jQuery.offset.setOffset( this, options, i );
  8328. } );
  8329. }
  8330. var rect, win,
  8331. elem = this[ 0 ];
  8332. if ( !elem ) {
  8333. return;
  8334. }
  8335. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  8336. // Support: IE <=11 only
  8337. // Running getBoundingClientRect on a
  8338. // disconnected node in IE throws an error
  8339. if ( !elem.getClientRects().length ) {
  8340. return { top: 0, left: 0 };
  8341. }
  8342. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  8343. rect = elem.getBoundingClientRect();
  8344. win = elem.ownerDocument.defaultView;
  8345. return {
  8346. top: rect.top + win.pageYOffset,
  8347. left: rect.left + win.pageXOffset
  8348. };
  8349. },
  8350. // position() relates an element's margin box to its offset parent's padding box
  8351. // This corresponds to the behavior of CSS absolute positioning
  8352. position: function() {
  8353. if ( !this[ 0 ] ) {
  8354. return;
  8355. }
  8356. var offsetParent, offset, doc,
  8357. elem = this[ 0 ],
  8358. parentOffset = { top: 0, left: 0 };
  8359. // position:fixed elements are offset from the viewport, which itself always has zero offset
  8360. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8361. // Assume position:fixed implies availability of getBoundingClientRect
  8362. offset = elem.getBoundingClientRect();
  8363. } else {
  8364. offset = this.offset();
  8365. // Account for the *real* offset parent, which can be the document or its root element
  8366. // when a statically positioned element is identified
  8367. doc = elem.ownerDocument;
  8368. offsetParent = elem.offsetParent || doc.documentElement;
  8369. while ( offsetParent &&
  8370. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  8371. jQuery.css( offsetParent, "position" ) === "static" ) {
  8372. offsetParent = offsetParent.parentNode;
  8373. }
  8374. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  8375. // Incorporate borders into its offset, since they are outside its content origin
  8376. parentOffset = jQuery( offsetParent ).offset();
  8377. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  8378. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  8379. }
  8380. }
  8381. // Subtract parent offsets and element margins
  8382. return {
  8383. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8384. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  8385. };
  8386. },
  8387. // This method will return documentElement in the following cases:
  8388. // 1) For the element inside the iframe without offsetParent, this method will return
  8389. // documentElement of the parent window
  8390. // 2) For the hidden or detached element
  8391. // 3) For body or html element, i.e. in case of the html node - it will return itself
  8392. //
  8393. // but those exceptions were never presented as a real life use-cases
  8394. // and might be considered as more preferable results.
  8395. //
  8396. // This logic, however, is not guaranteed and can change at any point in the future
  8397. offsetParent: function() {
  8398. return this.map( function() {
  8399. var offsetParent = this.offsetParent;
  8400. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  8401. offsetParent = offsetParent.offsetParent;
  8402. }
  8403. return offsetParent || documentElement;
  8404. } );
  8405. }
  8406. } );
  8407. // Create scrollLeft and scrollTop methods
  8408. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8409. var top = "pageYOffset" === prop;
  8410. jQuery.fn[ method ] = function( val ) {
  8411. return access( this, function( elem, method, val ) {
  8412. // Coalesce documents and windows
  8413. var win;
  8414. if ( isWindow( elem ) ) {
  8415. win = elem;
  8416. } else if ( elem.nodeType === 9 ) {
  8417. win = elem.defaultView;
  8418. }
  8419. if ( val === undefined ) {
  8420. return win ? win[ prop ] : elem[ method ];
  8421. }
  8422. if ( win ) {
  8423. win.scrollTo(
  8424. !top ? val : win.pageXOffset,
  8425. top ? val : win.pageYOffset
  8426. );
  8427. } else {
  8428. elem[ method ] = val;
  8429. }
  8430. }, method, val, arguments.length );
  8431. };
  8432. } );
  8433. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  8434. // Add the top/left cssHooks using jQuery.fn.position
  8435. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8436. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  8437. // getComputedStyle returns percent when specified for top/left/bottom/right;
  8438. // rather than make the css module depend on the offset module, just check for it here
  8439. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8440. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8441. function( elem, computed ) {
  8442. if ( computed ) {
  8443. computed = curCSS( elem, prop );
  8444. // If curCSS returns percentage, fallback to offset
  8445. return rnumnonpx.test( computed ) ?
  8446. jQuery( elem ).position()[ prop ] + "px" :
  8447. computed;
  8448. }
  8449. }
  8450. );
  8451. } );
  8452. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8453. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8454. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  8455. function( defaultExtra, funcName ) {
  8456. // Margin is only for outerHeight, outerWidth
  8457. jQuery.fn[ funcName ] = function( margin, value ) {
  8458. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8459. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8460. return access( this, function( elem, type, value ) {
  8461. var doc;
  8462. if ( isWindow( elem ) ) {
  8463. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  8464. return funcName.indexOf( "outer" ) === 0 ?
  8465. elem[ "inner" + name ] :
  8466. elem.document.documentElement[ "client" + name ];
  8467. }
  8468. // Get document width or height
  8469. if ( elem.nodeType === 9 ) {
  8470. doc = elem.documentElement;
  8471. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  8472. // whichever is greatest
  8473. return Math.max(
  8474. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8475. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8476. doc[ "client" + name ]
  8477. );
  8478. }
  8479. return value === undefined ?
  8480. // Get width or height on the element, requesting but not forcing parseFloat
  8481. jQuery.css( elem, type, extra ) :
  8482. // Set width or height on the element
  8483. jQuery.style( elem, type, value, extra );
  8484. }, type, chainable ? margin : undefined, chainable );
  8485. };
  8486. } );
  8487. } );
  8488. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  8489. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  8490. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  8491. function( i, name ) {
  8492. // Handle event binding
  8493. jQuery.fn[ name ] = function( data, fn ) {
  8494. return arguments.length > 0 ?
  8495. this.on( name, null, data, fn ) :
  8496. this.trigger( name );
  8497. };
  8498. } );
  8499. jQuery.fn.extend( {
  8500. hover: function( fnOver, fnOut ) {
  8501. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  8502. }
  8503. } );
  8504. jQuery.fn.extend( {
  8505. bind: function( types, data, fn ) {
  8506. return this.on( types, null, data, fn );
  8507. },
  8508. unbind: function( types, fn ) {
  8509. return this.off( types, null, fn );
  8510. },
  8511. delegate: function( selector, types, data, fn ) {
  8512. return this.on( types, selector, data, fn );
  8513. },
  8514. undelegate: function( selector, types, fn ) {
  8515. // ( namespace ) or ( selector, types [, fn] )
  8516. return arguments.length === 1 ?
  8517. this.off( selector, "**" ) :
  8518. this.off( types, selector || "**", fn );
  8519. }
  8520. } );
  8521. // Bind a function to a context, optionally partially applying any
  8522. // arguments.
  8523. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  8524. // However, it is not slated for removal any time soon
  8525. jQuery.proxy = function( fn, context ) {
  8526. var tmp, args, proxy;
  8527. if ( typeof context === "string" ) {
  8528. tmp = fn[ context ];
  8529. context = fn;
  8530. fn = tmp;
  8531. }
  8532. // Quick check to determine if target is callable, in the spec
  8533. // this throws a TypeError, but we will just return undefined.
  8534. if ( !isFunction( fn ) ) {
  8535. return undefined;
  8536. }
  8537. // Simulated bind
  8538. args = slice.call( arguments, 2 );
  8539. proxy = function() {
  8540. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  8541. };
  8542. // Set the guid of unique handler to the same of original handler, so it can be removed
  8543. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  8544. return proxy;
  8545. };
  8546. jQuery.holdReady = function( hold ) {
  8547. if ( hold ) {
  8548. jQuery.readyWait++;
  8549. } else {
  8550. jQuery.ready( true );
  8551. }
  8552. };
  8553. jQuery.isArray = Array.isArray;
  8554. jQuery.parseJSON = JSON.parse;
  8555. jQuery.nodeName = nodeName;
  8556. jQuery.isFunction = isFunction;
  8557. jQuery.isWindow = isWindow;
  8558. jQuery.camelCase = camelCase;
  8559. jQuery.type = toType;
  8560. jQuery.now = Date.now;
  8561. jQuery.isNumeric = function( obj ) {
  8562. // As of jQuery 3.0, isNumeric is limited to
  8563. // strings and numbers (primitives or objects)
  8564. // that can be coerced to finite numbers (gh-2662)
  8565. var type = jQuery.type( obj );
  8566. return ( type === "number" || type === "string" ) &&
  8567. // parseFloat NaNs numeric-cast false positives ("")
  8568. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  8569. // subtraction forces infinities to NaN
  8570. !isNaN( obj - parseFloat( obj ) );
  8571. };
  8572. // Register as a named AMD module, since jQuery can be concatenated with other
  8573. // files that may use define, but not via a proper concatenation script that
  8574. // understands anonymous AMD modules. A named AMD is safest and most robust
  8575. // way to register. Lowercase jquery is used because AMD module names are
  8576. // derived from file names, and jQuery is normally delivered in a lowercase
  8577. // file name. Do this after creating the global so that if an AMD module wants
  8578. // to call noConflict to hide this version of jQuery, it will work.
  8579. // Note that for maximum portability, libraries that are not jQuery should
  8580. // declare themselves as anonymous modules, and avoid setting a global if an
  8581. // AMD loader is present. jQuery is a special case. For more information, see
  8582. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8583. if ( typeof define === "function" && define.amd ) {
  8584. define( "jquery", [], function() {
  8585. return jQuery;
  8586. } );
  8587. }
  8588. var
  8589. // Map over jQuery in case of overwrite
  8590. _jQuery = window.jQuery,
  8591. // Map over the $ in case of overwrite
  8592. _$ = window.$;
  8593. jQuery.noConflict = function( deep ) {
  8594. if ( window.$ === jQuery ) {
  8595. window.$ = _$;
  8596. }
  8597. if ( deep && window.jQuery === jQuery ) {
  8598. window.jQuery = _jQuery;
  8599. }
  8600. return jQuery;
  8601. };
  8602. // Expose jQuery and $ identifiers, even in AMD
  8603. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8604. // and CommonJS for browser emulators (#13566)
  8605. if ( !noGlobal ) {
  8606. window.jQuery = window.$ = jQuery;
  8607. }
  8608. return jQuery;
  8609. } );
  8610. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  8611. // Distributed under an MIT license: http://codemirror.net/LICENSE
  8612. // This is CodeMirror (http://codemirror.net), a code editor
  8613. // implemented in JavaScript on top of the browser's DOM.
  8614. //
  8615. // You can find some technical background for some of the code below
  8616. // at http://marijnhaverbeke.nl/blog/#cm-internals .
  8617. (function (global, factory) {
  8618. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8619. typeof define === 'function' && define.amd ? define('codemirror/lib/codemirror',factory) :
  8620. (global.CodeMirror = factory());
  8621. }(this, (function () { 'use strict';
  8622. // Kludges for bugs and behavior differences that can't be feature
  8623. // detected are enabled based on userAgent etc sniffing.
  8624. var userAgent = navigator.userAgent;
  8625. var platform = navigator.platform;
  8626. var gecko = /gecko\/\d/i.test(userAgent);
  8627. var ie_upto10 = /MSIE \d/.test(userAgent);
  8628. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  8629. var edge = /Edge\/(\d+)/.exec(userAgent);
  8630. var ie = ie_upto10 || ie_11up || edge;
  8631. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  8632. var webkit = !edge && /WebKit\//.test(userAgent);
  8633. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  8634. var chrome = !edge && /Chrome\//.test(userAgent);
  8635. var presto = /Opera\//.test(userAgent);
  8636. var safari = /Apple Computer/.test(navigator.vendor);
  8637. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  8638. var phantom = /PhantomJS/.test(userAgent);
  8639. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  8640. var android = /Android/.test(userAgent);
  8641. // This is woefully incomplete. Suggestions for alternative methods welcome.
  8642. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  8643. var mac = ios || /Mac/.test(platform);
  8644. var chromeOS = /\bCrOS\b/.test(userAgent);
  8645. var windows = /win/i.test(platform);
  8646. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  8647. if (presto_version) { presto_version = Number(presto_version[1]); }
  8648. if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
  8649. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  8650. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  8651. var captureRightClick = gecko || (ie && ie_version >= 9);
  8652. function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
  8653. var rmClass = function(node, cls) {
  8654. var current = node.className;
  8655. var match = classTest(cls).exec(current);
  8656. if (match) {
  8657. var after = current.slice(match.index + match[0].length);
  8658. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  8659. }
  8660. };
  8661. function removeChildren(e) {
  8662. for (var count = e.childNodes.length; count > 0; --count)
  8663. { e.removeChild(e.firstChild); }
  8664. return e
  8665. }
  8666. function removeChildrenAndAdd(parent, e) {
  8667. return removeChildren(parent).appendChild(e)
  8668. }
  8669. function elt(tag, content, className, style) {
  8670. var e = document.createElement(tag);
  8671. if (className) { e.className = className; }
  8672. if (style) { e.style.cssText = style; }
  8673. if (typeof content == "string") { e.appendChild(document.createTextNode(content)); }
  8674. else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }
  8675. return e
  8676. }
  8677. // wrapper for elt, which removes the elt from the accessibility tree
  8678. function eltP(tag, content, className, style) {
  8679. var e = elt(tag, content, className, style);
  8680. e.setAttribute("role", "presentation");
  8681. return e
  8682. }
  8683. var range;
  8684. if (document.createRange) { range = function(node, start, end, endNode) {
  8685. var r = document.createRange();
  8686. r.setEnd(endNode || node, end);
  8687. r.setStart(node, start);
  8688. return r
  8689. }; }
  8690. else { range = function(node, start, end) {
  8691. var r = document.body.createTextRange();
  8692. try { r.moveToElementText(node.parentNode); }
  8693. catch(e) { return r }
  8694. r.collapse(true);
  8695. r.moveEnd("character", end);
  8696. r.moveStart("character", start);
  8697. return r
  8698. }; }
  8699. function contains(parent, child) {
  8700. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  8701. { child = child.parentNode; }
  8702. if (parent.contains)
  8703. { return parent.contains(child) }
  8704. do {
  8705. if (child.nodeType == 11) { child = child.host; }
  8706. if (child == parent) { return true }
  8707. } while (child = child.parentNode)
  8708. }
  8709. function activeElt() {
  8710. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  8711. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  8712. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  8713. var activeElement;
  8714. try {
  8715. activeElement = document.activeElement;
  8716. } catch(e) {
  8717. activeElement = document.body || null;
  8718. }
  8719. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
  8720. { activeElement = activeElement.shadowRoot.activeElement; }
  8721. return activeElement
  8722. }
  8723. function addClass(node, cls) {
  8724. var current = node.className;
  8725. if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; }
  8726. }
  8727. function joinClasses(a, b) {
  8728. var as = a.split(" ");
  8729. for (var i = 0; i < as.length; i++)
  8730. { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } }
  8731. return b
  8732. }
  8733. var selectInput = function(node) { node.select(); };
  8734. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  8735. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }
  8736. else if (ie) // Suppress mysterious IE10 errors
  8737. { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
  8738. function bind(f) {
  8739. var args = Array.prototype.slice.call(arguments, 1);
  8740. return function(){return f.apply(null, args)}
  8741. }
  8742. function copyObj(obj, target, overwrite) {
  8743. if (!target) { target = {}; }
  8744. for (var prop in obj)
  8745. { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
  8746. { target[prop] = obj[prop]; } }
  8747. return target
  8748. }
  8749. // Counts the column offset in a string, taking tabs into account.
  8750. // Used mostly to find indentation.
  8751. function countColumn(string, end, tabSize, startIndex, startValue) {
  8752. if (end == null) {
  8753. end = string.search(/[^\s\u00a0]/);
  8754. if (end == -1) { end = string.length; }
  8755. }
  8756. for (var i = startIndex || 0, n = startValue || 0;;) {
  8757. var nextTab = string.indexOf("\t", i);
  8758. if (nextTab < 0 || nextTab >= end)
  8759. { return n + (end - i) }
  8760. n += nextTab - i;
  8761. n += tabSize - (n % tabSize);
  8762. i = nextTab + 1;
  8763. }
  8764. }
  8765. var Delayed = function() {this.id = null;};
  8766. Delayed.prototype.set = function (ms, f) {
  8767. clearTimeout(this.id);
  8768. this.id = setTimeout(f, ms);
  8769. };
  8770. function indexOf(array, elt) {
  8771. for (var i = 0; i < array.length; ++i)
  8772. { if (array[i] == elt) { return i } }
  8773. return -1
  8774. }
  8775. // Number of pixels added to scroller and sizer to hide scrollbar
  8776. var scrollerGap = 30;
  8777. // Returned or thrown by various protocols to signal 'I'm not
  8778. // handling this'.
  8779. var Pass = {toString: function(){return "CodeMirror.Pass"}};
  8780. // Reused option objects for setSelection & friends
  8781. var sel_dontScroll = {scroll: false};
  8782. var sel_mouse = {origin: "*mouse"};
  8783. var sel_move = {origin: "+move"};
  8784. // The inverse of countColumn -- find the offset that corresponds to
  8785. // a particular column.
  8786. function findColumn(string, goal, tabSize) {
  8787. for (var pos = 0, col = 0;;) {
  8788. var nextTab = string.indexOf("\t", pos);
  8789. if (nextTab == -1) { nextTab = string.length; }
  8790. var skipped = nextTab - pos;
  8791. if (nextTab == string.length || col + skipped >= goal)
  8792. { return pos + Math.min(skipped, goal - col) }
  8793. col += nextTab - pos;
  8794. col += tabSize - (col % tabSize);
  8795. pos = nextTab + 1;
  8796. if (col >= goal) { return pos }
  8797. }
  8798. }
  8799. var spaceStrs = [""];
  8800. function spaceStr(n) {
  8801. while (spaceStrs.length <= n)
  8802. { spaceStrs.push(lst(spaceStrs) + " "); }
  8803. return spaceStrs[n]
  8804. }
  8805. function lst(arr) { return arr[arr.length-1] }
  8806. function map(array, f) {
  8807. var out = [];
  8808. for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }
  8809. return out
  8810. }
  8811. function insertSorted(array, value, score) {
  8812. var pos = 0, priority = score(value);
  8813. while (pos < array.length && score(array[pos]) <= priority) { pos++; }
  8814. array.splice(pos, 0, value);
  8815. }
  8816. function nothing() {}
  8817. function createObj(base, props) {
  8818. var inst;
  8819. if (Object.create) {
  8820. inst = Object.create(base);
  8821. } else {
  8822. nothing.prototype = base;
  8823. inst = new nothing();
  8824. }
  8825. if (props) { copyObj(props, inst); }
  8826. return inst
  8827. }
  8828. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  8829. function isWordCharBasic(ch) {
  8830. return /\w/.test(ch) || ch > "\x80" &&
  8831. (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  8832. }
  8833. function isWordChar(ch, helper) {
  8834. if (!helper) { return isWordCharBasic(ch) }
  8835. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
  8836. return helper.test(ch)
  8837. }
  8838. function isEmpty(obj) {
  8839. for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
  8840. return true
  8841. }
  8842. // Extending unicode characters. A series of a non-extending char +
  8843. // any number of extending chars is treated as a single unit as far
  8844. // as editing and measuring is concerned. This is not fully correct,
  8845. // since some scripts/fonts/browsers also treat other configurations
  8846. // of code points as a group.
  8847. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
  8848. function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
  8849. // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
  8850. function skipExtendingChars(str, pos, dir) {
  8851. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }
  8852. return pos
  8853. }
  8854. // Returns the value from the range [`from`; `to`] that satisfies
  8855. // `pred` and is closest to `from`. Assumes that at least `to`
  8856. // satisfies `pred`. Supports `from` being greater than `to`.
  8857. function findFirst(pred, from, to) {
  8858. // At any point we are certain `to` satisfies `pred`, don't know
  8859. // whether `from` does.
  8860. var dir = from > to ? -1 : 1;
  8861. for (;;) {
  8862. if (from == to) { return from }
  8863. var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  8864. if (mid == from) { return pred(mid) ? from : to }
  8865. if (pred(mid)) { to = mid; }
  8866. else { from = mid + dir; }
  8867. }
  8868. }
  8869. // The display handles the DOM integration, both for input reading
  8870. // and content drawing. It holds references to DOM nodes and
  8871. // display-related state.
  8872. function Display(place, doc, input) {
  8873. var d = this;
  8874. this.input = input;
  8875. // Covers bottom-right square when both scrollbars are present.
  8876. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  8877. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  8878. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  8879. // and h scrollbar is present.
  8880. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  8881. d.gutterFiller.setAttribute("cm-not-content", "true");
  8882. // Will contain the actual code, positioned to cover the viewport.
  8883. d.lineDiv = eltP("div", null, "CodeMirror-code");
  8884. // Elements are added to these to represent selection and cursors.
  8885. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  8886. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  8887. // A visibility: hidden element used to find the size of things.
  8888. d.measure = elt("div", null, "CodeMirror-measure");
  8889. // When lines outside of the viewport are measured, they are drawn in this.
  8890. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  8891. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  8892. d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
  8893. null, "position: relative; outline: none");
  8894. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  8895. // Moved around its parent to cover visible view.
  8896. d.mover = elt("div", [lines], null, "position: relative");
  8897. // Set to the height of the document, allowing scrolling.
  8898. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  8899. d.sizerWidth = null;
  8900. // Behavior of elts with overflow: auto and padding is
  8901. // inconsistent across browsers. This is used to ensure the
  8902. // scrollable area is big enough.
  8903. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  8904. // Will contain the gutters, if any.
  8905. d.gutters = elt("div", null, "CodeMirror-gutters");
  8906. d.lineGutter = null;
  8907. // Actual scrollable element.
  8908. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
  8909. d.scroller.setAttribute("tabIndex", "-1");
  8910. // The element in which the editor lives.
  8911. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
  8912. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  8913. if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
  8914. if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
  8915. if (place) {
  8916. if (place.appendChild) { place.appendChild(d.wrapper); }
  8917. else { place(d.wrapper); }
  8918. }
  8919. // Current rendered range (may be bigger than the view window).
  8920. d.viewFrom = d.viewTo = doc.first;
  8921. d.reportedViewFrom = d.reportedViewTo = doc.first;
  8922. // Information about the rendered lines.
  8923. d.view = [];
  8924. d.renderedView = null;
  8925. // Holds info about a single rendered line when it was rendered
  8926. // for measurement, while not in view.
  8927. d.externalMeasured = null;
  8928. // Empty space (in pixels) above the view
  8929. d.viewOffset = 0;
  8930. d.lastWrapHeight = d.lastWrapWidth = 0;
  8931. d.updateLineNumbers = null;
  8932. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  8933. d.scrollbarsClipped = false;
  8934. // Used to only resize the line number gutter when necessary (when
  8935. // the amount of lines crosses a boundary that makes its width change)
  8936. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  8937. // Set to true when a non-horizontal-scrolling line widget is
  8938. // added. As an optimization, line widget aligning is skipped when
  8939. // this is false.
  8940. d.alignWidgets = false;
  8941. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  8942. // Tracks the maximum line length so that the horizontal scrollbar
  8943. // can be kept static when scrolling.
  8944. d.maxLine = null;
  8945. d.maxLineLength = 0;
  8946. d.maxLineChanged = false;
  8947. // Used for measuring wheel scrolling granularity
  8948. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  8949. // True when shift is held down.
  8950. d.shift = false;
  8951. // Used to track whether anything happened since the context menu
  8952. // was opened.
  8953. d.selForContextMenu = null;
  8954. d.activeTouch = null;
  8955. input.init(d);
  8956. }
  8957. // Find the line object corresponding to the given line number.
  8958. function getLine(doc, n) {
  8959. n -= doc.first;
  8960. if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
  8961. var chunk = doc;
  8962. while (!chunk.lines) {
  8963. for (var i = 0;; ++i) {
  8964. var child = chunk.children[i], sz = child.chunkSize();
  8965. if (n < sz) { chunk = child; break }
  8966. n -= sz;
  8967. }
  8968. }
  8969. return chunk.lines[n]
  8970. }
  8971. // Get the part of a document between two positions, as an array of
  8972. // strings.
  8973. function getBetween(doc, start, end) {
  8974. var out = [], n = start.line;
  8975. doc.iter(start.line, end.line + 1, function (line) {
  8976. var text = line.text;
  8977. if (n == end.line) { text = text.slice(0, end.ch); }
  8978. if (n == start.line) { text = text.slice(start.ch); }
  8979. out.push(text);
  8980. ++n;
  8981. });
  8982. return out
  8983. }
  8984. // Get the lines between from and to, as array of strings.
  8985. function getLines(doc, from, to) {
  8986. var out = [];
  8987. doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value
  8988. return out
  8989. }
  8990. // Update the height of a line, propagating the height change
  8991. // upwards to parent nodes.
  8992. function updateLineHeight(line, height) {
  8993. var diff = height - line.height;
  8994. if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }
  8995. }
  8996. // Given a line object, find its line number by walking up through
  8997. // its parent links.
  8998. function lineNo(line) {
  8999. if (line.parent == null) { return null }
  9000. var cur = line.parent, no = indexOf(cur.lines, line);
  9001. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  9002. for (var i = 0;; ++i) {
  9003. if (chunk.children[i] == cur) { break }
  9004. no += chunk.children[i].chunkSize();
  9005. }
  9006. }
  9007. return no + cur.first
  9008. }
  9009. // Find the line at the given vertical position, using the height
  9010. // information in the document tree.
  9011. function lineAtHeight(chunk, h) {
  9012. var n = chunk.first;
  9013. outer: do {
  9014. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  9015. var child = chunk.children[i$1], ch = child.height;
  9016. if (h < ch) { chunk = child; continue outer }
  9017. h -= ch;
  9018. n += child.chunkSize();
  9019. }
  9020. return n
  9021. } while (!chunk.lines)
  9022. var i = 0;
  9023. for (; i < chunk.lines.length; ++i) {
  9024. var line = chunk.lines[i], lh = line.height;
  9025. if (h < lh) { break }
  9026. h -= lh;
  9027. }
  9028. return n + i
  9029. }
  9030. function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
  9031. function lineNumberFor(options, i) {
  9032. return String(options.lineNumberFormatter(i + options.firstLineNumber))
  9033. }
  9034. // A Pos instance represents a position within the text.
  9035. function Pos(line, ch, sticky) {
  9036. if ( sticky === void 0 ) sticky = null;
  9037. if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
  9038. this.line = line;
  9039. this.ch = ch;
  9040. this.sticky = sticky;
  9041. }
  9042. // Compare two positions, return 0 if they are the same, a negative
  9043. // number when a is less, and a positive number otherwise.
  9044. function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
  9045. function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
  9046. function copyPos(x) {return Pos(x.line, x.ch)}
  9047. function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
  9048. function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
  9049. // Most of the external API clips given positions to make sure they
  9050. // actually exist within the document.
  9051. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
  9052. function clipPos(doc, pos) {
  9053. if (pos.line < doc.first) { return Pos(doc.first, 0) }
  9054. var last = doc.first + doc.size - 1;
  9055. if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
  9056. return clipToLen(pos, getLine(doc, pos.line).text.length)
  9057. }
  9058. function clipToLen(pos, linelen) {
  9059. var ch = pos.ch;
  9060. if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
  9061. else if (ch < 0) { return Pos(pos.line, 0) }
  9062. else { return pos }
  9063. }
  9064. function clipPosArray(doc, array) {
  9065. var out = [];
  9066. for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }
  9067. return out
  9068. }
  9069. // Optimize some code when these features are not used.
  9070. var sawReadOnlySpans = false;
  9071. var sawCollapsedSpans = false;
  9072. function seeReadOnlySpans() {
  9073. sawReadOnlySpans = true;
  9074. }
  9075. function seeCollapsedSpans() {
  9076. sawCollapsedSpans = true;
  9077. }
  9078. // TEXTMARKER SPANS
  9079. function MarkedSpan(marker, from, to) {
  9080. this.marker = marker;
  9081. this.from = from; this.to = to;
  9082. }
  9083. // Search an array of spans for a span matching the given marker.
  9084. function getMarkedSpanFor(spans, marker) {
  9085. if (spans) { for (var i = 0; i < spans.length; ++i) {
  9086. var span = spans[i];
  9087. if (span.marker == marker) { return span }
  9088. } }
  9089. }
  9090. // Remove a span from an array, returning undefined if no spans are
  9091. // left (we don't store arrays for lines without spans).
  9092. function removeMarkedSpan(spans, span) {
  9093. var r;
  9094. for (var i = 0; i < spans.length; ++i)
  9095. { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
  9096. return r
  9097. }
  9098. // Add a span to a line.
  9099. function addMarkedSpan(line, span) {
  9100. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  9101. span.marker.attachLine(line);
  9102. }
  9103. // Used for the algorithm that adjusts markers for a change in the
  9104. // document. These functions cut an array of spans at a given
  9105. // character position, returning an array of remaining chunks (or
  9106. // undefined if nothing remains).
  9107. function markedSpansBefore(old, startCh, isInsert) {
  9108. var nw;
  9109. if (old) { for (var i = 0; i < old.length; ++i) {
  9110. var span = old[i], marker = span.marker;
  9111. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  9112. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  9113. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  9114. }
  9115. } }
  9116. return nw
  9117. }
  9118. function markedSpansAfter(old, endCh, isInsert) {
  9119. var nw;
  9120. if (old) { for (var i = 0; i < old.length; ++i) {
  9121. var span = old[i], marker = span.marker;
  9122. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  9123. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  9124. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
  9125. span.to == null ? null : span.to - endCh));
  9126. }
  9127. } }
  9128. return nw
  9129. }
  9130. // Given a change object, compute the new set of marker spans that
  9131. // cover the line in which the change took place. Removes spans
  9132. // entirely within the change, reconnects spans belonging to the
  9133. // same marker that appear on both sides of the change, and cuts off
  9134. // spans partially within the change. Returns an array of span
  9135. // arrays with one element for each line in (after) the change.
  9136. function stretchSpansOverChange(doc, change) {
  9137. if (change.full) { return null }
  9138. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
  9139. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
  9140. if (!oldFirst && !oldLast) { return null }
  9141. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
  9142. // Get the spans that 'stick out' on both sides
  9143. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  9144. var last = markedSpansAfter(oldLast, endCh, isInsert);
  9145. // Next, merge those two ends
  9146. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
  9147. if (first) {
  9148. // Fix up .to properties of first
  9149. for (var i = 0; i < first.length; ++i) {
  9150. var span = first[i];
  9151. if (span.to == null) {
  9152. var found = getMarkedSpanFor(last, span.marker);
  9153. if (!found) { span.to = startCh; }
  9154. else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }
  9155. }
  9156. }
  9157. }
  9158. if (last) {
  9159. // Fix up .from in last (or move them into first in case of sameLine)
  9160. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  9161. var span$1 = last[i$1];
  9162. if (span$1.to != null) { span$1.to += offset; }
  9163. if (span$1.from == null) {
  9164. var found$1 = getMarkedSpanFor(first, span$1.marker);
  9165. if (!found$1) {
  9166. span$1.from = offset;
  9167. if (sameLine) { (first || (first = [])).push(span$1); }
  9168. }
  9169. } else {
  9170. span$1.from += offset;
  9171. if (sameLine) { (first || (first = [])).push(span$1); }
  9172. }
  9173. }
  9174. }
  9175. // Make sure we didn't create any zero-length spans
  9176. if (first) { first = clearEmptySpans(first); }
  9177. if (last && last != first) { last = clearEmptySpans(last); }
  9178. var newMarkers = [first];
  9179. if (!sameLine) {
  9180. // Fill gap with whole-line-spans
  9181. var gap = change.text.length - 2, gapMarkers;
  9182. if (gap > 0 && first)
  9183. { for (var i$2 = 0; i$2 < first.length; ++i$2)
  9184. { if (first[i$2].to == null)
  9185. { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }
  9186. for (var i$3 = 0; i$3 < gap; ++i$3)
  9187. { newMarkers.push(gapMarkers); }
  9188. newMarkers.push(last);
  9189. }
  9190. return newMarkers
  9191. }
  9192. // Remove spans that are empty and don't have a clearWhenEmpty
  9193. // option of false.
  9194. function clearEmptySpans(spans) {
  9195. for (var i = 0; i < spans.length; ++i) {
  9196. var span = spans[i];
  9197. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
  9198. { spans.splice(i--, 1); }
  9199. }
  9200. if (!spans.length) { return null }
  9201. return spans
  9202. }
  9203. // Used to 'clip' out readOnly ranges when making a change.
  9204. function removeReadOnlyRanges(doc, from, to) {
  9205. var markers = null;
  9206. doc.iter(from.line, to.line + 1, function (line) {
  9207. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  9208. var mark = line.markedSpans[i].marker;
  9209. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
  9210. { (markers || (markers = [])).push(mark); }
  9211. } }
  9212. });
  9213. if (!markers) { return null }
  9214. var parts = [{from: from, to: to}];
  9215. for (var i = 0; i < markers.length; ++i) {
  9216. var mk = markers[i], m = mk.find(0);
  9217. for (var j = 0; j < parts.length; ++j) {
  9218. var p = parts[j];
  9219. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
  9220. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
  9221. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
  9222. { newParts.push({from: p.from, to: m.from}); }
  9223. if (dto > 0 || !mk.inclusiveRight && !dto)
  9224. { newParts.push({from: m.to, to: p.to}); }
  9225. parts.splice.apply(parts, newParts);
  9226. j += newParts.length - 3;
  9227. }
  9228. }
  9229. return parts
  9230. }
  9231. // Connect or disconnect spans from a line.
  9232. function detachMarkedSpans(line) {
  9233. var spans = line.markedSpans;
  9234. if (!spans) { return }
  9235. for (var i = 0; i < spans.length; ++i)
  9236. { spans[i].marker.detachLine(line); }
  9237. line.markedSpans = null;
  9238. }
  9239. function attachMarkedSpans(line, spans) {
  9240. if (!spans) { return }
  9241. for (var i = 0; i < spans.length; ++i)
  9242. { spans[i].marker.attachLine(line); }
  9243. line.markedSpans = spans;
  9244. }
  9245. // Helpers used when computing which overlapping collapsed span
  9246. // counts as the larger one.
  9247. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
  9248. function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
  9249. // Returns a number indicating which of two overlapping collapsed
  9250. // spans is larger (and thus includes the other). Falls back to
  9251. // comparing ids when the spans cover exactly the same range.
  9252. function compareCollapsedMarkers(a, b) {
  9253. var lenDiff = a.lines.length - b.lines.length;
  9254. if (lenDiff != 0) { return lenDiff }
  9255. var aPos = a.find(), bPos = b.find();
  9256. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  9257. if (fromCmp) { return -fromCmp }
  9258. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  9259. if (toCmp) { return toCmp }
  9260. return b.id - a.id
  9261. }
  9262. // Find out whether a line ends or starts in a collapsed span. If
  9263. // so, return the marker for that span.
  9264. function collapsedSpanAtSide(line, start) {
  9265. var sps = sawCollapsedSpans && line.markedSpans, found;
  9266. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  9267. sp = sps[i];
  9268. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
  9269. (!found || compareCollapsedMarkers(found, sp.marker) < 0))
  9270. { found = sp.marker; }
  9271. } }
  9272. return found
  9273. }
  9274. function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
  9275. function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
  9276. // Test whether there exists a collapsed span that partially
  9277. // overlaps (covers the start or end, but not both) of a new span.
  9278. // Such overlap is not allowed.
  9279. function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {
  9280. var line = getLine(doc, lineNo$$1);
  9281. var sps = sawCollapsedSpans && line.markedSpans;
  9282. if (sps) { for (var i = 0; i < sps.length; ++i) {
  9283. var sp = sps[i];
  9284. if (!sp.marker.collapsed) { continue }
  9285. var found = sp.marker.find(0);
  9286. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  9287. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  9288. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
  9289. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
  9290. fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
  9291. { return true }
  9292. } }
  9293. }
  9294. // A visual line is a line as drawn on the screen. Folding, for
  9295. // example, can cause multiple logical lines to appear on the same
  9296. // visual line. This finds the start of the visual line that the
  9297. // given line is part of (usually that is the line itself).
  9298. function visualLine(line) {
  9299. var merged;
  9300. while (merged = collapsedSpanAtStart(line))
  9301. { line = merged.find(-1, true).line; }
  9302. return line
  9303. }
  9304. function visualLineEnd(line) {
  9305. var merged;
  9306. while (merged = collapsedSpanAtEnd(line))
  9307. { line = merged.find(1, true).line; }
  9308. return line
  9309. }
  9310. // Returns an array of logical lines that continue the visual line
  9311. // started by the argument, or undefined if there are no such lines.
  9312. function visualLineContinued(line) {
  9313. var merged, lines;
  9314. while (merged = collapsedSpanAtEnd(line)) {
  9315. line = merged.find(1, true).line
  9316. ;(lines || (lines = [])).push(line);
  9317. }
  9318. return lines
  9319. }
  9320. // Get the line number of the start of the visual line that the
  9321. // given line number is part of.
  9322. function visualLineNo(doc, lineN) {
  9323. var line = getLine(doc, lineN), vis = visualLine(line);
  9324. if (line == vis) { return lineN }
  9325. return lineNo(vis)
  9326. }
  9327. // Get the line number of the start of the next visual line after
  9328. // the given line.
  9329. function visualLineEndNo(doc, lineN) {
  9330. if (lineN > doc.lastLine()) { return lineN }
  9331. var line = getLine(doc, lineN), merged;
  9332. if (!lineIsHidden(doc, line)) { return lineN }
  9333. while (merged = collapsedSpanAtEnd(line))
  9334. { line = merged.find(1, true).line; }
  9335. return lineNo(line) + 1
  9336. }
  9337. // Compute whether a line is hidden. Lines count as hidden when they
  9338. // are part of a visual line that starts with another line, or when
  9339. // they are entirely covered by collapsed, non-widget span.
  9340. function lineIsHidden(doc, line) {
  9341. var sps = sawCollapsedSpans && line.markedSpans;
  9342. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  9343. sp = sps[i];
  9344. if (!sp.marker.collapsed) { continue }
  9345. if (sp.from == null) { return true }
  9346. if (sp.marker.widgetNode) { continue }
  9347. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
  9348. { return true }
  9349. } }
  9350. }
  9351. function lineIsHiddenInner(doc, line, span) {
  9352. if (span.to == null) {
  9353. var end = span.marker.find(1, true);
  9354. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
  9355. }
  9356. if (span.marker.inclusiveRight && span.to == line.text.length)
  9357. { return true }
  9358. for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
  9359. sp = line.markedSpans[i];
  9360. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
  9361. (sp.to == null || sp.to != span.from) &&
  9362. (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
  9363. lineIsHiddenInner(doc, line, sp)) { return true }
  9364. }
  9365. }
  9366. // Find the height above the given line.
  9367. function heightAtLine(lineObj) {
  9368. lineObj = visualLine(lineObj);
  9369. var h = 0, chunk = lineObj.parent;
  9370. for (var i = 0; i < chunk.lines.length; ++i) {
  9371. var line = chunk.lines[i];
  9372. if (line == lineObj) { break }
  9373. else { h += line.height; }
  9374. }
  9375. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  9376. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  9377. var cur = p.children[i$1];
  9378. if (cur == chunk) { break }
  9379. else { h += cur.height; }
  9380. }
  9381. }
  9382. return h
  9383. }
  9384. // Compute the character length of a line, taking into account
  9385. // collapsed ranges (see markText) that might hide parts, and join
  9386. // other lines onto it.
  9387. function lineLength(line) {
  9388. if (line.height == 0) { return 0 }
  9389. var len = line.text.length, merged, cur = line;
  9390. while (merged = collapsedSpanAtStart(cur)) {
  9391. var found = merged.find(0, true);
  9392. cur = found.from.line;
  9393. len += found.from.ch - found.to.ch;
  9394. }
  9395. cur = line;
  9396. while (merged = collapsedSpanAtEnd(cur)) {
  9397. var found$1 = merged.find(0, true);
  9398. len -= cur.text.length - found$1.from.ch;
  9399. cur = found$1.to.line;
  9400. len += cur.text.length - found$1.to.ch;
  9401. }
  9402. return len
  9403. }
  9404. // Find the longest line in the document.
  9405. function findMaxLine(cm) {
  9406. var d = cm.display, doc = cm.doc;
  9407. d.maxLine = getLine(doc, doc.first);
  9408. d.maxLineLength = lineLength(d.maxLine);
  9409. d.maxLineChanged = true;
  9410. doc.iter(function (line) {
  9411. var len = lineLength(line);
  9412. if (len > d.maxLineLength) {
  9413. d.maxLineLength = len;
  9414. d.maxLine = line;
  9415. }
  9416. });
  9417. }
  9418. // BIDI HELPERS
  9419. function iterateBidiSections(order, from, to, f) {
  9420. if (!order) { return f(from, to, "ltr", 0) }
  9421. var found = false;
  9422. for (var i = 0; i < order.length; ++i) {
  9423. var part = order[i];
  9424. if (part.from < to && part.to > from || from == to && part.to == from) {
  9425. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
  9426. found = true;
  9427. }
  9428. }
  9429. if (!found) { f(from, to, "ltr"); }
  9430. }
  9431. var bidiOther = null;
  9432. function getBidiPartAt(order, ch, sticky) {
  9433. var found;
  9434. bidiOther = null;
  9435. for (var i = 0; i < order.length; ++i) {
  9436. var cur = order[i];
  9437. if (cur.from < ch && cur.to > ch) { return i }
  9438. if (cur.to == ch) {
  9439. if (cur.from != cur.to && sticky == "before") { found = i; }
  9440. else { bidiOther = i; }
  9441. }
  9442. if (cur.from == ch) {
  9443. if (cur.from != cur.to && sticky != "before") { found = i; }
  9444. else { bidiOther = i; }
  9445. }
  9446. }
  9447. return found != null ? found : bidiOther
  9448. }
  9449. // Bidirectional ordering algorithm
  9450. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  9451. // that this (partially) implements.
  9452. // One-char codes used for character types:
  9453. // L (L): Left-to-Right
  9454. // R (R): Right-to-Left
  9455. // r (AL): Right-to-Left Arabic
  9456. // 1 (EN): European Number
  9457. // + (ES): European Number Separator
  9458. // % (ET): European Number Terminator
  9459. // n (AN): Arabic Number
  9460. // , (CS): Common Number Separator
  9461. // m (NSM): Non-Spacing Mark
  9462. // b (BN): Boundary Neutral
  9463. // s (B): Paragraph Separator
  9464. // t (S): Segment Separator
  9465. // w (WS): Whitespace
  9466. // N (ON): Other Neutrals
  9467. // Returns null if characters are ordered as they appear
  9468. // (left-to-right), or an array of sections ({from, to, level}
  9469. // objects) in the order in which they occur visually.
  9470. var bidiOrdering = (function() {
  9471. // Character types for codepoints 0 to 0xff
  9472. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  9473. // Character types for codepoints 0x600 to 0x6f9
  9474. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  9475. function charType(code) {
  9476. if (code <= 0xf7) { return lowTypes.charAt(code) }
  9477. else if (0x590 <= code && code <= 0x5f4) { return "R" }
  9478. else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
  9479. else if (0x6ee <= code && code <= 0x8ac) { return "r" }
  9480. else if (0x2000 <= code && code <= 0x200b) { return "w" }
  9481. else if (code == 0x200c) { return "b" }
  9482. else { return "L" }
  9483. }
  9484. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  9485. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
  9486. function BidiSpan(level, from, to) {
  9487. this.level = level;
  9488. this.from = from; this.to = to;
  9489. }
  9490. return function(str, direction) {
  9491. var outerType = direction == "ltr" ? "L" : "R";
  9492. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
  9493. var len = str.length, types = [];
  9494. for (var i = 0; i < len; ++i)
  9495. { types.push(charType(str.charCodeAt(i))); }
  9496. // W1. Examine each non-spacing mark (NSM) in the level run, and
  9497. // change the type of the NSM to the type of the previous
  9498. // character. If the NSM is at the start of the level run, it will
  9499. // get the type of sor.
  9500. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  9501. var type = types[i$1];
  9502. if (type == "m") { types[i$1] = prev; }
  9503. else { prev = type; }
  9504. }
  9505. // W2. Search backwards from each instance of a European number
  9506. // until the first strong type (R, L, AL, or sor) is found. If an
  9507. // AL is found, change the type of the European number to Arabic
  9508. // number.
  9509. // W3. Change all ALs to R.
  9510. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  9511. var type$1 = types[i$2];
  9512. if (type$1 == "1" && cur == "r") { types[i$2] = "n"; }
  9513. else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } }
  9514. }
  9515. // W4. A single European separator between two European numbers
  9516. // changes to a European number. A single common separator between
  9517. // two numbers of the same type changes to that type.
  9518. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  9519. var type$2 = types[i$3];
  9520. if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; }
  9521. else if (type$2 == "," && prev$1 == types[i$3+1] &&
  9522. (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; }
  9523. prev$1 = type$2;
  9524. }
  9525. // W5. A sequence of European terminators adjacent to European
  9526. // numbers changes to all European numbers.
  9527. // W6. Otherwise, separators and terminators change to Other
  9528. // Neutral.
  9529. for (var i$4 = 0; i$4 < len; ++i$4) {
  9530. var type$3 = types[i$4];
  9531. if (type$3 == ",") { types[i$4] = "N"; }
  9532. else if (type$3 == "%") {
  9533. var end = (void 0);
  9534. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  9535. var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
  9536. for (var j = i$4; j < end; ++j) { types[j] = replace; }
  9537. i$4 = end - 1;
  9538. }
  9539. }
  9540. // W7. Search backwards from each instance of a European number
  9541. // until the first strong type (R, L, or sor) is found. If an L is
  9542. // found, then change the type of the European number to L.
  9543. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  9544. var type$4 = types[i$5];
  9545. if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; }
  9546. else if (isStrong.test(type$4)) { cur$1 = type$4; }
  9547. }
  9548. // N1. A sequence of neutrals takes the direction of the
  9549. // surrounding strong text if the text on both sides has the same
  9550. // direction. European and Arabic numbers act as if they were R in
  9551. // terms of their influence on neutrals. Start-of-level-run (sor)
  9552. // and end-of-level-run (eor) are used at level run boundaries.
  9553. // N2. Any remaining neutrals take the embedding direction.
  9554. for (var i$6 = 0; i$6 < len; ++i$6) {
  9555. if (isNeutral.test(types[i$6])) {
  9556. var end$1 = (void 0);
  9557. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  9558. var before = (i$6 ? types[i$6-1] : outerType) == "L";
  9559. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  9560. var replace$1 = before == after ? (before ? "L" : "R") : outerType;
  9561. for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }
  9562. i$6 = end$1 - 1;
  9563. }
  9564. }
  9565. // Here we depart from the documented algorithm, in order to avoid
  9566. // building up an actual levels array. Since there are only three
  9567. // levels (0, 1, 2) in an implementation that doesn't take
  9568. // explicit embedding into account, we can build up the order on
  9569. // the fly, without following the level-based algorithm.
  9570. var order = [], m;
  9571. for (var i$7 = 0; i$7 < len;) {
  9572. if (countsAsLeft.test(types[i$7])) {
  9573. var start = i$7;
  9574. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  9575. order.push(new BidiSpan(0, start, i$7));
  9576. } else {
  9577. var pos = i$7, at = order.length;
  9578. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  9579. for (var j$2 = pos; j$2 < i$7;) {
  9580. if (countsAsNum.test(types[j$2])) {
  9581. if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
  9582. var nstart = j$2;
  9583. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  9584. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  9585. pos = j$2;
  9586. } else { ++j$2; }
  9587. }
  9588. if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }
  9589. }
  9590. }
  9591. if (direction == "ltr") {
  9592. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  9593. order[0].from = m[0].length;
  9594. order.unshift(new BidiSpan(0, 0, m[0].length));
  9595. }
  9596. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  9597. lst(order).to -= m[0].length;
  9598. order.push(new BidiSpan(0, len - m[0].length, len));
  9599. }
  9600. }
  9601. return direction == "rtl" ? order.reverse() : order
  9602. }
  9603. })();
  9604. // Get the bidi ordering for the given line (and cache it). Returns
  9605. // false for lines that are fully left-to-right, and an array of
  9606. // BidiSpan objects otherwise.
  9607. function getOrder(line, direction) {
  9608. var order = line.order;
  9609. if (order == null) { order = line.order = bidiOrdering(line.text, direction); }
  9610. return order
  9611. }
  9612. // EVENT HANDLING
  9613. // Lightweight event framework. on/off also work on DOM nodes,
  9614. // registering native DOM handlers.
  9615. var noHandlers = [];
  9616. var on = function(emitter, type, f) {
  9617. if (emitter.addEventListener) {
  9618. emitter.addEventListener(type, f, false);
  9619. } else if (emitter.attachEvent) {
  9620. emitter.attachEvent("on" + type, f);
  9621. } else {
  9622. var map$$1 = emitter._handlers || (emitter._handlers = {});
  9623. map$$1[type] = (map$$1[type] || noHandlers).concat(f);
  9624. }
  9625. };
  9626. function getHandlers(emitter, type) {
  9627. return emitter._handlers && emitter._handlers[type] || noHandlers
  9628. }
  9629. function off(emitter, type, f) {
  9630. if (emitter.removeEventListener) {
  9631. emitter.removeEventListener(type, f, false);
  9632. } else if (emitter.detachEvent) {
  9633. emitter.detachEvent("on" + type, f);
  9634. } else {
  9635. var map$$1 = emitter._handlers, arr = map$$1 && map$$1[type];
  9636. if (arr) {
  9637. var index = indexOf(arr, f);
  9638. if (index > -1)
  9639. { map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }
  9640. }
  9641. }
  9642. }
  9643. function signal(emitter, type /*, values...*/) {
  9644. var handlers = getHandlers(emitter, type);
  9645. if (!handlers.length) { return }
  9646. var args = Array.prototype.slice.call(arguments, 2);
  9647. for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }
  9648. }
  9649. // The DOM events that CodeMirror handles can be overridden by
  9650. // registering a (non-DOM) handler on the editor for the event name,
  9651. // and preventDefault-ing the event in that handler.
  9652. function signalDOMEvent(cm, e, override) {
  9653. if (typeof e == "string")
  9654. { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }
  9655. signal(cm, override || e.type, cm, e);
  9656. return e_defaultPrevented(e) || e.codemirrorIgnore
  9657. }
  9658. function signalCursorActivity(cm) {
  9659. var arr = cm._handlers && cm._handlers.cursorActivity;
  9660. if (!arr) { return }
  9661. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  9662. for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
  9663. { set.push(arr[i]); } }
  9664. }
  9665. function hasHandler(emitter, type) {
  9666. return getHandlers(emitter, type).length > 0
  9667. }
  9668. // Add on and off methods to a constructor's prototype, to make
  9669. // registering events on such objects more convenient.
  9670. function eventMixin(ctor) {
  9671. ctor.prototype.on = function(type, f) {on(this, type, f);};
  9672. ctor.prototype.off = function(type, f) {off(this, type, f);};
  9673. }
  9674. // Due to the fact that we still support jurassic IE versions, some
  9675. // compatibility wrappers are needed.
  9676. function e_preventDefault(e) {
  9677. if (e.preventDefault) { e.preventDefault(); }
  9678. else { e.returnValue = false; }
  9679. }
  9680. function e_stopPropagation(e) {
  9681. if (e.stopPropagation) { e.stopPropagation(); }
  9682. else { e.cancelBubble = true; }
  9683. }
  9684. function e_defaultPrevented(e) {
  9685. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
  9686. }
  9687. function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
  9688. function e_target(e) {return e.target || e.srcElement}
  9689. function e_button(e) {
  9690. var b = e.which;
  9691. if (b == null) {
  9692. if (e.button & 1) { b = 1; }
  9693. else if (e.button & 2) { b = 3; }
  9694. else if (e.button & 4) { b = 2; }
  9695. }
  9696. if (mac && e.ctrlKey && b == 1) { b = 3; }
  9697. return b
  9698. }
  9699. // Detect drag-and-drop
  9700. var dragAndDrop = function() {
  9701. // There is *some* kind of drag-and-drop support in IE6-8, but I
  9702. // couldn't get it to work yet.
  9703. if (ie && ie_version < 9) { return false }
  9704. var div = elt('div');
  9705. return "draggable" in div || "dragDrop" in div
  9706. }();
  9707. var zwspSupported;
  9708. function zeroWidthElement(measure) {
  9709. if (zwspSupported == null) {
  9710. var test = elt("span", "\u200b");
  9711. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  9712. if (measure.firstChild.offsetHeight != 0)
  9713. { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }
  9714. }
  9715. var node = zwspSupported ? elt("span", "\u200b") :
  9716. elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
  9717. node.setAttribute("cm-text", "");
  9718. return node
  9719. }
  9720. // Feature-detect IE's crummy client rect reporting for bidi text
  9721. var badBidiRects;
  9722. function hasBadBidiRects(measure) {
  9723. if (badBidiRects != null) { return badBidiRects }
  9724. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
  9725. var r0 = range(txt, 0, 1).getBoundingClientRect();
  9726. var r1 = range(txt, 1, 2).getBoundingClientRect();
  9727. removeChildren(measure);
  9728. if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
  9729. return badBidiRects = (r1.right - r0.right < 3)
  9730. }
  9731. // See if "".split is the broken IE version, if so, provide an
  9732. // alternative way to split lines.
  9733. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  9734. var pos = 0, result = [], l = string.length;
  9735. while (pos <= l) {
  9736. var nl = string.indexOf("\n", pos);
  9737. if (nl == -1) { nl = string.length; }
  9738. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  9739. var rt = line.indexOf("\r");
  9740. if (rt != -1) {
  9741. result.push(line.slice(0, rt));
  9742. pos += rt + 1;
  9743. } else {
  9744. result.push(line);
  9745. pos = nl + 1;
  9746. }
  9747. }
  9748. return result
  9749. } : function (string) { return string.split(/\r\n?|\n/); };
  9750. var hasSelection = window.getSelection ? function (te) {
  9751. try { return te.selectionStart != te.selectionEnd }
  9752. catch(e) { return false }
  9753. } : function (te) {
  9754. var range$$1;
  9755. try {range$$1 = te.ownerDocument.selection.createRange();}
  9756. catch(e) {}
  9757. if (!range$$1 || range$$1.parentElement() != te) { return false }
  9758. return range$$1.compareEndPoints("StartToEnd", range$$1) != 0
  9759. };
  9760. var hasCopyEvent = (function () {
  9761. var e = elt("div");
  9762. if ("oncopy" in e) { return true }
  9763. e.setAttribute("oncopy", "return;");
  9764. return typeof e.oncopy == "function"
  9765. })();
  9766. var badZoomedRects = null;
  9767. function hasBadZoomedRects(measure) {
  9768. if (badZoomedRects != null) { return badZoomedRects }
  9769. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  9770. var normal = node.getBoundingClientRect();
  9771. var fromRange = range(node, 0, 1).getBoundingClientRect();
  9772. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
  9773. }
  9774. // Known modes, by name and by MIME
  9775. var modes = {};
  9776. var mimeModes = {};
  9777. // Extra arguments are stored as the mode's dependencies, which is
  9778. // used by (legacy) mechanisms like loadmode.js to automatically
  9779. // load a mode. (Preferred mechanism is the require/define calls.)
  9780. function defineMode(name, mode) {
  9781. if (arguments.length > 2)
  9782. { mode.dependencies = Array.prototype.slice.call(arguments, 2); }
  9783. modes[name] = mode;
  9784. }
  9785. function defineMIME(mime, spec) {
  9786. mimeModes[mime] = spec;
  9787. }
  9788. // Given a MIME type, a {name, ...options} config object, or a name
  9789. // string, return a mode config object.
  9790. function resolveMode(spec) {
  9791. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  9792. spec = mimeModes[spec];
  9793. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  9794. var found = mimeModes[spec.name];
  9795. if (typeof found == "string") { found = {name: found}; }
  9796. spec = createObj(found, spec);
  9797. spec.name = found.name;
  9798. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  9799. return resolveMode("application/xml")
  9800. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  9801. return resolveMode("application/json")
  9802. }
  9803. if (typeof spec == "string") { return {name: spec} }
  9804. else { return spec || {name: "null"} }
  9805. }
  9806. // Given a mode spec (anything that resolveMode accepts), find and
  9807. // initialize an actual mode object.
  9808. function getMode(options, spec) {
  9809. spec = resolveMode(spec);
  9810. var mfactory = modes[spec.name];
  9811. if (!mfactory) { return getMode(options, "text/plain") }
  9812. var modeObj = mfactory(options, spec);
  9813. if (modeExtensions.hasOwnProperty(spec.name)) {
  9814. var exts = modeExtensions[spec.name];
  9815. for (var prop in exts) {
  9816. if (!exts.hasOwnProperty(prop)) { continue }
  9817. if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; }
  9818. modeObj[prop] = exts[prop];
  9819. }
  9820. }
  9821. modeObj.name = spec.name;
  9822. if (spec.helperType) { modeObj.helperType = spec.helperType; }
  9823. if (spec.modeProps) { for (var prop$1 in spec.modeProps)
  9824. { modeObj[prop$1] = spec.modeProps[prop$1]; } }
  9825. return modeObj
  9826. }
  9827. // This can be used to attach properties to mode objects from
  9828. // outside the actual mode definition.
  9829. var modeExtensions = {};
  9830. function extendMode(mode, properties) {
  9831. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
  9832. copyObj(properties, exts);
  9833. }
  9834. function copyState(mode, state) {
  9835. if (state === true) { return state }
  9836. if (mode.copyState) { return mode.copyState(state) }
  9837. var nstate = {};
  9838. for (var n in state) {
  9839. var val = state[n];
  9840. if (val instanceof Array) { val = val.concat([]); }
  9841. nstate[n] = val;
  9842. }
  9843. return nstate
  9844. }
  9845. // Given a mode and a state (for that mode), find the inner mode and
  9846. // state at the position that the state refers to.
  9847. function innerMode(mode, state) {
  9848. var info;
  9849. while (mode.innerMode) {
  9850. info = mode.innerMode(state);
  9851. if (!info || info.mode == mode) { break }
  9852. state = info.state;
  9853. mode = info.mode;
  9854. }
  9855. return info || {mode: mode, state: state}
  9856. }
  9857. function startState(mode, a1, a2) {
  9858. return mode.startState ? mode.startState(a1, a2) : true
  9859. }
  9860. // STRING STREAM
  9861. // Fed to the mode parsers, provides helper functions to make
  9862. // parsers more succinct.
  9863. var StringStream = function(string, tabSize, lineOracle) {
  9864. this.pos = this.start = 0;
  9865. this.string = string;
  9866. this.tabSize = tabSize || 8;
  9867. this.lastColumnPos = this.lastColumnValue = 0;
  9868. this.lineStart = 0;
  9869. this.lineOracle = lineOracle;
  9870. };
  9871. StringStream.prototype.eol = function () {return this.pos >= this.string.length};
  9872. StringStream.prototype.sol = function () {return this.pos == this.lineStart};
  9873. StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
  9874. StringStream.prototype.next = function () {
  9875. if (this.pos < this.string.length)
  9876. { return this.string.charAt(this.pos++) }
  9877. };
  9878. StringStream.prototype.eat = function (match) {
  9879. var ch = this.string.charAt(this.pos);
  9880. var ok;
  9881. if (typeof match == "string") { ok = ch == match; }
  9882. else { ok = ch && (match.test ? match.test(ch) : match(ch)); }
  9883. if (ok) {++this.pos; return ch}
  9884. };
  9885. StringStream.prototype.eatWhile = function (match) {
  9886. var start = this.pos;
  9887. while (this.eat(match)){}
  9888. return this.pos > start
  9889. };
  9890. StringStream.prototype.eatSpace = function () {
  9891. var this$1 = this;
  9892. var start = this.pos;
  9893. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos; }
  9894. return this.pos > start
  9895. };
  9896. StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};
  9897. StringStream.prototype.skipTo = function (ch) {
  9898. var found = this.string.indexOf(ch, this.pos);
  9899. if (found > -1) {this.pos = found; return true}
  9900. };
  9901. StringStream.prototype.backUp = function (n) {this.pos -= n;};
  9902. StringStream.prototype.column = function () {
  9903. if (this.lastColumnPos < this.start) {
  9904. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  9905. this.lastColumnPos = this.start;
  9906. }
  9907. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  9908. };
  9909. StringStream.prototype.indentation = function () {
  9910. return countColumn(this.string, null, this.tabSize) -
  9911. (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  9912. };
  9913. StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
  9914. if (typeof pattern == "string") {
  9915. var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };
  9916. var substr = this.string.substr(this.pos, pattern.length);
  9917. if (cased(substr) == cased(pattern)) {
  9918. if (consume !== false) { this.pos += pattern.length; }
  9919. return true
  9920. }
  9921. } else {
  9922. var match = this.string.slice(this.pos).match(pattern);
  9923. if (match && match.index > 0) { return null }
  9924. if (match && consume !== false) { this.pos += match[0].length; }
  9925. return match
  9926. }
  9927. };
  9928. StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
  9929. StringStream.prototype.hideFirstChars = function (n, inner) {
  9930. this.lineStart += n;
  9931. try { return inner() }
  9932. finally { this.lineStart -= n; }
  9933. };
  9934. StringStream.prototype.lookAhead = function (n) {
  9935. var oracle = this.lineOracle;
  9936. return oracle && oracle.lookAhead(n)
  9937. };
  9938. StringStream.prototype.baseToken = function () {
  9939. var oracle = this.lineOracle;
  9940. return oracle && oracle.baseToken(this.pos)
  9941. };
  9942. var SavedContext = function(state, lookAhead) {
  9943. this.state = state;
  9944. this.lookAhead = lookAhead;
  9945. };
  9946. var Context = function(doc, state, line, lookAhead) {
  9947. this.state = state;
  9948. this.doc = doc;
  9949. this.line = line;
  9950. this.maxLookAhead = lookAhead || 0;
  9951. this.baseTokens = null;
  9952. this.baseTokenPos = 1;
  9953. };
  9954. Context.prototype.lookAhead = function (n) {
  9955. var line = this.doc.getLine(this.line + n);
  9956. if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }
  9957. return line
  9958. };
  9959. Context.prototype.baseToken = function (n) {
  9960. var this$1 = this;
  9961. if (!this.baseTokens) { return null }
  9962. while (this.baseTokens[this.baseTokenPos] <= n)
  9963. { this$1.baseTokenPos += 2; }
  9964. var type = this.baseTokens[this.baseTokenPos + 1];
  9965. return {type: type && type.replace(/( |^)overlay .*/, ""),
  9966. size: this.baseTokens[this.baseTokenPos] - n}
  9967. };
  9968. Context.prototype.nextLine = function () {
  9969. this.line++;
  9970. if (this.maxLookAhead > 0) { this.maxLookAhead--; }
  9971. };
  9972. Context.fromSaved = function (doc, saved, line) {
  9973. if (saved instanceof SavedContext)
  9974. { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
  9975. else
  9976. { return new Context(doc, copyState(doc.mode, saved), line) }
  9977. };
  9978. Context.prototype.save = function (copy) {
  9979. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  9980. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
  9981. };
  9982. // Compute a style array (an array starting with a mode generation
  9983. // -- for invalidation -- followed by pairs of end positions and
  9984. // style strings), which is used to highlight the tokens on the
  9985. // line.
  9986. function highlightLine(cm, line, context, forceToEnd) {
  9987. // A styles array always starts with a number identifying the
  9988. // mode/overlays that it is based on (for easy invalidation).
  9989. var st = [cm.state.modeGen], lineClasses = {};
  9990. // Compute the base array of styles
  9991. runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
  9992. lineClasses, forceToEnd);
  9993. var state = context.state;
  9994. // Run overlays, adjust style array.
  9995. var loop = function ( o ) {
  9996. context.baseTokens = st;
  9997. var overlay = cm.state.overlays[o], i = 1, at = 0;
  9998. context.state = true;
  9999. runMode(cm, line.text, overlay.mode, context, function (end, style) {
  10000. var start = i;
  10001. // Ensure there's a token end at the current position, and that i points at it
  10002. while (at < end) {
  10003. var i_end = st[i];
  10004. if (i_end > end)
  10005. { st.splice(i, 1, end, st[i+1], i_end); }
  10006. i += 2;
  10007. at = Math.min(end, i_end);
  10008. }
  10009. if (!style) { return }
  10010. if (overlay.opaque) {
  10011. st.splice(start, i - start, end, "overlay " + style);
  10012. i = start + 2;
  10013. } else {
  10014. for (; start < i; start += 2) {
  10015. var cur = st[start+1];
  10016. st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
  10017. }
  10018. }
  10019. }, lineClasses);
  10020. context.state = state;
  10021. context.baseTokens = null;
  10022. context.baseTokenPos = 1;
  10023. };
  10024. for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
  10025. return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
  10026. }
  10027. function getLineStyles(cm, line, updateFrontier) {
  10028. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  10029. var context = getContextBefore(cm, lineNo(line));
  10030. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  10031. var result = highlightLine(cm, line, context);
  10032. if (resetState) { context.state = resetState; }
  10033. line.stateAfter = context.save(!resetState);
  10034. line.styles = result.styles;
  10035. if (result.classes) { line.styleClasses = result.classes; }
  10036. else if (line.styleClasses) { line.styleClasses = null; }
  10037. if (updateFrontier === cm.doc.highlightFrontier)
  10038. { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
  10039. }
  10040. return line.styles
  10041. }
  10042. function getContextBefore(cm, n, precise) {
  10043. var doc = cm.doc, display = cm.display;
  10044. if (!doc.mode.startState) { return new Context(doc, true, n) }
  10045. var start = findStartLine(cm, n, precise);
  10046. var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
  10047. var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
  10048. doc.iter(start, n, function (line) {
  10049. processLine(cm, line.text, context);
  10050. var pos = context.line;
  10051. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  10052. context.nextLine();
  10053. });
  10054. if (precise) { doc.modeFrontier = context.line; }
  10055. return context
  10056. }
  10057. // Lightweight form of highlight -- proceed over this line and
  10058. // update state, but don't save a style array. Used for lines that
  10059. // aren't currently visible.
  10060. function processLine(cm, text, context, startAt) {
  10061. var mode = cm.doc.mode;
  10062. var stream = new StringStream(text, cm.options.tabSize, context);
  10063. stream.start = stream.pos = startAt || 0;
  10064. if (text == "") { callBlankLine(mode, context.state); }
  10065. while (!stream.eol()) {
  10066. readToken(mode, stream, context.state);
  10067. stream.start = stream.pos;
  10068. }
  10069. }
  10070. function callBlankLine(mode, state) {
  10071. if (mode.blankLine) { return mode.blankLine(state) }
  10072. if (!mode.innerMode) { return }
  10073. var inner = innerMode(mode, state);
  10074. if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
  10075. }
  10076. function readToken(mode, stream, state, inner) {
  10077. for (var i = 0; i < 10; i++) {
  10078. if (inner) { inner[0] = innerMode(mode, state).mode; }
  10079. var style = mode.token(stream, state);
  10080. if (stream.pos > stream.start) { return style }
  10081. }
  10082. throw new Error("Mode " + mode.name + " failed to advance stream.")
  10083. }
  10084. var Token = function(stream, type, state) {
  10085. this.start = stream.start; this.end = stream.pos;
  10086. this.string = stream.current();
  10087. this.type = type || null;
  10088. this.state = state;
  10089. };
  10090. // Utility for getTokenAt and getLineTokens
  10091. function takeToken(cm, pos, precise, asArray) {
  10092. var doc = cm.doc, mode = doc.mode, style;
  10093. pos = clipPos(doc, pos);
  10094. var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
  10095. var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
  10096. if (asArray) { tokens = []; }
  10097. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  10098. stream.start = stream.pos;
  10099. style = readToken(mode, stream, context.state);
  10100. if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
  10101. }
  10102. return asArray ? tokens : new Token(stream, style, context.state)
  10103. }
  10104. function extractLineClasses(type, output) {
  10105. if (type) { for (;;) {
  10106. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  10107. if (!lineClass) { break }
  10108. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  10109. var prop = lineClass[1] ? "bgClass" : "textClass";
  10110. if (output[prop] == null)
  10111. { output[prop] = lineClass[2]; }
  10112. else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
  10113. { output[prop] += " " + lineClass[2]; }
  10114. } }
  10115. return type
  10116. }
  10117. // Run the given mode's parser over a line, calling f for each token.
  10118. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  10119. var flattenSpans = mode.flattenSpans;
  10120. if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
  10121. var curStart = 0, curStyle = null;
  10122. var stream = new StringStream(text, cm.options.tabSize, context), style;
  10123. var inner = cm.options.addModeClass && [null];
  10124. if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
  10125. while (!stream.eol()) {
  10126. if (stream.pos > cm.options.maxHighlightLength) {
  10127. flattenSpans = false;
  10128. if (forceToEnd) { processLine(cm, text, context, stream.pos); }
  10129. stream.pos = text.length;
  10130. style = null;
  10131. } else {
  10132. style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  10133. }
  10134. if (inner) {
  10135. var mName = inner[0].name;
  10136. if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
  10137. }
  10138. if (!flattenSpans || curStyle != style) {
  10139. while (curStart < stream.start) {
  10140. curStart = Math.min(stream.start, curStart + 5000);
  10141. f(curStart, curStyle);
  10142. }
  10143. curStyle = style;
  10144. }
  10145. stream.start = stream.pos;
  10146. }
  10147. while (curStart < stream.pos) {
  10148. // Webkit seems to refuse to render text nodes longer than 57444
  10149. // characters, and returns inaccurate measurements in nodes
  10150. // starting around 5000 chars.
  10151. var pos = Math.min(stream.pos, curStart + 5000);
  10152. f(pos, curStyle);
  10153. curStart = pos;
  10154. }
  10155. }
  10156. // Finds the line to start with when starting a parse. Tries to
  10157. // find a line with a stateAfter, so that it can start with a
  10158. // valid state. If that fails, it returns the line with the
  10159. // smallest indentation, which tends to need the least context to
  10160. // parse correctly.
  10161. function findStartLine(cm, n, precise) {
  10162. var minindent, minline, doc = cm.doc;
  10163. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
  10164. for (var search = n; search > lim; --search) {
  10165. if (search <= doc.first) { return doc.first }
  10166. var line = getLine(doc, search - 1), after = line.stateAfter;
  10167. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
  10168. { return search }
  10169. var indented = countColumn(line.text, null, cm.options.tabSize);
  10170. if (minline == null || minindent > indented) {
  10171. minline = search - 1;
  10172. minindent = indented;
  10173. }
  10174. }
  10175. return minline
  10176. }
  10177. function retreatFrontier(doc, n) {
  10178. doc.modeFrontier = Math.min(doc.modeFrontier, n);
  10179. if (doc.highlightFrontier < n - 10) { return }
  10180. var start = doc.first;
  10181. for (var line = n - 1; line > start; line--) {
  10182. var saved = getLine(doc, line).stateAfter;
  10183. // change is on 3
  10184. // state on line 1 looked ahead 2 -- so saw 3
  10185. // test 1 + 2 < 3 should cover this
  10186. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  10187. start = line + 1;
  10188. break
  10189. }
  10190. }
  10191. doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
  10192. }
  10193. // LINE DATA STRUCTURE
  10194. // Line objects. These hold state related to a line, including
  10195. // highlighting info (the styles array).
  10196. var Line = function(text, markedSpans, estimateHeight) {
  10197. this.text = text;
  10198. attachMarkedSpans(this, markedSpans);
  10199. this.height = estimateHeight ? estimateHeight(this) : 1;
  10200. };
  10201. Line.prototype.lineNo = function () { return lineNo(this) };
  10202. eventMixin(Line);
  10203. // Change the content (text, markers) of a line. Automatically
  10204. // invalidates cached information and tries to re-estimate the
  10205. // line's height.
  10206. function updateLine(line, text, markedSpans, estimateHeight) {
  10207. line.text = text;
  10208. if (line.stateAfter) { line.stateAfter = null; }
  10209. if (line.styles) { line.styles = null; }
  10210. if (line.order != null) { line.order = null; }
  10211. detachMarkedSpans(line);
  10212. attachMarkedSpans(line, markedSpans);
  10213. var estHeight = estimateHeight ? estimateHeight(line) : 1;
  10214. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  10215. }
  10216. // Detach a line from the document tree and its markers.
  10217. function cleanUpLine(line) {
  10218. line.parent = null;
  10219. detachMarkedSpans(line);
  10220. }
  10221. // Convert a style as returned by a mode (either null, or a string
  10222. // containing one or more styles) to a CSS style. This is cached,
  10223. // and also looks for line-wide styles.
  10224. var styleToClassCache = {};
  10225. var styleToClassCacheWithMode = {};
  10226. function interpretTokenStyle(style, options) {
  10227. if (!style || /^\s*$/.test(style)) { return null }
  10228. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  10229. return cache[style] ||
  10230. (cache[style] = style.replace(/\S+/g, "cm-$&"))
  10231. }
  10232. // Render the DOM representation of the text of a line. Also builds
  10233. // up a 'line map', which points at the DOM nodes that represent
  10234. // specific stretches of text, and is used by the measuring code.
  10235. // The returned object contains the DOM node, this map, and
  10236. // information about line-wide styles that were set by the mode.
  10237. function buildLineContent(cm, lineView) {
  10238. // The padding-right forces the element to have a 'border', which
  10239. // is needed on Webkit to be able to get line-level bounding
  10240. // rectangles for it (in measureChar).
  10241. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  10242. var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
  10243. col: 0, pos: 0, cm: cm,
  10244. trailingSpace: false,
  10245. splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
  10246. lineView.measure = {};
  10247. // Iterate over the logical lines that make up this visual line.
  10248. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  10249. var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);
  10250. builder.pos = 0;
  10251. builder.addToken = buildToken;
  10252. // Optionally wire in some hacks into the token-rendering
  10253. // algorithm, to deal with browser quirks.
  10254. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
  10255. { builder.addToken = buildTokenBadBidi(builder.addToken, order); }
  10256. builder.map = [];
  10257. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  10258. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  10259. if (line.styleClasses) {
  10260. if (line.styleClasses.bgClass)
  10261. { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); }
  10262. if (line.styleClasses.textClass)
  10263. { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); }
  10264. }
  10265. // Ensure at least a single node is present, for measuring.
  10266. if (builder.map.length == 0)
  10267. { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }
  10268. // Store the map and a cache object for the current logical line
  10269. if (i == 0) {
  10270. lineView.measure.map = builder.map;
  10271. lineView.measure.cache = {};
  10272. } else {
  10273. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
  10274. ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});
  10275. }
  10276. }
  10277. // See issue #2901
  10278. if (webkit) {
  10279. var last = builder.content.lastChild;
  10280. if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
  10281. { builder.content.className = "cm-tab-wrap-hack"; }
  10282. }
  10283. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  10284. if (builder.pre.className)
  10285. { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
  10286. return builder
  10287. }
  10288. function defaultSpecialCharPlaceholder(ch) {
  10289. var token = elt("span", "\u2022", "cm-invalidchar");
  10290. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  10291. token.setAttribute("aria-label", token.title);
  10292. return token
  10293. }
  10294. // Build up the DOM representation for a single token, and add it to
  10295. // the line map. Takes care to render special characters separately.
  10296. function buildToken(builder, text, style, startStyle, endStyle, title, css) {
  10297. if (!text) { return }
  10298. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  10299. var special = builder.cm.state.specialChars, mustWrap = false;
  10300. var content;
  10301. if (!special.test(text)) {
  10302. builder.col += text.length;
  10303. content = document.createTextNode(displayText);
  10304. builder.map.push(builder.pos, builder.pos + text.length, content);
  10305. if (ie && ie_version < 9) { mustWrap = true; }
  10306. builder.pos += text.length;
  10307. } else {
  10308. content = document.createDocumentFragment();
  10309. var pos = 0;
  10310. while (true) {
  10311. special.lastIndex = pos;
  10312. var m = special.exec(text);
  10313. var skipped = m ? m.index - pos : text.length - pos;
  10314. if (skipped) {
  10315. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  10316. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); }
  10317. else { content.appendChild(txt); }
  10318. builder.map.push(builder.pos, builder.pos + skipped, txt);
  10319. builder.col += skipped;
  10320. builder.pos += skipped;
  10321. }
  10322. if (!m) { break }
  10323. pos += skipped + 1;
  10324. var txt$1 = (void 0);
  10325. if (m[0] == "\t") {
  10326. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
  10327. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  10328. txt$1.setAttribute("role", "presentation");
  10329. txt$1.setAttribute("cm-text", "\t");
  10330. builder.col += tabWidth;
  10331. } else if (m[0] == "\r" || m[0] == "\n") {
  10332. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
  10333. txt$1.setAttribute("cm-text", m[0]);
  10334. builder.col += 1;
  10335. } else {
  10336. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  10337. txt$1.setAttribute("cm-text", m[0]);
  10338. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); }
  10339. else { content.appendChild(txt$1); }
  10340. builder.col += 1;
  10341. }
  10342. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  10343. builder.pos++;
  10344. }
  10345. }
  10346. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  10347. if (style || startStyle || endStyle || mustWrap || css) {
  10348. var fullStyle = style || "";
  10349. if (startStyle) { fullStyle += startStyle; }
  10350. if (endStyle) { fullStyle += endStyle; }
  10351. var token = elt("span", [content], fullStyle, css);
  10352. if (title) { token.title = title; }
  10353. return builder.content.appendChild(token)
  10354. }
  10355. builder.content.appendChild(content);
  10356. }
  10357. function splitSpaces(text, trailingBefore) {
  10358. if (text.length > 1 && !/ /.test(text)) { return text }
  10359. var spaceBefore = trailingBefore, result = "";
  10360. for (var i = 0; i < text.length; i++) {
  10361. var ch = text.charAt(i);
  10362. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
  10363. { ch = "\u00a0"; }
  10364. result += ch;
  10365. spaceBefore = ch == " ";
  10366. }
  10367. return result
  10368. }
  10369. // Work around nonsense dimensions being reported for stretches of
  10370. // right-to-left text.
  10371. function buildTokenBadBidi(inner, order) {
  10372. return function (builder, text, style, startStyle, endStyle, title, css) {
  10373. style = style ? style + " cm-force-border" : "cm-force-border";
  10374. var start = builder.pos, end = start + text.length;
  10375. for (;;) {
  10376. // Find the part that overlaps with the start of this text
  10377. var part = (void 0);
  10378. for (var i = 0; i < order.length; i++) {
  10379. part = order[i];
  10380. if (part.to > start && part.from <= start) { break }
  10381. }
  10382. if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }
  10383. inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
  10384. startStyle = null;
  10385. text = text.slice(part.to - start);
  10386. start = part.to;
  10387. }
  10388. }
  10389. }
  10390. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  10391. var widget = !ignoreWidget && marker.widgetNode;
  10392. if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }
  10393. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  10394. if (!widget)
  10395. { widget = builder.content.appendChild(document.createElement("span")); }
  10396. widget.setAttribute("cm-marker", marker.id);
  10397. }
  10398. if (widget) {
  10399. builder.cm.display.input.setUneditable(widget);
  10400. builder.content.appendChild(widget);
  10401. }
  10402. builder.pos += size;
  10403. builder.trailingSpace = false;
  10404. }
  10405. // Outputs a number of spans to make up a line, taking highlighting
  10406. // and marked text into account.
  10407. function insertLineContent(line, builder, styles) {
  10408. var spans = line.markedSpans, allText = line.text, at = 0;
  10409. if (!spans) {
  10410. for (var i$1 = 1; i$1 < styles.length; i$1+=2)
  10411. { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }
  10412. return
  10413. }
  10414. var len = allText.length, pos = 0, i = 1, text = "", style, css;
  10415. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
  10416. for (;;) {
  10417. if (nextChange == pos) { // Update current marker set
  10418. spanStyle = spanEndStyle = spanStartStyle = title = css = "";
  10419. collapsed = null; nextChange = Infinity;
  10420. var foundBookmarks = [], endStyles = (void 0);
  10421. for (var j = 0; j < spans.length; ++j) {
  10422. var sp = spans[j], m = sp.marker;
  10423. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  10424. foundBookmarks.push(m);
  10425. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  10426. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  10427. nextChange = sp.to;
  10428. spanEndStyle = "";
  10429. }
  10430. if (m.className) { spanStyle += " " + m.className; }
  10431. if (m.css) { css = (css ? css + ";" : "") + m.css; }
  10432. if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; }
  10433. if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }
  10434. if (m.title && !title) { title = m.title; }
  10435. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
  10436. { collapsed = sp; }
  10437. } else if (sp.from > pos && nextChange > sp.from) {
  10438. nextChange = sp.from;
  10439. }
  10440. }
  10441. if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
  10442. { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } }
  10443. if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
  10444. { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }
  10445. if (collapsed && (collapsed.from || 0) == pos) {
  10446. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
  10447. collapsed.marker, collapsed.from == null);
  10448. if (collapsed.to == null) { return }
  10449. if (collapsed.to == pos) { collapsed = false; }
  10450. }
  10451. }
  10452. if (pos >= len) { break }
  10453. var upto = Math.min(len, nextChange);
  10454. while (true) {
  10455. if (text) {
  10456. var end = pos + text.length;
  10457. if (!collapsed) {
  10458. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  10459. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
  10460. spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
  10461. }
  10462. if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
  10463. pos = end;
  10464. spanStartStyle = "";
  10465. }
  10466. text = allText.slice(at, at = styles[i++]);
  10467. style = interpretTokenStyle(styles[i++], builder.cm.options);
  10468. }
  10469. }
  10470. }
  10471. // These objects are used to represent the visible (currently drawn)
  10472. // part of the document. A LineView may correspond to multiple
  10473. // logical lines, if those are connected by collapsed ranges.
  10474. function LineView(doc, line, lineN) {
  10475. // The starting line
  10476. this.line = line;
  10477. // Continuing lines, if any
  10478. this.rest = visualLineContinued(line);
  10479. // Number of logical lines in this visual line
  10480. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  10481. this.node = this.text = null;
  10482. this.hidden = lineIsHidden(doc, line);
  10483. }
  10484. // Create a range of LineView objects for the given lines.
  10485. function buildViewArray(cm, from, to) {
  10486. var array = [], nextPos;
  10487. for (var pos = from; pos < to; pos = nextPos) {
  10488. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  10489. nextPos = pos + view.size;
  10490. array.push(view);
  10491. }
  10492. return array
  10493. }
  10494. var operationGroup = null;
  10495. function pushOperation(op) {
  10496. if (operationGroup) {
  10497. operationGroup.ops.push(op);
  10498. } else {
  10499. op.ownsGroup = operationGroup = {
  10500. ops: [op],
  10501. delayedCallbacks: []
  10502. };
  10503. }
  10504. }
  10505. function fireCallbacksForOps(group) {
  10506. // Calls delayed callbacks and cursorActivity handlers until no
  10507. // new ones appear
  10508. var callbacks = group.delayedCallbacks, i = 0;
  10509. do {
  10510. for (; i < callbacks.length; i++)
  10511. { callbacks[i].call(null); }
  10512. for (var j = 0; j < group.ops.length; j++) {
  10513. var op = group.ops[j];
  10514. if (op.cursorActivityHandlers)
  10515. { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
  10516. { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }
  10517. }
  10518. } while (i < callbacks.length)
  10519. }
  10520. function finishOperation(op, endCb) {
  10521. var group = op.ownsGroup;
  10522. if (!group) { return }
  10523. try { fireCallbacksForOps(group); }
  10524. finally {
  10525. operationGroup = null;
  10526. endCb(group);
  10527. }
  10528. }
  10529. var orphanDelayedCallbacks = null;
  10530. // Often, we want to signal events at a point where we are in the
  10531. // middle of some work, but don't want the handler to start calling
  10532. // other methods on the editor, which might be in an inconsistent
  10533. // state or simply not expect any other events to happen.
  10534. // signalLater looks whether there are any handlers, and schedules
  10535. // them to be executed when the last operation ends, or, if no
  10536. // operation is active, when a timeout fires.
  10537. function signalLater(emitter, type /*, values...*/) {
  10538. var arr = getHandlers(emitter, type);
  10539. if (!arr.length) { return }
  10540. var args = Array.prototype.slice.call(arguments, 2), list;
  10541. if (operationGroup) {
  10542. list = operationGroup.delayedCallbacks;
  10543. } else if (orphanDelayedCallbacks) {
  10544. list = orphanDelayedCallbacks;
  10545. } else {
  10546. list = orphanDelayedCallbacks = [];
  10547. setTimeout(fireOrphanDelayed, 0);
  10548. }
  10549. var loop = function ( i ) {
  10550. list.push(function () { return arr[i].apply(null, args); });
  10551. };
  10552. for (var i = 0; i < arr.length; ++i)
  10553. loop( i );
  10554. }
  10555. function fireOrphanDelayed() {
  10556. var delayed = orphanDelayedCallbacks;
  10557. orphanDelayedCallbacks = null;
  10558. for (var i = 0; i < delayed.length; ++i) { delayed[i](); }
  10559. }
  10560. // When an aspect of a line changes, a string is added to
  10561. // lineView.changes. This updates the relevant part of the line's
  10562. // DOM structure.
  10563. function updateLineForChanges(cm, lineView, lineN, dims) {
  10564. for (var j = 0; j < lineView.changes.length; j++) {
  10565. var type = lineView.changes[j];
  10566. if (type == "text") { updateLineText(cm, lineView); }
  10567. else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); }
  10568. else if (type == "class") { updateLineClasses(cm, lineView); }
  10569. else if (type == "widget") { updateLineWidgets(cm, lineView, dims); }
  10570. }
  10571. lineView.changes = null;
  10572. }
  10573. // Lines with gutter elements, widgets or a background class need to
  10574. // be wrapped, and have the extra elements added to the wrapper div
  10575. function ensureLineWrapped(lineView) {
  10576. if (lineView.node == lineView.text) {
  10577. lineView.node = elt("div", null, null, "position: relative");
  10578. if (lineView.text.parentNode)
  10579. { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }
  10580. lineView.node.appendChild(lineView.text);
  10581. if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }
  10582. }
  10583. return lineView.node
  10584. }
  10585. function updateLineBackground(cm, lineView) {
  10586. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  10587. if (cls) { cls += " CodeMirror-linebackground"; }
  10588. if (lineView.background) {
  10589. if (cls) { lineView.background.className = cls; }
  10590. else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
  10591. } else if (cls) {
  10592. var wrap = ensureLineWrapped(lineView);
  10593. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
  10594. cm.display.input.setUneditable(lineView.background);
  10595. }
  10596. }
  10597. // Wrapper around buildLineContent which will reuse the structure
  10598. // in display.externalMeasured when possible.
  10599. function getLineContent(cm, lineView) {
  10600. var ext = cm.display.externalMeasured;
  10601. if (ext && ext.line == lineView.line) {
  10602. cm.display.externalMeasured = null;
  10603. lineView.measure = ext.measure;
  10604. return ext.built
  10605. }
  10606. return buildLineContent(cm, lineView)
  10607. }
  10608. // Redraw the line's text. Interacts with the background and text
  10609. // classes because the mode may output tokens that influence these
  10610. // classes.
  10611. function updateLineText(cm, lineView) {
  10612. var cls = lineView.text.className;
  10613. var built = getLineContent(cm, lineView);
  10614. if (lineView.text == lineView.node) { lineView.node = built.pre; }
  10615. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  10616. lineView.text = built.pre;
  10617. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  10618. lineView.bgClass = built.bgClass;
  10619. lineView.textClass = built.textClass;
  10620. updateLineClasses(cm, lineView);
  10621. } else if (cls) {
  10622. lineView.text.className = cls;
  10623. }
  10624. }
  10625. function updateLineClasses(cm, lineView) {
  10626. updateLineBackground(cm, lineView);
  10627. if (lineView.line.wrapClass)
  10628. { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }
  10629. else if (lineView.node != lineView.text)
  10630. { lineView.node.className = ""; }
  10631. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  10632. lineView.text.className = textClass || "";
  10633. }
  10634. function updateLineGutter(cm, lineView, lineN, dims) {
  10635. if (lineView.gutter) {
  10636. lineView.node.removeChild(lineView.gutter);
  10637. lineView.gutter = null;
  10638. }
  10639. if (lineView.gutterBackground) {
  10640. lineView.node.removeChild(lineView.gutterBackground);
  10641. lineView.gutterBackground = null;
  10642. }
  10643. if (lineView.line.gutterClass) {
  10644. var wrap = ensureLineWrapped(lineView);
  10645. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
  10646. ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"));
  10647. cm.display.input.setUneditable(lineView.gutterBackground);
  10648. wrap.insertBefore(lineView.gutterBackground, lineView.text);
  10649. }
  10650. var markers = lineView.line.gutterMarkers;
  10651. if (cm.options.lineNumbers || markers) {
  10652. var wrap$1 = ensureLineWrapped(lineView);
  10653. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
  10654. cm.display.input.setUneditable(gutterWrap);
  10655. wrap$1.insertBefore(gutterWrap, lineView.text);
  10656. if (lineView.line.gutterClass)
  10657. { gutterWrap.className += " " + lineView.line.gutterClass; }
  10658. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
  10659. { lineView.lineNumber = gutterWrap.appendChild(
  10660. elt("div", lineNumberFor(cm.options, lineN),
  10661. "CodeMirror-linenumber CodeMirror-gutter-elt",
  10662. ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); }
  10663. if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {
  10664. var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
  10665. if (found)
  10666. { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
  10667. ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); }
  10668. } }
  10669. }
  10670. }
  10671. function updateLineWidgets(cm, lineView, dims) {
  10672. if (lineView.alignable) { lineView.alignable = null; }
  10673. for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
  10674. next = node.nextSibling;
  10675. if (node.className == "CodeMirror-linewidget")
  10676. { lineView.node.removeChild(node); }
  10677. }
  10678. insertLineWidgets(cm, lineView, dims);
  10679. }
  10680. // Build a line's DOM representation from scratch
  10681. function buildLineElement(cm, lineView, lineN, dims) {
  10682. var built = getLineContent(cm, lineView);
  10683. lineView.text = lineView.node = built.pre;
  10684. if (built.bgClass) { lineView.bgClass = built.bgClass; }
  10685. if (built.textClass) { lineView.textClass = built.textClass; }
  10686. updateLineClasses(cm, lineView);
  10687. updateLineGutter(cm, lineView, lineN, dims);
  10688. insertLineWidgets(cm, lineView, dims);
  10689. return lineView.node
  10690. }
  10691. // A lineView may contain multiple logical lines (when merged by
  10692. // collapsed spans). The widgets for all of them need to be drawn.
  10693. function insertLineWidgets(cm, lineView, dims) {
  10694. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  10695. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  10696. { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }
  10697. }
  10698. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  10699. if (!line.widgets) { return }
  10700. var wrap = ensureLineWrapped(lineView);
  10701. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  10702. var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
  10703. if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); }
  10704. positionLineWidget(widget, node, lineView, dims);
  10705. cm.display.input.setUneditable(node);
  10706. if (allowAbove && widget.above)
  10707. { wrap.insertBefore(node, lineView.gutter || lineView.text); }
  10708. else
  10709. { wrap.appendChild(node); }
  10710. signalLater(widget, "redraw");
  10711. }
  10712. }
  10713. function positionLineWidget(widget, node, lineView, dims) {
  10714. if (widget.noHScroll) {
  10715. (lineView.alignable || (lineView.alignable = [])).push(node);
  10716. var width = dims.wrapperWidth;
  10717. node.style.left = dims.fixedPos + "px";
  10718. if (!widget.coverGutter) {
  10719. width -= dims.gutterTotalWidth;
  10720. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  10721. }
  10722. node.style.width = width + "px";
  10723. }
  10724. if (widget.coverGutter) {
  10725. node.style.zIndex = 5;
  10726. node.style.position = "relative";
  10727. if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; }
  10728. }
  10729. }
  10730. function widgetHeight(widget) {
  10731. if (widget.height != null) { return widget.height }
  10732. var cm = widget.doc.cm;
  10733. if (!cm) { return 0 }
  10734. if (!contains(document.body, widget.node)) {
  10735. var parentStyle = "position: relative;";
  10736. if (widget.coverGutter)
  10737. { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; }
  10738. if (widget.noHScroll)
  10739. { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; }
  10740. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  10741. }
  10742. return widget.height = widget.node.parentNode.offsetHeight
  10743. }
  10744. // Return true when the given mouse event happened in a widget
  10745. function eventInWidget(display, e) {
  10746. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  10747. if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
  10748. (n.parentNode == display.sizer && n != display.mover))
  10749. { return true }
  10750. }
  10751. }
  10752. // POSITION MEASUREMENT
  10753. function paddingTop(display) {return display.lineSpace.offsetTop}
  10754. function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
  10755. function paddingH(display) {
  10756. if (display.cachedPaddingH) { return display.cachedPaddingH }
  10757. var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
  10758. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  10759. var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
  10760. if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
  10761. return data
  10762. }
  10763. function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
  10764. function displayWidth(cm) {
  10765. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
  10766. }
  10767. function displayHeight(cm) {
  10768. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
  10769. }
  10770. // Ensure the lineView.wrapping.heights array is populated. This is
  10771. // an array of bottom offsets for the lines that make up a drawn
  10772. // line. When lineWrapping is on, there might be more than one
  10773. // height.
  10774. function ensureLineHeights(cm, lineView, rect) {
  10775. var wrapping = cm.options.lineWrapping;
  10776. var curWidth = wrapping && displayWidth(cm);
  10777. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  10778. var heights = lineView.measure.heights = [];
  10779. if (wrapping) {
  10780. lineView.measure.width = curWidth;
  10781. var rects = lineView.text.firstChild.getClientRects();
  10782. for (var i = 0; i < rects.length - 1; i++) {
  10783. var cur = rects[i], next = rects[i + 1];
  10784. if (Math.abs(cur.bottom - next.bottom) > 2)
  10785. { heights.push((cur.bottom + next.top) / 2 - rect.top); }
  10786. }
  10787. }
  10788. heights.push(rect.bottom - rect.top);
  10789. }
  10790. }
  10791. // Find a line map (mapping character offsets to text nodes) and a
  10792. // measurement cache for the given line number. (A line view might
  10793. // contain multiple lines when collapsed ranges are present.)
  10794. function mapFromLineView(lineView, line, lineN) {
  10795. if (lineView.line == line)
  10796. { return {map: lineView.measure.map, cache: lineView.measure.cache} }
  10797. for (var i = 0; i < lineView.rest.length; i++)
  10798. { if (lineView.rest[i] == line)
  10799. { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
  10800. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
  10801. { if (lineNo(lineView.rest[i$1]) > lineN)
  10802. { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
  10803. }
  10804. // Render a line into the hidden node display.externalMeasured. Used
  10805. // when measurement is needed for a line that's not in the viewport.
  10806. function updateExternalMeasurement(cm, line) {
  10807. line = visualLine(line);
  10808. var lineN = lineNo(line);
  10809. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  10810. view.lineN = lineN;
  10811. var built = view.built = buildLineContent(cm, view);
  10812. view.text = built.pre;
  10813. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  10814. return view
  10815. }
  10816. // Get a {top, bottom, left, right} box (in line-local coordinates)
  10817. // for a given character.
  10818. function measureChar(cm, line, ch, bias) {
  10819. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
  10820. }
  10821. // Find a line view that corresponds to the given line number.
  10822. function findViewForLine(cm, lineN) {
  10823. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
  10824. { return cm.display.view[findViewIndex(cm, lineN)] }
  10825. var ext = cm.display.externalMeasured;
  10826. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
  10827. { return ext }
  10828. }
  10829. // Measurement can be split in two steps, the set-up work that
  10830. // applies to the whole line, and the measurement of the actual
  10831. // character. Functions like coordsChar, that need to do a lot of
  10832. // measurements in a row, can thus ensure that the set-up work is
  10833. // only done once.
  10834. function prepareMeasureForLine(cm, line) {
  10835. var lineN = lineNo(line);
  10836. var view = findViewForLine(cm, lineN);
  10837. if (view && !view.text) {
  10838. view = null;
  10839. } else if (view && view.changes) {
  10840. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  10841. cm.curOp.forceUpdate = true;
  10842. }
  10843. if (!view)
  10844. { view = updateExternalMeasurement(cm, line); }
  10845. var info = mapFromLineView(view, line, lineN);
  10846. return {
  10847. line: line, view: view, rect: null,
  10848. map: info.map, cache: info.cache, before: info.before,
  10849. hasHeights: false
  10850. }
  10851. }
  10852. // Given a prepared measurement object, measures the position of an
  10853. // actual character (or fetches it from the cache).
  10854. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  10855. if (prepared.before) { ch = -1; }
  10856. var key = ch + (bias || ""), found;
  10857. if (prepared.cache.hasOwnProperty(key)) {
  10858. found = prepared.cache[key];
  10859. } else {
  10860. if (!prepared.rect)
  10861. { prepared.rect = prepared.view.text.getBoundingClientRect(); }
  10862. if (!prepared.hasHeights) {
  10863. ensureLineHeights(cm, prepared.view, prepared.rect);
  10864. prepared.hasHeights = true;
  10865. }
  10866. found = measureCharInner(cm, prepared, ch, bias);
  10867. if (!found.bogus) { prepared.cache[key] = found; }
  10868. }
  10869. return {left: found.left, right: found.right,
  10870. top: varHeight ? found.rtop : found.top,
  10871. bottom: varHeight ? found.rbottom : found.bottom}
  10872. }
  10873. var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
  10874. function nodeAndOffsetInLineMap(map$$1, ch, bias) {
  10875. var node, start, end, collapse, mStart, mEnd;
  10876. // First, search the line map for the text node corresponding to,
  10877. // or closest to, the target character.
  10878. for (var i = 0; i < map$$1.length; i += 3) {
  10879. mStart = map$$1[i];
  10880. mEnd = map$$1[i + 1];
  10881. if (ch < mStart) {
  10882. start = 0; end = 1;
  10883. collapse = "left";
  10884. } else if (ch < mEnd) {
  10885. start = ch - mStart;
  10886. end = start + 1;
  10887. } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {
  10888. end = mEnd - mStart;
  10889. start = end - 1;
  10890. if (ch >= mEnd) { collapse = "right"; }
  10891. }
  10892. if (start != null) {
  10893. node = map$$1[i + 2];
  10894. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
  10895. { collapse = bias; }
  10896. if (bias == "left" && start == 0)
  10897. { while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {
  10898. node = map$$1[(i -= 3) + 2];
  10899. collapse = "left";
  10900. } }
  10901. if (bias == "right" && start == mEnd - mStart)
  10902. { while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {
  10903. node = map$$1[(i += 3) + 2];
  10904. collapse = "right";
  10905. } }
  10906. break
  10907. }
  10908. }
  10909. return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
  10910. }
  10911. function getUsefulRect(rects, bias) {
  10912. var rect = nullRect;
  10913. if (bias == "left") { for (var i = 0; i < rects.length; i++) {
  10914. if ((rect = rects[i]).left != rect.right) { break }
  10915. } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  10916. if ((rect = rects[i$1]).left != rect.right) { break }
  10917. } }
  10918. return rect
  10919. }
  10920. function measureCharInner(cm, prepared, ch, bias) {
  10921. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  10922. var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
  10923. var rect;
  10924. if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
  10925. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
  10926. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }
  10927. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }
  10928. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
  10929. { rect = node.parentNode.getBoundingClientRect(); }
  10930. else
  10931. { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
  10932. if (rect.left || rect.right || start == 0) { break }
  10933. end = start;
  10934. start = start - 1;
  10935. collapse = "right";
  10936. }
  10937. if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }
  10938. } else { // If it is a widget, simply get the box for the whole widget.
  10939. if (start > 0) { collapse = bias = "right"; }
  10940. var rects;
  10941. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
  10942. { rect = rects[bias == "right" ? rects.length - 1 : 0]; }
  10943. else
  10944. { rect = node.getBoundingClientRect(); }
  10945. }
  10946. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  10947. var rSpan = node.parentNode.getClientRects()[0];
  10948. if (rSpan)
  10949. { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }
  10950. else
  10951. { rect = nullRect; }
  10952. }
  10953. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
  10954. var mid = (rtop + rbot) / 2;
  10955. var heights = prepared.view.measure.heights;
  10956. var i = 0;
  10957. for (; i < heights.length - 1; i++)
  10958. { if (mid < heights[i]) { break } }
  10959. var top = i ? heights[i - 1] : 0, bot = heights[i];
  10960. var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  10961. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  10962. top: top, bottom: bot};
  10963. if (!rect.left && !rect.right) { result.bogus = true; }
  10964. if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
  10965. return result
  10966. }
  10967. // Work around problem with bounding client rects on ranges being
  10968. // returned incorrectly when zoomed on IE10 and below.
  10969. function maybeUpdateRectForZooming(measure, rect) {
  10970. if (!window.screen || screen.logicalXDPI == null ||
  10971. screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
  10972. { return rect }
  10973. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  10974. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  10975. return {left: rect.left * scaleX, right: rect.right * scaleX,
  10976. top: rect.top * scaleY, bottom: rect.bottom * scaleY}
  10977. }
  10978. function clearLineMeasurementCacheFor(lineView) {
  10979. if (lineView.measure) {
  10980. lineView.measure.cache = {};
  10981. lineView.measure.heights = null;
  10982. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  10983. { lineView.measure.caches[i] = {}; } }
  10984. }
  10985. }
  10986. function clearLineMeasurementCache(cm) {
  10987. cm.display.externalMeasure = null;
  10988. removeChildren(cm.display.lineMeasure);
  10989. for (var i = 0; i < cm.display.view.length; i++)
  10990. { clearLineMeasurementCacheFor(cm.display.view[i]); }
  10991. }
  10992. function clearCaches(cm) {
  10993. clearLineMeasurementCache(cm);
  10994. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  10995. if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }
  10996. cm.display.lineNumChars = null;
  10997. }
  10998. function pageScrollX() {
  10999. // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
  11000. // which causes page_Offset and bounding client rects to use
  11001. // different reference viewports and invalidate our calculations.
  11002. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
  11003. return window.pageXOffset || (document.documentElement || document.body).scrollLeft
  11004. }
  11005. function pageScrollY() {
  11006. if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
  11007. return window.pageYOffset || (document.documentElement || document.body).scrollTop
  11008. }
  11009. function widgetTopHeight(lineObj) {
  11010. var height = 0;
  11011. if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
  11012. { height += widgetHeight(lineObj.widgets[i]); } } }
  11013. return height
  11014. }
  11015. // Converts a {top, bottom, left, right} box from line-local
  11016. // coordinates into another coordinate system. Context may be one of
  11017. // "line", "div" (display.lineDiv), "local"./null (editor), "window",
  11018. // or "page".
  11019. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  11020. if (!includeWidgets) {
  11021. var height = widgetTopHeight(lineObj);
  11022. rect.top += height; rect.bottom += height;
  11023. }
  11024. if (context == "line") { return rect }
  11025. if (!context) { context = "local"; }
  11026. var yOff = heightAtLine(lineObj);
  11027. if (context == "local") { yOff += paddingTop(cm.display); }
  11028. else { yOff -= cm.display.viewOffset; }
  11029. if (context == "page" || context == "window") {
  11030. var lOff = cm.display.lineSpace.getBoundingClientRect();
  11031. yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
  11032. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
  11033. rect.left += xOff; rect.right += xOff;
  11034. }
  11035. rect.top += yOff; rect.bottom += yOff;
  11036. return rect
  11037. }
  11038. // Coverts a box from "div" coords to another coordinate system.
  11039. // Context may be "window", "page", "div", or "local"./null.
  11040. function fromCoordSystem(cm, coords, context) {
  11041. if (context == "div") { return coords }
  11042. var left = coords.left, top = coords.top;
  11043. // First move into "page" coordinate system
  11044. if (context == "page") {
  11045. left -= pageScrollX();
  11046. top -= pageScrollY();
  11047. } else if (context == "local" || !context) {
  11048. var localBox = cm.display.sizer.getBoundingClientRect();
  11049. left += localBox.left;
  11050. top += localBox.top;
  11051. }
  11052. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  11053. return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
  11054. }
  11055. function charCoords(cm, pos, context, lineObj, bias) {
  11056. if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }
  11057. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
  11058. }
  11059. // Returns a box for a given cursor position, which may have an
  11060. // 'other' property containing the position of the secondary cursor
  11061. // on a bidi boundary.
  11062. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
  11063. // and after `char - 1` in writing order of `char - 1`
  11064. // A cursor Pos(line, char, "after") is on the same visual line as `char`
  11065. // and before `char` in writing order of `char`
  11066. // Examples (upper-case letters are RTL, lower-case are LTR):
  11067. // Pos(0, 1, ...)
  11068. // before after
  11069. // ab a|b a|b
  11070. // aB a|B aB|
  11071. // Ab |Ab A|b
  11072. // AB B|A B|A
  11073. // Every position after the last character on a line is considered to stick
  11074. // to the last character on the line.
  11075. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  11076. lineObj = lineObj || getLine(cm.doc, pos.line);
  11077. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  11078. function get(ch, right) {
  11079. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
  11080. if (right) { m.left = m.right; } else { m.right = m.left; }
  11081. return intoCoordSystem(cm, lineObj, m, context)
  11082. }
  11083. var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
  11084. if (ch >= lineObj.text.length) {
  11085. ch = lineObj.text.length;
  11086. sticky = "before";
  11087. } else if (ch <= 0) {
  11088. ch = 0;
  11089. sticky = "after";
  11090. }
  11091. if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
  11092. function getBidi(ch, partPos, invert) {
  11093. var part = order[partPos], right = part.level == 1;
  11094. return get(invert ? ch - 1 : ch, right != invert)
  11095. }
  11096. var partPos = getBidiPartAt(order, ch, sticky);
  11097. var other = bidiOther;
  11098. var val = getBidi(ch, partPos, sticky == "before");
  11099. if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
  11100. return val
  11101. }
  11102. // Used to cheaply estimate the coordinates for a position. Used for
  11103. // intermediate scroll updates.
  11104. function estimateCoords(cm, pos) {
  11105. var left = 0;
  11106. pos = clipPos(cm.doc, pos);
  11107. if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }
  11108. var lineObj = getLine(cm.doc, pos.line);
  11109. var top = heightAtLine(lineObj) + paddingTop(cm.display);
  11110. return {left: left, right: left, top: top, bottom: top + lineObj.height}
  11111. }
  11112. // Positions returned by coordsChar contain some extra information.
  11113. // xRel is the relative x position of the input coordinates compared
  11114. // to the found position (so xRel > 0 means the coordinates are to
  11115. // the right of the character position, for example). When outside
  11116. // is true, that means the coordinates lie outside the line's
  11117. // vertical range.
  11118. function PosWithInfo(line, ch, sticky, outside, xRel) {
  11119. var pos = Pos(line, ch, sticky);
  11120. pos.xRel = xRel;
  11121. if (outside) { pos.outside = true; }
  11122. return pos
  11123. }
  11124. // Compute the character position closest to the given coordinates.
  11125. // Input must be lineSpace-local ("div" coordinate system).
  11126. function coordsChar(cm, x, y) {
  11127. var doc = cm.doc;
  11128. y += cm.display.viewOffset;
  11129. if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
  11130. var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
  11131. if (lineN > last)
  11132. { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
  11133. if (x < 0) { x = 0; }
  11134. var lineObj = getLine(doc, lineN);
  11135. for (;;) {
  11136. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  11137. var merged = collapsedSpanAtEnd(lineObj);
  11138. var mergedPos = merged && merged.find(0, true);
  11139. if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
  11140. { lineN = lineNo(lineObj = mergedPos.to.line); }
  11141. else
  11142. { return found }
  11143. }
  11144. }
  11145. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  11146. y -= widgetTopHeight(lineObj);
  11147. var end = lineObj.text.length;
  11148. var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);
  11149. end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);
  11150. return {begin: begin, end: end}
  11151. }
  11152. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  11153. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  11154. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  11155. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
  11156. }
  11157. // Returns true if the given side of a box is after the given
  11158. // coordinates, in top-to-bottom, left-to-right order.
  11159. function boxIsAfter(box, x, y, left) {
  11160. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
  11161. }
  11162. function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {
  11163. // Move y into line-local coordinate space
  11164. y -= heightAtLine(lineObj);
  11165. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  11166. // When directly calling `measureCharPrepared`, we have to adjust
  11167. // for the widgets at this line.
  11168. var widgetHeight$$1 = widgetTopHeight(lineObj);
  11169. var begin = 0, end = lineObj.text.length, ltr = true;
  11170. var order = getOrder(lineObj, cm.doc.direction);
  11171. // If the line isn't plain left-to-right text, first figure out
  11172. // which bidi section the coordinates fall into.
  11173. if (order) {
  11174. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
  11175. (cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);
  11176. ltr = part.level != 1;
  11177. // The awkward -1 offsets are needed because findFirst (called
  11178. // on these below) will treat its first bound as inclusive,
  11179. // second as exclusive, but we want to actually address the
  11180. // characters in the part's range
  11181. begin = ltr ? part.from : part.to - 1;
  11182. end = ltr ? part.to : part.from - 1;
  11183. }
  11184. // A binary search to find the first character whose bounding box
  11185. // starts after the coordinates. If we run across any whose box wrap
  11186. // the coordinates, store that.
  11187. var chAround = null, boxAround = null;
  11188. var ch = findFirst(function (ch) {
  11189. var box = measureCharPrepared(cm, preparedMeasure, ch);
  11190. box.top += widgetHeight$$1; box.bottom += widgetHeight$$1;
  11191. if (!boxIsAfter(box, x, y, false)) { return false }
  11192. if (box.top <= y && box.left <= x) {
  11193. chAround = ch;
  11194. boxAround = box;
  11195. }
  11196. return true
  11197. }, begin, end);
  11198. var baseX, sticky, outside = false;
  11199. // If a box around the coordinates was found, use that
  11200. if (boxAround) {
  11201. // Distinguish coordinates nearer to the left or right side of the box
  11202. var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
  11203. ch = chAround + (atStart ? 0 : 1);
  11204. sticky = atStart ? "after" : "before";
  11205. baseX = atLeft ? boxAround.left : boxAround.right;
  11206. } else {
  11207. // (Adjust for extended bound, if necessary.)
  11208. if (!ltr && (ch == end || ch == begin)) { ch++; }
  11209. // To determine which side to associate with, get the box to the
  11210. // left of the character and compare it's vertical position to the
  11211. // coordinates
  11212. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
  11213. (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y) == ltr ?
  11214. "after" : "before";
  11215. // Now get accurate coordinates for this place, in order to get a
  11216. // base X position
  11217. var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
  11218. baseX = coords.left;
  11219. outside = y < coords.top || y >= coords.bottom;
  11220. }
  11221. ch = skipExtendingChars(lineObj.text, ch, 1);
  11222. return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX)
  11223. }
  11224. function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
  11225. // Bidi parts are sorted left-to-right, and in a non-line-wrapping
  11226. // situation, we can take this ordering to correspond to the visual
  11227. // ordering. This finds the first part whose end is after the given
  11228. // coordinates.
  11229. var index = findFirst(function (i) {
  11230. var part = order[i], ltr = part.level != 1;
  11231. return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"),
  11232. "line", lineObj, preparedMeasure), x, y, true)
  11233. }, 0, order.length - 1);
  11234. var part = order[index];
  11235. // If this isn't the first part, the part's start is also after
  11236. // the coordinates, and the coordinates aren't on the same line as
  11237. // that start, move one part back.
  11238. if (index > 0) {
  11239. var ltr = part.level != 1;
  11240. var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"),
  11241. "line", lineObj, preparedMeasure);
  11242. if (boxIsAfter(start, x, y, true) && start.top > y)
  11243. { part = order[index - 1]; }
  11244. }
  11245. return part
  11246. }
  11247. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  11248. // In a wrapped line, rtl text on wrapping boundaries can do things
  11249. // that don't correspond to the ordering in our `order` array at
  11250. // all, so a binary search doesn't work, and we want to return a
  11251. // part that only spans one line so that the binary search in
  11252. // coordsCharInner is safe. As such, we first find the extent of the
  11253. // wrapped line, and then do a flat search in which we discard any
  11254. // spans that aren't on the line.
  11255. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  11256. var begin = ref.begin;
  11257. var end = ref.end;
  11258. if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; }
  11259. var part = null, closestDist = null;
  11260. for (var i = 0; i < order.length; i++) {
  11261. var p = order[i];
  11262. if (p.from >= end || p.to <= begin) { continue }
  11263. var ltr = p.level != 1;
  11264. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  11265. // Weigh against spans ending before this, so that they are only
  11266. // picked if nothing ends after
  11267. var dist = endX < x ? x - endX + 1e9 : endX - x;
  11268. if (!part || closestDist > dist) {
  11269. part = p;
  11270. closestDist = dist;
  11271. }
  11272. }
  11273. if (!part) { part = order[order.length - 1]; }
  11274. // Clip the part to the wrapped line.
  11275. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }
  11276. if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }
  11277. return part
  11278. }
  11279. var measureText;
  11280. // Compute the default text height.
  11281. function textHeight(display) {
  11282. if (display.cachedTextHeight != null) { return display.cachedTextHeight }
  11283. if (measureText == null) {
  11284. measureText = elt("pre");
  11285. // Measure a bunch of lines, for browsers that compute
  11286. // fractional heights.
  11287. for (var i = 0; i < 49; ++i) {
  11288. measureText.appendChild(document.createTextNode("x"));
  11289. measureText.appendChild(elt("br"));
  11290. }
  11291. measureText.appendChild(document.createTextNode("x"));
  11292. }
  11293. removeChildrenAndAdd(display.measure, measureText);
  11294. var height = measureText.offsetHeight / 50;
  11295. if (height > 3) { display.cachedTextHeight = height; }
  11296. removeChildren(display.measure);
  11297. return height || 1
  11298. }
  11299. // Compute the default character width.
  11300. function charWidth(display) {
  11301. if (display.cachedCharWidth != null) { return display.cachedCharWidth }
  11302. var anchor = elt("span", "xxxxxxxxxx");
  11303. var pre = elt("pre", [anchor]);
  11304. removeChildrenAndAdd(display.measure, pre);
  11305. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
  11306. if (width > 2) { display.cachedCharWidth = width; }
  11307. return width || 10
  11308. }
  11309. // Do a bulk-read of the DOM positions and sizes needed to draw the
  11310. // view, so that we don't interleave reading and writing to the DOM.
  11311. function getDimensions(cm) {
  11312. var d = cm.display, left = {}, width = {};
  11313. var gutterLeft = d.gutters.clientLeft;
  11314. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  11315. left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
  11316. width[cm.options.gutters[i]] = n.clientWidth;
  11317. }
  11318. return {fixedPos: compensateForHScroll(d),
  11319. gutterTotalWidth: d.gutters.offsetWidth,
  11320. gutterLeft: left,
  11321. gutterWidth: width,
  11322. wrapperWidth: d.wrapper.clientWidth}
  11323. }
  11324. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  11325. // but using getBoundingClientRect to get a sub-pixel-accurate
  11326. // result.
  11327. function compensateForHScroll(display) {
  11328. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
  11329. }
  11330. // Returns a function that estimates the height of a line, to use as
  11331. // first approximation until the line becomes visible (and is thus
  11332. // properly measurable).
  11333. function estimateHeight(cm) {
  11334. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
  11335. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  11336. return function (line) {
  11337. if (lineIsHidden(cm.doc, line)) { return 0 }
  11338. var widgetsHeight = 0;
  11339. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
  11340. if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
  11341. } }
  11342. if (wrapping)
  11343. { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
  11344. else
  11345. { return widgetsHeight + th }
  11346. }
  11347. }
  11348. function estimateLineHeights(cm) {
  11349. var doc = cm.doc, est = estimateHeight(cm);
  11350. doc.iter(function (line) {
  11351. var estHeight = est(line);
  11352. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  11353. });
  11354. }
  11355. // Given a mouse event, find the corresponding position. If liberal
  11356. // is false, it checks whether a gutter or scrollbar was clicked,
  11357. // and returns null if it was. forRect is used by rectangular
  11358. // selections, and tries to estimate a character position even for
  11359. // coordinates beyond the right of the text.
  11360. function posFromMouse(cm, e, liberal, forRect) {
  11361. var display = cm.display;
  11362. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
  11363. var x, y, space = display.lineSpace.getBoundingClientRect();
  11364. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  11365. try { x = e.clientX - space.left; y = e.clientY - space.top; }
  11366. catch (e) { return null }
  11367. var coords = coordsChar(cm, x, y), line;
  11368. if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  11369. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  11370. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  11371. }
  11372. return coords
  11373. }
  11374. // Find the view element corresponding to a given line. Return null
  11375. // when the line isn't visible.
  11376. function findViewIndex(cm, n) {
  11377. if (n >= cm.display.viewTo) { return null }
  11378. n -= cm.display.viewFrom;
  11379. if (n < 0) { return null }
  11380. var view = cm.display.view;
  11381. for (var i = 0; i < view.length; i++) {
  11382. n -= view[i].size;
  11383. if (n < 0) { return i }
  11384. }
  11385. }
  11386. function updateSelection(cm) {
  11387. cm.display.input.showSelection(cm.display.input.prepareSelection());
  11388. }
  11389. function prepareSelection(cm, primary) {
  11390. if ( primary === void 0 ) primary = true;
  11391. var doc = cm.doc, result = {};
  11392. var curFragment = result.cursors = document.createDocumentFragment();
  11393. var selFragment = result.selection = document.createDocumentFragment();
  11394. for (var i = 0; i < doc.sel.ranges.length; i++) {
  11395. if (!primary && i == doc.sel.primIndex) { continue }
  11396. var range$$1 = doc.sel.ranges[i];
  11397. if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) { continue }
  11398. var collapsed = range$$1.empty();
  11399. if (collapsed || cm.options.showCursorWhenSelecting)
  11400. { drawSelectionCursor(cm, range$$1.head, curFragment); }
  11401. if (!collapsed)
  11402. { drawSelectionRange(cm, range$$1, selFragment); }
  11403. }
  11404. return result
  11405. }
  11406. // Draws a cursor for the given range
  11407. function drawSelectionCursor(cm, head, output) {
  11408. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  11409. var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
  11410. cursor.style.left = pos.left + "px";
  11411. cursor.style.top = pos.top + "px";
  11412. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  11413. if (pos.other) {
  11414. // Secondary cursor, shown when on a 'jump' in bi-directional text
  11415. var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  11416. otherCursor.style.display = "";
  11417. otherCursor.style.left = pos.other.left + "px";
  11418. otherCursor.style.top = pos.other.top + "px";
  11419. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  11420. }
  11421. }
  11422. function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
  11423. // Draws the given range as a highlighted selection
  11424. function drawSelectionRange(cm, range$$1, output) {
  11425. var display = cm.display, doc = cm.doc;
  11426. var fragment = document.createDocumentFragment();
  11427. var padding = paddingH(cm.display), leftSide = padding.left;
  11428. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  11429. var docLTR = doc.direction == "ltr";
  11430. function add(left, top, width, bottom) {
  11431. if (top < 0) { top = 0; }
  11432. top = Math.round(top);
  11433. bottom = Math.round(bottom);
  11434. fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")));
  11435. }
  11436. function drawForLine(line, fromArg, toArg) {
  11437. var lineObj = getLine(doc, line);
  11438. var lineLen = lineObj.text.length;
  11439. var start, end;
  11440. function coords(ch, bias) {
  11441. return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
  11442. }
  11443. function wrapX(pos, dir, side) {
  11444. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  11445. var prop = (dir == "ltr") == (side == "after") ? "left" : "right";
  11446. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  11447. return coords(ch, prop)[prop]
  11448. }
  11449. var order = getOrder(lineObj, doc.direction);
  11450. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
  11451. var ltr = dir == "ltr";
  11452. var fromPos = coords(from, ltr ? "left" : "right");
  11453. var toPos = coords(to - 1, ltr ? "right" : "left");
  11454. var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
  11455. var first = i == 0, last = !order || i == order.length - 1;
  11456. if (toPos.top - fromPos.top <= 3) { // Single line
  11457. var openLeft = (docLTR ? openStart : openEnd) && first;
  11458. var openRight = (docLTR ? openEnd : openStart) && last;
  11459. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  11460. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  11461. add(left, fromPos.top, right - left, fromPos.bottom);
  11462. } else { // Multiple lines
  11463. var topLeft, topRight, botLeft, botRight;
  11464. if (ltr) {
  11465. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  11466. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  11467. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  11468. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  11469. } else {
  11470. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  11471. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  11472. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  11473. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  11474. }
  11475. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  11476. if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }
  11477. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  11478. }
  11479. if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }
  11480. if (cmpCoords(toPos, start) < 0) { start = toPos; }
  11481. if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }
  11482. if (cmpCoords(toPos, end) < 0) { end = toPos; }
  11483. });
  11484. return {start: start, end: end}
  11485. }
  11486. var sFrom = range$$1.from(), sTo = range$$1.to();
  11487. if (sFrom.line == sTo.line) {
  11488. drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  11489. } else {
  11490. var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
  11491. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  11492. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  11493. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  11494. if (singleVLine) {
  11495. if (leftEnd.top < rightStart.top - 2) {
  11496. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  11497. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  11498. } else {
  11499. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  11500. }
  11501. }
  11502. if (leftEnd.bottom < rightStart.top)
  11503. { add(leftSide, leftEnd.bottom, null, rightStart.top); }
  11504. }
  11505. output.appendChild(fragment);
  11506. }
  11507. // Cursor-blinking
  11508. function restartBlink(cm) {
  11509. if (!cm.state.focused) { return }
  11510. var display = cm.display;
  11511. clearInterval(display.blinker);
  11512. var on = true;
  11513. display.cursorDiv.style.visibility = "";
  11514. if (cm.options.cursorBlinkRate > 0)
  11515. { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
  11516. cm.options.cursorBlinkRate); }
  11517. else if (cm.options.cursorBlinkRate < 0)
  11518. { display.cursorDiv.style.visibility = "hidden"; }
  11519. }
  11520. function ensureFocus(cm) {
  11521. if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
  11522. }
  11523. function delayBlurEvent(cm) {
  11524. cm.state.delayingBlurEvent = true;
  11525. setTimeout(function () { if (cm.state.delayingBlurEvent) {
  11526. cm.state.delayingBlurEvent = false;
  11527. onBlur(cm);
  11528. } }, 100);
  11529. }
  11530. function onFocus(cm, e) {
  11531. if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
  11532. if (cm.options.readOnly == "nocursor") { return }
  11533. if (!cm.state.focused) {
  11534. signal(cm, "focus", cm, e);
  11535. cm.state.focused = true;
  11536. addClass(cm.display.wrapper, "CodeMirror-focused");
  11537. // This test prevents this from firing when a context
  11538. // menu is closed (since the input reset would kill the
  11539. // select-all detection hack)
  11540. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  11541. cm.display.input.reset();
  11542. if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730
  11543. }
  11544. cm.display.input.receivedFocus();
  11545. }
  11546. restartBlink(cm);
  11547. }
  11548. function onBlur(cm, e) {
  11549. if (cm.state.delayingBlurEvent) { return }
  11550. if (cm.state.focused) {
  11551. signal(cm, "blur", cm, e);
  11552. cm.state.focused = false;
  11553. rmClass(cm.display.wrapper, "CodeMirror-focused");
  11554. }
  11555. clearInterval(cm.display.blinker);
  11556. setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);
  11557. }
  11558. // Read the actual heights of the rendered lines, and update their
  11559. // stored heights to match.
  11560. function updateHeightsInViewport(cm) {
  11561. var display = cm.display;
  11562. var prevBottom = display.lineDiv.offsetTop;
  11563. for (var i = 0; i < display.view.length; i++) {
  11564. var cur = display.view[i], height = (void 0);
  11565. if (cur.hidden) { continue }
  11566. if (ie && ie_version < 8) {
  11567. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  11568. height = bot - prevBottom;
  11569. prevBottom = bot;
  11570. } else {
  11571. var box = cur.node.getBoundingClientRect();
  11572. height = box.bottom - box.top;
  11573. }
  11574. var diff = cur.line.height - height;
  11575. if (height < 2) { height = textHeight(display); }
  11576. if (diff > .005 || diff < -.005) {
  11577. updateLineHeight(cur.line, height);
  11578. updateWidgetHeight(cur.line);
  11579. if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
  11580. { updateWidgetHeight(cur.rest[j]); } }
  11581. }
  11582. }
  11583. }
  11584. // Read and store the height of line widgets associated with the
  11585. // given line.
  11586. function updateWidgetHeight(line) {
  11587. if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
  11588. var w = line.widgets[i], parent = w.node.parentNode;
  11589. if (parent) { w.height = parent.offsetHeight; }
  11590. } }
  11591. }
  11592. // Compute the lines that are visible in a given viewport (defaults
  11593. // the the current scroll position). viewport may contain top,
  11594. // height, and ensure (see op.scrollToPos) properties.
  11595. function visibleLines(display, doc, viewport) {
  11596. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  11597. top = Math.floor(top - paddingTop(display));
  11598. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  11599. var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
  11600. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  11601. // forces those lines into the viewport (if possible).
  11602. if (viewport && viewport.ensure) {
  11603. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
  11604. if (ensureFrom < from) {
  11605. from = ensureFrom;
  11606. to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
  11607. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  11608. from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
  11609. to = ensureTo;
  11610. }
  11611. }
  11612. return {from: from, to: Math.max(to, from + 1)}
  11613. }
  11614. // Re-align line numbers and gutter marks to compensate for
  11615. // horizontal scrolling.
  11616. function alignHorizontally(cm) {
  11617. var display = cm.display, view = display.view;
  11618. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
  11619. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  11620. var gutterW = display.gutters.offsetWidth, left = comp + "px";
  11621. for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
  11622. if (cm.options.fixedGutter) {
  11623. if (view[i].gutter)
  11624. { view[i].gutter.style.left = left; }
  11625. if (view[i].gutterBackground)
  11626. { view[i].gutterBackground.style.left = left; }
  11627. }
  11628. var align = view[i].alignable;
  11629. if (align) { for (var j = 0; j < align.length; j++)
  11630. { align[j].style.left = left; } }
  11631. } }
  11632. if (cm.options.fixedGutter)
  11633. { display.gutters.style.left = (comp + gutterW) + "px"; }
  11634. }
  11635. // Used to ensure that the line number gutter is still the right
  11636. // size for the current document size. Returns true when an update
  11637. // is needed.
  11638. function maybeUpdateLineNumberWidth(cm) {
  11639. if (!cm.options.lineNumbers) { return false }
  11640. var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
  11641. if (last.length != display.lineNumChars) {
  11642. var test = display.measure.appendChild(elt("div", [elt("div", last)],
  11643. "CodeMirror-linenumber CodeMirror-gutter-elt"));
  11644. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
  11645. display.lineGutter.style.width = "";
  11646. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  11647. display.lineNumWidth = display.lineNumInnerWidth + padding;
  11648. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  11649. display.lineGutter.style.width = display.lineNumWidth + "px";
  11650. updateGutterSpace(cm);
  11651. return true
  11652. }
  11653. return false
  11654. }
  11655. // SCROLLING THINGS INTO VIEW
  11656. // If an editor sits on the top or bottom of the window, partially
  11657. // scrolled out of view, this ensures that the cursor is visible.
  11658. function maybeScrollWindow(cm, rect) {
  11659. if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
  11660. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
  11661. if (rect.top + box.top < 0) { doScroll = true; }
  11662. else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
  11663. if (doScroll != null && !phantom) {
  11664. var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
  11665. cm.display.lineSpace.appendChild(scrollNode);
  11666. scrollNode.scrollIntoView(doScroll);
  11667. cm.display.lineSpace.removeChild(scrollNode);
  11668. }
  11669. }
  11670. // Scroll a given position into view (immediately), verifying that
  11671. // it actually became visible (as line heights are accurately
  11672. // measured, the position of something may 'drift' during drawing).
  11673. function scrollPosIntoView(cm, pos, end, margin) {
  11674. if (margin == null) { margin = 0; }
  11675. var rect;
  11676. if (!cm.options.lineWrapping && pos == end) {
  11677. // Set pos and end to the cursor positions around the character pos sticks to
  11678. // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
  11679. // If pos == Pos(_, 0, "before"), pos and end are unchanged
  11680. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  11681. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  11682. }
  11683. for (var limit = 0; limit < 5; limit++) {
  11684. var changed = false;
  11685. var coords = cursorCoords(cm, pos);
  11686. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
  11687. rect = {left: Math.min(coords.left, endCoords.left),
  11688. top: Math.min(coords.top, endCoords.top) - margin,
  11689. right: Math.max(coords.left, endCoords.left),
  11690. bottom: Math.max(coords.bottom, endCoords.bottom) + margin};
  11691. var scrollPos = calculateScrollPos(cm, rect);
  11692. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
  11693. if (scrollPos.scrollTop != null) {
  11694. updateScrollTop(cm, scrollPos.scrollTop);
  11695. if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }
  11696. }
  11697. if (scrollPos.scrollLeft != null) {
  11698. setScrollLeft(cm, scrollPos.scrollLeft);
  11699. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }
  11700. }
  11701. if (!changed) { break }
  11702. }
  11703. return rect
  11704. }
  11705. // Scroll a given set of coordinates into view (immediately).
  11706. function scrollIntoView(cm, rect) {
  11707. var scrollPos = calculateScrollPos(cm, rect);
  11708. if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }
  11709. if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }
  11710. }
  11711. // Calculate a new scroll position needed to scroll the given
  11712. // rectangle into view. Returns an object with scrollTop and
  11713. // scrollLeft properties. When these are undefined, the
  11714. // vertical/horizontal position does not need to be adjusted.
  11715. function calculateScrollPos(cm, rect) {
  11716. var display = cm.display, snapMargin = textHeight(cm.display);
  11717. if (rect.top < 0) { rect.top = 0; }
  11718. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  11719. var screen = displayHeight(cm), result = {};
  11720. if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }
  11721. var docBottom = cm.doc.height + paddingVert(display);
  11722. var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
  11723. if (rect.top < screentop) {
  11724. result.scrollTop = atTop ? 0 : rect.top;
  11725. } else if (rect.bottom > screentop + screen) {
  11726. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
  11727. if (newTop != screentop) { result.scrollTop = newTop; }
  11728. }
  11729. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
  11730. var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
  11731. var tooWide = rect.right - rect.left > screenw;
  11732. if (tooWide) { rect.right = rect.left + screenw; }
  11733. if (rect.left < 10)
  11734. { result.scrollLeft = 0; }
  11735. else if (rect.left < screenleft)
  11736. { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
  11737. else if (rect.right > screenw + screenleft - 3)
  11738. { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
  11739. return result
  11740. }
  11741. // Store a relative adjustment to the scroll position in the current
  11742. // operation (to be applied when the operation finishes).
  11743. function addToScrollTop(cm, top) {
  11744. if (top == null) { return }
  11745. resolveScrollToPos(cm);
  11746. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  11747. }
  11748. // Make sure that at the end of the operation the current cursor is
  11749. // shown.
  11750. function ensureCursorVisible(cm) {
  11751. resolveScrollToPos(cm);
  11752. var cur = cm.getCursor();
  11753. cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};
  11754. }
  11755. function scrollToCoords(cm, x, y) {
  11756. if (x != null || y != null) { resolveScrollToPos(cm); }
  11757. if (x != null) { cm.curOp.scrollLeft = x; }
  11758. if (y != null) { cm.curOp.scrollTop = y; }
  11759. }
  11760. function scrollToRange(cm, range$$1) {
  11761. resolveScrollToPos(cm);
  11762. cm.curOp.scrollToPos = range$$1;
  11763. }
  11764. // When an operation has its scrollToPos property set, and another
  11765. // scroll action is applied before the end of the operation, this
  11766. // 'simulates' scrolling that position into view in a cheap way, so
  11767. // that the effect of intermediate scroll commands is not ignored.
  11768. function resolveScrollToPos(cm) {
  11769. var range$$1 = cm.curOp.scrollToPos;
  11770. if (range$$1) {
  11771. cm.curOp.scrollToPos = null;
  11772. var from = estimateCoords(cm, range$$1.from), to = estimateCoords(cm, range$$1.to);
  11773. scrollToCoordsRange(cm, from, to, range$$1.margin);
  11774. }
  11775. }
  11776. function scrollToCoordsRange(cm, from, to, margin) {
  11777. var sPos = calculateScrollPos(cm, {
  11778. left: Math.min(from.left, to.left),
  11779. top: Math.min(from.top, to.top) - margin,
  11780. right: Math.max(from.right, to.right),
  11781. bottom: Math.max(from.bottom, to.bottom) + margin
  11782. });
  11783. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  11784. }
  11785. // Sync the scrollable area and scrollbars, ensure the viewport
  11786. // covers the visible area.
  11787. function updateScrollTop(cm, val) {
  11788. if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
  11789. if (!gecko) { updateDisplaySimple(cm, {top: val}); }
  11790. setScrollTop(cm, val, true);
  11791. if (gecko) { updateDisplaySimple(cm); }
  11792. startWorker(cm, 100);
  11793. }
  11794. function setScrollTop(cm, val, forceScroll) {
  11795. val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
  11796. if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
  11797. cm.doc.scrollTop = val;
  11798. cm.display.scrollbars.setScrollTop(val);
  11799. if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }
  11800. }
  11801. // Sync scroller and scrollbar, ensure the gutter elements are
  11802. // aligned.
  11803. function setScrollLeft(cm, val, isScroller, forceScroll) {
  11804. val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
  11805. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
  11806. cm.doc.scrollLeft = val;
  11807. alignHorizontally(cm);
  11808. if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }
  11809. cm.display.scrollbars.setScrollLeft(val);
  11810. }
  11811. // SCROLLBARS
  11812. // Prepare DOM reads needed to update the scrollbars. Done in one
  11813. // shot to minimize update/measure roundtrips.
  11814. function measureForScrollbars(cm) {
  11815. var d = cm.display, gutterW = d.gutters.offsetWidth;
  11816. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  11817. return {
  11818. clientHeight: d.scroller.clientHeight,
  11819. viewHeight: d.wrapper.clientHeight,
  11820. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  11821. viewWidth: d.wrapper.clientWidth,
  11822. barLeft: cm.options.fixedGutter ? gutterW : 0,
  11823. docHeight: docH,
  11824. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  11825. nativeBarWidth: d.nativeBarWidth,
  11826. gutterWidth: gutterW
  11827. }
  11828. }
  11829. var NativeScrollbars = function(place, scroll, cm) {
  11830. this.cm = cm;
  11831. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  11832. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  11833. place(vert); place(horiz);
  11834. on(vert, "scroll", function () {
  11835. if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); }
  11836. });
  11837. on(horiz, "scroll", function () {
  11838. if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); }
  11839. });
  11840. this.checkedZeroWidth = false;
  11841. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  11842. if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; }
  11843. };
  11844. NativeScrollbars.prototype.update = function (measure) {
  11845. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  11846. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  11847. var sWidth = measure.nativeBarWidth;
  11848. if (needsV) {
  11849. this.vert.style.display = "block";
  11850. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  11851. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  11852. // A bug in IE8 can cause this value to be negative, so guard it.
  11853. this.vert.firstChild.style.height =
  11854. Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  11855. } else {
  11856. this.vert.style.display = "";
  11857. this.vert.firstChild.style.height = "0";
  11858. }
  11859. if (needsH) {
  11860. this.horiz.style.display = "block";
  11861. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  11862. this.horiz.style.left = measure.barLeft + "px";
  11863. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  11864. this.horiz.firstChild.style.width =
  11865. Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  11866. } else {
  11867. this.horiz.style.display = "";
  11868. this.horiz.firstChild.style.width = "0";
  11869. }
  11870. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  11871. if (sWidth == 0) { this.zeroWidthHack(); }
  11872. this.checkedZeroWidth = true;
  11873. }
  11874. return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
  11875. };
  11876. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  11877. if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }
  11878. if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }
  11879. };
  11880. NativeScrollbars.prototype.setScrollTop = function (pos) {
  11881. if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }
  11882. if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }
  11883. };
  11884. NativeScrollbars.prototype.zeroWidthHack = function () {
  11885. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  11886. this.horiz.style.height = this.vert.style.width = w;
  11887. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
  11888. this.disableHoriz = new Delayed;
  11889. this.disableVert = new Delayed;
  11890. };
  11891. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
  11892. bar.style.pointerEvents = "auto";
  11893. function maybeDisable() {
  11894. // To find out whether the scrollbar is still visible, we
  11895. // check whether the element under the pixel in the bottom
  11896. // right corner of the scrollbar box is the scrollbar box
  11897. // itself (when the bar is still visible) or its filler child
  11898. // (when the bar is hidden). If it is still visible, we keep
  11899. // it enabled, if it's hidden, we disable pointer events.
  11900. var box = bar.getBoundingClientRect();
  11901. var elt$$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
  11902. : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  11903. if (elt$$1 != bar) { bar.style.pointerEvents = "none"; }
  11904. else { delay.set(1000, maybeDisable); }
  11905. }
  11906. delay.set(1000, maybeDisable);
  11907. };
  11908. NativeScrollbars.prototype.clear = function () {
  11909. var parent = this.horiz.parentNode;
  11910. parent.removeChild(this.horiz);
  11911. parent.removeChild(this.vert);
  11912. };
  11913. var NullScrollbars = function () {};
  11914. NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
  11915. NullScrollbars.prototype.setScrollLeft = function () {};
  11916. NullScrollbars.prototype.setScrollTop = function () {};
  11917. NullScrollbars.prototype.clear = function () {};
  11918. function updateScrollbars(cm, measure) {
  11919. if (!measure) { measure = measureForScrollbars(cm); }
  11920. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
  11921. updateScrollbarsInner(cm, measure);
  11922. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  11923. if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
  11924. { updateHeightsInViewport(cm); }
  11925. updateScrollbarsInner(cm, measureForScrollbars(cm));
  11926. startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
  11927. }
  11928. }
  11929. // Re-synchronize the fake scrollbars with the actual size of the
  11930. // content.
  11931. function updateScrollbarsInner(cm, measure) {
  11932. var d = cm.display;
  11933. var sizes = d.scrollbars.update(measure);
  11934. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  11935. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  11936. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  11937. if (sizes.right && sizes.bottom) {
  11938. d.scrollbarFiller.style.display = "block";
  11939. d.scrollbarFiller.style.height = sizes.bottom + "px";
  11940. d.scrollbarFiller.style.width = sizes.right + "px";
  11941. } else { d.scrollbarFiller.style.display = ""; }
  11942. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  11943. d.gutterFiller.style.display = "block";
  11944. d.gutterFiller.style.height = sizes.bottom + "px";
  11945. d.gutterFiller.style.width = measure.gutterWidth + "px";
  11946. } else { d.gutterFiller.style.display = ""; }
  11947. }
  11948. var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
  11949. function initScrollbars(cm) {
  11950. if (cm.display.scrollbars) {
  11951. cm.display.scrollbars.clear();
  11952. if (cm.display.scrollbars.addClass)
  11953. { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  11954. }
  11955. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  11956. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  11957. // Prevent clicks in the scrollbars from killing focus
  11958. on(node, "mousedown", function () {
  11959. if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }
  11960. });
  11961. node.setAttribute("cm-not-content", "true");
  11962. }, function (pos, axis) {
  11963. if (axis == "horizontal") { setScrollLeft(cm, pos); }
  11964. else { updateScrollTop(cm, pos); }
  11965. }, cm);
  11966. if (cm.display.scrollbars.addClass)
  11967. { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  11968. }
  11969. // Operations are used to wrap a series of changes to the editor
  11970. // state in such a way that each change won't have to update the
  11971. // cursor and display (which would be awkward, slow, and
  11972. // error-prone). Instead, display updates are batched and then all
  11973. // combined and executed at once.
  11974. var nextOpId = 0;
  11975. // Start a new operation.
  11976. function startOperation(cm) {
  11977. cm.curOp = {
  11978. cm: cm,
  11979. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  11980. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  11981. forceUpdate: false, // Used to force a redraw
  11982. updateInput: null, // Whether to reset the input textarea
  11983. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  11984. changeObjs: null, // Accumulated changes, for firing change events
  11985. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  11986. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  11987. selectionChanged: false, // Whether the selection needs to be redrawn
  11988. updateMaxLine: false, // Set when the widest line needs to be determined anew
  11989. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  11990. scrollToPos: null, // Used to scroll to a specific position
  11991. focus: false,
  11992. id: ++nextOpId // Unique ID
  11993. };
  11994. pushOperation(cm.curOp);
  11995. }
  11996. // Finish an operation, updating the display and signalling delayed events
  11997. function endOperation(cm) {
  11998. var op = cm.curOp;
  11999. finishOperation(op, function (group) {
  12000. for (var i = 0; i < group.ops.length; i++)
  12001. { group.ops[i].cm.curOp = null; }
  12002. endOperations(group);
  12003. });
  12004. }
  12005. // The DOM updates done when an operation finishes are batched so
  12006. // that the minimum number of relayouts are required.
  12007. function endOperations(group) {
  12008. var ops = group.ops;
  12009. for (var i = 0; i < ops.length; i++) // Read DOM
  12010. { endOperation_R1(ops[i]); }
  12011. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  12012. { endOperation_W1(ops[i$1]); }
  12013. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  12014. { endOperation_R2(ops[i$2]); }
  12015. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  12016. { endOperation_W2(ops[i$3]); }
  12017. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  12018. { endOperation_finish(ops[i$4]); }
  12019. }
  12020. function endOperation_R1(op) {
  12021. var cm = op.cm, display = cm.display;
  12022. maybeClipScrollbars(cm);
  12023. if (op.updateMaxLine) { findMaxLine(cm); }
  12024. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
  12025. op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
  12026. op.scrollToPos.to.line >= display.viewTo) ||
  12027. display.maxLineChanged && cm.options.lineWrapping;
  12028. op.update = op.mustUpdate &&
  12029. new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
  12030. }
  12031. function endOperation_W1(op) {
  12032. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  12033. }
  12034. function endOperation_R2(op) {
  12035. var cm = op.cm, display = cm.display;
  12036. if (op.updatedDisplay) { updateHeightsInViewport(cm); }
  12037. op.barMeasure = measureForScrollbars(cm);
  12038. // If the max line changed since it was last measured, measure it,
  12039. // and ensure the document's width matches it.
  12040. // updateDisplay_W2 will use these properties to do the actual resizing
  12041. if (display.maxLineChanged && !cm.options.lineWrapping) {
  12042. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  12043. cm.display.sizerWidth = op.adjustWidthTo;
  12044. op.barMeasure.scrollWidth =
  12045. Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  12046. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  12047. }
  12048. if (op.updatedDisplay || op.selectionChanged)
  12049. { op.preparedSelection = display.input.prepareSelection(); }
  12050. }
  12051. function endOperation_W2(op) {
  12052. var cm = op.cm;
  12053. if (op.adjustWidthTo != null) {
  12054. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  12055. if (op.maxScrollLeft < cm.doc.scrollLeft)
  12056. { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }
  12057. cm.display.maxLineChanged = false;
  12058. }
  12059. var takeFocus = op.focus && op.focus == activeElt();
  12060. if (op.preparedSelection)
  12061. { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
  12062. if (op.updatedDisplay || op.startHeight != cm.doc.height)
  12063. { updateScrollbars(cm, op.barMeasure); }
  12064. if (op.updatedDisplay)
  12065. { setDocumentHeight(cm, op.barMeasure); }
  12066. if (op.selectionChanged) { restartBlink(cm); }
  12067. if (cm.state.focused && op.updateInput)
  12068. { cm.display.input.reset(op.typing); }
  12069. if (takeFocus) { ensureFocus(op.cm); }
  12070. }
  12071. function endOperation_finish(op) {
  12072. var cm = op.cm, display = cm.display, doc = cm.doc;
  12073. if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }
  12074. // Abort mouse wheel delta measurement, when scrolling explicitly
  12075. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
  12076. { display.wheelStartX = display.wheelStartY = null; }
  12077. // Propagate the scroll position to the actual DOM scroller
  12078. if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }
  12079. if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }
  12080. // If we need to scroll a specific position into view, do so.
  12081. if (op.scrollToPos) {
  12082. var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
  12083. clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
  12084. maybeScrollWindow(cm, rect);
  12085. }
  12086. // Fire events for markers that are hidden/unidden by editing or
  12087. // undoing
  12088. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
  12089. if (hidden) { for (var i = 0; i < hidden.length; ++i)
  12090. { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } }
  12091. if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
  12092. { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } }
  12093. if (display.wrapper.offsetHeight)
  12094. { doc.scrollTop = cm.display.scroller.scrollTop; }
  12095. // Fire change events, and delayed event handlers
  12096. if (op.changeObjs)
  12097. { signal(cm, "changes", cm, op.changeObjs); }
  12098. if (op.update)
  12099. { op.update.finish(); }
  12100. }
  12101. // Run the given function in an operation
  12102. function runInOp(cm, f) {
  12103. if (cm.curOp) { return f() }
  12104. startOperation(cm);
  12105. try { return f() }
  12106. finally { endOperation(cm); }
  12107. }
  12108. // Wraps a function in an operation. Returns the wrapped function.
  12109. function operation(cm, f) {
  12110. return function() {
  12111. if (cm.curOp) { return f.apply(cm, arguments) }
  12112. startOperation(cm);
  12113. try { return f.apply(cm, arguments) }
  12114. finally { endOperation(cm); }
  12115. }
  12116. }
  12117. // Used to add methods to editor and doc instances, wrapping them in
  12118. // operations.
  12119. function methodOp(f) {
  12120. return function() {
  12121. if (this.curOp) { return f.apply(this, arguments) }
  12122. startOperation(this);
  12123. try { return f.apply(this, arguments) }
  12124. finally { endOperation(this); }
  12125. }
  12126. }
  12127. function docMethodOp(f) {
  12128. return function() {
  12129. var cm = this.cm;
  12130. if (!cm || cm.curOp) { return f.apply(this, arguments) }
  12131. startOperation(cm);
  12132. try { return f.apply(this, arguments) }
  12133. finally { endOperation(cm); }
  12134. }
  12135. }
  12136. // Updates the display.view data structure for a given change to the
  12137. // document. From and to are in pre-change coordinates. Lendiff is
  12138. // the amount of lines added or subtracted by the change. This is
  12139. // used for changes that span multiple lines, or change the way
  12140. // lines are divided into visual lines. regLineChange (below)
  12141. // registers single-line changes.
  12142. function regChange(cm, from, to, lendiff) {
  12143. if (from == null) { from = cm.doc.first; }
  12144. if (to == null) { to = cm.doc.first + cm.doc.size; }
  12145. if (!lendiff) { lendiff = 0; }
  12146. var display = cm.display;
  12147. if (lendiff && to < display.viewTo &&
  12148. (display.updateLineNumbers == null || display.updateLineNumbers > from))
  12149. { display.updateLineNumbers = from; }
  12150. cm.curOp.viewChanged = true;
  12151. if (from >= display.viewTo) { // Change after
  12152. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
  12153. { resetView(cm); }
  12154. } else if (to <= display.viewFrom) { // Change before
  12155. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  12156. resetView(cm);
  12157. } else {
  12158. display.viewFrom += lendiff;
  12159. display.viewTo += lendiff;
  12160. }
  12161. } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
  12162. resetView(cm);
  12163. } else if (from <= display.viewFrom) { // Top overlap
  12164. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  12165. if (cut) {
  12166. display.view = display.view.slice(cut.index);
  12167. display.viewFrom = cut.lineN;
  12168. display.viewTo += lendiff;
  12169. } else {
  12170. resetView(cm);
  12171. }
  12172. } else if (to >= display.viewTo) { // Bottom overlap
  12173. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  12174. if (cut$1) {
  12175. display.view = display.view.slice(0, cut$1.index);
  12176. display.viewTo = cut$1.lineN;
  12177. } else {
  12178. resetView(cm);
  12179. }
  12180. } else { // Gap in the middle
  12181. var cutTop = viewCuttingPoint(cm, from, from, -1);
  12182. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  12183. if (cutTop && cutBot) {
  12184. display.view = display.view.slice(0, cutTop.index)
  12185. .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
  12186. .concat(display.view.slice(cutBot.index));
  12187. display.viewTo += lendiff;
  12188. } else {
  12189. resetView(cm);
  12190. }
  12191. }
  12192. var ext = display.externalMeasured;
  12193. if (ext) {
  12194. if (to < ext.lineN)
  12195. { ext.lineN += lendiff; }
  12196. else if (from < ext.lineN + ext.size)
  12197. { display.externalMeasured = null; }
  12198. }
  12199. }
  12200. // Register a change to a single line. Type must be one of "text",
  12201. // "gutter", "class", "widget"
  12202. function regLineChange(cm, line, type) {
  12203. cm.curOp.viewChanged = true;
  12204. var display = cm.display, ext = cm.display.externalMeasured;
  12205. if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
  12206. { display.externalMeasured = null; }
  12207. if (line < display.viewFrom || line >= display.viewTo) { return }
  12208. var lineView = display.view[findViewIndex(cm, line)];
  12209. if (lineView.node == null) { return }
  12210. var arr = lineView.changes || (lineView.changes = []);
  12211. if (indexOf(arr, type) == -1) { arr.push(type); }
  12212. }
  12213. // Clear the view.
  12214. function resetView(cm) {
  12215. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  12216. cm.display.view = [];
  12217. cm.display.viewOffset = 0;
  12218. }
  12219. function viewCuttingPoint(cm, oldN, newN, dir) {
  12220. var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
  12221. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
  12222. { return {index: index, lineN: newN} }
  12223. var n = cm.display.viewFrom;
  12224. for (var i = 0; i < index; i++)
  12225. { n += view[i].size; }
  12226. if (n != oldN) {
  12227. if (dir > 0) {
  12228. if (index == view.length - 1) { return null }
  12229. diff = (n + view[index].size) - oldN;
  12230. index++;
  12231. } else {
  12232. diff = n - oldN;
  12233. }
  12234. oldN += diff; newN += diff;
  12235. }
  12236. while (visualLineNo(cm.doc, newN) != newN) {
  12237. if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
  12238. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  12239. index += dir;
  12240. }
  12241. return {index: index, lineN: newN}
  12242. }
  12243. // Force the view to cover a given range, adding empty view element
  12244. // or clipping off existing ones as needed.
  12245. function adjustView(cm, from, to) {
  12246. var display = cm.display, view = display.view;
  12247. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  12248. display.view = buildViewArray(cm, from, to);
  12249. display.viewFrom = from;
  12250. } else {
  12251. if (display.viewFrom > from)
  12252. { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
  12253. else if (display.viewFrom < from)
  12254. { display.view = display.view.slice(findViewIndex(cm, from)); }
  12255. display.viewFrom = from;
  12256. if (display.viewTo < to)
  12257. { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
  12258. else if (display.viewTo > to)
  12259. { display.view = display.view.slice(0, findViewIndex(cm, to)); }
  12260. }
  12261. display.viewTo = to;
  12262. }
  12263. // Count the number of lines in the view whose DOM representation is
  12264. // out of date (or nonexistent).
  12265. function countDirtyView(cm) {
  12266. var view = cm.display.view, dirty = 0;
  12267. for (var i = 0; i < view.length; i++) {
  12268. var lineView = view[i];
  12269. if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }
  12270. }
  12271. return dirty
  12272. }
  12273. // HIGHLIGHT WORKER
  12274. function startWorker(cm, time) {
  12275. if (cm.doc.highlightFrontier < cm.display.viewTo)
  12276. { cm.state.highlight.set(time, bind(highlightWorker, cm)); }
  12277. }
  12278. function highlightWorker(cm) {
  12279. var doc = cm.doc;
  12280. if (doc.highlightFrontier >= cm.display.viewTo) { return }
  12281. var end = +new Date + cm.options.workTime;
  12282. var context = getContextBefore(cm, doc.highlightFrontier);
  12283. var changedLines = [];
  12284. doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  12285. if (context.line >= cm.display.viewFrom) { // Visible
  12286. var oldStyles = line.styles;
  12287. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
  12288. var highlighted = highlightLine(cm, line, context, true);
  12289. if (resetState) { context.state = resetState; }
  12290. line.styles = highlighted.styles;
  12291. var oldCls = line.styleClasses, newCls = highlighted.classes;
  12292. if (newCls) { line.styleClasses = newCls; }
  12293. else if (oldCls) { line.styleClasses = null; }
  12294. var ischange = !oldStyles || oldStyles.length != line.styles.length ||
  12295. oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  12296. for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }
  12297. if (ischange) { changedLines.push(context.line); }
  12298. line.stateAfter = context.save();
  12299. context.nextLine();
  12300. } else {
  12301. if (line.text.length <= cm.options.maxHighlightLength)
  12302. { processLine(cm, line.text, context); }
  12303. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  12304. context.nextLine();
  12305. }
  12306. if (+new Date > end) {
  12307. startWorker(cm, cm.options.workDelay);
  12308. return true
  12309. }
  12310. });
  12311. doc.highlightFrontier = context.line;
  12312. doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
  12313. if (changedLines.length) { runInOp(cm, function () {
  12314. for (var i = 0; i < changedLines.length; i++)
  12315. { regLineChange(cm, changedLines[i], "text"); }
  12316. }); }
  12317. }
  12318. // DISPLAY DRAWING
  12319. var DisplayUpdate = function(cm, viewport, force) {
  12320. var display = cm.display;
  12321. this.viewport = viewport;
  12322. // Store some values that we'll need later (but don't want to force a relayout for)
  12323. this.visible = visibleLines(display, cm.doc, viewport);
  12324. this.editorIsHidden = !display.wrapper.offsetWidth;
  12325. this.wrapperHeight = display.wrapper.clientHeight;
  12326. this.wrapperWidth = display.wrapper.clientWidth;
  12327. this.oldDisplayWidth = displayWidth(cm);
  12328. this.force = force;
  12329. this.dims = getDimensions(cm);
  12330. this.events = [];
  12331. };
  12332. DisplayUpdate.prototype.signal = function (emitter, type) {
  12333. if (hasHandler(emitter, type))
  12334. { this.events.push(arguments); }
  12335. };
  12336. DisplayUpdate.prototype.finish = function () {
  12337. var this$1 = this;
  12338. for (var i = 0; i < this.events.length; i++)
  12339. { signal.apply(null, this$1.events[i]); }
  12340. };
  12341. function maybeClipScrollbars(cm) {
  12342. var display = cm.display;
  12343. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  12344. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  12345. display.heightForcer.style.height = scrollGap(cm) + "px";
  12346. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  12347. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  12348. display.scrollbarsClipped = true;
  12349. }
  12350. }
  12351. function selectionSnapshot(cm) {
  12352. if (cm.hasFocus()) { return null }
  12353. var active = activeElt();
  12354. if (!active || !contains(cm.display.lineDiv, active)) { return null }
  12355. var result = {activeElt: active};
  12356. if (window.getSelection) {
  12357. var sel = window.getSelection();
  12358. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  12359. result.anchorNode = sel.anchorNode;
  12360. result.anchorOffset = sel.anchorOffset;
  12361. result.focusNode = sel.focusNode;
  12362. result.focusOffset = sel.focusOffset;
  12363. }
  12364. }
  12365. return result
  12366. }
  12367. function restoreSelection(snapshot) {
  12368. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
  12369. snapshot.activeElt.focus();
  12370. if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  12371. var sel = window.getSelection(), range$$1 = document.createRange();
  12372. range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  12373. range$$1.collapse(false);
  12374. sel.removeAllRanges();
  12375. sel.addRange(range$$1);
  12376. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  12377. }
  12378. }
  12379. // Does the actual updating of the line display. Bails out
  12380. // (returning false) when there is nothing to be done and forced is
  12381. // false.
  12382. function updateDisplayIfNeeded(cm, update) {
  12383. var display = cm.display, doc = cm.doc;
  12384. if (update.editorIsHidden) {
  12385. resetView(cm);
  12386. return false
  12387. }
  12388. // Bail out if the visible area is already rendered and nothing changed.
  12389. if (!update.force &&
  12390. update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
  12391. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
  12392. display.renderedView == display.view && countDirtyView(cm) == 0)
  12393. { return false }
  12394. if (maybeUpdateLineNumberWidth(cm)) {
  12395. resetView(cm);
  12396. update.dims = getDimensions(cm);
  12397. }
  12398. // Compute a suitable new viewport (from & to)
  12399. var end = doc.first + doc.size;
  12400. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
  12401. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  12402. if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }
  12403. if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }
  12404. if (sawCollapsedSpans) {
  12405. from = visualLineNo(cm.doc, from);
  12406. to = visualLineEndNo(cm.doc, to);
  12407. }
  12408. var different = from != display.viewFrom || to != display.viewTo ||
  12409. display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  12410. adjustView(cm, from, to);
  12411. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
  12412. // Position the mover div to align with the current scroll position
  12413. cm.display.mover.style.top = display.viewOffset + "px";
  12414. var toUpdate = countDirtyView(cm);
  12415. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
  12416. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
  12417. { return false }
  12418. // For big changes, we hide the enclosing element during the
  12419. // update, since that speeds up the operations on most browsers.
  12420. var selSnapshot = selectionSnapshot(cm);
  12421. if (toUpdate > 4) { display.lineDiv.style.display = "none"; }
  12422. patchDisplay(cm, display.updateLineNumbers, update.dims);
  12423. if (toUpdate > 4) { display.lineDiv.style.display = ""; }
  12424. display.renderedView = display.view;
  12425. // There might have been a widget with a focused element that got
  12426. // hidden or updated, if so re-focus it.
  12427. restoreSelection(selSnapshot);
  12428. // Prevent selection and cursors from interfering with the scroll
  12429. // width and height.
  12430. removeChildren(display.cursorDiv);
  12431. removeChildren(display.selectionDiv);
  12432. display.gutters.style.height = display.sizer.style.minHeight = 0;
  12433. if (different) {
  12434. display.lastWrapHeight = update.wrapperHeight;
  12435. display.lastWrapWidth = update.wrapperWidth;
  12436. startWorker(cm, 400);
  12437. }
  12438. display.updateLineNumbers = null;
  12439. return true
  12440. }
  12441. function postUpdateDisplay(cm, update) {
  12442. var viewport = update.viewport;
  12443. for (var first = true;; first = false) {
  12444. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  12445. // Clip forced viewport to actual scrollable area.
  12446. if (viewport && viewport.top != null)
  12447. { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }
  12448. // Updated line heights might result in the drawn area not
  12449. // actually covering the viewport. Keep looping until it does.
  12450. update.visible = visibleLines(cm.display, cm.doc, viewport);
  12451. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
  12452. { break }
  12453. }
  12454. if (!updateDisplayIfNeeded(cm, update)) { break }
  12455. updateHeightsInViewport(cm);
  12456. var barMeasure = measureForScrollbars(cm);
  12457. updateSelection(cm);
  12458. updateScrollbars(cm, barMeasure);
  12459. setDocumentHeight(cm, barMeasure);
  12460. update.force = false;
  12461. }
  12462. update.signal(cm, "update", cm);
  12463. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  12464. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  12465. cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
  12466. }
  12467. }
  12468. function updateDisplaySimple(cm, viewport) {
  12469. var update = new DisplayUpdate(cm, viewport);
  12470. if (updateDisplayIfNeeded(cm, update)) {
  12471. updateHeightsInViewport(cm);
  12472. postUpdateDisplay(cm, update);
  12473. var barMeasure = measureForScrollbars(cm);
  12474. updateSelection(cm);
  12475. updateScrollbars(cm, barMeasure);
  12476. setDocumentHeight(cm, barMeasure);
  12477. update.finish();
  12478. }
  12479. }
  12480. // Sync the actual display DOM structure with display.view, removing
  12481. // nodes for lines that are no longer in view, and creating the ones
  12482. // that are not there yet, and updating the ones that are out of
  12483. // date.
  12484. function patchDisplay(cm, updateNumbersFrom, dims) {
  12485. var display = cm.display, lineNumbers = cm.options.lineNumbers;
  12486. var container = display.lineDiv, cur = container.firstChild;
  12487. function rm(node) {
  12488. var next = node.nextSibling;
  12489. // Works around a throw-scroll bug in OS X Webkit
  12490. if (webkit && mac && cm.display.currentWheelTarget == node)
  12491. { node.style.display = "none"; }
  12492. else
  12493. { node.parentNode.removeChild(node); }
  12494. return next
  12495. }
  12496. var view = display.view, lineN = display.viewFrom;
  12497. // Loop over the elements in the view, syncing cur (the DOM nodes
  12498. // in display.lineDiv) with the view as we go.
  12499. for (var i = 0; i < view.length; i++) {
  12500. var lineView = view[i];
  12501. if (lineView.hidden) {
  12502. } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
  12503. var node = buildLineElement(cm, lineView, lineN, dims);
  12504. container.insertBefore(node, cur);
  12505. } else { // Already drawn
  12506. while (cur != lineView.node) { cur = rm(cur); }
  12507. var updateNumber = lineNumbers && updateNumbersFrom != null &&
  12508. updateNumbersFrom <= lineN && lineView.lineNumber;
  12509. if (lineView.changes) {
  12510. if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
  12511. updateLineForChanges(cm, lineView, lineN, dims);
  12512. }
  12513. if (updateNumber) {
  12514. removeChildren(lineView.lineNumber);
  12515. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  12516. }
  12517. cur = lineView.node.nextSibling;
  12518. }
  12519. lineN += lineView.size;
  12520. }
  12521. while (cur) { cur = rm(cur); }
  12522. }
  12523. function updateGutterSpace(cm) {
  12524. var width = cm.display.gutters.offsetWidth;
  12525. cm.display.sizer.style.marginLeft = width + "px";
  12526. }
  12527. function setDocumentHeight(cm, measure) {
  12528. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  12529. cm.display.heightForcer.style.top = measure.docHeight + "px";
  12530. cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
  12531. }
  12532. // Rebuild the gutter elements, ensure the margin to the left of the
  12533. // code matches their width.
  12534. function updateGutters(cm) {
  12535. var gutters = cm.display.gutters, specs = cm.options.gutters;
  12536. removeChildren(gutters);
  12537. var i = 0;
  12538. for (; i < specs.length; ++i) {
  12539. var gutterClass = specs[i];
  12540. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
  12541. if (gutterClass == "CodeMirror-linenumbers") {
  12542. cm.display.lineGutter = gElt;
  12543. gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
  12544. }
  12545. }
  12546. gutters.style.display = i ? "" : "none";
  12547. updateGutterSpace(cm);
  12548. }
  12549. // Make sure the gutters options contains the element
  12550. // "CodeMirror-linenumbers" when the lineNumbers option is true.
  12551. function setGuttersForLineNumbers(options) {
  12552. var found = indexOf(options.gutters, "CodeMirror-linenumbers");
  12553. if (found == -1 && options.lineNumbers) {
  12554. options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
  12555. } else if (found > -1 && !options.lineNumbers) {
  12556. options.gutters = options.gutters.slice(0);
  12557. options.gutters.splice(found, 1);
  12558. }
  12559. }
  12560. // Since the delta values reported on mouse wheel events are
  12561. // unstandardized between browsers and even browser versions, and
  12562. // generally horribly unpredictable, this code starts by measuring
  12563. // the scroll effect that the first few mouse wheel events have,
  12564. // and, from that, detects the way it can convert deltas to pixel
  12565. // offsets afterwards.
  12566. //
  12567. // The reason we want to know the amount a wheel event will scroll
  12568. // is that it gives us a chance to update the display before the
  12569. // actual scrolling happens, reducing flickering.
  12570. var wheelSamples = 0;
  12571. var wheelPixelsPerUnit = null;
  12572. // Fill in a browser-detected starting value on browsers where we
  12573. // know one. These don't have to be accurate -- the result of them
  12574. // being wrong would just be a slight flicker on the first wheel
  12575. // scroll (if it is large enough).
  12576. if (ie) { wheelPixelsPerUnit = -.53; }
  12577. else if (gecko) { wheelPixelsPerUnit = 15; }
  12578. else if (chrome) { wheelPixelsPerUnit = -.7; }
  12579. else if (safari) { wheelPixelsPerUnit = -1/3; }
  12580. function wheelEventDelta(e) {
  12581. var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
  12582. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }
  12583. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }
  12584. else if (dy == null) { dy = e.wheelDelta; }
  12585. return {x: dx, y: dy}
  12586. }
  12587. function wheelEventPixels(e) {
  12588. var delta = wheelEventDelta(e);
  12589. delta.x *= wheelPixelsPerUnit;
  12590. delta.y *= wheelPixelsPerUnit;
  12591. return delta
  12592. }
  12593. function onScrollWheel(cm, e) {
  12594. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
  12595. var display = cm.display, scroll = display.scroller;
  12596. // Quit if there's nothing to scroll here
  12597. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  12598. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  12599. if (!(dx && canScrollX || dy && canScrollY)) { return }
  12600. // Webkit browsers on OS X abort momentum scrolls when the target
  12601. // of the scroll event is removed from the scrollable element.
  12602. // This hack (see related code in patchDisplay) makes sure the
  12603. // element is kept around.
  12604. if (dy && mac && webkit) {
  12605. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  12606. for (var i = 0; i < view.length; i++) {
  12607. if (view[i].node == cur) {
  12608. cm.display.currentWheelTarget = cur;
  12609. break outer
  12610. }
  12611. }
  12612. }
  12613. }
  12614. // On some browsers, horizontal scrolling will cause redraws to
  12615. // happen before the gutter has been realigned, causing it to
  12616. // wriggle around in a most unseemly way. When we have an
  12617. // estimated pixels/delta value, we just handle horizontal
  12618. // scrolling entirely here. It'll be slightly off from native, but
  12619. // better than glitching out.
  12620. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  12621. if (dy && canScrollY)
  12622. { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
  12623. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
  12624. // Only prevent default scrolling if vertical scrolling is
  12625. // actually possible. Otherwise, it causes vertical scroll
  12626. // jitter on OSX trackpads when deltaX is small and deltaY
  12627. // is large (issue #3579)
  12628. if (!dy || (dy && canScrollY))
  12629. { e_preventDefault(e); }
  12630. display.wheelStartX = null; // Abort measurement, if in progress
  12631. return
  12632. }
  12633. // 'Project' the visible viewport to cover the area that is being
  12634. // scrolled into view (if we know enough to estimate it).
  12635. if (dy && wheelPixelsPerUnit != null) {
  12636. var pixels = dy * wheelPixelsPerUnit;
  12637. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
  12638. if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
  12639. else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
  12640. updateDisplaySimple(cm, {top: top, bottom: bot});
  12641. }
  12642. if (wheelSamples < 20) {
  12643. if (display.wheelStartX == null) {
  12644. display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
  12645. display.wheelDX = dx; display.wheelDY = dy;
  12646. setTimeout(function () {
  12647. if (display.wheelStartX == null) { return }
  12648. var movedX = scroll.scrollLeft - display.wheelStartX;
  12649. var movedY = scroll.scrollTop - display.wheelStartY;
  12650. var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
  12651. (movedX && display.wheelDX && movedX / display.wheelDX);
  12652. display.wheelStartX = display.wheelStartY = null;
  12653. if (!sample) { return }
  12654. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  12655. ++wheelSamples;
  12656. }, 200);
  12657. } else {
  12658. display.wheelDX += dx; display.wheelDY += dy;
  12659. }
  12660. }
  12661. }
  12662. // Selection objects are immutable. A new one is created every time
  12663. // the selection changes. A selection is one or more non-overlapping
  12664. // (and non-touching) ranges, sorted, and an integer that indicates
  12665. // which one is the primary selection (the one that's scrolled into
  12666. // view, that getCursor returns, etc).
  12667. var Selection = function(ranges, primIndex) {
  12668. this.ranges = ranges;
  12669. this.primIndex = primIndex;
  12670. };
  12671. Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
  12672. Selection.prototype.equals = function (other) {
  12673. var this$1 = this;
  12674. if (other == this) { return true }
  12675. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
  12676. for (var i = 0; i < this.ranges.length; i++) {
  12677. var here = this$1.ranges[i], there = other.ranges[i];
  12678. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
  12679. }
  12680. return true
  12681. };
  12682. Selection.prototype.deepCopy = function () {
  12683. var this$1 = this;
  12684. var out = [];
  12685. for (var i = 0; i < this.ranges.length; i++)
  12686. { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)); }
  12687. return new Selection(out, this.primIndex)
  12688. };
  12689. Selection.prototype.somethingSelected = function () {
  12690. var this$1 = this;
  12691. for (var i = 0; i < this.ranges.length; i++)
  12692. { if (!this$1.ranges[i].empty()) { return true } }
  12693. return false
  12694. };
  12695. Selection.prototype.contains = function (pos, end) {
  12696. var this$1 = this;
  12697. if (!end) { end = pos; }
  12698. for (var i = 0; i < this.ranges.length; i++) {
  12699. var range = this$1.ranges[i];
  12700. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
  12701. { return i }
  12702. }
  12703. return -1
  12704. };
  12705. var Range = function(anchor, head) {
  12706. this.anchor = anchor; this.head = head;
  12707. };
  12708. Range.prototype.from = function () { return minPos(this.anchor, this.head) };
  12709. Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
  12710. Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
  12711. // Take an unsorted, potentially overlapping set of ranges, and
  12712. // build a selection out of it. 'Consumes' ranges array (modifying
  12713. // it).
  12714. function normalizeSelection(ranges, primIndex) {
  12715. var prim = ranges[primIndex];
  12716. ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });
  12717. primIndex = indexOf(ranges, prim);
  12718. for (var i = 1; i < ranges.length; i++) {
  12719. var cur = ranges[i], prev = ranges[i - 1];
  12720. if (cmp(prev.to(), cur.from()) >= 0) {
  12721. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
  12722. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  12723. if (i <= primIndex) { --primIndex; }
  12724. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
  12725. }
  12726. }
  12727. return new Selection(ranges, primIndex)
  12728. }
  12729. function simpleSelection(anchor, head) {
  12730. return new Selection([new Range(anchor, head || anchor)], 0)
  12731. }
  12732. // Compute the position of the end of a change (its 'to' property
  12733. // refers to the pre-change end).
  12734. function changeEnd(change) {
  12735. if (!change.text) { return change.to }
  12736. return Pos(change.from.line + change.text.length - 1,
  12737. lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
  12738. }
  12739. // Adjust a position to refer to the post-change position of the
  12740. // same text, or the end of the change if the change covers it.
  12741. function adjustForChange(pos, change) {
  12742. if (cmp(pos, change.from) < 0) { return pos }
  12743. if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
  12744. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
  12745. if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
  12746. return Pos(line, ch)
  12747. }
  12748. function computeSelAfterChange(doc, change) {
  12749. var out = [];
  12750. for (var i = 0; i < doc.sel.ranges.length; i++) {
  12751. var range = doc.sel.ranges[i];
  12752. out.push(new Range(adjustForChange(range.anchor, change),
  12753. adjustForChange(range.head, change)));
  12754. }
  12755. return normalizeSelection(out, doc.sel.primIndex)
  12756. }
  12757. function offsetPos(pos, old, nw) {
  12758. if (pos.line == old.line)
  12759. { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
  12760. else
  12761. { return Pos(nw.line + (pos.line - old.line), pos.ch) }
  12762. }
  12763. // Used by replaceSelections to allow moving the selection to the
  12764. // start or around the replaced test. Hint may be "start" or "around".
  12765. function computeReplacedSel(doc, changes, hint) {
  12766. var out = [];
  12767. var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
  12768. for (var i = 0; i < changes.length; i++) {
  12769. var change = changes[i];
  12770. var from = offsetPos(change.from, oldPrev, newPrev);
  12771. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  12772. oldPrev = change.to;
  12773. newPrev = to;
  12774. if (hint == "around") {
  12775. var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
  12776. out[i] = new Range(inv ? to : from, inv ? from : to);
  12777. } else {
  12778. out[i] = new Range(from, from);
  12779. }
  12780. }
  12781. return new Selection(out, doc.sel.primIndex)
  12782. }
  12783. // Used to get the editor into a consistent state again when options change.
  12784. function loadMode(cm) {
  12785. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  12786. resetModeState(cm);
  12787. }
  12788. function resetModeState(cm) {
  12789. cm.doc.iter(function (line) {
  12790. if (line.stateAfter) { line.stateAfter = null; }
  12791. if (line.styles) { line.styles = null; }
  12792. });
  12793. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  12794. startWorker(cm, 100);
  12795. cm.state.modeGen++;
  12796. if (cm.curOp) { regChange(cm); }
  12797. }
  12798. // DOCUMENT DATA STRUCTURE
  12799. // By default, updates that start and end at the beginning of a line
  12800. // are treated specially, in order to make the association of line
  12801. // widgets and marker elements with the text behave more intuitive.
  12802. function isWholeLineUpdate(doc, change) {
  12803. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
  12804. (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
  12805. }
  12806. // Perform a change on the document data structure.
  12807. function updateDoc(doc, change, markedSpans, estimateHeight$$1) {
  12808. function spansFor(n) {return markedSpans ? markedSpans[n] : null}
  12809. function update(line, text, spans) {
  12810. updateLine(line, text, spans, estimateHeight$$1);
  12811. signalLater(line, "change", line, change);
  12812. }
  12813. function linesFor(start, end) {
  12814. var result = [];
  12815. for (var i = start; i < end; ++i)
  12816. { result.push(new Line(text[i], spansFor(i), estimateHeight$$1)); }
  12817. return result
  12818. }
  12819. var from = change.from, to = change.to, text = change.text;
  12820. var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
  12821. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
  12822. // Adjust the line structure
  12823. if (change.full) {
  12824. doc.insert(0, linesFor(0, text.length));
  12825. doc.remove(text.length, doc.size - text.length);
  12826. } else if (isWholeLineUpdate(doc, change)) {
  12827. // This is a whole-line replace. Treated specially to make
  12828. // sure line objects move the way they are supposed to.
  12829. var added = linesFor(0, text.length - 1);
  12830. update(lastLine, lastLine.text, lastSpans);
  12831. if (nlines) { doc.remove(from.line, nlines); }
  12832. if (added.length) { doc.insert(from.line, added); }
  12833. } else if (firstLine == lastLine) {
  12834. if (text.length == 1) {
  12835. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  12836. } else {
  12837. var added$1 = linesFor(1, text.length - 1);
  12838. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));
  12839. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  12840. doc.insert(from.line + 1, added$1);
  12841. }
  12842. } else if (text.length == 1) {
  12843. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  12844. doc.remove(from.line + 1, nlines);
  12845. } else {
  12846. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  12847. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  12848. var added$2 = linesFor(1, text.length - 1);
  12849. if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }
  12850. doc.insert(from.line + 1, added$2);
  12851. }
  12852. signalLater(doc, "change", doc, change);
  12853. }
  12854. // Call f for all linked documents.
  12855. function linkedDocs(doc, f, sharedHistOnly) {
  12856. function propagate(doc, skip, sharedHist) {
  12857. if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
  12858. var rel = doc.linked[i];
  12859. if (rel.doc == skip) { continue }
  12860. var shared = sharedHist && rel.sharedHist;
  12861. if (sharedHistOnly && !shared) { continue }
  12862. f(rel.doc, shared);
  12863. propagate(rel.doc, doc, shared);
  12864. } }
  12865. }
  12866. propagate(doc, null, true);
  12867. }
  12868. // Attach a document to an editor.
  12869. function attachDoc(cm, doc) {
  12870. if (doc.cm) { throw new Error("This document is already in use.") }
  12871. cm.doc = doc;
  12872. doc.cm = cm;
  12873. estimateLineHeights(cm);
  12874. loadMode(cm);
  12875. setDirectionClass(cm);
  12876. if (!cm.options.lineWrapping) { findMaxLine(cm); }
  12877. cm.options.mode = doc.modeOption;
  12878. regChange(cm);
  12879. }
  12880. function setDirectionClass(cm) {
  12881. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  12882. }
  12883. function directionChanged(cm) {
  12884. runInOp(cm, function () {
  12885. setDirectionClass(cm);
  12886. regChange(cm);
  12887. });
  12888. }
  12889. function History(startGen) {
  12890. // Arrays of change events and selections. Doing something adds an
  12891. // event to done and clears undo. Undoing moves events from done
  12892. // to undone, redoing moves them in the other direction.
  12893. this.done = []; this.undone = [];
  12894. this.undoDepth = Infinity;
  12895. // Used to track when changes can be merged into a single undo
  12896. // event
  12897. this.lastModTime = this.lastSelTime = 0;
  12898. this.lastOp = this.lastSelOp = null;
  12899. this.lastOrigin = this.lastSelOrigin = null;
  12900. // Used by the isClean() method
  12901. this.generation = this.maxGeneration = startGen || 1;
  12902. }
  12903. // Create a history change event from an updateDoc-style change
  12904. // object.
  12905. function historyChangeFromChange(doc, change) {
  12906. var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
  12907. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  12908. linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);
  12909. return histChange
  12910. }
  12911. // Pop all selection events off the end of a history array. Stop at
  12912. // a change event.
  12913. function clearSelectionEvents(array) {
  12914. while (array.length) {
  12915. var last = lst(array);
  12916. if (last.ranges) { array.pop(); }
  12917. else { break }
  12918. }
  12919. }
  12920. // Find the top change event in the history. Pop off selection
  12921. // events that are in the way.
  12922. function lastChangeEvent(hist, force) {
  12923. if (force) {
  12924. clearSelectionEvents(hist.done);
  12925. return lst(hist.done)
  12926. } else if (hist.done.length && !lst(hist.done).ranges) {
  12927. return lst(hist.done)
  12928. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  12929. hist.done.pop();
  12930. return lst(hist.done)
  12931. }
  12932. }
  12933. // Register a change in the history. Merges changes that are within
  12934. // a single operation, or are close together with an origin that
  12935. // allows merging (starting with "+") into a single event.
  12936. function addChangeToHistory(doc, change, selAfter, opId) {
  12937. var hist = doc.history;
  12938. hist.undone.length = 0;
  12939. var time = +new Date, cur;
  12940. var last;
  12941. if ((hist.lastOp == opId ||
  12942. hist.lastOrigin == change.origin && change.origin &&
  12943. ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
  12944. change.origin.charAt(0) == "*")) &&
  12945. (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  12946. // Merge this change into the last event
  12947. last = lst(cur.changes);
  12948. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  12949. // Optimized case for simple insertion -- don't want to add
  12950. // new changesets for every character typed
  12951. last.to = changeEnd(change);
  12952. } else {
  12953. // Add new sub-event
  12954. cur.changes.push(historyChangeFromChange(doc, change));
  12955. }
  12956. } else {
  12957. // Can not be merged, start a new event.
  12958. var before = lst(hist.done);
  12959. if (!before || !before.ranges)
  12960. { pushSelectionToHistory(doc.sel, hist.done); }
  12961. cur = {changes: [historyChangeFromChange(doc, change)],
  12962. generation: hist.generation};
  12963. hist.done.push(cur);
  12964. while (hist.done.length > hist.undoDepth) {
  12965. hist.done.shift();
  12966. if (!hist.done[0].ranges) { hist.done.shift(); }
  12967. }
  12968. }
  12969. hist.done.push(selAfter);
  12970. hist.generation = ++hist.maxGeneration;
  12971. hist.lastModTime = hist.lastSelTime = time;
  12972. hist.lastOp = hist.lastSelOp = opId;
  12973. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  12974. if (!last) { signal(doc, "historyAdded"); }
  12975. }
  12976. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  12977. var ch = origin.charAt(0);
  12978. return ch == "*" ||
  12979. ch == "+" &&
  12980. prev.ranges.length == sel.ranges.length &&
  12981. prev.somethingSelected() == sel.somethingSelected() &&
  12982. new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
  12983. }
  12984. // Called whenever the selection changes, sets the new selection as
  12985. // the pending selection in the history, and pushes the old pending
  12986. // selection into the 'done' array when it was significantly
  12987. // different (in number of selected ranges, emptiness, or time).
  12988. function addSelectionToHistory(doc, sel, opId, options) {
  12989. var hist = doc.history, origin = options && options.origin;
  12990. // A new event is started when the previous origin does not match
  12991. // the current, or the origins don't allow matching. Origins
  12992. // starting with * are always merged, those starting with + are
  12993. // merged when similar and close together in time.
  12994. if (opId == hist.lastSelOp ||
  12995. (origin && hist.lastSelOrigin == origin &&
  12996. (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
  12997. selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
  12998. { hist.done[hist.done.length - 1] = sel; }
  12999. else
  13000. { pushSelectionToHistory(sel, hist.done); }
  13001. hist.lastSelTime = +new Date;
  13002. hist.lastSelOrigin = origin;
  13003. hist.lastSelOp = opId;
  13004. if (options && options.clearRedo !== false)
  13005. { clearSelectionEvents(hist.undone); }
  13006. }
  13007. function pushSelectionToHistory(sel, dest) {
  13008. var top = lst(dest);
  13009. if (!(top && top.ranges && top.equals(sel)))
  13010. { dest.push(sel); }
  13011. }
  13012. // Used to store marked span information in the history.
  13013. function attachLocalSpans(doc, change, from, to) {
  13014. var existing = change["spans_" + doc.id], n = 0;
  13015. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  13016. if (line.markedSpans)
  13017. { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; }
  13018. ++n;
  13019. });
  13020. }
  13021. // When un/re-doing restores text containing marked spans, those
  13022. // that have been explicitly cleared should not be restored.
  13023. function removeClearedSpans(spans) {
  13024. if (!spans) { return null }
  13025. var out;
  13026. for (var i = 0; i < spans.length; ++i) {
  13027. if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }
  13028. else if (out) { out.push(spans[i]); }
  13029. }
  13030. return !out ? spans : out.length ? out : null
  13031. }
  13032. // Retrieve and filter the old marked spans stored in a change event.
  13033. function getOldSpans(doc, change) {
  13034. var found = change["spans_" + doc.id];
  13035. if (!found) { return null }
  13036. var nw = [];
  13037. for (var i = 0; i < change.text.length; ++i)
  13038. { nw.push(removeClearedSpans(found[i])); }
  13039. return nw
  13040. }
  13041. // Used for un/re-doing changes from the history. Combines the
  13042. // result of computing the existing spans with the set of spans that
  13043. // existed in the history (so that deleting around a span and then
  13044. // undoing brings back the span).
  13045. function mergeOldSpans(doc, change) {
  13046. var old = getOldSpans(doc, change);
  13047. var stretched = stretchSpansOverChange(doc, change);
  13048. if (!old) { return stretched }
  13049. if (!stretched) { return old }
  13050. for (var i = 0; i < old.length; ++i) {
  13051. var oldCur = old[i], stretchCur = stretched[i];
  13052. if (oldCur && stretchCur) {
  13053. spans: for (var j = 0; j < stretchCur.length; ++j) {
  13054. var span = stretchCur[j];
  13055. for (var k = 0; k < oldCur.length; ++k)
  13056. { if (oldCur[k].marker == span.marker) { continue spans } }
  13057. oldCur.push(span);
  13058. }
  13059. } else if (stretchCur) {
  13060. old[i] = stretchCur;
  13061. }
  13062. }
  13063. return old
  13064. }
  13065. // Used both to provide a JSON-safe object in .getHistory, and, when
  13066. // detaching a document, to split the history in two
  13067. function copyHistoryArray(events, newGroup, instantiateSel) {
  13068. var copy = [];
  13069. for (var i = 0; i < events.length; ++i) {
  13070. var event = events[i];
  13071. if (event.ranges) {
  13072. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  13073. continue
  13074. }
  13075. var changes = event.changes, newChanges = [];
  13076. copy.push({changes: newChanges});
  13077. for (var j = 0; j < changes.length; ++j) {
  13078. var change = changes[j], m = (void 0);
  13079. newChanges.push({from: change.from, to: change.to, text: change.text});
  13080. if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
  13081. if (indexOf(newGroup, Number(m[1])) > -1) {
  13082. lst(newChanges)[prop] = change[prop];
  13083. delete change[prop];
  13084. }
  13085. } } }
  13086. }
  13087. }
  13088. return copy
  13089. }
  13090. // The 'scroll' parameter given to many of these indicated whether
  13091. // the new cursor position should be scrolled into view after
  13092. // modifying the selection.
  13093. // If shift is held or the extend flag is set, extends a range to
  13094. // include a given position (and optionally a second position).
  13095. // Otherwise, simply returns the range between the given positions.
  13096. // Used for cursor motion and such.
  13097. function extendRange(range, head, other, extend) {
  13098. if (extend) {
  13099. var anchor = range.anchor;
  13100. if (other) {
  13101. var posBefore = cmp(head, anchor) < 0;
  13102. if (posBefore != (cmp(other, anchor) < 0)) {
  13103. anchor = head;
  13104. head = other;
  13105. } else if (posBefore != (cmp(head, other) < 0)) {
  13106. head = other;
  13107. }
  13108. }
  13109. return new Range(anchor, head)
  13110. } else {
  13111. return new Range(other || head, head)
  13112. }
  13113. }
  13114. // Extend the primary selection range, discard the rest.
  13115. function extendSelection(doc, head, other, options, extend) {
  13116. if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }
  13117. setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
  13118. }
  13119. // Extend all selections (pos is an array of selections with length
  13120. // equal the number of selections)
  13121. function extendSelections(doc, heads, options) {
  13122. var out = [];
  13123. var extend = doc.cm && (doc.cm.display.shift || doc.extend);
  13124. for (var i = 0; i < doc.sel.ranges.length; i++)
  13125. { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }
  13126. var newSel = normalizeSelection(out, doc.sel.primIndex);
  13127. setSelection(doc, newSel, options);
  13128. }
  13129. // Updates a single range in the selection.
  13130. function replaceOneSelection(doc, i, range, options) {
  13131. var ranges = doc.sel.ranges.slice(0);
  13132. ranges[i] = range;
  13133. setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
  13134. }
  13135. // Reset the selection to a single range.
  13136. function setSimpleSelection(doc, anchor, head, options) {
  13137. setSelection(doc, simpleSelection(anchor, head), options);
  13138. }
  13139. // Give beforeSelectionChange handlers a change to influence a
  13140. // selection update.
  13141. function filterSelectionChange(doc, sel, options) {
  13142. var obj = {
  13143. ranges: sel.ranges,
  13144. update: function(ranges) {
  13145. var this$1 = this;
  13146. this.ranges = [];
  13147. for (var i = 0; i < ranges.length; i++)
  13148. { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
  13149. clipPos(doc, ranges[i].head)); }
  13150. },
  13151. origin: options && options.origin
  13152. };
  13153. signal(doc, "beforeSelectionChange", doc, obj);
  13154. if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); }
  13155. if (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }
  13156. else { return sel }
  13157. }
  13158. function setSelectionReplaceHistory(doc, sel, options) {
  13159. var done = doc.history.done, last = lst(done);
  13160. if (last && last.ranges) {
  13161. done[done.length - 1] = sel;
  13162. setSelectionNoUndo(doc, sel, options);
  13163. } else {
  13164. setSelection(doc, sel, options);
  13165. }
  13166. }
  13167. // Set a new selection.
  13168. function setSelection(doc, sel, options) {
  13169. setSelectionNoUndo(doc, sel, options);
  13170. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
  13171. }
  13172. function setSelectionNoUndo(doc, sel, options) {
  13173. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
  13174. { sel = filterSelectionChange(doc, sel, options); }
  13175. var bias = options && options.bias ||
  13176. (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
  13177. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
  13178. if (!(options && options.scroll === false) && doc.cm)
  13179. { ensureCursorVisible(doc.cm); }
  13180. }
  13181. function setSelectionInner(doc, sel) {
  13182. if (sel.equals(doc.sel)) { return }
  13183. doc.sel = sel;
  13184. if (doc.cm) {
  13185. doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
  13186. signalCursorActivity(doc.cm);
  13187. }
  13188. signalLater(doc, "cursorActivity", doc);
  13189. }
  13190. // Verify that the selection does not partially select any atomic
  13191. // marked ranges.
  13192. function reCheckSelection(doc) {
  13193. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
  13194. }
  13195. // Return a selection that does not partially select any atomic
  13196. // ranges.
  13197. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  13198. var out;
  13199. for (var i = 0; i < sel.ranges.length; i++) {
  13200. var range = sel.ranges[i];
  13201. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
  13202. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
  13203. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
  13204. if (out || newAnchor != range.anchor || newHead != range.head) {
  13205. if (!out) { out = sel.ranges.slice(0, i); }
  13206. out[i] = new Range(newAnchor, newHead);
  13207. }
  13208. }
  13209. return out ? normalizeSelection(out, sel.primIndex) : sel
  13210. }
  13211. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  13212. var line = getLine(doc, pos.line);
  13213. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  13214. var sp = line.markedSpans[i], m = sp.marker;
  13215. if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
  13216. (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  13217. if (mayClear) {
  13218. signal(m, "beforeCursorEnter");
  13219. if (m.explicitlyCleared) {
  13220. if (!line.markedSpans) { break }
  13221. else {--i; continue}
  13222. }
  13223. }
  13224. if (!m.atomic) { continue }
  13225. if (oldPos) {
  13226. var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
  13227. if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
  13228. { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
  13229. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
  13230. { return skipAtomicInner(doc, near, pos, dir, mayClear) }
  13231. }
  13232. var far = m.find(dir < 0 ? -1 : 1);
  13233. if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
  13234. { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
  13235. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
  13236. }
  13237. } }
  13238. return pos
  13239. }
  13240. // Ensure a given position is not inside an atomic range.
  13241. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  13242. var dir = bias || 1;
  13243. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
  13244. (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
  13245. skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
  13246. (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
  13247. if (!found) {
  13248. doc.cantEdit = true;
  13249. return Pos(doc.first, 0)
  13250. }
  13251. return found
  13252. }
  13253. function movePos(doc, pos, dir, line) {
  13254. if (dir < 0 && pos.ch == 0) {
  13255. if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
  13256. else { return null }
  13257. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  13258. if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
  13259. else { return null }
  13260. } else {
  13261. return new Pos(pos.line, pos.ch + dir)
  13262. }
  13263. }
  13264. function selectAll(cm) {
  13265. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  13266. }
  13267. // UPDATING
  13268. // Allow "beforeChange" event handlers to influence a change
  13269. function filterChange(doc, change, update) {
  13270. var obj = {
  13271. canceled: false,
  13272. from: change.from,
  13273. to: change.to,
  13274. text: change.text,
  13275. origin: change.origin,
  13276. cancel: function () { return obj.canceled = true; }
  13277. };
  13278. if (update) { obj.update = function (from, to, text, origin) {
  13279. if (from) { obj.from = clipPos(doc, from); }
  13280. if (to) { obj.to = clipPos(doc, to); }
  13281. if (text) { obj.text = text; }
  13282. if (origin !== undefined) { obj.origin = origin; }
  13283. }; }
  13284. signal(doc, "beforeChange", doc, obj);
  13285. if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
  13286. if (obj.canceled) { return null }
  13287. return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
  13288. }
  13289. // Apply a change to a document, and add it to the document's
  13290. // history, and propagating it to all linked documents.
  13291. function makeChange(doc, change, ignoreReadOnly) {
  13292. if (doc.cm) {
  13293. if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
  13294. if (doc.cm.state.suppressEdits) { return }
  13295. }
  13296. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  13297. change = filterChange(doc, change, true);
  13298. if (!change) { return }
  13299. }
  13300. // Possibly split or suppress the update based on the presence
  13301. // of read-only spans in its range.
  13302. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
  13303. if (split) {
  13304. for (var i = split.length - 1; i >= 0; --i)
  13305. { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); }
  13306. } else {
  13307. makeChangeInner(doc, change);
  13308. }
  13309. }
  13310. function makeChangeInner(doc, change) {
  13311. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
  13312. var selAfter = computeSelAfterChange(doc, change);
  13313. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
  13314. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
  13315. var rebased = [];
  13316. linkedDocs(doc, function (doc, sharedHist) {
  13317. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  13318. rebaseHist(doc.history, change);
  13319. rebased.push(doc.history);
  13320. }
  13321. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
  13322. });
  13323. }
  13324. // Revert a change stored in a document's history.
  13325. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  13326. var suppress = doc.cm && doc.cm.state.suppressEdits;
  13327. if (suppress && !allowSelectionOnly) { return }
  13328. var hist = doc.history, event, selAfter = doc.sel;
  13329. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
  13330. // Verify that there is a useable event (so that ctrl-z won't
  13331. // needlessly clear selection events)
  13332. var i = 0;
  13333. for (; i < source.length; i++) {
  13334. event = source[i];
  13335. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
  13336. { break }
  13337. }
  13338. if (i == source.length) { return }
  13339. hist.lastOrigin = hist.lastSelOrigin = null;
  13340. for (;;) {
  13341. event = source.pop();
  13342. if (event.ranges) {
  13343. pushSelectionToHistory(event, dest);
  13344. if (allowSelectionOnly && !event.equals(doc.sel)) {
  13345. setSelection(doc, event, {clearRedo: false});
  13346. return
  13347. }
  13348. selAfter = event;
  13349. } else if (suppress) {
  13350. source.push(event);
  13351. return
  13352. } else { break }
  13353. }
  13354. // Build up a reverse change object to add to the opposite history
  13355. // stack (redo when undoing, and vice versa).
  13356. var antiChanges = [];
  13357. pushSelectionToHistory(selAfter, dest);
  13358. dest.push({changes: antiChanges, generation: hist.generation});
  13359. hist.generation = event.generation || ++hist.maxGeneration;
  13360. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
  13361. var loop = function ( i ) {
  13362. var change = event.changes[i];
  13363. change.origin = type;
  13364. if (filter && !filterChange(doc, change, false)) {
  13365. source.length = 0;
  13366. return {}
  13367. }
  13368. antiChanges.push(historyChangeFromChange(doc, change));
  13369. var after = i ? computeSelAfterChange(doc, change) : lst(source);
  13370. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
  13371. if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }
  13372. var rebased = [];
  13373. // Propagate to the linked documents
  13374. linkedDocs(doc, function (doc, sharedHist) {
  13375. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  13376. rebaseHist(doc.history, change);
  13377. rebased.push(doc.history);
  13378. }
  13379. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
  13380. });
  13381. };
  13382. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  13383. var returned = loop( i$1 );
  13384. if ( returned ) return returned.v;
  13385. }
  13386. }
  13387. // Sub-views need their line numbers shifted when text is added
  13388. // above or below them in the parent document.
  13389. function shiftDoc(doc, distance) {
  13390. if (distance == 0) { return }
  13391. doc.first += distance;
  13392. doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
  13393. Pos(range.anchor.line + distance, range.anchor.ch),
  13394. Pos(range.head.line + distance, range.head.ch)
  13395. ); }), doc.sel.primIndex);
  13396. if (doc.cm) {
  13397. regChange(doc.cm, doc.first, doc.first - distance, distance);
  13398. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
  13399. { regLineChange(doc.cm, l, "gutter"); }
  13400. }
  13401. }
  13402. // More lower-level change function, handling only a single document
  13403. // (not linked ones).
  13404. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  13405. if (doc.cm && !doc.cm.curOp)
  13406. { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
  13407. if (change.to.line < doc.first) {
  13408. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
  13409. return
  13410. }
  13411. if (change.from.line > doc.lastLine()) { return }
  13412. // Clip the change to the size of this doc
  13413. if (change.from.line < doc.first) {
  13414. var shift = change.text.length - 1 - (doc.first - change.from.line);
  13415. shiftDoc(doc, shift);
  13416. change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  13417. text: [lst(change.text)], origin: change.origin};
  13418. }
  13419. var last = doc.lastLine();
  13420. if (change.to.line > last) {
  13421. change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
  13422. text: [change.text[0]], origin: change.origin};
  13423. }
  13424. change.removed = getBetween(doc, change.from, change.to);
  13425. if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
  13426. if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
  13427. else { updateDoc(doc, change, spans); }
  13428. setSelectionNoUndo(doc, selAfter, sel_dontScroll);
  13429. }
  13430. // Handle the interaction of a change to a document with the editor
  13431. // that this document is part of.
  13432. function makeChangeSingleDocInEditor(cm, change, spans) {
  13433. var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
  13434. var recomputeMaxLength = false, checkWidthStart = from.line;
  13435. if (!cm.options.lineWrapping) {
  13436. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
  13437. doc.iter(checkWidthStart, to.line + 1, function (line) {
  13438. if (line == display.maxLine) {
  13439. recomputeMaxLength = true;
  13440. return true
  13441. }
  13442. });
  13443. }
  13444. if (doc.sel.contains(change.from, change.to) > -1)
  13445. { signalCursorActivity(cm); }
  13446. updateDoc(doc, change, spans, estimateHeight(cm));
  13447. if (!cm.options.lineWrapping) {
  13448. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  13449. var len = lineLength(line);
  13450. if (len > display.maxLineLength) {
  13451. display.maxLine = line;
  13452. display.maxLineLength = len;
  13453. display.maxLineChanged = true;
  13454. recomputeMaxLength = false;
  13455. }
  13456. });
  13457. if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }
  13458. }
  13459. retreatFrontier(doc, from.line);
  13460. startWorker(cm, 400);
  13461. var lendiff = change.text.length - (to.line - from.line) - 1;
  13462. // Remember that these lines changed, for updating the display
  13463. if (change.full)
  13464. { regChange(cm); }
  13465. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
  13466. { regLineChange(cm, from.line, "text"); }
  13467. else
  13468. { regChange(cm, from.line, to.line + 1, lendiff); }
  13469. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
  13470. if (changeHandler || changesHandler) {
  13471. var obj = {
  13472. from: from, to: to,
  13473. text: change.text,
  13474. removed: change.removed,
  13475. origin: change.origin
  13476. };
  13477. if (changeHandler) { signalLater(cm, "change", cm, obj); }
  13478. if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }
  13479. }
  13480. cm.display.selForContextMenu = null;
  13481. }
  13482. function replaceRange(doc, code, from, to, origin) {
  13483. if (!to) { to = from; }
  13484. if (cmp(to, from) < 0) { var assign;
  13485. (assign = [to, from], from = assign[0], to = assign[1]); }
  13486. if (typeof code == "string") { code = doc.splitLines(code); }
  13487. makeChange(doc, {from: from, to: to, text: code, origin: origin});
  13488. }
  13489. // Rebasing/resetting history to deal with externally-sourced changes
  13490. function rebaseHistSelSingle(pos, from, to, diff) {
  13491. if (to < pos.line) {
  13492. pos.line += diff;
  13493. } else if (from < pos.line) {
  13494. pos.line = from;
  13495. pos.ch = 0;
  13496. }
  13497. }
  13498. // Tries to rebase an array of history events given a change in the
  13499. // document. If the change touches the same lines as the event, the
  13500. // event, and everything 'behind' it, is discarded. If the change is
  13501. // before the event, the event's positions are updated. Uses a
  13502. // copy-on-write scheme for the positions, to avoid having to
  13503. // reallocate them all on every rebase, but also avoid problems with
  13504. // shared position objects being unsafely updated.
  13505. function rebaseHistArray(array, from, to, diff) {
  13506. for (var i = 0; i < array.length; ++i) {
  13507. var sub = array[i], ok = true;
  13508. if (sub.ranges) {
  13509. if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
  13510. for (var j = 0; j < sub.ranges.length; j++) {
  13511. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  13512. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  13513. }
  13514. continue
  13515. }
  13516. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  13517. var cur = sub.changes[j$1];
  13518. if (to < cur.from.line) {
  13519. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  13520. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  13521. } else if (from <= cur.to.line) {
  13522. ok = false;
  13523. break
  13524. }
  13525. }
  13526. if (!ok) {
  13527. array.splice(0, i + 1);
  13528. i = 0;
  13529. }
  13530. }
  13531. }
  13532. function rebaseHist(hist, change) {
  13533. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
  13534. rebaseHistArray(hist.done, from, to, diff);
  13535. rebaseHistArray(hist.undone, from, to, diff);
  13536. }
  13537. // Utility for applying a change to a line by handle or number,
  13538. // returning the number and optionally registering the line as
  13539. // changed.
  13540. function changeLine(doc, handle, changeType, op) {
  13541. var no = handle, line = handle;
  13542. if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); }
  13543. else { no = lineNo(handle); }
  13544. if (no == null) { return null }
  13545. if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }
  13546. return line
  13547. }
  13548. // The document is represented as a BTree consisting of leaves, with
  13549. // chunk of lines in them, and branches, with up to ten leaves or
  13550. // other branch nodes below them. The top node is always a branch
  13551. // node, and is the document object itself (meaning it has
  13552. // additional methods and properties).
  13553. //
  13554. // All nodes have parent links. The tree is used both to go from
  13555. // line numbers to line objects, and to go from objects to numbers.
  13556. // It also indexes by height, and is used to convert between height
  13557. // and line object, and to find the total height of the document.
  13558. //
  13559. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  13560. function LeafChunk(lines) {
  13561. var this$1 = this;
  13562. this.lines = lines;
  13563. this.parent = null;
  13564. var height = 0;
  13565. for (var i = 0; i < lines.length; ++i) {
  13566. lines[i].parent = this$1;
  13567. height += lines[i].height;
  13568. }
  13569. this.height = height;
  13570. }
  13571. LeafChunk.prototype = {
  13572. chunkSize: function() { return this.lines.length },
  13573. // Remove the n lines at offset 'at'.
  13574. removeInner: function(at, n) {
  13575. var this$1 = this;
  13576. for (var i = at, e = at + n; i < e; ++i) {
  13577. var line = this$1.lines[i];
  13578. this$1.height -= line.height;
  13579. cleanUpLine(line);
  13580. signalLater(line, "delete");
  13581. }
  13582. this.lines.splice(at, n);
  13583. },
  13584. // Helper used to collapse a small branch into a single leaf.
  13585. collapse: function(lines) {
  13586. lines.push.apply(lines, this.lines);
  13587. },
  13588. // Insert the given array of lines at offset 'at', count them as
  13589. // having the given height.
  13590. insertInner: function(at, lines, height) {
  13591. var this$1 = this;
  13592. this.height += height;
  13593. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  13594. for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1; }
  13595. },
  13596. // Used to iterate over a part of the tree.
  13597. iterN: function(at, n, op) {
  13598. var this$1 = this;
  13599. for (var e = at + n; at < e; ++at)
  13600. { if (op(this$1.lines[at])) { return true } }
  13601. }
  13602. };
  13603. function BranchChunk(children) {
  13604. var this$1 = this;
  13605. this.children = children;
  13606. var size = 0, height = 0;
  13607. for (var i = 0; i < children.length; ++i) {
  13608. var ch = children[i];
  13609. size += ch.chunkSize(); height += ch.height;
  13610. ch.parent = this$1;
  13611. }
  13612. this.size = size;
  13613. this.height = height;
  13614. this.parent = null;
  13615. }
  13616. BranchChunk.prototype = {
  13617. chunkSize: function() { return this.size },
  13618. removeInner: function(at, n) {
  13619. var this$1 = this;
  13620. this.size -= n;
  13621. for (var i = 0; i < this.children.length; ++i) {
  13622. var child = this$1.children[i], sz = child.chunkSize();
  13623. if (at < sz) {
  13624. var rm = Math.min(n, sz - at), oldHeight = child.height;
  13625. child.removeInner(at, rm);
  13626. this$1.height -= oldHeight - child.height;
  13627. if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null; }
  13628. if ((n -= rm) == 0) { break }
  13629. at = 0;
  13630. } else { at -= sz; }
  13631. }
  13632. // If the result is smaller than 25 lines, ensure that it is a
  13633. // single leaf node.
  13634. if (this.size - n < 25 &&
  13635. (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  13636. var lines = [];
  13637. this.collapse(lines);
  13638. this.children = [new LeafChunk(lines)];
  13639. this.children[0].parent = this;
  13640. }
  13641. },
  13642. collapse: function(lines) {
  13643. var this$1 = this;
  13644. for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines); }
  13645. },
  13646. insertInner: function(at, lines, height) {
  13647. var this$1 = this;
  13648. this.size += lines.length;
  13649. this.height += height;
  13650. for (var i = 0; i < this.children.length; ++i) {
  13651. var child = this$1.children[i], sz = child.chunkSize();
  13652. if (at <= sz) {
  13653. child.insertInner(at, lines, height);
  13654. if (child.lines && child.lines.length > 50) {
  13655. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  13656. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  13657. var remaining = child.lines.length % 25 + 25;
  13658. for (var pos = remaining; pos < child.lines.length;) {
  13659. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  13660. child.height -= leaf.height;
  13661. this$1.children.splice(++i, 0, leaf);
  13662. leaf.parent = this$1;
  13663. }
  13664. child.lines = child.lines.slice(0, remaining);
  13665. this$1.maybeSpill();
  13666. }
  13667. break
  13668. }
  13669. at -= sz;
  13670. }
  13671. },
  13672. // When a node has grown, check whether it should be split.
  13673. maybeSpill: function() {
  13674. if (this.children.length <= 10) { return }
  13675. var me = this;
  13676. do {
  13677. var spilled = me.children.splice(me.children.length - 5, 5);
  13678. var sibling = new BranchChunk(spilled);
  13679. if (!me.parent) { // Become the parent node
  13680. var copy = new BranchChunk(me.children);
  13681. copy.parent = me;
  13682. me.children = [copy, sibling];
  13683. me = copy;
  13684. } else {
  13685. me.size -= sibling.size;
  13686. me.height -= sibling.height;
  13687. var myIndex = indexOf(me.parent.children, me);
  13688. me.parent.children.splice(myIndex + 1, 0, sibling);
  13689. }
  13690. sibling.parent = me.parent;
  13691. } while (me.children.length > 10)
  13692. me.parent.maybeSpill();
  13693. },
  13694. iterN: function(at, n, op) {
  13695. var this$1 = this;
  13696. for (var i = 0; i < this.children.length; ++i) {
  13697. var child = this$1.children[i], sz = child.chunkSize();
  13698. if (at < sz) {
  13699. var used = Math.min(n, sz - at);
  13700. if (child.iterN(at, used, op)) { return true }
  13701. if ((n -= used) == 0) { break }
  13702. at = 0;
  13703. } else { at -= sz; }
  13704. }
  13705. }
  13706. };
  13707. // Line widgets are block elements displayed above or below a line.
  13708. var LineWidget = function(doc, node, options) {
  13709. var this$1 = this;
  13710. if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
  13711. { this$1[opt] = options[opt]; } } }
  13712. this.doc = doc;
  13713. this.node = node;
  13714. };
  13715. LineWidget.prototype.clear = function () {
  13716. var this$1 = this;
  13717. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
  13718. if (no == null || !ws) { return }
  13719. for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1); } }
  13720. if (!ws.length) { line.widgets = null; }
  13721. var height = widgetHeight(this);
  13722. updateLineHeight(line, Math.max(0, line.height - height));
  13723. if (cm) {
  13724. runInOp(cm, function () {
  13725. adjustScrollWhenAboveVisible(cm, line, -height);
  13726. regLineChange(cm, no, "widget");
  13727. });
  13728. signalLater(cm, "lineWidgetCleared", cm, this, no);
  13729. }
  13730. };
  13731. LineWidget.prototype.changed = function () {
  13732. var this$1 = this;
  13733. var oldH = this.height, cm = this.doc.cm, line = this.line;
  13734. this.height = null;
  13735. var diff = widgetHeight(this) - oldH;
  13736. if (!diff) { return }
  13737. updateLineHeight(line, line.height + diff);
  13738. if (cm) {
  13739. runInOp(cm, function () {
  13740. cm.curOp.forceUpdate = true;
  13741. adjustScrollWhenAboveVisible(cm, line, diff);
  13742. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  13743. });
  13744. }
  13745. };
  13746. eventMixin(LineWidget);
  13747. function adjustScrollWhenAboveVisible(cm, line, diff) {
  13748. if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
  13749. { addToScrollTop(cm, diff); }
  13750. }
  13751. function addLineWidget(doc, handle, node, options) {
  13752. var widget = new LineWidget(doc, node, options);
  13753. var cm = doc.cm;
  13754. if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }
  13755. changeLine(doc, handle, "widget", function (line) {
  13756. var widgets = line.widgets || (line.widgets = []);
  13757. if (widget.insertAt == null) { widgets.push(widget); }
  13758. else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
  13759. widget.line = line;
  13760. if (cm && !lineIsHidden(doc, line)) {
  13761. var aboveVisible = heightAtLine(line) < doc.scrollTop;
  13762. updateLineHeight(line, line.height + widgetHeight(widget));
  13763. if (aboveVisible) { addToScrollTop(cm, widget.height); }
  13764. cm.curOp.forceUpdate = true;
  13765. }
  13766. return true
  13767. });
  13768. if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); }
  13769. return widget
  13770. }
  13771. // TEXTMARKERS
  13772. // Created with markText and setBookmark methods. A TextMarker is a
  13773. // handle that can be used to clear or find a marked position in the
  13774. // document. Line objects hold arrays (markedSpans) containing
  13775. // {from, to, marker} object pointing to such marker objects, and
  13776. // indicating that such a marker is present on that line. Multiple
  13777. // lines may point to the same marker when it spans across lines.
  13778. // The spans will have null for their from/to properties when the
  13779. // marker continues beyond the start/end of the line. Markers have
  13780. // links back to the lines they currently touch.
  13781. // Collapsed markers have unique ids, in order to be able to order
  13782. // them, which is needed for uniquely determining an outer marker
  13783. // when they overlap (they may nest, but not partially overlap).
  13784. var nextMarkerId = 0;
  13785. var TextMarker = function(doc, type) {
  13786. this.lines = [];
  13787. this.type = type;
  13788. this.doc = doc;
  13789. this.id = ++nextMarkerId;
  13790. };
  13791. // Clear the marker.
  13792. TextMarker.prototype.clear = function () {
  13793. var this$1 = this;
  13794. if (this.explicitlyCleared) { return }
  13795. var cm = this.doc.cm, withOp = cm && !cm.curOp;
  13796. if (withOp) { startOperation(cm); }
  13797. if (hasHandler(this, "clear")) {
  13798. var found = this.find();
  13799. if (found) { signalLater(this, "clear", found.from, found.to); }
  13800. }
  13801. var min = null, max = null;
  13802. for (var i = 0; i < this.lines.length; ++i) {
  13803. var line = this$1.lines[i];
  13804. var span = getMarkedSpanFor(line.markedSpans, this$1);
  13805. if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text"); }
  13806. else if (cm) {
  13807. if (span.to != null) { max = lineNo(line); }
  13808. if (span.from != null) { min = lineNo(line); }
  13809. }
  13810. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  13811. if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
  13812. { updateLineHeight(line, textHeight(cm.display)); }
  13813. }
  13814. if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  13815. var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual);
  13816. if (len > cm.display.maxLineLength) {
  13817. cm.display.maxLine = visual;
  13818. cm.display.maxLineLength = len;
  13819. cm.display.maxLineChanged = true;
  13820. }
  13821. } }
  13822. if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }
  13823. this.lines.length = 0;
  13824. this.explicitlyCleared = true;
  13825. if (this.atomic && this.doc.cantEdit) {
  13826. this.doc.cantEdit = false;
  13827. if (cm) { reCheckSelection(cm.doc); }
  13828. }
  13829. if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); }
  13830. if (withOp) { endOperation(cm); }
  13831. if (this.parent) { this.parent.clear(); }
  13832. };
  13833. // Find the position of the marker in the document. Returns a {from,
  13834. // to} object by default. Side can be passed to get a specific side
  13835. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  13836. // Pos objects returned contain a line object, rather than a line
  13837. // number (used to prevent looking up the same line twice).
  13838. TextMarker.prototype.find = function (side, lineObj) {
  13839. var this$1 = this;
  13840. if (side == null && this.type == "bookmark") { side = 1; }
  13841. var from, to;
  13842. for (var i = 0; i < this.lines.length; ++i) {
  13843. var line = this$1.lines[i];
  13844. var span = getMarkedSpanFor(line.markedSpans, this$1);
  13845. if (span.from != null) {
  13846. from = Pos(lineObj ? line : lineNo(line), span.from);
  13847. if (side == -1) { return from }
  13848. }
  13849. if (span.to != null) {
  13850. to = Pos(lineObj ? line : lineNo(line), span.to);
  13851. if (side == 1) { return to }
  13852. }
  13853. }
  13854. return from && {from: from, to: to}
  13855. };
  13856. // Signals that the marker's widget changed, and surrounding layout
  13857. // should be recomputed.
  13858. TextMarker.prototype.changed = function () {
  13859. var this$1 = this;
  13860. var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
  13861. if (!pos || !cm) { return }
  13862. runInOp(cm, function () {
  13863. var line = pos.line, lineN = lineNo(pos.line);
  13864. var view = findViewForLine(cm, lineN);
  13865. if (view) {
  13866. clearLineMeasurementCacheFor(view);
  13867. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  13868. }
  13869. cm.curOp.updateMaxLine = true;
  13870. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  13871. var oldHeight = widget.height;
  13872. widget.height = null;
  13873. var dHeight = widgetHeight(widget) - oldHeight;
  13874. if (dHeight)
  13875. { updateLineHeight(line, line.height + dHeight); }
  13876. }
  13877. signalLater(cm, "markerChanged", cm, this$1);
  13878. });
  13879. };
  13880. TextMarker.prototype.attachLine = function (line) {
  13881. if (!this.lines.length && this.doc.cm) {
  13882. var op = this.doc.cm.curOp;
  13883. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
  13884. { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }
  13885. }
  13886. this.lines.push(line);
  13887. };
  13888. TextMarker.prototype.detachLine = function (line) {
  13889. this.lines.splice(indexOf(this.lines, line), 1);
  13890. if (!this.lines.length && this.doc.cm) {
  13891. var op = this.doc.cm.curOp;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  13892. }
  13893. };
  13894. eventMixin(TextMarker);
  13895. // Create a marker, wire it up to the right lines, and
  13896. function markText(doc, from, to, options, type) {
  13897. // Shared markers (across linked documents) are handled separately
  13898. // (markTextShared will call out to this again, once per
  13899. // document).
  13900. if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
  13901. // Ensure we are in an operation.
  13902. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
  13903. var marker = new TextMarker(doc, type), diff = cmp(from, to);
  13904. if (options) { copyObj(options, marker, false); }
  13905. // Don't connect empty markers unless clearWhenEmpty is false
  13906. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
  13907. { return marker }
  13908. if (marker.replacedWith) {
  13909. // Showing up as a widget implies collapsed (widget replaces text)
  13910. marker.collapsed = true;
  13911. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  13912. if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); }
  13913. if (options.insertLeft) { marker.widgetNode.insertLeft = true; }
  13914. }
  13915. if (marker.collapsed) {
  13916. if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
  13917. from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
  13918. { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
  13919. seeCollapsedSpans();
  13920. }
  13921. if (marker.addToHistory)
  13922. { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); }
  13923. var curLine = from.line, cm = doc.cm, updateMaxLine;
  13924. doc.iter(curLine, to.line + 1, function (line) {
  13925. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
  13926. { updateMaxLine = true; }
  13927. if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
  13928. addMarkedSpan(line, new MarkedSpan(marker,
  13929. curLine == from.line ? from.ch : null,
  13930. curLine == to.line ? to.ch : null));
  13931. ++curLine;
  13932. });
  13933. // lineIsHidden depends on the presence of the spans, so needs a second pass
  13934. if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
  13935. if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }
  13936. }); }
  13937. if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); }
  13938. if (marker.readOnly) {
  13939. seeReadOnlySpans();
  13940. if (doc.history.done.length || doc.history.undone.length)
  13941. { doc.clearHistory(); }
  13942. }
  13943. if (marker.collapsed) {
  13944. marker.id = ++nextMarkerId;
  13945. marker.atomic = true;
  13946. }
  13947. if (cm) {
  13948. // Sync editor state
  13949. if (updateMaxLine) { cm.curOp.updateMaxLine = true; }
  13950. if (marker.collapsed)
  13951. { regChange(cm, from.line, to.line + 1); }
  13952. else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
  13953. { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } }
  13954. if (marker.atomic) { reCheckSelection(cm.doc); }
  13955. signalLater(cm, "markerAdded", cm, marker);
  13956. }
  13957. return marker
  13958. }
  13959. // SHARED TEXTMARKERS
  13960. // A shared marker spans multiple linked documents. It is
  13961. // implemented as a meta-marker-object controlling multiple normal
  13962. // markers.
  13963. var SharedTextMarker = function(markers, primary) {
  13964. var this$1 = this;
  13965. this.markers = markers;
  13966. this.primary = primary;
  13967. for (var i = 0; i < markers.length; ++i)
  13968. { markers[i].parent = this$1; }
  13969. };
  13970. SharedTextMarker.prototype.clear = function () {
  13971. var this$1 = this;
  13972. if (this.explicitlyCleared) { return }
  13973. this.explicitlyCleared = true;
  13974. for (var i = 0; i < this.markers.length; ++i)
  13975. { this$1.markers[i].clear(); }
  13976. signalLater(this, "clear");
  13977. };
  13978. SharedTextMarker.prototype.find = function (side, lineObj) {
  13979. return this.primary.find(side, lineObj)
  13980. };
  13981. eventMixin(SharedTextMarker);
  13982. function markTextShared(doc, from, to, options, type) {
  13983. options = copyObj(options);
  13984. options.shared = false;
  13985. var markers = [markText(doc, from, to, options, type)], primary = markers[0];
  13986. var widget = options.widgetNode;
  13987. linkedDocs(doc, function (doc) {
  13988. if (widget) { options.widgetNode = widget.cloneNode(true); }
  13989. markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
  13990. for (var i = 0; i < doc.linked.length; ++i)
  13991. { if (doc.linked[i].isParent) { return } }
  13992. primary = lst(markers);
  13993. });
  13994. return new SharedTextMarker(markers, primary)
  13995. }
  13996. function findSharedMarkers(doc) {
  13997. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
  13998. }
  13999. function copySharedMarkers(doc, markers) {
  14000. for (var i = 0; i < markers.length; i++) {
  14001. var marker = markers[i], pos = marker.find();
  14002. var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
  14003. if (cmp(mFrom, mTo)) {
  14004. var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
  14005. marker.markers.push(subMark);
  14006. subMark.parent = marker;
  14007. }
  14008. }
  14009. }
  14010. function detachSharedMarkers(markers) {
  14011. var loop = function ( i ) {
  14012. var marker = markers[i], linked = [marker.primary.doc];
  14013. linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });
  14014. for (var j = 0; j < marker.markers.length; j++) {
  14015. var subMarker = marker.markers[j];
  14016. if (indexOf(linked, subMarker.doc) == -1) {
  14017. subMarker.parent = null;
  14018. marker.markers.splice(j--, 1);
  14019. }
  14020. }
  14021. };
  14022. for (var i = 0; i < markers.length; i++) loop( i );
  14023. }
  14024. var nextDocId = 0;
  14025. var Doc = function(text, mode, firstLine, lineSep, direction) {
  14026. if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
  14027. if (firstLine == null) { firstLine = 0; }
  14028. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  14029. this.first = firstLine;
  14030. this.scrollTop = this.scrollLeft = 0;
  14031. this.cantEdit = false;
  14032. this.cleanGeneration = 1;
  14033. this.modeFrontier = this.highlightFrontier = firstLine;
  14034. var start = Pos(firstLine, 0);
  14035. this.sel = simpleSelection(start);
  14036. this.history = new History(null);
  14037. this.id = ++nextDocId;
  14038. this.modeOption = mode;
  14039. this.lineSep = lineSep;
  14040. this.direction = (direction == "rtl") ? "rtl" : "ltr";
  14041. this.extend = false;
  14042. if (typeof text == "string") { text = this.splitLines(text); }
  14043. updateDoc(this, {from: start, to: start, text: text});
  14044. setSelection(this, simpleSelection(start), sel_dontScroll);
  14045. };
  14046. Doc.prototype = createObj(BranchChunk.prototype, {
  14047. constructor: Doc,
  14048. // Iterate over the document. Supports two forms -- with only one
  14049. // argument, it calls that for each line in the document. With
  14050. // three, it iterates over the range given by the first two (with
  14051. // the second being non-inclusive).
  14052. iter: function(from, to, op) {
  14053. if (op) { this.iterN(from - this.first, to - from, op); }
  14054. else { this.iterN(this.first, this.first + this.size, from); }
  14055. },
  14056. // Non-public interface for adding and removing lines.
  14057. insert: function(at, lines) {
  14058. var height = 0;
  14059. for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }
  14060. this.insertInner(at - this.first, lines, height);
  14061. },
  14062. remove: function(at, n) { this.removeInner(at - this.first, n); },
  14063. // From here, the methods are part of the public interface. Most
  14064. // are also available from CodeMirror (editor) instances.
  14065. getValue: function(lineSep) {
  14066. var lines = getLines(this, this.first, this.first + this.size);
  14067. if (lineSep === false) { return lines }
  14068. return lines.join(lineSep || this.lineSeparator())
  14069. },
  14070. setValue: docMethodOp(function(code) {
  14071. var top = Pos(this.first, 0), last = this.first + this.size - 1;
  14072. makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
  14073. text: this.splitLines(code), origin: "setValue", full: true}, true);
  14074. if (this.cm) { scrollToCoords(this.cm, 0, 0); }
  14075. setSelection(this, simpleSelection(top), sel_dontScroll);
  14076. }),
  14077. replaceRange: function(code, from, to, origin) {
  14078. from = clipPos(this, from);
  14079. to = to ? clipPos(this, to) : from;
  14080. replaceRange(this, code, from, to, origin);
  14081. },
  14082. getRange: function(from, to, lineSep) {
  14083. var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
  14084. if (lineSep === false) { return lines }
  14085. return lines.join(lineSep || this.lineSeparator())
  14086. },
  14087. getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
  14088. getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
  14089. getLineNumber: function(line) {return lineNo(line)},
  14090. getLineHandleVisualStart: function(line) {
  14091. if (typeof line == "number") { line = getLine(this, line); }
  14092. return visualLine(line)
  14093. },
  14094. lineCount: function() {return this.size},
  14095. firstLine: function() {return this.first},
  14096. lastLine: function() {return this.first + this.size - 1},
  14097. clipPos: function(pos) {return clipPos(this, pos)},
  14098. getCursor: function(start) {
  14099. var range$$1 = this.sel.primary(), pos;
  14100. if (start == null || start == "head") { pos = range$$1.head; }
  14101. else if (start == "anchor") { pos = range$$1.anchor; }
  14102. else if (start == "end" || start == "to" || start === false) { pos = range$$1.to(); }
  14103. else { pos = range$$1.from(); }
  14104. return pos
  14105. },
  14106. listSelections: function() { return this.sel.ranges },
  14107. somethingSelected: function() {return this.sel.somethingSelected()},
  14108. setCursor: docMethodOp(function(line, ch, options) {
  14109. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  14110. }),
  14111. setSelection: docMethodOp(function(anchor, head, options) {
  14112. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
  14113. }),
  14114. extendSelection: docMethodOp(function(head, other, options) {
  14115. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
  14116. }),
  14117. extendSelections: docMethodOp(function(heads, options) {
  14118. extendSelections(this, clipPosArray(this, heads), options);
  14119. }),
  14120. extendSelectionsBy: docMethodOp(function(f, options) {
  14121. var heads = map(this.sel.ranges, f);
  14122. extendSelections(this, clipPosArray(this, heads), options);
  14123. }),
  14124. setSelections: docMethodOp(function(ranges, primary, options) {
  14125. var this$1 = this;
  14126. if (!ranges.length) { return }
  14127. var out = [];
  14128. for (var i = 0; i < ranges.length; i++)
  14129. { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
  14130. clipPos(this$1, ranges[i].head)); }
  14131. if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
  14132. setSelection(this, normalizeSelection(out, primary), options);
  14133. }),
  14134. addSelection: docMethodOp(function(anchor, head, options) {
  14135. var ranges = this.sel.ranges.slice(0);
  14136. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
  14137. setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
  14138. }),
  14139. getSelection: function(lineSep) {
  14140. var this$1 = this;
  14141. var ranges = this.sel.ranges, lines;
  14142. for (var i = 0; i < ranges.length; i++) {
  14143. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  14144. lines = lines ? lines.concat(sel) : sel;
  14145. }
  14146. if (lineSep === false) { return lines }
  14147. else { return lines.join(lineSep || this.lineSeparator()) }
  14148. },
  14149. getSelections: function(lineSep) {
  14150. var this$1 = this;
  14151. var parts = [], ranges = this.sel.ranges;
  14152. for (var i = 0; i < ranges.length; i++) {
  14153. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  14154. if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()); }
  14155. parts[i] = sel;
  14156. }
  14157. return parts
  14158. },
  14159. replaceSelection: function(code, collapse, origin) {
  14160. var dup = [];
  14161. for (var i = 0; i < this.sel.ranges.length; i++)
  14162. { dup[i] = code; }
  14163. this.replaceSelections(dup, collapse, origin || "+input");
  14164. },
  14165. replaceSelections: docMethodOp(function(code, collapse, origin) {
  14166. var this$1 = this;
  14167. var changes = [], sel = this.sel;
  14168. for (var i = 0; i < sel.ranges.length; i++) {
  14169. var range$$1 = sel.ranges[i];
  14170. changes[i] = {from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin};
  14171. }
  14172. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  14173. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
  14174. { makeChange(this$1, changes[i$1]); }
  14175. if (newSel) { setSelectionReplaceHistory(this, newSel); }
  14176. else if (this.cm) { ensureCursorVisible(this.cm); }
  14177. }),
  14178. undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
  14179. redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
  14180. undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
  14181. redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
  14182. setExtending: function(val) {this.extend = val;},
  14183. getExtending: function() {return this.extend},
  14184. historySize: function() {
  14185. var hist = this.history, done = 0, undone = 0;
  14186. for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }
  14187. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
  14188. return {undo: done, redo: undone}
  14189. },
  14190. clearHistory: function() {this.history = new History(this.history.maxGeneration);},
  14191. markClean: function() {
  14192. this.cleanGeneration = this.changeGeneration(true);
  14193. },
  14194. changeGeneration: function(forceSplit) {
  14195. if (forceSplit)
  14196. { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }
  14197. return this.history.generation
  14198. },
  14199. isClean: function (gen) {
  14200. return this.history.generation == (gen || this.cleanGeneration)
  14201. },
  14202. getHistory: function() {
  14203. return {done: copyHistoryArray(this.history.done),
  14204. undone: copyHistoryArray(this.history.undone)}
  14205. },
  14206. setHistory: function(histData) {
  14207. var hist = this.history = new History(this.history.maxGeneration);
  14208. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  14209. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  14210. },
  14211. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  14212. return changeLine(this, line, "gutter", function (line) {
  14213. var markers = line.gutterMarkers || (line.gutterMarkers = {});
  14214. markers[gutterID] = value;
  14215. if (!value && isEmpty(markers)) { line.gutterMarkers = null; }
  14216. return true
  14217. })
  14218. }),
  14219. clearGutter: docMethodOp(function(gutterID) {
  14220. var this$1 = this;
  14221. this.iter(function (line) {
  14222. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  14223. changeLine(this$1, line, "gutter", function () {
  14224. line.gutterMarkers[gutterID] = null;
  14225. if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }
  14226. return true
  14227. });
  14228. }
  14229. });
  14230. }),
  14231. lineInfo: function(line) {
  14232. var n;
  14233. if (typeof line == "number") {
  14234. if (!isLine(this, line)) { return null }
  14235. n = line;
  14236. line = getLine(this, line);
  14237. if (!line) { return null }
  14238. } else {
  14239. n = lineNo(line);
  14240. if (n == null) { return null }
  14241. }
  14242. return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  14243. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  14244. widgets: line.widgets}
  14245. },
  14246. addLineClass: docMethodOp(function(handle, where, cls) {
  14247. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  14248. var prop = where == "text" ? "textClass"
  14249. : where == "background" ? "bgClass"
  14250. : where == "gutter" ? "gutterClass" : "wrapClass";
  14251. if (!line[prop]) { line[prop] = cls; }
  14252. else if (classTest(cls).test(line[prop])) { return false }
  14253. else { line[prop] += " " + cls; }
  14254. return true
  14255. })
  14256. }),
  14257. removeLineClass: docMethodOp(function(handle, where, cls) {
  14258. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  14259. var prop = where == "text" ? "textClass"
  14260. : where == "background" ? "bgClass"
  14261. : where == "gutter" ? "gutterClass" : "wrapClass";
  14262. var cur = line[prop];
  14263. if (!cur) { return false }
  14264. else if (cls == null) { line[prop] = null; }
  14265. else {
  14266. var found = cur.match(classTest(cls));
  14267. if (!found) { return false }
  14268. var end = found.index + found[0].length;
  14269. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  14270. }
  14271. return true
  14272. })
  14273. }),
  14274. addLineWidget: docMethodOp(function(handle, node, options) {
  14275. return addLineWidget(this, handle, node, options)
  14276. }),
  14277. removeLineWidget: function(widget) { widget.clear(); },
  14278. markText: function(from, to, options) {
  14279. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
  14280. },
  14281. setBookmark: function(pos, options) {
  14282. var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
  14283. insertLeft: options && options.insertLeft,
  14284. clearWhenEmpty: false, shared: options && options.shared,
  14285. handleMouseEvents: options && options.handleMouseEvents};
  14286. pos = clipPos(this, pos);
  14287. return markText(this, pos, pos, realOpts, "bookmark")
  14288. },
  14289. findMarksAt: function(pos) {
  14290. pos = clipPos(this, pos);
  14291. var markers = [], spans = getLine(this, pos.line).markedSpans;
  14292. if (spans) { for (var i = 0; i < spans.length; ++i) {
  14293. var span = spans[i];
  14294. if ((span.from == null || span.from <= pos.ch) &&
  14295. (span.to == null || span.to >= pos.ch))
  14296. { markers.push(span.marker.parent || span.marker); }
  14297. } }
  14298. return markers
  14299. },
  14300. findMarks: function(from, to, filter) {
  14301. from = clipPos(this, from); to = clipPos(this, to);
  14302. var found = [], lineNo$$1 = from.line;
  14303. this.iter(from.line, to.line + 1, function (line) {
  14304. var spans = line.markedSpans;
  14305. if (spans) { for (var i = 0; i < spans.length; i++) {
  14306. var span = spans[i];
  14307. if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to ||
  14308. span.from == null && lineNo$$1 != from.line ||
  14309. span.from != null && lineNo$$1 == to.line && span.from >= to.ch) &&
  14310. (!filter || filter(span.marker)))
  14311. { found.push(span.marker.parent || span.marker); }
  14312. } }
  14313. ++lineNo$$1;
  14314. });
  14315. return found
  14316. },
  14317. getAllMarks: function() {
  14318. var markers = [];
  14319. this.iter(function (line) {
  14320. var sps = line.markedSpans;
  14321. if (sps) { for (var i = 0; i < sps.length; ++i)
  14322. { if (sps[i].from != null) { markers.push(sps[i].marker); } } }
  14323. });
  14324. return markers
  14325. },
  14326. posFromIndex: function(off) {
  14327. var ch, lineNo$$1 = this.first, sepSize = this.lineSeparator().length;
  14328. this.iter(function (line) {
  14329. var sz = line.text.length + sepSize;
  14330. if (sz > off) { ch = off; return true }
  14331. off -= sz;
  14332. ++lineNo$$1;
  14333. });
  14334. return clipPos(this, Pos(lineNo$$1, ch))
  14335. },
  14336. indexFromPos: function (coords) {
  14337. coords = clipPos(this, coords);
  14338. var index = coords.ch;
  14339. if (coords.line < this.first || coords.ch < 0) { return 0 }
  14340. var sepSize = this.lineSeparator().length;
  14341. this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
  14342. index += line.text.length + sepSize;
  14343. });
  14344. return index
  14345. },
  14346. copy: function(copyHistory) {
  14347. var doc = new Doc(getLines(this, this.first, this.first + this.size),
  14348. this.modeOption, this.first, this.lineSep, this.direction);
  14349. doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
  14350. doc.sel = this.sel;
  14351. doc.extend = false;
  14352. if (copyHistory) {
  14353. doc.history.undoDepth = this.history.undoDepth;
  14354. doc.setHistory(this.getHistory());
  14355. }
  14356. return doc
  14357. },
  14358. linkedDoc: function(options) {
  14359. if (!options) { options = {}; }
  14360. var from = this.first, to = this.first + this.size;
  14361. if (options.from != null && options.from > from) { from = options.from; }
  14362. if (options.to != null && options.to < to) { to = options.to; }
  14363. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  14364. if (options.sharedHist) { copy.history = this.history
  14365. ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
  14366. copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
  14367. copySharedMarkers(copy, findSharedMarkers(this));
  14368. return copy
  14369. },
  14370. unlinkDoc: function(other) {
  14371. var this$1 = this;
  14372. if (other instanceof CodeMirror$1) { other = other.doc; }
  14373. if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
  14374. var link = this$1.linked[i];
  14375. if (link.doc != other) { continue }
  14376. this$1.linked.splice(i, 1);
  14377. other.unlinkDoc(this$1);
  14378. detachSharedMarkers(findSharedMarkers(this$1));
  14379. break
  14380. } }
  14381. // If the histories were shared, split them again
  14382. if (other.history == this.history) {
  14383. var splitIds = [other.id];
  14384. linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);
  14385. other.history = new History(null);
  14386. other.history.done = copyHistoryArray(this.history.done, splitIds);
  14387. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  14388. }
  14389. },
  14390. iterLinkedDocs: function(f) {linkedDocs(this, f);},
  14391. getMode: function() {return this.mode},
  14392. getEditor: function() {return this.cm},
  14393. splitLines: function(str) {
  14394. if (this.lineSep) { return str.split(this.lineSep) }
  14395. return splitLinesAuto(str)
  14396. },
  14397. lineSeparator: function() { return this.lineSep || "\n" },
  14398. setDirection: docMethodOp(function (dir) {
  14399. if (dir != "rtl") { dir = "ltr"; }
  14400. if (dir == this.direction) { return }
  14401. this.direction = dir;
  14402. this.iter(function (line) { return line.order = null; });
  14403. if (this.cm) { directionChanged(this.cm); }
  14404. })
  14405. });
  14406. // Public alias.
  14407. Doc.prototype.eachLine = Doc.prototype.iter;
  14408. // Kludge to work around strange IE behavior where it'll sometimes
  14409. // re-fire a series of drag-related events right after the drop (#1551)
  14410. var lastDrop = 0;
  14411. function onDrop(e) {
  14412. var cm = this;
  14413. clearDragCursor(cm);
  14414. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
  14415. { return }
  14416. e_preventDefault(e);
  14417. if (ie) { lastDrop = +new Date; }
  14418. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
  14419. if (!pos || cm.isReadOnly()) { return }
  14420. // Might be a file drop, in which case we simply extract the text
  14421. // and insert it.
  14422. if (files && files.length && window.FileReader && window.File) {
  14423. var n = files.length, text = Array(n), read = 0;
  14424. var loadFile = function (file, i) {
  14425. if (cm.options.allowDropFileTypes &&
  14426. indexOf(cm.options.allowDropFileTypes, file.type) == -1)
  14427. { return }
  14428. var reader = new FileReader;
  14429. reader.onload = operation(cm, function () {
  14430. var content = reader.result;
  14431. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
  14432. text[i] = content;
  14433. if (++read == n) {
  14434. pos = clipPos(cm.doc, pos);
  14435. var change = {from: pos, to: pos,
  14436. text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
  14437. origin: "paste"};
  14438. makeChange(cm.doc, change);
  14439. setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
  14440. }
  14441. });
  14442. reader.readAsText(file);
  14443. };
  14444. for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
  14445. } else { // Normal drop
  14446. // Don't do a replace if the drop happened inside of the selected text.
  14447. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  14448. cm.state.draggingText(e);
  14449. // Ensure the editor is re-focused
  14450. setTimeout(function () { return cm.display.input.focus(); }, 20);
  14451. return
  14452. }
  14453. try {
  14454. var text$1 = e.dataTransfer.getData("Text");
  14455. if (text$1) {
  14456. var selected;
  14457. if (cm.state.draggingText && !cm.state.draggingText.copy)
  14458. { selected = cm.listSelections(); }
  14459. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  14460. if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
  14461. { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } }
  14462. cm.replaceSelection(text$1, "around", "paste");
  14463. cm.display.input.focus();
  14464. }
  14465. }
  14466. catch(e){}
  14467. }
  14468. }
  14469. function onDragStart(cm, e) {
  14470. if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
  14471. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
  14472. e.dataTransfer.setData("Text", cm.getSelection());
  14473. e.dataTransfer.effectAllowed = "copyMove";
  14474. // Use dummy image instead of default browsers image.
  14475. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  14476. if (e.dataTransfer.setDragImage && !safari) {
  14477. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  14478. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  14479. if (presto) {
  14480. img.width = img.height = 1;
  14481. cm.display.wrapper.appendChild(img);
  14482. // Force a relayout, or Opera won't use our image for some obscure reason
  14483. img._top = img.offsetTop;
  14484. }
  14485. e.dataTransfer.setDragImage(img, 0, 0);
  14486. if (presto) { img.parentNode.removeChild(img); }
  14487. }
  14488. }
  14489. function onDragOver(cm, e) {
  14490. var pos = posFromMouse(cm, e);
  14491. if (!pos) { return }
  14492. var frag = document.createDocumentFragment();
  14493. drawSelectionCursor(cm, pos, frag);
  14494. if (!cm.display.dragCursor) {
  14495. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  14496. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  14497. }
  14498. removeChildrenAndAdd(cm.display.dragCursor, frag);
  14499. }
  14500. function clearDragCursor(cm) {
  14501. if (cm.display.dragCursor) {
  14502. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  14503. cm.display.dragCursor = null;
  14504. }
  14505. }
  14506. // These must be handled carefully, because naively registering a
  14507. // handler for each editor will cause the editors to never be
  14508. // garbage collected.
  14509. function forEachCodeMirror(f) {
  14510. if (!document.getElementsByClassName) { return }
  14511. var byClass = document.getElementsByClassName("CodeMirror");
  14512. for (var i = 0; i < byClass.length; i++) {
  14513. var cm = byClass[i].CodeMirror;
  14514. if (cm) { f(cm); }
  14515. }
  14516. }
  14517. var globalsRegistered = false;
  14518. function ensureGlobalHandlers() {
  14519. if (globalsRegistered) { return }
  14520. registerGlobalHandlers();
  14521. globalsRegistered = true;
  14522. }
  14523. function registerGlobalHandlers() {
  14524. // When the window resizes, we need to refresh active editors.
  14525. var resizeTimer;
  14526. on(window, "resize", function () {
  14527. if (resizeTimer == null) { resizeTimer = setTimeout(function () {
  14528. resizeTimer = null;
  14529. forEachCodeMirror(onResize);
  14530. }, 100); }
  14531. });
  14532. // When the window loses focus, we want to show the editor as blurred
  14533. on(window, "blur", function () { return forEachCodeMirror(onBlur); });
  14534. }
  14535. // Called when the window resizes
  14536. function onResize(cm) {
  14537. var d = cm.display;
  14538. if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
  14539. { return }
  14540. // Might be a text scaling operation, clear size caches.
  14541. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  14542. d.scrollbarsClipped = false;
  14543. cm.setSize();
  14544. }
  14545. var keyNames = {
  14546. 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  14547. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  14548. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  14549. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  14550. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", 145: "ScrollLock",
  14551. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  14552. 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  14553. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  14554. };
  14555. // Number keys
  14556. for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }
  14557. // Alphabetic keys
  14558. for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }
  14559. // Function keys
  14560. for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; }
  14561. var keyMap = {};
  14562. keyMap.basic = {
  14563. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  14564. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  14565. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  14566. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  14567. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  14568. "Esc": "singleSelection"
  14569. };
  14570. // Note that the save and find-related commands aren't defined by
  14571. // default. User code or addons can define them. Unknown commands
  14572. // are simply ignored.
  14573. keyMap.pcDefault = {
  14574. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  14575. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  14576. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  14577. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  14578. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  14579. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  14580. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  14581. fallthrough: "basic"
  14582. };
  14583. // Very basic readline/emacs-style bindings, which are standard on Mac.
  14584. keyMap.emacsy = {
  14585. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  14586. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  14587. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  14588. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  14589. "Ctrl-O": "openLine"
  14590. };
  14591. keyMap.macDefault = {
  14592. "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
  14593. "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
  14594. "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
  14595. "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
  14596. "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
  14597. "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
  14598. "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
  14599. fallthrough: ["basic", "emacsy"]
  14600. };
  14601. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  14602. // KEYMAP DISPATCH
  14603. function normalizeKeyName(name) {
  14604. var parts = name.split(/-(?!$)/);
  14605. name = parts[parts.length - 1];
  14606. var alt, ctrl, shift, cmd;
  14607. for (var i = 0; i < parts.length - 1; i++) {
  14608. var mod = parts[i];
  14609. if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
  14610. else if (/^a(lt)?$/i.test(mod)) { alt = true; }
  14611. else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
  14612. else if (/^s(hift)?$/i.test(mod)) { shift = true; }
  14613. else { throw new Error("Unrecognized modifier name: " + mod) }
  14614. }
  14615. if (alt) { name = "Alt-" + name; }
  14616. if (ctrl) { name = "Ctrl-" + name; }
  14617. if (cmd) { name = "Cmd-" + name; }
  14618. if (shift) { name = "Shift-" + name; }
  14619. return name
  14620. }
  14621. // This is a kludge to keep keymaps mostly working as raw objects
  14622. // (backwards compatibility) while at the same time support features
  14623. // like normalization and multi-stroke key bindings. It compiles a
  14624. // new normalized keymap, and then updates the old object to reflect
  14625. // this.
  14626. function normalizeKeyMap(keymap) {
  14627. var copy = {};
  14628. for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
  14629. var value = keymap[keyname];
  14630. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
  14631. if (value == "...") { delete keymap[keyname]; continue }
  14632. var keys = map(keyname.split(" "), normalizeKeyName);
  14633. for (var i = 0; i < keys.length; i++) {
  14634. var val = (void 0), name = (void 0);
  14635. if (i == keys.length - 1) {
  14636. name = keys.join(" ");
  14637. val = value;
  14638. } else {
  14639. name = keys.slice(0, i + 1).join(" ");
  14640. val = "...";
  14641. }
  14642. var prev = copy[name];
  14643. if (!prev) { copy[name] = val; }
  14644. else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
  14645. }
  14646. delete keymap[keyname];
  14647. } }
  14648. for (var prop in copy) { keymap[prop] = copy[prop]; }
  14649. return keymap
  14650. }
  14651. function lookupKey(key, map$$1, handle, context) {
  14652. map$$1 = getKeyMap(map$$1);
  14653. var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];
  14654. if (found === false) { return "nothing" }
  14655. if (found === "...") { return "multi" }
  14656. if (found != null && handle(found)) { return "handled" }
  14657. if (map$$1.fallthrough) {
  14658. if (Object.prototype.toString.call(map$$1.fallthrough) != "[object Array]")
  14659. { return lookupKey(key, map$$1.fallthrough, handle, context) }
  14660. for (var i = 0; i < map$$1.fallthrough.length; i++) {
  14661. var result = lookupKey(key, map$$1.fallthrough[i], handle, context);
  14662. if (result) { return result }
  14663. }
  14664. }
  14665. }
  14666. // Modifier key presses don't count as 'real' key presses for the
  14667. // purpose of keymap fallthrough.
  14668. function isModifierKey(value) {
  14669. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  14670. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
  14671. }
  14672. function addModifierNames(name, event, noShift) {
  14673. var base = name;
  14674. if (event.altKey && base != "Alt") { name = "Alt-" + name; }
  14675. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
  14676. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
  14677. if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
  14678. return name
  14679. }
  14680. // Look up the name of a key as indicated by an event object.
  14681. function keyName(event, noShift) {
  14682. if (presto && event.keyCode == 34 && event["char"]) { return false }
  14683. var name = keyNames[event.keyCode];
  14684. if (name == null || event.altGraphKey) { return false }
  14685. // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
  14686. // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
  14687. if (event.keyCode == 3 && event.code) { name = event.code; }
  14688. return addModifierNames(name, event, noShift)
  14689. }
  14690. function getKeyMap(val) {
  14691. return typeof val == "string" ? keyMap[val] : val
  14692. }
  14693. // Helper for deleting text near the selection(s), used to implement
  14694. // backspace, delete, and similar functionality.
  14695. function deleteNearSelection(cm, compute) {
  14696. var ranges = cm.doc.sel.ranges, kill = [];
  14697. // Build up a set of ranges to kill first, merging overlapping
  14698. // ranges.
  14699. for (var i = 0; i < ranges.length; i++) {
  14700. var toKill = compute(ranges[i]);
  14701. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  14702. var replaced = kill.pop();
  14703. if (cmp(replaced.from, toKill.from) < 0) {
  14704. toKill.from = replaced.from;
  14705. break
  14706. }
  14707. }
  14708. kill.push(toKill);
  14709. }
  14710. // Next, remove those actual ranges.
  14711. runInOp(cm, function () {
  14712. for (var i = kill.length - 1; i >= 0; i--)
  14713. { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
  14714. ensureCursorVisible(cm);
  14715. });
  14716. }
  14717. function moveCharLogically(line, ch, dir) {
  14718. var target = skipExtendingChars(line.text, ch + dir, dir);
  14719. return target < 0 || target > line.text.length ? null : target
  14720. }
  14721. function moveLogically(line, start, dir) {
  14722. var ch = moveCharLogically(line, start.ch, dir);
  14723. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
  14724. }
  14725. function endOfLine(visually, cm, lineObj, lineNo, dir) {
  14726. if (visually) {
  14727. var order = getOrder(lineObj, cm.doc.direction);
  14728. if (order) {
  14729. var part = dir < 0 ? lst(order) : order[0];
  14730. var moveInStorageOrder = (dir < 0) == (part.level == 1);
  14731. var sticky = moveInStorageOrder ? "after" : "before";
  14732. var ch;
  14733. // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
  14734. // it could be that the last bidi part is not on the last visual line,
  14735. // since visual lines contain content order-consecutive chunks.
  14736. // Thus, in rtl, we are looking for the first (content-order) character
  14737. // in the rtl chunk that is on the last line (that is, the same line
  14738. // as the last (content-order) character).
  14739. if (part.level > 0 || cm.doc.direction == "rtl") {
  14740. var prep = prepareMeasureForLine(cm, lineObj);
  14741. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  14742. var targetTop = measureCharPrepared(cm, prep, ch).top;
  14743. ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);
  14744. if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); }
  14745. } else { ch = dir < 0 ? part.to : part.from; }
  14746. return new Pos(lineNo, ch, sticky)
  14747. }
  14748. }
  14749. return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
  14750. }
  14751. function moveVisually(cm, line, start, dir) {
  14752. var bidi = getOrder(line, cm.doc.direction);
  14753. if (!bidi) { return moveLogically(line, start, dir) }
  14754. if (start.ch >= line.text.length) {
  14755. start.ch = line.text.length;
  14756. start.sticky = "before";
  14757. } else if (start.ch <= 0) {
  14758. start.ch = 0;
  14759. start.sticky = "after";
  14760. }
  14761. var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
  14762. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
  14763. // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
  14764. // nothing interesting happens.
  14765. return moveLogically(line, start, dir)
  14766. }
  14767. var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };
  14768. var prep;
  14769. var getWrappedLineExtent = function (ch) {
  14770. if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
  14771. prep = prep || prepareMeasureForLine(cm, line);
  14772. return wrappedLineExtentChar(cm, line, prep, ch)
  14773. };
  14774. var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  14775. if (cm.doc.direction == "rtl" || part.level == 1) {
  14776. var moveInStorageOrder = (part.level == 1) == (dir < 0);
  14777. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  14778. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
  14779. // Case 2: We move within an rtl part or in an rtl editor on the same visual line
  14780. var sticky = moveInStorageOrder ? "before" : "after";
  14781. return new Pos(start.line, ch, sticky)
  14782. }
  14783. }
  14784. // Case 3: Could not move within this bidi part in this visual line, so leave
  14785. // the current bidi part
  14786. var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
  14787. var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
  14788. ? new Pos(start.line, mv(ch, 1), "before")
  14789. : new Pos(start.line, ch, "after"); };
  14790. for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
  14791. var part = bidi[partPos];
  14792. var moveInStorageOrder = (dir > 0) == (part.level != 1);
  14793. var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
  14794. if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
  14795. ch = moveInStorageOrder ? part.from : mv(part.to, -1);
  14796. if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
  14797. }
  14798. };
  14799. // Case 3a: Look for other bidi parts on the same visual line
  14800. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
  14801. if (res) { return res }
  14802. // Case 3b: Look for other bidi parts on the next visual line
  14803. var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
  14804. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  14805. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  14806. if (res) { return res }
  14807. }
  14808. // Case 4: Nowhere to move
  14809. return null
  14810. }
  14811. // Commands are parameter-less actions that can be performed on an
  14812. // editor, mostly used for keybindings.
  14813. var commands = {
  14814. selectAll: selectAll,
  14815. singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
  14816. killLine: function (cm) { return deleteNearSelection(cm, function (range) {
  14817. if (range.empty()) {
  14818. var len = getLine(cm.doc, range.head.line).text.length;
  14819. if (range.head.ch == len && range.head.line < cm.lastLine())
  14820. { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
  14821. else
  14822. { return {from: range.head, to: Pos(range.head.line, len)} }
  14823. } else {
  14824. return {from: range.from(), to: range.to()}
  14825. }
  14826. }); },
  14827. deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  14828. from: Pos(range.from().line, 0),
  14829. to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
  14830. }); }); },
  14831. delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  14832. from: Pos(range.from().line, 0), to: range.from()
  14833. }); }); },
  14834. delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
  14835. var top = cm.charCoords(range.head, "div").top + 5;
  14836. var leftPos = cm.coordsChar({left: 0, top: top}, "div");
  14837. return {from: leftPos, to: range.from()}
  14838. }); },
  14839. delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
  14840. var top = cm.charCoords(range.head, "div").top + 5;
  14841. var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
  14842. return {from: range.from(), to: rightPos }
  14843. }); },
  14844. undo: function (cm) { return cm.undo(); },
  14845. redo: function (cm) { return cm.redo(); },
  14846. undoSelection: function (cm) { return cm.undoSelection(); },
  14847. redoSelection: function (cm) { return cm.redoSelection(); },
  14848. goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
  14849. goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
  14850. goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
  14851. {origin: "+move", bias: 1}
  14852. ); },
  14853. goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
  14854. {origin: "+move", bias: 1}
  14855. ); },
  14856. goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
  14857. {origin: "+move", bias: -1}
  14858. ); },
  14859. goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
  14860. var top = cm.cursorCoords(range.head, "div").top + 5;
  14861. return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  14862. }, sel_move); },
  14863. goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
  14864. var top = cm.cursorCoords(range.head, "div").top + 5;
  14865. return cm.coordsChar({left: 0, top: top}, "div")
  14866. }, sel_move); },
  14867. goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
  14868. var top = cm.cursorCoords(range.head, "div").top + 5;
  14869. var pos = cm.coordsChar({left: 0, top: top}, "div");
  14870. if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
  14871. return pos
  14872. }, sel_move); },
  14873. goLineUp: function (cm) { return cm.moveV(-1, "line"); },
  14874. goLineDown: function (cm) { return cm.moveV(1, "line"); },
  14875. goPageUp: function (cm) { return cm.moveV(-1, "page"); },
  14876. goPageDown: function (cm) { return cm.moveV(1, "page"); },
  14877. goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
  14878. goCharRight: function (cm) { return cm.moveH(1, "char"); },
  14879. goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
  14880. goColumnRight: function (cm) { return cm.moveH(1, "column"); },
  14881. goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
  14882. goGroupRight: function (cm) { return cm.moveH(1, "group"); },
  14883. goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
  14884. goWordRight: function (cm) { return cm.moveH(1, "word"); },
  14885. delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
  14886. delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
  14887. delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
  14888. delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
  14889. delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
  14890. delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
  14891. indentAuto: function (cm) { return cm.indentSelection("smart"); },
  14892. indentMore: function (cm) { return cm.indentSelection("add"); },
  14893. indentLess: function (cm) { return cm.indentSelection("subtract"); },
  14894. insertTab: function (cm) { return cm.replaceSelection("\t"); },
  14895. insertSoftTab: function (cm) {
  14896. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
  14897. for (var i = 0; i < ranges.length; i++) {
  14898. var pos = ranges[i].from();
  14899. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  14900. spaces.push(spaceStr(tabSize - col % tabSize));
  14901. }
  14902. cm.replaceSelections(spaces);
  14903. },
  14904. defaultTab: function (cm) {
  14905. if (cm.somethingSelected()) { cm.indentSelection("add"); }
  14906. else { cm.execCommand("insertTab"); }
  14907. },
  14908. // Swap the two chars left and right of each selection's head.
  14909. // Move cursor behind the two swapped characters afterwards.
  14910. //
  14911. // Doesn't consider line feeds a character.
  14912. // Doesn't scan more than one line above to find a character.
  14913. // Doesn't do anything on an empty line.
  14914. // Doesn't do anything with non-empty selections.
  14915. transposeChars: function (cm) { return runInOp(cm, function () {
  14916. var ranges = cm.listSelections(), newSel = [];
  14917. for (var i = 0; i < ranges.length; i++) {
  14918. if (!ranges[i].empty()) { continue }
  14919. var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
  14920. if (line) {
  14921. if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
  14922. if (cur.ch > 0) {
  14923. cur = new Pos(cur.line, cur.ch + 1);
  14924. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
  14925. Pos(cur.line, cur.ch - 2), cur, "+transpose");
  14926. } else if (cur.line > cm.doc.first) {
  14927. var prev = getLine(cm.doc, cur.line - 1).text;
  14928. if (prev) {
  14929. cur = new Pos(cur.line, 1);
  14930. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
  14931. prev.charAt(prev.length - 1),
  14932. Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  14933. }
  14934. }
  14935. }
  14936. newSel.push(new Range(cur, cur));
  14937. }
  14938. cm.setSelections(newSel);
  14939. }); },
  14940. newlineAndIndent: function (cm) { return runInOp(cm, function () {
  14941. var sels = cm.listSelections();
  14942. for (var i = sels.length - 1; i >= 0; i--)
  14943. { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); }
  14944. sels = cm.listSelections();
  14945. for (var i$1 = 0; i$1 < sels.length; i$1++)
  14946. { cm.indentLine(sels[i$1].from().line, null, true); }
  14947. ensureCursorVisible(cm);
  14948. }); },
  14949. openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
  14950. toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
  14951. };
  14952. function lineStart(cm, lineN) {
  14953. var line = getLine(cm.doc, lineN);
  14954. var visual = visualLine(line);
  14955. if (visual != line) { lineN = lineNo(visual); }
  14956. return endOfLine(true, cm, visual, lineN, 1)
  14957. }
  14958. function lineEnd(cm, lineN) {
  14959. var line = getLine(cm.doc, lineN);
  14960. var visual = visualLineEnd(line);
  14961. if (visual != line) { lineN = lineNo(visual); }
  14962. return endOfLine(true, cm, line, lineN, -1)
  14963. }
  14964. function lineStartSmart(cm, pos) {
  14965. var start = lineStart(cm, pos.line);
  14966. var line = getLine(cm.doc, start.line);
  14967. var order = getOrder(line, cm.doc.direction);
  14968. if (!order || order[0].level == 0) {
  14969. var firstNonWS = Math.max(0, line.text.search(/\S/));
  14970. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  14971. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
  14972. }
  14973. return start
  14974. }
  14975. // Run a handler that was bound to a key.
  14976. function doHandleBinding(cm, bound, dropShift) {
  14977. if (typeof bound == "string") {
  14978. bound = commands[bound];
  14979. if (!bound) { return false }
  14980. }
  14981. // Ensure previous input has been read, so that the handler sees a
  14982. // consistent view of the document
  14983. cm.display.input.ensurePolled();
  14984. var prevShift = cm.display.shift, done = false;
  14985. try {
  14986. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  14987. if (dropShift) { cm.display.shift = false; }
  14988. done = bound(cm) != Pass;
  14989. } finally {
  14990. cm.display.shift = prevShift;
  14991. cm.state.suppressEdits = false;
  14992. }
  14993. return done
  14994. }
  14995. function lookupKeyForEditor(cm, name, handle) {
  14996. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  14997. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
  14998. if (result) { return result }
  14999. }
  15000. return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
  15001. || lookupKey(name, cm.options.keyMap, handle, cm)
  15002. }
  15003. // Note that, despite the name, this function is also used to check
  15004. // for bound mouse clicks.
  15005. var stopSeq = new Delayed;
  15006. function dispatchKey(cm, name, e, handle) {
  15007. var seq = cm.state.keySeq;
  15008. if (seq) {
  15009. if (isModifierKey(name)) { return "handled" }
  15010. if (/\'$/.test(name))
  15011. { cm.state.keySeq = null; }
  15012. else
  15013. { stopSeq.set(50, function () {
  15014. if (cm.state.keySeq == seq) {
  15015. cm.state.keySeq = null;
  15016. cm.display.input.reset();
  15017. }
  15018. }); }
  15019. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
  15020. }
  15021. return dispatchKeyInner(cm, name, e, handle)
  15022. }
  15023. function dispatchKeyInner(cm, name, e, handle) {
  15024. var result = lookupKeyForEditor(cm, name, handle);
  15025. if (result == "multi")
  15026. { cm.state.keySeq = name; }
  15027. if (result == "handled")
  15028. { signalLater(cm, "keyHandled", cm, name, e); }
  15029. if (result == "handled" || result == "multi") {
  15030. e_preventDefault(e);
  15031. restartBlink(cm);
  15032. }
  15033. return !!result
  15034. }
  15035. // Handle a key from the keydown event.
  15036. function handleKeyBinding(cm, e) {
  15037. var name = keyName(e, true);
  15038. if (!name) { return false }
  15039. if (e.shiftKey && !cm.state.keySeq) {
  15040. // First try to resolve full name (including 'Shift-'). Failing
  15041. // that, see if there is a cursor-motion command (starting with
  15042. // 'go') bound to the keyname without 'Shift-'.
  15043. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
  15044. || dispatchKey(cm, name, e, function (b) {
  15045. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
  15046. { return doHandleBinding(cm, b) }
  15047. })
  15048. } else {
  15049. return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
  15050. }
  15051. }
  15052. // Handle a key from the keypress event
  15053. function handleCharBinding(cm, e, ch) {
  15054. return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
  15055. }
  15056. var lastStoppedKey = null;
  15057. function onKeyDown(e) {
  15058. var cm = this;
  15059. cm.curOp.focus = activeElt();
  15060. if (signalDOMEvent(cm, e)) { return }
  15061. // IE does strange things with escape.
  15062. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
  15063. var code = e.keyCode;
  15064. cm.display.shift = code == 16 || e.shiftKey;
  15065. var handled = handleKeyBinding(cm, e);
  15066. if (presto) {
  15067. lastStoppedKey = handled ? code : null;
  15068. // Opera has no cut event... we try to at least catch the key combo
  15069. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
  15070. { cm.replaceSelection("", null, "cut"); }
  15071. }
  15072. // Turn mouse into crosshair when Alt is held on Mac.
  15073. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
  15074. { showCrossHair(cm); }
  15075. }
  15076. function showCrossHair(cm) {
  15077. var lineDiv = cm.display.lineDiv;
  15078. addClass(lineDiv, "CodeMirror-crosshair");
  15079. function up(e) {
  15080. if (e.keyCode == 18 || !e.altKey) {
  15081. rmClass(lineDiv, "CodeMirror-crosshair");
  15082. off(document, "keyup", up);
  15083. off(document, "mouseover", up);
  15084. }
  15085. }
  15086. on(document, "keyup", up);
  15087. on(document, "mouseover", up);
  15088. }
  15089. function onKeyUp(e) {
  15090. if (e.keyCode == 16) { this.doc.sel.shift = false; }
  15091. signalDOMEvent(this, e);
  15092. }
  15093. function onKeyPress(e) {
  15094. var cm = this;
  15095. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
  15096. var keyCode = e.keyCode, charCode = e.charCode;
  15097. if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
  15098. if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
  15099. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  15100. // Some browsers fire keypress events for backspace
  15101. if (ch == "\x08") { return }
  15102. if (handleCharBinding(cm, e, ch)) { return }
  15103. cm.display.input.onKeyPress(e);
  15104. }
  15105. var DOUBLECLICK_DELAY = 400;
  15106. var PastClick = function(time, pos, button) {
  15107. this.time = time;
  15108. this.pos = pos;
  15109. this.button = button;
  15110. };
  15111. PastClick.prototype.compare = function (time, pos, button) {
  15112. return this.time + DOUBLECLICK_DELAY > time &&
  15113. cmp(pos, this.pos) == 0 && button == this.button
  15114. };
  15115. var lastClick;
  15116. var lastDoubleClick;
  15117. function clickRepeat(pos, button) {
  15118. var now = +new Date;
  15119. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  15120. lastClick = lastDoubleClick = null;
  15121. return "triple"
  15122. } else if (lastClick && lastClick.compare(now, pos, button)) {
  15123. lastDoubleClick = new PastClick(now, pos, button);
  15124. lastClick = null;
  15125. return "double"
  15126. } else {
  15127. lastClick = new PastClick(now, pos, button);
  15128. lastDoubleClick = null;
  15129. return "single"
  15130. }
  15131. }
  15132. // A mouse down can be a single click, double click, triple click,
  15133. // start of selection drag, start of text drag, new cursor
  15134. // (ctrl-click), rectangle drag (alt-drag), or xwin
  15135. // middle-click-paste. Or it might be a click on something we should
  15136. // not interfere with, such as a scrollbar or widget.
  15137. function onMouseDown(e) {
  15138. var cm = this, display = cm.display;
  15139. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
  15140. display.input.ensurePolled();
  15141. display.shift = e.shiftKey;
  15142. if (eventInWidget(display, e)) {
  15143. if (!webkit) {
  15144. // Briefly turn off draggability, to allow widgets to do
  15145. // normal dragging things.
  15146. display.scroller.draggable = false;
  15147. setTimeout(function () { return display.scroller.draggable = true; }, 100);
  15148. }
  15149. return
  15150. }
  15151. if (clickInGutter(cm, e)) { return }
  15152. var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
  15153. window.focus();
  15154. // #3261: make sure, that we're not starting a second selection
  15155. if (button == 1 && cm.state.selectingText)
  15156. { cm.state.selectingText(e); }
  15157. if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
  15158. if (button == 1) {
  15159. if (pos) { leftButtonDown(cm, pos, repeat, e); }
  15160. else if (e_target(e) == display.scroller) { e_preventDefault(e); }
  15161. } else if (button == 2) {
  15162. if (pos) { extendSelection(cm.doc, pos); }
  15163. setTimeout(function () { return display.input.focus(); }, 20);
  15164. } else if (button == 3) {
  15165. if (captureRightClick) { onContextMenu(cm, e); }
  15166. else { delayBlurEvent(cm); }
  15167. }
  15168. }
  15169. function handleMappedButton(cm, button, pos, repeat, event) {
  15170. var name = "Click";
  15171. if (repeat == "double") { name = "Double" + name; }
  15172. else if (repeat == "triple") { name = "Triple" + name; }
  15173. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  15174. return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
  15175. if (typeof bound == "string") { bound = commands[bound]; }
  15176. if (!bound) { return false }
  15177. var done = false;
  15178. try {
  15179. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  15180. done = bound(cm, pos) != Pass;
  15181. } finally {
  15182. cm.state.suppressEdits = false;
  15183. }
  15184. return done
  15185. })
  15186. }
  15187. function configureMouse(cm, repeat, event) {
  15188. var option = cm.getOption("configureMouse");
  15189. var value = option ? option(cm, repeat, event) : {};
  15190. if (value.unit == null) {
  15191. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  15192. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  15193. }
  15194. if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }
  15195. if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }
  15196. if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }
  15197. return value
  15198. }
  15199. function leftButtonDown(cm, pos, repeat, event) {
  15200. if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
  15201. else { cm.curOp.focus = activeElt(); }
  15202. var behavior = configureMouse(cm, repeat, event);
  15203. var sel = cm.doc.sel, contained;
  15204. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
  15205. repeat == "single" && (contained = sel.contains(pos)) > -1 &&
  15206. (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
  15207. (cmp(contained.to(), pos) > 0 || pos.xRel < 0))
  15208. { leftButtonStartDrag(cm, event, pos, behavior); }
  15209. else
  15210. { leftButtonSelect(cm, event, pos, behavior); }
  15211. }
  15212. // Start a text drag. When it ends, see if any dragging actually
  15213. // happen, and treat as a click if it didn't.
  15214. function leftButtonStartDrag(cm, event, pos, behavior) {
  15215. var display = cm.display, moved = false;
  15216. var dragEnd = operation(cm, function (e) {
  15217. if (webkit) { display.scroller.draggable = false; }
  15218. cm.state.draggingText = false;
  15219. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  15220. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  15221. off(display.scroller, "dragstart", dragStart);
  15222. off(display.scroller, "drop", dragEnd);
  15223. if (!moved) {
  15224. e_preventDefault(e);
  15225. if (!behavior.addNew)
  15226. { extendSelection(cm.doc, pos, null, null, behavior.extend); }
  15227. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  15228. if (webkit || ie && ie_version == 9)
  15229. { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
  15230. else
  15231. { display.input.focus(); }
  15232. }
  15233. });
  15234. var mouseMove = function(e2) {
  15235. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  15236. };
  15237. var dragStart = function () { return moved = true; };
  15238. // Let the drag handler handle this.
  15239. if (webkit) { display.scroller.draggable = true; }
  15240. cm.state.draggingText = dragEnd;
  15241. dragEnd.copy = !behavior.moveOnDrag;
  15242. // IE's approach to draggable
  15243. if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
  15244. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  15245. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  15246. on(display.scroller, "dragstart", dragStart);
  15247. on(display.scroller, "drop", dragEnd);
  15248. delayBlurEvent(cm);
  15249. setTimeout(function () { return display.input.focus(); }, 20);
  15250. }
  15251. function rangeForUnit(cm, pos, unit) {
  15252. if (unit == "char") { return new Range(pos, pos) }
  15253. if (unit == "word") { return cm.findWordAt(pos) }
  15254. if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
  15255. var result = unit(cm, pos);
  15256. return new Range(result.from, result.to)
  15257. }
  15258. // Normal selection, as opposed to text dragging.
  15259. function leftButtonSelect(cm, event, start, behavior) {
  15260. var display = cm.display, doc = cm.doc;
  15261. e_preventDefault(event);
  15262. var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
  15263. if (behavior.addNew && !behavior.extend) {
  15264. ourIndex = doc.sel.contains(start);
  15265. if (ourIndex > -1)
  15266. { ourRange = ranges[ourIndex]; }
  15267. else
  15268. { ourRange = new Range(start, start); }
  15269. } else {
  15270. ourRange = doc.sel.primary();
  15271. ourIndex = doc.sel.primIndex;
  15272. }
  15273. if (behavior.unit == "rectangle") {
  15274. if (!behavior.addNew) { ourRange = new Range(start, start); }
  15275. start = posFromMouse(cm, event, true, true);
  15276. ourIndex = -1;
  15277. } else {
  15278. var range$$1 = rangeForUnit(cm, start, behavior.unit);
  15279. if (behavior.extend)
  15280. { ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend); }
  15281. else
  15282. { ourRange = range$$1; }
  15283. }
  15284. if (!behavior.addNew) {
  15285. ourIndex = 0;
  15286. setSelection(doc, new Selection([ourRange], 0), sel_mouse);
  15287. startSel = doc.sel;
  15288. } else if (ourIndex == -1) {
  15289. ourIndex = ranges.length;
  15290. setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
  15291. {scroll: false, origin: "*mouse"});
  15292. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  15293. setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
  15294. {scroll: false, origin: "*mouse"});
  15295. startSel = doc.sel;
  15296. } else {
  15297. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
  15298. }
  15299. var lastPos = start;
  15300. function extendTo(pos) {
  15301. if (cmp(lastPos, pos) == 0) { return }
  15302. lastPos = pos;
  15303. if (behavior.unit == "rectangle") {
  15304. var ranges = [], tabSize = cm.options.tabSize;
  15305. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
  15306. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
  15307. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
  15308. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
  15309. line <= end; line++) {
  15310. var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
  15311. if (left == right)
  15312. { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
  15313. else if (text.length > leftPos)
  15314. { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
  15315. }
  15316. if (!ranges.length) { ranges.push(new Range(start, start)); }
  15317. setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
  15318. {origin: "*mouse", scroll: false});
  15319. cm.scrollIntoView(pos);
  15320. } else {
  15321. var oldRange = ourRange;
  15322. var range$$1 = rangeForUnit(cm, pos, behavior.unit);
  15323. var anchor = oldRange.anchor, head;
  15324. if (cmp(range$$1.anchor, anchor) > 0) {
  15325. head = range$$1.head;
  15326. anchor = minPos(oldRange.from(), range$$1.anchor);
  15327. } else {
  15328. head = range$$1.anchor;
  15329. anchor = maxPos(oldRange.to(), range$$1.head);
  15330. }
  15331. var ranges$1 = startSel.ranges.slice(0);
  15332. ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
  15333. setSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse);
  15334. }
  15335. }
  15336. var editorSize = display.wrapper.getBoundingClientRect();
  15337. // Used to ensure timeout re-tries don't fire when another extend
  15338. // happened in the meantime (clearTimeout isn't reliable -- at
  15339. // least on Chrome, the timeouts still happen even when cleared,
  15340. // if the clear happens after their scheduled firing time).
  15341. var counter = 0;
  15342. function extend(e) {
  15343. var curCount = ++counter;
  15344. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  15345. if (!cur) { return }
  15346. if (cmp(cur, lastPos) != 0) {
  15347. cm.curOp.focus = activeElt();
  15348. extendTo(cur);
  15349. var visible = visibleLines(display, doc);
  15350. if (cur.line >= visible.to || cur.line < visible.from)
  15351. { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
  15352. } else {
  15353. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  15354. if (outside) { setTimeout(operation(cm, function () {
  15355. if (counter != curCount) { return }
  15356. display.scroller.scrollTop += outside;
  15357. extend(e);
  15358. }), 50); }
  15359. }
  15360. }
  15361. function done(e) {
  15362. cm.state.selectingText = false;
  15363. counter = Infinity;
  15364. e_preventDefault(e);
  15365. display.input.focus();
  15366. off(display.wrapper.ownerDocument, "mousemove", move);
  15367. off(display.wrapper.ownerDocument, "mouseup", up);
  15368. doc.history.lastSelOrigin = null;
  15369. }
  15370. var move = operation(cm, function (e) {
  15371. if (!e_button(e)) { done(e); }
  15372. else { extend(e); }
  15373. });
  15374. var up = operation(cm, done);
  15375. cm.state.selectingText = up;
  15376. on(display.wrapper.ownerDocument, "mousemove", move);
  15377. on(display.wrapper.ownerDocument, "mouseup", up);
  15378. }
  15379. // Used when mouse-selecting to adjust the anchor to the proper side
  15380. // of a bidi jump depending on the visual position of the head.
  15381. function bidiSimplify(cm, range$$1) {
  15382. var anchor = range$$1.anchor;
  15383. var head = range$$1.head;
  15384. var anchorLine = getLine(cm.doc, anchor.line);
  15385. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range$$1 }
  15386. var order = getOrder(anchorLine);
  15387. if (!order) { return range$$1 }
  15388. var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
  15389. if (part.from != anchor.ch && part.to != anchor.ch) { return range$$1 }
  15390. var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);
  15391. if (boundary == 0 || boundary == order.length) { return range$$1 }
  15392. // Compute the relative visual position of the head compared to the
  15393. // anchor (<0 is to the left, >0 to the right)
  15394. var leftSide;
  15395. if (head.line != anchor.line) {
  15396. leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  15397. } else {
  15398. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  15399. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  15400. if (headIndex == boundary - 1 || headIndex == boundary)
  15401. { leftSide = dir < 0; }
  15402. else
  15403. { leftSide = dir > 0; }
  15404. }
  15405. var usePart = order[boundary + (leftSide ? -1 : 0)];
  15406. var from = leftSide == (usePart.level == 1);
  15407. var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
  15408. return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head)
  15409. }
  15410. // Determines whether an event happened in the gutter, and fires the
  15411. // handlers for the corresponding event.
  15412. function gutterEvent(cm, e, type, prevent) {
  15413. var mX, mY;
  15414. if (e.touches) {
  15415. mX = e.touches[0].clientX;
  15416. mY = e.touches[0].clientY;
  15417. } else {
  15418. try { mX = e.clientX; mY = e.clientY; }
  15419. catch(e) { return false }
  15420. }
  15421. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
  15422. if (prevent) { e_preventDefault(e); }
  15423. var display = cm.display;
  15424. var lineBox = display.lineDiv.getBoundingClientRect();
  15425. if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
  15426. mY -= lineBox.top - display.viewOffset;
  15427. for (var i = 0; i < cm.options.gutters.length; ++i) {
  15428. var g = display.gutters.childNodes[i];
  15429. if (g && g.getBoundingClientRect().right >= mX) {
  15430. var line = lineAtHeight(cm.doc, mY);
  15431. var gutter = cm.options.gutters[i];
  15432. signal(cm, type, cm, line, gutter, e);
  15433. return e_defaultPrevented(e)
  15434. }
  15435. }
  15436. }
  15437. function clickInGutter(cm, e) {
  15438. return gutterEvent(cm, e, "gutterClick", true)
  15439. }
  15440. // CONTEXT MENU HANDLING
  15441. // To make the context menu work, we need to briefly unhide the
  15442. // textarea (making it as unobtrusive as possible) to let the
  15443. // right-click take effect on it.
  15444. function onContextMenu(cm, e) {
  15445. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
  15446. if (signalDOMEvent(cm, e, "contextmenu")) { return }
  15447. cm.display.input.onContextMenu(e);
  15448. }
  15449. function contextMenuInGutter(cm, e) {
  15450. if (!hasHandler(cm, "gutterContextMenu")) { return false }
  15451. return gutterEvent(cm, e, "gutterContextMenu", false)
  15452. }
  15453. function themeChanged(cm) {
  15454. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
  15455. cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  15456. clearCaches(cm);
  15457. }
  15458. var Init = {toString: function(){return "CodeMirror.Init"}};
  15459. var defaults = {};
  15460. var optionHandlers = {};
  15461. function defineOptions(CodeMirror) {
  15462. var optionHandlers = CodeMirror.optionHandlers;
  15463. function option(name, deflt, handle, notOnInit) {
  15464. CodeMirror.defaults[name] = deflt;
  15465. if (handle) { optionHandlers[name] =
  15466. notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }
  15467. }
  15468. CodeMirror.defineOption = option;
  15469. // Passed to option handlers when there is no old value.
  15470. CodeMirror.Init = Init;
  15471. // These two are, on init, called from the constructor because they
  15472. // have to be initialized before the editor can start at all.
  15473. option("value", "", function (cm, val) { return cm.setValue(val); }, true);
  15474. option("mode", null, function (cm, val) {
  15475. cm.doc.modeOption = val;
  15476. loadMode(cm);
  15477. }, true);
  15478. option("indentUnit", 2, loadMode, true);
  15479. option("indentWithTabs", false);
  15480. option("smartIndent", true);
  15481. option("tabSize", 4, function (cm) {
  15482. resetModeState(cm);
  15483. clearCaches(cm);
  15484. regChange(cm);
  15485. }, true);
  15486. option("lineSeparator", null, function (cm, val) {
  15487. cm.doc.lineSep = val;
  15488. if (!val) { return }
  15489. var newBreaks = [], lineNo = cm.doc.first;
  15490. cm.doc.iter(function (line) {
  15491. for (var pos = 0;;) {
  15492. var found = line.text.indexOf(val, pos);
  15493. if (found == -1) { break }
  15494. pos = found + val.length;
  15495. newBreaks.push(Pos(lineNo, found));
  15496. }
  15497. lineNo++;
  15498. });
  15499. for (var i = newBreaks.length - 1; i >= 0; i--)
  15500. { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
  15501. });
  15502. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
  15503. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
  15504. if (old != Init) { cm.refresh(); }
  15505. });
  15506. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
  15507. option("electricChars", true);
  15508. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  15509. throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
  15510. }, true);
  15511. option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
  15512. option("rtlMoveVisually", !windows);
  15513. option("wholeLineUpdateBefore", true);
  15514. option("theme", "default", function (cm) {
  15515. themeChanged(cm);
  15516. guttersChanged(cm);
  15517. }, true);
  15518. option("keyMap", "default", function (cm, val, old) {
  15519. var next = getKeyMap(val);
  15520. var prev = old != Init && getKeyMap(old);
  15521. if (prev && prev.detach) { prev.detach(cm, next); }
  15522. if (next.attach) { next.attach(cm, prev || null); }
  15523. });
  15524. option("extraKeys", null);
  15525. option("configureMouse", null);
  15526. option("lineWrapping", false, wrappingChanged, true);
  15527. option("gutters", [], function (cm) {
  15528. setGuttersForLineNumbers(cm.options);
  15529. guttersChanged(cm);
  15530. }, true);
  15531. option("fixedGutter", true, function (cm, val) {
  15532. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  15533. cm.refresh();
  15534. }, true);
  15535. option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true);
  15536. option("scrollbarStyle", "native", function (cm) {
  15537. initScrollbars(cm);
  15538. updateScrollbars(cm);
  15539. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  15540. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  15541. }, true);
  15542. option("lineNumbers", false, function (cm) {
  15543. setGuttersForLineNumbers(cm.options);
  15544. guttersChanged(cm);
  15545. }, true);
  15546. option("firstLineNumber", 1, guttersChanged, true);
  15547. option("lineNumberFormatter", function (integer) { return integer; }, guttersChanged, true);
  15548. option("showCursorWhenSelecting", false, updateSelection, true);
  15549. option("resetSelectionOnContextMenu", true);
  15550. option("lineWiseCopyCut", true);
  15551. option("pasteLinesPerSelection", true);
  15552. option("readOnly", false, function (cm, val) {
  15553. if (val == "nocursor") {
  15554. onBlur(cm);
  15555. cm.display.input.blur();
  15556. }
  15557. cm.display.input.readOnlyChanged(val);
  15558. });
  15559. option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
  15560. option("dragDrop", true, dragDropChanged);
  15561. option("allowDropFileTypes", null);
  15562. option("cursorBlinkRate", 530);
  15563. option("cursorScrollMargin", 0);
  15564. option("cursorHeight", 1, updateSelection, true);
  15565. option("singleCursorHeightPerLine", true, updateSelection, true);
  15566. option("workTime", 100);
  15567. option("workDelay", 100);
  15568. option("flattenSpans", true, resetModeState, true);
  15569. option("addModeClass", false, resetModeState, true);
  15570. option("pollInterval", 100);
  15571. option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });
  15572. option("historyEventDelay", 1250);
  15573. option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true);
  15574. option("maxHighlightLength", 10000, resetModeState, true);
  15575. option("moveInputWithCursor", true, function (cm, val) {
  15576. if (!val) { cm.display.input.resetPosition(); }
  15577. });
  15578. option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; });
  15579. option("autofocus", null);
  15580. option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true);
  15581. }
  15582. function guttersChanged(cm) {
  15583. updateGutters(cm);
  15584. regChange(cm);
  15585. alignHorizontally(cm);
  15586. }
  15587. function dragDropChanged(cm, value, old) {
  15588. var wasOn = old && old != Init;
  15589. if (!value != !wasOn) {
  15590. var funcs = cm.display.dragFunctions;
  15591. var toggle = value ? on : off;
  15592. toggle(cm.display.scroller, "dragstart", funcs.start);
  15593. toggle(cm.display.scroller, "dragenter", funcs.enter);
  15594. toggle(cm.display.scroller, "dragover", funcs.over);
  15595. toggle(cm.display.scroller, "dragleave", funcs.leave);
  15596. toggle(cm.display.scroller, "drop", funcs.drop);
  15597. }
  15598. }
  15599. function wrappingChanged(cm) {
  15600. if (cm.options.lineWrapping) {
  15601. addClass(cm.display.wrapper, "CodeMirror-wrap");
  15602. cm.display.sizer.style.minWidth = "";
  15603. cm.display.sizerWidth = null;
  15604. } else {
  15605. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  15606. findMaxLine(cm);
  15607. }
  15608. estimateLineHeights(cm);
  15609. regChange(cm);
  15610. clearCaches(cm);
  15611. setTimeout(function () { return updateScrollbars(cm); }, 100);
  15612. }
  15613. // A CodeMirror instance represents an editor. This is the object
  15614. // that user code is usually dealing with.
  15615. function CodeMirror$1(place, options) {
  15616. var this$1 = this;
  15617. if (!(this instanceof CodeMirror$1)) { return new CodeMirror$1(place, options) }
  15618. this.options = options = options ? copyObj(options) : {};
  15619. // Determine effective options based on given values and defaults.
  15620. copyObj(defaults, options, false);
  15621. setGuttersForLineNumbers(options);
  15622. var doc = options.value;
  15623. if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }
  15624. this.doc = doc;
  15625. var input = new CodeMirror$1.inputStyles[options.inputStyle](this);
  15626. var display = this.display = new Display(place, doc, input);
  15627. display.wrapper.CodeMirror = this;
  15628. updateGutters(this);
  15629. themeChanged(this);
  15630. if (options.lineWrapping)
  15631. { this.display.wrapper.className += " CodeMirror-wrap"; }
  15632. initScrollbars(this);
  15633. this.state = {
  15634. keyMaps: [], // stores maps added by addKeyMap
  15635. overlays: [], // highlighting overlays, as added by addOverlay
  15636. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  15637. overwrite: false,
  15638. delayingBlurEvent: false,
  15639. focused: false,
  15640. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  15641. pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
  15642. selectingText: false,
  15643. draggingText: false,
  15644. highlight: new Delayed(), // stores highlight worker timeout
  15645. keySeq: null, // Unfinished key sequence
  15646. specialChars: null
  15647. };
  15648. if (options.autofocus && !mobile) { display.input.focus(); }
  15649. // Override magic textarea content restore that IE sometimes does
  15650. // on our hidden textarea on reload
  15651. if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }
  15652. registerEventHandlers(this);
  15653. ensureGlobalHandlers();
  15654. startOperation(this);
  15655. this.curOp.forceUpdate = true;
  15656. attachDoc(this, doc);
  15657. if ((options.autofocus && !mobile) || this.hasFocus())
  15658. { setTimeout(bind(onFocus, this), 20); }
  15659. else
  15660. { onBlur(this); }
  15661. for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
  15662. { optionHandlers[opt](this$1, options[opt], Init); } }
  15663. maybeUpdateLineNumberWidth(this);
  15664. if (options.finishInit) { options.finishInit(this); }
  15665. for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1); }
  15666. endOperation(this);
  15667. // Suppress optimizelegibility in Webkit, since it breaks text
  15668. // measuring on line wrapping boundaries.
  15669. if (webkit && options.lineWrapping &&
  15670. getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
  15671. { display.lineDiv.style.textRendering = "auto"; }
  15672. }
  15673. // The default configuration options.
  15674. CodeMirror$1.defaults = defaults;
  15675. // Functions to run when options are changed.
  15676. CodeMirror$1.optionHandlers = optionHandlers;
  15677. // Attach the necessary event handlers when initializing the editor
  15678. function registerEventHandlers(cm) {
  15679. var d = cm.display;
  15680. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  15681. // Older IE's will not fire a second mousedown for a double click
  15682. if (ie && ie_version < 11)
  15683. { on(d.scroller, "dblclick", operation(cm, function (e) {
  15684. if (signalDOMEvent(cm, e)) { return }
  15685. var pos = posFromMouse(cm, e);
  15686. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
  15687. e_preventDefault(e);
  15688. var word = cm.findWordAt(pos);
  15689. extendSelection(cm.doc, word.anchor, word.head);
  15690. })); }
  15691. else
  15692. { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }
  15693. // Some browsers fire contextmenu *after* opening the menu, at
  15694. // which point we can't mess with it anymore. Context menu is
  15695. // handled in onMouseDown for these browsers.
  15696. if (!captureRightClick) { on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); }
  15697. // Used to suppress mouse event handling when a touch happens
  15698. var touchFinished, prevTouch = {end: 0};
  15699. function finishTouch() {
  15700. if (d.activeTouch) {
  15701. touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);
  15702. prevTouch = d.activeTouch;
  15703. prevTouch.end = +new Date;
  15704. }
  15705. }
  15706. function isMouseLikeTouchEvent(e) {
  15707. if (e.touches.length != 1) { return false }
  15708. var touch = e.touches[0];
  15709. return touch.radiusX <= 1 && touch.radiusY <= 1
  15710. }
  15711. function farAway(touch, other) {
  15712. if (other.left == null) { return true }
  15713. var dx = other.left - touch.left, dy = other.top - touch.top;
  15714. return dx * dx + dy * dy > 20 * 20
  15715. }
  15716. on(d.scroller, "touchstart", function (e) {
  15717. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  15718. d.input.ensurePolled();
  15719. clearTimeout(touchFinished);
  15720. var now = +new Date;
  15721. d.activeTouch = {start: now, moved: false,
  15722. prev: now - prevTouch.end <= 300 ? prevTouch : null};
  15723. if (e.touches.length == 1) {
  15724. d.activeTouch.left = e.touches[0].pageX;
  15725. d.activeTouch.top = e.touches[0].pageY;
  15726. }
  15727. }
  15728. });
  15729. on(d.scroller, "touchmove", function () {
  15730. if (d.activeTouch) { d.activeTouch.moved = true; }
  15731. });
  15732. on(d.scroller, "touchend", function (e) {
  15733. var touch = d.activeTouch;
  15734. if (touch && !eventInWidget(d, e) && touch.left != null &&
  15735. !touch.moved && new Date - touch.start < 300) {
  15736. var pos = cm.coordsChar(d.activeTouch, "page"), range;
  15737. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  15738. { range = new Range(pos, pos); }
  15739. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  15740. { range = cm.findWordAt(pos); }
  15741. else // Triple tap
  15742. { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }
  15743. cm.setSelection(range.anchor, range.head);
  15744. cm.focus();
  15745. e_preventDefault(e);
  15746. }
  15747. finishTouch();
  15748. });
  15749. on(d.scroller, "touchcancel", finishTouch);
  15750. // Sync scrolling between fake scrollbars and real scrollable
  15751. // area, ensure viewport is updated when scrolling.
  15752. on(d.scroller, "scroll", function () {
  15753. if (d.scroller.clientHeight) {
  15754. updateScrollTop(cm, d.scroller.scrollTop);
  15755. setScrollLeft(cm, d.scroller.scrollLeft, true);
  15756. signal(cm, "scroll", cm);
  15757. }
  15758. });
  15759. // Listen to wheel events in order to try and update the viewport on time.
  15760. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); });
  15761. on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); });
  15762. // Prevent wrapper from ever scrolling
  15763. on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
  15764. d.dragFunctions = {
  15765. enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},
  15766. over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
  15767. start: function (e) { return onDragStart(cm, e); },
  15768. drop: operation(cm, onDrop),
  15769. leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
  15770. };
  15771. var inp = d.input.getField();
  15772. on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); });
  15773. on(inp, "keydown", operation(cm, onKeyDown));
  15774. on(inp, "keypress", operation(cm, onKeyPress));
  15775. on(inp, "focus", function (e) { return onFocus(cm, e); });
  15776. on(inp, "blur", function (e) { return onBlur(cm, e); });
  15777. }
  15778. var initHooks = [];
  15779. CodeMirror$1.defineInitHook = function (f) { return initHooks.push(f); };
  15780. // Indent the given line. The how parameter can be "smart",
  15781. // "add"/null, "subtract", or "prev". When aggressive is false
  15782. // (typically set to true for forced single-line indents), empty
  15783. // lines are not indented, and places where the mode returns Pass
  15784. // are left alone.
  15785. function indentLine(cm, n, how, aggressive) {
  15786. var doc = cm.doc, state;
  15787. if (how == null) { how = "add"; }
  15788. if (how == "smart") {
  15789. // Fall back to "prev" when the mode doesn't have an indentation
  15790. // method.
  15791. if (!doc.mode.indent) { how = "prev"; }
  15792. else { state = getContextBefore(cm, n).state; }
  15793. }
  15794. var tabSize = cm.options.tabSize;
  15795. var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
  15796. if (line.stateAfter) { line.stateAfter = null; }
  15797. var curSpaceString = line.text.match(/^\s*/)[0], indentation;
  15798. if (!aggressive && !/\S/.test(line.text)) {
  15799. indentation = 0;
  15800. how = "not";
  15801. } else if (how == "smart") {
  15802. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  15803. if (indentation == Pass || indentation > 150) {
  15804. if (!aggressive) { return }
  15805. how = "prev";
  15806. }
  15807. }
  15808. if (how == "prev") {
  15809. if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }
  15810. else { indentation = 0; }
  15811. } else if (how == "add") {
  15812. indentation = curSpace + cm.options.indentUnit;
  15813. } else if (how == "subtract") {
  15814. indentation = curSpace - cm.options.indentUnit;
  15815. } else if (typeof how == "number") {
  15816. indentation = curSpace + how;
  15817. }
  15818. indentation = Math.max(0, indentation);
  15819. var indentString = "", pos = 0;
  15820. if (cm.options.indentWithTabs)
  15821. { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} }
  15822. if (pos < indentation) { indentString += spaceStr(indentation - pos); }
  15823. if (indentString != curSpaceString) {
  15824. replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  15825. line.stateAfter = null;
  15826. return true
  15827. } else {
  15828. // Ensure that, if the cursor was in the whitespace at the start
  15829. // of the line, it is moved to the end of that space.
  15830. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  15831. var range = doc.sel.ranges[i$1];
  15832. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  15833. var pos$1 = Pos(n, curSpaceString.length);
  15834. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
  15835. break
  15836. }
  15837. }
  15838. }
  15839. }
  15840. // This will be set to a {lineWise: bool, text: [string]} object, so
  15841. // that, when pasting, we know what kind of selections the copied
  15842. // text was made out of.
  15843. var lastCopied = null;
  15844. function setLastCopied(newLastCopied) {
  15845. lastCopied = newLastCopied;
  15846. }
  15847. function applyTextInput(cm, inserted, deleted, sel, origin) {
  15848. var doc = cm.doc;
  15849. cm.display.shift = false;
  15850. if (!sel) { sel = doc.sel; }
  15851. var paste = cm.state.pasteIncoming || origin == "paste";
  15852. var textLines = splitLinesAuto(inserted), multiPaste = null;
  15853. // When pasting N lines into N selections, insert one line per selection
  15854. if (paste && sel.ranges.length > 1) {
  15855. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  15856. if (sel.ranges.length % lastCopied.text.length == 0) {
  15857. multiPaste = [];
  15858. for (var i = 0; i < lastCopied.text.length; i++)
  15859. { multiPaste.push(doc.splitLines(lastCopied.text[i])); }
  15860. }
  15861. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
  15862. multiPaste = map(textLines, function (l) { return [l]; });
  15863. }
  15864. }
  15865. var updateInput;
  15866. // Normal behavior is to insert the new text into every selection
  15867. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  15868. var range$$1 = sel.ranges[i$1];
  15869. var from = range$$1.from(), to = range$$1.to();
  15870. if (range$$1.empty()) {
  15871. if (deleted && deleted > 0) // Handle deletion
  15872. { from = Pos(from.line, from.ch - deleted); }
  15873. else if (cm.state.overwrite && !paste) // Handle overwrite
  15874. { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
  15875. else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
  15876. { from = to = Pos(from.line, 0); }
  15877. }
  15878. updateInput = cm.curOp.updateInput;
  15879. var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  15880. origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
  15881. makeChange(cm.doc, changeEvent);
  15882. signalLater(cm, "inputRead", cm, changeEvent);
  15883. }
  15884. if (inserted && !paste)
  15885. { triggerElectric(cm, inserted); }
  15886. ensureCursorVisible(cm);
  15887. cm.curOp.updateInput = updateInput;
  15888. cm.curOp.typing = true;
  15889. cm.state.pasteIncoming = cm.state.cutIncoming = false;
  15890. }
  15891. function handlePaste(e, cm) {
  15892. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  15893. if (pasted) {
  15894. e.preventDefault();
  15895. if (!cm.isReadOnly() && !cm.options.disableInput)
  15896. { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
  15897. return true
  15898. }
  15899. }
  15900. function triggerElectric(cm, inserted) {
  15901. // When an 'electric' character is inserted, immediately trigger a reindent
  15902. if (!cm.options.electricChars || !cm.options.smartIndent) { return }
  15903. var sel = cm.doc.sel;
  15904. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  15905. var range$$1 = sel.ranges[i];
  15906. if (range$$1.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range$$1.head.line)) { continue }
  15907. var mode = cm.getModeAt(range$$1.head);
  15908. var indented = false;
  15909. if (mode.electricChars) {
  15910. for (var j = 0; j < mode.electricChars.length; j++)
  15911. { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  15912. indented = indentLine(cm, range$$1.head.line, "smart");
  15913. break
  15914. } }
  15915. } else if (mode.electricInput) {
  15916. if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch)))
  15917. { indented = indentLine(cm, range$$1.head.line, "smart"); }
  15918. }
  15919. if (indented) { signalLater(cm, "electricInput", cm, range$$1.head.line); }
  15920. }
  15921. }
  15922. function copyableRanges(cm) {
  15923. var text = [], ranges = [];
  15924. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  15925. var line = cm.doc.sel.ranges[i].head.line;
  15926. var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
  15927. ranges.push(lineRange);
  15928. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  15929. }
  15930. return {text: text, ranges: ranges}
  15931. }
  15932. function disableBrowserMagic(field, spellcheck) {
  15933. field.setAttribute("autocorrect", "off");
  15934. field.setAttribute("autocapitalize", "off");
  15935. field.setAttribute("spellcheck", !!spellcheck);
  15936. }
  15937. function hiddenTextarea() {
  15938. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
  15939. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  15940. // The textarea is kept positioned near the cursor to prevent the
  15941. // fact that it'll be scrolled into view on input from scrolling
  15942. // our fake cursor out of view. On webkit, when wrap=off, paste is
  15943. // very slow. So make the area wide instead.
  15944. if (webkit) { te.style.width = "1000px"; }
  15945. else { te.setAttribute("wrap", "off"); }
  15946. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  15947. if (ios) { te.style.border = "1px solid black"; }
  15948. disableBrowserMagic(te);
  15949. return div
  15950. }
  15951. // The publicly visible API. Note that methodOp(f) means
  15952. // 'wrap f in an operation, performed on its `this` parameter'.
  15953. // This is not the complete set of editor methods. Most of the
  15954. // methods defined on the Doc type are also injected into
  15955. // CodeMirror.prototype, for backwards compatibility and
  15956. // convenience.
  15957. var addEditorMethods = function(CodeMirror) {
  15958. var optionHandlers = CodeMirror.optionHandlers;
  15959. var helpers = CodeMirror.helpers = {};
  15960. CodeMirror.prototype = {
  15961. constructor: CodeMirror,
  15962. focus: function(){window.focus(); this.display.input.focus();},
  15963. setOption: function(option, value) {
  15964. var options = this.options, old = options[option];
  15965. if (options[option] == value && option != "mode") { return }
  15966. options[option] = value;
  15967. if (optionHandlers.hasOwnProperty(option))
  15968. { operation(this, optionHandlers[option])(this, value, old); }
  15969. signal(this, "optionChange", this, option);
  15970. },
  15971. getOption: function(option) {return this.options[option]},
  15972. getDoc: function() {return this.doc},
  15973. addKeyMap: function(map$$1, bottom) {
  15974. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1));
  15975. },
  15976. removeKeyMap: function(map$$1) {
  15977. var maps = this.state.keyMaps;
  15978. for (var i = 0; i < maps.length; ++i)
  15979. { if (maps[i] == map$$1 || maps[i].name == map$$1) {
  15980. maps.splice(i, 1);
  15981. return true
  15982. } }
  15983. },
  15984. addOverlay: methodOp(function(spec, options) {
  15985. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
  15986. if (mode.startState) { throw new Error("Overlays may not be stateful.") }
  15987. insertSorted(this.state.overlays,
  15988. {mode: mode, modeSpec: spec, opaque: options && options.opaque,
  15989. priority: (options && options.priority) || 0},
  15990. function (overlay) { return overlay.priority; });
  15991. this.state.modeGen++;
  15992. regChange(this);
  15993. }),
  15994. removeOverlay: methodOp(function(spec) {
  15995. var this$1 = this;
  15996. var overlays = this.state.overlays;
  15997. for (var i = 0; i < overlays.length; ++i) {
  15998. var cur = overlays[i].modeSpec;
  15999. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  16000. overlays.splice(i, 1);
  16001. this$1.state.modeGen++;
  16002. regChange(this$1);
  16003. return
  16004. }
  16005. }
  16006. }),
  16007. indentLine: methodOp(function(n, dir, aggressive) {
  16008. if (typeof dir != "string" && typeof dir != "number") {
  16009. if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; }
  16010. else { dir = dir ? "add" : "subtract"; }
  16011. }
  16012. if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }
  16013. }),
  16014. indentSelection: methodOp(function(how) {
  16015. var this$1 = this;
  16016. var ranges = this.doc.sel.ranges, end = -1;
  16017. for (var i = 0; i < ranges.length; i++) {
  16018. var range$$1 = ranges[i];
  16019. if (!range$$1.empty()) {
  16020. var from = range$$1.from(), to = range$$1.to();
  16021. var start = Math.max(end, from.line);
  16022. end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  16023. for (var j = start; j < end; ++j)
  16024. { indentLine(this$1, j, how); }
  16025. var newRanges = this$1.doc.sel.ranges;
  16026. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
  16027. { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }
  16028. } else if (range$$1.head.line > end) {
  16029. indentLine(this$1, range$$1.head.line, how, true);
  16030. end = range$$1.head.line;
  16031. if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1); }
  16032. }
  16033. }
  16034. }),
  16035. // Fetch the parser token for a given character. Useful for hacks
  16036. // that want to inspect the mode state (say, for completion).
  16037. getTokenAt: function(pos, precise) {
  16038. return takeToken(this, pos, precise)
  16039. },
  16040. getLineTokens: function(line, precise) {
  16041. return takeToken(this, Pos(line), precise, true)
  16042. },
  16043. getTokenTypeAt: function(pos) {
  16044. pos = clipPos(this.doc, pos);
  16045. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  16046. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
  16047. var type;
  16048. if (ch == 0) { type = styles[2]; }
  16049. else { for (;;) {
  16050. var mid = (before + after) >> 1;
  16051. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }
  16052. else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }
  16053. else { type = styles[mid * 2 + 2]; break }
  16054. } }
  16055. var cut = type ? type.indexOf("overlay ") : -1;
  16056. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
  16057. },
  16058. getModeAt: function(pos) {
  16059. var mode = this.doc.mode;
  16060. if (!mode.innerMode) { return mode }
  16061. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
  16062. },
  16063. getHelper: function(pos, type) {
  16064. return this.getHelpers(pos, type)[0]
  16065. },
  16066. getHelpers: function(pos, type) {
  16067. var this$1 = this;
  16068. var found = [];
  16069. if (!helpers.hasOwnProperty(type)) { return found }
  16070. var help = helpers[type], mode = this.getModeAt(pos);
  16071. if (typeof mode[type] == "string") {
  16072. if (help[mode[type]]) { found.push(help[mode[type]]); }
  16073. } else if (mode[type]) {
  16074. for (var i = 0; i < mode[type].length; i++) {
  16075. var val = help[mode[type][i]];
  16076. if (val) { found.push(val); }
  16077. }
  16078. } else if (mode.helperType && help[mode.helperType]) {
  16079. found.push(help[mode.helperType]);
  16080. } else if (help[mode.name]) {
  16081. found.push(help[mode.name]);
  16082. }
  16083. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  16084. var cur = help._global[i$1];
  16085. if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
  16086. { found.push(cur.val); }
  16087. }
  16088. return found
  16089. },
  16090. getStateAfter: function(line, precise) {
  16091. var doc = this.doc;
  16092. line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
  16093. return getContextBefore(this, line + 1, precise).state
  16094. },
  16095. cursorCoords: function(start, mode) {
  16096. var pos, range$$1 = this.doc.sel.primary();
  16097. if (start == null) { pos = range$$1.head; }
  16098. else if (typeof start == "object") { pos = clipPos(this.doc, start); }
  16099. else { pos = start ? range$$1.from() : range$$1.to(); }
  16100. return cursorCoords(this, pos, mode || "page")
  16101. },
  16102. charCoords: function(pos, mode) {
  16103. return charCoords(this, clipPos(this.doc, pos), mode || "page")
  16104. },
  16105. coordsChar: function(coords, mode) {
  16106. coords = fromCoordSystem(this, coords, mode || "page");
  16107. return coordsChar(this, coords.left, coords.top)
  16108. },
  16109. lineAtHeight: function(height, mode) {
  16110. height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
  16111. return lineAtHeight(this.doc, height + this.display.viewOffset)
  16112. },
  16113. heightAtLine: function(line, mode, includeWidgets) {
  16114. var end = false, lineObj;
  16115. if (typeof line == "number") {
  16116. var last = this.doc.first + this.doc.size - 1;
  16117. if (line < this.doc.first) { line = this.doc.first; }
  16118. else if (line > last) { line = last; end = true; }
  16119. lineObj = getLine(this.doc, line);
  16120. } else {
  16121. lineObj = line;
  16122. }
  16123. return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
  16124. (end ? this.doc.height - heightAtLine(lineObj) : 0)
  16125. },
  16126. defaultTextHeight: function() { return textHeight(this.display) },
  16127. defaultCharWidth: function() { return charWidth(this.display) },
  16128. getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
  16129. addWidget: function(pos, node, scroll, vert, horiz) {
  16130. var display = this.display;
  16131. pos = cursorCoords(this, clipPos(this.doc, pos));
  16132. var top = pos.bottom, left = pos.left;
  16133. node.style.position = "absolute";
  16134. node.setAttribute("cm-ignore-events", "true");
  16135. this.display.input.setUneditable(node);
  16136. display.sizer.appendChild(node);
  16137. if (vert == "over") {
  16138. top = pos.top;
  16139. } else if (vert == "above" || vert == "near") {
  16140. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  16141. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  16142. // Default to positioning above (if specified and possible); otherwise default to positioning below
  16143. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
  16144. { top = pos.top - node.offsetHeight; }
  16145. else if (pos.bottom + node.offsetHeight <= vspace)
  16146. { top = pos.bottom; }
  16147. if (left + node.offsetWidth > hspace)
  16148. { left = hspace - node.offsetWidth; }
  16149. }
  16150. node.style.top = top + "px";
  16151. node.style.left = node.style.right = "";
  16152. if (horiz == "right") {
  16153. left = display.sizer.clientWidth - node.offsetWidth;
  16154. node.style.right = "0px";
  16155. } else {
  16156. if (horiz == "left") { left = 0; }
  16157. else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }
  16158. node.style.left = left + "px";
  16159. }
  16160. if (scroll)
  16161. { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }
  16162. },
  16163. triggerOnKeyDown: methodOp(onKeyDown),
  16164. triggerOnKeyPress: methodOp(onKeyPress),
  16165. triggerOnKeyUp: onKeyUp,
  16166. triggerOnMouseDown: methodOp(onMouseDown),
  16167. execCommand: function(cmd) {
  16168. if (commands.hasOwnProperty(cmd))
  16169. { return commands[cmd].call(null, this) }
  16170. },
  16171. triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
  16172. findPosH: function(from, amount, unit, visually) {
  16173. var this$1 = this;
  16174. var dir = 1;
  16175. if (amount < 0) { dir = -1; amount = -amount; }
  16176. var cur = clipPos(this.doc, from);
  16177. for (var i = 0; i < amount; ++i) {
  16178. cur = findPosH(this$1.doc, cur, dir, unit, visually);
  16179. if (cur.hitSide) { break }
  16180. }
  16181. return cur
  16182. },
  16183. moveH: methodOp(function(dir, unit) {
  16184. var this$1 = this;
  16185. this.extendSelectionsBy(function (range$$1) {
  16186. if (this$1.display.shift || this$1.doc.extend || range$$1.empty())
  16187. { return findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually) }
  16188. else
  16189. { return dir < 0 ? range$$1.from() : range$$1.to() }
  16190. }, sel_move);
  16191. }),
  16192. deleteH: methodOp(function(dir, unit) {
  16193. var sel = this.doc.sel, doc = this.doc;
  16194. if (sel.somethingSelected())
  16195. { doc.replaceSelection("", null, "+delete"); }
  16196. else
  16197. { deleteNearSelection(this, function (range$$1) {
  16198. var other = findPosH(doc, range$$1.head, dir, unit, false);
  16199. return dir < 0 ? {from: other, to: range$$1.head} : {from: range$$1.head, to: other}
  16200. }); }
  16201. }),
  16202. findPosV: function(from, amount, unit, goalColumn) {
  16203. var this$1 = this;
  16204. var dir = 1, x = goalColumn;
  16205. if (amount < 0) { dir = -1; amount = -amount; }
  16206. var cur = clipPos(this.doc, from);
  16207. for (var i = 0; i < amount; ++i) {
  16208. var coords = cursorCoords(this$1, cur, "div");
  16209. if (x == null) { x = coords.left; }
  16210. else { coords.left = x; }
  16211. cur = findPosV(this$1, coords, dir, unit);
  16212. if (cur.hitSide) { break }
  16213. }
  16214. return cur
  16215. },
  16216. moveV: methodOp(function(dir, unit) {
  16217. var this$1 = this;
  16218. var doc = this.doc, goals = [];
  16219. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
  16220. doc.extendSelectionsBy(function (range$$1) {
  16221. if (collapse)
  16222. { return dir < 0 ? range$$1.from() : range$$1.to() }
  16223. var headPos = cursorCoords(this$1, range$$1.head, "div");
  16224. if (range$$1.goalColumn != null) { headPos.left = range$$1.goalColumn; }
  16225. goals.push(headPos.left);
  16226. var pos = findPosV(this$1, headPos, dir, unit);
  16227. if (unit == "page" && range$$1 == doc.sel.primary())
  16228. { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); }
  16229. return pos
  16230. }, sel_move);
  16231. if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
  16232. { doc.sel.ranges[i].goalColumn = goals[i]; } }
  16233. }),
  16234. // Find the word at the given position (as returned by coordsChar).
  16235. findWordAt: function(pos) {
  16236. var doc = this.doc, line = getLine(doc, pos.line).text;
  16237. var start = pos.ch, end = pos.ch;
  16238. if (line) {
  16239. var helper = this.getHelper(pos, "wordChars");
  16240. if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; }
  16241. var startChar = line.charAt(start);
  16242. var check = isWordChar(startChar, helper)
  16243. ? function (ch) { return isWordChar(ch, helper); }
  16244. : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
  16245. : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); };
  16246. while (start > 0 && check(line.charAt(start - 1))) { --start; }
  16247. while (end < line.length && check(line.charAt(end))) { ++end; }
  16248. }
  16249. return new Range(Pos(pos.line, start), Pos(pos.line, end))
  16250. },
  16251. toggleOverwrite: function(value) {
  16252. if (value != null && value == this.state.overwrite) { return }
  16253. if (this.state.overwrite = !this.state.overwrite)
  16254. { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  16255. else
  16256. { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  16257. signal(this, "overwriteToggle", this, this.state.overwrite);
  16258. },
  16259. hasFocus: function() { return this.display.input.getField() == activeElt() },
  16260. isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
  16261. scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
  16262. getScrollInfo: function() {
  16263. var scroller = this.display.scroller;
  16264. return {left: scroller.scrollLeft, top: scroller.scrollTop,
  16265. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  16266. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  16267. clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
  16268. },
  16269. scrollIntoView: methodOp(function(range$$1, margin) {
  16270. if (range$$1 == null) {
  16271. range$$1 = {from: this.doc.sel.primary().head, to: null};
  16272. if (margin == null) { margin = this.options.cursorScrollMargin; }
  16273. } else if (typeof range$$1 == "number") {
  16274. range$$1 = {from: Pos(range$$1, 0), to: null};
  16275. } else if (range$$1.from == null) {
  16276. range$$1 = {from: range$$1, to: null};
  16277. }
  16278. if (!range$$1.to) { range$$1.to = range$$1.from; }
  16279. range$$1.margin = margin || 0;
  16280. if (range$$1.from.line != null) {
  16281. scrollToRange(this, range$$1);
  16282. } else {
  16283. scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);
  16284. }
  16285. }),
  16286. setSize: methodOp(function(width, height) {
  16287. var this$1 = this;
  16288. var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; };
  16289. if (width != null) { this.display.wrapper.style.width = interpret(width); }
  16290. if (height != null) { this.display.wrapper.style.height = interpret(height); }
  16291. if (this.options.lineWrapping) { clearLineMeasurementCache(this); }
  16292. var lineNo$$1 = this.display.viewFrom;
  16293. this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {
  16294. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
  16295. { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo$$1, "widget"); break } } }
  16296. ++lineNo$$1;
  16297. });
  16298. this.curOp.forceUpdate = true;
  16299. signal(this, "refresh", this);
  16300. }),
  16301. operation: function(f){return runInOp(this, f)},
  16302. startOperation: function(){return startOperation(this)},
  16303. endOperation: function(){return endOperation(this)},
  16304. refresh: methodOp(function() {
  16305. var oldHeight = this.display.cachedTextHeight;
  16306. regChange(this);
  16307. this.curOp.forceUpdate = true;
  16308. clearCaches(this);
  16309. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  16310. updateGutterSpace(this);
  16311. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
  16312. { estimateLineHeights(this); }
  16313. signal(this, "refresh", this);
  16314. }),
  16315. swapDoc: methodOp(function(doc) {
  16316. var old = this.doc;
  16317. old.cm = null;
  16318. attachDoc(this, doc);
  16319. clearCaches(this);
  16320. this.display.input.reset();
  16321. scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
  16322. this.curOp.forceScroll = true;
  16323. signalLater(this, "swapDoc", this, old);
  16324. return old
  16325. }),
  16326. getInputField: function(){return this.display.input.getField()},
  16327. getWrapperElement: function(){return this.display.wrapper},
  16328. getScrollerElement: function(){return this.display.scroller},
  16329. getGutterElement: function(){return this.display.gutters}
  16330. };
  16331. eventMixin(CodeMirror);
  16332. CodeMirror.registerHelper = function(type, name, value) {
  16333. if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }
  16334. helpers[type][name] = value;
  16335. };
  16336. CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
  16337. CodeMirror.registerHelper(type, name, value);
  16338. helpers[type]._global.push({pred: predicate, val: value});
  16339. };
  16340. };
  16341. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  16342. // right), unit can be "char", "column" (like char, but doesn't
  16343. // cross line boundaries), "word" (across next word), or "group" (to
  16344. // the start of next group of word or non-word-non-whitespace
  16345. // chars). The visually param controls whether, in right-to-left
  16346. // text, direction 1 means to move towards the next index in the
  16347. // string, or towards the character to the right of the current
  16348. // position. The resulting position will have a hitSide=true
  16349. // property if it reached the end of the document.
  16350. function findPosH(doc, pos, dir, unit, visually) {
  16351. var oldPos = pos;
  16352. var origDir = dir;
  16353. var lineObj = getLine(doc, pos.line);
  16354. function findNextLine() {
  16355. var l = pos.line + dir;
  16356. if (l < doc.first || l >= doc.first + doc.size) { return false }
  16357. pos = new Pos(l, pos.ch, pos.sticky);
  16358. return lineObj = getLine(doc, l)
  16359. }
  16360. function moveOnce(boundToLine) {
  16361. var next;
  16362. if (visually) {
  16363. next = moveVisually(doc.cm, lineObj, pos, dir);
  16364. } else {
  16365. next = moveLogically(lineObj, pos, dir);
  16366. }
  16367. if (next == null) {
  16368. if (!boundToLine && findNextLine())
  16369. { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
  16370. else
  16371. { return false }
  16372. } else {
  16373. pos = next;
  16374. }
  16375. return true
  16376. }
  16377. if (unit == "char") {
  16378. moveOnce();
  16379. } else if (unit == "column") {
  16380. moveOnce(true);
  16381. } else if (unit == "word" || unit == "group") {
  16382. var sawType = null, group = unit == "group";
  16383. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
  16384. for (var first = true;; first = false) {
  16385. if (dir < 0 && !moveOnce(!first)) { break }
  16386. var cur = lineObj.text.charAt(pos.ch) || "\n";
  16387. var type = isWordChar(cur, helper) ? "w"
  16388. : group && cur == "\n" ? "n"
  16389. : !group || /\s/.test(cur) ? null
  16390. : "p";
  16391. if (group && !first && !type) { type = "s"; }
  16392. if (sawType && sawType != type) {
  16393. if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";}
  16394. break
  16395. }
  16396. if (type) { sawType = type; }
  16397. if (dir > 0 && !moveOnce(!first)) { break }
  16398. }
  16399. }
  16400. var result = skipAtomic(doc, pos, oldPos, origDir, true);
  16401. if (equalCursorPos(oldPos, result)) { result.hitSide = true; }
  16402. return result
  16403. }
  16404. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  16405. // "page" or "line". The resulting position will have a hitSide=true
  16406. // property if it reached the end of the document.
  16407. function findPosV(cm, pos, dir, unit) {
  16408. var doc = cm.doc, x = pos.left, y;
  16409. if (unit == "page") {
  16410. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
  16411. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  16412. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  16413. } else if (unit == "line") {
  16414. y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  16415. }
  16416. var target;
  16417. for (;;) {
  16418. target = coordsChar(cm, x, y);
  16419. if (!target.outside) { break }
  16420. if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
  16421. y += dir * 5;
  16422. }
  16423. return target
  16424. }
  16425. // CONTENTEDITABLE INPUT STYLE
  16426. var ContentEditableInput = function(cm) {
  16427. this.cm = cm;
  16428. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  16429. this.polling = new Delayed();
  16430. this.composing = null;
  16431. this.gracePeriod = false;
  16432. this.readDOMTimeout = null;
  16433. };
  16434. ContentEditableInput.prototype.init = function (display) {
  16435. var this$1 = this;
  16436. var input = this, cm = input.cm;
  16437. var div = input.div = display.lineDiv;
  16438. disableBrowserMagic(div, cm.options.spellcheck);
  16439. on(div, "paste", function (e) {
  16440. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  16441. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  16442. if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
  16443. });
  16444. on(div, "compositionstart", function (e) {
  16445. this$1.composing = {data: e.data, done: false};
  16446. });
  16447. on(div, "compositionupdate", function (e) {
  16448. if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }
  16449. });
  16450. on(div, "compositionend", function (e) {
  16451. if (this$1.composing) {
  16452. if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }
  16453. this$1.composing.done = true;
  16454. }
  16455. });
  16456. on(div, "touchstart", function () { return input.forceCompositionEnd(); });
  16457. on(div, "input", function () {
  16458. if (!this$1.composing) { this$1.readFromDOMSoon(); }
  16459. });
  16460. function onCopyCut(e) {
  16461. if (signalDOMEvent(cm, e)) { return }
  16462. if (cm.somethingSelected()) {
  16463. setLastCopied({lineWise: false, text: cm.getSelections()});
  16464. if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
  16465. } else if (!cm.options.lineWiseCopyCut) {
  16466. return
  16467. } else {
  16468. var ranges = copyableRanges(cm);
  16469. setLastCopied({lineWise: true, text: ranges.text});
  16470. if (e.type == "cut") {
  16471. cm.operation(function () {
  16472. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  16473. cm.replaceSelection("", null, "cut");
  16474. });
  16475. }
  16476. }
  16477. if (e.clipboardData) {
  16478. e.clipboardData.clearData();
  16479. var content = lastCopied.text.join("\n");
  16480. // iOS exposes the clipboard API, but seems to discard content inserted into it
  16481. e.clipboardData.setData("Text", content);
  16482. if (e.clipboardData.getData("Text") == content) {
  16483. e.preventDefault();
  16484. return
  16485. }
  16486. }
  16487. // Old-fashioned briefly-focus-a-textarea hack
  16488. var kludge = hiddenTextarea(), te = kludge.firstChild;
  16489. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  16490. te.value = lastCopied.text.join("\n");
  16491. var hadFocus = document.activeElement;
  16492. selectInput(te);
  16493. setTimeout(function () {
  16494. cm.display.lineSpace.removeChild(kludge);
  16495. hadFocus.focus();
  16496. if (hadFocus == div) { input.showPrimarySelection(); }
  16497. }, 50);
  16498. }
  16499. on(div, "copy", onCopyCut);
  16500. on(div, "cut", onCopyCut);
  16501. };
  16502. ContentEditableInput.prototype.prepareSelection = function () {
  16503. var result = prepareSelection(this.cm, false);
  16504. result.focus = this.cm.state.focused;
  16505. return result
  16506. };
  16507. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  16508. if (!info || !this.cm.display.view.length) { return }
  16509. if (info.focus || takeFocus) { this.showPrimarySelection(); }
  16510. this.showMultipleSelections(info);
  16511. };
  16512. ContentEditableInput.prototype.showPrimarySelection = function () {
  16513. var sel = window.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
  16514. var from = prim.from(), to = prim.to();
  16515. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  16516. sel.removeAllRanges();
  16517. return
  16518. }
  16519. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  16520. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  16521. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
  16522. cmp(minPos(curAnchor, curFocus), from) == 0 &&
  16523. cmp(maxPos(curAnchor, curFocus), to) == 0)
  16524. { return }
  16525. var view = cm.display.view;
  16526. var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
  16527. {node: view[0].measure.map[2], offset: 0};
  16528. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  16529. if (!end) {
  16530. var measure = view[view.length - 1].measure;
  16531. var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  16532. end = {node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3]};
  16533. }
  16534. if (!start || !end) {
  16535. sel.removeAllRanges();
  16536. return
  16537. }
  16538. var old = sel.rangeCount && sel.getRangeAt(0), rng;
  16539. try { rng = range(start.node, start.offset, end.offset, end.node); }
  16540. catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  16541. if (rng) {
  16542. if (!gecko && cm.state.focused) {
  16543. sel.collapse(start.node, start.offset);
  16544. if (!rng.collapsed) {
  16545. sel.removeAllRanges();
  16546. sel.addRange(rng);
  16547. }
  16548. } else {
  16549. sel.removeAllRanges();
  16550. sel.addRange(rng);
  16551. }
  16552. if (old && sel.anchorNode == null) { sel.addRange(old); }
  16553. else if (gecko) { this.startGracePeriod(); }
  16554. }
  16555. this.rememberSelection();
  16556. };
  16557. ContentEditableInput.prototype.startGracePeriod = function () {
  16558. var this$1 = this;
  16559. clearTimeout(this.gracePeriod);
  16560. this.gracePeriod = setTimeout(function () {
  16561. this$1.gracePeriod = false;
  16562. if (this$1.selectionChanged())
  16563. { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }
  16564. }, 20);
  16565. };
  16566. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  16567. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  16568. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  16569. };
  16570. ContentEditableInput.prototype.rememberSelection = function () {
  16571. var sel = window.getSelection();
  16572. this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
  16573. this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
  16574. };
  16575. ContentEditableInput.prototype.selectionInEditor = function () {
  16576. var sel = window.getSelection();
  16577. if (!sel.rangeCount) { return false }
  16578. var node = sel.getRangeAt(0).commonAncestorContainer;
  16579. return contains(this.div, node)
  16580. };
  16581. ContentEditableInput.prototype.focus = function () {
  16582. if (this.cm.options.readOnly != "nocursor") {
  16583. if (!this.selectionInEditor())
  16584. { this.showSelection(this.prepareSelection(), true); }
  16585. this.div.focus();
  16586. }
  16587. };
  16588. ContentEditableInput.prototype.blur = function () { this.div.blur(); };
  16589. ContentEditableInput.prototype.getField = function () { return this.div };
  16590. ContentEditableInput.prototype.supportsTouch = function () { return true };
  16591. ContentEditableInput.prototype.receivedFocus = function () {
  16592. var input = this;
  16593. if (this.selectionInEditor())
  16594. { this.pollSelection(); }
  16595. else
  16596. { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
  16597. function poll() {
  16598. if (input.cm.state.focused) {
  16599. input.pollSelection();
  16600. input.polling.set(input.cm.options.pollInterval, poll);
  16601. }
  16602. }
  16603. this.polling.set(this.cm.options.pollInterval, poll);
  16604. };
  16605. ContentEditableInput.prototype.selectionChanged = function () {
  16606. var sel = window.getSelection();
  16607. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
  16608. sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
  16609. };
  16610. ContentEditableInput.prototype.pollSelection = function () {
  16611. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
  16612. var sel = window.getSelection(), cm = this.cm;
  16613. // On Android Chrome (version 56, at least), backspacing into an
  16614. // uneditable block element will put the cursor in that element,
  16615. // and then, because it's not editable, hide the virtual keyboard.
  16616. // Because Android doesn't allow us to actually detect backspace
  16617. // presses in a sane way, this code checks for when that happens
  16618. // and simulates a backspace press in this case.
  16619. if (android && chrome && this.cm.options.gutters.length && isInGutter(sel.anchorNode)) {
  16620. this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs});
  16621. this.blur();
  16622. this.focus();
  16623. return
  16624. }
  16625. if (this.composing) { return }
  16626. this.rememberSelection();
  16627. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  16628. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  16629. if (anchor && head) { runInOp(cm, function () {
  16630. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  16631. if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }
  16632. }); }
  16633. };
  16634. ContentEditableInput.prototype.pollContent = function () {
  16635. if (this.readDOMTimeout != null) {
  16636. clearTimeout(this.readDOMTimeout);
  16637. this.readDOMTimeout = null;
  16638. }
  16639. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
  16640. var from = sel.from(), to = sel.to();
  16641. if (from.ch == 0 && from.line > cm.firstLine())
  16642. { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
  16643. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
  16644. { to = Pos(to.line + 1, 0); }
  16645. if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
  16646. var fromIndex, fromLine, fromNode;
  16647. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  16648. fromLine = lineNo(display.view[0].line);
  16649. fromNode = display.view[0].node;
  16650. } else {
  16651. fromLine = lineNo(display.view[fromIndex].line);
  16652. fromNode = display.view[fromIndex - 1].node.nextSibling;
  16653. }
  16654. var toIndex = findViewIndex(cm, to.line);
  16655. var toLine, toNode;
  16656. if (toIndex == display.view.length - 1) {
  16657. toLine = display.viewTo - 1;
  16658. toNode = display.lineDiv.lastChild;
  16659. } else {
  16660. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  16661. toNode = display.view[toIndex + 1].node.previousSibling;
  16662. }
  16663. if (!fromNode) { return false }
  16664. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  16665. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  16666. while (newText.length > 1 && oldText.length > 1) {
  16667. if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
  16668. else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
  16669. else { break }
  16670. }
  16671. var cutFront = 0, cutEnd = 0;
  16672. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
  16673. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
  16674. { ++cutFront; }
  16675. var newBot = lst(newText), oldBot = lst(oldText);
  16676. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
  16677. oldBot.length - (oldText.length == 1 ? cutFront : 0));
  16678. while (cutEnd < maxCutEnd &&
  16679. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
  16680. { ++cutEnd; }
  16681. // Try to move start of change to start of selection if ambiguous
  16682. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
  16683. while (cutFront && cutFront > from.ch &&
  16684. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  16685. cutFront--;
  16686. cutEnd++;
  16687. }
  16688. }
  16689. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  16690. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  16691. var chFrom = Pos(fromLine, cutFront);
  16692. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  16693. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  16694. replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  16695. return true
  16696. }
  16697. };
  16698. ContentEditableInput.prototype.ensurePolled = function () {
  16699. this.forceCompositionEnd();
  16700. };
  16701. ContentEditableInput.prototype.reset = function () {
  16702. this.forceCompositionEnd();
  16703. };
  16704. ContentEditableInput.prototype.forceCompositionEnd = function () {
  16705. if (!this.composing) { return }
  16706. clearTimeout(this.readDOMTimeout);
  16707. this.composing = null;
  16708. this.updateFromDOM();
  16709. this.div.blur();
  16710. this.div.focus();
  16711. };
  16712. ContentEditableInput.prototype.readFromDOMSoon = function () {
  16713. var this$1 = this;
  16714. if (this.readDOMTimeout != null) { return }
  16715. this.readDOMTimeout = setTimeout(function () {
  16716. this$1.readDOMTimeout = null;
  16717. if (this$1.composing) {
  16718. if (this$1.composing.done) { this$1.composing = null; }
  16719. else { return }
  16720. }
  16721. this$1.updateFromDOM();
  16722. }, 80);
  16723. };
  16724. ContentEditableInput.prototype.updateFromDOM = function () {
  16725. var this$1 = this;
  16726. if (this.cm.isReadOnly() || !this.pollContent())
  16727. { runInOp(this.cm, function () { return regChange(this$1.cm); }); }
  16728. };
  16729. ContentEditableInput.prototype.setUneditable = function (node) {
  16730. node.contentEditable = "false";
  16731. };
  16732. ContentEditableInput.prototype.onKeyPress = function (e) {
  16733. if (e.charCode == 0 || this.composing) { return }
  16734. e.preventDefault();
  16735. if (!this.cm.isReadOnly())
  16736. { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }
  16737. };
  16738. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  16739. this.div.contentEditable = String(val != "nocursor");
  16740. };
  16741. ContentEditableInput.prototype.onContextMenu = function () {};
  16742. ContentEditableInput.prototype.resetPosition = function () {};
  16743. ContentEditableInput.prototype.needsContentAttribute = true;
  16744. function posToDOM(cm, pos) {
  16745. var view = findViewForLine(cm, pos.line);
  16746. if (!view || view.hidden) { return null }
  16747. var line = getLine(cm.doc, pos.line);
  16748. var info = mapFromLineView(view, line, pos.line);
  16749. var order = getOrder(line, cm.doc.direction), side = "left";
  16750. if (order) {
  16751. var partPos = getBidiPartAt(order, pos.ch);
  16752. side = partPos % 2 ? "right" : "left";
  16753. }
  16754. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  16755. result.offset = result.collapse == "right" ? result.end : result.start;
  16756. return result
  16757. }
  16758. function isInGutter(node) {
  16759. for (var scan = node; scan; scan = scan.parentNode)
  16760. { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
  16761. return false
  16762. }
  16763. function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
  16764. function domTextBetween(cm, from, to, fromLine, toLine) {
  16765. var text = "", closing = false, lineSep = cm.doc.lineSeparator();
  16766. function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
  16767. function close() {
  16768. if (closing) {
  16769. text += lineSep;
  16770. closing = false;
  16771. }
  16772. }
  16773. function addText(str) {
  16774. if (str) {
  16775. close();
  16776. text += str;
  16777. }
  16778. }
  16779. function walk(node) {
  16780. if (node.nodeType == 1) {
  16781. var cmText = node.getAttribute("cm-text");
  16782. if (cmText != null) {
  16783. addText(cmText || node.textContent.replace(/\u200b/g, ""));
  16784. return
  16785. }
  16786. var markerID = node.getAttribute("cm-marker"), range$$1;
  16787. if (markerID) {
  16788. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  16789. if (found.length && (range$$1 = found[0].find(0)))
  16790. { addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep)); }
  16791. return
  16792. }
  16793. if (node.getAttribute("contenteditable") == "false") { return }
  16794. var isBlock = /^(pre|div|p)$/i.test(node.nodeName);
  16795. if (isBlock) { close(); }
  16796. for (var i = 0; i < node.childNodes.length; i++)
  16797. { walk(node.childNodes[i]); }
  16798. if (isBlock) { closing = true; }
  16799. } else if (node.nodeType == 3) {
  16800. addText(node.nodeValue);
  16801. }
  16802. }
  16803. for (;;) {
  16804. walk(from);
  16805. if (from == to) { break }
  16806. from = from.nextSibling;
  16807. }
  16808. return text
  16809. }
  16810. function domToPos(cm, node, offset) {
  16811. var lineNode;
  16812. if (node == cm.display.lineDiv) {
  16813. lineNode = cm.display.lineDiv.childNodes[offset];
  16814. if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
  16815. node = null; offset = 0;
  16816. } else {
  16817. for (lineNode = node;; lineNode = lineNode.parentNode) {
  16818. if (!lineNode || lineNode == cm.display.lineDiv) { return null }
  16819. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
  16820. }
  16821. }
  16822. for (var i = 0; i < cm.display.view.length; i++) {
  16823. var lineView = cm.display.view[i];
  16824. if (lineView.node == lineNode)
  16825. { return locateNodeInLineView(lineView, node, offset) }
  16826. }
  16827. }
  16828. function locateNodeInLineView(lineView, node, offset) {
  16829. var wrapper = lineView.text.firstChild, bad = false;
  16830. if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
  16831. if (node == wrapper) {
  16832. bad = true;
  16833. node = wrapper.childNodes[offset];
  16834. offset = 0;
  16835. if (!node) {
  16836. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  16837. return badPos(Pos(lineNo(line), line.text.length), bad)
  16838. }
  16839. }
  16840. var textNode = node.nodeType == 3 ? node : null, topNode = node;
  16841. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  16842. textNode = node.firstChild;
  16843. if (offset) { offset = textNode.nodeValue.length; }
  16844. }
  16845. while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }
  16846. var measure = lineView.measure, maps = measure.maps;
  16847. function find(textNode, topNode, offset) {
  16848. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  16849. var map$$1 = i < 0 ? measure.map : maps[i];
  16850. for (var j = 0; j < map$$1.length; j += 3) {
  16851. var curNode = map$$1[j + 2];
  16852. if (curNode == textNode || curNode == topNode) {
  16853. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
  16854. var ch = map$$1[j] + offset;
  16855. if (offset < 0 || curNode != textNode) { ch = map$$1[j + (offset ? 1 : 0)]; }
  16856. return Pos(line, ch)
  16857. }
  16858. }
  16859. }
  16860. }
  16861. var found = find(textNode, topNode, offset);
  16862. if (found) { return badPos(found, bad) }
  16863. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  16864. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  16865. found = find(after, after.firstChild, 0);
  16866. if (found)
  16867. { return badPos(Pos(found.line, found.ch - dist), bad) }
  16868. else
  16869. { dist += after.textContent.length; }
  16870. }
  16871. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  16872. found = find(before, before.firstChild, -1);
  16873. if (found)
  16874. { return badPos(Pos(found.line, found.ch + dist$1), bad) }
  16875. else
  16876. { dist$1 += before.textContent.length; }
  16877. }
  16878. }
  16879. // TEXTAREA INPUT STYLE
  16880. var TextareaInput = function(cm) {
  16881. this.cm = cm;
  16882. // See input.poll and input.reset
  16883. this.prevInput = "";
  16884. // Flag that indicates whether we expect input to appear real soon
  16885. // now (after some event like 'keypress' or 'input') and are
  16886. // polling intensively.
  16887. this.pollingFast = false;
  16888. // Self-resetting timeout for the poller
  16889. this.polling = new Delayed();
  16890. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  16891. this.hasSelection = false;
  16892. this.composing = null;
  16893. };
  16894. TextareaInput.prototype.init = function (display) {
  16895. var this$1 = this;
  16896. var input = this, cm = this.cm;
  16897. this.createField(display);
  16898. var te = this.textarea;
  16899. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  16900. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  16901. if (ios) { te.style.width = "0px"; }
  16902. on(te, "input", function () {
  16903. if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }
  16904. input.poll();
  16905. });
  16906. on(te, "paste", function (e) {
  16907. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  16908. cm.state.pasteIncoming = true;
  16909. input.fastPoll();
  16910. });
  16911. function prepareCopyCut(e) {
  16912. if (signalDOMEvent(cm, e)) { return }
  16913. if (cm.somethingSelected()) {
  16914. setLastCopied({lineWise: false, text: cm.getSelections()});
  16915. } else if (!cm.options.lineWiseCopyCut) {
  16916. return
  16917. } else {
  16918. var ranges = copyableRanges(cm);
  16919. setLastCopied({lineWise: true, text: ranges.text});
  16920. if (e.type == "cut") {
  16921. cm.setSelections(ranges.ranges, null, sel_dontScroll);
  16922. } else {
  16923. input.prevInput = "";
  16924. te.value = ranges.text.join("\n");
  16925. selectInput(te);
  16926. }
  16927. }
  16928. if (e.type == "cut") { cm.state.cutIncoming = true; }
  16929. }
  16930. on(te, "cut", prepareCopyCut);
  16931. on(te, "copy", prepareCopyCut);
  16932. on(display.scroller, "paste", function (e) {
  16933. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
  16934. cm.state.pasteIncoming = true;
  16935. input.focus();
  16936. });
  16937. // Prevent normal selection in the editor (we handle our own)
  16938. on(display.lineSpace, "selectstart", function (e) {
  16939. if (!eventInWidget(display, e)) { e_preventDefault(e); }
  16940. });
  16941. on(te, "compositionstart", function () {
  16942. var start = cm.getCursor("from");
  16943. if (input.composing) { input.composing.range.clear(); }
  16944. input.composing = {
  16945. start: start,
  16946. range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
  16947. };
  16948. });
  16949. on(te, "compositionend", function () {
  16950. if (input.composing) {
  16951. input.poll();
  16952. input.composing.range.clear();
  16953. input.composing = null;
  16954. }
  16955. });
  16956. };
  16957. TextareaInput.prototype.createField = function (_display) {
  16958. // Wraps and hides input textarea
  16959. this.wrapper = hiddenTextarea();
  16960. // The semihidden textarea that is focused when the editor is
  16961. // focused, and receives input.
  16962. this.textarea = this.wrapper.firstChild;
  16963. };
  16964. TextareaInput.prototype.prepareSelection = function () {
  16965. // Redraw the selection and/or cursor
  16966. var cm = this.cm, display = cm.display, doc = cm.doc;
  16967. var result = prepareSelection(cm);
  16968. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  16969. if (cm.options.moveInputWithCursor) {
  16970. var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
  16971. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
  16972. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
  16973. headPos.top + lineOff.top - wrapOff.top));
  16974. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
  16975. headPos.left + lineOff.left - wrapOff.left));
  16976. }
  16977. return result
  16978. };
  16979. TextareaInput.prototype.showSelection = function (drawn) {
  16980. var cm = this.cm, display = cm.display;
  16981. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  16982. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  16983. if (drawn.teTop != null) {
  16984. this.wrapper.style.top = drawn.teTop + "px";
  16985. this.wrapper.style.left = drawn.teLeft + "px";
  16986. }
  16987. };
  16988. // Reset the input to correspond to the selection (or to be empty,
  16989. // when not typing and nothing is selected)
  16990. TextareaInput.prototype.reset = function (typing) {
  16991. if (this.contextMenuPending || this.composing) { return }
  16992. var cm = this.cm;
  16993. if (cm.somethingSelected()) {
  16994. this.prevInput = "";
  16995. var content = cm.getSelection();
  16996. this.textarea.value = content;
  16997. if (cm.state.focused) { selectInput(this.textarea); }
  16998. if (ie && ie_version >= 9) { this.hasSelection = content; }
  16999. } else if (!typing) {
  17000. this.prevInput = this.textarea.value = "";
  17001. if (ie && ie_version >= 9) { this.hasSelection = null; }
  17002. }
  17003. };
  17004. TextareaInput.prototype.getField = function () { return this.textarea };
  17005. TextareaInput.prototype.supportsTouch = function () { return false };
  17006. TextareaInput.prototype.focus = function () {
  17007. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  17008. try { this.textarea.focus(); }
  17009. catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  17010. }
  17011. };
  17012. TextareaInput.prototype.blur = function () { this.textarea.blur(); };
  17013. TextareaInput.prototype.resetPosition = function () {
  17014. this.wrapper.style.top = this.wrapper.style.left = 0;
  17015. };
  17016. TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };
  17017. // Poll for input changes, using the normal rate of polling. This
  17018. // runs as long as the editor is focused.
  17019. TextareaInput.prototype.slowPoll = function () {
  17020. var this$1 = this;
  17021. if (this.pollingFast) { return }
  17022. this.polling.set(this.cm.options.pollInterval, function () {
  17023. this$1.poll();
  17024. if (this$1.cm.state.focused) { this$1.slowPoll(); }
  17025. });
  17026. };
  17027. // When an event has just come in that is likely to add or change
  17028. // something in the input textarea, we poll faster, to ensure that
  17029. // the change appears on the screen quickly.
  17030. TextareaInput.prototype.fastPoll = function () {
  17031. var missed = false, input = this;
  17032. input.pollingFast = true;
  17033. function p() {
  17034. var changed = input.poll();
  17035. if (!changed && !missed) {missed = true; input.polling.set(60, p);}
  17036. else {input.pollingFast = false; input.slowPoll();}
  17037. }
  17038. input.polling.set(20, p);
  17039. };
  17040. // Read input from the textarea, and update the document to match.
  17041. // When something is selected, it is present in the textarea, and
  17042. // selected (unless it is huge, in which case a placeholder is
  17043. // used). When nothing is selected, the cursor sits after previously
  17044. // seen text (can be empty), which is stored in prevInput (we must
  17045. // not reset the textarea when typing, because that breaks IME).
  17046. TextareaInput.prototype.poll = function () {
  17047. var this$1 = this;
  17048. var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
  17049. // Since this is called a *lot*, try to bail out as cheaply as
  17050. // possible when it is clear that nothing happened. hasSelection
  17051. // will be the case when there is a lot of text in the textarea,
  17052. // in which case reading its value would be expensive.
  17053. if (this.contextMenuPending || !cm.state.focused ||
  17054. (hasSelection(input) && !prevInput && !this.composing) ||
  17055. cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
  17056. { return false }
  17057. var text = input.value;
  17058. // If nothing changed, bail.
  17059. if (text == prevInput && !cm.somethingSelected()) { return false }
  17060. // Work around nonsensical selection resetting in IE9/10, and
  17061. // inexplicable appearance of private area unicode characters on
  17062. // some key combos in Mac (#2689).
  17063. if (ie && ie_version >= 9 && this.hasSelection === text ||
  17064. mac && /[\uf700-\uf7ff]/.test(text)) {
  17065. cm.display.input.reset();
  17066. return false
  17067. }
  17068. if (cm.doc.sel == cm.display.selForContextMenu) {
  17069. var first = text.charCodeAt(0);
  17070. if (first == 0x200b && !prevInput) { prevInput = "\u200b"; }
  17071. if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
  17072. }
  17073. // Find the part of the input that is actually new
  17074. var same = 0, l = Math.min(prevInput.length, text.length);
  17075. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }
  17076. runInOp(cm, function () {
  17077. applyTextInput(cm, text.slice(same), prevInput.length - same,
  17078. null, this$1.composing ? "*compose" : null);
  17079. // Don't leave long text in the textarea, since it makes further polling slow
  17080. if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; }
  17081. else { this$1.prevInput = text; }
  17082. if (this$1.composing) {
  17083. this$1.composing.range.clear();
  17084. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
  17085. {className: "CodeMirror-composing"});
  17086. }
  17087. });
  17088. return true
  17089. };
  17090. TextareaInput.prototype.ensurePolled = function () {
  17091. if (this.pollingFast && this.poll()) { this.pollingFast = false; }
  17092. };
  17093. TextareaInput.prototype.onKeyPress = function () {
  17094. if (ie && ie_version >= 9) { this.hasSelection = null; }
  17095. this.fastPoll();
  17096. };
  17097. TextareaInput.prototype.onContextMenu = function (e) {
  17098. var input = this, cm = input.cm, display = cm.display, te = input.textarea;
  17099. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
  17100. if (!pos || presto) { return } // Opera is difficult.
  17101. // Reset the current text selection only if the click is done outside of the selection
  17102. // and 'resetSelectionOnContextMenu' option is true.
  17103. var reset = cm.options.resetSelectionOnContextMenu;
  17104. if (reset && cm.doc.sel.contains(pos) == -1)
  17105. { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
  17106. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
  17107. input.wrapper.style.cssText = "position: absolute";
  17108. var wrapperBox = input.wrapper.getBoundingClientRect();
  17109. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
  17110. var oldScrollY;
  17111. if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
  17112. display.input.focus();
  17113. if (webkit) { window.scrollTo(null, oldScrollY); }
  17114. display.input.reset();
  17115. // Adds "Select all" to context menu in FF
  17116. if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
  17117. input.contextMenuPending = true;
  17118. display.selForContextMenu = cm.doc.sel;
  17119. clearTimeout(display.detectingSelectAll);
  17120. // Select-all will be greyed out if there's nothing to select, so
  17121. // this adds a zero-width space so that we can later check whether
  17122. // it got selected.
  17123. function prepareSelectAllHack() {
  17124. if (te.selectionStart != null) {
  17125. var selected = cm.somethingSelected();
  17126. var extval = "\u200b" + (selected ? te.value : "");
  17127. te.value = "\u21da"; // Used to catch context-menu undo
  17128. te.value = extval;
  17129. input.prevInput = selected ? "" : "\u200b";
  17130. te.selectionStart = 1; te.selectionEnd = extval.length;
  17131. // Re-set this, in case some other handler touched the
  17132. // selection in the meantime.
  17133. display.selForContextMenu = cm.doc.sel;
  17134. }
  17135. }
  17136. function rehide() {
  17137. input.contextMenuPending = false;
  17138. input.wrapper.style.cssText = oldWrapperCSS;
  17139. te.style.cssText = oldCSS;
  17140. if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }
  17141. // Try to detect the user choosing select-all
  17142. if (te.selectionStart != null) {
  17143. if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }
  17144. var i = 0, poll = function () {
  17145. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
  17146. te.selectionEnd > 0 && input.prevInput == "\u200b") {
  17147. operation(cm, selectAll)(cm);
  17148. } else if (i++ < 10) {
  17149. display.detectingSelectAll = setTimeout(poll, 500);
  17150. } else {
  17151. display.selForContextMenu = null;
  17152. display.input.reset();
  17153. }
  17154. };
  17155. display.detectingSelectAll = setTimeout(poll, 200);
  17156. }
  17157. }
  17158. if (ie && ie_version >= 9) { prepareSelectAllHack(); }
  17159. if (captureRightClick) {
  17160. e_stop(e);
  17161. var mouseup = function () {
  17162. off(window, "mouseup", mouseup);
  17163. setTimeout(rehide, 20);
  17164. };
  17165. on(window, "mouseup", mouseup);
  17166. } else {
  17167. setTimeout(rehide, 50);
  17168. }
  17169. };
  17170. TextareaInput.prototype.readOnlyChanged = function (val) {
  17171. if (!val) { this.reset(); }
  17172. this.textarea.disabled = val == "nocursor";
  17173. };
  17174. TextareaInput.prototype.setUneditable = function () {};
  17175. TextareaInput.prototype.needsContentAttribute = false;
  17176. function fromTextArea(textarea, options) {
  17177. options = options ? copyObj(options) : {};
  17178. options.value = textarea.value;
  17179. if (!options.tabindex && textarea.tabIndex)
  17180. { options.tabindex = textarea.tabIndex; }
  17181. if (!options.placeholder && textarea.placeholder)
  17182. { options.placeholder = textarea.placeholder; }
  17183. // Set autofocus to true if this textarea is focused, or if it has
  17184. // autofocus and no other element is focused.
  17185. if (options.autofocus == null) {
  17186. var hasFocus = activeElt();
  17187. options.autofocus = hasFocus == textarea ||
  17188. textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  17189. }
  17190. function save() {textarea.value = cm.getValue();}
  17191. var realSubmit;
  17192. if (textarea.form) {
  17193. on(textarea.form, "submit", save);
  17194. // Deplorable hack to make the submit method do the right thing.
  17195. if (!options.leaveSubmitMethodAlone) {
  17196. var form = textarea.form;
  17197. realSubmit = form.submit;
  17198. try {
  17199. var wrappedSubmit = form.submit = function () {
  17200. save();
  17201. form.submit = realSubmit;
  17202. form.submit();
  17203. form.submit = wrappedSubmit;
  17204. };
  17205. } catch(e) {}
  17206. }
  17207. }
  17208. options.finishInit = function (cm) {
  17209. cm.save = save;
  17210. cm.getTextArea = function () { return textarea; };
  17211. cm.toTextArea = function () {
  17212. cm.toTextArea = isNaN; // Prevent this from being ran twice
  17213. save();
  17214. textarea.parentNode.removeChild(cm.getWrapperElement());
  17215. textarea.style.display = "";
  17216. if (textarea.form) {
  17217. off(textarea.form, "submit", save);
  17218. if (typeof textarea.form.submit == "function")
  17219. { textarea.form.submit = realSubmit; }
  17220. }
  17221. };
  17222. };
  17223. textarea.style.display = "none";
  17224. var cm = CodeMirror$1(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
  17225. options);
  17226. return cm
  17227. }
  17228. function addLegacyProps(CodeMirror) {
  17229. CodeMirror.off = off;
  17230. CodeMirror.on = on;
  17231. CodeMirror.wheelEventPixels = wheelEventPixels;
  17232. CodeMirror.Doc = Doc;
  17233. CodeMirror.splitLines = splitLinesAuto;
  17234. CodeMirror.countColumn = countColumn;
  17235. CodeMirror.findColumn = findColumn;
  17236. CodeMirror.isWordChar = isWordCharBasic;
  17237. CodeMirror.Pass = Pass;
  17238. CodeMirror.signal = signal;
  17239. CodeMirror.Line = Line;
  17240. CodeMirror.changeEnd = changeEnd;
  17241. CodeMirror.scrollbarModel = scrollbarModel;
  17242. CodeMirror.Pos = Pos;
  17243. CodeMirror.cmpPos = cmp;
  17244. CodeMirror.modes = modes;
  17245. CodeMirror.mimeModes = mimeModes;
  17246. CodeMirror.resolveMode = resolveMode;
  17247. CodeMirror.getMode = getMode;
  17248. CodeMirror.modeExtensions = modeExtensions;
  17249. CodeMirror.extendMode = extendMode;
  17250. CodeMirror.copyState = copyState;
  17251. CodeMirror.startState = startState;
  17252. CodeMirror.innerMode = innerMode;
  17253. CodeMirror.commands = commands;
  17254. CodeMirror.keyMap = keyMap;
  17255. CodeMirror.keyName = keyName;
  17256. CodeMirror.isModifierKey = isModifierKey;
  17257. CodeMirror.lookupKey = lookupKey;
  17258. CodeMirror.normalizeKeyMap = normalizeKeyMap;
  17259. CodeMirror.StringStream = StringStream;
  17260. CodeMirror.SharedTextMarker = SharedTextMarker;
  17261. CodeMirror.TextMarker = TextMarker;
  17262. CodeMirror.LineWidget = LineWidget;
  17263. CodeMirror.e_preventDefault = e_preventDefault;
  17264. CodeMirror.e_stopPropagation = e_stopPropagation;
  17265. CodeMirror.e_stop = e_stop;
  17266. CodeMirror.addClass = addClass;
  17267. CodeMirror.contains = contains;
  17268. CodeMirror.rmClass = rmClass;
  17269. CodeMirror.keyNames = keyNames;
  17270. }
  17271. // EDITOR CONSTRUCTOR
  17272. defineOptions(CodeMirror$1);
  17273. addEditorMethods(CodeMirror$1);
  17274. // Set up methods on CodeMirror's prototype to redirect to the editor's document.
  17275. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  17276. for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
  17277. { CodeMirror$1.prototype[prop] = (function(method) {
  17278. return function() {return method.apply(this.doc, arguments)}
  17279. })(Doc.prototype[prop]); } }
  17280. eventMixin(Doc);
  17281. // INPUT HANDLING
  17282. CodeMirror$1.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
  17283. // MODE DEFINITION AND QUERYING
  17284. // Extra arguments are stored as the mode's dependencies, which is
  17285. // used by (legacy) mechanisms like loadmode.js to automatically
  17286. // load a mode. (Preferred mechanism is the require/define calls.)
  17287. CodeMirror$1.defineMode = function(name/*, mode, …*/) {
  17288. if (!CodeMirror$1.defaults.mode && name != "null") { CodeMirror$1.defaults.mode = name; }
  17289. defineMode.apply(this, arguments);
  17290. };
  17291. CodeMirror$1.defineMIME = defineMIME;
  17292. // Minimal default mode.
  17293. CodeMirror$1.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
  17294. CodeMirror$1.defineMIME("text/plain", "null");
  17295. // EXTENSIONS
  17296. CodeMirror$1.defineExtension = function (name, func) {
  17297. CodeMirror$1.prototype[name] = func;
  17298. };
  17299. CodeMirror$1.defineDocExtension = function (name, func) {
  17300. Doc.prototype[name] = func;
  17301. };
  17302. CodeMirror$1.fromTextArea = fromTextArea;
  17303. addLegacyProps(CodeMirror$1);
  17304. CodeMirror$1.version = "5.37.0";
  17305. return CodeMirror$1;
  17306. })));
  17307. ;(function (global, factory) {
  17308. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  17309. typeof define === 'function' && define.amd ? define('moment',factory) :
  17310. global.moment = factory()
  17311. }(this, (function () { 'use strict';
  17312. var hookCallback;
  17313. function hooks () {
  17314. return hookCallback.apply(null, arguments);
  17315. }
  17316. // This is done to register the method called with moment()
  17317. // without creating circular dependencies.
  17318. function setHookCallback (callback) {
  17319. hookCallback = callback;
  17320. }
  17321. function isArray(input) {
  17322. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  17323. }
  17324. function isObject(input) {
  17325. // IE8 will treat undefined and null as object if it wasn't for
  17326. // input != null
  17327. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  17328. }
  17329. function isObjectEmpty(obj) {
  17330. if (Object.getOwnPropertyNames) {
  17331. return (Object.getOwnPropertyNames(obj).length === 0);
  17332. } else {
  17333. var k;
  17334. for (k in obj) {
  17335. if (obj.hasOwnProperty(k)) {
  17336. return false;
  17337. }
  17338. }
  17339. return true;
  17340. }
  17341. }
  17342. function isUndefined(input) {
  17343. return input === void 0;
  17344. }
  17345. function isNumber(input) {
  17346. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  17347. }
  17348. function isDate(input) {
  17349. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  17350. }
  17351. function map(arr, fn) {
  17352. var res = [], i;
  17353. for (i = 0; i < arr.length; ++i) {
  17354. res.push(fn(arr[i], i));
  17355. }
  17356. return res;
  17357. }
  17358. function hasOwnProp(a, b) {
  17359. return Object.prototype.hasOwnProperty.call(a, b);
  17360. }
  17361. function extend(a, b) {
  17362. for (var i in b) {
  17363. if (hasOwnProp(b, i)) {
  17364. a[i] = b[i];
  17365. }
  17366. }
  17367. if (hasOwnProp(b, 'toString')) {
  17368. a.toString = b.toString;
  17369. }
  17370. if (hasOwnProp(b, 'valueOf')) {
  17371. a.valueOf = b.valueOf;
  17372. }
  17373. return a;
  17374. }
  17375. function createUTC (input, format, locale, strict) {
  17376. return createLocalOrUTC(input, format, locale, strict, true).utc();
  17377. }
  17378. function defaultParsingFlags() {
  17379. // We need to deep clone this object.
  17380. return {
  17381. empty : false,
  17382. unusedTokens : [],
  17383. unusedInput : [],
  17384. overflow : -2,
  17385. charsLeftOver : 0,
  17386. nullInput : false,
  17387. invalidMonth : null,
  17388. invalidFormat : false,
  17389. userInvalidated : false,
  17390. iso : false,
  17391. parsedDateParts : [],
  17392. meridiem : null,
  17393. rfc2822 : false,
  17394. weekdayMismatch : false
  17395. };
  17396. }
  17397. function getParsingFlags(m) {
  17398. if (m._pf == null) {
  17399. m._pf = defaultParsingFlags();
  17400. }
  17401. return m._pf;
  17402. }
  17403. var some;
  17404. if (Array.prototype.some) {
  17405. some = Array.prototype.some;
  17406. } else {
  17407. some = function (fun) {
  17408. var t = Object(this);
  17409. var len = t.length >>> 0;
  17410. for (var i = 0; i < len; i++) {
  17411. if (i in t && fun.call(this, t[i], i, t)) {
  17412. return true;
  17413. }
  17414. }
  17415. return false;
  17416. };
  17417. }
  17418. function isValid(m) {
  17419. if (m._isValid == null) {
  17420. var flags = getParsingFlags(m);
  17421. var parsedParts = some.call(flags.parsedDateParts, function (i) {
  17422. return i != null;
  17423. });
  17424. var isNowValid = !isNaN(m._d.getTime()) &&
  17425. flags.overflow < 0 &&
  17426. !flags.empty &&
  17427. !flags.invalidMonth &&
  17428. !flags.invalidWeekday &&
  17429. !flags.weekdayMismatch &&
  17430. !flags.nullInput &&
  17431. !flags.invalidFormat &&
  17432. !flags.userInvalidated &&
  17433. (!flags.meridiem || (flags.meridiem && parsedParts));
  17434. if (m._strict) {
  17435. isNowValid = isNowValid &&
  17436. flags.charsLeftOver === 0 &&
  17437. flags.unusedTokens.length === 0 &&
  17438. flags.bigHour === undefined;
  17439. }
  17440. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  17441. m._isValid = isNowValid;
  17442. }
  17443. else {
  17444. return isNowValid;
  17445. }
  17446. }
  17447. return m._isValid;
  17448. }
  17449. function createInvalid (flags) {
  17450. var m = createUTC(NaN);
  17451. if (flags != null) {
  17452. extend(getParsingFlags(m), flags);
  17453. }
  17454. else {
  17455. getParsingFlags(m).userInvalidated = true;
  17456. }
  17457. return m;
  17458. }
  17459. // Plugins that add properties should also add the key here (null value),
  17460. // so we can properly clone ourselves.
  17461. var momentProperties = hooks.momentProperties = [];
  17462. function copyConfig(to, from) {
  17463. var i, prop, val;
  17464. if (!isUndefined(from._isAMomentObject)) {
  17465. to._isAMomentObject = from._isAMomentObject;
  17466. }
  17467. if (!isUndefined(from._i)) {
  17468. to._i = from._i;
  17469. }
  17470. if (!isUndefined(from._f)) {
  17471. to._f = from._f;
  17472. }
  17473. if (!isUndefined(from._l)) {
  17474. to._l = from._l;
  17475. }
  17476. if (!isUndefined(from._strict)) {
  17477. to._strict = from._strict;
  17478. }
  17479. if (!isUndefined(from._tzm)) {
  17480. to._tzm = from._tzm;
  17481. }
  17482. if (!isUndefined(from._isUTC)) {
  17483. to._isUTC = from._isUTC;
  17484. }
  17485. if (!isUndefined(from._offset)) {
  17486. to._offset = from._offset;
  17487. }
  17488. if (!isUndefined(from._pf)) {
  17489. to._pf = getParsingFlags(from);
  17490. }
  17491. if (!isUndefined(from._locale)) {
  17492. to._locale = from._locale;
  17493. }
  17494. if (momentProperties.length > 0) {
  17495. for (i = 0; i < momentProperties.length; i++) {
  17496. prop = momentProperties[i];
  17497. val = from[prop];
  17498. if (!isUndefined(val)) {
  17499. to[prop] = val;
  17500. }
  17501. }
  17502. }
  17503. return to;
  17504. }
  17505. var updateInProgress = false;
  17506. // Moment prototype object
  17507. function Moment(config) {
  17508. copyConfig(this, config);
  17509. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  17510. if (!this.isValid()) {
  17511. this._d = new Date(NaN);
  17512. }
  17513. // Prevent infinite loop in case updateOffset creates new moment
  17514. // objects.
  17515. if (updateInProgress === false) {
  17516. updateInProgress = true;
  17517. hooks.updateOffset(this);
  17518. updateInProgress = false;
  17519. }
  17520. }
  17521. function isMoment (obj) {
  17522. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  17523. }
  17524. function absFloor (number) {
  17525. if (number < 0) {
  17526. // -0 -> 0
  17527. return Math.ceil(number) || 0;
  17528. } else {
  17529. return Math.floor(number);
  17530. }
  17531. }
  17532. function toInt(argumentForCoercion) {
  17533. var coercedNumber = +argumentForCoercion,
  17534. value = 0;
  17535. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  17536. value = absFloor(coercedNumber);
  17537. }
  17538. return value;
  17539. }
  17540. // compare two arrays, return the number of differences
  17541. function compareArrays(array1, array2, dontConvert) {
  17542. var len = Math.min(array1.length, array2.length),
  17543. lengthDiff = Math.abs(array1.length - array2.length),
  17544. diffs = 0,
  17545. i;
  17546. for (i = 0; i < len; i++) {
  17547. if ((dontConvert && array1[i] !== array2[i]) ||
  17548. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  17549. diffs++;
  17550. }
  17551. }
  17552. return diffs + lengthDiff;
  17553. }
  17554. function warn(msg) {
  17555. if (hooks.suppressDeprecationWarnings === false &&
  17556. (typeof console !== 'undefined') && console.warn) {
  17557. console.warn('Deprecation warning: ' + msg);
  17558. }
  17559. }
  17560. function deprecate(msg, fn) {
  17561. var firstTime = true;
  17562. return extend(function () {
  17563. if (hooks.deprecationHandler != null) {
  17564. hooks.deprecationHandler(null, msg);
  17565. }
  17566. if (firstTime) {
  17567. var args = [];
  17568. var arg;
  17569. for (var i = 0; i < arguments.length; i++) {
  17570. arg = '';
  17571. if (typeof arguments[i] === 'object') {
  17572. arg += '\n[' + i + '] ';
  17573. for (var key in arguments[0]) {
  17574. arg += key + ': ' + arguments[0][key] + ', ';
  17575. }
  17576. arg = arg.slice(0, -2); // Remove trailing comma and space
  17577. } else {
  17578. arg = arguments[i];
  17579. }
  17580. args.push(arg);
  17581. }
  17582. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  17583. firstTime = false;
  17584. }
  17585. return fn.apply(this, arguments);
  17586. }, fn);
  17587. }
  17588. var deprecations = {};
  17589. function deprecateSimple(name, msg) {
  17590. if (hooks.deprecationHandler != null) {
  17591. hooks.deprecationHandler(name, msg);
  17592. }
  17593. if (!deprecations[name]) {
  17594. warn(msg);
  17595. deprecations[name] = true;
  17596. }
  17597. }
  17598. hooks.suppressDeprecationWarnings = false;
  17599. hooks.deprecationHandler = null;
  17600. function isFunction(input) {
  17601. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  17602. }
  17603. function set (config) {
  17604. var prop, i;
  17605. for (i in config) {
  17606. prop = config[i];
  17607. if (isFunction(prop)) {
  17608. this[i] = prop;
  17609. } else {
  17610. this['_' + i] = prop;
  17611. }
  17612. }
  17613. this._config = config;
  17614. // Lenient ordinal parsing accepts just a number in addition to
  17615. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  17616. // TODO: Remove "ordinalParse" fallback in next major release.
  17617. this._dayOfMonthOrdinalParseLenient = new RegExp(
  17618. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  17619. '|' + (/\d{1,2}/).source);
  17620. }
  17621. function mergeConfigs(parentConfig, childConfig) {
  17622. var res = extend({}, parentConfig), prop;
  17623. for (prop in childConfig) {
  17624. if (hasOwnProp(childConfig, prop)) {
  17625. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  17626. res[prop] = {};
  17627. extend(res[prop], parentConfig[prop]);
  17628. extend(res[prop], childConfig[prop]);
  17629. } else if (childConfig[prop] != null) {
  17630. res[prop] = childConfig[prop];
  17631. } else {
  17632. delete res[prop];
  17633. }
  17634. }
  17635. }
  17636. for (prop in parentConfig) {
  17637. if (hasOwnProp(parentConfig, prop) &&
  17638. !hasOwnProp(childConfig, prop) &&
  17639. isObject(parentConfig[prop])) {
  17640. // make sure changes to properties don't modify parent config
  17641. res[prop] = extend({}, res[prop]);
  17642. }
  17643. }
  17644. return res;
  17645. }
  17646. function Locale(config) {
  17647. if (config != null) {
  17648. this.set(config);
  17649. }
  17650. }
  17651. var keys;
  17652. if (Object.keys) {
  17653. keys = Object.keys;
  17654. } else {
  17655. keys = function (obj) {
  17656. var i, res = [];
  17657. for (i in obj) {
  17658. if (hasOwnProp(obj, i)) {
  17659. res.push(i);
  17660. }
  17661. }
  17662. return res;
  17663. };
  17664. }
  17665. var defaultCalendar = {
  17666. sameDay : '[Today at] LT',
  17667. nextDay : '[Tomorrow at] LT',
  17668. nextWeek : 'dddd [at] LT',
  17669. lastDay : '[Yesterday at] LT',
  17670. lastWeek : '[Last] dddd [at] LT',
  17671. sameElse : 'L'
  17672. };
  17673. function calendar (key, mom, now) {
  17674. var output = this._calendar[key] || this._calendar['sameElse'];
  17675. return isFunction(output) ? output.call(mom, now) : output;
  17676. }
  17677. var defaultLongDateFormat = {
  17678. LTS : 'h:mm:ss A',
  17679. LT : 'h:mm A',
  17680. L : 'MM/DD/YYYY',
  17681. LL : 'MMMM D, YYYY',
  17682. LLL : 'MMMM D, YYYY h:mm A',
  17683. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  17684. };
  17685. function longDateFormat (key) {
  17686. var format = this._longDateFormat[key],
  17687. formatUpper = this._longDateFormat[key.toUpperCase()];
  17688. if (format || !formatUpper) {
  17689. return format;
  17690. }
  17691. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  17692. return val.slice(1);
  17693. });
  17694. return this._longDateFormat[key];
  17695. }
  17696. var defaultInvalidDate = 'Invalid date';
  17697. function invalidDate () {
  17698. return this._invalidDate;
  17699. }
  17700. var defaultOrdinal = '%d';
  17701. var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  17702. function ordinal (number) {
  17703. return this._ordinal.replace('%d', number);
  17704. }
  17705. var defaultRelativeTime = {
  17706. future : 'in %s',
  17707. past : '%s ago',
  17708. s : 'a few seconds',
  17709. ss : '%d seconds',
  17710. m : 'a minute',
  17711. mm : '%d minutes',
  17712. h : 'an hour',
  17713. hh : '%d hours',
  17714. d : 'a day',
  17715. dd : '%d days',
  17716. M : 'a month',
  17717. MM : '%d months',
  17718. y : 'a year',
  17719. yy : '%d years'
  17720. };
  17721. function relativeTime (number, withoutSuffix, string, isFuture) {
  17722. var output = this._relativeTime[string];
  17723. return (isFunction(output)) ?
  17724. output(number, withoutSuffix, string, isFuture) :
  17725. output.replace(/%d/i, number);
  17726. }
  17727. function pastFuture (diff, output) {
  17728. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  17729. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  17730. }
  17731. var aliases = {};
  17732. function addUnitAlias (unit, shorthand) {
  17733. var lowerCase = unit.toLowerCase();
  17734. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  17735. }
  17736. function normalizeUnits(units) {
  17737. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  17738. }
  17739. function normalizeObjectUnits(inputObject) {
  17740. var normalizedInput = {},
  17741. normalizedProp,
  17742. prop;
  17743. for (prop in inputObject) {
  17744. if (hasOwnProp(inputObject, prop)) {
  17745. normalizedProp = normalizeUnits(prop);
  17746. if (normalizedProp) {
  17747. normalizedInput[normalizedProp] = inputObject[prop];
  17748. }
  17749. }
  17750. }
  17751. return normalizedInput;
  17752. }
  17753. var priorities = {};
  17754. function addUnitPriority(unit, priority) {
  17755. priorities[unit] = priority;
  17756. }
  17757. function getPrioritizedUnits(unitsObj) {
  17758. var units = [];
  17759. for (var u in unitsObj) {
  17760. units.push({unit: u, priority: priorities[u]});
  17761. }
  17762. units.sort(function (a, b) {
  17763. return a.priority - b.priority;
  17764. });
  17765. return units;
  17766. }
  17767. function zeroFill(number, targetLength, forceSign) {
  17768. var absNumber = '' + Math.abs(number),
  17769. zerosToFill = targetLength - absNumber.length,
  17770. sign = number >= 0;
  17771. return (sign ? (forceSign ? '+' : '') : '-') +
  17772. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  17773. }
  17774. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  17775. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  17776. var formatFunctions = {};
  17777. var formatTokenFunctions = {};
  17778. // token: 'M'
  17779. // padded: ['MM', 2]
  17780. // ordinal: 'Mo'
  17781. // callback: function () { this.month() + 1 }
  17782. function addFormatToken (token, padded, ordinal, callback) {
  17783. var func = callback;
  17784. if (typeof callback === 'string') {
  17785. func = function () {
  17786. return this[callback]();
  17787. };
  17788. }
  17789. if (token) {
  17790. formatTokenFunctions[token] = func;
  17791. }
  17792. if (padded) {
  17793. formatTokenFunctions[padded[0]] = function () {
  17794. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  17795. };
  17796. }
  17797. if (ordinal) {
  17798. formatTokenFunctions[ordinal] = function () {
  17799. return this.localeData().ordinal(func.apply(this, arguments), token);
  17800. };
  17801. }
  17802. }
  17803. function removeFormattingTokens(input) {
  17804. if (input.match(/\[[\s\S]/)) {
  17805. return input.replace(/^\[|\]$/g, '');
  17806. }
  17807. return input.replace(/\\/g, '');
  17808. }
  17809. function makeFormatFunction(format) {
  17810. var array = format.match(formattingTokens), i, length;
  17811. for (i = 0, length = array.length; i < length; i++) {
  17812. if (formatTokenFunctions[array[i]]) {
  17813. array[i] = formatTokenFunctions[array[i]];
  17814. } else {
  17815. array[i] = removeFormattingTokens(array[i]);
  17816. }
  17817. }
  17818. return function (mom) {
  17819. var output = '', i;
  17820. for (i = 0; i < length; i++) {
  17821. output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
  17822. }
  17823. return output;
  17824. };
  17825. }
  17826. // format date using native date object
  17827. function formatMoment(m, format) {
  17828. if (!m.isValid()) {
  17829. return m.localeData().invalidDate();
  17830. }
  17831. format = expandFormat(format, m.localeData());
  17832. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  17833. return formatFunctions[format](m);
  17834. }
  17835. function expandFormat(format, locale) {
  17836. var i = 5;
  17837. function replaceLongDateFormatTokens(input) {
  17838. return locale.longDateFormat(input) || input;
  17839. }
  17840. localFormattingTokens.lastIndex = 0;
  17841. while (i >= 0 && localFormattingTokens.test(format)) {
  17842. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  17843. localFormattingTokens.lastIndex = 0;
  17844. i -= 1;
  17845. }
  17846. return format;
  17847. }
  17848. var match1 = /\d/; // 0 - 9
  17849. var match2 = /\d\d/; // 00 - 99
  17850. var match3 = /\d{3}/; // 000 - 999
  17851. var match4 = /\d{4}/; // 0000 - 9999
  17852. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  17853. var match1to2 = /\d\d?/; // 0 - 99
  17854. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  17855. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  17856. var match1to3 = /\d{1,3}/; // 0 - 999
  17857. var match1to4 = /\d{1,4}/; // 0 - 9999
  17858. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  17859. var matchUnsigned = /\d+/; // 0 - inf
  17860. var matchSigned = /[+-]?\d+/; // -inf - inf
  17861. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  17862. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  17863. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  17864. // any word (or two) characters or numbers including two/three word month in arabic.
  17865. // includes scottish gaelic two word and hyphenated months
  17866. var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
  17867. var regexes = {};
  17868. function addRegexToken (token, regex, strictRegex) {
  17869. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  17870. return (isStrict && strictRegex) ? strictRegex : regex;
  17871. };
  17872. }
  17873. function getParseRegexForToken (token, config) {
  17874. if (!hasOwnProp(regexes, token)) {
  17875. return new RegExp(unescapeFormat(token));
  17876. }
  17877. return regexes[token](config._strict, config._locale);
  17878. }
  17879. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  17880. function unescapeFormat(s) {
  17881. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  17882. return p1 || p2 || p3 || p4;
  17883. }));
  17884. }
  17885. function regexEscape(s) {
  17886. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  17887. }
  17888. var tokens = {};
  17889. function addParseToken (token, callback) {
  17890. var i, func = callback;
  17891. if (typeof token === 'string') {
  17892. token = [token];
  17893. }
  17894. if (isNumber(callback)) {
  17895. func = function (input, array) {
  17896. array[callback] = toInt(input);
  17897. };
  17898. }
  17899. for (i = 0; i < token.length; i++) {
  17900. tokens[token[i]] = func;
  17901. }
  17902. }
  17903. function addWeekParseToken (token, callback) {
  17904. addParseToken(token, function (input, array, config, token) {
  17905. config._w = config._w || {};
  17906. callback(input, config._w, config, token);
  17907. });
  17908. }
  17909. function addTimeToArrayFromToken(token, input, config) {
  17910. if (input != null && hasOwnProp(tokens, token)) {
  17911. tokens[token](input, config._a, config, token);
  17912. }
  17913. }
  17914. var YEAR = 0;
  17915. var MONTH = 1;
  17916. var DATE = 2;
  17917. var HOUR = 3;
  17918. var MINUTE = 4;
  17919. var SECOND = 5;
  17920. var MILLISECOND = 6;
  17921. var WEEK = 7;
  17922. var WEEKDAY = 8;
  17923. // FORMATTING
  17924. addFormatToken('Y', 0, 0, function () {
  17925. var y = this.year();
  17926. return y <= 9999 ? '' + y : '+' + y;
  17927. });
  17928. addFormatToken(0, ['YY', 2], 0, function () {
  17929. return this.year() % 100;
  17930. });
  17931. addFormatToken(0, ['YYYY', 4], 0, 'year');
  17932. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  17933. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  17934. // ALIASES
  17935. addUnitAlias('year', 'y');
  17936. // PRIORITIES
  17937. addUnitPriority('year', 1);
  17938. // PARSING
  17939. addRegexToken('Y', matchSigned);
  17940. addRegexToken('YY', match1to2, match2);
  17941. addRegexToken('YYYY', match1to4, match4);
  17942. addRegexToken('YYYYY', match1to6, match6);
  17943. addRegexToken('YYYYYY', match1to6, match6);
  17944. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  17945. addParseToken('YYYY', function (input, array) {
  17946. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  17947. });
  17948. addParseToken('YY', function (input, array) {
  17949. array[YEAR] = hooks.parseTwoDigitYear(input);
  17950. });
  17951. addParseToken('Y', function (input, array) {
  17952. array[YEAR] = parseInt(input, 10);
  17953. });
  17954. // HELPERS
  17955. function daysInYear(year) {
  17956. return isLeapYear(year) ? 366 : 365;
  17957. }
  17958. function isLeapYear(year) {
  17959. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  17960. }
  17961. // HOOKS
  17962. hooks.parseTwoDigitYear = function (input) {
  17963. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  17964. };
  17965. // MOMENTS
  17966. var getSetYear = makeGetSet('FullYear', true);
  17967. function getIsLeapYear () {
  17968. return isLeapYear(this.year());
  17969. }
  17970. function makeGetSet (unit, keepTime) {
  17971. return function (value) {
  17972. if (value != null) {
  17973. set$1(this, unit, value);
  17974. hooks.updateOffset(this, keepTime);
  17975. return this;
  17976. } else {
  17977. return get(this, unit);
  17978. }
  17979. };
  17980. }
  17981. function get (mom, unit) {
  17982. return mom.isValid() ?
  17983. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  17984. }
  17985. function set$1 (mom, unit, value) {
  17986. if (mom.isValid() && !isNaN(value)) {
  17987. if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
  17988. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
  17989. }
  17990. else {
  17991. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  17992. }
  17993. }
  17994. }
  17995. // MOMENTS
  17996. function stringGet (units) {
  17997. units = normalizeUnits(units);
  17998. if (isFunction(this[units])) {
  17999. return this[units]();
  18000. }
  18001. return this;
  18002. }
  18003. function stringSet (units, value) {
  18004. if (typeof units === 'object') {
  18005. units = normalizeObjectUnits(units);
  18006. var prioritized = getPrioritizedUnits(units);
  18007. for (var i = 0; i < prioritized.length; i++) {
  18008. this[prioritized[i].unit](units[prioritized[i].unit]);
  18009. }
  18010. } else {
  18011. units = normalizeUnits(units);
  18012. if (isFunction(this[units])) {
  18013. return this[units](value);
  18014. }
  18015. }
  18016. return this;
  18017. }
  18018. function mod(n, x) {
  18019. return ((n % x) + x) % x;
  18020. }
  18021. var indexOf;
  18022. if (Array.prototype.indexOf) {
  18023. indexOf = Array.prototype.indexOf;
  18024. } else {
  18025. indexOf = function (o) {
  18026. // I know
  18027. var i;
  18028. for (i = 0; i < this.length; ++i) {
  18029. if (this[i] === o) {
  18030. return i;
  18031. }
  18032. }
  18033. return -1;
  18034. };
  18035. }
  18036. function daysInMonth(year, month) {
  18037. if (isNaN(year) || isNaN(month)) {
  18038. return NaN;
  18039. }
  18040. var modMonth = mod(month, 12);
  18041. year += (month - modMonth) / 12;
  18042. return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
  18043. }
  18044. // FORMATTING
  18045. addFormatToken('M', ['MM', 2], 'Mo', function () {
  18046. return this.month() + 1;
  18047. });
  18048. addFormatToken('MMM', 0, 0, function (format) {
  18049. return this.localeData().monthsShort(this, format);
  18050. });
  18051. addFormatToken('MMMM', 0, 0, function (format) {
  18052. return this.localeData().months(this, format);
  18053. });
  18054. // ALIASES
  18055. addUnitAlias('month', 'M');
  18056. // PRIORITY
  18057. addUnitPriority('month', 8);
  18058. // PARSING
  18059. addRegexToken('M', match1to2);
  18060. addRegexToken('MM', match1to2, match2);
  18061. addRegexToken('MMM', function (isStrict, locale) {
  18062. return locale.monthsShortRegex(isStrict);
  18063. });
  18064. addRegexToken('MMMM', function (isStrict, locale) {
  18065. return locale.monthsRegex(isStrict);
  18066. });
  18067. addParseToken(['M', 'MM'], function (input, array) {
  18068. array[MONTH] = toInt(input) - 1;
  18069. });
  18070. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  18071. var month = config._locale.monthsParse(input, token, config._strict);
  18072. // if we didn't find a month name, mark the date as invalid.
  18073. if (month != null) {
  18074. array[MONTH] = month;
  18075. } else {
  18076. getParsingFlags(config).invalidMonth = input;
  18077. }
  18078. });
  18079. // LOCALES
  18080. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  18081. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  18082. function localeMonths (m, format) {
  18083. if (!m) {
  18084. return isArray(this._months) ? this._months :
  18085. this._months['standalone'];
  18086. }
  18087. return isArray(this._months) ? this._months[m.month()] :
  18088. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  18089. }
  18090. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  18091. function localeMonthsShort (m, format) {
  18092. if (!m) {
  18093. return isArray(this._monthsShort) ? this._monthsShort :
  18094. this._monthsShort['standalone'];
  18095. }
  18096. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  18097. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  18098. }
  18099. function handleStrictParse(monthName, format, strict) {
  18100. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  18101. if (!this._monthsParse) {
  18102. // this is not used
  18103. this._monthsParse = [];
  18104. this._longMonthsParse = [];
  18105. this._shortMonthsParse = [];
  18106. for (i = 0; i < 12; ++i) {
  18107. mom = createUTC([2000, i]);
  18108. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  18109. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  18110. }
  18111. }
  18112. if (strict) {
  18113. if (format === 'MMM') {
  18114. ii = indexOf.call(this._shortMonthsParse, llc);
  18115. return ii !== -1 ? ii : null;
  18116. } else {
  18117. ii = indexOf.call(this._longMonthsParse, llc);
  18118. return ii !== -1 ? ii : null;
  18119. }
  18120. } else {
  18121. if (format === 'MMM') {
  18122. ii = indexOf.call(this._shortMonthsParse, llc);
  18123. if (ii !== -1) {
  18124. return ii;
  18125. }
  18126. ii = indexOf.call(this._longMonthsParse, llc);
  18127. return ii !== -1 ? ii : null;
  18128. } else {
  18129. ii = indexOf.call(this._longMonthsParse, llc);
  18130. if (ii !== -1) {
  18131. return ii;
  18132. }
  18133. ii = indexOf.call(this._shortMonthsParse, llc);
  18134. return ii !== -1 ? ii : null;
  18135. }
  18136. }
  18137. }
  18138. function localeMonthsParse (monthName, format, strict) {
  18139. var i, mom, regex;
  18140. if (this._monthsParseExact) {
  18141. return handleStrictParse.call(this, monthName, format, strict);
  18142. }
  18143. if (!this._monthsParse) {
  18144. this._monthsParse = [];
  18145. this._longMonthsParse = [];
  18146. this._shortMonthsParse = [];
  18147. }
  18148. // TODO: add sorting
  18149. // Sorting makes sure if one month (or abbr) is a prefix of another
  18150. // see sorting in computeMonthsParse
  18151. for (i = 0; i < 12; i++) {
  18152. // make the regex if we don't have it already
  18153. mom = createUTC([2000, i]);
  18154. if (strict && !this._longMonthsParse[i]) {
  18155. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  18156. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  18157. }
  18158. if (!strict && !this._monthsParse[i]) {
  18159. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  18160. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  18161. }
  18162. // test the regex
  18163. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  18164. return i;
  18165. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  18166. return i;
  18167. } else if (!strict && this._monthsParse[i].test(monthName)) {
  18168. return i;
  18169. }
  18170. }
  18171. }
  18172. // MOMENTS
  18173. function setMonth (mom, value) {
  18174. var dayOfMonth;
  18175. if (!mom.isValid()) {
  18176. // No op
  18177. return mom;
  18178. }
  18179. if (typeof value === 'string') {
  18180. if (/^\d+$/.test(value)) {
  18181. value = toInt(value);
  18182. } else {
  18183. value = mom.localeData().monthsParse(value);
  18184. // TODO: Another silent failure?
  18185. if (!isNumber(value)) {
  18186. return mom;
  18187. }
  18188. }
  18189. }
  18190. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  18191. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  18192. return mom;
  18193. }
  18194. function getSetMonth (value) {
  18195. if (value != null) {
  18196. setMonth(this, value);
  18197. hooks.updateOffset(this, true);
  18198. return this;
  18199. } else {
  18200. return get(this, 'Month');
  18201. }
  18202. }
  18203. function getDaysInMonth () {
  18204. return daysInMonth(this.year(), this.month());
  18205. }
  18206. var defaultMonthsShortRegex = matchWord;
  18207. function monthsShortRegex (isStrict) {
  18208. if (this._monthsParseExact) {
  18209. if (!hasOwnProp(this, '_monthsRegex')) {
  18210. computeMonthsParse.call(this);
  18211. }
  18212. if (isStrict) {
  18213. return this._monthsShortStrictRegex;
  18214. } else {
  18215. return this._monthsShortRegex;
  18216. }
  18217. } else {
  18218. if (!hasOwnProp(this, '_monthsShortRegex')) {
  18219. this._monthsShortRegex = defaultMonthsShortRegex;
  18220. }
  18221. return this._monthsShortStrictRegex && isStrict ?
  18222. this._monthsShortStrictRegex : this._monthsShortRegex;
  18223. }
  18224. }
  18225. var defaultMonthsRegex = matchWord;
  18226. function monthsRegex (isStrict) {
  18227. if (this._monthsParseExact) {
  18228. if (!hasOwnProp(this, '_monthsRegex')) {
  18229. computeMonthsParse.call(this);
  18230. }
  18231. if (isStrict) {
  18232. return this._monthsStrictRegex;
  18233. } else {
  18234. return this._monthsRegex;
  18235. }
  18236. } else {
  18237. if (!hasOwnProp(this, '_monthsRegex')) {
  18238. this._monthsRegex = defaultMonthsRegex;
  18239. }
  18240. return this._monthsStrictRegex && isStrict ?
  18241. this._monthsStrictRegex : this._monthsRegex;
  18242. }
  18243. }
  18244. function computeMonthsParse () {
  18245. function cmpLenRev(a, b) {
  18246. return b.length - a.length;
  18247. }
  18248. var shortPieces = [], longPieces = [], mixedPieces = [],
  18249. i, mom;
  18250. for (i = 0; i < 12; i++) {
  18251. // make the regex if we don't have it already
  18252. mom = createUTC([2000, i]);
  18253. shortPieces.push(this.monthsShort(mom, ''));
  18254. longPieces.push(this.months(mom, ''));
  18255. mixedPieces.push(this.months(mom, ''));
  18256. mixedPieces.push(this.monthsShort(mom, ''));
  18257. }
  18258. // Sorting makes sure if one month (or abbr) is a prefix of another it
  18259. // will match the longer piece.
  18260. shortPieces.sort(cmpLenRev);
  18261. longPieces.sort(cmpLenRev);
  18262. mixedPieces.sort(cmpLenRev);
  18263. for (i = 0; i < 12; i++) {
  18264. shortPieces[i] = regexEscape(shortPieces[i]);
  18265. longPieces[i] = regexEscape(longPieces[i]);
  18266. }
  18267. for (i = 0; i < 24; i++) {
  18268. mixedPieces[i] = regexEscape(mixedPieces[i]);
  18269. }
  18270. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  18271. this._monthsShortRegex = this._monthsRegex;
  18272. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  18273. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  18274. }
  18275. function createDate (y, m, d, h, M, s, ms) {
  18276. // can't just apply() to create a date:
  18277. // https://stackoverflow.com/q/181348
  18278. var date = new Date(y, m, d, h, M, s, ms);
  18279. // the date constructor remaps years 0-99 to 1900-1999
  18280. if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  18281. date.setFullYear(y);
  18282. }
  18283. return date;
  18284. }
  18285. function createUTCDate (y) {
  18286. var date = new Date(Date.UTC.apply(null, arguments));
  18287. // the Date.UTC function remaps years 0-99 to 1900-1999
  18288. if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  18289. date.setUTCFullYear(y);
  18290. }
  18291. return date;
  18292. }
  18293. // start-of-first-week - start-of-year
  18294. function firstWeekOffset(year, dow, doy) {
  18295. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  18296. fwd = 7 + dow - doy,
  18297. // first-week day local weekday -- which local weekday is fwd
  18298. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  18299. return -fwdlw + fwd - 1;
  18300. }
  18301. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  18302. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  18303. var localWeekday = (7 + weekday - dow) % 7,
  18304. weekOffset = firstWeekOffset(year, dow, doy),
  18305. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  18306. resYear, resDayOfYear;
  18307. if (dayOfYear <= 0) {
  18308. resYear = year - 1;
  18309. resDayOfYear = daysInYear(resYear) + dayOfYear;
  18310. } else if (dayOfYear > daysInYear(year)) {
  18311. resYear = year + 1;
  18312. resDayOfYear = dayOfYear - daysInYear(year);
  18313. } else {
  18314. resYear = year;
  18315. resDayOfYear = dayOfYear;
  18316. }
  18317. return {
  18318. year: resYear,
  18319. dayOfYear: resDayOfYear
  18320. };
  18321. }
  18322. function weekOfYear(mom, dow, doy) {
  18323. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  18324. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  18325. resWeek, resYear;
  18326. if (week < 1) {
  18327. resYear = mom.year() - 1;
  18328. resWeek = week + weeksInYear(resYear, dow, doy);
  18329. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  18330. resWeek = week - weeksInYear(mom.year(), dow, doy);
  18331. resYear = mom.year() + 1;
  18332. } else {
  18333. resYear = mom.year();
  18334. resWeek = week;
  18335. }
  18336. return {
  18337. week: resWeek,
  18338. year: resYear
  18339. };
  18340. }
  18341. function weeksInYear(year, dow, doy) {
  18342. var weekOffset = firstWeekOffset(year, dow, doy),
  18343. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  18344. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  18345. }
  18346. // FORMATTING
  18347. addFormatToken('w', ['ww', 2], 'wo', 'week');
  18348. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  18349. // ALIASES
  18350. addUnitAlias('week', 'w');
  18351. addUnitAlias('isoWeek', 'W');
  18352. // PRIORITIES
  18353. addUnitPriority('week', 5);
  18354. addUnitPriority('isoWeek', 5);
  18355. // PARSING
  18356. addRegexToken('w', match1to2);
  18357. addRegexToken('ww', match1to2, match2);
  18358. addRegexToken('W', match1to2);
  18359. addRegexToken('WW', match1to2, match2);
  18360. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  18361. week[token.substr(0, 1)] = toInt(input);
  18362. });
  18363. // HELPERS
  18364. // LOCALES
  18365. function localeWeek (mom) {
  18366. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  18367. }
  18368. var defaultLocaleWeek = {
  18369. dow : 0, // Sunday is the first day of the week.
  18370. doy : 6 // The week that contains Jan 1st is the first week of the year.
  18371. };
  18372. function localeFirstDayOfWeek () {
  18373. return this._week.dow;
  18374. }
  18375. function localeFirstDayOfYear () {
  18376. return this._week.doy;
  18377. }
  18378. // MOMENTS
  18379. function getSetWeek (input) {
  18380. var week = this.localeData().week(this);
  18381. return input == null ? week : this.add((input - week) * 7, 'd');
  18382. }
  18383. function getSetISOWeek (input) {
  18384. var week = weekOfYear(this, 1, 4).week;
  18385. return input == null ? week : this.add((input - week) * 7, 'd');
  18386. }
  18387. // FORMATTING
  18388. addFormatToken('d', 0, 'do', 'day');
  18389. addFormatToken('dd', 0, 0, function (format) {
  18390. return this.localeData().weekdaysMin(this, format);
  18391. });
  18392. addFormatToken('ddd', 0, 0, function (format) {
  18393. return this.localeData().weekdaysShort(this, format);
  18394. });
  18395. addFormatToken('dddd', 0, 0, function (format) {
  18396. return this.localeData().weekdays(this, format);
  18397. });
  18398. addFormatToken('e', 0, 0, 'weekday');
  18399. addFormatToken('E', 0, 0, 'isoWeekday');
  18400. // ALIASES
  18401. addUnitAlias('day', 'd');
  18402. addUnitAlias('weekday', 'e');
  18403. addUnitAlias('isoWeekday', 'E');
  18404. // PRIORITY
  18405. addUnitPriority('day', 11);
  18406. addUnitPriority('weekday', 11);
  18407. addUnitPriority('isoWeekday', 11);
  18408. // PARSING
  18409. addRegexToken('d', match1to2);
  18410. addRegexToken('e', match1to2);
  18411. addRegexToken('E', match1to2);
  18412. addRegexToken('dd', function (isStrict, locale) {
  18413. return locale.weekdaysMinRegex(isStrict);
  18414. });
  18415. addRegexToken('ddd', function (isStrict, locale) {
  18416. return locale.weekdaysShortRegex(isStrict);
  18417. });
  18418. addRegexToken('dddd', function (isStrict, locale) {
  18419. return locale.weekdaysRegex(isStrict);
  18420. });
  18421. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  18422. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  18423. // if we didn't get a weekday name, mark the date as invalid
  18424. if (weekday != null) {
  18425. week.d = weekday;
  18426. } else {
  18427. getParsingFlags(config).invalidWeekday = input;
  18428. }
  18429. });
  18430. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  18431. week[token] = toInt(input);
  18432. });
  18433. // HELPERS
  18434. function parseWeekday(input, locale) {
  18435. if (typeof input !== 'string') {
  18436. return input;
  18437. }
  18438. if (!isNaN(input)) {
  18439. return parseInt(input, 10);
  18440. }
  18441. input = locale.weekdaysParse(input);
  18442. if (typeof input === 'number') {
  18443. return input;
  18444. }
  18445. return null;
  18446. }
  18447. function parseIsoWeekday(input, locale) {
  18448. if (typeof input === 'string') {
  18449. return locale.weekdaysParse(input) % 7 || 7;
  18450. }
  18451. return isNaN(input) ? null : input;
  18452. }
  18453. // LOCALES
  18454. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  18455. function localeWeekdays (m, format) {
  18456. if (!m) {
  18457. return isArray(this._weekdays) ? this._weekdays :
  18458. this._weekdays['standalone'];
  18459. }
  18460. return isArray(this._weekdays) ? this._weekdays[m.day()] :
  18461. this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
  18462. }
  18463. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  18464. function localeWeekdaysShort (m) {
  18465. return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  18466. }
  18467. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  18468. function localeWeekdaysMin (m) {
  18469. return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  18470. }
  18471. function handleStrictParse$1(weekdayName, format, strict) {
  18472. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  18473. if (!this._weekdaysParse) {
  18474. this._weekdaysParse = [];
  18475. this._shortWeekdaysParse = [];
  18476. this._minWeekdaysParse = [];
  18477. for (i = 0; i < 7; ++i) {
  18478. mom = createUTC([2000, 1]).day(i);
  18479. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  18480. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  18481. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  18482. }
  18483. }
  18484. if (strict) {
  18485. if (format === 'dddd') {
  18486. ii = indexOf.call(this._weekdaysParse, llc);
  18487. return ii !== -1 ? ii : null;
  18488. } else if (format === 'ddd') {
  18489. ii = indexOf.call(this._shortWeekdaysParse, llc);
  18490. return ii !== -1 ? ii : null;
  18491. } else {
  18492. ii = indexOf.call(this._minWeekdaysParse, llc);
  18493. return ii !== -1 ? ii : null;
  18494. }
  18495. } else {
  18496. if (format === 'dddd') {
  18497. ii = indexOf.call(this._weekdaysParse, llc);
  18498. if (ii !== -1) {
  18499. return ii;
  18500. }
  18501. ii = indexOf.call(this._shortWeekdaysParse, llc);
  18502. if (ii !== -1) {
  18503. return ii;
  18504. }
  18505. ii = indexOf.call(this._minWeekdaysParse, llc);
  18506. return ii !== -1 ? ii : null;
  18507. } else if (format === 'ddd') {
  18508. ii = indexOf.call(this._shortWeekdaysParse, llc);
  18509. if (ii !== -1) {
  18510. return ii;
  18511. }
  18512. ii = indexOf.call(this._weekdaysParse, llc);
  18513. if (ii !== -1) {
  18514. return ii;
  18515. }
  18516. ii = indexOf.call(this._minWeekdaysParse, llc);
  18517. return ii !== -1 ? ii : null;
  18518. } else {
  18519. ii = indexOf.call(this._minWeekdaysParse, llc);
  18520. if (ii !== -1) {
  18521. return ii;
  18522. }
  18523. ii = indexOf.call(this._weekdaysParse, llc);
  18524. if (ii !== -1) {
  18525. return ii;
  18526. }
  18527. ii = indexOf.call(this._shortWeekdaysParse, llc);
  18528. return ii !== -1 ? ii : null;
  18529. }
  18530. }
  18531. }
  18532. function localeWeekdaysParse (weekdayName, format, strict) {
  18533. var i, mom, regex;
  18534. if (this._weekdaysParseExact) {
  18535. return handleStrictParse$1.call(this, weekdayName, format, strict);
  18536. }
  18537. if (!this._weekdaysParse) {
  18538. this._weekdaysParse = [];
  18539. this._minWeekdaysParse = [];
  18540. this._shortWeekdaysParse = [];
  18541. this._fullWeekdaysParse = [];
  18542. }
  18543. for (i = 0; i < 7; i++) {
  18544. // make the regex if we don't have it already
  18545. mom = createUTC([2000, 1]).day(i);
  18546. if (strict && !this._fullWeekdaysParse[i]) {
  18547. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
  18548. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
  18549. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
  18550. }
  18551. if (!this._weekdaysParse[i]) {
  18552. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  18553. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  18554. }
  18555. // test the regex
  18556. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  18557. return i;
  18558. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  18559. return i;
  18560. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  18561. return i;
  18562. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  18563. return i;
  18564. }
  18565. }
  18566. }
  18567. // MOMENTS
  18568. function getSetDayOfWeek (input) {
  18569. if (!this.isValid()) {
  18570. return input != null ? this : NaN;
  18571. }
  18572. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  18573. if (input != null) {
  18574. input = parseWeekday(input, this.localeData());
  18575. return this.add(input - day, 'd');
  18576. } else {
  18577. return day;
  18578. }
  18579. }
  18580. function getSetLocaleDayOfWeek (input) {
  18581. if (!this.isValid()) {
  18582. return input != null ? this : NaN;
  18583. }
  18584. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  18585. return input == null ? weekday : this.add(input - weekday, 'd');
  18586. }
  18587. function getSetISODayOfWeek (input) {
  18588. if (!this.isValid()) {
  18589. return input != null ? this : NaN;
  18590. }
  18591. // behaves the same as moment#day except
  18592. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  18593. // as a setter, sunday should belong to the previous week.
  18594. if (input != null) {
  18595. var weekday = parseIsoWeekday(input, this.localeData());
  18596. return this.day(this.day() % 7 ? weekday : weekday - 7);
  18597. } else {
  18598. return this.day() || 7;
  18599. }
  18600. }
  18601. var defaultWeekdaysRegex = matchWord;
  18602. function weekdaysRegex (isStrict) {
  18603. if (this._weekdaysParseExact) {
  18604. if (!hasOwnProp(this, '_weekdaysRegex')) {
  18605. computeWeekdaysParse.call(this);
  18606. }
  18607. if (isStrict) {
  18608. return this._weekdaysStrictRegex;
  18609. } else {
  18610. return this._weekdaysRegex;
  18611. }
  18612. } else {
  18613. if (!hasOwnProp(this, '_weekdaysRegex')) {
  18614. this._weekdaysRegex = defaultWeekdaysRegex;
  18615. }
  18616. return this._weekdaysStrictRegex && isStrict ?
  18617. this._weekdaysStrictRegex : this._weekdaysRegex;
  18618. }
  18619. }
  18620. var defaultWeekdaysShortRegex = matchWord;
  18621. function weekdaysShortRegex (isStrict) {
  18622. if (this._weekdaysParseExact) {
  18623. if (!hasOwnProp(this, '_weekdaysRegex')) {
  18624. computeWeekdaysParse.call(this);
  18625. }
  18626. if (isStrict) {
  18627. return this._weekdaysShortStrictRegex;
  18628. } else {
  18629. return this._weekdaysShortRegex;
  18630. }
  18631. } else {
  18632. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  18633. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  18634. }
  18635. return this._weekdaysShortStrictRegex && isStrict ?
  18636. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  18637. }
  18638. }
  18639. var defaultWeekdaysMinRegex = matchWord;
  18640. function weekdaysMinRegex (isStrict) {
  18641. if (this._weekdaysParseExact) {
  18642. if (!hasOwnProp(this, '_weekdaysRegex')) {
  18643. computeWeekdaysParse.call(this);
  18644. }
  18645. if (isStrict) {
  18646. return this._weekdaysMinStrictRegex;
  18647. } else {
  18648. return this._weekdaysMinRegex;
  18649. }
  18650. } else {
  18651. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  18652. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  18653. }
  18654. return this._weekdaysMinStrictRegex && isStrict ?
  18655. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  18656. }
  18657. }
  18658. function computeWeekdaysParse () {
  18659. function cmpLenRev(a, b) {
  18660. return b.length - a.length;
  18661. }
  18662. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  18663. i, mom, minp, shortp, longp;
  18664. for (i = 0; i < 7; i++) {
  18665. // make the regex if we don't have it already
  18666. mom = createUTC([2000, 1]).day(i);
  18667. minp = this.weekdaysMin(mom, '');
  18668. shortp = this.weekdaysShort(mom, '');
  18669. longp = this.weekdays(mom, '');
  18670. minPieces.push(minp);
  18671. shortPieces.push(shortp);
  18672. longPieces.push(longp);
  18673. mixedPieces.push(minp);
  18674. mixedPieces.push(shortp);
  18675. mixedPieces.push(longp);
  18676. }
  18677. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  18678. // will match the longer piece.
  18679. minPieces.sort(cmpLenRev);
  18680. shortPieces.sort(cmpLenRev);
  18681. longPieces.sort(cmpLenRev);
  18682. mixedPieces.sort(cmpLenRev);
  18683. for (i = 0; i < 7; i++) {
  18684. shortPieces[i] = regexEscape(shortPieces[i]);
  18685. longPieces[i] = regexEscape(longPieces[i]);
  18686. mixedPieces[i] = regexEscape(mixedPieces[i]);
  18687. }
  18688. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  18689. this._weekdaysShortRegex = this._weekdaysRegex;
  18690. this._weekdaysMinRegex = this._weekdaysRegex;
  18691. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  18692. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  18693. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  18694. }
  18695. // FORMATTING
  18696. function hFormat() {
  18697. return this.hours() % 12 || 12;
  18698. }
  18699. function kFormat() {
  18700. return this.hours() || 24;
  18701. }
  18702. addFormatToken('H', ['HH', 2], 0, 'hour');
  18703. addFormatToken('h', ['hh', 2], 0, hFormat);
  18704. addFormatToken('k', ['kk', 2], 0, kFormat);
  18705. addFormatToken('hmm', 0, 0, function () {
  18706. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  18707. });
  18708. addFormatToken('hmmss', 0, 0, function () {
  18709. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  18710. zeroFill(this.seconds(), 2);
  18711. });
  18712. addFormatToken('Hmm', 0, 0, function () {
  18713. return '' + this.hours() + zeroFill(this.minutes(), 2);
  18714. });
  18715. addFormatToken('Hmmss', 0, 0, function () {
  18716. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  18717. zeroFill(this.seconds(), 2);
  18718. });
  18719. function meridiem (token, lowercase) {
  18720. addFormatToken(token, 0, 0, function () {
  18721. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  18722. });
  18723. }
  18724. meridiem('a', true);
  18725. meridiem('A', false);
  18726. // ALIASES
  18727. addUnitAlias('hour', 'h');
  18728. // PRIORITY
  18729. addUnitPriority('hour', 13);
  18730. // PARSING
  18731. function matchMeridiem (isStrict, locale) {
  18732. return locale._meridiemParse;
  18733. }
  18734. addRegexToken('a', matchMeridiem);
  18735. addRegexToken('A', matchMeridiem);
  18736. addRegexToken('H', match1to2);
  18737. addRegexToken('h', match1to2);
  18738. addRegexToken('k', match1to2);
  18739. addRegexToken('HH', match1to2, match2);
  18740. addRegexToken('hh', match1to2, match2);
  18741. addRegexToken('kk', match1to2, match2);
  18742. addRegexToken('hmm', match3to4);
  18743. addRegexToken('hmmss', match5to6);
  18744. addRegexToken('Hmm', match3to4);
  18745. addRegexToken('Hmmss', match5to6);
  18746. addParseToken(['H', 'HH'], HOUR);
  18747. addParseToken(['k', 'kk'], function (input, array, config) {
  18748. var kInput = toInt(input);
  18749. array[HOUR] = kInput === 24 ? 0 : kInput;
  18750. });
  18751. addParseToken(['a', 'A'], function (input, array, config) {
  18752. config._isPm = config._locale.isPM(input);
  18753. config._meridiem = input;
  18754. });
  18755. addParseToken(['h', 'hh'], function (input, array, config) {
  18756. array[HOUR] = toInt(input);
  18757. getParsingFlags(config).bigHour = true;
  18758. });
  18759. addParseToken('hmm', function (input, array, config) {
  18760. var pos = input.length - 2;
  18761. array[HOUR] = toInt(input.substr(0, pos));
  18762. array[MINUTE] = toInt(input.substr(pos));
  18763. getParsingFlags(config).bigHour = true;
  18764. });
  18765. addParseToken('hmmss', function (input, array, config) {
  18766. var pos1 = input.length - 4;
  18767. var pos2 = input.length - 2;
  18768. array[HOUR] = toInt(input.substr(0, pos1));
  18769. array[MINUTE] = toInt(input.substr(pos1, 2));
  18770. array[SECOND] = toInt(input.substr(pos2));
  18771. getParsingFlags(config).bigHour = true;
  18772. });
  18773. addParseToken('Hmm', function (input, array, config) {
  18774. var pos = input.length - 2;
  18775. array[HOUR] = toInt(input.substr(0, pos));
  18776. array[MINUTE] = toInt(input.substr(pos));
  18777. });
  18778. addParseToken('Hmmss', function (input, array, config) {
  18779. var pos1 = input.length - 4;
  18780. var pos2 = input.length - 2;
  18781. array[HOUR] = toInt(input.substr(0, pos1));
  18782. array[MINUTE] = toInt(input.substr(pos1, 2));
  18783. array[SECOND] = toInt(input.substr(pos2));
  18784. });
  18785. // LOCALES
  18786. function localeIsPM (input) {
  18787. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  18788. // Using charAt should be more compatible.
  18789. return ((input + '').toLowerCase().charAt(0) === 'p');
  18790. }
  18791. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  18792. function localeMeridiem (hours, minutes, isLower) {
  18793. if (hours > 11) {
  18794. return isLower ? 'pm' : 'PM';
  18795. } else {
  18796. return isLower ? 'am' : 'AM';
  18797. }
  18798. }
  18799. // MOMENTS
  18800. // Setting the hour should keep the time, because the user explicitly
  18801. // specified which hour he wants. So trying to maintain the same hour (in
  18802. // a new timezone) makes sense. Adding/subtracting hours does not follow
  18803. // this rule.
  18804. var getSetHour = makeGetSet('Hours', true);
  18805. // months
  18806. // week
  18807. // weekdays
  18808. // meridiem
  18809. var baseConfig = {
  18810. calendar: defaultCalendar,
  18811. longDateFormat: defaultLongDateFormat,
  18812. invalidDate: defaultInvalidDate,
  18813. ordinal: defaultOrdinal,
  18814. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  18815. relativeTime: defaultRelativeTime,
  18816. months: defaultLocaleMonths,
  18817. monthsShort: defaultLocaleMonthsShort,
  18818. week: defaultLocaleWeek,
  18819. weekdays: defaultLocaleWeekdays,
  18820. weekdaysMin: defaultLocaleWeekdaysMin,
  18821. weekdaysShort: defaultLocaleWeekdaysShort,
  18822. meridiemParse: defaultLocaleMeridiemParse
  18823. };
  18824. // internal storage for locale config files
  18825. var locales = {};
  18826. var localeFamilies = {};
  18827. var globalLocale;
  18828. function normalizeLocale(key) {
  18829. return key ? key.toLowerCase().replace('_', '-') : key;
  18830. }
  18831. // pick the locale from the array
  18832. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  18833. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  18834. function chooseLocale(names) {
  18835. var i = 0, j, next, locale, split;
  18836. while (i < names.length) {
  18837. split = normalizeLocale(names[i]).split('-');
  18838. j = split.length;
  18839. next = normalizeLocale(names[i + 1]);
  18840. next = next ? next.split('-') : null;
  18841. while (j > 0) {
  18842. locale = loadLocale(split.slice(0, j).join('-'));
  18843. if (locale) {
  18844. return locale;
  18845. }
  18846. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  18847. //the next array item is better than a shallower substring of this one
  18848. break;
  18849. }
  18850. j--;
  18851. }
  18852. i++;
  18853. }
  18854. return null;
  18855. }
  18856. function loadLocale(name) {
  18857. var oldLocale = null;
  18858. // TODO: Find a better way to register and load all the locales in Node
  18859. if (!locales[name] && (typeof module !== 'undefined') &&
  18860. module && module.exports) {
  18861. try {
  18862. oldLocale = globalLocale._abbr;
  18863. var aliasedRequire = require;
  18864. aliasedRequire('./locale/' + name);
  18865. getSetGlobalLocale(oldLocale);
  18866. } catch (e) {}
  18867. }
  18868. return locales[name];
  18869. }
  18870. // This function will load locale and then set the global locale. If
  18871. // no arguments are passed in, it will simply return the current global
  18872. // locale key.
  18873. function getSetGlobalLocale (key, values) {
  18874. var data;
  18875. if (key) {
  18876. if (isUndefined(values)) {
  18877. data = getLocale(key);
  18878. }
  18879. else {
  18880. data = defineLocale(key, values);
  18881. }
  18882. if (data) {
  18883. // moment.duration._locale = moment._locale = data;
  18884. globalLocale = data;
  18885. }
  18886. }
  18887. return globalLocale._abbr;
  18888. }
  18889. function defineLocale (name, config) {
  18890. if (config !== null) {
  18891. var parentConfig = baseConfig;
  18892. config.abbr = name;
  18893. if (locales[name] != null) {
  18894. deprecateSimple('defineLocaleOverride',
  18895. 'use moment.updateLocale(localeName, config) to change ' +
  18896. 'an existing locale. moment.defineLocale(localeName, ' +
  18897. 'config) should only be used for creating a new locale ' +
  18898. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  18899. parentConfig = locales[name]._config;
  18900. } else if (config.parentLocale != null) {
  18901. if (locales[config.parentLocale] != null) {
  18902. parentConfig = locales[config.parentLocale]._config;
  18903. } else {
  18904. if (!localeFamilies[config.parentLocale]) {
  18905. localeFamilies[config.parentLocale] = [];
  18906. }
  18907. localeFamilies[config.parentLocale].push({
  18908. name: name,
  18909. config: config
  18910. });
  18911. return null;
  18912. }
  18913. }
  18914. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  18915. if (localeFamilies[name]) {
  18916. localeFamilies[name].forEach(function (x) {
  18917. defineLocale(x.name, x.config);
  18918. });
  18919. }
  18920. // backwards compat for now: also set the locale
  18921. // make sure we set the locale AFTER all child locales have been
  18922. // created, so we won't end up with the child locale set.
  18923. getSetGlobalLocale(name);
  18924. return locales[name];
  18925. } else {
  18926. // useful for testing
  18927. delete locales[name];
  18928. return null;
  18929. }
  18930. }
  18931. function updateLocale(name, config) {
  18932. if (config != null) {
  18933. var locale, tmpLocale, parentConfig = baseConfig;
  18934. // MERGE
  18935. tmpLocale = loadLocale(name);
  18936. if (tmpLocale != null) {
  18937. parentConfig = tmpLocale._config;
  18938. }
  18939. config = mergeConfigs(parentConfig, config);
  18940. locale = new Locale(config);
  18941. locale.parentLocale = locales[name];
  18942. locales[name] = locale;
  18943. // backwards compat for now: also set the locale
  18944. getSetGlobalLocale(name);
  18945. } else {
  18946. // pass null for config to unupdate, useful for tests
  18947. if (locales[name] != null) {
  18948. if (locales[name].parentLocale != null) {
  18949. locales[name] = locales[name].parentLocale;
  18950. } else if (locales[name] != null) {
  18951. delete locales[name];
  18952. }
  18953. }
  18954. }
  18955. return locales[name];
  18956. }
  18957. // returns locale data
  18958. function getLocale (key) {
  18959. var locale;
  18960. if (key && key._locale && key._locale._abbr) {
  18961. key = key._locale._abbr;
  18962. }
  18963. if (!key) {
  18964. return globalLocale;
  18965. }
  18966. if (!isArray(key)) {
  18967. //short-circuit everything else
  18968. locale = loadLocale(key);
  18969. if (locale) {
  18970. return locale;
  18971. }
  18972. key = [key];
  18973. }
  18974. return chooseLocale(key);
  18975. }
  18976. function listLocales() {
  18977. return keys(locales);
  18978. }
  18979. function checkOverflow (m) {
  18980. var overflow;
  18981. var a = m._a;
  18982. if (a && getParsingFlags(m).overflow === -2) {
  18983. overflow =
  18984. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  18985. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  18986. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  18987. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  18988. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  18989. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  18990. -1;
  18991. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  18992. overflow = DATE;
  18993. }
  18994. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  18995. overflow = WEEK;
  18996. }
  18997. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  18998. overflow = WEEKDAY;
  18999. }
  19000. getParsingFlags(m).overflow = overflow;
  19001. }
  19002. return m;
  19003. }
  19004. // Pick the first defined of two or three arguments.
  19005. function defaults(a, b, c) {
  19006. if (a != null) {
  19007. return a;
  19008. }
  19009. if (b != null) {
  19010. return b;
  19011. }
  19012. return c;
  19013. }
  19014. function currentDateArray(config) {
  19015. // hooks is actually the exported moment object
  19016. var nowValue = new Date(hooks.now());
  19017. if (config._useUTC) {
  19018. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  19019. }
  19020. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  19021. }
  19022. // convert an array to a date.
  19023. // the array should mirror the parameters below
  19024. // note: all values past the year are optional and will default to the lowest possible value.
  19025. // [year, month, day , hour, minute, second, millisecond]
  19026. function configFromArray (config) {
  19027. var i, date, input = [], currentDate, expectedWeekday, yearToUse;
  19028. if (config._d) {
  19029. return;
  19030. }
  19031. currentDate = currentDateArray(config);
  19032. //compute day of the year from weeks and weekdays
  19033. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  19034. dayOfYearFromWeekInfo(config);
  19035. }
  19036. //if the day of the year is set, figure out what it is
  19037. if (config._dayOfYear != null) {
  19038. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  19039. if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
  19040. getParsingFlags(config)._overflowDayOfYear = true;
  19041. }
  19042. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  19043. config._a[MONTH] = date.getUTCMonth();
  19044. config._a[DATE] = date.getUTCDate();
  19045. }
  19046. // Default to current date.
  19047. // * if no year, month, day of month are given, default to today
  19048. // * if day of month is given, default month and year
  19049. // * if month is given, default only year
  19050. // * if year is given, don't default anything
  19051. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  19052. config._a[i] = input[i] = currentDate[i];
  19053. }
  19054. // Zero out whatever was not defaulted, including time
  19055. for (; i < 7; i++) {
  19056. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  19057. }
  19058. // Check for 24:00:00.000
  19059. if (config._a[HOUR] === 24 &&
  19060. config._a[MINUTE] === 0 &&
  19061. config._a[SECOND] === 0 &&
  19062. config._a[MILLISECOND] === 0) {
  19063. config._nextDay = true;
  19064. config._a[HOUR] = 0;
  19065. }
  19066. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  19067. expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
  19068. // Apply timezone offset from input. The actual utcOffset can be changed
  19069. // with parseZone.
  19070. if (config._tzm != null) {
  19071. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  19072. }
  19073. if (config._nextDay) {
  19074. config._a[HOUR] = 24;
  19075. }
  19076. // check for mismatching day of week
  19077. if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
  19078. getParsingFlags(config).weekdayMismatch = true;
  19079. }
  19080. }
  19081. function dayOfYearFromWeekInfo(config) {
  19082. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  19083. w = config._w;
  19084. if (w.GG != null || w.W != null || w.E != null) {
  19085. dow = 1;
  19086. doy = 4;
  19087. // TODO: We need to take the current isoWeekYear, but that depends on
  19088. // how we interpret now (local, utc, fixed offset). So create
  19089. // a now version of current config (take local/utc/offset flags, and
  19090. // create now).
  19091. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  19092. week = defaults(w.W, 1);
  19093. weekday = defaults(w.E, 1);
  19094. if (weekday < 1 || weekday > 7) {
  19095. weekdayOverflow = true;
  19096. }
  19097. } else {
  19098. dow = config._locale._week.dow;
  19099. doy = config._locale._week.doy;
  19100. var curWeek = weekOfYear(createLocal(), dow, doy);
  19101. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  19102. // Default to current week.
  19103. week = defaults(w.w, curWeek.week);
  19104. if (w.d != null) {
  19105. // weekday -- low day numbers are considered next week
  19106. weekday = w.d;
  19107. if (weekday < 0 || weekday > 6) {
  19108. weekdayOverflow = true;
  19109. }
  19110. } else if (w.e != null) {
  19111. // local weekday -- counting starts from begining of week
  19112. weekday = w.e + dow;
  19113. if (w.e < 0 || w.e > 6) {
  19114. weekdayOverflow = true;
  19115. }
  19116. } else {
  19117. // default to begining of week
  19118. weekday = dow;
  19119. }
  19120. }
  19121. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  19122. getParsingFlags(config)._overflowWeeks = true;
  19123. } else if (weekdayOverflow != null) {
  19124. getParsingFlags(config)._overflowWeekday = true;
  19125. } else {
  19126. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  19127. config._a[YEAR] = temp.year;
  19128. config._dayOfYear = temp.dayOfYear;
  19129. }
  19130. }
  19131. // iso 8601 regex
  19132. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  19133. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  19134. var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  19135. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  19136. var isoDates = [
  19137. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  19138. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  19139. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  19140. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  19141. ['YYYY-DDD', /\d{4}-\d{3}/],
  19142. ['YYYY-MM', /\d{4}-\d\d/, false],
  19143. ['YYYYYYMMDD', /[+-]\d{10}/],
  19144. ['YYYYMMDD', /\d{8}/],
  19145. // YYYYMM is NOT allowed by the standard
  19146. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  19147. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  19148. ['YYYYDDD', /\d{7}/]
  19149. ];
  19150. // iso time formats and regexes
  19151. var isoTimes = [
  19152. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  19153. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  19154. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  19155. ['HH:mm', /\d\d:\d\d/],
  19156. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  19157. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  19158. ['HHmmss', /\d\d\d\d\d\d/],
  19159. ['HHmm', /\d\d\d\d/],
  19160. ['HH', /\d\d/]
  19161. ];
  19162. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  19163. // date from iso format
  19164. function configFromISO(config) {
  19165. var i, l,
  19166. string = config._i,
  19167. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  19168. allowTime, dateFormat, timeFormat, tzFormat;
  19169. if (match) {
  19170. getParsingFlags(config).iso = true;
  19171. for (i = 0, l = isoDates.length; i < l; i++) {
  19172. if (isoDates[i][1].exec(match[1])) {
  19173. dateFormat = isoDates[i][0];
  19174. allowTime = isoDates[i][2] !== false;
  19175. break;
  19176. }
  19177. }
  19178. if (dateFormat == null) {
  19179. config._isValid = false;
  19180. return;
  19181. }
  19182. if (match[3]) {
  19183. for (i = 0, l = isoTimes.length; i < l; i++) {
  19184. if (isoTimes[i][1].exec(match[3])) {
  19185. // match[2] should be 'T' or space
  19186. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  19187. break;
  19188. }
  19189. }
  19190. if (timeFormat == null) {
  19191. config._isValid = false;
  19192. return;
  19193. }
  19194. }
  19195. if (!allowTime && timeFormat != null) {
  19196. config._isValid = false;
  19197. return;
  19198. }
  19199. if (match[4]) {
  19200. if (tzRegex.exec(match[4])) {
  19201. tzFormat = 'Z';
  19202. } else {
  19203. config._isValid = false;
  19204. return;
  19205. }
  19206. }
  19207. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  19208. configFromStringAndFormat(config);
  19209. } else {
  19210. config._isValid = false;
  19211. }
  19212. }
  19213. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  19214. var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
  19215. function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  19216. var result = [
  19217. untruncateYear(yearStr),
  19218. defaultLocaleMonthsShort.indexOf(monthStr),
  19219. parseInt(dayStr, 10),
  19220. parseInt(hourStr, 10),
  19221. parseInt(minuteStr, 10)
  19222. ];
  19223. if (secondStr) {
  19224. result.push(parseInt(secondStr, 10));
  19225. }
  19226. return result;
  19227. }
  19228. function untruncateYear(yearStr) {
  19229. var year = parseInt(yearStr, 10);
  19230. if (year <= 49) {
  19231. return 2000 + year;
  19232. } else if (year <= 999) {
  19233. return 1900 + year;
  19234. }
  19235. return year;
  19236. }
  19237. function preprocessRFC2822(s) {
  19238. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  19239. return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
  19240. }
  19241. function checkWeekday(weekdayStr, parsedInput, config) {
  19242. if (weekdayStr) {
  19243. // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
  19244. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  19245. weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
  19246. if (weekdayProvided !== weekdayActual) {
  19247. getParsingFlags(config).weekdayMismatch = true;
  19248. config._isValid = false;
  19249. return false;
  19250. }
  19251. }
  19252. return true;
  19253. }
  19254. var obsOffsets = {
  19255. UT: 0,
  19256. GMT: 0,
  19257. EDT: -4 * 60,
  19258. EST: -5 * 60,
  19259. CDT: -5 * 60,
  19260. CST: -6 * 60,
  19261. MDT: -6 * 60,
  19262. MST: -7 * 60,
  19263. PDT: -7 * 60,
  19264. PST: -8 * 60
  19265. };
  19266. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  19267. if (obsOffset) {
  19268. return obsOffsets[obsOffset];
  19269. } else if (militaryOffset) {
  19270. // the only allowed military tz is Z
  19271. return 0;
  19272. } else {
  19273. var hm = parseInt(numOffset, 10);
  19274. var m = hm % 100, h = (hm - m) / 100;
  19275. return h * 60 + m;
  19276. }
  19277. }
  19278. // date and time from ref 2822 format
  19279. function configFromRFC2822(config) {
  19280. var match = rfc2822.exec(preprocessRFC2822(config._i));
  19281. if (match) {
  19282. var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
  19283. if (!checkWeekday(match[1], parsedArray, config)) {
  19284. return;
  19285. }
  19286. config._a = parsedArray;
  19287. config._tzm = calculateOffset(match[8], match[9], match[10]);
  19288. config._d = createUTCDate.apply(null, config._a);
  19289. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  19290. getParsingFlags(config).rfc2822 = true;
  19291. } else {
  19292. config._isValid = false;
  19293. }
  19294. }
  19295. // date from iso format or fallback
  19296. function configFromString(config) {
  19297. var matched = aspNetJsonRegex.exec(config._i);
  19298. if (matched !== null) {
  19299. config._d = new Date(+matched[1]);
  19300. return;
  19301. }
  19302. configFromISO(config);
  19303. if (config._isValid === false) {
  19304. delete config._isValid;
  19305. } else {
  19306. return;
  19307. }
  19308. configFromRFC2822(config);
  19309. if (config._isValid === false) {
  19310. delete config._isValid;
  19311. } else {
  19312. return;
  19313. }
  19314. // Final attempt, use Input Fallback
  19315. hooks.createFromInputFallback(config);
  19316. }
  19317. hooks.createFromInputFallback = deprecate(
  19318. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  19319. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  19320. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  19321. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  19322. function (config) {
  19323. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  19324. }
  19325. );
  19326. // constant that refers to the ISO standard
  19327. hooks.ISO_8601 = function () {};
  19328. // constant that refers to the RFC 2822 form
  19329. hooks.RFC_2822 = function () {};
  19330. // date from string and format string
  19331. function configFromStringAndFormat(config) {
  19332. // TODO: Move this to another part of the creation flow to prevent circular deps
  19333. if (config._f === hooks.ISO_8601) {
  19334. configFromISO(config);
  19335. return;
  19336. }
  19337. if (config._f === hooks.RFC_2822) {
  19338. configFromRFC2822(config);
  19339. return;
  19340. }
  19341. config._a = [];
  19342. getParsingFlags(config).empty = true;
  19343. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  19344. var string = '' + config._i,
  19345. i, parsedInput, tokens, token, skipped,
  19346. stringLength = string.length,
  19347. totalParsedInputLength = 0;
  19348. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  19349. for (i = 0; i < tokens.length; i++) {
  19350. token = tokens[i];
  19351. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  19352. // console.log('token', token, 'parsedInput', parsedInput,
  19353. // 'regex', getParseRegexForToken(token, config));
  19354. if (parsedInput) {
  19355. skipped = string.substr(0, string.indexOf(parsedInput));
  19356. if (skipped.length > 0) {
  19357. getParsingFlags(config).unusedInput.push(skipped);
  19358. }
  19359. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  19360. totalParsedInputLength += parsedInput.length;
  19361. }
  19362. // don't parse if it's not a known token
  19363. if (formatTokenFunctions[token]) {
  19364. if (parsedInput) {
  19365. getParsingFlags(config).empty = false;
  19366. }
  19367. else {
  19368. getParsingFlags(config).unusedTokens.push(token);
  19369. }
  19370. addTimeToArrayFromToken(token, parsedInput, config);
  19371. }
  19372. else if (config._strict && !parsedInput) {
  19373. getParsingFlags(config).unusedTokens.push(token);
  19374. }
  19375. }
  19376. // add remaining unparsed input length to the string
  19377. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  19378. if (string.length > 0) {
  19379. getParsingFlags(config).unusedInput.push(string);
  19380. }
  19381. // clear _12h flag if hour is <= 12
  19382. if (config._a[HOUR] <= 12 &&
  19383. getParsingFlags(config).bigHour === true &&
  19384. config._a[HOUR] > 0) {
  19385. getParsingFlags(config).bigHour = undefined;
  19386. }
  19387. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  19388. getParsingFlags(config).meridiem = config._meridiem;
  19389. // handle meridiem
  19390. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  19391. configFromArray(config);
  19392. checkOverflow(config);
  19393. }
  19394. function meridiemFixWrap (locale, hour, meridiem) {
  19395. var isPm;
  19396. if (meridiem == null) {
  19397. // nothing to do
  19398. return hour;
  19399. }
  19400. if (locale.meridiemHour != null) {
  19401. return locale.meridiemHour(hour, meridiem);
  19402. } else if (locale.isPM != null) {
  19403. // Fallback
  19404. isPm = locale.isPM(meridiem);
  19405. if (isPm && hour < 12) {
  19406. hour += 12;
  19407. }
  19408. if (!isPm && hour === 12) {
  19409. hour = 0;
  19410. }
  19411. return hour;
  19412. } else {
  19413. // this is not supposed to happen
  19414. return hour;
  19415. }
  19416. }
  19417. // date from string and array of format strings
  19418. function configFromStringAndArray(config) {
  19419. var tempConfig,
  19420. bestMoment,
  19421. scoreToBeat,
  19422. i,
  19423. currentScore;
  19424. if (config._f.length === 0) {
  19425. getParsingFlags(config).invalidFormat = true;
  19426. config._d = new Date(NaN);
  19427. return;
  19428. }
  19429. for (i = 0; i < config._f.length; i++) {
  19430. currentScore = 0;
  19431. tempConfig = copyConfig({}, config);
  19432. if (config._useUTC != null) {
  19433. tempConfig._useUTC = config._useUTC;
  19434. }
  19435. tempConfig._f = config._f[i];
  19436. configFromStringAndFormat(tempConfig);
  19437. if (!isValid(tempConfig)) {
  19438. continue;
  19439. }
  19440. // if there is any input that was not parsed add a penalty for that format
  19441. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  19442. //or tokens
  19443. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  19444. getParsingFlags(tempConfig).score = currentScore;
  19445. if (scoreToBeat == null || currentScore < scoreToBeat) {
  19446. scoreToBeat = currentScore;
  19447. bestMoment = tempConfig;
  19448. }
  19449. }
  19450. extend(config, bestMoment || tempConfig);
  19451. }
  19452. function configFromObject(config) {
  19453. if (config._d) {
  19454. return;
  19455. }
  19456. var i = normalizeObjectUnits(config._i);
  19457. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  19458. return obj && parseInt(obj, 10);
  19459. });
  19460. configFromArray(config);
  19461. }
  19462. function createFromConfig (config) {
  19463. var res = new Moment(checkOverflow(prepareConfig(config)));
  19464. if (res._nextDay) {
  19465. // Adding is smart enough around DST
  19466. res.add(1, 'd');
  19467. res._nextDay = undefined;
  19468. }
  19469. return res;
  19470. }
  19471. function prepareConfig (config) {
  19472. var input = config._i,
  19473. format = config._f;
  19474. config._locale = config._locale || getLocale(config._l);
  19475. if (input === null || (format === undefined && input === '')) {
  19476. return createInvalid({nullInput: true});
  19477. }
  19478. if (typeof input === 'string') {
  19479. config._i = input = config._locale.preparse(input);
  19480. }
  19481. if (isMoment(input)) {
  19482. return new Moment(checkOverflow(input));
  19483. } else if (isDate(input)) {
  19484. config._d = input;
  19485. } else if (isArray(format)) {
  19486. configFromStringAndArray(config);
  19487. } else if (format) {
  19488. configFromStringAndFormat(config);
  19489. } else {
  19490. configFromInput(config);
  19491. }
  19492. if (!isValid(config)) {
  19493. config._d = null;
  19494. }
  19495. return config;
  19496. }
  19497. function configFromInput(config) {
  19498. var input = config._i;
  19499. if (isUndefined(input)) {
  19500. config._d = new Date(hooks.now());
  19501. } else if (isDate(input)) {
  19502. config._d = new Date(input.valueOf());
  19503. } else if (typeof input === 'string') {
  19504. configFromString(config);
  19505. } else if (isArray(input)) {
  19506. config._a = map(input.slice(0), function (obj) {
  19507. return parseInt(obj, 10);
  19508. });
  19509. configFromArray(config);
  19510. } else if (isObject(input)) {
  19511. configFromObject(config);
  19512. } else if (isNumber(input)) {
  19513. // from milliseconds
  19514. config._d = new Date(input);
  19515. } else {
  19516. hooks.createFromInputFallback(config);
  19517. }
  19518. }
  19519. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  19520. var c = {};
  19521. if (locale === true || locale === false) {
  19522. strict = locale;
  19523. locale = undefined;
  19524. }
  19525. if ((isObject(input) && isObjectEmpty(input)) ||
  19526. (isArray(input) && input.length === 0)) {
  19527. input = undefined;
  19528. }
  19529. // object construction must be done this way.
  19530. // https://github.com/moment/moment/issues/1423
  19531. c._isAMomentObject = true;
  19532. c._useUTC = c._isUTC = isUTC;
  19533. c._l = locale;
  19534. c._i = input;
  19535. c._f = format;
  19536. c._strict = strict;
  19537. return createFromConfig(c);
  19538. }
  19539. function createLocal (input, format, locale, strict) {
  19540. return createLocalOrUTC(input, format, locale, strict, false);
  19541. }
  19542. var prototypeMin = deprecate(
  19543. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  19544. function () {
  19545. var other = createLocal.apply(null, arguments);
  19546. if (this.isValid() && other.isValid()) {
  19547. return other < this ? this : other;
  19548. } else {
  19549. return createInvalid();
  19550. }
  19551. }
  19552. );
  19553. var prototypeMax = deprecate(
  19554. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  19555. function () {
  19556. var other = createLocal.apply(null, arguments);
  19557. if (this.isValid() && other.isValid()) {
  19558. return other > this ? this : other;
  19559. } else {
  19560. return createInvalid();
  19561. }
  19562. }
  19563. );
  19564. // Pick a moment m from moments so that m[fn](other) is true for all
  19565. // other. This relies on the function fn to be transitive.
  19566. //
  19567. // moments should either be an array of moment objects or an array, whose
  19568. // first element is an array of moment objects.
  19569. function pickBy(fn, moments) {
  19570. var res, i;
  19571. if (moments.length === 1 && isArray(moments[0])) {
  19572. moments = moments[0];
  19573. }
  19574. if (!moments.length) {
  19575. return createLocal();
  19576. }
  19577. res = moments[0];
  19578. for (i = 1; i < moments.length; ++i) {
  19579. if (!moments[i].isValid() || moments[i][fn](res)) {
  19580. res = moments[i];
  19581. }
  19582. }
  19583. return res;
  19584. }
  19585. // TODO: Use [].sort instead?
  19586. function min () {
  19587. var args = [].slice.call(arguments, 0);
  19588. return pickBy('isBefore', args);
  19589. }
  19590. function max () {
  19591. var args = [].slice.call(arguments, 0);
  19592. return pickBy('isAfter', args);
  19593. }
  19594. var now = function () {
  19595. return Date.now ? Date.now() : +(new Date());
  19596. };
  19597. var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
  19598. function isDurationValid(m) {
  19599. for (var key in m) {
  19600. if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
  19601. return false;
  19602. }
  19603. }
  19604. var unitHasDecimal = false;
  19605. for (var i = 0; i < ordering.length; ++i) {
  19606. if (m[ordering[i]]) {
  19607. if (unitHasDecimal) {
  19608. return false; // only allow non-integers for smallest unit
  19609. }
  19610. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  19611. unitHasDecimal = true;
  19612. }
  19613. }
  19614. }
  19615. return true;
  19616. }
  19617. function isValid$1() {
  19618. return this._isValid;
  19619. }
  19620. function createInvalid$1() {
  19621. return createDuration(NaN);
  19622. }
  19623. function Duration (duration) {
  19624. var normalizedInput = normalizeObjectUnits(duration),
  19625. years = normalizedInput.year || 0,
  19626. quarters = normalizedInput.quarter || 0,
  19627. months = normalizedInput.month || 0,
  19628. weeks = normalizedInput.week || 0,
  19629. days = normalizedInput.day || 0,
  19630. hours = normalizedInput.hour || 0,
  19631. minutes = normalizedInput.minute || 0,
  19632. seconds = normalizedInput.second || 0,
  19633. milliseconds = normalizedInput.millisecond || 0;
  19634. this._isValid = isDurationValid(normalizedInput);
  19635. // representation for dateAddRemove
  19636. this._milliseconds = +milliseconds +
  19637. seconds * 1e3 + // 1000
  19638. minutes * 6e4 + // 1000 * 60
  19639. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  19640. // Because of dateAddRemove treats 24 hours as different from a
  19641. // day when working around DST, we need to store them separately
  19642. this._days = +days +
  19643. weeks * 7;
  19644. // It is impossible to translate months into days without knowing
  19645. // which months you are are talking about, so we have to store
  19646. // it separately.
  19647. this._months = +months +
  19648. quarters * 3 +
  19649. years * 12;
  19650. this._data = {};
  19651. this._locale = getLocale();
  19652. this._bubble();
  19653. }
  19654. function isDuration (obj) {
  19655. return obj instanceof Duration;
  19656. }
  19657. function absRound (number) {
  19658. if (number < 0) {
  19659. return Math.round(-1 * number) * -1;
  19660. } else {
  19661. return Math.round(number);
  19662. }
  19663. }
  19664. // FORMATTING
  19665. function offset (token, separator) {
  19666. addFormatToken(token, 0, 0, function () {
  19667. var offset = this.utcOffset();
  19668. var sign = '+';
  19669. if (offset < 0) {
  19670. offset = -offset;
  19671. sign = '-';
  19672. }
  19673. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  19674. });
  19675. }
  19676. offset('Z', ':');
  19677. offset('ZZ', '');
  19678. // PARSING
  19679. addRegexToken('Z', matchShortOffset);
  19680. addRegexToken('ZZ', matchShortOffset);
  19681. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  19682. config._useUTC = true;
  19683. config._tzm = offsetFromString(matchShortOffset, input);
  19684. });
  19685. // HELPERS
  19686. // timezone chunker
  19687. // '+10:00' > ['10', '00']
  19688. // '-1530' > ['-15', '30']
  19689. var chunkOffset = /([\+\-]|\d\d)/gi;
  19690. function offsetFromString(matcher, string) {
  19691. var matches = (string || '').match(matcher);
  19692. if (matches === null) {
  19693. return null;
  19694. }
  19695. var chunk = matches[matches.length - 1] || [];
  19696. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  19697. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  19698. return minutes === 0 ?
  19699. 0 :
  19700. parts[0] === '+' ? minutes : -minutes;
  19701. }
  19702. // Return a moment from input, that is local/utc/zone equivalent to model.
  19703. function cloneWithOffset(input, model) {
  19704. var res, diff;
  19705. if (model._isUTC) {
  19706. res = model.clone();
  19707. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  19708. // Use low-level api, because this fn is low-level api.
  19709. res._d.setTime(res._d.valueOf() + diff);
  19710. hooks.updateOffset(res, false);
  19711. return res;
  19712. } else {
  19713. return createLocal(input).local();
  19714. }
  19715. }
  19716. function getDateOffset (m) {
  19717. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  19718. // https://github.com/moment/moment/pull/1871
  19719. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  19720. }
  19721. // HOOKS
  19722. // This function will be called whenever a moment is mutated.
  19723. // It is intended to keep the offset in sync with the timezone.
  19724. hooks.updateOffset = function () {};
  19725. // MOMENTS
  19726. // keepLocalTime = true means only change the timezone, without
  19727. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  19728. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  19729. // +0200, so we adjust the time as needed, to be valid.
  19730. //
  19731. // Keeping the time actually adds/subtracts (one hour)
  19732. // from the actual represented time. That is why we call updateOffset
  19733. // a second time. In case it wants us to change the offset again
  19734. // _changeInProgress == true case, then we have to adjust, because
  19735. // there is no such time in the given timezone.
  19736. function getSetOffset (input, keepLocalTime, keepMinutes) {
  19737. var offset = this._offset || 0,
  19738. localAdjust;
  19739. if (!this.isValid()) {
  19740. return input != null ? this : NaN;
  19741. }
  19742. if (input != null) {
  19743. if (typeof input === 'string') {
  19744. input = offsetFromString(matchShortOffset, input);
  19745. if (input === null) {
  19746. return this;
  19747. }
  19748. } else if (Math.abs(input) < 16 && !keepMinutes) {
  19749. input = input * 60;
  19750. }
  19751. if (!this._isUTC && keepLocalTime) {
  19752. localAdjust = getDateOffset(this);
  19753. }
  19754. this._offset = input;
  19755. this._isUTC = true;
  19756. if (localAdjust != null) {
  19757. this.add(localAdjust, 'm');
  19758. }
  19759. if (offset !== input) {
  19760. if (!keepLocalTime || this._changeInProgress) {
  19761. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  19762. } else if (!this._changeInProgress) {
  19763. this._changeInProgress = true;
  19764. hooks.updateOffset(this, true);
  19765. this._changeInProgress = null;
  19766. }
  19767. }
  19768. return this;
  19769. } else {
  19770. return this._isUTC ? offset : getDateOffset(this);
  19771. }
  19772. }
  19773. function getSetZone (input, keepLocalTime) {
  19774. if (input != null) {
  19775. if (typeof input !== 'string') {
  19776. input = -input;
  19777. }
  19778. this.utcOffset(input, keepLocalTime);
  19779. return this;
  19780. } else {
  19781. return -this.utcOffset();
  19782. }
  19783. }
  19784. function setOffsetToUTC (keepLocalTime) {
  19785. return this.utcOffset(0, keepLocalTime);
  19786. }
  19787. function setOffsetToLocal (keepLocalTime) {
  19788. if (this._isUTC) {
  19789. this.utcOffset(0, keepLocalTime);
  19790. this._isUTC = false;
  19791. if (keepLocalTime) {
  19792. this.subtract(getDateOffset(this), 'm');
  19793. }
  19794. }
  19795. return this;
  19796. }
  19797. function setOffsetToParsedOffset () {
  19798. if (this._tzm != null) {
  19799. this.utcOffset(this._tzm, false, true);
  19800. } else if (typeof this._i === 'string') {
  19801. var tZone = offsetFromString(matchOffset, this._i);
  19802. if (tZone != null) {
  19803. this.utcOffset(tZone);
  19804. }
  19805. else {
  19806. this.utcOffset(0, true);
  19807. }
  19808. }
  19809. return this;
  19810. }
  19811. function hasAlignedHourOffset (input) {
  19812. if (!this.isValid()) {
  19813. return false;
  19814. }
  19815. input = input ? createLocal(input).utcOffset() : 0;
  19816. return (this.utcOffset() - input) % 60 === 0;
  19817. }
  19818. function isDaylightSavingTime () {
  19819. return (
  19820. this.utcOffset() > this.clone().month(0).utcOffset() ||
  19821. this.utcOffset() > this.clone().month(5).utcOffset()
  19822. );
  19823. }
  19824. function isDaylightSavingTimeShifted () {
  19825. if (!isUndefined(this._isDSTShifted)) {
  19826. return this._isDSTShifted;
  19827. }
  19828. var c = {};
  19829. copyConfig(c, this);
  19830. c = prepareConfig(c);
  19831. if (c._a) {
  19832. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  19833. this._isDSTShifted = this.isValid() &&
  19834. compareArrays(c._a, other.toArray()) > 0;
  19835. } else {
  19836. this._isDSTShifted = false;
  19837. }
  19838. return this._isDSTShifted;
  19839. }
  19840. function isLocal () {
  19841. return this.isValid() ? !this._isUTC : false;
  19842. }
  19843. function isUtcOffset () {
  19844. return this.isValid() ? this._isUTC : false;
  19845. }
  19846. function isUtc () {
  19847. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  19848. }
  19849. // ASP.NET json date format regex
  19850. var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  19851. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  19852. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  19853. // and further modified to allow for strings containing both week and day
  19854. var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  19855. function createDuration (input, key) {
  19856. var duration = input,
  19857. // matching against regexp is expensive, do it on demand
  19858. match = null,
  19859. sign,
  19860. ret,
  19861. diffRes;
  19862. if (isDuration(input)) {
  19863. duration = {
  19864. ms : input._milliseconds,
  19865. d : input._days,
  19866. M : input._months
  19867. };
  19868. } else if (isNumber(input)) {
  19869. duration = {};
  19870. if (key) {
  19871. duration[key] = input;
  19872. } else {
  19873. duration.milliseconds = input;
  19874. }
  19875. } else if (!!(match = aspNetRegex.exec(input))) {
  19876. sign = (match[1] === '-') ? -1 : 1;
  19877. duration = {
  19878. y : 0,
  19879. d : toInt(match[DATE]) * sign,
  19880. h : toInt(match[HOUR]) * sign,
  19881. m : toInt(match[MINUTE]) * sign,
  19882. s : toInt(match[SECOND]) * sign,
  19883. ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  19884. };
  19885. } else if (!!(match = isoRegex.exec(input))) {
  19886. sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
  19887. duration = {
  19888. y : parseIso(match[2], sign),
  19889. M : parseIso(match[3], sign),
  19890. w : parseIso(match[4], sign),
  19891. d : parseIso(match[5], sign),
  19892. h : parseIso(match[6], sign),
  19893. m : parseIso(match[7], sign),
  19894. s : parseIso(match[8], sign)
  19895. };
  19896. } else if (duration == null) {// checks for null or undefined
  19897. duration = {};
  19898. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  19899. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  19900. duration = {};
  19901. duration.ms = diffRes.milliseconds;
  19902. duration.M = diffRes.months;
  19903. }
  19904. ret = new Duration(duration);
  19905. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  19906. ret._locale = input._locale;
  19907. }
  19908. return ret;
  19909. }
  19910. createDuration.fn = Duration.prototype;
  19911. createDuration.invalid = createInvalid$1;
  19912. function parseIso (inp, sign) {
  19913. // We'd normally use ~~inp for this, but unfortunately it also
  19914. // converts floats to ints.
  19915. // inp may be undefined, so careful calling replace on it.
  19916. var res = inp && parseFloat(inp.replace(',', '.'));
  19917. // apply sign while we're at it
  19918. return (isNaN(res) ? 0 : res) * sign;
  19919. }
  19920. function positiveMomentsDifference(base, other) {
  19921. var res = {milliseconds: 0, months: 0};
  19922. res.months = other.month() - base.month() +
  19923. (other.year() - base.year()) * 12;
  19924. if (base.clone().add(res.months, 'M').isAfter(other)) {
  19925. --res.months;
  19926. }
  19927. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  19928. return res;
  19929. }
  19930. function momentsDifference(base, other) {
  19931. var res;
  19932. if (!(base.isValid() && other.isValid())) {
  19933. return {milliseconds: 0, months: 0};
  19934. }
  19935. other = cloneWithOffset(other, base);
  19936. if (base.isBefore(other)) {
  19937. res = positiveMomentsDifference(base, other);
  19938. } else {
  19939. res = positiveMomentsDifference(other, base);
  19940. res.milliseconds = -res.milliseconds;
  19941. res.months = -res.months;
  19942. }
  19943. return res;
  19944. }
  19945. // TODO: remove 'name' arg after deprecation is removed
  19946. function createAdder(direction, name) {
  19947. return function (val, period) {
  19948. var dur, tmp;
  19949. //invert the arguments, but complain about it
  19950. if (period !== null && !isNaN(+period)) {
  19951. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  19952. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  19953. tmp = val; val = period; period = tmp;
  19954. }
  19955. val = typeof val === 'string' ? +val : val;
  19956. dur = createDuration(val, period);
  19957. addSubtract(this, dur, direction);
  19958. return this;
  19959. };
  19960. }
  19961. function addSubtract (mom, duration, isAdding, updateOffset) {
  19962. var milliseconds = duration._milliseconds,
  19963. days = absRound(duration._days),
  19964. months = absRound(duration._months);
  19965. if (!mom.isValid()) {
  19966. // No op
  19967. return;
  19968. }
  19969. updateOffset = updateOffset == null ? true : updateOffset;
  19970. if (months) {
  19971. setMonth(mom, get(mom, 'Month') + months * isAdding);
  19972. }
  19973. if (days) {
  19974. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  19975. }
  19976. if (milliseconds) {
  19977. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  19978. }
  19979. if (updateOffset) {
  19980. hooks.updateOffset(mom, days || months);
  19981. }
  19982. }
  19983. var add = createAdder(1, 'add');
  19984. var subtract = createAdder(-1, 'subtract');
  19985. function getCalendarFormat(myMoment, now) {
  19986. var diff = myMoment.diff(now, 'days', true);
  19987. return diff < -6 ? 'sameElse' :
  19988. diff < -1 ? 'lastWeek' :
  19989. diff < 0 ? 'lastDay' :
  19990. diff < 1 ? 'sameDay' :
  19991. diff < 2 ? 'nextDay' :
  19992. diff < 7 ? 'nextWeek' : 'sameElse';
  19993. }
  19994. function calendar$1 (time, formats) {
  19995. // We want to compare the start of today, vs this.
  19996. // Getting start-of-today depends on whether we're local/utc/offset or not.
  19997. var now = time || createLocal(),
  19998. sod = cloneWithOffset(now, this).startOf('day'),
  19999. format = hooks.calendarFormat(this, sod) || 'sameElse';
  20000. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  20001. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  20002. }
  20003. function clone () {
  20004. return new Moment(this);
  20005. }
  20006. function isAfter (input, units) {
  20007. var localInput = isMoment(input) ? input : createLocal(input);
  20008. if (!(this.isValid() && localInput.isValid())) {
  20009. return false;
  20010. }
  20011. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  20012. if (units === 'millisecond') {
  20013. return this.valueOf() > localInput.valueOf();
  20014. } else {
  20015. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  20016. }
  20017. }
  20018. function isBefore (input, units) {
  20019. var localInput = isMoment(input) ? input : createLocal(input);
  20020. if (!(this.isValid() && localInput.isValid())) {
  20021. return false;
  20022. }
  20023. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  20024. if (units === 'millisecond') {
  20025. return this.valueOf() < localInput.valueOf();
  20026. } else {
  20027. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  20028. }
  20029. }
  20030. function isBetween (from, to, units, inclusivity) {
  20031. inclusivity = inclusivity || '()';
  20032. return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
  20033. (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
  20034. }
  20035. function isSame (input, units) {
  20036. var localInput = isMoment(input) ? input : createLocal(input),
  20037. inputMs;
  20038. if (!(this.isValid() && localInput.isValid())) {
  20039. return false;
  20040. }
  20041. units = normalizeUnits(units || 'millisecond');
  20042. if (units === 'millisecond') {
  20043. return this.valueOf() === localInput.valueOf();
  20044. } else {
  20045. inputMs = localInput.valueOf();
  20046. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  20047. }
  20048. }
  20049. function isSameOrAfter (input, units) {
  20050. return this.isSame(input, units) || this.isAfter(input,units);
  20051. }
  20052. function isSameOrBefore (input, units) {
  20053. return this.isSame(input, units) || this.isBefore(input,units);
  20054. }
  20055. function diff (input, units, asFloat) {
  20056. var that,
  20057. zoneDelta,
  20058. delta, output;
  20059. if (!this.isValid()) {
  20060. return NaN;
  20061. }
  20062. that = cloneWithOffset(input, this);
  20063. if (!that.isValid()) {
  20064. return NaN;
  20065. }
  20066. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  20067. units = normalizeUnits(units);
  20068. switch (units) {
  20069. case 'year': output = monthDiff(this, that) / 12; break;
  20070. case 'month': output = monthDiff(this, that); break;
  20071. case 'quarter': output = monthDiff(this, that) / 3; break;
  20072. case 'second': output = (this - that) / 1e3; break; // 1000
  20073. case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
  20074. case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
  20075. case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
  20076. case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
  20077. default: output = this - that;
  20078. }
  20079. return asFloat ? output : absFloor(output);
  20080. }
  20081. function monthDiff (a, b) {
  20082. // difference in months
  20083. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  20084. // b is in (anchor - 1 month, anchor + 1 month)
  20085. anchor = a.clone().add(wholeMonthDiff, 'months'),
  20086. anchor2, adjust;
  20087. if (b - anchor < 0) {
  20088. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  20089. // linear across the month
  20090. adjust = (b - anchor) / (anchor - anchor2);
  20091. } else {
  20092. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  20093. // linear across the month
  20094. adjust = (b - anchor) / (anchor2 - anchor);
  20095. }
  20096. //check for negative zero, return zero if negative zero
  20097. return -(wholeMonthDiff + adjust) || 0;
  20098. }
  20099. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  20100. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  20101. function toString () {
  20102. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  20103. }
  20104. function toISOString() {
  20105. if (!this.isValid()) {
  20106. return null;
  20107. }
  20108. var m = this.clone().utc();
  20109. if (m.year() < 0 || m.year() > 9999) {
  20110. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  20111. }
  20112. if (isFunction(Date.prototype.toISOString)) {
  20113. // native implementation is ~50x faster, use it when we can
  20114. return this.toDate().toISOString();
  20115. }
  20116. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  20117. }
  20118. /**
  20119. * Return a human readable representation of a moment that can
  20120. * also be evaluated to get a new moment which is the same
  20121. *
  20122. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  20123. */
  20124. function inspect () {
  20125. if (!this.isValid()) {
  20126. return 'moment.invalid(/* ' + this._i + ' */)';
  20127. }
  20128. var func = 'moment';
  20129. var zone = '';
  20130. if (!this.isLocal()) {
  20131. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  20132. zone = 'Z';
  20133. }
  20134. var prefix = '[' + func + '("]';
  20135. var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  20136. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  20137. var suffix = zone + '[")]';
  20138. return this.format(prefix + year + datetime + suffix);
  20139. }
  20140. function format (inputString) {
  20141. if (!inputString) {
  20142. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  20143. }
  20144. var output = formatMoment(this, inputString);
  20145. return this.localeData().postformat(output);
  20146. }
  20147. function from (time, withoutSuffix) {
  20148. if (this.isValid() &&
  20149. ((isMoment(time) && time.isValid()) ||
  20150. createLocal(time).isValid())) {
  20151. return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  20152. } else {
  20153. return this.localeData().invalidDate();
  20154. }
  20155. }
  20156. function fromNow (withoutSuffix) {
  20157. return this.from(createLocal(), withoutSuffix);
  20158. }
  20159. function to (time, withoutSuffix) {
  20160. if (this.isValid() &&
  20161. ((isMoment(time) && time.isValid()) ||
  20162. createLocal(time).isValid())) {
  20163. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  20164. } else {
  20165. return this.localeData().invalidDate();
  20166. }
  20167. }
  20168. function toNow (withoutSuffix) {
  20169. return this.to(createLocal(), withoutSuffix);
  20170. }
  20171. // If passed a locale key, it will set the locale for this
  20172. // instance. Otherwise, it will return the locale configuration
  20173. // variables for this instance.
  20174. function locale (key) {
  20175. var newLocaleData;
  20176. if (key === undefined) {
  20177. return this._locale._abbr;
  20178. } else {
  20179. newLocaleData = getLocale(key);
  20180. if (newLocaleData != null) {
  20181. this._locale = newLocaleData;
  20182. }
  20183. return this;
  20184. }
  20185. }
  20186. var lang = deprecate(
  20187. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  20188. function (key) {
  20189. if (key === undefined) {
  20190. return this.localeData();
  20191. } else {
  20192. return this.locale(key);
  20193. }
  20194. }
  20195. );
  20196. function localeData () {
  20197. return this._locale;
  20198. }
  20199. function startOf (units) {
  20200. units = normalizeUnits(units);
  20201. // the following switch intentionally omits break keywords
  20202. // to utilize falling through the cases.
  20203. switch (units) {
  20204. case 'year':
  20205. this.month(0);
  20206. /* falls through */
  20207. case 'quarter':
  20208. case 'month':
  20209. this.date(1);
  20210. /* falls through */
  20211. case 'week':
  20212. case 'isoWeek':
  20213. case 'day':
  20214. case 'date':
  20215. this.hours(0);
  20216. /* falls through */
  20217. case 'hour':
  20218. this.minutes(0);
  20219. /* falls through */
  20220. case 'minute':
  20221. this.seconds(0);
  20222. /* falls through */
  20223. case 'second':
  20224. this.milliseconds(0);
  20225. }
  20226. // weeks are a special case
  20227. if (units === 'week') {
  20228. this.weekday(0);
  20229. }
  20230. if (units === 'isoWeek') {
  20231. this.isoWeekday(1);
  20232. }
  20233. // quarters are also special
  20234. if (units === 'quarter') {
  20235. this.month(Math.floor(this.month() / 3) * 3);
  20236. }
  20237. return this;
  20238. }
  20239. function endOf (units) {
  20240. units = normalizeUnits(units);
  20241. if (units === undefined || units === 'millisecond') {
  20242. return this;
  20243. }
  20244. // 'date' is an alias for 'day', so it should be considered as such.
  20245. if (units === 'date') {
  20246. units = 'day';
  20247. }
  20248. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  20249. }
  20250. function valueOf () {
  20251. return this._d.valueOf() - ((this._offset || 0) * 60000);
  20252. }
  20253. function unix () {
  20254. return Math.floor(this.valueOf() / 1000);
  20255. }
  20256. function toDate () {
  20257. return new Date(this.valueOf());
  20258. }
  20259. function toArray () {
  20260. var m = this;
  20261. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  20262. }
  20263. function toObject () {
  20264. var m = this;
  20265. return {
  20266. years: m.year(),
  20267. months: m.month(),
  20268. date: m.date(),
  20269. hours: m.hours(),
  20270. minutes: m.minutes(),
  20271. seconds: m.seconds(),
  20272. milliseconds: m.milliseconds()
  20273. };
  20274. }
  20275. function toJSON () {
  20276. // new Date(NaN).toJSON() === null
  20277. return this.isValid() ? this.toISOString() : null;
  20278. }
  20279. function isValid$2 () {
  20280. return isValid(this);
  20281. }
  20282. function parsingFlags () {
  20283. return extend({}, getParsingFlags(this));
  20284. }
  20285. function invalidAt () {
  20286. return getParsingFlags(this).overflow;
  20287. }
  20288. function creationData() {
  20289. return {
  20290. input: this._i,
  20291. format: this._f,
  20292. locale: this._locale,
  20293. isUTC: this._isUTC,
  20294. strict: this._strict
  20295. };
  20296. }
  20297. // FORMATTING
  20298. addFormatToken(0, ['gg', 2], 0, function () {
  20299. return this.weekYear() % 100;
  20300. });
  20301. addFormatToken(0, ['GG', 2], 0, function () {
  20302. return this.isoWeekYear() % 100;
  20303. });
  20304. function addWeekYearFormatToken (token, getter) {
  20305. addFormatToken(0, [token, token.length], 0, getter);
  20306. }
  20307. addWeekYearFormatToken('gggg', 'weekYear');
  20308. addWeekYearFormatToken('ggggg', 'weekYear');
  20309. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  20310. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  20311. // ALIASES
  20312. addUnitAlias('weekYear', 'gg');
  20313. addUnitAlias('isoWeekYear', 'GG');
  20314. // PRIORITY
  20315. addUnitPriority('weekYear', 1);
  20316. addUnitPriority('isoWeekYear', 1);
  20317. // PARSING
  20318. addRegexToken('G', matchSigned);
  20319. addRegexToken('g', matchSigned);
  20320. addRegexToken('GG', match1to2, match2);
  20321. addRegexToken('gg', match1to2, match2);
  20322. addRegexToken('GGGG', match1to4, match4);
  20323. addRegexToken('gggg', match1to4, match4);
  20324. addRegexToken('GGGGG', match1to6, match6);
  20325. addRegexToken('ggggg', match1to6, match6);
  20326. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  20327. week[token.substr(0, 2)] = toInt(input);
  20328. });
  20329. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  20330. week[token] = hooks.parseTwoDigitYear(input);
  20331. });
  20332. // MOMENTS
  20333. function getSetWeekYear (input) {
  20334. return getSetWeekYearHelper.call(this,
  20335. input,
  20336. this.week(),
  20337. this.weekday(),
  20338. this.localeData()._week.dow,
  20339. this.localeData()._week.doy);
  20340. }
  20341. function getSetISOWeekYear (input) {
  20342. return getSetWeekYearHelper.call(this,
  20343. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  20344. }
  20345. function getISOWeeksInYear () {
  20346. return weeksInYear(this.year(), 1, 4);
  20347. }
  20348. function getWeeksInYear () {
  20349. var weekInfo = this.localeData()._week;
  20350. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  20351. }
  20352. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  20353. var weeksTarget;
  20354. if (input == null) {
  20355. return weekOfYear(this, dow, doy).year;
  20356. } else {
  20357. weeksTarget = weeksInYear(input, dow, doy);
  20358. if (week > weeksTarget) {
  20359. week = weeksTarget;
  20360. }
  20361. return setWeekAll.call(this, input, week, weekday, dow, doy);
  20362. }
  20363. }
  20364. function setWeekAll(weekYear, week, weekday, dow, doy) {
  20365. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  20366. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  20367. this.year(date.getUTCFullYear());
  20368. this.month(date.getUTCMonth());
  20369. this.date(date.getUTCDate());
  20370. return this;
  20371. }
  20372. // FORMATTING
  20373. addFormatToken('Q', 0, 'Qo', 'quarter');
  20374. // ALIASES
  20375. addUnitAlias('quarter', 'Q');
  20376. // PRIORITY
  20377. addUnitPriority('quarter', 7);
  20378. // PARSING
  20379. addRegexToken('Q', match1);
  20380. addParseToken('Q', function (input, array) {
  20381. array[MONTH] = (toInt(input) - 1) * 3;
  20382. });
  20383. // MOMENTS
  20384. function getSetQuarter (input) {
  20385. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  20386. }
  20387. // FORMATTING
  20388. addFormatToken('D', ['DD', 2], 'Do', 'date');
  20389. // ALIASES
  20390. addUnitAlias('date', 'D');
  20391. // PRIOROITY
  20392. addUnitPriority('date', 9);
  20393. // PARSING
  20394. addRegexToken('D', match1to2);
  20395. addRegexToken('DD', match1to2, match2);
  20396. addRegexToken('Do', function (isStrict, locale) {
  20397. // TODO: Remove "ordinalParse" fallback in next major release.
  20398. return isStrict ?
  20399. (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
  20400. locale._dayOfMonthOrdinalParseLenient;
  20401. });
  20402. addParseToken(['D', 'DD'], DATE);
  20403. addParseToken('Do', function (input, array) {
  20404. array[DATE] = toInt(input.match(match1to2)[0]);
  20405. });
  20406. // MOMENTS
  20407. var getSetDayOfMonth = makeGetSet('Date', true);
  20408. // FORMATTING
  20409. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  20410. // ALIASES
  20411. addUnitAlias('dayOfYear', 'DDD');
  20412. // PRIORITY
  20413. addUnitPriority('dayOfYear', 4);
  20414. // PARSING
  20415. addRegexToken('DDD', match1to3);
  20416. addRegexToken('DDDD', match3);
  20417. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  20418. config._dayOfYear = toInt(input);
  20419. });
  20420. // HELPERS
  20421. // MOMENTS
  20422. function getSetDayOfYear (input) {
  20423. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  20424. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  20425. }
  20426. // FORMATTING
  20427. addFormatToken('m', ['mm', 2], 0, 'minute');
  20428. // ALIASES
  20429. addUnitAlias('minute', 'm');
  20430. // PRIORITY
  20431. addUnitPriority('minute', 14);
  20432. // PARSING
  20433. addRegexToken('m', match1to2);
  20434. addRegexToken('mm', match1to2, match2);
  20435. addParseToken(['m', 'mm'], MINUTE);
  20436. // MOMENTS
  20437. var getSetMinute = makeGetSet('Minutes', false);
  20438. // FORMATTING
  20439. addFormatToken('s', ['ss', 2], 0, 'second');
  20440. // ALIASES
  20441. addUnitAlias('second', 's');
  20442. // PRIORITY
  20443. addUnitPriority('second', 15);
  20444. // PARSING
  20445. addRegexToken('s', match1to2);
  20446. addRegexToken('ss', match1to2, match2);
  20447. addParseToken(['s', 'ss'], SECOND);
  20448. // MOMENTS
  20449. var getSetSecond = makeGetSet('Seconds', false);
  20450. // FORMATTING
  20451. addFormatToken('S', 0, 0, function () {
  20452. return ~~(this.millisecond() / 100);
  20453. });
  20454. addFormatToken(0, ['SS', 2], 0, function () {
  20455. return ~~(this.millisecond() / 10);
  20456. });
  20457. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  20458. addFormatToken(0, ['SSSS', 4], 0, function () {
  20459. return this.millisecond() * 10;
  20460. });
  20461. addFormatToken(0, ['SSSSS', 5], 0, function () {
  20462. return this.millisecond() * 100;
  20463. });
  20464. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  20465. return this.millisecond() * 1000;
  20466. });
  20467. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  20468. return this.millisecond() * 10000;
  20469. });
  20470. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  20471. return this.millisecond() * 100000;
  20472. });
  20473. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  20474. return this.millisecond() * 1000000;
  20475. });
  20476. // ALIASES
  20477. addUnitAlias('millisecond', 'ms');
  20478. // PRIORITY
  20479. addUnitPriority('millisecond', 16);
  20480. // PARSING
  20481. addRegexToken('S', match1to3, match1);
  20482. addRegexToken('SS', match1to3, match2);
  20483. addRegexToken('SSS', match1to3, match3);
  20484. var token;
  20485. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  20486. addRegexToken(token, matchUnsigned);
  20487. }
  20488. function parseMs(input, array) {
  20489. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  20490. }
  20491. for (token = 'S'; token.length <= 9; token += 'S') {
  20492. addParseToken(token, parseMs);
  20493. }
  20494. // MOMENTS
  20495. var getSetMillisecond = makeGetSet('Milliseconds', false);
  20496. // FORMATTING
  20497. addFormatToken('z', 0, 0, 'zoneAbbr');
  20498. addFormatToken('zz', 0, 0, 'zoneName');
  20499. // MOMENTS
  20500. function getZoneAbbr () {
  20501. return this._isUTC ? 'UTC' : '';
  20502. }
  20503. function getZoneName () {
  20504. return this._isUTC ? 'Coordinated Universal Time' : '';
  20505. }
  20506. var proto = Moment.prototype;
  20507. proto.add = add;
  20508. proto.calendar = calendar$1;
  20509. proto.clone = clone;
  20510. proto.diff = diff;
  20511. proto.endOf = endOf;
  20512. proto.format = format;
  20513. proto.from = from;
  20514. proto.fromNow = fromNow;
  20515. proto.to = to;
  20516. proto.toNow = toNow;
  20517. proto.get = stringGet;
  20518. proto.invalidAt = invalidAt;
  20519. proto.isAfter = isAfter;
  20520. proto.isBefore = isBefore;
  20521. proto.isBetween = isBetween;
  20522. proto.isSame = isSame;
  20523. proto.isSameOrAfter = isSameOrAfter;
  20524. proto.isSameOrBefore = isSameOrBefore;
  20525. proto.isValid = isValid$2;
  20526. proto.lang = lang;
  20527. proto.locale = locale;
  20528. proto.localeData = localeData;
  20529. proto.max = prototypeMax;
  20530. proto.min = prototypeMin;
  20531. proto.parsingFlags = parsingFlags;
  20532. proto.set = stringSet;
  20533. proto.startOf = startOf;
  20534. proto.subtract = subtract;
  20535. proto.toArray = toArray;
  20536. proto.toObject = toObject;
  20537. proto.toDate = toDate;
  20538. proto.toISOString = toISOString;
  20539. proto.inspect = inspect;
  20540. proto.toJSON = toJSON;
  20541. proto.toString = toString;
  20542. proto.unix = unix;
  20543. proto.valueOf = valueOf;
  20544. proto.creationData = creationData;
  20545. // Year
  20546. proto.year = getSetYear;
  20547. proto.isLeapYear = getIsLeapYear;
  20548. // Week Year
  20549. proto.weekYear = getSetWeekYear;
  20550. proto.isoWeekYear = getSetISOWeekYear;
  20551. // Quarter
  20552. proto.quarter = proto.quarters = getSetQuarter;
  20553. // Month
  20554. proto.month = getSetMonth;
  20555. proto.daysInMonth = getDaysInMonth;
  20556. // Week
  20557. proto.week = proto.weeks = getSetWeek;
  20558. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  20559. proto.weeksInYear = getWeeksInYear;
  20560. proto.isoWeeksInYear = getISOWeeksInYear;
  20561. // Day
  20562. proto.date = getSetDayOfMonth;
  20563. proto.day = proto.days = getSetDayOfWeek;
  20564. proto.weekday = getSetLocaleDayOfWeek;
  20565. proto.isoWeekday = getSetISODayOfWeek;
  20566. proto.dayOfYear = getSetDayOfYear;
  20567. // Hour
  20568. proto.hour = proto.hours = getSetHour;
  20569. // Minute
  20570. proto.minute = proto.minutes = getSetMinute;
  20571. // Second
  20572. proto.second = proto.seconds = getSetSecond;
  20573. // Millisecond
  20574. proto.millisecond = proto.milliseconds = getSetMillisecond;
  20575. // Offset
  20576. proto.utcOffset = getSetOffset;
  20577. proto.utc = setOffsetToUTC;
  20578. proto.local = setOffsetToLocal;
  20579. proto.parseZone = setOffsetToParsedOffset;
  20580. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  20581. proto.isDST = isDaylightSavingTime;
  20582. proto.isLocal = isLocal;
  20583. proto.isUtcOffset = isUtcOffset;
  20584. proto.isUtc = isUtc;
  20585. proto.isUTC = isUtc;
  20586. // Timezone
  20587. proto.zoneAbbr = getZoneAbbr;
  20588. proto.zoneName = getZoneName;
  20589. // Deprecations
  20590. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  20591. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  20592. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  20593. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  20594. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  20595. function createUnix (input) {
  20596. return createLocal(input * 1000);
  20597. }
  20598. function createInZone () {
  20599. return createLocal.apply(null, arguments).parseZone();
  20600. }
  20601. function preParsePostFormat (string) {
  20602. return string;
  20603. }
  20604. var proto$1 = Locale.prototype;
  20605. proto$1.calendar = calendar;
  20606. proto$1.longDateFormat = longDateFormat;
  20607. proto$1.invalidDate = invalidDate;
  20608. proto$1.ordinal = ordinal;
  20609. proto$1.preparse = preParsePostFormat;
  20610. proto$1.postformat = preParsePostFormat;
  20611. proto$1.relativeTime = relativeTime;
  20612. proto$1.pastFuture = pastFuture;
  20613. proto$1.set = set;
  20614. // Month
  20615. proto$1.months = localeMonths;
  20616. proto$1.monthsShort = localeMonthsShort;
  20617. proto$1.monthsParse = localeMonthsParse;
  20618. proto$1.monthsRegex = monthsRegex;
  20619. proto$1.monthsShortRegex = monthsShortRegex;
  20620. // Week
  20621. proto$1.week = localeWeek;
  20622. proto$1.firstDayOfYear = localeFirstDayOfYear;
  20623. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  20624. // Day of Week
  20625. proto$1.weekdays = localeWeekdays;
  20626. proto$1.weekdaysMin = localeWeekdaysMin;
  20627. proto$1.weekdaysShort = localeWeekdaysShort;
  20628. proto$1.weekdaysParse = localeWeekdaysParse;
  20629. proto$1.weekdaysRegex = weekdaysRegex;
  20630. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  20631. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  20632. // Hours
  20633. proto$1.isPM = localeIsPM;
  20634. proto$1.meridiem = localeMeridiem;
  20635. function get$1 (format, index, field, setter) {
  20636. var locale = getLocale();
  20637. var utc = createUTC().set(setter, index);
  20638. return locale[field](utc, format);
  20639. }
  20640. function listMonthsImpl (format, index, field) {
  20641. if (isNumber(format)) {
  20642. index = format;
  20643. format = undefined;
  20644. }
  20645. format = format || '';
  20646. if (index != null) {
  20647. return get$1(format, index, field, 'month');
  20648. }
  20649. var i;
  20650. var out = [];
  20651. for (i = 0; i < 12; i++) {
  20652. out[i] = get$1(format, i, field, 'month');
  20653. }
  20654. return out;
  20655. }
  20656. // ()
  20657. // (5)
  20658. // (fmt, 5)
  20659. // (fmt)
  20660. // (true)
  20661. // (true, 5)
  20662. // (true, fmt, 5)
  20663. // (true, fmt)
  20664. function listWeekdaysImpl (localeSorted, format, index, field) {
  20665. if (typeof localeSorted === 'boolean') {
  20666. if (isNumber(format)) {
  20667. index = format;
  20668. format = undefined;
  20669. }
  20670. format = format || '';
  20671. } else {
  20672. format = localeSorted;
  20673. index = format;
  20674. localeSorted = false;
  20675. if (isNumber(format)) {
  20676. index = format;
  20677. format = undefined;
  20678. }
  20679. format = format || '';
  20680. }
  20681. var locale = getLocale(),
  20682. shift = localeSorted ? locale._week.dow : 0;
  20683. if (index != null) {
  20684. return get$1(format, (index + shift) % 7, field, 'day');
  20685. }
  20686. var i;
  20687. var out = [];
  20688. for (i = 0; i < 7; i++) {
  20689. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  20690. }
  20691. return out;
  20692. }
  20693. function listMonths (format, index) {
  20694. return listMonthsImpl(format, index, 'months');
  20695. }
  20696. function listMonthsShort (format, index) {
  20697. return listMonthsImpl(format, index, 'monthsShort');
  20698. }
  20699. function listWeekdays (localeSorted, format, index) {
  20700. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  20701. }
  20702. function listWeekdaysShort (localeSorted, format, index) {
  20703. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  20704. }
  20705. function listWeekdaysMin (localeSorted, format, index) {
  20706. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  20707. }
  20708. getSetGlobalLocale('en', {
  20709. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  20710. ordinal : function (number) {
  20711. var b = number % 10,
  20712. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  20713. (b === 1) ? 'st' :
  20714. (b === 2) ? 'nd' :
  20715. (b === 3) ? 'rd' : 'th';
  20716. return number + output;
  20717. }
  20718. });
  20719. // Side effect imports
  20720. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  20721. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  20722. var mathAbs = Math.abs;
  20723. function abs () {
  20724. var data = this._data;
  20725. this._milliseconds = mathAbs(this._milliseconds);
  20726. this._days = mathAbs(this._days);
  20727. this._months = mathAbs(this._months);
  20728. data.milliseconds = mathAbs(data.milliseconds);
  20729. data.seconds = mathAbs(data.seconds);
  20730. data.minutes = mathAbs(data.minutes);
  20731. data.hours = mathAbs(data.hours);
  20732. data.months = mathAbs(data.months);
  20733. data.years = mathAbs(data.years);
  20734. return this;
  20735. }
  20736. function addSubtract$1 (duration, input, value, direction) {
  20737. var other = createDuration(input, value);
  20738. duration._milliseconds += direction * other._milliseconds;
  20739. duration._days += direction * other._days;
  20740. duration._months += direction * other._months;
  20741. return duration._bubble();
  20742. }
  20743. // supports only 2.0-style add(1, 's') or add(duration)
  20744. function add$1 (input, value) {
  20745. return addSubtract$1(this, input, value, 1);
  20746. }
  20747. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  20748. function subtract$1 (input, value) {
  20749. return addSubtract$1(this, input, value, -1);
  20750. }
  20751. function absCeil (number) {
  20752. if (number < 0) {
  20753. return Math.floor(number);
  20754. } else {
  20755. return Math.ceil(number);
  20756. }
  20757. }
  20758. function bubble () {
  20759. var milliseconds = this._milliseconds;
  20760. var days = this._days;
  20761. var months = this._months;
  20762. var data = this._data;
  20763. var seconds, minutes, hours, years, monthsFromDays;
  20764. // if we have a mix of positive and negative values, bubble down first
  20765. // check: https://github.com/moment/moment/issues/2166
  20766. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  20767. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  20768. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  20769. days = 0;
  20770. months = 0;
  20771. }
  20772. // The following code bubbles up values, see the tests for
  20773. // examples of what that means.
  20774. data.milliseconds = milliseconds % 1000;
  20775. seconds = absFloor(milliseconds / 1000);
  20776. data.seconds = seconds % 60;
  20777. minutes = absFloor(seconds / 60);
  20778. data.minutes = minutes % 60;
  20779. hours = absFloor(minutes / 60);
  20780. data.hours = hours % 24;
  20781. days += absFloor(hours / 24);
  20782. // convert days to months
  20783. monthsFromDays = absFloor(daysToMonths(days));
  20784. months += monthsFromDays;
  20785. days -= absCeil(monthsToDays(monthsFromDays));
  20786. // 12 months -> 1 year
  20787. years = absFloor(months / 12);
  20788. months %= 12;
  20789. data.days = days;
  20790. data.months = months;
  20791. data.years = years;
  20792. return this;
  20793. }
  20794. function daysToMonths (days) {
  20795. // 400 years have 146097 days (taking into account leap year rules)
  20796. // 400 years have 12 months === 4800
  20797. return days * 4800 / 146097;
  20798. }
  20799. function monthsToDays (months) {
  20800. // the reverse of daysToMonths
  20801. return months * 146097 / 4800;
  20802. }
  20803. function as (units) {
  20804. if (!this.isValid()) {
  20805. return NaN;
  20806. }
  20807. var days;
  20808. var months;
  20809. var milliseconds = this._milliseconds;
  20810. units = normalizeUnits(units);
  20811. if (units === 'month' || units === 'year') {
  20812. days = this._days + milliseconds / 864e5;
  20813. months = this._months + daysToMonths(days);
  20814. return units === 'month' ? months : months / 12;
  20815. } else {
  20816. // handle milliseconds separately because of floating point math errors (issue #1867)
  20817. days = this._days + Math.round(monthsToDays(this._months));
  20818. switch (units) {
  20819. case 'week' : return days / 7 + milliseconds / 6048e5;
  20820. case 'day' : return days + milliseconds / 864e5;
  20821. case 'hour' : return days * 24 + milliseconds / 36e5;
  20822. case 'minute' : return days * 1440 + milliseconds / 6e4;
  20823. case 'second' : return days * 86400 + milliseconds / 1000;
  20824. // Math.floor prevents floating point math errors here
  20825. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  20826. default: throw new Error('Unknown unit ' + units);
  20827. }
  20828. }
  20829. }
  20830. // TODO: Use this.as('ms')?
  20831. function valueOf$1 () {
  20832. if (!this.isValid()) {
  20833. return NaN;
  20834. }
  20835. return (
  20836. this._milliseconds +
  20837. this._days * 864e5 +
  20838. (this._months % 12) * 2592e6 +
  20839. toInt(this._months / 12) * 31536e6
  20840. );
  20841. }
  20842. function makeAs (alias) {
  20843. return function () {
  20844. return this.as(alias);
  20845. };
  20846. }
  20847. var asMilliseconds = makeAs('ms');
  20848. var asSeconds = makeAs('s');
  20849. var asMinutes = makeAs('m');
  20850. var asHours = makeAs('h');
  20851. var asDays = makeAs('d');
  20852. var asWeeks = makeAs('w');
  20853. var asMonths = makeAs('M');
  20854. var asYears = makeAs('y');
  20855. function clone$1 () {
  20856. return createDuration(this);
  20857. }
  20858. function get$2 (units) {
  20859. units = normalizeUnits(units);
  20860. return this.isValid() ? this[units + 's']() : NaN;
  20861. }
  20862. function makeGetter(name) {
  20863. return function () {
  20864. return this.isValid() ? this._data[name] : NaN;
  20865. };
  20866. }
  20867. var milliseconds = makeGetter('milliseconds');
  20868. var seconds = makeGetter('seconds');
  20869. var minutes = makeGetter('minutes');
  20870. var hours = makeGetter('hours');
  20871. var days = makeGetter('days');
  20872. var months = makeGetter('months');
  20873. var years = makeGetter('years');
  20874. function weeks () {
  20875. return absFloor(this.days() / 7);
  20876. }
  20877. var round = Math.round;
  20878. var thresholds = {
  20879. ss: 44, // a few seconds to seconds
  20880. s : 45, // seconds to minute
  20881. m : 45, // minutes to hour
  20882. h : 22, // hours to day
  20883. d : 26, // days to month
  20884. M : 11 // months to year
  20885. };
  20886. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  20887. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  20888. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  20889. }
  20890. function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
  20891. var duration = createDuration(posNegDuration).abs();
  20892. var seconds = round(duration.as('s'));
  20893. var minutes = round(duration.as('m'));
  20894. var hours = round(duration.as('h'));
  20895. var days = round(duration.as('d'));
  20896. var months = round(duration.as('M'));
  20897. var years = round(duration.as('y'));
  20898. var a = seconds <= thresholds.ss && ['s', seconds] ||
  20899. seconds < thresholds.s && ['ss', seconds] ||
  20900. minutes <= 1 && ['m'] ||
  20901. minutes < thresholds.m && ['mm', minutes] ||
  20902. hours <= 1 && ['h'] ||
  20903. hours < thresholds.h && ['hh', hours] ||
  20904. days <= 1 && ['d'] ||
  20905. days < thresholds.d && ['dd', days] ||
  20906. months <= 1 && ['M'] ||
  20907. months < thresholds.M && ['MM', months] ||
  20908. years <= 1 && ['y'] || ['yy', years];
  20909. a[2] = withoutSuffix;
  20910. a[3] = +posNegDuration > 0;
  20911. a[4] = locale;
  20912. return substituteTimeAgo.apply(null, a);
  20913. }
  20914. // This function allows you to set the rounding function for relative time strings
  20915. function getSetRelativeTimeRounding (roundingFunction) {
  20916. if (roundingFunction === undefined) {
  20917. return round;
  20918. }
  20919. if (typeof(roundingFunction) === 'function') {
  20920. round = roundingFunction;
  20921. return true;
  20922. }
  20923. return false;
  20924. }
  20925. // This function allows you to set a threshold for relative time strings
  20926. function getSetRelativeTimeThreshold (threshold, limit) {
  20927. if (thresholds[threshold] === undefined) {
  20928. return false;
  20929. }
  20930. if (limit === undefined) {
  20931. return thresholds[threshold];
  20932. }
  20933. thresholds[threshold] = limit;
  20934. if (threshold === 's') {
  20935. thresholds.ss = limit - 1;
  20936. }
  20937. return true;
  20938. }
  20939. function humanize (withSuffix) {
  20940. if (!this.isValid()) {
  20941. return this.localeData().invalidDate();
  20942. }
  20943. var locale = this.localeData();
  20944. var output = relativeTime$1(this, !withSuffix, locale);
  20945. if (withSuffix) {
  20946. output = locale.pastFuture(+this, output);
  20947. }
  20948. return locale.postformat(output);
  20949. }
  20950. var abs$1 = Math.abs;
  20951. function sign(x) {
  20952. return ((x > 0) - (x < 0)) || +x;
  20953. }
  20954. function toISOString$1() {
  20955. // for ISO strings we do not use the normal bubbling rules:
  20956. // * milliseconds bubble up until they become hours
  20957. // * days do not bubble at all
  20958. // * months bubble up until they become years
  20959. // This is because there is no context-free conversion between hours and days
  20960. // (think of clock changes)
  20961. // and also not between days and months (28-31 days per month)
  20962. if (!this.isValid()) {
  20963. return this.localeData().invalidDate();
  20964. }
  20965. var seconds = abs$1(this._milliseconds) / 1000;
  20966. var days = abs$1(this._days);
  20967. var months = abs$1(this._months);
  20968. var minutes, hours, years;
  20969. // 3600 seconds -> 60 minutes -> 1 hour
  20970. minutes = absFloor(seconds / 60);
  20971. hours = absFloor(minutes / 60);
  20972. seconds %= 60;
  20973. minutes %= 60;
  20974. // 12 months -> 1 year
  20975. years = absFloor(months / 12);
  20976. months %= 12;
  20977. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  20978. var Y = years;
  20979. var M = months;
  20980. var D = days;
  20981. var h = hours;
  20982. var m = minutes;
  20983. var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  20984. var total = this.asSeconds();
  20985. if (!total) {
  20986. // this is the same as C#'s (Noda) and python (isodate)...
  20987. // but not other JS (goog.date)
  20988. return 'P0D';
  20989. }
  20990. var totalSign = total < 0 ? '-' : '';
  20991. var ymSign = sign(this._months) !== sign(total) ? '-' : '';
  20992. var daysSign = sign(this._days) !== sign(total) ? '-' : '';
  20993. var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  20994. return totalSign + 'P' +
  20995. (Y ? ymSign + Y + 'Y' : '') +
  20996. (M ? ymSign + M + 'M' : '') +
  20997. (D ? daysSign + D + 'D' : '') +
  20998. ((h || m || s) ? 'T' : '') +
  20999. (h ? hmsSign + h + 'H' : '') +
  21000. (m ? hmsSign + m + 'M' : '') +
  21001. (s ? hmsSign + s + 'S' : '');
  21002. }
  21003. var proto$2 = Duration.prototype;
  21004. proto$2.isValid = isValid$1;
  21005. proto$2.abs = abs;
  21006. proto$2.add = add$1;
  21007. proto$2.subtract = subtract$1;
  21008. proto$2.as = as;
  21009. proto$2.asMilliseconds = asMilliseconds;
  21010. proto$2.asSeconds = asSeconds;
  21011. proto$2.asMinutes = asMinutes;
  21012. proto$2.asHours = asHours;
  21013. proto$2.asDays = asDays;
  21014. proto$2.asWeeks = asWeeks;
  21015. proto$2.asMonths = asMonths;
  21016. proto$2.asYears = asYears;
  21017. proto$2.valueOf = valueOf$1;
  21018. proto$2._bubble = bubble;
  21019. proto$2.clone = clone$1;
  21020. proto$2.get = get$2;
  21021. proto$2.milliseconds = milliseconds;
  21022. proto$2.seconds = seconds;
  21023. proto$2.minutes = minutes;
  21024. proto$2.hours = hours;
  21025. proto$2.days = days;
  21026. proto$2.weeks = weeks;
  21027. proto$2.months = months;
  21028. proto$2.years = years;
  21029. proto$2.humanize = humanize;
  21030. proto$2.toISOString = toISOString$1;
  21031. proto$2.toString = toISOString$1;
  21032. proto$2.toJSON = toISOString$1;
  21033. proto$2.locale = locale;
  21034. proto$2.localeData = localeData;
  21035. // Deprecations
  21036. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  21037. proto$2.lang = lang;
  21038. // Side effect imports
  21039. // FORMATTING
  21040. addFormatToken('X', 0, 0, 'unix');
  21041. addFormatToken('x', 0, 0, 'valueOf');
  21042. // PARSING
  21043. addRegexToken('x', matchSigned);
  21044. addRegexToken('X', matchTimestamp);
  21045. addParseToken('X', function (input, array, config) {
  21046. config._d = new Date(parseFloat(input, 10) * 1000);
  21047. });
  21048. addParseToken('x', function (input, array, config) {
  21049. config._d = new Date(toInt(input));
  21050. });
  21051. // Side effect imports
  21052. //! moment.js
  21053. //! version : 2.19.4
  21054. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  21055. //! license : MIT
  21056. //! momentjs.com
  21057. hooks.version = '2.19.4';
  21058. setHookCallback(createLocal);
  21059. hooks.fn = proto;
  21060. hooks.min = min;
  21061. hooks.max = max;
  21062. hooks.now = now;
  21063. hooks.utc = createUTC;
  21064. hooks.unix = createUnix;
  21065. hooks.months = listMonths;
  21066. hooks.isDate = isDate;
  21067. hooks.locale = getSetGlobalLocale;
  21068. hooks.invalid = createInvalid;
  21069. hooks.duration = createDuration;
  21070. hooks.isMoment = isMoment;
  21071. hooks.weekdays = listWeekdays;
  21072. hooks.parseZone = createInZone;
  21073. hooks.localeData = getLocale;
  21074. hooks.isDuration = isDuration;
  21075. hooks.monthsShort = listMonthsShort;
  21076. hooks.weekdaysMin = listWeekdaysMin;
  21077. hooks.defineLocale = defineLocale;
  21078. hooks.updateLocale = updateLocale;
  21079. hooks.locales = listLocales;
  21080. hooks.weekdaysShort = listWeekdaysShort;
  21081. hooks.normalizeUnits = normalizeUnits;
  21082. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  21083. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  21084. hooks.calendarFormat = getCalendarFormat;
  21085. hooks.prototype = proto;
  21086. //! moment.js locale configuration
  21087. //! locale : Afrikaans [af]
  21088. //! author : Werner Mollentze : https://github.com/wernerm
  21089. hooks.defineLocale('af', {
  21090. months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
  21091. monthsShort : 'Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
  21092. weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
  21093. weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
  21094. weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
  21095. meridiemParse: /vm|nm/i,
  21096. isPM : function (input) {
  21097. return /^nm$/i.test(input);
  21098. },
  21099. meridiem : function (hours, minutes, isLower) {
  21100. if (hours < 12) {
  21101. return isLower ? 'vm' : 'VM';
  21102. } else {
  21103. return isLower ? 'nm' : 'NM';
  21104. }
  21105. },
  21106. longDateFormat : {
  21107. LT : 'HH:mm',
  21108. LTS : 'HH:mm:ss',
  21109. L : 'DD/MM/YYYY',
  21110. LL : 'D MMMM YYYY',
  21111. LLL : 'D MMMM YYYY HH:mm',
  21112. LLLL : 'dddd, D MMMM YYYY HH:mm'
  21113. },
  21114. calendar : {
  21115. sameDay : '[Vandag om] LT',
  21116. nextDay : '[Môre om] LT',
  21117. nextWeek : 'dddd [om] LT',
  21118. lastDay : '[Gister om] LT',
  21119. lastWeek : '[Laas] dddd [om] LT',
  21120. sameElse : 'L'
  21121. },
  21122. relativeTime : {
  21123. future : 'oor %s',
  21124. past : '%s gelede',
  21125. s : '\'n paar sekondes',
  21126. m : '\'n minuut',
  21127. mm : '%d minute',
  21128. h : '\'n uur',
  21129. hh : '%d ure',
  21130. d : '\'n dag',
  21131. dd : '%d dae',
  21132. M : '\'n maand',
  21133. MM : '%d maande',
  21134. y : '\'n jaar',
  21135. yy : '%d jaar'
  21136. },
  21137. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  21138. ordinal : function (number) {
  21139. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
  21140. },
  21141. week : {
  21142. dow : 1, // Maandag is die eerste dag van die week.
  21143. doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
  21144. }
  21145. });
  21146. //! moment.js locale configuration
  21147. //! locale : Arabic (Algeria) [ar-dz]
  21148. //! author : Noureddine LOUAHEDJ : https://github.com/noureddineme
  21149. hooks.defineLocale('ar-dz', {
  21150. months : 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21151. monthsShort : 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21152. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21153. weekdaysShort : 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  21154. weekdaysMin : 'أح_إث_ثلا_أر_خم_جم_سب'.split('_'),
  21155. weekdaysParseExact : true,
  21156. longDateFormat : {
  21157. LT : 'HH:mm',
  21158. LTS : 'HH:mm:ss',
  21159. L : 'DD/MM/YYYY',
  21160. LL : 'D MMMM YYYY',
  21161. LLL : 'D MMMM YYYY HH:mm',
  21162. LLLL : 'dddd D MMMM YYYY HH:mm'
  21163. },
  21164. calendar : {
  21165. sameDay: '[اليوم على الساعة] LT',
  21166. nextDay: '[غدا على الساعة] LT',
  21167. nextWeek: 'dddd [على الساعة] LT',
  21168. lastDay: '[أمس على الساعة] LT',
  21169. lastWeek: 'dddd [على الساعة] LT',
  21170. sameElse: 'L'
  21171. },
  21172. relativeTime : {
  21173. future : 'في %s',
  21174. past : 'منذ %s',
  21175. s : 'ثوان',
  21176. m : 'دقيقة',
  21177. mm : '%d دقائق',
  21178. h : 'ساعة',
  21179. hh : '%d ساعات',
  21180. d : 'يوم',
  21181. dd : '%d أيام',
  21182. M : 'شهر',
  21183. MM : '%d أشهر',
  21184. y : 'سنة',
  21185. yy : '%d سنوات'
  21186. },
  21187. week : {
  21188. dow : 0, // Sunday is the first day of the week.
  21189. doy : 4 // The week that contains Jan 1st is the first week of the year.
  21190. }
  21191. });
  21192. //! moment.js locale configuration
  21193. //! locale : Arabic (Kuwait) [ar-kw]
  21194. //! author : Nusret Parlak: https://github.com/nusretparlak
  21195. hooks.defineLocale('ar-kw', {
  21196. months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  21197. monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  21198. weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21199. weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  21200. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21201. weekdaysParseExact : true,
  21202. longDateFormat : {
  21203. LT : 'HH:mm',
  21204. LTS : 'HH:mm:ss',
  21205. L : 'DD/MM/YYYY',
  21206. LL : 'D MMMM YYYY',
  21207. LLL : 'D MMMM YYYY HH:mm',
  21208. LLLL : 'dddd D MMMM YYYY HH:mm'
  21209. },
  21210. calendar : {
  21211. sameDay: '[اليوم على الساعة] LT',
  21212. nextDay: '[غدا على الساعة] LT',
  21213. nextWeek: 'dddd [على الساعة] LT',
  21214. lastDay: '[أمس على الساعة] LT',
  21215. lastWeek: 'dddd [على الساعة] LT',
  21216. sameElse: 'L'
  21217. },
  21218. relativeTime : {
  21219. future : 'في %s',
  21220. past : 'منذ %s',
  21221. s : 'ثوان',
  21222. m : 'دقيقة',
  21223. mm : '%d دقائق',
  21224. h : 'ساعة',
  21225. hh : '%d ساعات',
  21226. d : 'يوم',
  21227. dd : '%d أيام',
  21228. M : 'شهر',
  21229. MM : '%d أشهر',
  21230. y : 'سنة',
  21231. yy : '%d سنوات'
  21232. },
  21233. week : {
  21234. dow : 0, // Sunday is the first day of the week.
  21235. doy : 12 // The week that contains Jan 1st is the first week of the year.
  21236. }
  21237. });
  21238. //! moment.js locale configuration
  21239. //! locale : Arabic (Lybia) [ar-ly]
  21240. //! author : Ali Hmer: https://github.com/kikoanis
  21241. var symbolMap = {
  21242. '1': '1',
  21243. '2': '2',
  21244. '3': '3',
  21245. '4': '4',
  21246. '5': '5',
  21247. '6': '6',
  21248. '7': '7',
  21249. '8': '8',
  21250. '9': '9',
  21251. '0': '0'
  21252. };
  21253. var pluralForm = function (n) {
  21254. return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
  21255. };
  21256. var plurals = {
  21257. s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
  21258. m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
  21259. h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
  21260. d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
  21261. M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
  21262. y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
  21263. };
  21264. var pluralize = function (u) {
  21265. return function (number, withoutSuffix, string, isFuture) {
  21266. var f = pluralForm(number),
  21267. str = plurals[u][pluralForm(number)];
  21268. if (f === 2) {
  21269. str = str[withoutSuffix ? 0 : 1];
  21270. }
  21271. return str.replace(/%d/i, number);
  21272. };
  21273. };
  21274. var months$1 = [
  21275. 'يناير',
  21276. 'فبراير',
  21277. 'مارس',
  21278. 'أبريل',
  21279. 'مايو',
  21280. 'يونيو',
  21281. 'يوليو',
  21282. 'أغسطس',
  21283. 'سبتمبر',
  21284. 'أكتوبر',
  21285. 'نوفمبر',
  21286. 'ديسمبر'
  21287. ];
  21288. hooks.defineLocale('ar-ly', {
  21289. months : months$1,
  21290. monthsShort : months$1,
  21291. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21292. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  21293. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21294. weekdaysParseExact : true,
  21295. longDateFormat : {
  21296. LT : 'HH:mm',
  21297. LTS : 'HH:mm:ss',
  21298. L : 'D/\u200FM/\u200FYYYY',
  21299. LL : 'D MMMM YYYY',
  21300. LLL : 'D MMMM YYYY HH:mm',
  21301. LLLL : 'dddd D MMMM YYYY HH:mm'
  21302. },
  21303. meridiemParse: /ص|م/,
  21304. isPM : function (input) {
  21305. return 'م' === input;
  21306. },
  21307. meridiem : function (hour, minute, isLower) {
  21308. if (hour < 12) {
  21309. return 'ص';
  21310. } else {
  21311. return 'م';
  21312. }
  21313. },
  21314. calendar : {
  21315. sameDay: '[اليوم عند الساعة] LT',
  21316. nextDay: '[غدًا عند الساعة] LT',
  21317. nextWeek: 'dddd [عند الساعة] LT',
  21318. lastDay: '[أمس عند الساعة] LT',
  21319. lastWeek: 'dddd [عند الساعة] LT',
  21320. sameElse: 'L'
  21321. },
  21322. relativeTime : {
  21323. future : 'بعد %s',
  21324. past : 'منذ %s',
  21325. s : pluralize('s'),
  21326. m : pluralize('m'),
  21327. mm : pluralize('m'),
  21328. h : pluralize('h'),
  21329. hh : pluralize('h'),
  21330. d : pluralize('d'),
  21331. dd : pluralize('d'),
  21332. M : pluralize('M'),
  21333. MM : pluralize('M'),
  21334. y : pluralize('y'),
  21335. yy : pluralize('y')
  21336. },
  21337. preparse: function (string) {
  21338. return string.replace(/،/g, ',');
  21339. },
  21340. postformat: function (string) {
  21341. return string.replace(/\d/g, function (match) {
  21342. return symbolMap[match];
  21343. }).replace(/,/g, '،');
  21344. },
  21345. week : {
  21346. dow : 6, // Saturday is the first day of the week.
  21347. doy : 12 // The week that contains Jan 1st is the first week of the year.
  21348. }
  21349. });
  21350. //! moment.js locale configuration
  21351. //! locale : Arabic (Morocco) [ar-ma]
  21352. //! author : ElFadili Yassine : https://github.com/ElFadiliY
  21353. //! author : Abdel Said : https://github.com/abdelsaid
  21354. hooks.defineLocale('ar-ma', {
  21355. months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  21356. monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  21357. weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21358. weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  21359. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21360. weekdaysParseExact : true,
  21361. longDateFormat : {
  21362. LT : 'HH:mm',
  21363. LTS : 'HH:mm:ss',
  21364. L : 'DD/MM/YYYY',
  21365. LL : 'D MMMM YYYY',
  21366. LLL : 'D MMMM YYYY HH:mm',
  21367. LLLL : 'dddd D MMMM YYYY HH:mm'
  21368. },
  21369. calendar : {
  21370. sameDay: '[اليوم على الساعة] LT',
  21371. nextDay: '[غدا على الساعة] LT',
  21372. nextWeek: 'dddd [على الساعة] LT',
  21373. lastDay: '[أمس على الساعة] LT',
  21374. lastWeek: 'dddd [على الساعة] LT',
  21375. sameElse: 'L'
  21376. },
  21377. relativeTime : {
  21378. future : 'في %s',
  21379. past : 'منذ %s',
  21380. s : 'ثوان',
  21381. m : 'دقيقة',
  21382. mm : '%d دقائق',
  21383. h : 'ساعة',
  21384. hh : '%d ساعات',
  21385. d : 'يوم',
  21386. dd : '%d أيام',
  21387. M : 'شهر',
  21388. MM : '%d أشهر',
  21389. y : 'سنة',
  21390. yy : '%d سنوات'
  21391. },
  21392. week : {
  21393. dow : 6, // Saturday is the first day of the week.
  21394. doy : 12 // The week that contains Jan 1st is the first week of the year.
  21395. }
  21396. });
  21397. //! moment.js locale configuration
  21398. //! locale : Arabic (Saudi Arabia) [ar-sa]
  21399. //! author : Suhail Alkowaileet : https://github.com/xsoh
  21400. var symbolMap$1 = {
  21401. '1': '١',
  21402. '2': '٢',
  21403. '3': '٣',
  21404. '4': '٤',
  21405. '5': '٥',
  21406. '6': '٦',
  21407. '7': '٧',
  21408. '8': '٨',
  21409. '9': '٩',
  21410. '0': '٠'
  21411. };
  21412. var numberMap = {
  21413. '١': '1',
  21414. '٢': '2',
  21415. '٣': '3',
  21416. '٤': '4',
  21417. '٥': '5',
  21418. '٦': '6',
  21419. '٧': '7',
  21420. '٨': '8',
  21421. '٩': '9',
  21422. '٠': '0'
  21423. };
  21424. hooks.defineLocale('ar-sa', {
  21425. months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21426. monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21427. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21428. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  21429. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21430. weekdaysParseExact : true,
  21431. longDateFormat : {
  21432. LT : 'HH:mm',
  21433. LTS : 'HH:mm:ss',
  21434. L : 'DD/MM/YYYY',
  21435. LL : 'D MMMM YYYY',
  21436. LLL : 'D MMMM YYYY HH:mm',
  21437. LLLL : 'dddd D MMMM YYYY HH:mm'
  21438. },
  21439. meridiemParse: /ص|م/,
  21440. isPM : function (input) {
  21441. return 'م' === input;
  21442. },
  21443. meridiem : function (hour, minute, isLower) {
  21444. if (hour < 12) {
  21445. return 'ص';
  21446. } else {
  21447. return 'م';
  21448. }
  21449. },
  21450. calendar : {
  21451. sameDay: '[اليوم على الساعة] LT',
  21452. nextDay: '[غدا على الساعة] LT',
  21453. nextWeek: 'dddd [على الساعة] LT',
  21454. lastDay: '[أمس على الساعة] LT',
  21455. lastWeek: 'dddd [على الساعة] LT',
  21456. sameElse: 'L'
  21457. },
  21458. relativeTime : {
  21459. future : 'في %s',
  21460. past : 'منذ %s',
  21461. s : 'ثوان',
  21462. m : 'دقيقة',
  21463. mm : '%d دقائق',
  21464. h : 'ساعة',
  21465. hh : '%d ساعات',
  21466. d : 'يوم',
  21467. dd : '%d أيام',
  21468. M : 'شهر',
  21469. MM : '%d أشهر',
  21470. y : 'سنة',
  21471. yy : '%d سنوات'
  21472. },
  21473. preparse: function (string) {
  21474. return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
  21475. return numberMap[match];
  21476. }).replace(/،/g, ',');
  21477. },
  21478. postformat: function (string) {
  21479. return string.replace(/\d/g, function (match) {
  21480. return symbolMap$1[match];
  21481. }).replace(/,/g, '،');
  21482. },
  21483. week : {
  21484. dow : 0, // Sunday is the first day of the week.
  21485. doy : 6 // The week that contains Jan 1st is the first week of the year.
  21486. }
  21487. });
  21488. //! moment.js locale configuration
  21489. //! locale : Arabic (Tunisia) [ar-tn]
  21490. //! author : Nader Toukabri : https://github.com/naderio
  21491. hooks.defineLocale('ar-tn', {
  21492. months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21493. monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  21494. weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21495. weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  21496. weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21497. weekdaysParseExact : true,
  21498. longDateFormat: {
  21499. LT: 'HH:mm',
  21500. LTS: 'HH:mm:ss',
  21501. L: 'DD/MM/YYYY',
  21502. LL: 'D MMMM YYYY',
  21503. LLL: 'D MMMM YYYY HH:mm',
  21504. LLLL: 'dddd D MMMM YYYY HH:mm'
  21505. },
  21506. calendar: {
  21507. sameDay: '[اليوم على الساعة] LT',
  21508. nextDay: '[غدا على الساعة] LT',
  21509. nextWeek: 'dddd [على الساعة] LT',
  21510. lastDay: '[أمس على الساعة] LT',
  21511. lastWeek: 'dddd [على الساعة] LT',
  21512. sameElse: 'L'
  21513. },
  21514. relativeTime: {
  21515. future: 'في %s',
  21516. past: 'منذ %s',
  21517. s: 'ثوان',
  21518. m: 'دقيقة',
  21519. mm: '%d دقائق',
  21520. h: 'ساعة',
  21521. hh: '%d ساعات',
  21522. d: 'يوم',
  21523. dd: '%d أيام',
  21524. M: 'شهر',
  21525. MM: '%d أشهر',
  21526. y: 'سنة',
  21527. yy: '%d سنوات'
  21528. },
  21529. week: {
  21530. dow: 1, // Monday is the first day of the week.
  21531. doy: 4 // The week that contains Jan 4th is the first week of the year.
  21532. }
  21533. });
  21534. //! moment.js locale configuration
  21535. //! locale : Arabic [ar]
  21536. //! author : Abdel Said: https://github.com/abdelsaid
  21537. //! author : Ahmed Elkhatib
  21538. //! author : forabi https://github.com/forabi
  21539. var symbolMap$2 = {
  21540. '1': '١',
  21541. '2': '٢',
  21542. '3': '٣',
  21543. '4': '٤',
  21544. '5': '٥',
  21545. '6': '٦',
  21546. '7': '٧',
  21547. '8': '٨',
  21548. '9': '٩',
  21549. '0': '٠'
  21550. };
  21551. var numberMap$1 = {
  21552. '١': '1',
  21553. '٢': '2',
  21554. '٣': '3',
  21555. '٤': '4',
  21556. '٥': '5',
  21557. '٦': '6',
  21558. '٧': '7',
  21559. '٨': '8',
  21560. '٩': '9',
  21561. '٠': '0'
  21562. };
  21563. var pluralForm$1 = function (n) {
  21564. return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
  21565. };
  21566. var plurals$1 = {
  21567. s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
  21568. m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
  21569. h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
  21570. d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
  21571. M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
  21572. y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
  21573. };
  21574. var pluralize$1 = function (u) {
  21575. return function (number, withoutSuffix, string, isFuture) {
  21576. var f = pluralForm$1(number),
  21577. str = plurals$1[u][pluralForm$1(number)];
  21578. if (f === 2) {
  21579. str = str[withoutSuffix ? 0 : 1];
  21580. }
  21581. return str.replace(/%d/i, number);
  21582. };
  21583. };
  21584. var months$2 = [
  21585. 'كانون الثاني يناير',
  21586. 'شباط فبراير',
  21587. 'آذار مارس',
  21588. 'نيسان أبريل',
  21589. 'أيار مايو',
  21590. 'حزيران يونيو',
  21591. 'تموز يوليو',
  21592. 'آب أغسطس',
  21593. 'أيلول سبتمبر',
  21594. 'تشرين الأول أكتوبر',
  21595. 'تشرين الثاني نوفمبر',
  21596. 'كانون الأول ديسمبر'
  21597. ];
  21598. hooks.defineLocale('ar', {
  21599. months : months$2,
  21600. monthsShort : months$2,
  21601. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  21602. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  21603. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  21604. weekdaysParseExact : true,
  21605. longDateFormat : {
  21606. LT : 'HH:mm',
  21607. LTS : 'HH:mm:ss',
  21608. L : 'D/\u200FM/\u200FYYYY',
  21609. LL : 'D MMMM YYYY',
  21610. LLL : 'D MMMM YYYY HH:mm',
  21611. LLLL : 'dddd D MMMM YYYY HH:mm'
  21612. },
  21613. meridiemParse: /ص|م/,
  21614. isPM : function (input) {
  21615. return 'م' === input;
  21616. },
  21617. meridiem : function (hour, minute, isLower) {
  21618. if (hour < 12) {
  21619. return 'ص';
  21620. } else {
  21621. return 'م';
  21622. }
  21623. },
  21624. calendar : {
  21625. sameDay: '[اليوم عند الساعة] LT',
  21626. nextDay: '[غدًا عند الساعة] LT',
  21627. nextWeek: 'dddd [عند الساعة] LT',
  21628. lastDay: '[أمس عند الساعة] LT',
  21629. lastWeek: 'dddd [عند الساعة] LT',
  21630. sameElse: 'L'
  21631. },
  21632. relativeTime : {
  21633. future : 'بعد %s',
  21634. past : 'منذ %s',
  21635. s : pluralize$1('s'),
  21636. m : pluralize$1('m'),
  21637. mm : pluralize$1('m'),
  21638. h : pluralize$1('h'),
  21639. hh : pluralize$1('h'),
  21640. d : pluralize$1('d'),
  21641. dd : pluralize$1('d'),
  21642. M : pluralize$1('M'),
  21643. MM : pluralize$1('M'),
  21644. y : pluralize$1('y'),
  21645. yy : pluralize$1('y')
  21646. },
  21647. preparse: function (string) {
  21648. return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
  21649. return numberMap$1[match];
  21650. }).replace(/،/g, ',');
  21651. },
  21652. postformat: function (string) {
  21653. return string.replace(/\d/g, function (match) {
  21654. return symbolMap$2[match];
  21655. }).replace(/,/g, '،');
  21656. },
  21657. week : {
  21658. dow : 6, // Saturday is the first day of the week.
  21659. doy : 12 // The week that contains Jan 1st is the first week of the year.
  21660. }
  21661. });
  21662. //! moment.js locale configuration
  21663. //! locale : Azerbaijani [az]
  21664. //! author : topchiyev : https://github.com/topchiyev
  21665. var suffixes = {
  21666. 1: '-inci',
  21667. 5: '-inci',
  21668. 8: '-inci',
  21669. 70: '-inci',
  21670. 80: '-inci',
  21671. 2: '-nci',
  21672. 7: '-nci',
  21673. 20: '-nci',
  21674. 50: '-nci',
  21675. 3: '-üncü',
  21676. 4: '-üncü',
  21677. 100: '-üncü',
  21678. 6: '-ncı',
  21679. 9: '-uncu',
  21680. 10: '-uncu',
  21681. 30: '-uncu',
  21682. 60: '-ıncı',
  21683. 90: '-ıncı'
  21684. };
  21685. hooks.defineLocale('az', {
  21686. months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
  21687. monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
  21688. weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
  21689. weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
  21690. weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
  21691. weekdaysParseExact : true,
  21692. longDateFormat : {
  21693. LT : 'HH:mm',
  21694. LTS : 'HH:mm:ss',
  21695. L : 'DD.MM.YYYY',
  21696. LL : 'D MMMM YYYY',
  21697. LLL : 'D MMMM YYYY HH:mm',
  21698. LLLL : 'dddd, D MMMM YYYY HH:mm'
  21699. },
  21700. calendar : {
  21701. sameDay : '[bugün saat] LT',
  21702. nextDay : '[sabah saat] LT',
  21703. nextWeek : '[gələn həftə] dddd [saat] LT',
  21704. lastDay : '[dünən] LT',
  21705. lastWeek : '[keçən həftə] dddd [saat] LT',
  21706. sameElse : 'L'
  21707. },
  21708. relativeTime : {
  21709. future : '%s sonra',
  21710. past : '%s əvvəl',
  21711. s : 'birneçə saniyyə',
  21712. m : 'bir dəqiqə',
  21713. mm : '%d dəqiqə',
  21714. h : 'bir saat',
  21715. hh : '%d saat',
  21716. d : 'bir gün',
  21717. dd : '%d gün',
  21718. M : 'bir ay',
  21719. MM : '%d ay',
  21720. y : 'bir il',
  21721. yy : '%d il'
  21722. },
  21723. meridiemParse: /gecə|səhər|gündüz|axşam/,
  21724. isPM : function (input) {
  21725. return /^(gündüz|axşam)$/.test(input);
  21726. },
  21727. meridiem : function (hour, minute, isLower) {
  21728. if (hour < 4) {
  21729. return 'gecə';
  21730. } else if (hour < 12) {
  21731. return 'səhər';
  21732. } else if (hour < 17) {
  21733. return 'gündüz';
  21734. } else {
  21735. return 'axşam';
  21736. }
  21737. },
  21738. dayOfMonthOrdinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
  21739. ordinal : function (number) {
  21740. if (number === 0) { // special case for zero
  21741. return number + '-ıncı';
  21742. }
  21743. var a = number % 10,
  21744. b = number % 100 - a,
  21745. c = number >= 100 ? 100 : null;
  21746. return number + (suffixes[a] || suffixes[b] || suffixes[c]);
  21747. },
  21748. week : {
  21749. dow : 1, // Monday is the first day of the week.
  21750. doy : 7 // The week that contains Jan 1st is the first week of the year.
  21751. }
  21752. });
  21753. //! moment.js locale configuration
  21754. //! locale : Belarusian [be]
  21755. //! author : Dmitry Demidov : https://github.com/demidov91
  21756. //! author: Praleska: http://praleska.pro/
  21757. //! Author : Menelion Elensúle : https://github.com/Oire
  21758. function plural(word, num) {
  21759. var forms = word.split('_');
  21760. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  21761. }
  21762. function relativeTimeWithPlural(number, withoutSuffix, key) {
  21763. var format = {
  21764. 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
  21765. 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
  21766. 'dd': 'дзень_дні_дзён',
  21767. 'MM': 'месяц_месяцы_месяцаў',
  21768. 'yy': 'год_гады_гадоў'
  21769. };
  21770. if (key === 'm') {
  21771. return withoutSuffix ? 'хвіліна' : 'хвіліну';
  21772. }
  21773. else if (key === 'h') {
  21774. return withoutSuffix ? 'гадзіна' : 'гадзіну';
  21775. }
  21776. else {
  21777. return number + ' ' + plural(format[key], +number);
  21778. }
  21779. }
  21780. hooks.defineLocale('be', {
  21781. months : {
  21782. format: 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_'),
  21783. standalone: 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_')
  21784. },
  21785. monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
  21786. weekdays : {
  21787. format: 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_'),
  21788. standalone: 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
  21789. isFormat: /\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/
  21790. },
  21791. weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
  21792. weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
  21793. longDateFormat : {
  21794. LT : 'HH:mm',
  21795. LTS : 'HH:mm:ss',
  21796. L : 'DD.MM.YYYY',
  21797. LL : 'D MMMM YYYY г.',
  21798. LLL : 'D MMMM YYYY г., HH:mm',
  21799. LLLL : 'dddd, D MMMM YYYY г., HH:mm'
  21800. },
  21801. calendar : {
  21802. sameDay: '[Сёння ў] LT',
  21803. nextDay: '[Заўтра ў] LT',
  21804. lastDay: '[Учора ў] LT',
  21805. nextWeek: function () {
  21806. return '[У] dddd [ў] LT';
  21807. },
  21808. lastWeek: function () {
  21809. switch (this.day()) {
  21810. case 0:
  21811. case 3:
  21812. case 5:
  21813. case 6:
  21814. return '[У мінулую] dddd [ў] LT';
  21815. case 1:
  21816. case 2:
  21817. case 4:
  21818. return '[У мінулы] dddd [ў] LT';
  21819. }
  21820. },
  21821. sameElse: 'L'
  21822. },
  21823. relativeTime : {
  21824. future : 'праз %s',
  21825. past : '%s таму',
  21826. s : 'некалькі секунд',
  21827. m : relativeTimeWithPlural,
  21828. mm : relativeTimeWithPlural,
  21829. h : relativeTimeWithPlural,
  21830. hh : relativeTimeWithPlural,
  21831. d : 'дзень',
  21832. dd : relativeTimeWithPlural,
  21833. M : 'месяц',
  21834. MM : relativeTimeWithPlural,
  21835. y : 'год',
  21836. yy : relativeTimeWithPlural
  21837. },
  21838. meridiemParse: /ночы|раніцы|дня|вечара/,
  21839. isPM : function (input) {
  21840. return /^(дня|вечара)$/.test(input);
  21841. },
  21842. meridiem : function (hour, minute, isLower) {
  21843. if (hour < 4) {
  21844. return 'ночы';
  21845. } else if (hour < 12) {
  21846. return 'раніцы';
  21847. } else if (hour < 17) {
  21848. return 'дня';
  21849. } else {
  21850. return 'вечара';
  21851. }
  21852. },
  21853. dayOfMonthOrdinalParse: /\d{1,2}-(і|ы|га)/,
  21854. ordinal: function (number, period) {
  21855. switch (period) {
  21856. case 'M':
  21857. case 'd':
  21858. case 'DDD':
  21859. case 'w':
  21860. case 'W':
  21861. return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
  21862. case 'D':
  21863. return number + '-га';
  21864. default:
  21865. return number;
  21866. }
  21867. },
  21868. week : {
  21869. dow : 1, // Monday is the first day of the week.
  21870. doy : 7 // The week that contains Jan 1st is the first week of the year.
  21871. }
  21872. });
  21873. //! moment.js locale configuration
  21874. //! locale : Bulgarian [bg]
  21875. //! author : Krasen Borisov : https://github.com/kraz
  21876. hooks.defineLocale('bg', {
  21877. months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
  21878. monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
  21879. weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
  21880. weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
  21881. weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  21882. longDateFormat : {
  21883. LT : 'H:mm',
  21884. LTS : 'H:mm:ss',
  21885. L : 'D.MM.YYYY',
  21886. LL : 'D MMMM YYYY',
  21887. LLL : 'D MMMM YYYY H:mm',
  21888. LLLL : 'dddd, D MMMM YYYY H:mm'
  21889. },
  21890. calendar : {
  21891. sameDay : '[Днес в] LT',
  21892. nextDay : '[Утре в] LT',
  21893. nextWeek : 'dddd [в] LT',
  21894. lastDay : '[Вчера в] LT',
  21895. lastWeek : function () {
  21896. switch (this.day()) {
  21897. case 0:
  21898. case 3:
  21899. case 6:
  21900. return '[В изминалата] dddd [в] LT';
  21901. case 1:
  21902. case 2:
  21903. case 4:
  21904. case 5:
  21905. return '[В изминалия] dddd [в] LT';
  21906. }
  21907. },
  21908. sameElse : 'L'
  21909. },
  21910. relativeTime : {
  21911. future : 'след %s',
  21912. past : 'преди %s',
  21913. s : 'няколко секунди',
  21914. m : 'минута',
  21915. mm : '%d минути',
  21916. h : 'час',
  21917. hh : '%d часа',
  21918. d : 'ден',
  21919. dd : '%d дни',
  21920. M : 'месец',
  21921. MM : '%d месеца',
  21922. y : 'година',
  21923. yy : '%d години'
  21924. },
  21925. dayOfMonthOrdinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
  21926. ordinal : function (number) {
  21927. var lastDigit = number % 10,
  21928. last2Digits = number % 100;
  21929. if (number === 0) {
  21930. return number + '-ев';
  21931. } else if (last2Digits === 0) {
  21932. return number + '-ен';
  21933. } else if (last2Digits > 10 && last2Digits < 20) {
  21934. return number + '-ти';
  21935. } else if (lastDigit === 1) {
  21936. return number + '-ви';
  21937. } else if (lastDigit === 2) {
  21938. return number + '-ри';
  21939. } else if (lastDigit === 7 || lastDigit === 8) {
  21940. return number + '-ми';
  21941. } else {
  21942. return number + '-ти';
  21943. }
  21944. },
  21945. week : {
  21946. dow : 1, // Monday is the first day of the week.
  21947. doy : 7 // The week that contains Jan 1st is the first week of the year.
  21948. }
  21949. });
  21950. //! moment.js locale configuration
  21951. //! locale : Bambara [bm]
  21952. //! author : Estelle Comment : https://github.com/estellecomment
  21953. // Language contact person : Abdoufata Kane : https://github.com/abdoufata
  21954. hooks.defineLocale('bm', {
  21955. months : 'Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo'.split('_'),
  21956. monthsShort : 'Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des'.split('_'),
  21957. weekdays : 'Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri'.split('_'),
  21958. weekdaysShort : 'Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib'.split('_'),
  21959. weekdaysMin : 'Ka_Nt_Ta_Ar_Al_Ju_Si'.split('_'),
  21960. longDateFormat : {
  21961. LT : 'HH:mm',
  21962. LTS : 'HH:mm:ss',
  21963. L : 'DD/MM/YYYY',
  21964. LL : 'MMMM [tile] D [san] YYYY',
  21965. LLL : 'MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm',
  21966. LLLL : 'dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm'
  21967. },
  21968. calendar : {
  21969. sameDay : '[Bi lɛrɛ] LT',
  21970. nextDay : '[Sini lɛrɛ] LT',
  21971. nextWeek : 'dddd [don lɛrɛ] LT',
  21972. lastDay : '[Kunu lɛrɛ] LT',
  21973. lastWeek : 'dddd [tɛmɛnen lɛrɛ] LT',
  21974. sameElse : 'L'
  21975. },
  21976. relativeTime : {
  21977. future : '%s kɔnɔ',
  21978. past : 'a bɛ %s bɔ',
  21979. s : 'sanga dama dama',
  21980. m : 'miniti kelen',
  21981. mm : 'miniti %d',
  21982. h : 'lɛrɛ kelen',
  21983. hh : 'lɛrɛ %d',
  21984. d : 'tile kelen',
  21985. dd : 'tile %d',
  21986. M : 'kalo kelen',
  21987. MM : 'kalo %d',
  21988. y : 'san kelen',
  21989. yy : 'san %d'
  21990. },
  21991. week : {
  21992. dow : 1, // Monday is the first day of the week.
  21993. doy : 4 // The week that contains Jan 4th is the first week of the year.
  21994. }
  21995. });
  21996. //! moment.js locale configuration
  21997. //! locale : Bengali [bn]
  21998. //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
  21999. var symbolMap$3 = {
  22000. '1': '১',
  22001. '2': '২',
  22002. '3': '৩',
  22003. '4': '৪',
  22004. '5': '৫',
  22005. '6': '৬',
  22006. '7': '৭',
  22007. '8': '৮',
  22008. '9': '৯',
  22009. '0': '০'
  22010. };
  22011. var numberMap$2 = {
  22012. '১': '1',
  22013. '২': '2',
  22014. '৩': '3',
  22015. '৪': '4',
  22016. '৫': '5',
  22017. '৬': '6',
  22018. '৭': '7',
  22019. '৮': '8',
  22020. '৯': '9',
  22021. '০': '0'
  22022. };
  22023. hooks.defineLocale('bn', {
  22024. months : 'জানুয়ারী_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
  22025. monthsShort : 'জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'),
  22026. weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'),
  22027. weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'),
  22028. weekdaysMin : 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'),
  22029. longDateFormat : {
  22030. LT : 'A h:mm সময়',
  22031. LTS : 'A h:mm:ss সময়',
  22032. L : 'DD/MM/YYYY',
  22033. LL : 'D MMMM YYYY',
  22034. LLL : 'D MMMM YYYY, A h:mm সময়',
  22035. LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
  22036. },
  22037. calendar : {
  22038. sameDay : '[আজ] LT',
  22039. nextDay : '[আগামীকাল] LT',
  22040. nextWeek : 'dddd, LT',
  22041. lastDay : '[গতকাল] LT',
  22042. lastWeek : '[গত] dddd, LT',
  22043. sameElse : 'L'
  22044. },
  22045. relativeTime : {
  22046. future : '%s পরে',
  22047. past : '%s আগে',
  22048. s : 'কয়েক সেকেন্ড',
  22049. m : 'এক মিনিট',
  22050. mm : '%d মিনিট',
  22051. h : 'এক ঘন্টা',
  22052. hh : '%d ঘন্টা',
  22053. d : 'এক দিন',
  22054. dd : '%d দিন',
  22055. M : 'এক মাস',
  22056. MM : '%d মাস',
  22057. y : 'এক বছর',
  22058. yy : '%d বছর'
  22059. },
  22060. preparse: function (string) {
  22061. return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
  22062. return numberMap$2[match];
  22063. });
  22064. },
  22065. postformat: function (string) {
  22066. return string.replace(/\d/g, function (match) {
  22067. return symbolMap$3[match];
  22068. });
  22069. },
  22070. meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
  22071. meridiemHour : function (hour, meridiem) {
  22072. if (hour === 12) {
  22073. hour = 0;
  22074. }
  22075. if ((meridiem === 'রাত' && hour >= 4) ||
  22076. (meridiem === 'দুপুর' && hour < 5) ||
  22077. meridiem === 'বিকাল') {
  22078. return hour + 12;
  22079. } else {
  22080. return hour;
  22081. }
  22082. },
  22083. meridiem : function (hour, minute, isLower) {
  22084. if (hour < 4) {
  22085. return 'রাত';
  22086. } else if (hour < 10) {
  22087. return 'সকাল';
  22088. } else if (hour < 17) {
  22089. return 'দুপুর';
  22090. } else if (hour < 20) {
  22091. return 'বিকাল';
  22092. } else {
  22093. return 'রাত';
  22094. }
  22095. },
  22096. week : {
  22097. dow : 0, // Sunday is the first day of the week.
  22098. doy : 6 // The week that contains Jan 1st is the first week of the year.
  22099. }
  22100. });
  22101. //! moment.js locale configuration
  22102. //! locale : Tibetan [bo]
  22103. //! author : Thupten N. Chakrishar : https://github.com/vajradog
  22104. var symbolMap$4 = {
  22105. '1': '༡',
  22106. '2': '༢',
  22107. '3': '༣',
  22108. '4': '༤',
  22109. '5': '༥',
  22110. '6': '༦',
  22111. '7': '༧',
  22112. '8': '༨',
  22113. '9': '༩',
  22114. '0': '༠'
  22115. };
  22116. var numberMap$3 = {
  22117. '༡': '1',
  22118. '༢': '2',
  22119. '༣': '3',
  22120. '༤': '4',
  22121. '༥': '5',
  22122. '༦': '6',
  22123. '༧': '7',
  22124. '༨': '8',
  22125. '༩': '9',
  22126. '༠': '0'
  22127. };
  22128. hooks.defineLocale('bo', {
  22129. months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
  22130. monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
  22131. weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
  22132. weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
  22133. weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
  22134. longDateFormat : {
  22135. LT : 'A h:mm',
  22136. LTS : 'A h:mm:ss',
  22137. L : 'DD/MM/YYYY',
  22138. LL : 'D MMMM YYYY',
  22139. LLL : 'D MMMM YYYY, A h:mm',
  22140. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  22141. },
  22142. calendar : {
  22143. sameDay : '[དི་རིང] LT',
  22144. nextDay : '[སང་ཉིན] LT',
  22145. nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
  22146. lastDay : '[ཁ་སང] LT',
  22147. lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
  22148. sameElse : 'L'
  22149. },
  22150. relativeTime : {
  22151. future : '%s ལ་',
  22152. past : '%s སྔན་ལ',
  22153. s : 'ལམ་སང',
  22154. m : 'སྐར་མ་གཅིག',
  22155. mm : '%d སྐར་མ',
  22156. h : 'ཆུ་ཚོད་གཅིག',
  22157. hh : '%d ཆུ་ཚོད',
  22158. d : 'ཉིན་གཅིག',
  22159. dd : '%d ཉིན་',
  22160. M : 'ཟླ་བ་གཅིག',
  22161. MM : '%d ཟླ་བ',
  22162. y : 'ལོ་གཅིག',
  22163. yy : '%d ལོ'
  22164. },
  22165. preparse: function (string) {
  22166. return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
  22167. return numberMap$3[match];
  22168. });
  22169. },
  22170. postformat: function (string) {
  22171. return string.replace(/\d/g, function (match) {
  22172. return symbolMap$4[match];
  22173. });
  22174. },
  22175. meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
  22176. meridiemHour : function (hour, meridiem) {
  22177. if (hour === 12) {
  22178. hour = 0;
  22179. }
  22180. if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
  22181. (meridiem === 'ཉིན་གུང' && hour < 5) ||
  22182. meridiem === 'དགོང་དག') {
  22183. return hour + 12;
  22184. } else {
  22185. return hour;
  22186. }
  22187. },
  22188. meridiem : function (hour, minute, isLower) {
  22189. if (hour < 4) {
  22190. return 'མཚན་མོ';
  22191. } else if (hour < 10) {
  22192. return 'ཞོགས་ཀས';
  22193. } else if (hour < 17) {
  22194. return 'ཉིན་གུང';
  22195. } else if (hour < 20) {
  22196. return 'དགོང་དག';
  22197. } else {
  22198. return 'མཚན་མོ';
  22199. }
  22200. },
  22201. week : {
  22202. dow : 0, // Sunday is the first day of the week.
  22203. doy : 6 // The week that contains Jan 1st is the first week of the year.
  22204. }
  22205. });
  22206. //! moment.js locale configuration
  22207. //! locale : Breton [br]
  22208. //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
  22209. function relativeTimeWithMutation(number, withoutSuffix, key) {
  22210. var format = {
  22211. 'mm': 'munutenn',
  22212. 'MM': 'miz',
  22213. 'dd': 'devezh'
  22214. };
  22215. return number + ' ' + mutation(format[key], number);
  22216. }
  22217. function specialMutationForYears(number) {
  22218. switch (lastNumber(number)) {
  22219. case 1:
  22220. case 3:
  22221. case 4:
  22222. case 5:
  22223. case 9:
  22224. return number + ' bloaz';
  22225. default:
  22226. return number + ' vloaz';
  22227. }
  22228. }
  22229. function lastNumber(number) {
  22230. if (number > 9) {
  22231. return lastNumber(number % 10);
  22232. }
  22233. return number;
  22234. }
  22235. function mutation(text, number) {
  22236. if (number === 2) {
  22237. return softMutation(text);
  22238. }
  22239. return text;
  22240. }
  22241. function softMutation(text) {
  22242. var mutationTable = {
  22243. 'm': 'v',
  22244. 'b': 'v',
  22245. 'd': 'z'
  22246. };
  22247. if (mutationTable[text.charAt(0)] === undefined) {
  22248. return text;
  22249. }
  22250. return mutationTable[text.charAt(0)] + text.substring(1);
  22251. }
  22252. hooks.defineLocale('br', {
  22253. months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
  22254. monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
  22255. weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
  22256. weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
  22257. weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
  22258. weekdaysParseExact : true,
  22259. longDateFormat : {
  22260. LT : 'h[e]mm A',
  22261. LTS : 'h[e]mm:ss A',
  22262. L : 'DD/MM/YYYY',
  22263. LL : 'D [a viz] MMMM YYYY',
  22264. LLL : 'D [a viz] MMMM YYYY h[e]mm A',
  22265. LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
  22266. },
  22267. calendar : {
  22268. sameDay : '[Hiziv da] LT',
  22269. nextDay : '[Warc\'hoazh da] LT',
  22270. nextWeek : 'dddd [da] LT',
  22271. lastDay : '[Dec\'h da] LT',
  22272. lastWeek : 'dddd [paset da] LT',
  22273. sameElse : 'L'
  22274. },
  22275. relativeTime : {
  22276. future : 'a-benn %s',
  22277. past : '%s \'zo',
  22278. s : 'un nebeud segondennoù',
  22279. m : 'ur vunutenn',
  22280. mm : relativeTimeWithMutation,
  22281. h : 'un eur',
  22282. hh : '%d eur',
  22283. d : 'un devezh',
  22284. dd : relativeTimeWithMutation,
  22285. M : 'ur miz',
  22286. MM : relativeTimeWithMutation,
  22287. y : 'ur bloaz',
  22288. yy : specialMutationForYears
  22289. },
  22290. dayOfMonthOrdinalParse: /\d{1,2}(añ|vet)/,
  22291. ordinal : function (number) {
  22292. var output = (number === 1) ? 'añ' : 'vet';
  22293. return number + output;
  22294. },
  22295. week : {
  22296. dow : 1, // Monday is the first day of the week.
  22297. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22298. }
  22299. });
  22300. //! moment.js locale configuration
  22301. //! locale : Bosnian [bs]
  22302. //! author : Nedim Cholich : https://github.com/frontyard
  22303. //! based on (hr) translation by Bojan Marković
  22304. function translate(number, withoutSuffix, key) {
  22305. var result = number + ' ';
  22306. switch (key) {
  22307. case 'm':
  22308. return withoutSuffix ? 'jedna minuta' : 'jedne minute';
  22309. case 'mm':
  22310. if (number === 1) {
  22311. result += 'minuta';
  22312. } else if (number === 2 || number === 3 || number === 4) {
  22313. result += 'minute';
  22314. } else {
  22315. result += 'minuta';
  22316. }
  22317. return result;
  22318. case 'h':
  22319. return withoutSuffix ? 'jedan sat' : 'jednog sata';
  22320. case 'hh':
  22321. if (number === 1) {
  22322. result += 'sat';
  22323. } else if (number === 2 || number === 3 || number === 4) {
  22324. result += 'sata';
  22325. } else {
  22326. result += 'sati';
  22327. }
  22328. return result;
  22329. case 'dd':
  22330. if (number === 1) {
  22331. result += 'dan';
  22332. } else {
  22333. result += 'dana';
  22334. }
  22335. return result;
  22336. case 'MM':
  22337. if (number === 1) {
  22338. result += 'mjesec';
  22339. } else if (number === 2 || number === 3 || number === 4) {
  22340. result += 'mjeseca';
  22341. } else {
  22342. result += 'mjeseci';
  22343. }
  22344. return result;
  22345. case 'yy':
  22346. if (number === 1) {
  22347. result += 'godina';
  22348. } else if (number === 2 || number === 3 || number === 4) {
  22349. result += 'godine';
  22350. } else {
  22351. result += 'godina';
  22352. }
  22353. return result;
  22354. }
  22355. }
  22356. hooks.defineLocale('bs', {
  22357. months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
  22358. monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
  22359. monthsParseExact: true,
  22360. weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  22361. weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  22362. weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
  22363. weekdaysParseExact : true,
  22364. longDateFormat : {
  22365. LT : 'H:mm',
  22366. LTS : 'H:mm:ss',
  22367. L : 'DD.MM.YYYY',
  22368. LL : 'D. MMMM YYYY',
  22369. LLL : 'D. MMMM YYYY H:mm',
  22370. LLLL : 'dddd, D. MMMM YYYY H:mm'
  22371. },
  22372. calendar : {
  22373. sameDay : '[danas u] LT',
  22374. nextDay : '[sutra u] LT',
  22375. nextWeek : function () {
  22376. switch (this.day()) {
  22377. case 0:
  22378. return '[u] [nedjelju] [u] LT';
  22379. case 3:
  22380. return '[u] [srijedu] [u] LT';
  22381. case 6:
  22382. return '[u] [subotu] [u] LT';
  22383. case 1:
  22384. case 2:
  22385. case 4:
  22386. case 5:
  22387. return '[u] dddd [u] LT';
  22388. }
  22389. },
  22390. lastDay : '[jučer u] LT',
  22391. lastWeek : function () {
  22392. switch (this.day()) {
  22393. case 0:
  22394. case 3:
  22395. return '[prošlu] dddd [u] LT';
  22396. case 6:
  22397. return '[prošle] [subote] [u] LT';
  22398. case 1:
  22399. case 2:
  22400. case 4:
  22401. case 5:
  22402. return '[prošli] dddd [u] LT';
  22403. }
  22404. },
  22405. sameElse : 'L'
  22406. },
  22407. relativeTime : {
  22408. future : 'za %s',
  22409. past : 'prije %s',
  22410. s : 'par sekundi',
  22411. m : translate,
  22412. mm : translate,
  22413. h : translate,
  22414. hh : translate,
  22415. d : 'dan',
  22416. dd : translate,
  22417. M : 'mjesec',
  22418. MM : translate,
  22419. y : 'godinu',
  22420. yy : translate
  22421. },
  22422. dayOfMonthOrdinalParse: /\d{1,2}\./,
  22423. ordinal : '%d.',
  22424. week : {
  22425. dow : 1, // Monday is the first day of the week.
  22426. doy : 7 // The week that contains Jan 1st is the first week of the year.
  22427. }
  22428. });
  22429. //! moment.js locale configuration
  22430. //! locale : Catalan [ca]
  22431. //! author : Juan G. Hurtado : https://github.com/juanghurtado
  22432. hooks.defineLocale('ca', {
  22433. months : {
  22434. standalone: 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
  22435. format: 'de gener_de febrer_de març_d\'abril_de maig_de juny_de juliol_d\'agost_de setembre_d\'octubre_de novembre_de desembre'.split('_'),
  22436. isFormat: /D[oD]?(\s)+MMMM/
  22437. },
  22438. monthsShort : 'gen._febr._març_abr._maig_juny_jul._ag._set._oct._nov._des.'.split('_'),
  22439. monthsParseExact : true,
  22440. weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
  22441. weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
  22442. weekdaysMin : 'dg_dl_dt_dc_dj_dv_ds'.split('_'),
  22443. weekdaysParseExact : true,
  22444. longDateFormat : {
  22445. LT : 'H:mm',
  22446. LTS : 'H:mm:ss',
  22447. L : 'DD/MM/YYYY',
  22448. LL : 'D MMMM [de] YYYY',
  22449. ll : 'D MMM YYYY',
  22450. LLL : 'D MMMM [de] YYYY [a les] H:mm',
  22451. lll : 'D MMM YYYY, H:mm',
  22452. LLLL : 'dddd D MMMM [de] YYYY [a les] H:mm',
  22453. llll : 'ddd D MMM YYYY, H:mm'
  22454. },
  22455. calendar : {
  22456. sameDay : function () {
  22457. return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  22458. },
  22459. nextDay : function () {
  22460. return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  22461. },
  22462. nextWeek : function () {
  22463. return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  22464. },
  22465. lastDay : function () {
  22466. return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  22467. },
  22468. lastWeek : function () {
  22469. return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  22470. },
  22471. sameElse : 'L'
  22472. },
  22473. relativeTime : {
  22474. future : 'd\'aquí %s',
  22475. past : 'fa %s',
  22476. s : 'uns segons',
  22477. m : 'un minut',
  22478. mm : '%d minuts',
  22479. h : 'una hora',
  22480. hh : '%d hores',
  22481. d : 'un dia',
  22482. dd : '%d dies',
  22483. M : 'un mes',
  22484. MM : '%d mesos',
  22485. y : 'un any',
  22486. yy : '%d anys'
  22487. },
  22488. dayOfMonthOrdinalParse: /\d{1,2}(r|n|t|è|a)/,
  22489. ordinal : function (number, period) {
  22490. var output = (number === 1) ? 'r' :
  22491. (number === 2) ? 'n' :
  22492. (number === 3) ? 'r' :
  22493. (number === 4) ? 't' : 'è';
  22494. if (period === 'w' || period === 'W') {
  22495. output = 'a';
  22496. }
  22497. return number + output;
  22498. },
  22499. week : {
  22500. dow : 1, // Monday is the first day of the week.
  22501. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22502. }
  22503. });
  22504. //! moment.js locale configuration
  22505. //! locale : Czech [cs]
  22506. //! author : petrbela : https://github.com/petrbela
  22507. var months$3 = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_');
  22508. var monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
  22509. function plural$1(n) {
  22510. return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
  22511. }
  22512. function translate$1(number, withoutSuffix, key, isFuture) {
  22513. var result = number + ' ';
  22514. switch (key) {
  22515. case 's': // a few seconds / in a few seconds / a few seconds ago
  22516. return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
  22517. case 'm': // a minute / in a minute / a minute ago
  22518. return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
  22519. case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
  22520. if (withoutSuffix || isFuture) {
  22521. return result + (plural$1(number) ? 'minuty' : 'minut');
  22522. } else {
  22523. return result + 'minutami';
  22524. }
  22525. break;
  22526. case 'h': // an hour / in an hour / an hour ago
  22527. return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
  22528. case 'hh': // 9 hours / in 9 hours / 9 hours ago
  22529. if (withoutSuffix || isFuture) {
  22530. return result + (plural$1(number) ? 'hodiny' : 'hodin');
  22531. } else {
  22532. return result + 'hodinami';
  22533. }
  22534. break;
  22535. case 'd': // a day / in a day / a day ago
  22536. return (withoutSuffix || isFuture) ? 'den' : 'dnem';
  22537. case 'dd': // 9 days / in 9 days / 9 days ago
  22538. if (withoutSuffix || isFuture) {
  22539. return result + (plural$1(number) ? 'dny' : 'dní');
  22540. } else {
  22541. return result + 'dny';
  22542. }
  22543. break;
  22544. case 'M': // a month / in a month / a month ago
  22545. return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
  22546. case 'MM': // 9 months / in 9 months / 9 months ago
  22547. if (withoutSuffix || isFuture) {
  22548. return result + (plural$1(number) ? 'měsíce' : 'měsíců');
  22549. } else {
  22550. return result + 'měsíci';
  22551. }
  22552. break;
  22553. case 'y': // a year / in a year / a year ago
  22554. return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
  22555. case 'yy': // 9 years / in 9 years / 9 years ago
  22556. if (withoutSuffix || isFuture) {
  22557. return result + (plural$1(number) ? 'roky' : 'let');
  22558. } else {
  22559. return result + 'lety';
  22560. }
  22561. break;
  22562. }
  22563. }
  22564. hooks.defineLocale('cs', {
  22565. months : months$3,
  22566. monthsShort : monthsShort,
  22567. monthsParse : (function (months, monthsShort) {
  22568. var i, _monthsParse = [];
  22569. for (i = 0; i < 12; i++) {
  22570. // use custom parser to solve problem with July (červenec)
  22571. _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
  22572. }
  22573. return _monthsParse;
  22574. }(months$3, monthsShort)),
  22575. shortMonthsParse : (function (monthsShort) {
  22576. var i, _shortMonthsParse = [];
  22577. for (i = 0; i < 12; i++) {
  22578. _shortMonthsParse[i] = new RegExp('^' + monthsShort[i] + '$', 'i');
  22579. }
  22580. return _shortMonthsParse;
  22581. }(monthsShort)),
  22582. longMonthsParse : (function (months) {
  22583. var i, _longMonthsParse = [];
  22584. for (i = 0; i < 12; i++) {
  22585. _longMonthsParse[i] = new RegExp('^' + months[i] + '$', 'i');
  22586. }
  22587. return _longMonthsParse;
  22588. }(months$3)),
  22589. weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
  22590. weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
  22591. weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
  22592. longDateFormat : {
  22593. LT: 'H:mm',
  22594. LTS : 'H:mm:ss',
  22595. L : 'DD.MM.YYYY',
  22596. LL : 'D. MMMM YYYY',
  22597. LLL : 'D. MMMM YYYY H:mm',
  22598. LLLL : 'dddd D. MMMM YYYY H:mm',
  22599. l : 'D. M. YYYY'
  22600. },
  22601. calendar : {
  22602. sameDay: '[dnes v] LT',
  22603. nextDay: '[zítra v] LT',
  22604. nextWeek: function () {
  22605. switch (this.day()) {
  22606. case 0:
  22607. return '[v neděli v] LT';
  22608. case 1:
  22609. case 2:
  22610. return '[v] dddd [v] LT';
  22611. case 3:
  22612. return '[ve středu v] LT';
  22613. case 4:
  22614. return '[ve čtvrtek v] LT';
  22615. case 5:
  22616. return '[v pátek v] LT';
  22617. case 6:
  22618. return '[v sobotu v] LT';
  22619. }
  22620. },
  22621. lastDay: '[včera v] LT',
  22622. lastWeek: function () {
  22623. switch (this.day()) {
  22624. case 0:
  22625. return '[minulou neděli v] LT';
  22626. case 1:
  22627. case 2:
  22628. return '[minulé] dddd [v] LT';
  22629. case 3:
  22630. return '[minulou středu v] LT';
  22631. case 4:
  22632. case 5:
  22633. return '[minulý] dddd [v] LT';
  22634. case 6:
  22635. return '[minulou sobotu v] LT';
  22636. }
  22637. },
  22638. sameElse: 'L'
  22639. },
  22640. relativeTime : {
  22641. future : 'za %s',
  22642. past : 'před %s',
  22643. s : translate$1,
  22644. m : translate$1,
  22645. mm : translate$1,
  22646. h : translate$1,
  22647. hh : translate$1,
  22648. d : translate$1,
  22649. dd : translate$1,
  22650. M : translate$1,
  22651. MM : translate$1,
  22652. y : translate$1,
  22653. yy : translate$1
  22654. },
  22655. dayOfMonthOrdinalParse : /\d{1,2}\./,
  22656. ordinal : '%d.',
  22657. week : {
  22658. dow : 1, // Monday is the first day of the week.
  22659. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22660. }
  22661. });
  22662. //! moment.js locale configuration
  22663. //! locale : Chuvash [cv]
  22664. //! author : Anatoly Mironov : https://github.com/mirontoli
  22665. hooks.defineLocale('cv', {
  22666. months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
  22667. monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
  22668. weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
  22669. weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
  22670. weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
  22671. longDateFormat : {
  22672. LT : 'HH:mm',
  22673. LTS : 'HH:mm:ss',
  22674. L : 'DD-MM-YYYY',
  22675. LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
  22676. LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
  22677. LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
  22678. },
  22679. calendar : {
  22680. sameDay: '[Паян] LT [сехетре]',
  22681. nextDay: '[Ыран] LT [сехетре]',
  22682. lastDay: '[Ӗнер] LT [сехетре]',
  22683. nextWeek: '[Ҫитес] dddd LT [сехетре]',
  22684. lastWeek: '[Иртнӗ] dddd LT [сехетре]',
  22685. sameElse: 'L'
  22686. },
  22687. relativeTime : {
  22688. future : function (output) {
  22689. var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
  22690. return output + affix;
  22691. },
  22692. past : '%s каялла',
  22693. s : 'пӗр-ик ҫеккунт',
  22694. m : 'пӗр минут',
  22695. mm : '%d минут',
  22696. h : 'пӗр сехет',
  22697. hh : '%d сехет',
  22698. d : 'пӗр кун',
  22699. dd : '%d кун',
  22700. M : 'пӗр уйӑх',
  22701. MM : '%d уйӑх',
  22702. y : 'пӗр ҫул',
  22703. yy : '%d ҫул'
  22704. },
  22705. dayOfMonthOrdinalParse: /\d{1,2}-мӗш/,
  22706. ordinal : '%d-мӗш',
  22707. week : {
  22708. dow : 1, // Monday is the first day of the week.
  22709. doy : 7 // The week that contains Jan 1st is the first week of the year.
  22710. }
  22711. });
  22712. //! moment.js locale configuration
  22713. //! locale : Welsh [cy]
  22714. //! author : Robert Allen : https://github.com/robgallen
  22715. //! author : https://github.com/ryangreaves
  22716. hooks.defineLocale('cy', {
  22717. months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
  22718. monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
  22719. weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
  22720. weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
  22721. weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
  22722. weekdaysParseExact : true,
  22723. // time formats are the same as en-gb
  22724. longDateFormat: {
  22725. LT: 'HH:mm',
  22726. LTS : 'HH:mm:ss',
  22727. L: 'DD/MM/YYYY',
  22728. LL: 'D MMMM YYYY',
  22729. LLL: 'D MMMM YYYY HH:mm',
  22730. LLLL: 'dddd, D MMMM YYYY HH:mm'
  22731. },
  22732. calendar: {
  22733. sameDay: '[Heddiw am] LT',
  22734. nextDay: '[Yfory am] LT',
  22735. nextWeek: 'dddd [am] LT',
  22736. lastDay: '[Ddoe am] LT',
  22737. lastWeek: 'dddd [diwethaf am] LT',
  22738. sameElse: 'L'
  22739. },
  22740. relativeTime: {
  22741. future: 'mewn %s',
  22742. past: '%s yn ôl',
  22743. s: 'ychydig eiliadau',
  22744. m: 'munud',
  22745. mm: '%d munud',
  22746. h: 'awr',
  22747. hh: '%d awr',
  22748. d: 'diwrnod',
  22749. dd: '%d diwrnod',
  22750. M: 'mis',
  22751. MM: '%d mis',
  22752. y: 'blwyddyn',
  22753. yy: '%d flynedd'
  22754. },
  22755. dayOfMonthOrdinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
  22756. // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
  22757. ordinal: function (number) {
  22758. var b = number,
  22759. output = '',
  22760. lookup = [
  22761. '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
  22762. 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
  22763. ];
  22764. if (b > 20) {
  22765. if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
  22766. output = 'fed'; // not 30ain, 70ain or 90ain
  22767. } else {
  22768. output = 'ain';
  22769. }
  22770. } else if (b > 0) {
  22771. output = lookup[b];
  22772. }
  22773. return number + output;
  22774. },
  22775. week : {
  22776. dow : 1, // Monday is the first day of the week.
  22777. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22778. }
  22779. });
  22780. //! moment.js locale configuration
  22781. //! locale : Danish [da]
  22782. //! author : Ulrik Nielsen : https://github.com/mrbase
  22783. hooks.defineLocale('da', {
  22784. months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
  22785. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
  22786. weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
  22787. weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
  22788. weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
  22789. longDateFormat : {
  22790. LT : 'HH:mm',
  22791. LTS : 'HH:mm:ss',
  22792. L : 'DD.MM.YYYY',
  22793. LL : 'D. MMMM YYYY',
  22794. LLL : 'D. MMMM YYYY HH:mm',
  22795. LLLL : 'dddd [d.] D. MMMM YYYY [kl.] HH:mm'
  22796. },
  22797. calendar : {
  22798. sameDay : '[i dag kl.] LT',
  22799. nextDay : '[i morgen kl.] LT',
  22800. nextWeek : 'på dddd [kl.] LT',
  22801. lastDay : '[i går kl.] LT',
  22802. lastWeek : '[i] dddd[s kl.] LT',
  22803. sameElse : 'L'
  22804. },
  22805. relativeTime : {
  22806. future : 'om %s',
  22807. past : '%s siden',
  22808. s : 'få sekunder',
  22809. m : 'et minut',
  22810. mm : '%d minutter',
  22811. h : 'en time',
  22812. hh : '%d timer',
  22813. d : 'en dag',
  22814. dd : '%d dage',
  22815. M : 'en måned',
  22816. MM : '%d måneder',
  22817. y : 'et år',
  22818. yy : '%d år'
  22819. },
  22820. dayOfMonthOrdinalParse: /\d{1,2}\./,
  22821. ordinal : '%d.',
  22822. week : {
  22823. dow : 1, // Monday is the first day of the week.
  22824. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22825. }
  22826. });
  22827. //! moment.js locale configuration
  22828. //! locale : German (Austria) [de-at]
  22829. //! author : lluchs : https://github.com/lluchs
  22830. //! author: Menelion Elensúle: https://github.com/Oire
  22831. //! author : Martin Groller : https://github.com/MadMG
  22832. //! author : Mikolaj Dadela : https://github.com/mik01aj
  22833. function processRelativeTime(number, withoutSuffix, key, isFuture) {
  22834. var format = {
  22835. 'm': ['eine Minute', 'einer Minute'],
  22836. 'h': ['eine Stunde', 'einer Stunde'],
  22837. 'd': ['ein Tag', 'einem Tag'],
  22838. 'dd': [number + ' Tage', number + ' Tagen'],
  22839. 'M': ['ein Monat', 'einem Monat'],
  22840. 'MM': [number + ' Monate', number + ' Monaten'],
  22841. 'y': ['ein Jahr', 'einem Jahr'],
  22842. 'yy': [number + ' Jahre', number + ' Jahren']
  22843. };
  22844. return withoutSuffix ? format[key][0] : format[key][1];
  22845. }
  22846. hooks.defineLocale('de-at', {
  22847. months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  22848. monthsShort : 'Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  22849. monthsParseExact : true,
  22850. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  22851. weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
  22852. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  22853. weekdaysParseExact : true,
  22854. longDateFormat : {
  22855. LT: 'HH:mm',
  22856. LTS: 'HH:mm:ss',
  22857. L : 'DD.MM.YYYY',
  22858. LL : 'D. MMMM YYYY',
  22859. LLL : 'D. MMMM YYYY HH:mm',
  22860. LLLL : 'dddd, D. MMMM YYYY HH:mm'
  22861. },
  22862. calendar : {
  22863. sameDay: '[heute um] LT [Uhr]',
  22864. sameElse: 'L',
  22865. nextDay: '[morgen um] LT [Uhr]',
  22866. nextWeek: 'dddd [um] LT [Uhr]',
  22867. lastDay: '[gestern um] LT [Uhr]',
  22868. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  22869. },
  22870. relativeTime : {
  22871. future : 'in %s',
  22872. past : 'vor %s',
  22873. s : 'ein paar Sekunden',
  22874. m : processRelativeTime,
  22875. mm : '%d Minuten',
  22876. h : processRelativeTime,
  22877. hh : '%d Stunden',
  22878. d : processRelativeTime,
  22879. dd : processRelativeTime,
  22880. M : processRelativeTime,
  22881. MM : processRelativeTime,
  22882. y : processRelativeTime,
  22883. yy : processRelativeTime
  22884. },
  22885. dayOfMonthOrdinalParse: /\d{1,2}\./,
  22886. ordinal : '%d.',
  22887. week : {
  22888. dow : 1, // Monday is the first day of the week.
  22889. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22890. }
  22891. });
  22892. //! moment.js locale configuration
  22893. //! locale : German (Switzerland) [de-ch]
  22894. //! author : sschueller : https://github.com/sschueller
  22895. // based on: https://www.bk.admin.ch/dokumentation/sprachen/04915/05016/index.html?lang=de#
  22896. function processRelativeTime$1(number, withoutSuffix, key, isFuture) {
  22897. var format = {
  22898. 'm': ['eine Minute', 'einer Minute'],
  22899. 'h': ['eine Stunde', 'einer Stunde'],
  22900. 'd': ['ein Tag', 'einem Tag'],
  22901. 'dd': [number + ' Tage', number + ' Tagen'],
  22902. 'M': ['ein Monat', 'einem Monat'],
  22903. 'MM': [number + ' Monate', number + ' Monaten'],
  22904. 'y': ['ein Jahr', 'einem Jahr'],
  22905. 'yy': [number + ' Jahre', number + ' Jahren']
  22906. };
  22907. return withoutSuffix ? format[key][0] : format[key][1];
  22908. }
  22909. hooks.defineLocale('de-ch', {
  22910. months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  22911. monthsShort : 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  22912. monthsParseExact : true,
  22913. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  22914. weekdaysShort : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  22915. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  22916. weekdaysParseExact : true,
  22917. longDateFormat : {
  22918. LT: 'HH.mm',
  22919. LTS: 'HH.mm.ss',
  22920. L : 'DD.MM.YYYY',
  22921. LL : 'D. MMMM YYYY',
  22922. LLL : 'D. MMMM YYYY HH.mm',
  22923. LLLL : 'dddd, D. MMMM YYYY HH.mm'
  22924. },
  22925. calendar : {
  22926. sameDay: '[heute um] LT [Uhr]',
  22927. sameElse: 'L',
  22928. nextDay: '[morgen um] LT [Uhr]',
  22929. nextWeek: 'dddd [um] LT [Uhr]',
  22930. lastDay: '[gestern um] LT [Uhr]',
  22931. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  22932. },
  22933. relativeTime : {
  22934. future : 'in %s',
  22935. past : 'vor %s',
  22936. s : 'ein paar Sekunden',
  22937. m : processRelativeTime$1,
  22938. mm : '%d Minuten',
  22939. h : processRelativeTime$1,
  22940. hh : '%d Stunden',
  22941. d : processRelativeTime$1,
  22942. dd : processRelativeTime$1,
  22943. M : processRelativeTime$1,
  22944. MM : processRelativeTime$1,
  22945. y : processRelativeTime$1,
  22946. yy : processRelativeTime$1
  22947. },
  22948. dayOfMonthOrdinalParse: /\d{1,2}\./,
  22949. ordinal : '%d.',
  22950. week : {
  22951. dow : 1, // Monday is the first day of the week.
  22952. doy : 4 // The week that contains Jan 4th is the first week of the year.
  22953. }
  22954. });
  22955. //! moment.js locale configuration
  22956. //! locale : German [de]
  22957. //! author : lluchs : https://github.com/lluchs
  22958. //! author: Menelion Elensúle: https://github.com/Oire
  22959. //! author : Mikolaj Dadela : https://github.com/mik01aj
  22960. function processRelativeTime$2(number, withoutSuffix, key, isFuture) {
  22961. var format = {
  22962. 'm': ['eine Minute', 'einer Minute'],
  22963. 'h': ['eine Stunde', 'einer Stunde'],
  22964. 'd': ['ein Tag', 'einem Tag'],
  22965. 'dd': [number + ' Tage', number + ' Tagen'],
  22966. 'M': ['ein Monat', 'einem Monat'],
  22967. 'MM': [number + ' Monate', number + ' Monaten'],
  22968. 'y': ['ein Jahr', 'einem Jahr'],
  22969. 'yy': [number + ' Jahre', number + ' Jahren']
  22970. };
  22971. return withoutSuffix ? format[key][0] : format[key][1];
  22972. }
  22973. hooks.defineLocale('de', {
  22974. months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  22975. monthsShort : 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  22976. monthsParseExact : true,
  22977. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  22978. weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
  22979. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  22980. weekdaysParseExact : true,
  22981. longDateFormat : {
  22982. LT: 'HH:mm',
  22983. LTS: 'HH:mm:ss',
  22984. L : 'DD.MM.YYYY',
  22985. LL : 'D. MMMM YYYY',
  22986. LLL : 'D. MMMM YYYY HH:mm',
  22987. LLLL : 'dddd, D. MMMM YYYY HH:mm'
  22988. },
  22989. calendar : {
  22990. sameDay: '[heute um] LT [Uhr]',
  22991. sameElse: 'L',
  22992. nextDay: '[morgen um] LT [Uhr]',
  22993. nextWeek: 'dddd [um] LT [Uhr]',
  22994. lastDay: '[gestern um] LT [Uhr]',
  22995. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  22996. },
  22997. relativeTime : {
  22998. future : 'in %s',
  22999. past : 'vor %s',
  23000. s : 'ein paar Sekunden',
  23001. m : processRelativeTime$2,
  23002. mm : '%d Minuten',
  23003. h : processRelativeTime$2,
  23004. hh : '%d Stunden',
  23005. d : processRelativeTime$2,
  23006. dd : processRelativeTime$2,
  23007. M : processRelativeTime$2,
  23008. MM : processRelativeTime$2,
  23009. y : processRelativeTime$2,
  23010. yy : processRelativeTime$2
  23011. },
  23012. dayOfMonthOrdinalParse: /\d{1,2}\./,
  23013. ordinal : '%d.',
  23014. week : {
  23015. dow : 1, // Monday is the first day of the week.
  23016. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23017. }
  23018. });
  23019. //! moment.js locale configuration
  23020. //! locale : Maldivian [dv]
  23021. //! author : Jawish Hameed : https://github.com/jawish
  23022. var months$4 = [
  23023. 'ޖެނުއަރީ',
  23024. 'ފެބްރުއަރީ',
  23025. 'މާރިޗު',
  23026. 'އޭޕްރީލު',
  23027. 'މޭ',
  23028. 'ޖޫން',
  23029. 'ޖުލައި',
  23030. 'އޯގަސްޓު',
  23031. 'ސެޕްޓެމްބަރު',
  23032. 'އޮކްޓޯބަރު',
  23033. 'ނޮވެމްބަރު',
  23034. 'ޑިސެމްބަރު'
  23035. ];
  23036. var weekdays = [
  23037. 'އާދިއްތަ',
  23038. 'ހޯމަ',
  23039. 'އަންގާރަ',
  23040. 'ބުދަ',
  23041. 'ބުރާސްފަތި',
  23042. 'ހުކުރު',
  23043. 'ހޮނިހިރު'
  23044. ];
  23045. hooks.defineLocale('dv', {
  23046. months : months$4,
  23047. monthsShort : months$4,
  23048. weekdays : weekdays,
  23049. weekdaysShort : weekdays,
  23050. weekdaysMin : 'އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި'.split('_'),
  23051. longDateFormat : {
  23052. LT : 'HH:mm',
  23053. LTS : 'HH:mm:ss',
  23054. L : 'D/M/YYYY',
  23055. LL : 'D MMMM YYYY',
  23056. LLL : 'D MMMM YYYY HH:mm',
  23057. LLLL : 'dddd D MMMM YYYY HH:mm'
  23058. },
  23059. meridiemParse: /މކ|މފ/,
  23060. isPM : function (input) {
  23061. return 'މފ' === input;
  23062. },
  23063. meridiem : function (hour, minute, isLower) {
  23064. if (hour < 12) {
  23065. return 'މކ';
  23066. } else {
  23067. return 'މފ';
  23068. }
  23069. },
  23070. calendar : {
  23071. sameDay : '[މިއަދު] LT',
  23072. nextDay : '[މާދަމާ] LT',
  23073. nextWeek : 'dddd LT',
  23074. lastDay : '[އިއްޔެ] LT',
  23075. lastWeek : '[ފާއިތުވި] dddd LT',
  23076. sameElse : 'L'
  23077. },
  23078. relativeTime : {
  23079. future : 'ތެރޭގައި %s',
  23080. past : 'ކުރިން %s',
  23081. s : 'ސިކުންތުކޮޅެއް',
  23082. m : 'މިނިޓެއް',
  23083. mm : 'މިނިޓު %d',
  23084. h : 'ގަޑިއިރެއް',
  23085. hh : 'ގަޑިއިރު %d',
  23086. d : 'ދުވަހެއް',
  23087. dd : 'ދުވަސް %d',
  23088. M : 'މަހެއް',
  23089. MM : 'މަސް %d',
  23090. y : 'އަހަރެއް',
  23091. yy : 'އަހަރު %d'
  23092. },
  23093. preparse: function (string) {
  23094. return string.replace(/،/g, ',');
  23095. },
  23096. postformat: function (string) {
  23097. return string.replace(/,/g, '،');
  23098. },
  23099. week : {
  23100. dow : 7, // Sunday is the first day of the week.
  23101. doy : 12 // The week that contains Jan 1st is the first week of the year.
  23102. }
  23103. });
  23104. //! moment.js locale configuration
  23105. //! locale : Greek [el]
  23106. //! author : Aggelos Karalias : https://github.com/mehiel
  23107. hooks.defineLocale('el', {
  23108. monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
  23109. monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
  23110. months : function (momentToFormat, format) {
  23111. if (!momentToFormat) {
  23112. return this._monthsNominativeEl;
  23113. } else if (typeof format === 'string' && /D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
  23114. return this._monthsGenitiveEl[momentToFormat.month()];
  23115. } else {
  23116. return this._monthsNominativeEl[momentToFormat.month()];
  23117. }
  23118. },
  23119. monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
  23120. weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
  23121. weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
  23122. weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
  23123. meridiem : function (hours, minutes, isLower) {
  23124. if (hours > 11) {
  23125. return isLower ? 'μμ' : 'ΜΜ';
  23126. } else {
  23127. return isLower ? 'πμ' : 'ΠΜ';
  23128. }
  23129. },
  23130. isPM : function (input) {
  23131. return ((input + '').toLowerCase()[0] === 'μ');
  23132. },
  23133. meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
  23134. longDateFormat : {
  23135. LT : 'h:mm A',
  23136. LTS : 'h:mm:ss A',
  23137. L : 'DD/MM/YYYY',
  23138. LL : 'D MMMM YYYY',
  23139. LLL : 'D MMMM YYYY h:mm A',
  23140. LLLL : 'dddd, D MMMM YYYY h:mm A'
  23141. },
  23142. calendarEl : {
  23143. sameDay : '[Σήμερα {}] LT',
  23144. nextDay : '[Αύριο {}] LT',
  23145. nextWeek : 'dddd [{}] LT',
  23146. lastDay : '[Χθες {}] LT',
  23147. lastWeek : function () {
  23148. switch (this.day()) {
  23149. case 6:
  23150. return '[το προηγούμενο] dddd [{}] LT';
  23151. default:
  23152. return '[την προηγούμενη] dddd [{}] LT';
  23153. }
  23154. },
  23155. sameElse : 'L'
  23156. },
  23157. calendar : function (key, mom) {
  23158. var output = this._calendarEl[key],
  23159. hours = mom && mom.hours();
  23160. if (isFunction(output)) {
  23161. output = output.apply(mom);
  23162. }
  23163. return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
  23164. },
  23165. relativeTime : {
  23166. future : 'σε %s',
  23167. past : '%s πριν',
  23168. s : 'λίγα δευτερόλεπτα',
  23169. m : 'ένα λεπτό',
  23170. mm : '%d λεπτά',
  23171. h : 'μία ώρα',
  23172. hh : '%d ώρες',
  23173. d : 'μία μέρα',
  23174. dd : '%d μέρες',
  23175. M : 'ένας μήνας',
  23176. MM : '%d μήνες',
  23177. y : 'ένας χρόνος',
  23178. yy : '%d χρόνια'
  23179. },
  23180. dayOfMonthOrdinalParse: /\d{1,2}η/,
  23181. ordinal: '%dη',
  23182. week : {
  23183. dow : 1, // Monday is the first day of the week.
  23184. doy : 4 // The week that contains Jan 4st is the first week of the year.
  23185. }
  23186. });
  23187. //! moment.js locale configuration
  23188. //! locale : English (Australia) [en-au]
  23189. //! author : Jared Morse : https://github.com/jarcoal
  23190. hooks.defineLocale('en-au', {
  23191. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  23192. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  23193. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  23194. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  23195. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  23196. longDateFormat : {
  23197. LT : 'h:mm A',
  23198. LTS : 'h:mm:ss A',
  23199. L : 'DD/MM/YYYY',
  23200. LL : 'D MMMM YYYY',
  23201. LLL : 'D MMMM YYYY h:mm A',
  23202. LLLL : 'dddd, D MMMM YYYY h:mm A'
  23203. },
  23204. calendar : {
  23205. sameDay : '[Today at] LT',
  23206. nextDay : '[Tomorrow at] LT',
  23207. nextWeek : 'dddd [at] LT',
  23208. lastDay : '[Yesterday at] LT',
  23209. lastWeek : '[Last] dddd [at] LT',
  23210. sameElse : 'L'
  23211. },
  23212. relativeTime : {
  23213. future : 'in %s',
  23214. past : '%s ago',
  23215. s : 'a few seconds',
  23216. m : 'a minute',
  23217. mm : '%d minutes',
  23218. h : 'an hour',
  23219. hh : '%d hours',
  23220. d : 'a day',
  23221. dd : '%d days',
  23222. M : 'a month',
  23223. MM : '%d months',
  23224. y : 'a year',
  23225. yy : '%d years'
  23226. },
  23227. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  23228. ordinal : function (number) {
  23229. var b = number % 10,
  23230. output = (~~(number % 100 / 10) === 1) ? 'th' :
  23231. (b === 1) ? 'st' :
  23232. (b === 2) ? 'nd' :
  23233. (b === 3) ? 'rd' : 'th';
  23234. return number + output;
  23235. },
  23236. week : {
  23237. dow : 1, // Monday is the first day of the week.
  23238. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23239. }
  23240. });
  23241. //! moment.js locale configuration
  23242. //! locale : English (Canada) [en-ca]
  23243. //! author : Jonathan Abourbih : https://github.com/jonbca
  23244. hooks.defineLocale('en-ca', {
  23245. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  23246. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  23247. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  23248. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  23249. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  23250. longDateFormat : {
  23251. LT : 'h:mm A',
  23252. LTS : 'h:mm:ss A',
  23253. L : 'YYYY-MM-DD',
  23254. LL : 'MMMM D, YYYY',
  23255. LLL : 'MMMM D, YYYY h:mm A',
  23256. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  23257. },
  23258. calendar : {
  23259. sameDay : '[Today at] LT',
  23260. nextDay : '[Tomorrow at] LT',
  23261. nextWeek : 'dddd [at] LT',
  23262. lastDay : '[Yesterday at] LT',
  23263. lastWeek : '[Last] dddd [at] LT',
  23264. sameElse : 'L'
  23265. },
  23266. relativeTime : {
  23267. future : 'in %s',
  23268. past : '%s ago',
  23269. s : 'a few seconds',
  23270. m : 'a minute',
  23271. mm : '%d minutes',
  23272. h : 'an hour',
  23273. hh : '%d hours',
  23274. d : 'a day',
  23275. dd : '%d days',
  23276. M : 'a month',
  23277. MM : '%d months',
  23278. y : 'a year',
  23279. yy : '%d years'
  23280. },
  23281. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  23282. ordinal : function (number) {
  23283. var b = number % 10,
  23284. output = (~~(number % 100 / 10) === 1) ? 'th' :
  23285. (b === 1) ? 'st' :
  23286. (b === 2) ? 'nd' :
  23287. (b === 3) ? 'rd' : 'th';
  23288. return number + output;
  23289. }
  23290. });
  23291. //! moment.js locale configuration
  23292. //! locale : English (United Kingdom) [en-gb]
  23293. //! author : Chris Gedrim : https://github.com/chrisgedrim
  23294. hooks.defineLocale('en-gb', {
  23295. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  23296. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  23297. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  23298. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  23299. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  23300. longDateFormat : {
  23301. LT : 'HH:mm',
  23302. LTS : 'HH:mm:ss',
  23303. L : 'DD/MM/YYYY',
  23304. LL : 'D MMMM YYYY',
  23305. LLL : 'D MMMM YYYY HH:mm',
  23306. LLLL : 'dddd, D MMMM YYYY HH:mm'
  23307. },
  23308. calendar : {
  23309. sameDay : '[Today at] LT',
  23310. nextDay : '[Tomorrow at] LT',
  23311. nextWeek : 'dddd [at] LT',
  23312. lastDay : '[Yesterday at] LT',
  23313. lastWeek : '[Last] dddd [at] LT',
  23314. sameElse : 'L'
  23315. },
  23316. relativeTime : {
  23317. future : 'in %s',
  23318. past : '%s ago',
  23319. s : 'a few seconds',
  23320. m : 'a minute',
  23321. mm : '%d minutes',
  23322. h : 'an hour',
  23323. hh : '%d hours',
  23324. d : 'a day',
  23325. dd : '%d days',
  23326. M : 'a month',
  23327. MM : '%d months',
  23328. y : 'a year',
  23329. yy : '%d years'
  23330. },
  23331. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  23332. ordinal : function (number) {
  23333. var b = number % 10,
  23334. output = (~~(number % 100 / 10) === 1) ? 'th' :
  23335. (b === 1) ? 'st' :
  23336. (b === 2) ? 'nd' :
  23337. (b === 3) ? 'rd' : 'th';
  23338. return number + output;
  23339. },
  23340. week : {
  23341. dow : 1, // Monday is the first day of the week.
  23342. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23343. }
  23344. });
  23345. //! moment.js locale configuration
  23346. //! locale : English (Ireland) [en-ie]
  23347. //! author : Chris Cartlidge : https://github.com/chriscartlidge
  23348. hooks.defineLocale('en-ie', {
  23349. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  23350. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  23351. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  23352. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  23353. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  23354. longDateFormat : {
  23355. LT : 'HH:mm',
  23356. LTS : 'HH:mm:ss',
  23357. L : 'DD-MM-YYYY',
  23358. LL : 'D MMMM YYYY',
  23359. LLL : 'D MMMM YYYY HH:mm',
  23360. LLLL : 'dddd D MMMM YYYY HH:mm'
  23361. },
  23362. calendar : {
  23363. sameDay : '[Today at] LT',
  23364. nextDay : '[Tomorrow at] LT',
  23365. nextWeek : 'dddd [at] LT',
  23366. lastDay : '[Yesterday at] LT',
  23367. lastWeek : '[Last] dddd [at] LT',
  23368. sameElse : 'L'
  23369. },
  23370. relativeTime : {
  23371. future : 'in %s',
  23372. past : '%s ago',
  23373. s : 'a few seconds',
  23374. m : 'a minute',
  23375. mm : '%d minutes',
  23376. h : 'an hour',
  23377. hh : '%d hours',
  23378. d : 'a day',
  23379. dd : '%d days',
  23380. M : 'a month',
  23381. MM : '%d months',
  23382. y : 'a year',
  23383. yy : '%d years'
  23384. },
  23385. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  23386. ordinal : function (number) {
  23387. var b = number % 10,
  23388. output = (~~(number % 100 / 10) === 1) ? 'th' :
  23389. (b === 1) ? 'st' :
  23390. (b === 2) ? 'nd' :
  23391. (b === 3) ? 'rd' : 'th';
  23392. return number + output;
  23393. },
  23394. week : {
  23395. dow : 1, // Monday is the first day of the week.
  23396. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23397. }
  23398. });
  23399. //! moment.js locale configuration
  23400. //! locale : English (New Zealand) [en-nz]
  23401. //! author : Luke McGregor : https://github.com/lukemcgregor
  23402. hooks.defineLocale('en-nz', {
  23403. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  23404. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  23405. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  23406. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  23407. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  23408. longDateFormat : {
  23409. LT : 'h:mm A',
  23410. LTS : 'h:mm:ss A',
  23411. L : 'DD/MM/YYYY',
  23412. LL : 'D MMMM YYYY',
  23413. LLL : 'D MMMM YYYY h:mm A',
  23414. LLLL : 'dddd, D MMMM YYYY h:mm A'
  23415. },
  23416. calendar : {
  23417. sameDay : '[Today at] LT',
  23418. nextDay : '[Tomorrow at] LT',
  23419. nextWeek : 'dddd [at] LT',
  23420. lastDay : '[Yesterday at] LT',
  23421. lastWeek : '[Last] dddd [at] LT',
  23422. sameElse : 'L'
  23423. },
  23424. relativeTime : {
  23425. future : 'in %s',
  23426. past : '%s ago',
  23427. s : 'a few seconds',
  23428. m : 'a minute',
  23429. mm : '%d minutes',
  23430. h : 'an hour',
  23431. hh : '%d hours',
  23432. d : 'a day',
  23433. dd : '%d days',
  23434. M : 'a month',
  23435. MM : '%d months',
  23436. y : 'a year',
  23437. yy : '%d years'
  23438. },
  23439. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  23440. ordinal : function (number) {
  23441. var b = number % 10,
  23442. output = (~~(number % 100 / 10) === 1) ? 'th' :
  23443. (b === 1) ? 'st' :
  23444. (b === 2) ? 'nd' :
  23445. (b === 3) ? 'rd' : 'th';
  23446. return number + output;
  23447. },
  23448. week : {
  23449. dow : 1, // Monday is the first day of the week.
  23450. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23451. }
  23452. });
  23453. //! moment.js locale configuration
  23454. //! locale : Esperanto [eo]
  23455. //! author : Colin Dean : https://github.com/colindean
  23456. //! author : Mia Nordentoft Imperatori : https://github.com/miestasmia
  23457. //! comment : miestasmia corrected the translation by colindean
  23458. hooks.defineLocale('eo', {
  23459. months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
  23460. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
  23461. weekdays : 'dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato'.split('_'),
  23462. weekdaysShort : 'dim_lun_mard_merk_ĵaŭ_ven_sab'.split('_'),
  23463. weekdaysMin : 'di_lu_ma_me_ĵa_ve_sa'.split('_'),
  23464. longDateFormat : {
  23465. LT : 'HH:mm',
  23466. LTS : 'HH:mm:ss',
  23467. L : 'YYYY-MM-DD',
  23468. LL : 'D[-a de] MMMM, YYYY',
  23469. LLL : 'D[-a de] MMMM, YYYY HH:mm',
  23470. LLLL : 'dddd, [la] D[-a de] MMMM, YYYY HH:mm'
  23471. },
  23472. meridiemParse: /[ap]\.t\.m/i,
  23473. isPM: function (input) {
  23474. return input.charAt(0).toLowerCase() === 'p';
  23475. },
  23476. meridiem : function (hours, minutes, isLower) {
  23477. if (hours > 11) {
  23478. return isLower ? 'p.t.m.' : 'P.T.M.';
  23479. } else {
  23480. return isLower ? 'a.t.m.' : 'A.T.M.';
  23481. }
  23482. },
  23483. calendar : {
  23484. sameDay : '[Hodiaŭ je] LT',
  23485. nextDay : '[Morgaŭ je] LT',
  23486. nextWeek : 'dddd [je] LT',
  23487. lastDay : '[Hieraŭ je] LT',
  23488. lastWeek : '[pasinta] dddd [je] LT',
  23489. sameElse : 'L'
  23490. },
  23491. relativeTime : {
  23492. future : 'post %s',
  23493. past : 'antaŭ %s',
  23494. s : 'sekundoj',
  23495. m : 'minuto',
  23496. mm : '%d minutoj',
  23497. h : 'horo',
  23498. hh : '%d horoj',
  23499. d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
  23500. dd : '%d tagoj',
  23501. M : 'monato',
  23502. MM : '%d monatoj',
  23503. y : 'jaro',
  23504. yy : '%d jaroj'
  23505. },
  23506. dayOfMonthOrdinalParse: /\d{1,2}a/,
  23507. ordinal : '%da',
  23508. week : {
  23509. dow : 1, // Monday is the first day of the week.
  23510. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23511. }
  23512. });
  23513. //! moment.js locale configuration
  23514. //! locale : Spanish (Dominican Republic) [es-do]
  23515. var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  23516. var monthsShort$1 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  23517. var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
  23518. var monthsRegex$1 = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
  23519. hooks.defineLocale('es-do', {
  23520. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  23521. monthsShort : function (m, format) {
  23522. if (!m) {
  23523. return monthsShortDot;
  23524. } else if (/-MMM-/.test(format)) {
  23525. return monthsShort$1[m.month()];
  23526. } else {
  23527. return monthsShortDot[m.month()];
  23528. }
  23529. },
  23530. monthsRegex: monthsRegex$1,
  23531. monthsShortRegex: monthsRegex$1,
  23532. monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
  23533. monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
  23534. monthsParse: monthsParse,
  23535. longMonthsParse: monthsParse,
  23536. shortMonthsParse: monthsParse,
  23537. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  23538. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  23539. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  23540. weekdaysParseExact : true,
  23541. longDateFormat : {
  23542. LT : 'h:mm A',
  23543. LTS : 'h:mm:ss A',
  23544. L : 'DD/MM/YYYY',
  23545. LL : 'D [de] MMMM [de] YYYY',
  23546. LLL : 'D [de] MMMM [de] YYYY h:mm A',
  23547. LLLL : 'dddd, D [de] MMMM [de] YYYY h:mm A'
  23548. },
  23549. calendar : {
  23550. sameDay : function () {
  23551. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23552. },
  23553. nextDay : function () {
  23554. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23555. },
  23556. nextWeek : function () {
  23557. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23558. },
  23559. lastDay : function () {
  23560. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23561. },
  23562. lastWeek : function () {
  23563. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23564. },
  23565. sameElse : 'L'
  23566. },
  23567. relativeTime : {
  23568. future : 'en %s',
  23569. past : 'hace %s',
  23570. s : 'unos segundos',
  23571. m : 'un minuto',
  23572. mm : '%d minutos',
  23573. h : 'una hora',
  23574. hh : '%d horas',
  23575. d : 'un día',
  23576. dd : '%d días',
  23577. M : 'un mes',
  23578. MM : '%d meses',
  23579. y : 'un año',
  23580. yy : '%d años'
  23581. },
  23582. dayOfMonthOrdinalParse : /\d{1,2}º/,
  23583. ordinal : '%dº',
  23584. week : {
  23585. dow : 1, // Monday is the first day of the week.
  23586. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23587. }
  23588. });
  23589. //! moment.js locale configuration
  23590. //! locale : Spanish (United States) [es-us]
  23591. //! author : bustta : https://github.com/bustta
  23592. var monthsShortDot$1 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  23593. var monthsShort$2 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  23594. hooks.defineLocale('es-us', {
  23595. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  23596. monthsShort : function (m, format) {
  23597. if (!m) {
  23598. return monthsShortDot$1;
  23599. } else if (/-MMM-/.test(format)) {
  23600. return monthsShort$2[m.month()];
  23601. } else {
  23602. return monthsShortDot$1[m.month()];
  23603. }
  23604. },
  23605. monthsParseExact : true,
  23606. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  23607. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  23608. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  23609. weekdaysParseExact : true,
  23610. longDateFormat : {
  23611. LT : 'H:mm',
  23612. LTS : 'H:mm:ss',
  23613. L : 'MM/DD/YYYY',
  23614. LL : 'MMMM [de] D [de] YYYY',
  23615. LLL : 'MMMM [de] D [de] YYYY H:mm',
  23616. LLLL : 'dddd, MMMM [de] D [de] YYYY H:mm'
  23617. },
  23618. calendar : {
  23619. sameDay : function () {
  23620. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23621. },
  23622. nextDay : function () {
  23623. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23624. },
  23625. nextWeek : function () {
  23626. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23627. },
  23628. lastDay : function () {
  23629. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23630. },
  23631. lastWeek : function () {
  23632. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23633. },
  23634. sameElse : 'L'
  23635. },
  23636. relativeTime : {
  23637. future : 'en %s',
  23638. past : 'hace %s',
  23639. s : 'unos segundos',
  23640. m : 'un minuto',
  23641. mm : '%d minutos',
  23642. h : 'una hora',
  23643. hh : '%d horas',
  23644. d : 'un día',
  23645. dd : '%d días',
  23646. M : 'un mes',
  23647. MM : '%d meses',
  23648. y : 'un año',
  23649. yy : '%d años'
  23650. },
  23651. dayOfMonthOrdinalParse : /\d{1,2}º/,
  23652. ordinal : '%dº',
  23653. week : {
  23654. dow : 0, // Sunday is the first day of the week.
  23655. doy : 6 // The week that contains Jan 1st is the first week of the year.
  23656. }
  23657. });
  23658. //! moment.js locale configuration
  23659. //! locale : Spanish [es]
  23660. //! author : Julio Napurí : https://github.com/julionc
  23661. var monthsShortDot$2 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  23662. var monthsShort$3 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  23663. var monthsParse$1 = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
  23664. var monthsRegex$2 = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
  23665. hooks.defineLocale('es', {
  23666. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  23667. monthsShort : function (m, format) {
  23668. if (!m) {
  23669. return monthsShortDot$2;
  23670. } else if (/-MMM-/.test(format)) {
  23671. return monthsShort$3[m.month()];
  23672. } else {
  23673. return monthsShortDot$2[m.month()];
  23674. }
  23675. },
  23676. monthsRegex : monthsRegex$2,
  23677. monthsShortRegex : monthsRegex$2,
  23678. monthsStrictRegex : /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
  23679. monthsShortStrictRegex : /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
  23680. monthsParse : monthsParse$1,
  23681. longMonthsParse : monthsParse$1,
  23682. shortMonthsParse : monthsParse$1,
  23683. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  23684. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  23685. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  23686. weekdaysParseExact : true,
  23687. longDateFormat : {
  23688. LT : 'H:mm',
  23689. LTS : 'H:mm:ss',
  23690. L : 'DD/MM/YYYY',
  23691. LL : 'D [de] MMMM [de] YYYY',
  23692. LLL : 'D [de] MMMM [de] YYYY H:mm',
  23693. LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
  23694. },
  23695. calendar : {
  23696. sameDay : function () {
  23697. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23698. },
  23699. nextDay : function () {
  23700. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23701. },
  23702. nextWeek : function () {
  23703. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23704. },
  23705. lastDay : function () {
  23706. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23707. },
  23708. lastWeek : function () {
  23709. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  23710. },
  23711. sameElse : 'L'
  23712. },
  23713. relativeTime : {
  23714. future : 'en %s',
  23715. past : 'hace %s',
  23716. s : 'unos segundos',
  23717. m : 'un minuto',
  23718. mm : '%d minutos',
  23719. h : 'una hora',
  23720. hh : '%d horas',
  23721. d : 'un día',
  23722. dd : '%d días',
  23723. M : 'un mes',
  23724. MM : '%d meses',
  23725. y : 'un año',
  23726. yy : '%d años'
  23727. },
  23728. dayOfMonthOrdinalParse : /\d{1,2}º/,
  23729. ordinal : '%dº',
  23730. week : {
  23731. dow : 1, // Monday is the first day of the week.
  23732. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23733. }
  23734. });
  23735. //! moment.js locale configuration
  23736. //! locale : Estonian [et]
  23737. //! author : Henry Kehlmann : https://github.com/madhenry
  23738. //! improvements : Illimar Tambek : https://github.com/ragulka
  23739. function processRelativeTime$3(number, withoutSuffix, key, isFuture) {
  23740. var format = {
  23741. 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
  23742. 'm' : ['ühe minuti', 'üks minut'],
  23743. 'mm': [number + ' minuti', number + ' minutit'],
  23744. 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
  23745. 'hh': [number + ' tunni', number + ' tundi'],
  23746. 'd' : ['ühe päeva', 'üks päev'],
  23747. 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
  23748. 'MM': [number + ' kuu', number + ' kuud'],
  23749. 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
  23750. 'yy': [number + ' aasta', number + ' aastat']
  23751. };
  23752. if (withoutSuffix) {
  23753. return format[key][2] ? format[key][2] : format[key][1];
  23754. }
  23755. return isFuture ? format[key][0] : format[key][1];
  23756. }
  23757. hooks.defineLocale('et', {
  23758. months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
  23759. monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
  23760. weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
  23761. weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
  23762. weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
  23763. longDateFormat : {
  23764. LT : 'H:mm',
  23765. LTS : 'H:mm:ss',
  23766. L : 'DD.MM.YYYY',
  23767. LL : 'D. MMMM YYYY',
  23768. LLL : 'D. MMMM YYYY H:mm',
  23769. LLLL : 'dddd, D. MMMM YYYY H:mm'
  23770. },
  23771. calendar : {
  23772. sameDay : '[Täna,] LT',
  23773. nextDay : '[Homme,] LT',
  23774. nextWeek : '[Järgmine] dddd LT',
  23775. lastDay : '[Eile,] LT',
  23776. lastWeek : '[Eelmine] dddd LT',
  23777. sameElse : 'L'
  23778. },
  23779. relativeTime : {
  23780. future : '%s pärast',
  23781. past : '%s tagasi',
  23782. s : processRelativeTime$3,
  23783. m : processRelativeTime$3,
  23784. mm : processRelativeTime$3,
  23785. h : processRelativeTime$3,
  23786. hh : processRelativeTime$3,
  23787. d : processRelativeTime$3,
  23788. dd : '%d päeva',
  23789. M : processRelativeTime$3,
  23790. MM : processRelativeTime$3,
  23791. y : processRelativeTime$3,
  23792. yy : processRelativeTime$3
  23793. },
  23794. dayOfMonthOrdinalParse: /\d{1,2}\./,
  23795. ordinal : '%d.',
  23796. week : {
  23797. dow : 1, // Monday is the first day of the week.
  23798. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23799. }
  23800. });
  23801. //! moment.js locale configuration
  23802. //! locale : Basque [eu]
  23803. //! author : Eneko Illarramendi : https://github.com/eillarra
  23804. hooks.defineLocale('eu', {
  23805. months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
  23806. monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
  23807. monthsParseExact : true,
  23808. weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
  23809. weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
  23810. weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
  23811. weekdaysParseExact : true,
  23812. longDateFormat : {
  23813. LT : 'HH:mm',
  23814. LTS : 'HH:mm:ss',
  23815. L : 'YYYY-MM-DD',
  23816. LL : 'YYYY[ko] MMMM[ren] D[a]',
  23817. LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
  23818. LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
  23819. l : 'YYYY-M-D',
  23820. ll : 'YYYY[ko] MMM D[a]',
  23821. lll : 'YYYY[ko] MMM D[a] HH:mm',
  23822. llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
  23823. },
  23824. calendar : {
  23825. sameDay : '[gaur] LT[etan]',
  23826. nextDay : '[bihar] LT[etan]',
  23827. nextWeek : 'dddd LT[etan]',
  23828. lastDay : '[atzo] LT[etan]',
  23829. lastWeek : '[aurreko] dddd LT[etan]',
  23830. sameElse : 'L'
  23831. },
  23832. relativeTime : {
  23833. future : '%s barru',
  23834. past : 'duela %s',
  23835. s : 'segundo batzuk',
  23836. m : 'minutu bat',
  23837. mm : '%d minutu',
  23838. h : 'ordu bat',
  23839. hh : '%d ordu',
  23840. d : 'egun bat',
  23841. dd : '%d egun',
  23842. M : 'hilabete bat',
  23843. MM : '%d hilabete',
  23844. y : 'urte bat',
  23845. yy : '%d urte'
  23846. },
  23847. dayOfMonthOrdinalParse: /\d{1,2}\./,
  23848. ordinal : '%d.',
  23849. week : {
  23850. dow : 1, // Monday is the first day of the week.
  23851. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23852. }
  23853. });
  23854. //! moment.js locale configuration
  23855. //! locale : Persian [fa]
  23856. //! author : Ebrahim Byagowi : https://github.com/ebraminio
  23857. var symbolMap$5 = {
  23858. '1': '۱',
  23859. '2': '۲',
  23860. '3': '۳',
  23861. '4': '۴',
  23862. '5': '۵',
  23863. '6': '۶',
  23864. '7': '۷',
  23865. '8': '۸',
  23866. '9': '۹',
  23867. '0': '۰'
  23868. };
  23869. var numberMap$4 = {
  23870. '۱': '1',
  23871. '۲': '2',
  23872. '۳': '3',
  23873. '۴': '4',
  23874. '۵': '5',
  23875. '۶': '6',
  23876. '۷': '7',
  23877. '۸': '8',
  23878. '۹': '9',
  23879. '۰': '0'
  23880. };
  23881. hooks.defineLocale('fa', {
  23882. months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
  23883. monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
  23884. weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
  23885. weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
  23886. weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
  23887. weekdaysParseExact : true,
  23888. longDateFormat : {
  23889. LT : 'HH:mm',
  23890. LTS : 'HH:mm:ss',
  23891. L : 'DD/MM/YYYY',
  23892. LL : 'D MMMM YYYY',
  23893. LLL : 'D MMMM YYYY HH:mm',
  23894. LLLL : 'dddd, D MMMM YYYY HH:mm'
  23895. },
  23896. meridiemParse: /قبل از ظهر|بعد از ظهر/,
  23897. isPM: function (input) {
  23898. return /بعد از ظهر/.test(input);
  23899. },
  23900. meridiem : function (hour, minute, isLower) {
  23901. if (hour < 12) {
  23902. return 'قبل از ظهر';
  23903. } else {
  23904. return 'بعد از ظهر';
  23905. }
  23906. },
  23907. calendar : {
  23908. sameDay : '[امروز ساعت] LT',
  23909. nextDay : '[فردا ساعت] LT',
  23910. nextWeek : 'dddd [ساعت] LT',
  23911. lastDay : '[دیروز ساعت] LT',
  23912. lastWeek : 'dddd [پیش] [ساعت] LT',
  23913. sameElse : 'L'
  23914. },
  23915. relativeTime : {
  23916. future : 'در %s',
  23917. past : '%s پیش',
  23918. s : 'چند ثانیه',
  23919. m : 'یک دقیقه',
  23920. mm : '%d دقیقه',
  23921. h : 'یک ساعت',
  23922. hh : '%d ساعت',
  23923. d : 'یک روز',
  23924. dd : '%d روز',
  23925. M : 'یک ماه',
  23926. MM : '%d ماه',
  23927. y : 'یک سال',
  23928. yy : '%d سال'
  23929. },
  23930. preparse: function (string) {
  23931. return string.replace(/[۰-۹]/g, function (match) {
  23932. return numberMap$4[match];
  23933. }).replace(/،/g, ',');
  23934. },
  23935. postformat: function (string) {
  23936. return string.replace(/\d/g, function (match) {
  23937. return symbolMap$5[match];
  23938. }).replace(/,/g, '،');
  23939. },
  23940. dayOfMonthOrdinalParse: /\d{1,2}م/,
  23941. ordinal : '%dم',
  23942. week : {
  23943. dow : 6, // Saturday is the first day of the week.
  23944. doy : 12 // The week that contains Jan 1st is the first week of the year.
  23945. }
  23946. });
  23947. //! moment.js locale configuration
  23948. //! locale : Finnish [fi]
  23949. //! author : Tarmo Aidantausta : https://github.com/bleadof
  23950. var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' ');
  23951. var numbersFuture = [
  23952. 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
  23953. numbersPast[7], numbersPast[8], numbersPast[9]
  23954. ];
  23955. function translate$2(number, withoutSuffix, key, isFuture) {
  23956. var result = '';
  23957. switch (key) {
  23958. case 's':
  23959. return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
  23960. case 'm':
  23961. return isFuture ? 'minuutin' : 'minuutti';
  23962. case 'mm':
  23963. result = isFuture ? 'minuutin' : 'minuuttia';
  23964. break;
  23965. case 'h':
  23966. return isFuture ? 'tunnin' : 'tunti';
  23967. case 'hh':
  23968. result = isFuture ? 'tunnin' : 'tuntia';
  23969. break;
  23970. case 'd':
  23971. return isFuture ? 'päivän' : 'päivä';
  23972. case 'dd':
  23973. result = isFuture ? 'päivän' : 'päivää';
  23974. break;
  23975. case 'M':
  23976. return isFuture ? 'kuukauden' : 'kuukausi';
  23977. case 'MM':
  23978. result = isFuture ? 'kuukauden' : 'kuukautta';
  23979. break;
  23980. case 'y':
  23981. return isFuture ? 'vuoden' : 'vuosi';
  23982. case 'yy':
  23983. result = isFuture ? 'vuoden' : 'vuotta';
  23984. break;
  23985. }
  23986. result = verbalNumber(number, isFuture) + ' ' + result;
  23987. return result;
  23988. }
  23989. function verbalNumber(number, isFuture) {
  23990. return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
  23991. }
  23992. hooks.defineLocale('fi', {
  23993. months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
  23994. monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
  23995. weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
  23996. weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
  23997. weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
  23998. longDateFormat : {
  23999. LT : 'HH.mm',
  24000. LTS : 'HH.mm.ss',
  24001. L : 'DD.MM.YYYY',
  24002. LL : 'Do MMMM[ta] YYYY',
  24003. LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
  24004. LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
  24005. l : 'D.M.YYYY',
  24006. ll : 'Do MMM YYYY',
  24007. lll : 'Do MMM YYYY, [klo] HH.mm',
  24008. llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
  24009. },
  24010. calendar : {
  24011. sameDay : '[tänään] [klo] LT',
  24012. nextDay : '[huomenna] [klo] LT',
  24013. nextWeek : 'dddd [klo] LT',
  24014. lastDay : '[eilen] [klo] LT',
  24015. lastWeek : '[viime] dddd[na] [klo] LT',
  24016. sameElse : 'L'
  24017. },
  24018. relativeTime : {
  24019. future : '%s päästä',
  24020. past : '%s sitten',
  24021. s : translate$2,
  24022. m : translate$2,
  24023. mm : translate$2,
  24024. h : translate$2,
  24025. hh : translate$2,
  24026. d : translate$2,
  24027. dd : translate$2,
  24028. M : translate$2,
  24029. MM : translate$2,
  24030. y : translate$2,
  24031. yy : translate$2
  24032. },
  24033. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24034. ordinal : '%d.',
  24035. week : {
  24036. dow : 1, // Monday is the first day of the week.
  24037. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24038. }
  24039. });
  24040. //! moment.js locale configuration
  24041. //! locale : Faroese [fo]
  24042. //! author : Ragnar Johannesen : https://github.com/ragnar123
  24043. hooks.defineLocale('fo', {
  24044. months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  24045. monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
  24046. weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
  24047. weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
  24048. weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
  24049. longDateFormat : {
  24050. LT : 'HH:mm',
  24051. LTS : 'HH:mm:ss',
  24052. L : 'DD/MM/YYYY',
  24053. LL : 'D MMMM YYYY',
  24054. LLL : 'D MMMM YYYY HH:mm',
  24055. LLLL : 'dddd D. MMMM, YYYY HH:mm'
  24056. },
  24057. calendar : {
  24058. sameDay : '[Í dag kl.] LT',
  24059. nextDay : '[Í morgin kl.] LT',
  24060. nextWeek : 'dddd [kl.] LT',
  24061. lastDay : '[Í gjár kl.] LT',
  24062. lastWeek : '[síðstu] dddd [kl] LT',
  24063. sameElse : 'L'
  24064. },
  24065. relativeTime : {
  24066. future : 'um %s',
  24067. past : '%s síðani',
  24068. s : 'fá sekund',
  24069. m : 'ein minutt',
  24070. mm : '%d minuttir',
  24071. h : 'ein tími',
  24072. hh : '%d tímar',
  24073. d : 'ein dagur',
  24074. dd : '%d dagar',
  24075. M : 'ein mánaði',
  24076. MM : '%d mánaðir',
  24077. y : 'eitt ár',
  24078. yy : '%d ár'
  24079. },
  24080. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24081. ordinal : '%d.',
  24082. week : {
  24083. dow : 1, // Monday is the first day of the week.
  24084. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24085. }
  24086. });
  24087. //! moment.js locale configuration
  24088. //! locale : French (Canada) [fr-ca]
  24089. //! author : Jonathan Abourbih : https://github.com/jonbca
  24090. hooks.defineLocale('fr-ca', {
  24091. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  24092. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  24093. monthsParseExact : true,
  24094. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  24095. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  24096. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  24097. weekdaysParseExact : true,
  24098. longDateFormat : {
  24099. LT : 'HH:mm',
  24100. LTS : 'HH:mm:ss',
  24101. L : 'YYYY-MM-DD',
  24102. LL : 'D MMMM YYYY',
  24103. LLL : 'D MMMM YYYY HH:mm',
  24104. LLLL : 'dddd D MMMM YYYY HH:mm'
  24105. },
  24106. calendar : {
  24107. sameDay : '[Aujourd’hui à] LT',
  24108. nextDay : '[Demain à] LT',
  24109. nextWeek : 'dddd [à] LT',
  24110. lastDay : '[Hier à] LT',
  24111. lastWeek : 'dddd [dernier à] LT',
  24112. sameElse : 'L'
  24113. },
  24114. relativeTime : {
  24115. future : 'dans %s',
  24116. past : 'il y a %s',
  24117. s : 'quelques secondes',
  24118. m : 'une minute',
  24119. mm : '%d minutes',
  24120. h : 'une heure',
  24121. hh : '%d heures',
  24122. d : 'un jour',
  24123. dd : '%d jours',
  24124. M : 'un mois',
  24125. MM : '%d mois',
  24126. y : 'un an',
  24127. yy : '%d ans'
  24128. },
  24129. dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
  24130. ordinal : function (number, period) {
  24131. switch (period) {
  24132. // Words with masculine grammatical gender: mois, trimestre, jour
  24133. default:
  24134. case 'M':
  24135. case 'Q':
  24136. case 'D':
  24137. case 'DDD':
  24138. case 'd':
  24139. return number + (number === 1 ? 'er' : 'e');
  24140. // Words with feminine grammatical gender: semaine
  24141. case 'w':
  24142. case 'W':
  24143. return number + (number === 1 ? 're' : 'e');
  24144. }
  24145. }
  24146. });
  24147. //! moment.js locale configuration
  24148. //! locale : French (Switzerland) [fr-ch]
  24149. //! author : Gaspard Bucher : https://github.com/gaspard
  24150. hooks.defineLocale('fr-ch', {
  24151. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  24152. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  24153. monthsParseExact : true,
  24154. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  24155. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  24156. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  24157. weekdaysParseExact : true,
  24158. longDateFormat : {
  24159. LT : 'HH:mm',
  24160. LTS : 'HH:mm:ss',
  24161. L : 'DD.MM.YYYY',
  24162. LL : 'D MMMM YYYY',
  24163. LLL : 'D MMMM YYYY HH:mm',
  24164. LLLL : 'dddd D MMMM YYYY HH:mm'
  24165. },
  24166. calendar : {
  24167. sameDay : '[Aujourd’hui à] LT',
  24168. nextDay : '[Demain à] LT',
  24169. nextWeek : 'dddd [à] LT',
  24170. lastDay : '[Hier à] LT',
  24171. lastWeek : 'dddd [dernier à] LT',
  24172. sameElse : 'L'
  24173. },
  24174. relativeTime : {
  24175. future : 'dans %s',
  24176. past : 'il y a %s',
  24177. s : 'quelques secondes',
  24178. m : 'une minute',
  24179. mm : '%d minutes',
  24180. h : 'une heure',
  24181. hh : '%d heures',
  24182. d : 'un jour',
  24183. dd : '%d jours',
  24184. M : 'un mois',
  24185. MM : '%d mois',
  24186. y : 'un an',
  24187. yy : '%d ans'
  24188. },
  24189. dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
  24190. ordinal : function (number, period) {
  24191. switch (period) {
  24192. // Words with masculine grammatical gender: mois, trimestre, jour
  24193. default:
  24194. case 'M':
  24195. case 'Q':
  24196. case 'D':
  24197. case 'DDD':
  24198. case 'd':
  24199. return number + (number === 1 ? 'er' : 'e');
  24200. // Words with feminine grammatical gender: semaine
  24201. case 'w':
  24202. case 'W':
  24203. return number + (number === 1 ? 're' : 'e');
  24204. }
  24205. },
  24206. week : {
  24207. dow : 1, // Monday is the first day of the week.
  24208. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24209. }
  24210. });
  24211. //! moment.js locale configuration
  24212. //! locale : French [fr]
  24213. //! author : John Fischer : https://github.com/jfroffice
  24214. hooks.defineLocale('fr', {
  24215. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  24216. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  24217. monthsParseExact : true,
  24218. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  24219. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  24220. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  24221. weekdaysParseExact : true,
  24222. longDateFormat : {
  24223. LT : 'HH:mm',
  24224. LTS : 'HH:mm:ss',
  24225. L : 'DD/MM/YYYY',
  24226. LL : 'D MMMM YYYY',
  24227. LLL : 'D MMMM YYYY HH:mm',
  24228. LLLL : 'dddd D MMMM YYYY HH:mm'
  24229. },
  24230. calendar : {
  24231. sameDay : '[Aujourd’hui à] LT',
  24232. nextDay : '[Demain à] LT',
  24233. nextWeek : 'dddd [à] LT',
  24234. lastDay : '[Hier à] LT',
  24235. lastWeek : 'dddd [dernier à] LT',
  24236. sameElse : 'L'
  24237. },
  24238. relativeTime : {
  24239. future : 'dans %s',
  24240. past : 'il y a %s',
  24241. s : 'quelques secondes',
  24242. m : 'une minute',
  24243. mm : '%d minutes',
  24244. h : 'une heure',
  24245. hh : '%d heures',
  24246. d : 'un jour',
  24247. dd : '%d jours',
  24248. M : 'un mois',
  24249. MM : '%d mois',
  24250. y : 'un an',
  24251. yy : '%d ans'
  24252. },
  24253. dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
  24254. ordinal : function (number, period) {
  24255. switch (period) {
  24256. // TODO: Return 'e' when day of month > 1. Move this case inside
  24257. // block for masculine words below.
  24258. // See https://github.com/moment/moment/issues/3375
  24259. case 'D':
  24260. return number + (number === 1 ? 'er' : '');
  24261. // Words with masculine grammatical gender: mois, trimestre, jour
  24262. default:
  24263. case 'M':
  24264. case 'Q':
  24265. case 'DDD':
  24266. case 'd':
  24267. return number + (number === 1 ? 'er' : 'e');
  24268. // Words with feminine grammatical gender: semaine
  24269. case 'w':
  24270. case 'W':
  24271. return number + (number === 1 ? 're' : 'e');
  24272. }
  24273. },
  24274. week : {
  24275. dow : 1, // Monday is the first day of the week.
  24276. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24277. }
  24278. });
  24279. //! moment.js locale configuration
  24280. //! locale : Frisian [fy]
  24281. //! author : Robin van der Vliet : https://github.com/robin0van0der0v
  24282. var monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_');
  24283. var monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
  24284. hooks.defineLocale('fy', {
  24285. months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
  24286. monthsShort : function (m, format) {
  24287. if (!m) {
  24288. return monthsShortWithDots;
  24289. } else if (/-MMM-/.test(format)) {
  24290. return monthsShortWithoutDots[m.month()];
  24291. } else {
  24292. return monthsShortWithDots[m.month()];
  24293. }
  24294. },
  24295. monthsParseExact : true,
  24296. weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
  24297. weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
  24298. weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
  24299. weekdaysParseExact : true,
  24300. longDateFormat : {
  24301. LT : 'HH:mm',
  24302. LTS : 'HH:mm:ss',
  24303. L : 'DD-MM-YYYY',
  24304. LL : 'D MMMM YYYY',
  24305. LLL : 'D MMMM YYYY HH:mm',
  24306. LLLL : 'dddd D MMMM YYYY HH:mm'
  24307. },
  24308. calendar : {
  24309. sameDay: '[hjoed om] LT',
  24310. nextDay: '[moarn om] LT',
  24311. nextWeek: 'dddd [om] LT',
  24312. lastDay: '[juster om] LT',
  24313. lastWeek: '[ôfrûne] dddd [om] LT',
  24314. sameElse: 'L'
  24315. },
  24316. relativeTime : {
  24317. future : 'oer %s',
  24318. past : '%s lyn',
  24319. s : 'in pear sekonden',
  24320. m : 'ien minút',
  24321. mm : '%d minuten',
  24322. h : 'ien oere',
  24323. hh : '%d oeren',
  24324. d : 'ien dei',
  24325. dd : '%d dagen',
  24326. M : 'ien moanne',
  24327. MM : '%d moannen',
  24328. y : 'ien jier',
  24329. yy : '%d jierren'
  24330. },
  24331. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  24332. ordinal : function (number) {
  24333. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  24334. },
  24335. week : {
  24336. dow : 1, // Monday is the first day of the week.
  24337. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24338. }
  24339. });
  24340. //! moment.js locale configuration
  24341. //! locale : Scottish Gaelic [gd]
  24342. //! author : Jon Ashdown : https://github.com/jonashdown
  24343. var months$5 = [
  24344. 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
  24345. ];
  24346. var monthsShort$4 = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
  24347. var weekdays$1 = ['Didòmhnaich', 'Diluain', 'Dimàirt', 'Diciadain', 'Diardaoin', 'Dihaoine', 'Disathairne'];
  24348. var weekdaysShort = ['Did', 'Dil', 'Dim', 'Dic', 'Dia', 'Dih', 'Dis'];
  24349. var weekdaysMin = ['Dò', 'Lu', 'Mà', 'Ci', 'Ar', 'Ha', 'Sa'];
  24350. hooks.defineLocale('gd', {
  24351. months : months$5,
  24352. monthsShort : monthsShort$4,
  24353. monthsParseExact : true,
  24354. weekdays : weekdays$1,
  24355. weekdaysShort : weekdaysShort,
  24356. weekdaysMin : weekdaysMin,
  24357. longDateFormat : {
  24358. LT : 'HH:mm',
  24359. LTS : 'HH:mm:ss',
  24360. L : 'DD/MM/YYYY',
  24361. LL : 'D MMMM YYYY',
  24362. LLL : 'D MMMM YYYY HH:mm',
  24363. LLLL : 'dddd, D MMMM YYYY HH:mm'
  24364. },
  24365. calendar : {
  24366. sameDay : '[An-diugh aig] LT',
  24367. nextDay : '[A-màireach aig] LT',
  24368. nextWeek : 'dddd [aig] LT',
  24369. lastDay : '[An-dè aig] LT',
  24370. lastWeek : 'dddd [seo chaidh] [aig] LT',
  24371. sameElse : 'L'
  24372. },
  24373. relativeTime : {
  24374. future : 'ann an %s',
  24375. past : 'bho chionn %s',
  24376. s : 'beagan diogan',
  24377. m : 'mionaid',
  24378. mm : '%d mionaidean',
  24379. h : 'uair',
  24380. hh : '%d uairean',
  24381. d : 'latha',
  24382. dd : '%d latha',
  24383. M : 'mìos',
  24384. MM : '%d mìosan',
  24385. y : 'bliadhna',
  24386. yy : '%d bliadhna'
  24387. },
  24388. dayOfMonthOrdinalParse : /\d{1,2}(d|na|mh)/,
  24389. ordinal : function (number) {
  24390. var output = number === 1 ? 'd' : number % 10 === 2 ? 'na' : 'mh';
  24391. return number + output;
  24392. },
  24393. week : {
  24394. dow : 1, // Monday is the first day of the week.
  24395. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24396. }
  24397. });
  24398. //! moment.js locale configuration
  24399. //! locale : Galician [gl]
  24400. //! author : Juan G. Hurtado : https://github.com/juanghurtado
  24401. hooks.defineLocale('gl', {
  24402. months : 'xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro'.split('_'),
  24403. monthsShort : 'xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.'.split('_'),
  24404. monthsParseExact: true,
  24405. weekdays : 'domingo_luns_martes_mércores_xoves_venres_sábado'.split('_'),
  24406. weekdaysShort : 'dom._lun._mar._mér._xov._ven._sáb.'.split('_'),
  24407. weekdaysMin : 'do_lu_ma_mé_xo_ve_sá'.split('_'),
  24408. weekdaysParseExact : true,
  24409. longDateFormat : {
  24410. LT : 'H:mm',
  24411. LTS : 'H:mm:ss',
  24412. L : 'DD/MM/YYYY',
  24413. LL : 'D [de] MMMM [de] YYYY',
  24414. LLL : 'D [de] MMMM [de] YYYY H:mm',
  24415. LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
  24416. },
  24417. calendar : {
  24418. sameDay : function () {
  24419. return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
  24420. },
  24421. nextDay : function () {
  24422. return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
  24423. },
  24424. nextWeek : function () {
  24425. return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
  24426. },
  24427. lastDay : function () {
  24428. return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
  24429. },
  24430. lastWeek : function () {
  24431. return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
  24432. },
  24433. sameElse : 'L'
  24434. },
  24435. relativeTime : {
  24436. future : function (str) {
  24437. if (str.indexOf('un') === 0) {
  24438. return 'n' + str;
  24439. }
  24440. return 'en ' + str;
  24441. },
  24442. past : 'hai %s',
  24443. s : 'uns segundos',
  24444. m : 'un minuto',
  24445. mm : '%d minutos',
  24446. h : 'unha hora',
  24447. hh : '%d horas',
  24448. d : 'un día',
  24449. dd : '%d días',
  24450. M : 'un mes',
  24451. MM : '%d meses',
  24452. y : 'un ano',
  24453. yy : '%d anos'
  24454. },
  24455. dayOfMonthOrdinalParse : /\d{1,2}º/,
  24456. ordinal : '%dº',
  24457. week : {
  24458. dow : 1, // Monday is the first day of the week.
  24459. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24460. }
  24461. });
  24462. //! moment.js locale configuration
  24463. //! locale : Konkani Latin script [gom-latn]
  24464. //! author : The Discoverer : https://github.com/WikiDiscoverer
  24465. function processRelativeTime$4(number, withoutSuffix, key, isFuture) {
  24466. var format = {
  24467. 's': ['thodde secondanim', 'thodde second'],
  24468. 'm': ['eka mintan', 'ek minute'],
  24469. 'mm': [number + ' mintanim', number + ' mintam'],
  24470. 'h': ['eka horan', 'ek hor'],
  24471. 'hh': [number + ' horanim', number + ' hor'],
  24472. 'd': ['eka disan', 'ek dis'],
  24473. 'dd': [number + ' disanim', number + ' dis'],
  24474. 'M': ['eka mhoinean', 'ek mhoino'],
  24475. 'MM': [number + ' mhoineanim', number + ' mhoine'],
  24476. 'y': ['eka vorsan', 'ek voros'],
  24477. 'yy': [number + ' vorsanim', number + ' vorsam']
  24478. };
  24479. return withoutSuffix ? format[key][0] : format[key][1];
  24480. }
  24481. hooks.defineLocale('gom-latn', {
  24482. months : 'Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr'.split('_'),
  24483. monthsShort : 'Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.'.split('_'),
  24484. monthsParseExact : true,
  24485. weekdays : 'Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son\'var'.split('_'),
  24486. weekdaysShort : 'Ait._Som._Mon._Bud._Bre._Suk._Son.'.split('_'),
  24487. weekdaysMin : 'Ai_Sm_Mo_Bu_Br_Su_Sn'.split('_'),
  24488. weekdaysParseExact : true,
  24489. longDateFormat : {
  24490. LT : 'A h:mm [vazta]',
  24491. LTS : 'A h:mm:ss [vazta]',
  24492. L : 'DD-MM-YYYY',
  24493. LL : 'D MMMM YYYY',
  24494. LLL : 'D MMMM YYYY A h:mm [vazta]',
  24495. LLLL : 'dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]',
  24496. llll: 'ddd, D MMM YYYY, A h:mm [vazta]'
  24497. },
  24498. calendar : {
  24499. sameDay: '[Aiz] LT',
  24500. nextDay: '[Faleam] LT',
  24501. nextWeek: '[Ieta to] dddd[,] LT',
  24502. lastDay: '[Kal] LT',
  24503. lastWeek: '[Fatlo] dddd[,] LT',
  24504. sameElse: 'L'
  24505. },
  24506. relativeTime : {
  24507. future : '%s',
  24508. past : '%s adim',
  24509. s : processRelativeTime$4,
  24510. m : processRelativeTime$4,
  24511. mm : processRelativeTime$4,
  24512. h : processRelativeTime$4,
  24513. hh : processRelativeTime$4,
  24514. d : processRelativeTime$4,
  24515. dd : processRelativeTime$4,
  24516. M : processRelativeTime$4,
  24517. MM : processRelativeTime$4,
  24518. y : processRelativeTime$4,
  24519. yy : processRelativeTime$4
  24520. },
  24521. dayOfMonthOrdinalParse : /\d{1,2}(er)/,
  24522. ordinal : function (number, period) {
  24523. switch (period) {
  24524. // the ordinal 'er' only applies to day of the month
  24525. case 'D':
  24526. return number + 'er';
  24527. default:
  24528. case 'M':
  24529. case 'Q':
  24530. case 'DDD':
  24531. case 'd':
  24532. case 'w':
  24533. case 'W':
  24534. return number;
  24535. }
  24536. },
  24537. week : {
  24538. dow : 1, // Monday is the first day of the week.
  24539. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24540. },
  24541. meridiemParse: /rati|sokalli|donparam|sanje/,
  24542. meridiemHour : function (hour, meridiem) {
  24543. if (hour === 12) {
  24544. hour = 0;
  24545. }
  24546. if (meridiem === 'rati') {
  24547. return hour < 4 ? hour : hour + 12;
  24548. } else if (meridiem === 'sokalli') {
  24549. return hour;
  24550. } else if (meridiem === 'donparam') {
  24551. return hour > 12 ? hour : hour + 12;
  24552. } else if (meridiem === 'sanje') {
  24553. return hour + 12;
  24554. }
  24555. },
  24556. meridiem : function (hour, minute, isLower) {
  24557. if (hour < 4) {
  24558. return 'rati';
  24559. } else if (hour < 12) {
  24560. return 'sokalli';
  24561. } else if (hour < 16) {
  24562. return 'donparam';
  24563. } else if (hour < 20) {
  24564. return 'sanje';
  24565. } else {
  24566. return 'rati';
  24567. }
  24568. }
  24569. });
  24570. //! moment.js locale configuration
  24571. //! locale : Gujarati [gu]
  24572. //! author : Kaushik Thanki : https://github.com/Kaushik1987
  24573. var symbolMap$6 = {
  24574. '1': '૧',
  24575. '2': '૨',
  24576. '3': '૩',
  24577. '4': '૪',
  24578. '5': '૫',
  24579. '6': '૬',
  24580. '7': '૭',
  24581. '8': '૮',
  24582. '9': '૯',
  24583. '0': '૦'
  24584. };
  24585. var numberMap$5 = {
  24586. '૧': '1',
  24587. '૨': '2',
  24588. '૩': '3',
  24589. '૪': '4',
  24590. '૫': '5',
  24591. '૬': '6',
  24592. '૭': '7',
  24593. '૮': '8',
  24594. '૯': '9',
  24595. '૦': '0'
  24596. };
  24597. hooks.defineLocale('gu', {
  24598. months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split('_'),
  24599. monthsShort: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split('_'),
  24600. monthsParseExact: true,
  24601. weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split('_'),
  24602. weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'),
  24603. weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'),
  24604. longDateFormat: {
  24605. LT: 'A h:mm વાગ્યે',
  24606. LTS: 'A h:mm:ss વાગ્યે',
  24607. L: 'DD/MM/YYYY',
  24608. LL: 'D MMMM YYYY',
  24609. LLL: 'D MMMM YYYY, A h:mm વાગ્યે',
  24610. LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે'
  24611. },
  24612. calendar: {
  24613. sameDay: '[આજ] LT',
  24614. nextDay: '[કાલે] LT',
  24615. nextWeek: 'dddd, LT',
  24616. lastDay: '[ગઇકાલે] LT',
  24617. lastWeek: '[પાછલા] dddd, LT',
  24618. sameElse: 'L'
  24619. },
  24620. relativeTime: {
  24621. future: '%s મા',
  24622. past: '%s પેહલા',
  24623. s: 'અમુક પળો',
  24624. m: 'એક મિનિટ',
  24625. mm: '%d મિનિટ',
  24626. h: 'એક કલાક',
  24627. hh: '%d કલાક',
  24628. d: 'એક દિવસ',
  24629. dd: '%d દિવસ',
  24630. M: 'એક મહિનો',
  24631. MM: '%d મહિનો',
  24632. y: 'એક વર્ષ',
  24633. yy: '%d વર્ષ'
  24634. },
  24635. preparse: function (string) {
  24636. return string.replace(/[૧૨૩૪૫૬૭૮૯૦]/g, function (match) {
  24637. return numberMap$5[match];
  24638. });
  24639. },
  24640. postformat: function (string) {
  24641. return string.replace(/\d/g, function (match) {
  24642. return symbolMap$6[match];
  24643. });
  24644. },
  24645. // Gujarati notation for meridiems are quite fuzzy in practice. While there exists
  24646. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Gujarati.
  24647. meridiemParse: /રાત|બપોર|સવાર|સાંજ/,
  24648. meridiemHour: function (hour, meridiem) {
  24649. if (hour === 12) {
  24650. hour = 0;
  24651. }
  24652. if (meridiem === 'રાત') {
  24653. return hour < 4 ? hour : hour + 12;
  24654. } else if (meridiem === 'સવાર') {
  24655. return hour;
  24656. } else if (meridiem === 'બપોર') {
  24657. return hour >= 10 ? hour : hour + 12;
  24658. } else if (meridiem === 'સાંજ') {
  24659. return hour + 12;
  24660. }
  24661. },
  24662. meridiem: function (hour, minute, isLower) {
  24663. if (hour < 4) {
  24664. return 'રાત';
  24665. } else if (hour < 10) {
  24666. return 'સવાર';
  24667. } else if (hour < 17) {
  24668. return 'બપોર';
  24669. } else if (hour < 20) {
  24670. return 'સાંજ';
  24671. } else {
  24672. return 'રાત';
  24673. }
  24674. },
  24675. week: {
  24676. dow: 0, // Sunday is the first day of the week.
  24677. doy: 6 // The week that contains Jan 1st is the first week of the year.
  24678. }
  24679. });
  24680. //! moment.js locale configuration
  24681. //! locale : Hebrew [he]
  24682. //! author : Tomer Cohen : https://github.com/tomer
  24683. //! author : Moshe Simantov : https://github.com/DevelopmentIL
  24684. //! author : Tal Ater : https://github.com/TalAter
  24685. hooks.defineLocale('he', {
  24686. months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
  24687. monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
  24688. weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
  24689. weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
  24690. weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
  24691. longDateFormat : {
  24692. LT : 'HH:mm',
  24693. LTS : 'HH:mm:ss',
  24694. L : 'DD/MM/YYYY',
  24695. LL : 'D [ב]MMMM YYYY',
  24696. LLL : 'D [ב]MMMM YYYY HH:mm',
  24697. LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
  24698. l : 'D/M/YYYY',
  24699. ll : 'D MMM YYYY',
  24700. lll : 'D MMM YYYY HH:mm',
  24701. llll : 'ddd, D MMM YYYY HH:mm'
  24702. },
  24703. calendar : {
  24704. sameDay : '[היום ב־]LT',
  24705. nextDay : '[מחר ב־]LT',
  24706. nextWeek : 'dddd [בשעה] LT',
  24707. lastDay : '[אתמול ב־]LT',
  24708. lastWeek : '[ביום] dddd [האחרון בשעה] LT',
  24709. sameElse : 'L'
  24710. },
  24711. relativeTime : {
  24712. future : 'בעוד %s',
  24713. past : 'לפני %s',
  24714. s : 'מספר שניות',
  24715. m : 'דקה',
  24716. mm : '%d דקות',
  24717. h : 'שעה',
  24718. hh : function (number) {
  24719. if (number === 2) {
  24720. return 'שעתיים';
  24721. }
  24722. return number + ' שעות';
  24723. },
  24724. d : 'יום',
  24725. dd : function (number) {
  24726. if (number === 2) {
  24727. return 'יומיים';
  24728. }
  24729. return number + ' ימים';
  24730. },
  24731. M : 'חודש',
  24732. MM : function (number) {
  24733. if (number === 2) {
  24734. return 'חודשיים';
  24735. }
  24736. return number + ' חודשים';
  24737. },
  24738. y : 'שנה',
  24739. yy : function (number) {
  24740. if (number === 2) {
  24741. return 'שנתיים';
  24742. } else if (number % 10 === 0 && number !== 10) {
  24743. return number + ' שנה';
  24744. }
  24745. return number + ' שנים';
  24746. }
  24747. },
  24748. meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
  24749. isPM : function (input) {
  24750. return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
  24751. },
  24752. meridiem : function (hour, minute, isLower) {
  24753. if (hour < 5) {
  24754. return 'לפנות בוקר';
  24755. } else if (hour < 10) {
  24756. return 'בבוקר';
  24757. } else if (hour < 12) {
  24758. return isLower ? 'לפנה"צ' : 'לפני הצהריים';
  24759. } else if (hour < 18) {
  24760. return isLower ? 'אחה"צ' : 'אחרי הצהריים';
  24761. } else {
  24762. return 'בערב';
  24763. }
  24764. }
  24765. });
  24766. //! moment.js locale configuration
  24767. //! locale : Hindi [hi]
  24768. //! author : Mayank Singhal : https://github.com/mayanksinghal
  24769. var symbolMap$7 = {
  24770. '1': '१',
  24771. '2': '२',
  24772. '3': '३',
  24773. '4': '४',
  24774. '5': '५',
  24775. '6': '६',
  24776. '7': '७',
  24777. '8': '८',
  24778. '9': '९',
  24779. '0': '०'
  24780. };
  24781. var numberMap$6 = {
  24782. '१': '1',
  24783. '२': '2',
  24784. '३': '3',
  24785. '४': '4',
  24786. '५': '5',
  24787. '६': '6',
  24788. '७': '7',
  24789. '८': '8',
  24790. '९': '9',
  24791. '०': '0'
  24792. };
  24793. hooks.defineLocale('hi', {
  24794. months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
  24795. monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
  24796. monthsParseExact: true,
  24797. weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
  24798. weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
  24799. weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
  24800. longDateFormat : {
  24801. LT : 'A h:mm बजे',
  24802. LTS : 'A h:mm:ss बजे',
  24803. L : 'DD/MM/YYYY',
  24804. LL : 'D MMMM YYYY',
  24805. LLL : 'D MMMM YYYY, A h:mm बजे',
  24806. LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
  24807. },
  24808. calendar : {
  24809. sameDay : '[आज] LT',
  24810. nextDay : '[कल] LT',
  24811. nextWeek : 'dddd, LT',
  24812. lastDay : '[कल] LT',
  24813. lastWeek : '[पिछले] dddd, LT',
  24814. sameElse : 'L'
  24815. },
  24816. relativeTime : {
  24817. future : '%s में',
  24818. past : '%s पहले',
  24819. s : 'कुछ ही क्षण',
  24820. m : 'एक मिनट',
  24821. mm : '%d मिनट',
  24822. h : 'एक घंटा',
  24823. hh : '%d घंटे',
  24824. d : 'एक दिन',
  24825. dd : '%d दिन',
  24826. M : 'एक महीने',
  24827. MM : '%d महीने',
  24828. y : 'एक वर्ष',
  24829. yy : '%d वर्ष'
  24830. },
  24831. preparse: function (string) {
  24832. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  24833. return numberMap$6[match];
  24834. });
  24835. },
  24836. postformat: function (string) {
  24837. return string.replace(/\d/g, function (match) {
  24838. return symbolMap$7[match];
  24839. });
  24840. },
  24841. // Hindi notation for meridiems are quite fuzzy in practice. While there exists
  24842. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
  24843. meridiemParse: /रात|सुबह|दोपहर|शाम/,
  24844. meridiemHour : function (hour, meridiem) {
  24845. if (hour === 12) {
  24846. hour = 0;
  24847. }
  24848. if (meridiem === 'रात') {
  24849. return hour < 4 ? hour : hour + 12;
  24850. } else if (meridiem === 'सुबह') {
  24851. return hour;
  24852. } else if (meridiem === 'दोपहर') {
  24853. return hour >= 10 ? hour : hour + 12;
  24854. } else if (meridiem === 'शाम') {
  24855. return hour + 12;
  24856. }
  24857. },
  24858. meridiem : function (hour, minute, isLower) {
  24859. if (hour < 4) {
  24860. return 'रात';
  24861. } else if (hour < 10) {
  24862. return 'सुबह';
  24863. } else if (hour < 17) {
  24864. return 'दोपहर';
  24865. } else if (hour < 20) {
  24866. return 'शाम';
  24867. } else {
  24868. return 'रात';
  24869. }
  24870. },
  24871. week : {
  24872. dow : 0, // Sunday is the first day of the week.
  24873. doy : 6 // The week that contains Jan 1st is the first week of the year.
  24874. }
  24875. });
  24876. //! moment.js locale configuration
  24877. //! locale : Croatian [hr]
  24878. //! author : Bojan Marković : https://github.com/bmarkovic
  24879. function translate$3(number, withoutSuffix, key) {
  24880. var result = number + ' ';
  24881. switch (key) {
  24882. case 'm':
  24883. return withoutSuffix ? 'jedna minuta' : 'jedne minute';
  24884. case 'mm':
  24885. if (number === 1) {
  24886. result += 'minuta';
  24887. } else if (number === 2 || number === 3 || number === 4) {
  24888. result += 'minute';
  24889. } else {
  24890. result += 'minuta';
  24891. }
  24892. return result;
  24893. case 'h':
  24894. return withoutSuffix ? 'jedan sat' : 'jednog sata';
  24895. case 'hh':
  24896. if (number === 1) {
  24897. result += 'sat';
  24898. } else if (number === 2 || number === 3 || number === 4) {
  24899. result += 'sata';
  24900. } else {
  24901. result += 'sati';
  24902. }
  24903. return result;
  24904. case 'dd':
  24905. if (number === 1) {
  24906. result += 'dan';
  24907. } else {
  24908. result += 'dana';
  24909. }
  24910. return result;
  24911. case 'MM':
  24912. if (number === 1) {
  24913. result += 'mjesec';
  24914. } else if (number === 2 || number === 3 || number === 4) {
  24915. result += 'mjeseca';
  24916. } else {
  24917. result += 'mjeseci';
  24918. }
  24919. return result;
  24920. case 'yy':
  24921. if (number === 1) {
  24922. result += 'godina';
  24923. } else if (number === 2 || number === 3 || number === 4) {
  24924. result += 'godine';
  24925. } else {
  24926. result += 'godina';
  24927. }
  24928. return result;
  24929. }
  24930. }
  24931. hooks.defineLocale('hr', {
  24932. months : {
  24933. format: 'siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca'.split('_'),
  24934. standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
  24935. },
  24936. monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
  24937. monthsParseExact: true,
  24938. weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  24939. weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  24940. weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
  24941. weekdaysParseExact : true,
  24942. longDateFormat : {
  24943. LT : 'H:mm',
  24944. LTS : 'H:mm:ss',
  24945. L : 'DD.MM.YYYY',
  24946. LL : 'D. MMMM YYYY',
  24947. LLL : 'D. MMMM YYYY H:mm',
  24948. LLLL : 'dddd, D. MMMM YYYY H:mm'
  24949. },
  24950. calendar : {
  24951. sameDay : '[danas u] LT',
  24952. nextDay : '[sutra u] LT',
  24953. nextWeek : function () {
  24954. switch (this.day()) {
  24955. case 0:
  24956. return '[u] [nedjelju] [u] LT';
  24957. case 3:
  24958. return '[u] [srijedu] [u] LT';
  24959. case 6:
  24960. return '[u] [subotu] [u] LT';
  24961. case 1:
  24962. case 2:
  24963. case 4:
  24964. case 5:
  24965. return '[u] dddd [u] LT';
  24966. }
  24967. },
  24968. lastDay : '[jučer u] LT',
  24969. lastWeek : function () {
  24970. switch (this.day()) {
  24971. case 0:
  24972. case 3:
  24973. return '[prošlu] dddd [u] LT';
  24974. case 6:
  24975. return '[prošle] [subote] [u] LT';
  24976. case 1:
  24977. case 2:
  24978. case 4:
  24979. case 5:
  24980. return '[prošli] dddd [u] LT';
  24981. }
  24982. },
  24983. sameElse : 'L'
  24984. },
  24985. relativeTime : {
  24986. future : 'za %s',
  24987. past : 'prije %s',
  24988. s : 'par sekundi',
  24989. m : translate$3,
  24990. mm : translate$3,
  24991. h : translate$3,
  24992. hh : translate$3,
  24993. d : 'dan',
  24994. dd : translate$3,
  24995. M : 'mjesec',
  24996. MM : translate$3,
  24997. y : 'godinu',
  24998. yy : translate$3
  24999. },
  25000. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25001. ordinal : '%d.',
  25002. week : {
  25003. dow : 1, // Monday is the first day of the week.
  25004. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25005. }
  25006. });
  25007. //! moment.js locale configuration
  25008. //! locale : Hungarian [hu]
  25009. //! author : Adam Brunner : https://github.com/adambrunner
  25010. var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
  25011. function translate$4(number, withoutSuffix, key, isFuture) {
  25012. var num = number;
  25013. switch (key) {
  25014. case 's':
  25015. return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
  25016. case 'm':
  25017. return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
  25018. case 'mm':
  25019. return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
  25020. case 'h':
  25021. return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
  25022. case 'hh':
  25023. return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
  25024. case 'd':
  25025. return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
  25026. case 'dd':
  25027. return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
  25028. case 'M':
  25029. return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
  25030. case 'MM':
  25031. return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
  25032. case 'y':
  25033. return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
  25034. case 'yy':
  25035. return num + (isFuture || withoutSuffix ? ' év' : ' éve');
  25036. }
  25037. return '';
  25038. }
  25039. function week(isFuture) {
  25040. return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
  25041. }
  25042. hooks.defineLocale('hu', {
  25043. months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
  25044. monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
  25045. weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
  25046. weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
  25047. weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
  25048. longDateFormat : {
  25049. LT : 'H:mm',
  25050. LTS : 'H:mm:ss',
  25051. L : 'YYYY.MM.DD.',
  25052. LL : 'YYYY. MMMM D.',
  25053. LLL : 'YYYY. MMMM D. H:mm',
  25054. LLLL : 'YYYY. MMMM D., dddd H:mm'
  25055. },
  25056. meridiemParse: /de|du/i,
  25057. isPM: function (input) {
  25058. return input.charAt(1).toLowerCase() === 'u';
  25059. },
  25060. meridiem : function (hours, minutes, isLower) {
  25061. if (hours < 12) {
  25062. return isLower === true ? 'de' : 'DE';
  25063. } else {
  25064. return isLower === true ? 'du' : 'DU';
  25065. }
  25066. },
  25067. calendar : {
  25068. sameDay : '[ma] LT[-kor]',
  25069. nextDay : '[holnap] LT[-kor]',
  25070. nextWeek : function () {
  25071. return week.call(this, true);
  25072. },
  25073. lastDay : '[tegnap] LT[-kor]',
  25074. lastWeek : function () {
  25075. return week.call(this, false);
  25076. },
  25077. sameElse : 'L'
  25078. },
  25079. relativeTime : {
  25080. future : '%s múlva',
  25081. past : '%s',
  25082. s : translate$4,
  25083. m : translate$4,
  25084. mm : translate$4,
  25085. h : translate$4,
  25086. hh : translate$4,
  25087. d : translate$4,
  25088. dd : translate$4,
  25089. M : translate$4,
  25090. MM : translate$4,
  25091. y : translate$4,
  25092. yy : translate$4
  25093. },
  25094. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25095. ordinal : '%d.',
  25096. week : {
  25097. dow : 1, // Monday is the first day of the week.
  25098. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25099. }
  25100. });
  25101. //! moment.js locale configuration
  25102. //! locale : Armenian [hy-am]
  25103. //! author : Armendarabyan : https://github.com/armendarabyan
  25104. hooks.defineLocale('hy-am', {
  25105. months : {
  25106. format: 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_'),
  25107. standalone: 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_')
  25108. },
  25109. monthsShort : 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
  25110. weekdays : 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_'),
  25111. weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
  25112. weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
  25113. longDateFormat : {
  25114. LT : 'HH:mm',
  25115. LTS : 'HH:mm:ss',
  25116. L : 'DD.MM.YYYY',
  25117. LL : 'D MMMM YYYY թ.',
  25118. LLL : 'D MMMM YYYY թ., HH:mm',
  25119. LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
  25120. },
  25121. calendar : {
  25122. sameDay: '[այսօր] LT',
  25123. nextDay: '[վաղը] LT',
  25124. lastDay: '[երեկ] LT',
  25125. nextWeek: function () {
  25126. return 'dddd [օրը ժամը] LT';
  25127. },
  25128. lastWeek: function () {
  25129. return '[անցած] dddd [օրը ժամը] LT';
  25130. },
  25131. sameElse: 'L'
  25132. },
  25133. relativeTime : {
  25134. future : '%s հետո',
  25135. past : '%s առաջ',
  25136. s : 'մի քանի վայրկյան',
  25137. m : 'րոպե',
  25138. mm : '%d րոպե',
  25139. h : 'ժամ',
  25140. hh : '%d ժամ',
  25141. d : 'օր',
  25142. dd : '%d օր',
  25143. M : 'ամիս',
  25144. MM : '%d ամիս',
  25145. y : 'տարի',
  25146. yy : '%d տարի'
  25147. },
  25148. meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
  25149. isPM: function (input) {
  25150. return /^(ցերեկվա|երեկոյան)$/.test(input);
  25151. },
  25152. meridiem : function (hour) {
  25153. if (hour < 4) {
  25154. return 'գիշերվա';
  25155. } else if (hour < 12) {
  25156. return 'առավոտվա';
  25157. } else if (hour < 17) {
  25158. return 'ցերեկվա';
  25159. } else {
  25160. return 'երեկոյան';
  25161. }
  25162. },
  25163. dayOfMonthOrdinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
  25164. ordinal: function (number, period) {
  25165. switch (period) {
  25166. case 'DDD':
  25167. case 'w':
  25168. case 'W':
  25169. case 'DDDo':
  25170. if (number === 1) {
  25171. return number + '-ին';
  25172. }
  25173. return number + '-րդ';
  25174. default:
  25175. return number;
  25176. }
  25177. },
  25178. week : {
  25179. dow : 1, // Monday is the first day of the week.
  25180. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25181. }
  25182. });
  25183. //! moment.js locale configuration
  25184. //! locale : Indonesian [id]
  25185. //! author : Mohammad Satrio Utomo : https://github.com/tyok
  25186. //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
  25187. hooks.defineLocale('id', {
  25188. months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
  25189. monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
  25190. weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
  25191. weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
  25192. weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
  25193. longDateFormat : {
  25194. LT : 'HH.mm',
  25195. LTS : 'HH.mm.ss',
  25196. L : 'DD/MM/YYYY',
  25197. LL : 'D MMMM YYYY',
  25198. LLL : 'D MMMM YYYY [pukul] HH.mm',
  25199. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  25200. },
  25201. meridiemParse: /pagi|siang|sore|malam/,
  25202. meridiemHour : function (hour, meridiem) {
  25203. if (hour === 12) {
  25204. hour = 0;
  25205. }
  25206. if (meridiem === 'pagi') {
  25207. return hour;
  25208. } else if (meridiem === 'siang') {
  25209. return hour >= 11 ? hour : hour + 12;
  25210. } else if (meridiem === 'sore' || meridiem === 'malam') {
  25211. return hour + 12;
  25212. }
  25213. },
  25214. meridiem : function (hours, minutes, isLower) {
  25215. if (hours < 11) {
  25216. return 'pagi';
  25217. } else if (hours < 15) {
  25218. return 'siang';
  25219. } else if (hours < 19) {
  25220. return 'sore';
  25221. } else {
  25222. return 'malam';
  25223. }
  25224. },
  25225. calendar : {
  25226. sameDay : '[Hari ini pukul] LT',
  25227. nextDay : '[Besok pukul] LT',
  25228. nextWeek : 'dddd [pukul] LT',
  25229. lastDay : '[Kemarin pukul] LT',
  25230. lastWeek : 'dddd [lalu pukul] LT',
  25231. sameElse : 'L'
  25232. },
  25233. relativeTime : {
  25234. future : 'dalam %s',
  25235. past : '%s yang lalu',
  25236. s : 'beberapa detik',
  25237. m : 'semenit',
  25238. mm : '%d menit',
  25239. h : 'sejam',
  25240. hh : '%d jam',
  25241. d : 'sehari',
  25242. dd : '%d hari',
  25243. M : 'sebulan',
  25244. MM : '%d bulan',
  25245. y : 'setahun',
  25246. yy : '%d tahun'
  25247. },
  25248. week : {
  25249. dow : 1, // Monday is the first day of the week.
  25250. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25251. }
  25252. });
  25253. //! moment.js locale configuration
  25254. //! locale : Icelandic [is]
  25255. //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
  25256. function plural$2(n) {
  25257. if (n % 100 === 11) {
  25258. return true;
  25259. } else if (n % 10 === 1) {
  25260. return false;
  25261. }
  25262. return true;
  25263. }
  25264. function translate$5(number, withoutSuffix, key, isFuture) {
  25265. var result = number + ' ';
  25266. switch (key) {
  25267. case 's':
  25268. return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
  25269. case 'm':
  25270. return withoutSuffix ? 'mínúta' : 'mínútu';
  25271. case 'mm':
  25272. if (plural$2(number)) {
  25273. return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
  25274. } else if (withoutSuffix) {
  25275. return result + 'mínúta';
  25276. }
  25277. return result + 'mínútu';
  25278. case 'hh':
  25279. if (plural$2(number)) {
  25280. return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
  25281. }
  25282. return result + 'klukkustund';
  25283. case 'd':
  25284. if (withoutSuffix) {
  25285. return 'dagur';
  25286. }
  25287. return isFuture ? 'dag' : 'degi';
  25288. case 'dd':
  25289. if (plural$2(number)) {
  25290. if (withoutSuffix) {
  25291. return result + 'dagar';
  25292. }
  25293. return result + (isFuture ? 'daga' : 'dögum');
  25294. } else if (withoutSuffix) {
  25295. return result + 'dagur';
  25296. }
  25297. return result + (isFuture ? 'dag' : 'degi');
  25298. case 'M':
  25299. if (withoutSuffix) {
  25300. return 'mánuður';
  25301. }
  25302. return isFuture ? 'mánuð' : 'mánuði';
  25303. case 'MM':
  25304. if (plural$2(number)) {
  25305. if (withoutSuffix) {
  25306. return result + 'mánuðir';
  25307. }
  25308. return result + (isFuture ? 'mánuði' : 'mánuðum');
  25309. } else if (withoutSuffix) {
  25310. return result + 'mánuður';
  25311. }
  25312. return result + (isFuture ? 'mánuð' : 'mánuði');
  25313. case 'y':
  25314. return withoutSuffix || isFuture ? 'ár' : 'ári';
  25315. case 'yy':
  25316. if (plural$2(number)) {
  25317. return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
  25318. }
  25319. return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
  25320. }
  25321. }
  25322. hooks.defineLocale('is', {
  25323. months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
  25324. monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
  25325. weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
  25326. weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
  25327. weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
  25328. longDateFormat : {
  25329. LT : 'H:mm',
  25330. LTS : 'H:mm:ss',
  25331. L : 'DD.MM.YYYY',
  25332. LL : 'D. MMMM YYYY',
  25333. LLL : 'D. MMMM YYYY [kl.] H:mm',
  25334. LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
  25335. },
  25336. calendar : {
  25337. sameDay : '[í dag kl.] LT',
  25338. nextDay : '[á morgun kl.] LT',
  25339. nextWeek : 'dddd [kl.] LT',
  25340. lastDay : '[í gær kl.] LT',
  25341. lastWeek : '[síðasta] dddd [kl.] LT',
  25342. sameElse : 'L'
  25343. },
  25344. relativeTime : {
  25345. future : 'eftir %s',
  25346. past : 'fyrir %s síðan',
  25347. s : translate$5,
  25348. m : translate$5,
  25349. mm : translate$5,
  25350. h : 'klukkustund',
  25351. hh : translate$5,
  25352. d : translate$5,
  25353. dd : translate$5,
  25354. M : translate$5,
  25355. MM : translate$5,
  25356. y : translate$5,
  25357. yy : translate$5
  25358. },
  25359. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25360. ordinal : '%d.',
  25361. week : {
  25362. dow : 1, // Monday is the first day of the week.
  25363. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25364. }
  25365. });
  25366. //! moment.js locale configuration
  25367. //! locale : Italian [it]
  25368. //! author : Lorenzo : https://github.com/aliem
  25369. //! author: Mattia Larentis: https://github.com/nostalgiaz
  25370. hooks.defineLocale('it', {
  25371. months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
  25372. monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
  25373. weekdays : 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'),
  25374. weekdaysShort : 'dom_lun_mar_mer_gio_ven_sab'.split('_'),
  25375. weekdaysMin : 'do_lu_ma_me_gi_ve_sa'.split('_'),
  25376. longDateFormat : {
  25377. LT : 'HH:mm',
  25378. LTS : 'HH:mm:ss',
  25379. L : 'DD/MM/YYYY',
  25380. LL : 'D MMMM YYYY',
  25381. LLL : 'D MMMM YYYY HH:mm',
  25382. LLLL : 'dddd, D MMMM YYYY HH:mm'
  25383. },
  25384. calendar : {
  25385. sameDay: '[Oggi alle] LT',
  25386. nextDay: '[Domani alle] LT',
  25387. nextWeek: 'dddd [alle] LT',
  25388. lastDay: '[Ieri alle] LT',
  25389. lastWeek: function () {
  25390. switch (this.day()) {
  25391. case 0:
  25392. return '[la scorsa] dddd [alle] LT';
  25393. default:
  25394. return '[lo scorso] dddd [alle] LT';
  25395. }
  25396. },
  25397. sameElse: 'L'
  25398. },
  25399. relativeTime : {
  25400. future : function (s) {
  25401. return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
  25402. },
  25403. past : '%s fa',
  25404. s : 'alcuni secondi',
  25405. m : 'un minuto',
  25406. mm : '%d minuti',
  25407. h : 'un\'ora',
  25408. hh : '%d ore',
  25409. d : 'un giorno',
  25410. dd : '%d giorni',
  25411. M : 'un mese',
  25412. MM : '%d mesi',
  25413. y : 'un anno',
  25414. yy : '%d anni'
  25415. },
  25416. dayOfMonthOrdinalParse : /\d{1,2}º/,
  25417. ordinal: '%dº',
  25418. week : {
  25419. dow : 1, // Monday is the first day of the week.
  25420. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25421. }
  25422. });
  25423. //! moment.js locale configuration
  25424. //! locale : Japanese [ja]
  25425. //! author : LI Long : https://github.com/baryon
  25426. hooks.defineLocale('ja', {
  25427. months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  25428. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  25429. weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
  25430. weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
  25431. weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
  25432. longDateFormat : {
  25433. LT : 'HH:mm',
  25434. LTS : 'HH:mm:ss',
  25435. L : 'YYYY/MM/DD',
  25436. LL : 'YYYY年M月D日',
  25437. LLL : 'YYYY年M月D日 HH:mm',
  25438. LLLL : 'YYYY年M月D日 HH:mm dddd',
  25439. l : 'YYYY/MM/DD',
  25440. ll : 'YYYY年M月D日',
  25441. lll : 'YYYY年M月D日 HH:mm',
  25442. llll : 'YYYY年M月D日 HH:mm dddd'
  25443. },
  25444. meridiemParse: /午前|午後/i,
  25445. isPM : function (input) {
  25446. return input === '午後';
  25447. },
  25448. meridiem : function (hour, minute, isLower) {
  25449. if (hour < 12) {
  25450. return '午前';
  25451. } else {
  25452. return '午後';
  25453. }
  25454. },
  25455. calendar : {
  25456. sameDay : '[今日] LT',
  25457. nextDay : '[明日] LT',
  25458. nextWeek : '[来週]dddd LT',
  25459. lastDay : '[昨日] LT',
  25460. lastWeek : '[前週]dddd LT',
  25461. sameElse : 'L'
  25462. },
  25463. dayOfMonthOrdinalParse : /\d{1,2}日/,
  25464. ordinal : function (number, period) {
  25465. switch (period) {
  25466. case 'd':
  25467. case 'D':
  25468. case 'DDD':
  25469. return number + '日';
  25470. default:
  25471. return number;
  25472. }
  25473. },
  25474. relativeTime : {
  25475. future : '%s後',
  25476. past : '%s前',
  25477. s : '数秒',
  25478. m : '1分',
  25479. mm : '%d分',
  25480. h : '1時間',
  25481. hh : '%d時間',
  25482. d : '1日',
  25483. dd : '%d日',
  25484. M : '1ヶ月',
  25485. MM : '%dヶ月',
  25486. y : '1年',
  25487. yy : '%d年'
  25488. }
  25489. });
  25490. //! moment.js locale configuration
  25491. //! locale : Javanese [jv]
  25492. //! author : Rony Lantip : https://github.com/lantip
  25493. //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
  25494. hooks.defineLocale('jv', {
  25495. months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
  25496. monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
  25497. weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
  25498. weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
  25499. weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
  25500. longDateFormat : {
  25501. LT : 'HH.mm',
  25502. LTS : 'HH.mm.ss',
  25503. L : 'DD/MM/YYYY',
  25504. LL : 'D MMMM YYYY',
  25505. LLL : 'D MMMM YYYY [pukul] HH.mm',
  25506. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  25507. },
  25508. meridiemParse: /enjing|siyang|sonten|ndalu/,
  25509. meridiemHour : function (hour, meridiem) {
  25510. if (hour === 12) {
  25511. hour = 0;
  25512. }
  25513. if (meridiem === 'enjing') {
  25514. return hour;
  25515. } else if (meridiem === 'siyang') {
  25516. return hour >= 11 ? hour : hour + 12;
  25517. } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
  25518. return hour + 12;
  25519. }
  25520. },
  25521. meridiem : function (hours, minutes, isLower) {
  25522. if (hours < 11) {
  25523. return 'enjing';
  25524. } else if (hours < 15) {
  25525. return 'siyang';
  25526. } else if (hours < 19) {
  25527. return 'sonten';
  25528. } else {
  25529. return 'ndalu';
  25530. }
  25531. },
  25532. calendar : {
  25533. sameDay : '[Dinten puniko pukul] LT',
  25534. nextDay : '[Mbenjang pukul] LT',
  25535. nextWeek : 'dddd [pukul] LT',
  25536. lastDay : '[Kala wingi pukul] LT',
  25537. lastWeek : 'dddd [kepengker pukul] LT',
  25538. sameElse : 'L'
  25539. },
  25540. relativeTime : {
  25541. future : 'wonten ing %s',
  25542. past : '%s ingkang kepengker',
  25543. s : 'sawetawis detik',
  25544. m : 'setunggal menit',
  25545. mm : '%d menit',
  25546. h : 'setunggal jam',
  25547. hh : '%d jam',
  25548. d : 'sedinten',
  25549. dd : '%d dinten',
  25550. M : 'sewulan',
  25551. MM : '%d wulan',
  25552. y : 'setaun',
  25553. yy : '%d taun'
  25554. },
  25555. week : {
  25556. dow : 1, // Monday is the first day of the week.
  25557. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25558. }
  25559. });
  25560. //! moment.js locale configuration
  25561. //! locale : Georgian [ka]
  25562. //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
  25563. hooks.defineLocale('ka', {
  25564. months : {
  25565. standalone: 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
  25566. format: 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
  25567. },
  25568. monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
  25569. weekdays : {
  25570. standalone: 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
  25571. format: 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_'),
  25572. isFormat: /(წინა|შემდეგ)/
  25573. },
  25574. weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
  25575. weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
  25576. longDateFormat : {
  25577. LT : 'h:mm A',
  25578. LTS : 'h:mm:ss A',
  25579. L : 'DD/MM/YYYY',
  25580. LL : 'D MMMM YYYY',
  25581. LLL : 'D MMMM YYYY h:mm A',
  25582. LLLL : 'dddd, D MMMM YYYY h:mm A'
  25583. },
  25584. calendar : {
  25585. sameDay : '[დღეს] LT[-ზე]',
  25586. nextDay : '[ხვალ] LT[-ზე]',
  25587. lastDay : '[გუშინ] LT[-ზე]',
  25588. nextWeek : '[შემდეგ] dddd LT[-ზე]',
  25589. lastWeek : '[წინა] dddd LT-ზე',
  25590. sameElse : 'L'
  25591. },
  25592. relativeTime : {
  25593. future : function (s) {
  25594. return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
  25595. s.replace(/ი$/, 'ში') :
  25596. s + 'ში';
  25597. },
  25598. past : function (s) {
  25599. if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
  25600. return s.replace(/(ი|ე)$/, 'ის უკან');
  25601. }
  25602. if ((/წელი/).test(s)) {
  25603. return s.replace(/წელი$/, 'წლის უკან');
  25604. }
  25605. },
  25606. s : 'რამდენიმე წამი',
  25607. m : 'წუთი',
  25608. mm : '%d წუთი',
  25609. h : 'საათი',
  25610. hh : '%d საათი',
  25611. d : 'დღე',
  25612. dd : '%d დღე',
  25613. M : 'თვე',
  25614. MM : '%d თვე',
  25615. y : 'წელი',
  25616. yy : '%d წელი'
  25617. },
  25618. dayOfMonthOrdinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
  25619. ordinal : function (number) {
  25620. if (number === 0) {
  25621. return number;
  25622. }
  25623. if (number === 1) {
  25624. return number + '-ლი';
  25625. }
  25626. if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
  25627. return 'მე-' + number;
  25628. }
  25629. return number + '-ე';
  25630. },
  25631. week : {
  25632. dow : 1,
  25633. doy : 7
  25634. }
  25635. });
  25636. //! moment.js locale configuration
  25637. //! locale : Kazakh [kk]
  25638. //! authors : Nurlan Rakhimzhanov : https://github.com/nurlan
  25639. var suffixes$1 = {
  25640. 0: '-ші',
  25641. 1: '-ші',
  25642. 2: '-ші',
  25643. 3: '-ші',
  25644. 4: '-ші',
  25645. 5: '-ші',
  25646. 6: '-шы',
  25647. 7: '-ші',
  25648. 8: '-ші',
  25649. 9: '-шы',
  25650. 10: '-шы',
  25651. 20: '-шы',
  25652. 30: '-шы',
  25653. 40: '-шы',
  25654. 50: '-ші',
  25655. 60: '-шы',
  25656. 70: '-ші',
  25657. 80: '-ші',
  25658. 90: '-шы',
  25659. 100: '-ші'
  25660. };
  25661. hooks.defineLocale('kk', {
  25662. months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
  25663. monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
  25664. weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
  25665. weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
  25666. weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
  25667. longDateFormat : {
  25668. LT : 'HH:mm',
  25669. LTS : 'HH:mm:ss',
  25670. L : 'DD.MM.YYYY',
  25671. LL : 'D MMMM YYYY',
  25672. LLL : 'D MMMM YYYY HH:mm',
  25673. LLLL : 'dddd, D MMMM YYYY HH:mm'
  25674. },
  25675. calendar : {
  25676. sameDay : '[Бүгін сағат] LT',
  25677. nextDay : '[Ертең сағат] LT',
  25678. nextWeek : 'dddd [сағат] LT',
  25679. lastDay : '[Кеше сағат] LT',
  25680. lastWeek : '[Өткен аптаның] dddd [сағат] LT',
  25681. sameElse : 'L'
  25682. },
  25683. relativeTime : {
  25684. future : '%s ішінде',
  25685. past : '%s бұрын',
  25686. s : 'бірнеше секунд',
  25687. m : 'бір минут',
  25688. mm : '%d минут',
  25689. h : 'бір сағат',
  25690. hh : '%d сағат',
  25691. d : 'бір күн',
  25692. dd : '%d күн',
  25693. M : 'бір ай',
  25694. MM : '%d ай',
  25695. y : 'бір жыл',
  25696. yy : '%d жыл'
  25697. },
  25698. dayOfMonthOrdinalParse: /\d{1,2}-(ші|шы)/,
  25699. ordinal : function (number) {
  25700. var a = number % 10,
  25701. b = number >= 100 ? 100 : null;
  25702. return number + (suffixes$1[number] || suffixes$1[a] || suffixes$1[b]);
  25703. },
  25704. week : {
  25705. dow : 1, // Monday is the first day of the week.
  25706. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25707. }
  25708. });
  25709. //! moment.js locale configuration
  25710. //! locale : Cambodian [km]
  25711. //! author : Kruy Vanna : https://github.com/kruyvanna
  25712. hooks.defineLocale('km', {
  25713. months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
  25714. monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
  25715. weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  25716. weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  25717. weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  25718. longDateFormat: {
  25719. LT: 'HH:mm',
  25720. LTS : 'HH:mm:ss',
  25721. L: 'DD/MM/YYYY',
  25722. LL: 'D MMMM YYYY',
  25723. LLL: 'D MMMM YYYY HH:mm',
  25724. LLLL: 'dddd, D MMMM YYYY HH:mm'
  25725. },
  25726. calendar: {
  25727. sameDay: '[ថ្ងៃនេះ ម៉ោង] LT',
  25728. nextDay: '[ស្អែក ម៉ោង] LT',
  25729. nextWeek: 'dddd [ម៉ោង] LT',
  25730. lastDay: '[ម្សិលមិញ ម៉ោង] LT',
  25731. lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
  25732. sameElse: 'L'
  25733. },
  25734. relativeTime: {
  25735. future: '%sទៀត',
  25736. past: '%sមុន',
  25737. s: 'ប៉ុន្មានវិនាទី',
  25738. m: 'មួយនាទី',
  25739. mm: '%d នាទី',
  25740. h: 'មួយម៉ោង',
  25741. hh: '%d ម៉ោង',
  25742. d: 'មួយថ្ងៃ',
  25743. dd: '%d ថ្ងៃ',
  25744. M: 'មួយខែ',
  25745. MM: '%d ខែ',
  25746. y: 'មួយឆ្នាំ',
  25747. yy: '%d ឆ្នាំ'
  25748. },
  25749. week: {
  25750. dow: 1, // Monday is the first day of the week.
  25751. doy: 4 // The week that contains Jan 4th is the first week of the year.
  25752. }
  25753. });
  25754. //! moment.js locale configuration
  25755. //! locale : Kannada [kn]
  25756. //! author : Rajeev Naik : https://github.com/rajeevnaikte
  25757. var symbolMap$8 = {
  25758. '1': '೧',
  25759. '2': '೨',
  25760. '3': '೩',
  25761. '4': '೪',
  25762. '5': '೫',
  25763. '6': '೬',
  25764. '7': '೭',
  25765. '8': '೮',
  25766. '9': '೯',
  25767. '0': '೦'
  25768. };
  25769. var numberMap$7 = {
  25770. '೧': '1',
  25771. '೨': '2',
  25772. '೩': '3',
  25773. '೪': '4',
  25774. '೫': '5',
  25775. '೬': '6',
  25776. '೭': '7',
  25777. '೮': '8',
  25778. '೯': '9',
  25779. '೦': '0'
  25780. };
  25781. hooks.defineLocale('kn', {
  25782. months : 'ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್'.split('_'),
  25783. monthsShort : 'ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬ_ಅಕ್ಟೋಬ_ನವೆಂಬ_ಡಿಸೆಂಬ'.split('_'),
  25784. monthsParseExact: true,
  25785. weekdays : 'ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ'.split('_'),
  25786. weekdaysShort : 'ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ'.split('_'),
  25787. weekdaysMin : 'ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ'.split('_'),
  25788. longDateFormat : {
  25789. LT : 'A h:mm',
  25790. LTS : 'A h:mm:ss',
  25791. L : 'DD/MM/YYYY',
  25792. LL : 'D MMMM YYYY',
  25793. LLL : 'D MMMM YYYY, A h:mm',
  25794. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  25795. },
  25796. calendar : {
  25797. sameDay : '[ಇಂದು] LT',
  25798. nextDay : '[ನಾಳೆ] LT',
  25799. nextWeek : 'dddd, LT',
  25800. lastDay : '[ನಿನ್ನೆ] LT',
  25801. lastWeek : '[ಕೊನೆಯ] dddd, LT',
  25802. sameElse : 'L'
  25803. },
  25804. relativeTime : {
  25805. future : '%s ನಂತರ',
  25806. past : '%s ಹಿಂದೆ',
  25807. s : 'ಕೆಲವು ಕ್ಷಣಗಳು',
  25808. m : 'ಒಂದು ನಿಮಿಷ',
  25809. mm : '%d ನಿಮಿಷ',
  25810. h : 'ಒಂದು ಗಂಟೆ',
  25811. hh : '%d ಗಂಟೆ',
  25812. d : 'ಒಂದು ದಿನ',
  25813. dd : '%d ದಿನ',
  25814. M : 'ಒಂದು ತಿಂಗಳು',
  25815. MM : '%d ತಿಂಗಳು',
  25816. y : 'ಒಂದು ವರ್ಷ',
  25817. yy : '%d ವರ್ಷ'
  25818. },
  25819. preparse: function (string) {
  25820. return string.replace(/[೧೨೩೪೫೬೭೮೯೦]/g, function (match) {
  25821. return numberMap$7[match];
  25822. });
  25823. },
  25824. postformat: function (string) {
  25825. return string.replace(/\d/g, function (match) {
  25826. return symbolMap$8[match];
  25827. });
  25828. },
  25829. meridiemParse: /ರಾತ್ರಿ|ಬೆಳಿಗ್ಗೆ|ಮಧ್ಯಾಹ್ನ|ಸಂಜೆ/,
  25830. meridiemHour : function (hour, meridiem) {
  25831. if (hour === 12) {
  25832. hour = 0;
  25833. }
  25834. if (meridiem === 'ರಾತ್ರಿ') {
  25835. return hour < 4 ? hour : hour + 12;
  25836. } else if (meridiem === 'ಬೆಳಿಗ್ಗೆ') {
  25837. return hour;
  25838. } else if (meridiem === 'ಮಧ್ಯಾಹ್ನ') {
  25839. return hour >= 10 ? hour : hour + 12;
  25840. } else if (meridiem === 'ಸಂಜೆ') {
  25841. return hour + 12;
  25842. }
  25843. },
  25844. meridiem : function (hour, minute, isLower) {
  25845. if (hour < 4) {
  25846. return 'ರಾತ್ರಿ';
  25847. } else if (hour < 10) {
  25848. return 'ಬೆಳಿಗ್ಗೆ';
  25849. } else if (hour < 17) {
  25850. return 'ಮಧ್ಯಾಹ್ನ';
  25851. } else if (hour < 20) {
  25852. return 'ಸಂಜೆ';
  25853. } else {
  25854. return 'ರಾತ್ರಿ';
  25855. }
  25856. },
  25857. dayOfMonthOrdinalParse: /\d{1,2}(ನೇ)/,
  25858. ordinal : function (number) {
  25859. return number + 'ನೇ';
  25860. },
  25861. week : {
  25862. dow : 0, // Sunday is the first day of the week.
  25863. doy : 6 // The week that contains Jan 1st is the first week of the year.
  25864. }
  25865. });
  25866. //! moment.js locale configuration
  25867. //! locale : Korean [ko]
  25868. //! author : Kyungwook, Park : https://github.com/kyungw00k
  25869. //! author : Jeeeyul Lee <jeeeyul@gmail.com>
  25870. hooks.defineLocale('ko', {
  25871. months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
  25872. monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
  25873. weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
  25874. weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
  25875. weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
  25876. longDateFormat : {
  25877. LT : 'A h:mm',
  25878. LTS : 'A h:mm:ss',
  25879. L : 'YYYY.MM.DD',
  25880. LL : 'YYYY년 MMMM D일',
  25881. LLL : 'YYYY년 MMMM D일 A h:mm',
  25882. LLLL : 'YYYY년 MMMM D일 dddd A h:mm',
  25883. l : 'YYYY.MM.DD',
  25884. ll : 'YYYY년 MMMM D일',
  25885. lll : 'YYYY년 MMMM D일 A h:mm',
  25886. llll : 'YYYY년 MMMM D일 dddd A h:mm'
  25887. },
  25888. calendar : {
  25889. sameDay : '오늘 LT',
  25890. nextDay : '내일 LT',
  25891. nextWeek : 'dddd LT',
  25892. lastDay : '어제 LT',
  25893. lastWeek : '지난주 dddd LT',
  25894. sameElse : 'L'
  25895. },
  25896. relativeTime : {
  25897. future : '%s 후',
  25898. past : '%s 전',
  25899. s : '몇 초',
  25900. ss : '%d초',
  25901. m : '1분',
  25902. mm : '%d분',
  25903. h : '한 시간',
  25904. hh : '%d시간',
  25905. d : '하루',
  25906. dd : '%d일',
  25907. M : '한 달',
  25908. MM : '%d달',
  25909. y : '일 년',
  25910. yy : '%d년'
  25911. },
  25912. dayOfMonthOrdinalParse : /\d{1,2}(일|월|주)/,
  25913. ordinal : function (number, period) {
  25914. switch (period) {
  25915. case 'd':
  25916. case 'D':
  25917. case 'DDD':
  25918. return number + '일';
  25919. case 'M':
  25920. return number + '월';
  25921. case 'w':
  25922. case 'W':
  25923. return number + '주';
  25924. default:
  25925. return number;
  25926. }
  25927. },
  25928. meridiemParse : /오전|오후/,
  25929. isPM : function (token) {
  25930. return token === '오후';
  25931. },
  25932. meridiem : function (hour, minute, isUpper) {
  25933. return hour < 12 ? '오전' : '오후';
  25934. }
  25935. });
  25936. //! moment.js locale configuration
  25937. //! locale : Kyrgyz [ky]
  25938. //! author : Chyngyz Arystan uulu : https://github.com/chyngyz
  25939. var suffixes$2 = {
  25940. 0: '-чү',
  25941. 1: '-чи',
  25942. 2: '-чи',
  25943. 3: '-чү',
  25944. 4: '-чү',
  25945. 5: '-чи',
  25946. 6: '-чы',
  25947. 7: '-чи',
  25948. 8: '-чи',
  25949. 9: '-чу',
  25950. 10: '-чу',
  25951. 20: '-чы',
  25952. 30: '-чу',
  25953. 40: '-чы',
  25954. 50: '-чү',
  25955. 60: '-чы',
  25956. 70: '-чи',
  25957. 80: '-чи',
  25958. 90: '-чу',
  25959. 100: '-чү'
  25960. };
  25961. hooks.defineLocale('ky', {
  25962. months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
  25963. monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
  25964. weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
  25965. weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
  25966. weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
  25967. longDateFormat : {
  25968. LT : 'HH:mm',
  25969. LTS : 'HH:mm:ss',
  25970. L : 'DD.MM.YYYY',
  25971. LL : 'D MMMM YYYY',
  25972. LLL : 'D MMMM YYYY HH:mm',
  25973. LLLL : 'dddd, D MMMM YYYY HH:mm'
  25974. },
  25975. calendar : {
  25976. sameDay : '[Бүгүн саат] LT',
  25977. nextDay : '[Эртең саат] LT',
  25978. nextWeek : 'dddd [саат] LT',
  25979. lastDay : '[Кече саат] LT',
  25980. lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
  25981. sameElse : 'L'
  25982. },
  25983. relativeTime : {
  25984. future : '%s ичинде',
  25985. past : '%s мурун',
  25986. s : 'бирнече секунд',
  25987. m : 'бир мүнөт',
  25988. mm : '%d мүнөт',
  25989. h : 'бир саат',
  25990. hh : '%d саат',
  25991. d : 'бир күн',
  25992. dd : '%d күн',
  25993. M : 'бир ай',
  25994. MM : '%d ай',
  25995. y : 'бир жыл',
  25996. yy : '%d жыл'
  25997. },
  25998. dayOfMonthOrdinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
  25999. ordinal : function (number) {
  26000. var a = number % 10,
  26001. b = number >= 100 ? 100 : null;
  26002. return number + (suffixes$2[number] || suffixes$2[a] || suffixes$2[b]);
  26003. },
  26004. week : {
  26005. dow : 1, // Monday is the first day of the week.
  26006. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26007. }
  26008. });
  26009. //! moment.js locale configuration
  26010. //! locale : Luxembourgish [lb]
  26011. //! author : mweimerskirch : https://github.com/mweimerskirch
  26012. //! author : David Raison : https://github.com/kwisatz
  26013. function processRelativeTime$5(number, withoutSuffix, key, isFuture) {
  26014. var format = {
  26015. 'm': ['eng Minutt', 'enger Minutt'],
  26016. 'h': ['eng Stonn', 'enger Stonn'],
  26017. 'd': ['een Dag', 'engem Dag'],
  26018. 'M': ['ee Mount', 'engem Mount'],
  26019. 'y': ['ee Joer', 'engem Joer']
  26020. };
  26021. return withoutSuffix ? format[key][0] : format[key][1];
  26022. }
  26023. function processFutureTime(string) {
  26024. var number = string.substr(0, string.indexOf(' '));
  26025. if (eifelerRegelAppliesToNumber(number)) {
  26026. return 'a ' + string;
  26027. }
  26028. return 'an ' + string;
  26029. }
  26030. function processPastTime(string) {
  26031. var number = string.substr(0, string.indexOf(' '));
  26032. if (eifelerRegelAppliesToNumber(number)) {
  26033. return 'viru ' + string;
  26034. }
  26035. return 'virun ' + string;
  26036. }
  26037. /**
  26038. * Returns true if the word before the given number loses the '-n' ending.
  26039. * e.g. 'an 10 Deeg' but 'a 5 Deeg'
  26040. *
  26041. * @param number {integer}
  26042. * @returns {boolean}
  26043. */
  26044. function eifelerRegelAppliesToNumber(number) {
  26045. number = parseInt(number, 10);
  26046. if (isNaN(number)) {
  26047. return false;
  26048. }
  26049. if (number < 0) {
  26050. // Negative Number --> always true
  26051. return true;
  26052. } else if (number < 10) {
  26053. // Only 1 digit
  26054. if (4 <= number && number <= 7) {
  26055. return true;
  26056. }
  26057. return false;
  26058. } else if (number < 100) {
  26059. // 2 digits
  26060. var lastDigit = number % 10, firstDigit = number / 10;
  26061. if (lastDigit === 0) {
  26062. return eifelerRegelAppliesToNumber(firstDigit);
  26063. }
  26064. return eifelerRegelAppliesToNumber(lastDigit);
  26065. } else if (number < 10000) {
  26066. // 3 or 4 digits --> recursively check first digit
  26067. while (number >= 10) {
  26068. number = number / 10;
  26069. }
  26070. return eifelerRegelAppliesToNumber(number);
  26071. } else {
  26072. // Anything larger than 4 digits: recursively check first n-3 digits
  26073. number = number / 1000;
  26074. return eifelerRegelAppliesToNumber(number);
  26075. }
  26076. }
  26077. hooks.defineLocale('lb', {
  26078. months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  26079. monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
  26080. monthsParseExact : true,
  26081. weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
  26082. weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
  26083. weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
  26084. weekdaysParseExact : true,
  26085. longDateFormat: {
  26086. LT: 'H:mm [Auer]',
  26087. LTS: 'H:mm:ss [Auer]',
  26088. L: 'DD.MM.YYYY',
  26089. LL: 'D. MMMM YYYY',
  26090. LLL: 'D. MMMM YYYY H:mm [Auer]',
  26091. LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
  26092. },
  26093. calendar: {
  26094. sameDay: '[Haut um] LT',
  26095. sameElse: 'L',
  26096. nextDay: '[Muer um] LT',
  26097. nextWeek: 'dddd [um] LT',
  26098. lastDay: '[Gëschter um] LT',
  26099. lastWeek: function () {
  26100. // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
  26101. switch (this.day()) {
  26102. case 2:
  26103. case 4:
  26104. return '[Leschten] dddd [um] LT';
  26105. default:
  26106. return '[Leschte] dddd [um] LT';
  26107. }
  26108. }
  26109. },
  26110. relativeTime : {
  26111. future : processFutureTime,
  26112. past : processPastTime,
  26113. s : 'e puer Sekonnen',
  26114. m : processRelativeTime$5,
  26115. mm : '%d Minutten',
  26116. h : processRelativeTime$5,
  26117. hh : '%d Stonnen',
  26118. d : processRelativeTime$5,
  26119. dd : '%d Deeg',
  26120. M : processRelativeTime$5,
  26121. MM : '%d Méint',
  26122. y : processRelativeTime$5,
  26123. yy : '%d Joer'
  26124. },
  26125. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26126. ordinal: '%d.',
  26127. week: {
  26128. dow: 1, // Monday is the first day of the week.
  26129. doy: 4 // The week that contains Jan 4th is the first week of the year.
  26130. }
  26131. });
  26132. //! moment.js locale configuration
  26133. //! locale : Lao [lo]
  26134. //! author : Ryan Hart : https://github.com/ryanhart2
  26135. hooks.defineLocale('lo', {
  26136. months : 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'),
  26137. monthsShort : 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'),
  26138. weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
  26139. weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
  26140. weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
  26141. weekdaysParseExact : true,
  26142. longDateFormat : {
  26143. LT : 'HH:mm',
  26144. LTS : 'HH:mm:ss',
  26145. L : 'DD/MM/YYYY',
  26146. LL : 'D MMMM YYYY',
  26147. LLL : 'D MMMM YYYY HH:mm',
  26148. LLLL : 'ວັນdddd D MMMM YYYY HH:mm'
  26149. },
  26150. meridiemParse: /ຕອນເຊົ້າ|ຕອນແລງ/,
  26151. isPM: function (input) {
  26152. return input === 'ຕອນແລງ';
  26153. },
  26154. meridiem : function (hour, minute, isLower) {
  26155. if (hour < 12) {
  26156. return 'ຕອນເຊົ້າ';
  26157. } else {
  26158. return 'ຕອນແລງ';
  26159. }
  26160. },
  26161. calendar : {
  26162. sameDay : '[ມື້ນີ້ເວລາ] LT',
  26163. nextDay : '[ມື້ອື່ນເວລາ] LT',
  26164. nextWeek : '[ວັນ]dddd[ໜ້າເວລາ] LT',
  26165. lastDay : '[ມື້ວານນີ້ເວລາ] LT',
  26166. lastWeek : '[ວັນ]dddd[ແລ້ວນີ້ເວລາ] LT',
  26167. sameElse : 'L'
  26168. },
  26169. relativeTime : {
  26170. future : 'ອີກ %s',
  26171. past : '%sຜ່ານມາ',
  26172. s : 'ບໍ່ເທົ່າໃດວິນາທີ',
  26173. m : '1 ນາທີ',
  26174. mm : '%d ນາທີ',
  26175. h : '1 ຊົ່ວໂມງ',
  26176. hh : '%d ຊົ່ວໂມງ',
  26177. d : '1 ມື້',
  26178. dd : '%d ມື້',
  26179. M : '1 ເດືອນ',
  26180. MM : '%d ເດືອນ',
  26181. y : '1 ປີ',
  26182. yy : '%d ປີ'
  26183. },
  26184. dayOfMonthOrdinalParse: /(ທີ່)\d{1,2}/,
  26185. ordinal : function (number) {
  26186. return 'ທີ່' + number;
  26187. }
  26188. });
  26189. //! moment.js locale configuration
  26190. //! locale : Lithuanian [lt]
  26191. //! author : Mindaugas Mozūras : https://github.com/mmozuras
  26192. var units = {
  26193. 'm' : 'minutė_minutės_minutę',
  26194. 'mm': 'minutės_minučių_minutes',
  26195. 'h' : 'valanda_valandos_valandą',
  26196. 'hh': 'valandos_valandų_valandas',
  26197. 'd' : 'diena_dienos_dieną',
  26198. 'dd': 'dienos_dienų_dienas',
  26199. 'M' : 'mėnuo_mėnesio_mėnesį',
  26200. 'MM': 'mėnesiai_mėnesių_mėnesius',
  26201. 'y' : 'metai_metų_metus',
  26202. 'yy': 'metai_metų_metus'
  26203. };
  26204. function translateSeconds(number, withoutSuffix, key, isFuture) {
  26205. if (withoutSuffix) {
  26206. return 'kelios sekundės';
  26207. } else {
  26208. return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
  26209. }
  26210. }
  26211. function translateSingular(number, withoutSuffix, key, isFuture) {
  26212. return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
  26213. }
  26214. function special(number) {
  26215. return number % 10 === 0 || (number > 10 && number < 20);
  26216. }
  26217. function forms(key) {
  26218. return units[key].split('_');
  26219. }
  26220. function translate$6(number, withoutSuffix, key, isFuture) {
  26221. var result = number + ' ';
  26222. if (number === 1) {
  26223. return result + translateSingular(number, withoutSuffix, key[0], isFuture);
  26224. } else if (withoutSuffix) {
  26225. return result + (special(number) ? forms(key)[1] : forms(key)[0]);
  26226. } else {
  26227. if (isFuture) {
  26228. return result + forms(key)[1];
  26229. } else {
  26230. return result + (special(number) ? forms(key)[1] : forms(key)[2]);
  26231. }
  26232. }
  26233. }
  26234. hooks.defineLocale('lt', {
  26235. months : {
  26236. format: 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_'),
  26237. standalone: 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
  26238. isFormat: /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/
  26239. },
  26240. monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
  26241. weekdays : {
  26242. format: 'sekmadienį_pirmadienį_antradienį_trečiadienį_ketvirtadienį_penktadienį_šeštadienį'.split('_'),
  26243. standalone: 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_'),
  26244. isFormat: /dddd HH:mm/
  26245. },
  26246. weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
  26247. weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
  26248. weekdaysParseExact : true,
  26249. longDateFormat : {
  26250. LT : 'HH:mm',
  26251. LTS : 'HH:mm:ss',
  26252. L : 'YYYY-MM-DD',
  26253. LL : 'YYYY [m.] MMMM D [d.]',
  26254. LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
  26255. LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
  26256. l : 'YYYY-MM-DD',
  26257. ll : 'YYYY [m.] MMMM D [d.]',
  26258. lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
  26259. llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
  26260. },
  26261. calendar : {
  26262. sameDay : '[Šiandien] LT',
  26263. nextDay : '[Rytoj] LT',
  26264. nextWeek : 'dddd LT',
  26265. lastDay : '[Vakar] LT',
  26266. lastWeek : '[Praėjusį] dddd LT',
  26267. sameElse : 'L'
  26268. },
  26269. relativeTime : {
  26270. future : 'po %s',
  26271. past : 'prieš %s',
  26272. s : translateSeconds,
  26273. m : translateSingular,
  26274. mm : translate$6,
  26275. h : translateSingular,
  26276. hh : translate$6,
  26277. d : translateSingular,
  26278. dd : translate$6,
  26279. M : translateSingular,
  26280. MM : translate$6,
  26281. y : translateSingular,
  26282. yy : translate$6
  26283. },
  26284. dayOfMonthOrdinalParse: /\d{1,2}-oji/,
  26285. ordinal : function (number) {
  26286. return number + '-oji';
  26287. },
  26288. week : {
  26289. dow : 1, // Monday is the first day of the week.
  26290. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26291. }
  26292. });
  26293. //! moment.js locale configuration
  26294. //! locale : Latvian [lv]
  26295. //! author : Kristaps Karlsons : https://github.com/skakri
  26296. //! author : Jānis Elmeris : https://github.com/JanisE
  26297. var units$1 = {
  26298. 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  26299. 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  26300. 'h': 'stundas_stundām_stunda_stundas'.split('_'),
  26301. 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
  26302. 'd': 'dienas_dienām_diena_dienas'.split('_'),
  26303. 'dd': 'dienas_dienām_diena_dienas'.split('_'),
  26304. 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  26305. 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  26306. 'y': 'gada_gadiem_gads_gadi'.split('_'),
  26307. 'yy': 'gada_gadiem_gads_gadi'.split('_')
  26308. };
  26309. /**
  26310. * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
  26311. */
  26312. function format$1(forms, number, withoutSuffix) {
  26313. if (withoutSuffix) {
  26314. // E.g. "21 minūte", "3 minūtes".
  26315. return number % 10 === 1 && number % 100 !== 11 ? forms[2] : forms[3];
  26316. } else {
  26317. // E.g. "21 minūtes" as in "pēc 21 minūtes".
  26318. // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
  26319. return number % 10 === 1 && number % 100 !== 11 ? forms[0] : forms[1];
  26320. }
  26321. }
  26322. function relativeTimeWithPlural$1(number, withoutSuffix, key) {
  26323. return number + ' ' + format$1(units$1[key], number, withoutSuffix);
  26324. }
  26325. function relativeTimeWithSingular(number, withoutSuffix, key) {
  26326. return format$1(units$1[key], number, withoutSuffix);
  26327. }
  26328. function relativeSeconds(number, withoutSuffix) {
  26329. return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
  26330. }
  26331. hooks.defineLocale('lv', {
  26332. months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
  26333. monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
  26334. weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
  26335. weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
  26336. weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
  26337. weekdaysParseExact : true,
  26338. longDateFormat : {
  26339. LT : 'HH:mm',
  26340. LTS : 'HH:mm:ss',
  26341. L : 'DD.MM.YYYY.',
  26342. LL : 'YYYY. [gada] D. MMMM',
  26343. LLL : 'YYYY. [gada] D. MMMM, HH:mm',
  26344. LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
  26345. },
  26346. calendar : {
  26347. sameDay : '[Šodien pulksten] LT',
  26348. nextDay : '[Rīt pulksten] LT',
  26349. nextWeek : 'dddd [pulksten] LT',
  26350. lastDay : '[Vakar pulksten] LT',
  26351. lastWeek : '[Pagājušā] dddd [pulksten] LT',
  26352. sameElse : 'L'
  26353. },
  26354. relativeTime : {
  26355. future : 'pēc %s',
  26356. past : 'pirms %s',
  26357. s : relativeSeconds,
  26358. m : relativeTimeWithSingular,
  26359. mm : relativeTimeWithPlural$1,
  26360. h : relativeTimeWithSingular,
  26361. hh : relativeTimeWithPlural$1,
  26362. d : relativeTimeWithSingular,
  26363. dd : relativeTimeWithPlural$1,
  26364. M : relativeTimeWithSingular,
  26365. MM : relativeTimeWithPlural$1,
  26366. y : relativeTimeWithSingular,
  26367. yy : relativeTimeWithPlural$1
  26368. },
  26369. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26370. ordinal : '%d.',
  26371. week : {
  26372. dow : 1, // Monday is the first day of the week.
  26373. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26374. }
  26375. });
  26376. //! moment.js locale configuration
  26377. //! locale : Montenegrin [me]
  26378. //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
  26379. var translator = {
  26380. words: { //Different grammatical cases
  26381. m: ['jedan minut', 'jednog minuta'],
  26382. mm: ['minut', 'minuta', 'minuta'],
  26383. h: ['jedan sat', 'jednog sata'],
  26384. hh: ['sat', 'sata', 'sati'],
  26385. dd: ['dan', 'dana', 'dana'],
  26386. MM: ['mjesec', 'mjeseca', 'mjeseci'],
  26387. yy: ['godina', 'godine', 'godina']
  26388. },
  26389. correctGrammaticalCase: function (number, wordKey) {
  26390. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  26391. },
  26392. translate: function (number, withoutSuffix, key) {
  26393. var wordKey = translator.words[key];
  26394. if (key.length === 1) {
  26395. return withoutSuffix ? wordKey[0] : wordKey[1];
  26396. } else {
  26397. return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
  26398. }
  26399. }
  26400. };
  26401. hooks.defineLocale('me', {
  26402. months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
  26403. monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
  26404. monthsParseExact : true,
  26405. weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  26406. weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  26407. weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
  26408. weekdaysParseExact : true,
  26409. longDateFormat: {
  26410. LT: 'H:mm',
  26411. LTS : 'H:mm:ss',
  26412. L: 'DD.MM.YYYY',
  26413. LL: 'D. MMMM YYYY',
  26414. LLL: 'D. MMMM YYYY H:mm',
  26415. LLLL: 'dddd, D. MMMM YYYY H:mm'
  26416. },
  26417. calendar: {
  26418. sameDay: '[danas u] LT',
  26419. nextDay: '[sjutra u] LT',
  26420. nextWeek: function () {
  26421. switch (this.day()) {
  26422. case 0:
  26423. return '[u] [nedjelju] [u] LT';
  26424. case 3:
  26425. return '[u] [srijedu] [u] LT';
  26426. case 6:
  26427. return '[u] [subotu] [u] LT';
  26428. case 1:
  26429. case 2:
  26430. case 4:
  26431. case 5:
  26432. return '[u] dddd [u] LT';
  26433. }
  26434. },
  26435. lastDay : '[juče u] LT',
  26436. lastWeek : function () {
  26437. var lastWeekDays = [
  26438. '[prošle] [nedjelje] [u] LT',
  26439. '[prošlog] [ponedjeljka] [u] LT',
  26440. '[prošlog] [utorka] [u] LT',
  26441. '[prošle] [srijede] [u] LT',
  26442. '[prošlog] [četvrtka] [u] LT',
  26443. '[prošlog] [petka] [u] LT',
  26444. '[prošle] [subote] [u] LT'
  26445. ];
  26446. return lastWeekDays[this.day()];
  26447. },
  26448. sameElse : 'L'
  26449. },
  26450. relativeTime : {
  26451. future : 'za %s',
  26452. past : 'prije %s',
  26453. s : 'nekoliko sekundi',
  26454. m : translator.translate,
  26455. mm : translator.translate,
  26456. h : translator.translate,
  26457. hh : translator.translate,
  26458. d : 'dan',
  26459. dd : translator.translate,
  26460. M : 'mjesec',
  26461. MM : translator.translate,
  26462. y : 'godinu',
  26463. yy : translator.translate
  26464. },
  26465. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26466. ordinal : '%d.',
  26467. week : {
  26468. dow : 1, // Monday is the first day of the week.
  26469. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26470. }
  26471. });
  26472. //! moment.js locale configuration
  26473. //! locale : Maori [mi]
  26474. //! author : John Corrigan <robbiecloset@gmail.com> : https://github.com/johnideal
  26475. hooks.defineLocale('mi', {
  26476. months: 'Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea'.split('_'),
  26477. monthsShort: 'Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki'.split('_'),
  26478. monthsRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  26479. monthsStrictRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  26480. monthsShortRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  26481. monthsShortStrictRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,2}/i,
  26482. weekdays: 'Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei'.split('_'),
  26483. weekdaysShort: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'),
  26484. weekdaysMin: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'),
  26485. longDateFormat: {
  26486. LT: 'HH:mm',
  26487. LTS: 'HH:mm:ss',
  26488. L: 'DD/MM/YYYY',
  26489. LL: 'D MMMM YYYY',
  26490. LLL: 'D MMMM YYYY [i] HH:mm',
  26491. LLLL: 'dddd, D MMMM YYYY [i] HH:mm'
  26492. },
  26493. calendar: {
  26494. sameDay: '[i teie mahana, i] LT',
  26495. nextDay: '[apopo i] LT',
  26496. nextWeek: 'dddd [i] LT',
  26497. lastDay: '[inanahi i] LT',
  26498. lastWeek: 'dddd [whakamutunga i] LT',
  26499. sameElse: 'L'
  26500. },
  26501. relativeTime: {
  26502. future: 'i roto i %s',
  26503. past: '%s i mua',
  26504. s: 'te hēkona ruarua',
  26505. m: 'he meneti',
  26506. mm: '%d meneti',
  26507. h: 'te haora',
  26508. hh: '%d haora',
  26509. d: 'he ra',
  26510. dd: '%d ra',
  26511. M: 'he marama',
  26512. MM: '%d marama',
  26513. y: 'he tau',
  26514. yy: '%d tau'
  26515. },
  26516. dayOfMonthOrdinalParse: /\d{1,2}º/,
  26517. ordinal: '%dº',
  26518. week : {
  26519. dow : 1, // Monday is the first day of the week.
  26520. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26521. }
  26522. });
  26523. //! moment.js locale configuration
  26524. //! locale : Macedonian [mk]
  26525. //! author : Borislav Mickov : https://github.com/B0k0
  26526. hooks.defineLocale('mk', {
  26527. months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
  26528. monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
  26529. weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
  26530. weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
  26531. weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
  26532. longDateFormat : {
  26533. LT : 'H:mm',
  26534. LTS : 'H:mm:ss',
  26535. L : 'D.MM.YYYY',
  26536. LL : 'D MMMM YYYY',
  26537. LLL : 'D MMMM YYYY H:mm',
  26538. LLLL : 'dddd, D MMMM YYYY H:mm'
  26539. },
  26540. calendar : {
  26541. sameDay : '[Денес во] LT',
  26542. nextDay : '[Утре во] LT',
  26543. nextWeek : '[Во] dddd [во] LT',
  26544. lastDay : '[Вчера во] LT',
  26545. lastWeek : function () {
  26546. switch (this.day()) {
  26547. case 0:
  26548. case 3:
  26549. case 6:
  26550. return '[Изминатата] dddd [во] LT';
  26551. case 1:
  26552. case 2:
  26553. case 4:
  26554. case 5:
  26555. return '[Изминатиот] dddd [во] LT';
  26556. }
  26557. },
  26558. sameElse : 'L'
  26559. },
  26560. relativeTime : {
  26561. future : 'после %s',
  26562. past : 'пред %s',
  26563. s : 'неколку секунди',
  26564. m : 'минута',
  26565. mm : '%d минути',
  26566. h : 'час',
  26567. hh : '%d часа',
  26568. d : 'ден',
  26569. dd : '%d дена',
  26570. M : 'месец',
  26571. MM : '%d месеци',
  26572. y : 'година',
  26573. yy : '%d години'
  26574. },
  26575. dayOfMonthOrdinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
  26576. ordinal : function (number) {
  26577. var lastDigit = number % 10,
  26578. last2Digits = number % 100;
  26579. if (number === 0) {
  26580. return number + '-ев';
  26581. } else if (last2Digits === 0) {
  26582. return number + '-ен';
  26583. } else if (last2Digits > 10 && last2Digits < 20) {
  26584. return number + '-ти';
  26585. } else if (lastDigit === 1) {
  26586. return number + '-ви';
  26587. } else if (lastDigit === 2) {
  26588. return number + '-ри';
  26589. } else if (lastDigit === 7 || lastDigit === 8) {
  26590. return number + '-ми';
  26591. } else {
  26592. return number + '-ти';
  26593. }
  26594. },
  26595. week : {
  26596. dow : 1, // Monday is the first day of the week.
  26597. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26598. }
  26599. });
  26600. //! moment.js locale configuration
  26601. //! locale : Malayalam [ml]
  26602. //! author : Floyd Pink : https://github.com/floydpink
  26603. hooks.defineLocale('ml', {
  26604. months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
  26605. monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
  26606. monthsParseExact : true,
  26607. weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
  26608. weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
  26609. weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
  26610. longDateFormat : {
  26611. LT : 'A h:mm -നു',
  26612. LTS : 'A h:mm:ss -നു',
  26613. L : 'DD/MM/YYYY',
  26614. LL : 'D MMMM YYYY',
  26615. LLL : 'D MMMM YYYY, A h:mm -നു',
  26616. LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
  26617. },
  26618. calendar : {
  26619. sameDay : '[ഇന്ന്] LT',
  26620. nextDay : '[നാളെ] LT',
  26621. nextWeek : 'dddd, LT',
  26622. lastDay : '[ഇന്നലെ] LT',
  26623. lastWeek : '[കഴിഞ്ഞ] dddd, LT',
  26624. sameElse : 'L'
  26625. },
  26626. relativeTime : {
  26627. future : '%s കഴിഞ്ഞ്',
  26628. past : '%s മുൻപ്',
  26629. s : 'അൽപ നിമിഷങ്ങൾ',
  26630. m : 'ഒരു മിനിറ്റ്',
  26631. mm : '%d മിനിറ്റ്',
  26632. h : 'ഒരു മണിക്കൂർ',
  26633. hh : '%d മണിക്കൂർ',
  26634. d : 'ഒരു ദിവസം',
  26635. dd : '%d ദിവസം',
  26636. M : 'ഒരു മാസം',
  26637. MM : '%d മാസം',
  26638. y : 'ഒരു വർഷം',
  26639. yy : '%d വർഷം'
  26640. },
  26641. meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
  26642. meridiemHour : function (hour, meridiem) {
  26643. if (hour === 12) {
  26644. hour = 0;
  26645. }
  26646. if ((meridiem === 'രാത്രി' && hour >= 4) ||
  26647. meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
  26648. meridiem === 'വൈകുന്നേരം') {
  26649. return hour + 12;
  26650. } else {
  26651. return hour;
  26652. }
  26653. },
  26654. meridiem : function (hour, minute, isLower) {
  26655. if (hour < 4) {
  26656. return 'രാത്രി';
  26657. } else if (hour < 12) {
  26658. return 'രാവിലെ';
  26659. } else if (hour < 17) {
  26660. return 'ഉച്ച കഴിഞ്ഞ്';
  26661. } else if (hour < 20) {
  26662. return 'വൈകുന്നേരം';
  26663. } else {
  26664. return 'രാത്രി';
  26665. }
  26666. }
  26667. });
  26668. //! moment.js locale configuration
  26669. //! locale : Marathi [mr]
  26670. //! author : Harshad Kale : https://github.com/kalehv
  26671. //! author : Vivek Athalye : https://github.com/vnathalye
  26672. var symbolMap$9 = {
  26673. '1': '१',
  26674. '2': '२',
  26675. '3': '३',
  26676. '4': '४',
  26677. '5': '५',
  26678. '6': '६',
  26679. '7': '७',
  26680. '8': '८',
  26681. '9': '९',
  26682. '0': '०'
  26683. };
  26684. var numberMap$8 = {
  26685. '१': '1',
  26686. '२': '2',
  26687. '३': '3',
  26688. '४': '4',
  26689. '५': '5',
  26690. '६': '6',
  26691. '७': '7',
  26692. '८': '8',
  26693. '९': '9',
  26694. '०': '0'
  26695. };
  26696. function relativeTimeMr(number, withoutSuffix, string, isFuture)
  26697. {
  26698. var output = '';
  26699. if (withoutSuffix) {
  26700. switch (string) {
  26701. case 's': output = 'काही सेकंद'; break;
  26702. case 'm': output = 'एक मिनिट'; break;
  26703. case 'mm': output = '%d मिनिटे'; break;
  26704. case 'h': output = 'एक तास'; break;
  26705. case 'hh': output = '%d तास'; break;
  26706. case 'd': output = 'एक दिवस'; break;
  26707. case 'dd': output = '%d दिवस'; break;
  26708. case 'M': output = 'एक महिना'; break;
  26709. case 'MM': output = '%d महिने'; break;
  26710. case 'y': output = 'एक वर्ष'; break;
  26711. case 'yy': output = '%d वर्षे'; break;
  26712. }
  26713. }
  26714. else {
  26715. switch (string) {
  26716. case 's': output = 'काही सेकंदां'; break;
  26717. case 'm': output = 'एका मिनिटा'; break;
  26718. case 'mm': output = '%d मिनिटां'; break;
  26719. case 'h': output = 'एका तासा'; break;
  26720. case 'hh': output = '%d तासां'; break;
  26721. case 'd': output = 'एका दिवसा'; break;
  26722. case 'dd': output = '%d दिवसां'; break;
  26723. case 'M': output = 'एका महिन्या'; break;
  26724. case 'MM': output = '%d महिन्यां'; break;
  26725. case 'y': output = 'एका वर्षा'; break;
  26726. case 'yy': output = '%d वर्षां'; break;
  26727. }
  26728. }
  26729. return output.replace(/%d/i, number);
  26730. }
  26731. hooks.defineLocale('mr', {
  26732. months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
  26733. monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
  26734. monthsParseExact : true,
  26735. weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
  26736. weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
  26737. weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
  26738. longDateFormat : {
  26739. LT : 'A h:mm वाजता',
  26740. LTS : 'A h:mm:ss वाजता',
  26741. L : 'DD/MM/YYYY',
  26742. LL : 'D MMMM YYYY',
  26743. LLL : 'D MMMM YYYY, A h:mm वाजता',
  26744. LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
  26745. },
  26746. calendar : {
  26747. sameDay : '[आज] LT',
  26748. nextDay : '[उद्या] LT',
  26749. nextWeek : 'dddd, LT',
  26750. lastDay : '[काल] LT',
  26751. lastWeek: '[मागील] dddd, LT',
  26752. sameElse : 'L'
  26753. },
  26754. relativeTime : {
  26755. future: '%sमध्ये',
  26756. past: '%sपूर्वी',
  26757. s: relativeTimeMr,
  26758. m: relativeTimeMr,
  26759. mm: relativeTimeMr,
  26760. h: relativeTimeMr,
  26761. hh: relativeTimeMr,
  26762. d: relativeTimeMr,
  26763. dd: relativeTimeMr,
  26764. M: relativeTimeMr,
  26765. MM: relativeTimeMr,
  26766. y: relativeTimeMr,
  26767. yy: relativeTimeMr
  26768. },
  26769. preparse: function (string) {
  26770. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  26771. return numberMap$8[match];
  26772. });
  26773. },
  26774. postformat: function (string) {
  26775. return string.replace(/\d/g, function (match) {
  26776. return symbolMap$9[match];
  26777. });
  26778. },
  26779. meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
  26780. meridiemHour : function (hour, meridiem) {
  26781. if (hour === 12) {
  26782. hour = 0;
  26783. }
  26784. if (meridiem === 'रात्री') {
  26785. return hour < 4 ? hour : hour + 12;
  26786. } else if (meridiem === 'सकाळी') {
  26787. return hour;
  26788. } else if (meridiem === 'दुपारी') {
  26789. return hour >= 10 ? hour : hour + 12;
  26790. } else if (meridiem === 'सायंकाळी') {
  26791. return hour + 12;
  26792. }
  26793. },
  26794. meridiem: function (hour, minute, isLower) {
  26795. if (hour < 4) {
  26796. return 'रात्री';
  26797. } else if (hour < 10) {
  26798. return 'सकाळी';
  26799. } else if (hour < 17) {
  26800. return 'दुपारी';
  26801. } else if (hour < 20) {
  26802. return 'सायंकाळी';
  26803. } else {
  26804. return 'रात्री';
  26805. }
  26806. },
  26807. week : {
  26808. dow : 0, // Sunday is the first day of the week.
  26809. doy : 6 // The week that contains Jan 1st is the first week of the year.
  26810. }
  26811. });
  26812. //! moment.js locale configuration
  26813. //! locale : Malay [ms-my]
  26814. //! note : DEPRECATED, the correct one is [ms]
  26815. //! author : Weldan Jamili : https://github.com/weldan
  26816. hooks.defineLocale('ms-my', {
  26817. months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
  26818. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
  26819. weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
  26820. weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
  26821. weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
  26822. longDateFormat : {
  26823. LT : 'HH.mm',
  26824. LTS : 'HH.mm.ss',
  26825. L : 'DD/MM/YYYY',
  26826. LL : 'D MMMM YYYY',
  26827. LLL : 'D MMMM YYYY [pukul] HH.mm',
  26828. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  26829. },
  26830. meridiemParse: /pagi|tengahari|petang|malam/,
  26831. meridiemHour: function (hour, meridiem) {
  26832. if (hour === 12) {
  26833. hour = 0;
  26834. }
  26835. if (meridiem === 'pagi') {
  26836. return hour;
  26837. } else if (meridiem === 'tengahari') {
  26838. return hour >= 11 ? hour : hour + 12;
  26839. } else if (meridiem === 'petang' || meridiem === 'malam') {
  26840. return hour + 12;
  26841. }
  26842. },
  26843. meridiem : function (hours, minutes, isLower) {
  26844. if (hours < 11) {
  26845. return 'pagi';
  26846. } else if (hours < 15) {
  26847. return 'tengahari';
  26848. } else if (hours < 19) {
  26849. return 'petang';
  26850. } else {
  26851. return 'malam';
  26852. }
  26853. },
  26854. calendar : {
  26855. sameDay : '[Hari ini pukul] LT',
  26856. nextDay : '[Esok pukul] LT',
  26857. nextWeek : 'dddd [pukul] LT',
  26858. lastDay : '[Kelmarin pukul] LT',
  26859. lastWeek : 'dddd [lepas pukul] LT',
  26860. sameElse : 'L'
  26861. },
  26862. relativeTime : {
  26863. future : 'dalam %s',
  26864. past : '%s yang lepas',
  26865. s : 'beberapa saat',
  26866. m : 'seminit',
  26867. mm : '%d minit',
  26868. h : 'sejam',
  26869. hh : '%d jam',
  26870. d : 'sehari',
  26871. dd : '%d hari',
  26872. M : 'sebulan',
  26873. MM : '%d bulan',
  26874. y : 'setahun',
  26875. yy : '%d tahun'
  26876. },
  26877. week : {
  26878. dow : 1, // Monday is the first day of the week.
  26879. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26880. }
  26881. });
  26882. //! moment.js locale configuration
  26883. //! locale : Malay [ms]
  26884. //! author : Weldan Jamili : https://github.com/weldan
  26885. hooks.defineLocale('ms', {
  26886. months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
  26887. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
  26888. weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
  26889. weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
  26890. weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
  26891. longDateFormat : {
  26892. LT : 'HH.mm',
  26893. LTS : 'HH.mm.ss',
  26894. L : 'DD/MM/YYYY',
  26895. LL : 'D MMMM YYYY',
  26896. LLL : 'D MMMM YYYY [pukul] HH.mm',
  26897. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  26898. },
  26899. meridiemParse: /pagi|tengahari|petang|malam/,
  26900. meridiemHour: function (hour, meridiem) {
  26901. if (hour === 12) {
  26902. hour = 0;
  26903. }
  26904. if (meridiem === 'pagi') {
  26905. return hour;
  26906. } else if (meridiem === 'tengahari') {
  26907. return hour >= 11 ? hour : hour + 12;
  26908. } else if (meridiem === 'petang' || meridiem === 'malam') {
  26909. return hour + 12;
  26910. }
  26911. },
  26912. meridiem : function (hours, minutes, isLower) {
  26913. if (hours < 11) {
  26914. return 'pagi';
  26915. } else if (hours < 15) {
  26916. return 'tengahari';
  26917. } else if (hours < 19) {
  26918. return 'petang';
  26919. } else {
  26920. return 'malam';
  26921. }
  26922. },
  26923. calendar : {
  26924. sameDay : '[Hari ini pukul] LT',
  26925. nextDay : '[Esok pukul] LT',
  26926. nextWeek : 'dddd [pukul] LT',
  26927. lastDay : '[Kelmarin pukul] LT',
  26928. lastWeek : 'dddd [lepas pukul] LT',
  26929. sameElse : 'L'
  26930. },
  26931. relativeTime : {
  26932. future : 'dalam %s',
  26933. past : '%s yang lepas',
  26934. s : 'beberapa saat',
  26935. m : 'seminit',
  26936. mm : '%d minit',
  26937. h : 'sejam',
  26938. hh : '%d jam',
  26939. d : 'sehari',
  26940. dd : '%d hari',
  26941. M : 'sebulan',
  26942. MM : '%d bulan',
  26943. y : 'setahun',
  26944. yy : '%d tahun'
  26945. },
  26946. week : {
  26947. dow : 1, // Monday is the first day of the week.
  26948. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26949. }
  26950. });
  26951. //! moment.js locale configuration
  26952. //! locale : Burmese [my]
  26953. //! author : Squar team, mysquar.com
  26954. //! author : David Rossellat : https://github.com/gholadr
  26955. //! author : Tin Aung Lin : https://github.com/thanyawzinmin
  26956. var symbolMap$10 = {
  26957. '1': '၁',
  26958. '2': '၂',
  26959. '3': '၃',
  26960. '4': '၄',
  26961. '5': '၅',
  26962. '6': '၆',
  26963. '7': '၇',
  26964. '8': '၈',
  26965. '9': '၉',
  26966. '0': '၀'
  26967. };
  26968. var numberMap$9 = {
  26969. '၁': '1',
  26970. '၂': '2',
  26971. '၃': '3',
  26972. '၄': '4',
  26973. '၅': '5',
  26974. '၆': '6',
  26975. '၇': '7',
  26976. '၈': '8',
  26977. '၉': '9',
  26978. '၀': '0'
  26979. };
  26980. hooks.defineLocale('my', {
  26981. months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
  26982. monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
  26983. weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
  26984. weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
  26985. weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
  26986. longDateFormat: {
  26987. LT: 'HH:mm',
  26988. LTS: 'HH:mm:ss',
  26989. L: 'DD/MM/YYYY',
  26990. LL: 'D MMMM YYYY',
  26991. LLL: 'D MMMM YYYY HH:mm',
  26992. LLLL: 'dddd D MMMM YYYY HH:mm'
  26993. },
  26994. calendar: {
  26995. sameDay: '[ယနေ.] LT [မှာ]',
  26996. nextDay: '[မနက်ဖြန်] LT [မှာ]',
  26997. nextWeek: 'dddd LT [မှာ]',
  26998. lastDay: '[မနေ.က] LT [မှာ]',
  26999. lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
  27000. sameElse: 'L'
  27001. },
  27002. relativeTime: {
  27003. future: 'လာမည့် %s မှာ',
  27004. past: 'လွန်ခဲ့သော %s က',
  27005. s: 'စက္ကန်.အနည်းငယ်',
  27006. m: 'တစ်မိနစ်',
  27007. mm: '%d မိနစ်',
  27008. h: 'တစ်နာရီ',
  27009. hh: '%d နာရီ',
  27010. d: 'တစ်ရက်',
  27011. dd: '%d ရက်',
  27012. M: 'တစ်လ',
  27013. MM: '%d လ',
  27014. y: 'တစ်နှစ်',
  27015. yy: '%d နှစ်'
  27016. },
  27017. preparse: function (string) {
  27018. return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
  27019. return numberMap$9[match];
  27020. });
  27021. },
  27022. postformat: function (string) {
  27023. return string.replace(/\d/g, function (match) {
  27024. return symbolMap$10[match];
  27025. });
  27026. },
  27027. week: {
  27028. dow: 1, // Monday is the first day of the week.
  27029. doy: 4 // The week that contains Jan 1st is the first week of the year.
  27030. }
  27031. });
  27032. //! moment.js locale configuration
  27033. //! locale : Norwegian Bokmål [nb]
  27034. //! authors : Espen Hovlandsdal : https://github.com/rexxars
  27035. //! Sigurd Gartmann : https://github.com/sigurdga
  27036. hooks.defineLocale('nb', {
  27037. months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  27038. monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
  27039. monthsParseExact : true,
  27040. weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
  27041. weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
  27042. weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
  27043. weekdaysParseExact : true,
  27044. longDateFormat : {
  27045. LT : 'HH:mm',
  27046. LTS : 'HH:mm:ss',
  27047. L : 'DD.MM.YYYY',
  27048. LL : 'D. MMMM YYYY',
  27049. LLL : 'D. MMMM YYYY [kl.] HH:mm',
  27050. LLLL : 'dddd D. MMMM YYYY [kl.] HH:mm'
  27051. },
  27052. calendar : {
  27053. sameDay: '[i dag kl.] LT',
  27054. nextDay: '[i morgen kl.] LT',
  27055. nextWeek: 'dddd [kl.] LT',
  27056. lastDay: '[i går kl.] LT',
  27057. lastWeek: '[forrige] dddd [kl.] LT',
  27058. sameElse: 'L'
  27059. },
  27060. relativeTime : {
  27061. future : 'om %s',
  27062. past : '%s siden',
  27063. s : 'noen sekunder',
  27064. m : 'ett minutt',
  27065. mm : '%d minutter',
  27066. h : 'en time',
  27067. hh : '%d timer',
  27068. d : 'en dag',
  27069. dd : '%d dager',
  27070. M : 'en måned',
  27071. MM : '%d måneder',
  27072. y : 'ett år',
  27073. yy : '%d år'
  27074. },
  27075. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27076. ordinal : '%d.',
  27077. week : {
  27078. dow : 1, // Monday is the first day of the week.
  27079. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27080. }
  27081. });
  27082. //! moment.js locale configuration
  27083. //! locale : Nepalese [ne]
  27084. //! author : suvash : https://github.com/suvash
  27085. var symbolMap$11 = {
  27086. '1': '१',
  27087. '2': '२',
  27088. '3': '३',
  27089. '4': '४',
  27090. '5': '५',
  27091. '6': '६',
  27092. '7': '७',
  27093. '8': '८',
  27094. '9': '९',
  27095. '0': '०'
  27096. };
  27097. var numberMap$10 = {
  27098. '१': '1',
  27099. '२': '2',
  27100. '३': '3',
  27101. '४': '4',
  27102. '५': '5',
  27103. '६': '6',
  27104. '७': '7',
  27105. '८': '8',
  27106. '९': '9',
  27107. '०': '0'
  27108. };
  27109. hooks.defineLocale('ne', {
  27110. months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
  27111. monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
  27112. monthsParseExact : true,
  27113. weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
  27114. weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
  27115. weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
  27116. weekdaysParseExact : true,
  27117. longDateFormat : {
  27118. LT : 'Aको h:mm बजे',
  27119. LTS : 'Aको h:mm:ss बजे',
  27120. L : 'DD/MM/YYYY',
  27121. LL : 'D MMMM YYYY',
  27122. LLL : 'D MMMM YYYY, Aको h:mm बजे',
  27123. LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
  27124. },
  27125. preparse: function (string) {
  27126. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  27127. return numberMap$10[match];
  27128. });
  27129. },
  27130. postformat: function (string) {
  27131. return string.replace(/\d/g, function (match) {
  27132. return symbolMap$11[match];
  27133. });
  27134. },
  27135. meridiemParse: /राति|बिहान|दिउँसो|साँझ/,
  27136. meridiemHour : function (hour, meridiem) {
  27137. if (hour === 12) {
  27138. hour = 0;
  27139. }
  27140. if (meridiem === 'राति') {
  27141. return hour < 4 ? hour : hour + 12;
  27142. } else if (meridiem === 'बिहान') {
  27143. return hour;
  27144. } else if (meridiem === 'दिउँसो') {
  27145. return hour >= 10 ? hour : hour + 12;
  27146. } else if (meridiem === 'साँझ') {
  27147. return hour + 12;
  27148. }
  27149. },
  27150. meridiem : function (hour, minute, isLower) {
  27151. if (hour < 3) {
  27152. return 'राति';
  27153. } else if (hour < 12) {
  27154. return 'बिहान';
  27155. } else if (hour < 16) {
  27156. return 'दिउँसो';
  27157. } else if (hour < 20) {
  27158. return 'साँझ';
  27159. } else {
  27160. return 'राति';
  27161. }
  27162. },
  27163. calendar : {
  27164. sameDay : '[आज] LT',
  27165. nextDay : '[भोलि] LT',
  27166. nextWeek : '[आउँदो] dddd[,] LT',
  27167. lastDay : '[हिजो] LT',
  27168. lastWeek : '[गएको] dddd[,] LT',
  27169. sameElse : 'L'
  27170. },
  27171. relativeTime : {
  27172. future : '%sमा',
  27173. past : '%s अगाडि',
  27174. s : 'केही क्षण',
  27175. m : 'एक मिनेट',
  27176. mm : '%d मिनेट',
  27177. h : 'एक घण्टा',
  27178. hh : '%d घण्टा',
  27179. d : 'एक दिन',
  27180. dd : '%d दिन',
  27181. M : 'एक महिना',
  27182. MM : '%d महिना',
  27183. y : 'एक बर्ष',
  27184. yy : '%d बर्ष'
  27185. },
  27186. week : {
  27187. dow : 0, // Sunday is the first day of the week.
  27188. doy : 6 // The week that contains Jan 1st is the first week of the year.
  27189. }
  27190. });
  27191. //! moment.js locale configuration
  27192. //! locale : Dutch (Belgium) [nl-be]
  27193. //! author : Joris Röling : https://github.com/jorisroling
  27194. //! author : Jacob Middag : https://github.com/middagj
  27195. var monthsShortWithDots$1 = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
  27196. var monthsShortWithoutDots$1 = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
  27197. var monthsParse$2 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
  27198. var monthsRegex$3 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
  27199. hooks.defineLocale('nl-be', {
  27200. months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
  27201. monthsShort : function (m, format) {
  27202. if (!m) {
  27203. return monthsShortWithDots$1;
  27204. } else if (/-MMM-/.test(format)) {
  27205. return monthsShortWithoutDots$1[m.month()];
  27206. } else {
  27207. return monthsShortWithDots$1[m.month()];
  27208. }
  27209. },
  27210. monthsRegex: monthsRegex$3,
  27211. monthsShortRegex: monthsRegex$3,
  27212. monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
  27213. monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
  27214. monthsParse : monthsParse$2,
  27215. longMonthsParse : monthsParse$2,
  27216. shortMonthsParse : monthsParse$2,
  27217. weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
  27218. weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
  27219. weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
  27220. weekdaysParseExact : true,
  27221. longDateFormat : {
  27222. LT : 'HH:mm',
  27223. LTS : 'HH:mm:ss',
  27224. L : 'DD/MM/YYYY',
  27225. LL : 'D MMMM YYYY',
  27226. LLL : 'D MMMM YYYY HH:mm',
  27227. LLLL : 'dddd D MMMM YYYY HH:mm'
  27228. },
  27229. calendar : {
  27230. sameDay: '[vandaag om] LT',
  27231. nextDay: '[morgen om] LT',
  27232. nextWeek: 'dddd [om] LT',
  27233. lastDay: '[gisteren om] LT',
  27234. lastWeek: '[afgelopen] dddd [om] LT',
  27235. sameElse: 'L'
  27236. },
  27237. relativeTime : {
  27238. future : 'over %s',
  27239. past : '%s geleden',
  27240. s : 'een paar seconden',
  27241. m : 'één minuut',
  27242. mm : '%d minuten',
  27243. h : 'één uur',
  27244. hh : '%d uur',
  27245. d : 'één dag',
  27246. dd : '%d dagen',
  27247. M : 'één maand',
  27248. MM : '%d maanden',
  27249. y : 'één jaar',
  27250. yy : '%d jaar'
  27251. },
  27252. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  27253. ordinal : function (number) {
  27254. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  27255. },
  27256. week : {
  27257. dow : 1, // Monday is the first day of the week.
  27258. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27259. }
  27260. });
  27261. //! moment.js locale configuration
  27262. //! locale : Dutch [nl]
  27263. //! author : Joris Röling : https://github.com/jorisroling
  27264. //! author : Jacob Middag : https://github.com/middagj
  27265. var monthsShortWithDots$2 = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
  27266. var monthsShortWithoutDots$2 = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
  27267. var monthsParse$3 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
  27268. var monthsRegex$4 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
  27269. hooks.defineLocale('nl', {
  27270. months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
  27271. monthsShort : function (m, format) {
  27272. if (!m) {
  27273. return monthsShortWithDots$2;
  27274. } else if (/-MMM-/.test(format)) {
  27275. return monthsShortWithoutDots$2[m.month()];
  27276. } else {
  27277. return monthsShortWithDots$2[m.month()];
  27278. }
  27279. },
  27280. monthsRegex: monthsRegex$4,
  27281. monthsShortRegex: monthsRegex$4,
  27282. monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
  27283. monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
  27284. monthsParse : monthsParse$3,
  27285. longMonthsParse : monthsParse$3,
  27286. shortMonthsParse : monthsParse$3,
  27287. weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
  27288. weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
  27289. weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
  27290. weekdaysParseExact : true,
  27291. longDateFormat : {
  27292. LT : 'HH:mm',
  27293. LTS : 'HH:mm:ss',
  27294. L : 'DD-MM-YYYY',
  27295. LL : 'D MMMM YYYY',
  27296. LLL : 'D MMMM YYYY HH:mm',
  27297. LLLL : 'dddd D MMMM YYYY HH:mm'
  27298. },
  27299. calendar : {
  27300. sameDay: '[vandaag om] LT',
  27301. nextDay: '[morgen om] LT',
  27302. nextWeek: 'dddd [om] LT',
  27303. lastDay: '[gisteren om] LT',
  27304. lastWeek: '[afgelopen] dddd [om] LT',
  27305. sameElse: 'L'
  27306. },
  27307. relativeTime : {
  27308. future : 'over %s',
  27309. past : '%s geleden',
  27310. s : 'een paar seconden',
  27311. m : 'één minuut',
  27312. mm : '%d minuten',
  27313. h : 'één uur',
  27314. hh : '%d uur',
  27315. d : 'één dag',
  27316. dd : '%d dagen',
  27317. M : 'één maand',
  27318. MM : '%d maanden',
  27319. y : 'één jaar',
  27320. yy : '%d jaar'
  27321. },
  27322. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  27323. ordinal : function (number) {
  27324. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  27325. },
  27326. week : {
  27327. dow : 1, // Monday is the first day of the week.
  27328. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27329. }
  27330. });
  27331. //! moment.js locale configuration
  27332. //! locale : Nynorsk [nn]
  27333. //! author : https://github.com/mechuwind
  27334. hooks.defineLocale('nn', {
  27335. months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  27336. monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
  27337. weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
  27338. weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
  27339. weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
  27340. longDateFormat : {
  27341. LT : 'HH:mm',
  27342. LTS : 'HH:mm:ss',
  27343. L : 'DD.MM.YYYY',
  27344. LL : 'D. MMMM YYYY',
  27345. LLL : 'D. MMMM YYYY [kl.] H:mm',
  27346. LLLL : 'dddd D. MMMM YYYY [kl.] HH:mm'
  27347. },
  27348. calendar : {
  27349. sameDay: '[I dag klokka] LT',
  27350. nextDay: '[I morgon klokka] LT',
  27351. nextWeek: 'dddd [klokka] LT',
  27352. lastDay: '[I går klokka] LT',
  27353. lastWeek: '[Føregåande] dddd [klokka] LT',
  27354. sameElse: 'L'
  27355. },
  27356. relativeTime : {
  27357. future : 'om %s',
  27358. past : '%s sidan',
  27359. s : 'nokre sekund',
  27360. m : 'eit minutt',
  27361. mm : '%d minutt',
  27362. h : 'ein time',
  27363. hh : '%d timar',
  27364. d : 'ein dag',
  27365. dd : '%d dagar',
  27366. M : 'ein månad',
  27367. MM : '%d månader',
  27368. y : 'eit år',
  27369. yy : '%d år'
  27370. },
  27371. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27372. ordinal : '%d.',
  27373. week : {
  27374. dow : 1, // Monday is the first day of the week.
  27375. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27376. }
  27377. });
  27378. //! moment.js locale configuration
  27379. //! locale : Punjabi (India) [pa-in]
  27380. //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
  27381. var symbolMap$12 = {
  27382. '1': '੧',
  27383. '2': '੨',
  27384. '3': '੩',
  27385. '4': '੪',
  27386. '5': '੫',
  27387. '6': '੬',
  27388. '7': '੭',
  27389. '8': '੮',
  27390. '9': '੯',
  27391. '0': '੦'
  27392. };
  27393. var numberMap$11 = {
  27394. '੧': '1',
  27395. '੨': '2',
  27396. '੩': '3',
  27397. '੪': '4',
  27398. '੫': '5',
  27399. '੬': '6',
  27400. '੭': '7',
  27401. '੮': '8',
  27402. '੯': '9',
  27403. '੦': '0'
  27404. };
  27405. hooks.defineLocale('pa-in', {
  27406. // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
  27407. months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
  27408. monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
  27409. weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
  27410. weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  27411. weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  27412. longDateFormat : {
  27413. LT : 'A h:mm ਵਜੇ',
  27414. LTS : 'A h:mm:ss ਵਜੇ',
  27415. L : 'DD/MM/YYYY',
  27416. LL : 'D MMMM YYYY',
  27417. LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
  27418. LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
  27419. },
  27420. calendar : {
  27421. sameDay : '[ਅਜ] LT',
  27422. nextDay : '[ਕਲ] LT',
  27423. nextWeek : 'dddd, LT',
  27424. lastDay : '[ਕਲ] LT',
  27425. lastWeek : '[ਪਿਛਲੇ] dddd, LT',
  27426. sameElse : 'L'
  27427. },
  27428. relativeTime : {
  27429. future : '%s ਵਿੱਚ',
  27430. past : '%s ਪਿਛਲੇ',
  27431. s : 'ਕੁਝ ਸਕਿੰਟ',
  27432. m : 'ਇਕ ਮਿੰਟ',
  27433. mm : '%d ਮਿੰਟ',
  27434. h : 'ਇੱਕ ਘੰਟਾ',
  27435. hh : '%d ਘੰਟੇ',
  27436. d : 'ਇੱਕ ਦਿਨ',
  27437. dd : '%d ਦਿਨ',
  27438. M : 'ਇੱਕ ਮਹੀਨਾ',
  27439. MM : '%d ਮਹੀਨੇ',
  27440. y : 'ਇੱਕ ਸਾਲ',
  27441. yy : '%d ਸਾਲ'
  27442. },
  27443. preparse: function (string) {
  27444. return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
  27445. return numberMap$11[match];
  27446. });
  27447. },
  27448. postformat: function (string) {
  27449. return string.replace(/\d/g, function (match) {
  27450. return symbolMap$12[match];
  27451. });
  27452. },
  27453. // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
  27454. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
  27455. meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
  27456. meridiemHour : function (hour, meridiem) {
  27457. if (hour === 12) {
  27458. hour = 0;
  27459. }
  27460. if (meridiem === 'ਰਾਤ') {
  27461. return hour < 4 ? hour : hour + 12;
  27462. } else if (meridiem === 'ਸਵੇਰ') {
  27463. return hour;
  27464. } else if (meridiem === 'ਦੁਪਹਿਰ') {
  27465. return hour >= 10 ? hour : hour + 12;
  27466. } else if (meridiem === 'ਸ਼ਾਮ') {
  27467. return hour + 12;
  27468. }
  27469. },
  27470. meridiem : function (hour, minute, isLower) {
  27471. if (hour < 4) {
  27472. return 'ਰਾਤ';
  27473. } else if (hour < 10) {
  27474. return 'ਸਵੇਰ';
  27475. } else if (hour < 17) {
  27476. return 'ਦੁਪਹਿਰ';
  27477. } else if (hour < 20) {
  27478. return 'ਸ਼ਾਮ';
  27479. } else {
  27480. return 'ਰਾਤ';
  27481. }
  27482. },
  27483. week : {
  27484. dow : 0, // Sunday is the first day of the week.
  27485. doy : 6 // The week that contains Jan 1st is the first week of the year.
  27486. }
  27487. });
  27488. //! moment.js locale configuration
  27489. //! locale : Polish [pl]
  27490. //! author : Rafal Hirsz : https://github.com/evoL
  27491. var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_');
  27492. var monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
  27493. function plural$3(n) {
  27494. return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
  27495. }
  27496. function translate$7(number, withoutSuffix, key) {
  27497. var result = number + ' ';
  27498. switch (key) {
  27499. case 'm':
  27500. return withoutSuffix ? 'minuta' : 'minutę';
  27501. case 'mm':
  27502. return result + (plural$3(number) ? 'minuty' : 'minut');
  27503. case 'h':
  27504. return withoutSuffix ? 'godzina' : 'godzinę';
  27505. case 'hh':
  27506. return result + (plural$3(number) ? 'godziny' : 'godzin');
  27507. case 'MM':
  27508. return result + (plural$3(number) ? 'miesiące' : 'miesięcy');
  27509. case 'yy':
  27510. return result + (plural$3(number) ? 'lata' : 'lat');
  27511. }
  27512. }
  27513. hooks.defineLocale('pl', {
  27514. months : function (momentToFormat, format) {
  27515. if (!momentToFormat) {
  27516. return monthsNominative;
  27517. } else if (format === '') {
  27518. // Hack: if format empty we know this is used to generate
  27519. // RegExp by moment. Give then back both valid forms of months
  27520. // in RegExp ready format.
  27521. return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
  27522. } else if (/D MMMM/.test(format)) {
  27523. return monthsSubjective[momentToFormat.month()];
  27524. } else {
  27525. return monthsNominative[momentToFormat.month()];
  27526. }
  27527. },
  27528. monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
  27529. weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
  27530. weekdaysShort : 'ndz_pon_wt_śr_czw_pt_sob'.split('_'),
  27531. weekdaysMin : 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
  27532. longDateFormat : {
  27533. LT : 'HH:mm',
  27534. LTS : 'HH:mm:ss',
  27535. L : 'DD.MM.YYYY',
  27536. LL : 'D MMMM YYYY',
  27537. LLL : 'D MMMM YYYY HH:mm',
  27538. LLLL : 'dddd, D MMMM YYYY HH:mm'
  27539. },
  27540. calendar : {
  27541. sameDay: '[Dziś o] LT',
  27542. nextDay: '[Jutro o] LT',
  27543. nextWeek: function () {
  27544. switch (this.day()) {
  27545. case 0:
  27546. return '[W niedzielę o] LT';
  27547. case 2:
  27548. return '[We wtorek o] LT';
  27549. case 3:
  27550. return '[W środę o] LT';
  27551. case 6:
  27552. return '[W sobotę o] LT';
  27553. default:
  27554. return '[W] dddd [o] LT';
  27555. }
  27556. },
  27557. lastDay: '[Wczoraj o] LT',
  27558. lastWeek: function () {
  27559. switch (this.day()) {
  27560. case 0:
  27561. return '[W zeszłą niedzielę o] LT';
  27562. case 3:
  27563. return '[W zeszłą środę o] LT';
  27564. case 6:
  27565. return '[W zeszłą sobotę o] LT';
  27566. default:
  27567. return '[W zeszły] dddd [o] LT';
  27568. }
  27569. },
  27570. sameElse: 'L'
  27571. },
  27572. relativeTime : {
  27573. future : 'za %s',
  27574. past : '%s temu',
  27575. s : 'kilka sekund',
  27576. m : translate$7,
  27577. mm : translate$7,
  27578. h : translate$7,
  27579. hh : translate$7,
  27580. d : '1 dzień',
  27581. dd : '%d dni',
  27582. M : 'miesiąc',
  27583. MM : translate$7,
  27584. y : 'rok',
  27585. yy : translate$7
  27586. },
  27587. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27588. ordinal : '%d.',
  27589. week : {
  27590. dow : 1, // Monday is the first day of the week.
  27591. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27592. }
  27593. });
  27594. //! moment.js locale configuration
  27595. //! locale : Portuguese (Brazil) [pt-br]
  27596. //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
  27597. hooks.defineLocale('pt-br', {
  27598. months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
  27599. monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
  27600. weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
  27601. weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
  27602. weekdaysMin : 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'),
  27603. weekdaysParseExact : true,
  27604. longDateFormat : {
  27605. LT : 'HH:mm',
  27606. LTS : 'HH:mm:ss',
  27607. L : 'DD/MM/YYYY',
  27608. LL : 'D [de] MMMM [de] YYYY',
  27609. LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
  27610. LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
  27611. },
  27612. calendar : {
  27613. sameDay: '[Hoje às] LT',
  27614. nextDay: '[Amanhã às] LT',
  27615. nextWeek: 'dddd [às] LT',
  27616. lastDay: '[Ontem às] LT',
  27617. lastWeek: function () {
  27618. return (this.day() === 0 || this.day() === 6) ?
  27619. '[Último] dddd [às] LT' : // Saturday + Sunday
  27620. '[Última] dddd [às] LT'; // Monday - Friday
  27621. },
  27622. sameElse: 'L'
  27623. },
  27624. relativeTime : {
  27625. future : 'em %s',
  27626. past : '%s atrás',
  27627. s : 'poucos segundos',
  27628. ss : '%d segundos',
  27629. m : 'um minuto',
  27630. mm : '%d minutos',
  27631. h : 'uma hora',
  27632. hh : '%d horas',
  27633. d : 'um dia',
  27634. dd : '%d dias',
  27635. M : 'um mês',
  27636. MM : '%d meses',
  27637. y : 'um ano',
  27638. yy : '%d anos'
  27639. },
  27640. dayOfMonthOrdinalParse: /\d{1,2}º/,
  27641. ordinal : '%dº'
  27642. });
  27643. //! moment.js locale configuration
  27644. //! locale : Portuguese [pt]
  27645. //! author : Jefferson : https://github.com/jalex79
  27646. hooks.defineLocale('pt', {
  27647. months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
  27648. monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
  27649. weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
  27650. weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
  27651. weekdaysMin : 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'),
  27652. weekdaysParseExact : true,
  27653. longDateFormat : {
  27654. LT : 'HH:mm',
  27655. LTS : 'HH:mm:ss',
  27656. L : 'DD/MM/YYYY',
  27657. LL : 'D [de] MMMM [de] YYYY',
  27658. LLL : 'D [de] MMMM [de] YYYY HH:mm',
  27659. LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
  27660. },
  27661. calendar : {
  27662. sameDay: '[Hoje às] LT',
  27663. nextDay: '[Amanhã às] LT',
  27664. nextWeek: 'dddd [às] LT',
  27665. lastDay: '[Ontem às] LT',
  27666. lastWeek: function () {
  27667. return (this.day() === 0 || this.day() === 6) ?
  27668. '[Último] dddd [às] LT' : // Saturday + Sunday
  27669. '[Última] dddd [às] LT'; // Monday - Friday
  27670. },
  27671. sameElse: 'L'
  27672. },
  27673. relativeTime : {
  27674. future : 'em %s',
  27675. past : 'há %s',
  27676. s : 'segundos',
  27677. m : 'um minuto',
  27678. mm : '%d minutos',
  27679. h : 'uma hora',
  27680. hh : '%d horas',
  27681. d : 'um dia',
  27682. dd : '%d dias',
  27683. M : 'um mês',
  27684. MM : '%d meses',
  27685. y : 'um ano',
  27686. yy : '%d anos'
  27687. },
  27688. dayOfMonthOrdinalParse: /\d{1,2}º/,
  27689. ordinal : '%dº',
  27690. week : {
  27691. dow : 1, // Monday is the first day of the week.
  27692. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27693. }
  27694. });
  27695. //! moment.js locale configuration
  27696. //! locale : Romanian [ro]
  27697. //! author : Vlad Gurdiga : https://github.com/gurdiga
  27698. //! author : Valentin Agachi : https://github.com/avaly
  27699. function relativeTimeWithPlural$2(number, withoutSuffix, key) {
  27700. var format = {
  27701. 'mm': 'minute',
  27702. 'hh': 'ore',
  27703. 'dd': 'zile',
  27704. 'MM': 'luni',
  27705. 'yy': 'ani'
  27706. },
  27707. separator = ' ';
  27708. if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
  27709. separator = ' de ';
  27710. }
  27711. return number + separator + format[key];
  27712. }
  27713. hooks.defineLocale('ro', {
  27714. months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
  27715. monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
  27716. monthsParseExact: true,
  27717. weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
  27718. weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
  27719. weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
  27720. longDateFormat : {
  27721. LT : 'H:mm',
  27722. LTS : 'H:mm:ss',
  27723. L : 'DD.MM.YYYY',
  27724. LL : 'D MMMM YYYY',
  27725. LLL : 'D MMMM YYYY H:mm',
  27726. LLLL : 'dddd, D MMMM YYYY H:mm'
  27727. },
  27728. calendar : {
  27729. sameDay: '[azi la] LT',
  27730. nextDay: '[mâine la] LT',
  27731. nextWeek: 'dddd [la] LT',
  27732. lastDay: '[ieri la] LT',
  27733. lastWeek: '[fosta] dddd [la] LT',
  27734. sameElse: 'L'
  27735. },
  27736. relativeTime : {
  27737. future : 'peste %s',
  27738. past : '%s în urmă',
  27739. s : 'câteva secunde',
  27740. m : 'un minut',
  27741. mm : relativeTimeWithPlural$2,
  27742. h : 'o oră',
  27743. hh : relativeTimeWithPlural$2,
  27744. d : 'o zi',
  27745. dd : relativeTimeWithPlural$2,
  27746. M : 'o lună',
  27747. MM : relativeTimeWithPlural$2,
  27748. y : 'un an',
  27749. yy : relativeTimeWithPlural$2
  27750. },
  27751. week : {
  27752. dow : 1, // Monday is the first day of the week.
  27753. doy : 7 // The week that contains Jan 1st is the first week of the year.
  27754. }
  27755. });
  27756. //! moment.js locale configuration
  27757. //! locale : Russian [ru]
  27758. //! author : Viktorminator : https://github.com/Viktorminator
  27759. //! Author : Menelion Elensúle : https://github.com/Oire
  27760. //! author : Коренберг Марк : https://github.com/socketpair
  27761. function plural$4(word, num) {
  27762. var forms = word.split('_');
  27763. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  27764. }
  27765. function relativeTimeWithPlural$3(number, withoutSuffix, key) {
  27766. var format = {
  27767. 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
  27768. 'hh': 'час_часа_часов',
  27769. 'dd': 'день_дня_дней',
  27770. 'MM': 'месяц_месяца_месяцев',
  27771. 'yy': 'год_года_лет'
  27772. };
  27773. if (key === 'm') {
  27774. return withoutSuffix ? 'минута' : 'минуту';
  27775. }
  27776. else {
  27777. return number + ' ' + plural$4(format[key], +number);
  27778. }
  27779. }
  27780. var monthsParse$4 = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
  27781. // http://new.gramota.ru/spravka/rules/139-prop : § 103
  27782. // Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
  27783. // CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
  27784. hooks.defineLocale('ru', {
  27785. months : {
  27786. format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
  27787. standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
  27788. },
  27789. monthsShort : {
  27790. // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
  27791. format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
  27792. standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
  27793. },
  27794. weekdays : {
  27795. standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
  27796. format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
  27797. isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
  27798. },
  27799. weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
  27800. weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
  27801. monthsParse : monthsParse$4,
  27802. longMonthsParse : monthsParse$4,
  27803. shortMonthsParse : monthsParse$4,
  27804. // полные названия с падежами, по три буквы, для некоторых, по 4 буквы, сокращения с точкой и без точки
  27805. monthsRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
  27806. // копия предыдущего
  27807. monthsShortRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
  27808. // полные названия с падежами
  27809. monthsStrictRegex: /^(январ[яь]|феврал[яь]|марта?|апрел[яь]|ма[яй]|июн[яь]|июл[яь]|августа?|сентябр[яь]|октябр[яь]|ноябр[яь]|декабр[яь])/i,
  27810. // Выражение, которое соотвествует только сокращённым формам
  27811. monthsShortStrictRegex: /^(янв\.|февр?\.|мар[т.]|апр\.|ма[яй]|июн[ья.]|июл[ья.]|авг\.|сент?\.|окт\.|нояб?\.|дек\.)/i,
  27812. longDateFormat : {
  27813. LT : 'HH:mm',
  27814. LTS : 'HH:mm:ss',
  27815. L : 'DD.MM.YYYY',
  27816. LL : 'D MMMM YYYY г.',
  27817. LLL : 'D MMMM YYYY г., HH:mm',
  27818. LLLL : 'dddd, D MMMM YYYY г., HH:mm'
  27819. },
  27820. calendar : {
  27821. sameDay: '[Сегодня в] LT',
  27822. nextDay: '[Завтра в] LT',
  27823. lastDay: '[Вчера в] LT',
  27824. nextWeek: function (now) {
  27825. if (now.week() !== this.week()) {
  27826. switch (this.day()) {
  27827. case 0:
  27828. return '[В следующее] dddd [в] LT';
  27829. case 1:
  27830. case 2:
  27831. case 4:
  27832. return '[В следующий] dddd [в] LT';
  27833. case 3:
  27834. case 5:
  27835. case 6:
  27836. return '[В следующую] dddd [в] LT';
  27837. }
  27838. } else {
  27839. if (this.day() === 2) {
  27840. return '[Во] dddd [в] LT';
  27841. } else {
  27842. return '[В] dddd [в] LT';
  27843. }
  27844. }
  27845. },
  27846. lastWeek: function (now) {
  27847. if (now.week() !== this.week()) {
  27848. switch (this.day()) {
  27849. case 0:
  27850. return '[В прошлое] dddd [в] LT';
  27851. case 1:
  27852. case 2:
  27853. case 4:
  27854. return '[В прошлый] dddd [в] LT';
  27855. case 3:
  27856. case 5:
  27857. case 6:
  27858. return '[В прошлую] dddd [в] LT';
  27859. }
  27860. } else {
  27861. if (this.day() === 2) {
  27862. return '[Во] dddd [в] LT';
  27863. } else {
  27864. return '[В] dddd [в] LT';
  27865. }
  27866. }
  27867. },
  27868. sameElse: 'L'
  27869. },
  27870. relativeTime : {
  27871. future : 'через %s',
  27872. past : '%s назад',
  27873. s : 'несколько секунд',
  27874. m : relativeTimeWithPlural$3,
  27875. mm : relativeTimeWithPlural$3,
  27876. h : 'час',
  27877. hh : relativeTimeWithPlural$3,
  27878. d : 'день',
  27879. dd : relativeTimeWithPlural$3,
  27880. M : 'месяц',
  27881. MM : relativeTimeWithPlural$3,
  27882. y : 'год',
  27883. yy : relativeTimeWithPlural$3
  27884. },
  27885. meridiemParse: /ночи|утра|дня|вечера/i,
  27886. isPM : function (input) {
  27887. return /^(дня|вечера)$/.test(input);
  27888. },
  27889. meridiem : function (hour, minute, isLower) {
  27890. if (hour < 4) {
  27891. return 'ночи';
  27892. } else if (hour < 12) {
  27893. return 'утра';
  27894. } else if (hour < 17) {
  27895. return 'дня';
  27896. } else {
  27897. return 'вечера';
  27898. }
  27899. },
  27900. dayOfMonthOrdinalParse: /\d{1,2}-(й|го|я)/,
  27901. ordinal: function (number, period) {
  27902. switch (period) {
  27903. case 'M':
  27904. case 'd':
  27905. case 'DDD':
  27906. return number + '-й';
  27907. case 'D':
  27908. return number + '-го';
  27909. case 'w':
  27910. case 'W':
  27911. return number + '-я';
  27912. default:
  27913. return number;
  27914. }
  27915. },
  27916. week : {
  27917. dow : 1, // Monday is the first day of the week.
  27918. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27919. }
  27920. });
  27921. //! moment.js locale configuration
  27922. //! locale : Sindhi [sd]
  27923. //! author : Narain Sagar : https://github.com/narainsagar
  27924. var months$6 = [
  27925. 'جنوري',
  27926. 'فيبروري',
  27927. 'مارچ',
  27928. 'اپريل',
  27929. 'مئي',
  27930. 'جون',
  27931. 'جولاءِ',
  27932. 'آگسٽ',
  27933. 'سيپٽمبر',
  27934. 'آڪٽوبر',
  27935. 'نومبر',
  27936. 'ڊسمبر'
  27937. ];
  27938. var days$1 = [
  27939. 'آچر',
  27940. 'سومر',
  27941. 'اڱارو',
  27942. 'اربع',
  27943. 'خميس',
  27944. 'جمع',
  27945. 'ڇنڇر'
  27946. ];
  27947. hooks.defineLocale('sd', {
  27948. months : months$6,
  27949. monthsShort : months$6,
  27950. weekdays : days$1,
  27951. weekdaysShort : days$1,
  27952. weekdaysMin : days$1,
  27953. longDateFormat : {
  27954. LT : 'HH:mm',
  27955. LTS : 'HH:mm:ss',
  27956. L : 'DD/MM/YYYY',
  27957. LL : 'D MMMM YYYY',
  27958. LLL : 'D MMMM YYYY HH:mm',
  27959. LLLL : 'dddd، D MMMM YYYY HH:mm'
  27960. },
  27961. meridiemParse: /صبح|شام/,
  27962. isPM : function (input) {
  27963. return 'شام' === input;
  27964. },
  27965. meridiem : function (hour, minute, isLower) {
  27966. if (hour < 12) {
  27967. return 'صبح';
  27968. }
  27969. return 'شام';
  27970. },
  27971. calendar : {
  27972. sameDay : '[اڄ] LT',
  27973. nextDay : '[سڀاڻي] LT',
  27974. nextWeek : 'dddd [اڳين هفتي تي] LT',
  27975. lastDay : '[ڪالهه] LT',
  27976. lastWeek : '[گزريل هفتي] dddd [تي] LT',
  27977. sameElse : 'L'
  27978. },
  27979. relativeTime : {
  27980. future : '%s پوء',
  27981. past : '%s اڳ',
  27982. s : 'چند سيڪنڊ',
  27983. m : 'هڪ منٽ',
  27984. mm : '%d منٽ',
  27985. h : 'هڪ ڪلاڪ',
  27986. hh : '%d ڪلاڪ',
  27987. d : 'هڪ ڏينهن',
  27988. dd : '%d ڏينهن',
  27989. M : 'هڪ مهينو',
  27990. MM : '%d مهينا',
  27991. y : 'هڪ سال',
  27992. yy : '%d سال'
  27993. },
  27994. preparse: function (string) {
  27995. return string.replace(/،/g, ',');
  27996. },
  27997. postformat: function (string) {
  27998. return string.replace(/,/g, '،');
  27999. },
  28000. week : {
  28001. dow : 1, // Monday is the first day of the week.
  28002. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28003. }
  28004. });
  28005. //! moment.js locale configuration
  28006. //! locale : Northern Sami [se]
  28007. //! authors : Bård Rolstad Henriksen : https://github.com/karamell
  28008. hooks.defineLocale('se', {
  28009. months : 'ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu'.split('_'),
  28010. monthsShort : 'ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov'.split('_'),
  28011. weekdays : 'sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat'.split('_'),
  28012. weekdaysShort : 'sotn_vuos_maŋ_gask_duor_bear_láv'.split('_'),
  28013. weekdaysMin : 's_v_m_g_d_b_L'.split('_'),
  28014. longDateFormat : {
  28015. LT : 'HH:mm',
  28016. LTS : 'HH:mm:ss',
  28017. L : 'DD.MM.YYYY',
  28018. LL : 'MMMM D. [b.] YYYY',
  28019. LLL : 'MMMM D. [b.] YYYY [ti.] HH:mm',
  28020. LLLL : 'dddd, MMMM D. [b.] YYYY [ti.] HH:mm'
  28021. },
  28022. calendar : {
  28023. sameDay: '[otne ti] LT',
  28024. nextDay: '[ihttin ti] LT',
  28025. nextWeek: 'dddd [ti] LT',
  28026. lastDay: '[ikte ti] LT',
  28027. lastWeek: '[ovddit] dddd [ti] LT',
  28028. sameElse: 'L'
  28029. },
  28030. relativeTime : {
  28031. future : '%s geažes',
  28032. past : 'maŋit %s',
  28033. s : 'moadde sekunddat',
  28034. m : 'okta minuhta',
  28035. mm : '%d minuhtat',
  28036. h : 'okta diimmu',
  28037. hh : '%d diimmut',
  28038. d : 'okta beaivi',
  28039. dd : '%d beaivvit',
  28040. M : 'okta mánnu',
  28041. MM : '%d mánut',
  28042. y : 'okta jahki',
  28043. yy : '%d jagit'
  28044. },
  28045. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28046. ordinal : '%d.',
  28047. week : {
  28048. dow : 1, // Monday is the first day of the week.
  28049. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28050. }
  28051. });
  28052. //! moment.js locale configuration
  28053. //! locale : Sinhalese [si]
  28054. //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
  28055. /*jshint -W100*/
  28056. hooks.defineLocale('si', {
  28057. months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
  28058. monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
  28059. weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
  28060. weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
  28061. weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
  28062. weekdaysParseExact : true,
  28063. longDateFormat : {
  28064. LT : 'a h:mm',
  28065. LTS : 'a h:mm:ss',
  28066. L : 'YYYY/MM/DD',
  28067. LL : 'YYYY MMMM D',
  28068. LLL : 'YYYY MMMM D, a h:mm',
  28069. LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
  28070. },
  28071. calendar : {
  28072. sameDay : '[අද] LT[ට]',
  28073. nextDay : '[හෙට] LT[ට]',
  28074. nextWeek : 'dddd LT[ට]',
  28075. lastDay : '[ඊයේ] LT[ට]',
  28076. lastWeek : '[පසුගිය] dddd LT[ට]',
  28077. sameElse : 'L'
  28078. },
  28079. relativeTime : {
  28080. future : '%sකින්',
  28081. past : '%sකට පෙර',
  28082. s : 'තත්පර කිහිපය',
  28083. m : 'මිනිත්තුව',
  28084. mm : 'මිනිත්තු %d',
  28085. h : 'පැය',
  28086. hh : 'පැය %d',
  28087. d : 'දිනය',
  28088. dd : 'දින %d',
  28089. M : 'මාසය',
  28090. MM : 'මාස %d',
  28091. y : 'වසර',
  28092. yy : 'වසර %d'
  28093. },
  28094. dayOfMonthOrdinalParse: /\d{1,2} වැනි/,
  28095. ordinal : function (number) {
  28096. return number + ' වැනි';
  28097. },
  28098. meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
  28099. isPM : function (input) {
  28100. return input === 'ප.ව.' || input === 'පස් වරු';
  28101. },
  28102. meridiem : function (hours, minutes, isLower) {
  28103. if (hours > 11) {
  28104. return isLower ? 'ප.ව.' : 'පස් වරු';
  28105. } else {
  28106. return isLower ? 'පෙ.ව.' : 'පෙර වරු';
  28107. }
  28108. }
  28109. });
  28110. //! moment.js locale configuration
  28111. //! locale : Slovak [sk]
  28112. //! author : Martin Minka : https://github.com/k2s
  28113. //! based on work of petrbela : https://github.com/petrbela
  28114. var months$7 = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_');
  28115. var monthsShort$5 = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
  28116. function plural$5(n) {
  28117. return (n > 1) && (n < 5);
  28118. }
  28119. function translate$8(number, withoutSuffix, key, isFuture) {
  28120. var result = number + ' ';
  28121. switch (key) {
  28122. case 's': // a few seconds / in a few seconds / a few seconds ago
  28123. return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
  28124. case 'm': // a minute / in a minute / a minute ago
  28125. return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
  28126. case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
  28127. if (withoutSuffix || isFuture) {
  28128. return result + (plural$5(number) ? 'minúty' : 'minút');
  28129. } else {
  28130. return result + 'minútami';
  28131. }
  28132. break;
  28133. case 'h': // an hour / in an hour / an hour ago
  28134. return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
  28135. case 'hh': // 9 hours / in 9 hours / 9 hours ago
  28136. if (withoutSuffix || isFuture) {
  28137. return result + (plural$5(number) ? 'hodiny' : 'hodín');
  28138. } else {
  28139. return result + 'hodinami';
  28140. }
  28141. break;
  28142. case 'd': // a day / in a day / a day ago
  28143. return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
  28144. case 'dd': // 9 days / in 9 days / 9 days ago
  28145. if (withoutSuffix || isFuture) {
  28146. return result + (plural$5(number) ? 'dni' : 'dní');
  28147. } else {
  28148. return result + 'dňami';
  28149. }
  28150. break;
  28151. case 'M': // a month / in a month / a month ago
  28152. return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
  28153. case 'MM': // 9 months / in 9 months / 9 months ago
  28154. if (withoutSuffix || isFuture) {
  28155. return result + (plural$5(number) ? 'mesiace' : 'mesiacov');
  28156. } else {
  28157. return result + 'mesiacmi';
  28158. }
  28159. break;
  28160. case 'y': // a year / in a year / a year ago
  28161. return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
  28162. case 'yy': // 9 years / in 9 years / 9 years ago
  28163. if (withoutSuffix || isFuture) {
  28164. return result + (plural$5(number) ? 'roky' : 'rokov');
  28165. } else {
  28166. return result + 'rokmi';
  28167. }
  28168. break;
  28169. }
  28170. }
  28171. hooks.defineLocale('sk', {
  28172. months : months$7,
  28173. monthsShort : monthsShort$5,
  28174. weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
  28175. weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
  28176. weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
  28177. longDateFormat : {
  28178. LT: 'H:mm',
  28179. LTS : 'H:mm:ss',
  28180. L : 'DD.MM.YYYY',
  28181. LL : 'D. MMMM YYYY',
  28182. LLL : 'D. MMMM YYYY H:mm',
  28183. LLLL : 'dddd D. MMMM YYYY H:mm'
  28184. },
  28185. calendar : {
  28186. sameDay: '[dnes o] LT',
  28187. nextDay: '[zajtra o] LT',
  28188. nextWeek: function () {
  28189. switch (this.day()) {
  28190. case 0:
  28191. return '[v nedeľu o] LT';
  28192. case 1:
  28193. case 2:
  28194. return '[v] dddd [o] LT';
  28195. case 3:
  28196. return '[v stredu o] LT';
  28197. case 4:
  28198. return '[vo štvrtok o] LT';
  28199. case 5:
  28200. return '[v piatok o] LT';
  28201. case 6:
  28202. return '[v sobotu o] LT';
  28203. }
  28204. },
  28205. lastDay: '[včera o] LT',
  28206. lastWeek: function () {
  28207. switch (this.day()) {
  28208. case 0:
  28209. return '[minulú nedeľu o] LT';
  28210. case 1:
  28211. case 2:
  28212. return '[minulý] dddd [o] LT';
  28213. case 3:
  28214. return '[minulú stredu o] LT';
  28215. case 4:
  28216. case 5:
  28217. return '[minulý] dddd [o] LT';
  28218. case 6:
  28219. return '[minulú sobotu o] LT';
  28220. }
  28221. },
  28222. sameElse: 'L'
  28223. },
  28224. relativeTime : {
  28225. future : 'za %s',
  28226. past : 'pred %s',
  28227. s : translate$8,
  28228. m : translate$8,
  28229. mm : translate$8,
  28230. h : translate$8,
  28231. hh : translate$8,
  28232. d : translate$8,
  28233. dd : translate$8,
  28234. M : translate$8,
  28235. MM : translate$8,
  28236. y : translate$8,
  28237. yy : translate$8
  28238. },
  28239. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28240. ordinal : '%d.',
  28241. week : {
  28242. dow : 1, // Monday is the first day of the week.
  28243. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28244. }
  28245. });
  28246. //! moment.js locale configuration
  28247. //! locale : Slovenian [sl]
  28248. //! author : Robert Sedovšek : https://github.com/sedovsek
  28249. function processRelativeTime$6(number, withoutSuffix, key, isFuture) {
  28250. var result = number + ' ';
  28251. switch (key) {
  28252. case 's':
  28253. return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
  28254. case 'm':
  28255. return withoutSuffix ? 'ena minuta' : 'eno minuto';
  28256. case 'mm':
  28257. if (number === 1) {
  28258. result += withoutSuffix ? 'minuta' : 'minuto';
  28259. } else if (number === 2) {
  28260. result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
  28261. } else if (number < 5) {
  28262. result += withoutSuffix || isFuture ? 'minute' : 'minutami';
  28263. } else {
  28264. result += withoutSuffix || isFuture ? 'minut' : 'minutami';
  28265. }
  28266. return result;
  28267. case 'h':
  28268. return withoutSuffix ? 'ena ura' : 'eno uro';
  28269. case 'hh':
  28270. if (number === 1) {
  28271. result += withoutSuffix ? 'ura' : 'uro';
  28272. } else if (number === 2) {
  28273. result += withoutSuffix || isFuture ? 'uri' : 'urama';
  28274. } else if (number < 5) {
  28275. result += withoutSuffix || isFuture ? 'ure' : 'urami';
  28276. } else {
  28277. result += withoutSuffix || isFuture ? 'ur' : 'urami';
  28278. }
  28279. return result;
  28280. case 'd':
  28281. return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
  28282. case 'dd':
  28283. if (number === 1) {
  28284. result += withoutSuffix || isFuture ? 'dan' : 'dnem';
  28285. } else if (number === 2) {
  28286. result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
  28287. } else {
  28288. result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
  28289. }
  28290. return result;
  28291. case 'M':
  28292. return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
  28293. case 'MM':
  28294. if (number === 1) {
  28295. result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
  28296. } else if (number === 2) {
  28297. result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
  28298. } else if (number < 5) {
  28299. result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
  28300. } else {
  28301. result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
  28302. }
  28303. return result;
  28304. case 'y':
  28305. return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
  28306. case 'yy':
  28307. if (number === 1) {
  28308. result += withoutSuffix || isFuture ? 'leto' : 'letom';
  28309. } else if (number === 2) {
  28310. result += withoutSuffix || isFuture ? 'leti' : 'letoma';
  28311. } else if (number < 5) {
  28312. result += withoutSuffix || isFuture ? 'leta' : 'leti';
  28313. } else {
  28314. result += withoutSuffix || isFuture ? 'let' : 'leti';
  28315. }
  28316. return result;
  28317. }
  28318. }
  28319. hooks.defineLocale('sl', {
  28320. months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
  28321. monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
  28322. monthsParseExact: true,
  28323. weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
  28324. weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
  28325. weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
  28326. weekdaysParseExact : true,
  28327. longDateFormat : {
  28328. LT : 'H:mm',
  28329. LTS : 'H:mm:ss',
  28330. L : 'DD.MM.YYYY',
  28331. LL : 'D. MMMM YYYY',
  28332. LLL : 'D. MMMM YYYY H:mm',
  28333. LLLL : 'dddd, D. MMMM YYYY H:mm'
  28334. },
  28335. calendar : {
  28336. sameDay : '[danes ob] LT',
  28337. nextDay : '[jutri ob] LT',
  28338. nextWeek : function () {
  28339. switch (this.day()) {
  28340. case 0:
  28341. return '[v] [nedeljo] [ob] LT';
  28342. case 3:
  28343. return '[v] [sredo] [ob] LT';
  28344. case 6:
  28345. return '[v] [soboto] [ob] LT';
  28346. case 1:
  28347. case 2:
  28348. case 4:
  28349. case 5:
  28350. return '[v] dddd [ob] LT';
  28351. }
  28352. },
  28353. lastDay : '[včeraj ob] LT',
  28354. lastWeek : function () {
  28355. switch (this.day()) {
  28356. case 0:
  28357. return '[prejšnjo] [nedeljo] [ob] LT';
  28358. case 3:
  28359. return '[prejšnjo] [sredo] [ob] LT';
  28360. case 6:
  28361. return '[prejšnjo] [soboto] [ob] LT';
  28362. case 1:
  28363. case 2:
  28364. case 4:
  28365. case 5:
  28366. return '[prejšnji] dddd [ob] LT';
  28367. }
  28368. },
  28369. sameElse : 'L'
  28370. },
  28371. relativeTime : {
  28372. future : 'čez %s',
  28373. past : 'pred %s',
  28374. s : processRelativeTime$6,
  28375. m : processRelativeTime$6,
  28376. mm : processRelativeTime$6,
  28377. h : processRelativeTime$6,
  28378. hh : processRelativeTime$6,
  28379. d : processRelativeTime$6,
  28380. dd : processRelativeTime$6,
  28381. M : processRelativeTime$6,
  28382. MM : processRelativeTime$6,
  28383. y : processRelativeTime$6,
  28384. yy : processRelativeTime$6
  28385. },
  28386. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28387. ordinal : '%d.',
  28388. week : {
  28389. dow : 1, // Monday is the first day of the week.
  28390. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28391. }
  28392. });
  28393. //! moment.js locale configuration
  28394. //! locale : Albanian [sq]
  28395. //! author : Flakërim Ismani : https://github.com/flakerimi
  28396. //! author : Menelion Elensúle : https://github.com/Oire
  28397. //! author : Oerd Cukalla : https://github.com/oerd
  28398. hooks.defineLocale('sq', {
  28399. months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
  28400. monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
  28401. weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
  28402. weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
  28403. weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
  28404. weekdaysParseExact : true,
  28405. meridiemParse: /PD|MD/,
  28406. isPM: function (input) {
  28407. return input.charAt(0) === 'M';
  28408. },
  28409. meridiem : function (hours, minutes, isLower) {
  28410. return hours < 12 ? 'PD' : 'MD';
  28411. },
  28412. longDateFormat : {
  28413. LT : 'HH:mm',
  28414. LTS : 'HH:mm:ss',
  28415. L : 'DD/MM/YYYY',
  28416. LL : 'D MMMM YYYY',
  28417. LLL : 'D MMMM YYYY HH:mm',
  28418. LLLL : 'dddd, D MMMM YYYY HH:mm'
  28419. },
  28420. calendar : {
  28421. sameDay : '[Sot në] LT',
  28422. nextDay : '[Nesër në] LT',
  28423. nextWeek : 'dddd [në] LT',
  28424. lastDay : '[Dje në] LT',
  28425. lastWeek : 'dddd [e kaluar në] LT',
  28426. sameElse : 'L'
  28427. },
  28428. relativeTime : {
  28429. future : 'në %s',
  28430. past : '%s më parë',
  28431. s : 'disa sekonda',
  28432. m : 'një minutë',
  28433. mm : '%d minuta',
  28434. h : 'një orë',
  28435. hh : '%d orë',
  28436. d : 'një ditë',
  28437. dd : '%d ditë',
  28438. M : 'një muaj',
  28439. MM : '%d muaj',
  28440. y : 'një vit',
  28441. yy : '%d vite'
  28442. },
  28443. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28444. ordinal : '%d.',
  28445. week : {
  28446. dow : 1, // Monday is the first day of the week.
  28447. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28448. }
  28449. });
  28450. //! moment.js locale configuration
  28451. //! locale : Serbian Cyrillic [sr-cyrl]
  28452. //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  28453. var translator$1 = {
  28454. words: { //Different grammatical cases
  28455. m: ['један минут', 'једне минуте'],
  28456. mm: ['минут', 'минуте', 'минута'],
  28457. h: ['један сат', 'једног сата'],
  28458. hh: ['сат', 'сата', 'сати'],
  28459. dd: ['дан', 'дана', 'дана'],
  28460. MM: ['месец', 'месеца', 'месеци'],
  28461. yy: ['година', 'године', 'година']
  28462. },
  28463. correctGrammaticalCase: function (number, wordKey) {
  28464. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  28465. },
  28466. translate: function (number, withoutSuffix, key) {
  28467. var wordKey = translator$1.words[key];
  28468. if (key.length === 1) {
  28469. return withoutSuffix ? wordKey[0] : wordKey[1];
  28470. } else {
  28471. return number + ' ' + translator$1.correctGrammaticalCase(number, wordKey);
  28472. }
  28473. }
  28474. };
  28475. hooks.defineLocale('sr-cyrl', {
  28476. months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
  28477. monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
  28478. monthsParseExact: true,
  28479. weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
  28480. weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
  28481. weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
  28482. weekdaysParseExact : true,
  28483. longDateFormat: {
  28484. LT: 'H:mm',
  28485. LTS : 'H:mm:ss',
  28486. L: 'DD.MM.YYYY',
  28487. LL: 'D. MMMM YYYY',
  28488. LLL: 'D. MMMM YYYY H:mm',
  28489. LLLL: 'dddd, D. MMMM YYYY H:mm'
  28490. },
  28491. calendar: {
  28492. sameDay: '[данас у] LT',
  28493. nextDay: '[сутра у] LT',
  28494. nextWeek: function () {
  28495. switch (this.day()) {
  28496. case 0:
  28497. return '[у] [недељу] [у] LT';
  28498. case 3:
  28499. return '[у] [среду] [у] LT';
  28500. case 6:
  28501. return '[у] [суботу] [у] LT';
  28502. case 1:
  28503. case 2:
  28504. case 4:
  28505. case 5:
  28506. return '[у] dddd [у] LT';
  28507. }
  28508. },
  28509. lastDay : '[јуче у] LT',
  28510. lastWeek : function () {
  28511. var lastWeekDays = [
  28512. '[прошле] [недеље] [у] LT',
  28513. '[прошлог] [понедељка] [у] LT',
  28514. '[прошлог] [уторка] [у] LT',
  28515. '[прошле] [среде] [у] LT',
  28516. '[прошлог] [четвртка] [у] LT',
  28517. '[прошлог] [петка] [у] LT',
  28518. '[прошле] [суботе] [у] LT'
  28519. ];
  28520. return lastWeekDays[this.day()];
  28521. },
  28522. sameElse : 'L'
  28523. },
  28524. relativeTime : {
  28525. future : 'за %s',
  28526. past : 'пре %s',
  28527. s : 'неколико секунди',
  28528. m : translator$1.translate,
  28529. mm : translator$1.translate,
  28530. h : translator$1.translate,
  28531. hh : translator$1.translate,
  28532. d : 'дан',
  28533. dd : translator$1.translate,
  28534. M : 'месец',
  28535. MM : translator$1.translate,
  28536. y : 'годину',
  28537. yy : translator$1.translate
  28538. },
  28539. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28540. ordinal : '%d.',
  28541. week : {
  28542. dow : 1, // Monday is the first day of the week.
  28543. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28544. }
  28545. });
  28546. //! moment.js locale configuration
  28547. //! locale : Serbian [sr]
  28548. //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  28549. var translator$2 = {
  28550. words: { //Different grammatical cases
  28551. m: ['jedan minut', 'jedne minute'],
  28552. mm: ['minut', 'minute', 'minuta'],
  28553. h: ['jedan sat', 'jednog sata'],
  28554. hh: ['sat', 'sata', 'sati'],
  28555. dd: ['dan', 'dana', 'dana'],
  28556. MM: ['mesec', 'meseca', 'meseci'],
  28557. yy: ['godina', 'godine', 'godina']
  28558. },
  28559. correctGrammaticalCase: function (number, wordKey) {
  28560. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  28561. },
  28562. translate: function (number, withoutSuffix, key) {
  28563. var wordKey = translator$2.words[key];
  28564. if (key.length === 1) {
  28565. return withoutSuffix ? wordKey[0] : wordKey[1];
  28566. } else {
  28567. return number + ' ' + translator$2.correctGrammaticalCase(number, wordKey);
  28568. }
  28569. }
  28570. };
  28571. hooks.defineLocale('sr', {
  28572. months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
  28573. monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
  28574. monthsParseExact: true,
  28575. weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
  28576. weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
  28577. weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
  28578. weekdaysParseExact : true,
  28579. longDateFormat: {
  28580. LT: 'H:mm',
  28581. LTS : 'H:mm:ss',
  28582. L: 'DD.MM.YYYY',
  28583. LL: 'D. MMMM YYYY',
  28584. LLL: 'D. MMMM YYYY H:mm',
  28585. LLLL: 'dddd, D. MMMM YYYY H:mm'
  28586. },
  28587. calendar: {
  28588. sameDay: '[danas u] LT',
  28589. nextDay: '[sutra u] LT',
  28590. nextWeek: function () {
  28591. switch (this.day()) {
  28592. case 0:
  28593. return '[u] [nedelju] [u] LT';
  28594. case 3:
  28595. return '[u] [sredu] [u] LT';
  28596. case 6:
  28597. return '[u] [subotu] [u] LT';
  28598. case 1:
  28599. case 2:
  28600. case 4:
  28601. case 5:
  28602. return '[u] dddd [u] LT';
  28603. }
  28604. },
  28605. lastDay : '[juče u] LT',
  28606. lastWeek : function () {
  28607. var lastWeekDays = [
  28608. '[prošle] [nedelje] [u] LT',
  28609. '[prošlog] [ponedeljka] [u] LT',
  28610. '[prošlog] [utorka] [u] LT',
  28611. '[prošle] [srede] [u] LT',
  28612. '[prošlog] [četvrtka] [u] LT',
  28613. '[prošlog] [petka] [u] LT',
  28614. '[prošle] [subote] [u] LT'
  28615. ];
  28616. return lastWeekDays[this.day()];
  28617. },
  28618. sameElse : 'L'
  28619. },
  28620. relativeTime : {
  28621. future : 'za %s',
  28622. past : 'pre %s',
  28623. s : 'nekoliko sekundi',
  28624. m : translator$2.translate,
  28625. mm : translator$2.translate,
  28626. h : translator$2.translate,
  28627. hh : translator$2.translate,
  28628. d : 'dan',
  28629. dd : translator$2.translate,
  28630. M : 'mesec',
  28631. MM : translator$2.translate,
  28632. y : 'godinu',
  28633. yy : translator$2.translate
  28634. },
  28635. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28636. ordinal : '%d.',
  28637. week : {
  28638. dow : 1, // Monday is the first day of the week.
  28639. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28640. }
  28641. });
  28642. //! moment.js locale configuration
  28643. //! locale : siSwati [ss]
  28644. //! author : Nicolai Davies<mail@nicolai.io> : https://github.com/nicolaidavies
  28645. hooks.defineLocale('ss', {
  28646. months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
  28647. monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
  28648. weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
  28649. weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
  28650. weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
  28651. weekdaysParseExact : true,
  28652. longDateFormat : {
  28653. LT : 'h:mm A',
  28654. LTS : 'h:mm:ss A',
  28655. L : 'DD/MM/YYYY',
  28656. LL : 'D MMMM YYYY',
  28657. LLL : 'D MMMM YYYY h:mm A',
  28658. LLLL : 'dddd, D MMMM YYYY h:mm A'
  28659. },
  28660. calendar : {
  28661. sameDay : '[Namuhla nga] LT',
  28662. nextDay : '[Kusasa nga] LT',
  28663. nextWeek : 'dddd [nga] LT',
  28664. lastDay : '[Itolo nga] LT',
  28665. lastWeek : 'dddd [leliphelile] [nga] LT',
  28666. sameElse : 'L'
  28667. },
  28668. relativeTime : {
  28669. future : 'nga %s',
  28670. past : 'wenteka nga %s',
  28671. s : 'emizuzwana lomcane',
  28672. m : 'umzuzu',
  28673. mm : '%d emizuzu',
  28674. h : 'lihora',
  28675. hh : '%d emahora',
  28676. d : 'lilanga',
  28677. dd : '%d emalanga',
  28678. M : 'inyanga',
  28679. MM : '%d tinyanga',
  28680. y : 'umnyaka',
  28681. yy : '%d iminyaka'
  28682. },
  28683. meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
  28684. meridiem : function (hours, minutes, isLower) {
  28685. if (hours < 11) {
  28686. return 'ekuseni';
  28687. } else if (hours < 15) {
  28688. return 'emini';
  28689. } else if (hours < 19) {
  28690. return 'entsambama';
  28691. } else {
  28692. return 'ebusuku';
  28693. }
  28694. },
  28695. meridiemHour : function (hour, meridiem) {
  28696. if (hour === 12) {
  28697. hour = 0;
  28698. }
  28699. if (meridiem === 'ekuseni') {
  28700. return hour;
  28701. } else if (meridiem === 'emini') {
  28702. return hour >= 11 ? hour : hour + 12;
  28703. } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
  28704. if (hour === 0) {
  28705. return 0;
  28706. }
  28707. return hour + 12;
  28708. }
  28709. },
  28710. dayOfMonthOrdinalParse: /\d{1,2}/,
  28711. ordinal : '%d',
  28712. week : {
  28713. dow : 1, // Monday is the first day of the week.
  28714. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28715. }
  28716. });
  28717. //! moment.js locale configuration
  28718. //! locale : Swedish [sv]
  28719. //! author : Jens Alm : https://github.com/ulmus
  28720. hooks.defineLocale('sv', {
  28721. months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
  28722. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
  28723. weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
  28724. weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
  28725. weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
  28726. longDateFormat : {
  28727. LT : 'HH:mm',
  28728. LTS : 'HH:mm:ss',
  28729. L : 'YYYY-MM-DD',
  28730. LL : 'D MMMM YYYY',
  28731. LLL : 'D MMMM YYYY [kl.] HH:mm',
  28732. LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
  28733. lll : 'D MMM YYYY HH:mm',
  28734. llll : 'ddd D MMM YYYY HH:mm'
  28735. },
  28736. calendar : {
  28737. sameDay: '[Idag] LT',
  28738. nextDay: '[Imorgon] LT',
  28739. lastDay: '[Igår] LT',
  28740. nextWeek: '[På] dddd LT',
  28741. lastWeek: '[I] dddd[s] LT',
  28742. sameElse: 'L'
  28743. },
  28744. relativeTime : {
  28745. future : 'om %s',
  28746. past : 'för %s sedan',
  28747. s : 'några sekunder',
  28748. m : 'en minut',
  28749. mm : '%d minuter',
  28750. h : 'en timme',
  28751. hh : '%d timmar',
  28752. d : 'en dag',
  28753. dd : '%d dagar',
  28754. M : 'en månad',
  28755. MM : '%d månader',
  28756. y : 'ett år',
  28757. yy : '%d år'
  28758. },
  28759. dayOfMonthOrdinalParse: /\d{1,2}(e|a)/,
  28760. ordinal : function (number) {
  28761. var b = number % 10,
  28762. output = (~~(number % 100 / 10) === 1) ? 'e' :
  28763. (b === 1) ? 'a' :
  28764. (b === 2) ? 'a' :
  28765. (b === 3) ? 'e' : 'e';
  28766. return number + output;
  28767. },
  28768. week : {
  28769. dow : 1, // Monday is the first day of the week.
  28770. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28771. }
  28772. });
  28773. //! moment.js locale configuration
  28774. //! locale : Swahili [sw]
  28775. //! author : Fahad Kassim : https://github.com/fadsel
  28776. hooks.defineLocale('sw', {
  28777. months : 'Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba'.split('_'),
  28778. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des'.split('_'),
  28779. weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
  28780. weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
  28781. weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
  28782. weekdaysParseExact : true,
  28783. longDateFormat : {
  28784. LT : 'HH:mm',
  28785. LTS : 'HH:mm:ss',
  28786. L : 'DD.MM.YYYY',
  28787. LL : 'D MMMM YYYY',
  28788. LLL : 'D MMMM YYYY HH:mm',
  28789. LLLL : 'dddd, D MMMM YYYY HH:mm'
  28790. },
  28791. calendar : {
  28792. sameDay : '[leo saa] LT',
  28793. nextDay : '[kesho saa] LT',
  28794. nextWeek : '[wiki ijayo] dddd [saat] LT',
  28795. lastDay : '[jana] LT',
  28796. lastWeek : '[wiki iliyopita] dddd [saat] LT',
  28797. sameElse : 'L'
  28798. },
  28799. relativeTime : {
  28800. future : '%s baadaye',
  28801. past : 'tokea %s',
  28802. s : 'hivi punde',
  28803. m : 'dakika moja',
  28804. mm : 'dakika %d',
  28805. h : 'saa limoja',
  28806. hh : 'masaa %d',
  28807. d : 'siku moja',
  28808. dd : 'masiku %d',
  28809. M : 'mwezi mmoja',
  28810. MM : 'miezi %d',
  28811. y : 'mwaka mmoja',
  28812. yy : 'miaka %d'
  28813. },
  28814. week : {
  28815. dow : 1, // Monday is the first day of the week.
  28816. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28817. }
  28818. });
  28819. //! moment.js locale configuration
  28820. //! locale : Tamil [ta]
  28821. //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
  28822. var symbolMap$13 = {
  28823. '1': '௧',
  28824. '2': '௨',
  28825. '3': '௩',
  28826. '4': '௪',
  28827. '5': '௫',
  28828. '6': '௬',
  28829. '7': '௭',
  28830. '8': '௮',
  28831. '9': '௯',
  28832. '0': '௦'
  28833. };
  28834. var numberMap$12 = {
  28835. '௧': '1',
  28836. '௨': '2',
  28837. '௩': '3',
  28838. '௪': '4',
  28839. '௫': '5',
  28840. '௬': '6',
  28841. '௭': '7',
  28842. '௮': '8',
  28843. '௯': '9',
  28844. '௦': '0'
  28845. };
  28846. hooks.defineLocale('ta', {
  28847. months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
  28848. monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
  28849. weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
  28850. weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
  28851. weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
  28852. longDateFormat : {
  28853. LT : 'HH:mm',
  28854. LTS : 'HH:mm:ss',
  28855. L : 'DD/MM/YYYY',
  28856. LL : 'D MMMM YYYY',
  28857. LLL : 'D MMMM YYYY, HH:mm',
  28858. LLLL : 'dddd, D MMMM YYYY, HH:mm'
  28859. },
  28860. calendar : {
  28861. sameDay : '[இன்று] LT',
  28862. nextDay : '[நாளை] LT',
  28863. nextWeek : 'dddd, LT',
  28864. lastDay : '[நேற்று] LT',
  28865. lastWeek : '[கடந்த வாரம்] dddd, LT',
  28866. sameElse : 'L'
  28867. },
  28868. relativeTime : {
  28869. future : '%s இல்',
  28870. past : '%s முன்',
  28871. s : 'ஒரு சில விநாடிகள்',
  28872. m : 'ஒரு நிமிடம்',
  28873. mm : '%d நிமிடங்கள்',
  28874. h : 'ஒரு மணி நேரம்',
  28875. hh : '%d மணி நேரம்',
  28876. d : 'ஒரு நாள்',
  28877. dd : '%d நாட்கள்',
  28878. M : 'ஒரு மாதம்',
  28879. MM : '%d மாதங்கள்',
  28880. y : 'ஒரு வருடம்',
  28881. yy : '%d ஆண்டுகள்'
  28882. },
  28883. dayOfMonthOrdinalParse: /\d{1,2}வது/,
  28884. ordinal : function (number) {
  28885. return number + 'வது';
  28886. },
  28887. preparse: function (string) {
  28888. return string.replace(/[௧௨௩௪௫௬௭௮௯௦]/g, function (match) {
  28889. return numberMap$12[match];
  28890. });
  28891. },
  28892. postformat: function (string) {
  28893. return string.replace(/\d/g, function (match) {
  28894. return symbolMap$13[match];
  28895. });
  28896. },
  28897. // refer http://ta.wikipedia.org/s/1er1
  28898. meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
  28899. meridiem : function (hour, minute, isLower) {
  28900. if (hour < 2) {
  28901. return ' யாமம்';
  28902. } else if (hour < 6) {
  28903. return ' வைகறை'; // வைகறை
  28904. } else if (hour < 10) {
  28905. return ' காலை'; // காலை
  28906. } else if (hour < 14) {
  28907. return ' நண்பகல்'; // நண்பகல்
  28908. } else if (hour < 18) {
  28909. return ' எற்பாடு'; // எற்பாடு
  28910. } else if (hour < 22) {
  28911. return ' மாலை'; // மாலை
  28912. } else {
  28913. return ' யாமம்';
  28914. }
  28915. },
  28916. meridiemHour : function (hour, meridiem) {
  28917. if (hour === 12) {
  28918. hour = 0;
  28919. }
  28920. if (meridiem === 'யாமம்') {
  28921. return hour < 2 ? hour : hour + 12;
  28922. } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
  28923. return hour;
  28924. } else if (meridiem === 'நண்பகல்') {
  28925. return hour >= 10 ? hour : hour + 12;
  28926. } else {
  28927. return hour + 12;
  28928. }
  28929. },
  28930. week : {
  28931. dow : 0, // Sunday is the first day of the week.
  28932. doy : 6 // The week that contains Jan 1st is the first week of the year.
  28933. }
  28934. });
  28935. //! moment.js locale configuration
  28936. //! locale : Telugu [te]
  28937. //! author : Krishna Chaitanya Thota : https://github.com/kcthota
  28938. hooks.defineLocale('te', {
  28939. months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
  28940. monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
  28941. monthsParseExact : true,
  28942. weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
  28943. weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
  28944. weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
  28945. longDateFormat : {
  28946. LT : 'A h:mm',
  28947. LTS : 'A h:mm:ss',
  28948. L : 'DD/MM/YYYY',
  28949. LL : 'D MMMM YYYY',
  28950. LLL : 'D MMMM YYYY, A h:mm',
  28951. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  28952. },
  28953. calendar : {
  28954. sameDay : '[నేడు] LT',
  28955. nextDay : '[రేపు] LT',
  28956. nextWeek : 'dddd, LT',
  28957. lastDay : '[నిన్న] LT',
  28958. lastWeek : '[గత] dddd, LT',
  28959. sameElse : 'L'
  28960. },
  28961. relativeTime : {
  28962. future : '%s లో',
  28963. past : '%s క్రితం',
  28964. s : 'కొన్ని క్షణాలు',
  28965. m : 'ఒక నిమిషం',
  28966. mm : '%d నిమిషాలు',
  28967. h : 'ఒక గంట',
  28968. hh : '%d గంటలు',
  28969. d : 'ఒక రోజు',
  28970. dd : '%d రోజులు',
  28971. M : 'ఒక నెల',
  28972. MM : '%d నెలలు',
  28973. y : 'ఒక సంవత్సరం',
  28974. yy : '%d సంవత్సరాలు'
  28975. },
  28976. dayOfMonthOrdinalParse : /\d{1,2}వ/,
  28977. ordinal : '%dవ',
  28978. meridiemParse: /రాత్రి|ఉదయం|మధ్యాహ్నం|సాయంత్రం/,
  28979. meridiemHour : function (hour, meridiem) {
  28980. if (hour === 12) {
  28981. hour = 0;
  28982. }
  28983. if (meridiem === 'రాత్రి') {
  28984. return hour < 4 ? hour : hour + 12;
  28985. } else if (meridiem === 'ఉదయం') {
  28986. return hour;
  28987. } else if (meridiem === 'మధ్యాహ్నం') {
  28988. return hour >= 10 ? hour : hour + 12;
  28989. } else if (meridiem === 'సాయంత్రం') {
  28990. return hour + 12;
  28991. }
  28992. },
  28993. meridiem : function (hour, minute, isLower) {
  28994. if (hour < 4) {
  28995. return 'రాత్రి';
  28996. } else if (hour < 10) {
  28997. return 'ఉదయం';
  28998. } else if (hour < 17) {
  28999. return 'మధ్యాహ్నం';
  29000. } else if (hour < 20) {
  29001. return 'సాయంత్రం';
  29002. } else {
  29003. return 'రాత్రి';
  29004. }
  29005. },
  29006. week : {
  29007. dow : 0, // Sunday is the first day of the week.
  29008. doy : 6 // The week that contains Jan 1st is the first week of the year.
  29009. }
  29010. });
  29011. //! moment.js locale configuration
  29012. //! locale : Tetun Dili (East Timor) [tet]
  29013. //! author : Joshua Brooks : https://github.com/joshbrooks
  29014. //! author : Onorio De J. Afonso : https://github.com/marobo
  29015. hooks.defineLocale('tet', {
  29016. months : 'Janeiru_Fevereiru_Marsu_Abril_Maiu_Juniu_Juliu_Augustu_Setembru_Outubru_Novembru_Dezembru'.split('_'),
  29017. monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Aug_Set_Out_Nov_Dez'.split('_'),
  29018. weekdays : 'Domingu_Segunda_Tersa_Kuarta_Kinta_Sexta_Sabadu'.split('_'),
  29019. weekdaysShort : 'Dom_Seg_Ters_Kua_Kint_Sext_Sab'.split('_'),
  29020. weekdaysMin : 'Do_Seg_Te_Ku_Ki_Sex_Sa'.split('_'),
  29021. longDateFormat : {
  29022. LT : 'HH:mm',
  29023. LTS : 'HH:mm:ss',
  29024. L : 'DD/MM/YYYY',
  29025. LL : 'D MMMM YYYY',
  29026. LLL : 'D MMMM YYYY HH:mm',
  29027. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29028. },
  29029. calendar : {
  29030. sameDay: '[Ohin iha] LT',
  29031. nextDay: '[Aban iha] LT',
  29032. nextWeek: 'dddd [iha] LT',
  29033. lastDay: '[Horiseik iha] LT',
  29034. lastWeek: 'dddd [semana kotuk] [iha] LT',
  29035. sameElse: 'L'
  29036. },
  29037. relativeTime : {
  29038. future : 'iha %s',
  29039. past : '%s liuba',
  29040. s : 'minutu balun',
  29041. m : 'minutu ida',
  29042. mm : 'minutus %d',
  29043. h : 'horas ida',
  29044. hh : 'horas %d',
  29045. d : 'loron ida',
  29046. dd : 'loron %d',
  29047. M : 'fulan ida',
  29048. MM : 'fulan %d',
  29049. y : 'tinan ida',
  29050. yy : 'tinan %d'
  29051. },
  29052. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  29053. ordinal : function (number) {
  29054. var b = number % 10,
  29055. output = (~~(number % 100 / 10) === 1) ? 'th' :
  29056. (b === 1) ? 'st' :
  29057. (b === 2) ? 'nd' :
  29058. (b === 3) ? 'rd' : 'th';
  29059. return number + output;
  29060. },
  29061. week : {
  29062. dow : 1, // Monday is the first day of the week.
  29063. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29064. }
  29065. });
  29066. //! moment.js locale configuration
  29067. //! locale : Thai [th]
  29068. //! author : Kridsada Thanabulpong : https://github.com/sirn
  29069. hooks.defineLocale('th', {
  29070. months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
  29071. monthsShort : 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'),
  29072. monthsParseExact: true,
  29073. weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
  29074. weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
  29075. weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
  29076. weekdaysParseExact : true,
  29077. longDateFormat : {
  29078. LT : 'H:mm',
  29079. LTS : 'H:mm:ss',
  29080. L : 'DD/MM/YYYY',
  29081. LL : 'D MMMM YYYY',
  29082. LLL : 'D MMMM YYYY เวลา H:mm',
  29083. LLLL : 'วันddddที่ D MMMM YYYY เวลา H:mm'
  29084. },
  29085. meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
  29086. isPM: function (input) {
  29087. return input === 'หลังเที่ยง';
  29088. },
  29089. meridiem : function (hour, minute, isLower) {
  29090. if (hour < 12) {
  29091. return 'ก่อนเที่ยง';
  29092. } else {
  29093. return 'หลังเที่ยง';
  29094. }
  29095. },
  29096. calendar : {
  29097. sameDay : '[วันนี้ เวลา] LT',
  29098. nextDay : '[พรุ่งนี้ เวลา] LT',
  29099. nextWeek : 'dddd[หน้า เวลา] LT',
  29100. lastDay : '[เมื่อวานนี้ เวลา] LT',
  29101. lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
  29102. sameElse : 'L'
  29103. },
  29104. relativeTime : {
  29105. future : 'อีก %s',
  29106. past : '%sที่แล้ว',
  29107. s : 'ไม่กี่วินาที',
  29108. m : '1 นาที',
  29109. mm : '%d นาที',
  29110. h : '1 ชั่วโมง',
  29111. hh : '%d ชั่วโมง',
  29112. d : '1 วัน',
  29113. dd : '%d วัน',
  29114. M : '1 เดือน',
  29115. MM : '%d เดือน',
  29116. y : '1 ปี',
  29117. yy : '%d ปี'
  29118. }
  29119. });
  29120. //! moment.js locale configuration
  29121. //! locale : Tagalog (Philippines) [tl-ph]
  29122. //! author : Dan Hagman : https://github.com/hagmandan
  29123. hooks.defineLocale('tl-ph', {
  29124. months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
  29125. monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
  29126. weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
  29127. weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
  29128. weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
  29129. longDateFormat : {
  29130. LT : 'HH:mm',
  29131. LTS : 'HH:mm:ss',
  29132. L : 'MM/D/YYYY',
  29133. LL : 'MMMM D, YYYY',
  29134. LLL : 'MMMM D, YYYY HH:mm',
  29135. LLLL : 'dddd, MMMM DD, YYYY HH:mm'
  29136. },
  29137. calendar : {
  29138. sameDay: 'LT [ngayong araw]',
  29139. nextDay: '[Bukas ng] LT',
  29140. nextWeek: 'LT [sa susunod na] dddd',
  29141. lastDay: 'LT [kahapon]',
  29142. lastWeek: 'LT [noong nakaraang] dddd',
  29143. sameElse: 'L'
  29144. },
  29145. relativeTime : {
  29146. future : 'sa loob ng %s',
  29147. past : '%s ang nakalipas',
  29148. s : 'ilang segundo',
  29149. m : 'isang minuto',
  29150. mm : '%d minuto',
  29151. h : 'isang oras',
  29152. hh : '%d oras',
  29153. d : 'isang araw',
  29154. dd : '%d araw',
  29155. M : 'isang buwan',
  29156. MM : '%d buwan',
  29157. y : 'isang taon',
  29158. yy : '%d taon'
  29159. },
  29160. dayOfMonthOrdinalParse: /\d{1,2}/,
  29161. ordinal : function (number) {
  29162. return number;
  29163. },
  29164. week : {
  29165. dow : 1, // Monday is the first day of the week.
  29166. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29167. }
  29168. });
  29169. //! moment.js locale configuration
  29170. //! locale : Klingon [tlh]
  29171. //! author : Dominika Kruk : https://github.com/amaranthrose
  29172. var numbersNouns = 'pagh_wa’_cha’_wej_loS_vagh_jav_Soch_chorgh_Hut'.split('_');
  29173. function translateFuture(output) {
  29174. var time = output;
  29175. time = (output.indexOf('jaj') !== -1) ?
  29176. time.slice(0, -3) + 'leS' :
  29177. (output.indexOf('jar') !== -1) ?
  29178. time.slice(0, -3) + 'waQ' :
  29179. (output.indexOf('DIS') !== -1) ?
  29180. time.slice(0, -3) + 'nem' :
  29181. time + ' pIq';
  29182. return time;
  29183. }
  29184. function translatePast(output) {
  29185. var time = output;
  29186. time = (output.indexOf('jaj') !== -1) ?
  29187. time.slice(0, -3) + 'Hu’' :
  29188. (output.indexOf('jar') !== -1) ?
  29189. time.slice(0, -3) + 'wen' :
  29190. (output.indexOf('DIS') !== -1) ?
  29191. time.slice(0, -3) + 'ben' :
  29192. time + ' ret';
  29193. return time;
  29194. }
  29195. function translate$9(number, withoutSuffix, string, isFuture) {
  29196. var numberNoun = numberAsNoun(number);
  29197. switch (string) {
  29198. case 'mm':
  29199. return numberNoun + ' tup';
  29200. case 'hh':
  29201. return numberNoun + ' rep';
  29202. case 'dd':
  29203. return numberNoun + ' jaj';
  29204. case 'MM':
  29205. return numberNoun + ' jar';
  29206. case 'yy':
  29207. return numberNoun + ' DIS';
  29208. }
  29209. }
  29210. function numberAsNoun(number) {
  29211. var hundred = Math.floor((number % 1000) / 100),
  29212. ten = Math.floor((number % 100) / 10),
  29213. one = number % 10,
  29214. word = '';
  29215. if (hundred > 0) {
  29216. word += numbersNouns[hundred] + 'vatlh';
  29217. }
  29218. if (ten > 0) {
  29219. word += ((word !== '') ? ' ' : '') + numbersNouns[ten] + 'maH';
  29220. }
  29221. if (one > 0) {
  29222. word += ((word !== '') ? ' ' : '') + numbersNouns[one];
  29223. }
  29224. return (word === '') ? 'pagh' : word;
  29225. }
  29226. hooks.defineLocale('tlh', {
  29227. months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
  29228. monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
  29229. monthsParseExact : true,
  29230. weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  29231. weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  29232. weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  29233. longDateFormat : {
  29234. LT : 'HH:mm',
  29235. LTS : 'HH:mm:ss',
  29236. L : 'DD.MM.YYYY',
  29237. LL : 'D MMMM YYYY',
  29238. LLL : 'D MMMM YYYY HH:mm',
  29239. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29240. },
  29241. calendar : {
  29242. sameDay: '[DaHjaj] LT',
  29243. nextDay: '[wa’leS] LT',
  29244. nextWeek: 'LLL',
  29245. lastDay: '[wa’Hu’] LT',
  29246. lastWeek: 'LLL',
  29247. sameElse: 'L'
  29248. },
  29249. relativeTime : {
  29250. future : translateFuture,
  29251. past : translatePast,
  29252. s : 'puS lup',
  29253. m : 'wa’ tup',
  29254. mm : translate$9,
  29255. h : 'wa’ rep',
  29256. hh : translate$9,
  29257. d : 'wa’ jaj',
  29258. dd : translate$9,
  29259. M : 'wa’ jar',
  29260. MM : translate$9,
  29261. y : 'wa’ DIS',
  29262. yy : translate$9
  29263. },
  29264. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29265. ordinal : '%d.',
  29266. week : {
  29267. dow : 1, // Monday is the first day of the week.
  29268. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29269. }
  29270. });
  29271. //! moment.js locale configuration
  29272. //! locale : Turkish [tr]
  29273. //! authors : Erhan Gundogan : https://github.com/erhangundogan,
  29274. //! Burak Yiğit Kaya: https://github.com/BYK
  29275. var suffixes$3 = {
  29276. 1: '\'inci',
  29277. 5: '\'inci',
  29278. 8: '\'inci',
  29279. 70: '\'inci',
  29280. 80: '\'inci',
  29281. 2: '\'nci',
  29282. 7: '\'nci',
  29283. 20: '\'nci',
  29284. 50: '\'nci',
  29285. 3: '\'üncü',
  29286. 4: '\'üncü',
  29287. 100: '\'üncü',
  29288. 6: '\'ncı',
  29289. 9: '\'uncu',
  29290. 10: '\'uncu',
  29291. 30: '\'uncu',
  29292. 60: '\'ıncı',
  29293. 90: '\'ıncı'
  29294. };
  29295. hooks.defineLocale('tr', {
  29296. months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
  29297. monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
  29298. weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
  29299. weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
  29300. weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
  29301. longDateFormat : {
  29302. LT : 'HH:mm',
  29303. LTS : 'HH:mm:ss',
  29304. L : 'DD.MM.YYYY',
  29305. LL : 'D MMMM YYYY',
  29306. LLL : 'D MMMM YYYY HH:mm',
  29307. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29308. },
  29309. calendar : {
  29310. sameDay : '[bugün saat] LT',
  29311. nextDay : '[yarın saat] LT',
  29312. nextWeek : '[gelecek] dddd [saat] LT',
  29313. lastDay : '[dün] LT',
  29314. lastWeek : '[geçen] dddd [saat] LT',
  29315. sameElse : 'L'
  29316. },
  29317. relativeTime : {
  29318. future : '%s sonra',
  29319. past : '%s önce',
  29320. s : 'birkaç saniye',
  29321. m : 'bir dakika',
  29322. mm : '%d dakika',
  29323. h : 'bir saat',
  29324. hh : '%d saat',
  29325. d : 'bir gün',
  29326. dd : '%d gün',
  29327. M : 'bir ay',
  29328. MM : '%d ay',
  29329. y : 'bir yıl',
  29330. yy : '%d yıl'
  29331. },
  29332. dayOfMonthOrdinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
  29333. ordinal : function (number) {
  29334. if (number === 0) { // special case for zero
  29335. return number + '\'ıncı';
  29336. }
  29337. var a = number % 10,
  29338. b = number % 100 - a,
  29339. c = number >= 100 ? 100 : null;
  29340. return number + (suffixes$3[a] || suffixes$3[b] || suffixes$3[c]);
  29341. },
  29342. week : {
  29343. dow : 1, // Monday is the first day of the week.
  29344. doy : 7 // The week that contains Jan 1st is the first week of the year.
  29345. }
  29346. });
  29347. //! moment.js locale configuration
  29348. //! locale : Talossan [tzl]
  29349. //! author : Robin van der Vliet : https://github.com/robin0van0der0v
  29350. //! author : Iustì Canun
  29351. // After the year there should be a slash and the amount of years since December 26, 1979 in Roman numerals.
  29352. // This is currently too difficult (maybe even impossible) to add.
  29353. hooks.defineLocale('tzl', {
  29354. months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
  29355. monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
  29356. weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
  29357. weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
  29358. weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
  29359. longDateFormat : {
  29360. LT : 'HH.mm',
  29361. LTS : 'HH.mm.ss',
  29362. L : 'DD.MM.YYYY',
  29363. LL : 'D. MMMM [dallas] YYYY',
  29364. LLL : 'D. MMMM [dallas] YYYY HH.mm',
  29365. LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
  29366. },
  29367. meridiemParse: /d\'o|d\'a/i,
  29368. isPM : function (input) {
  29369. return 'd\'o' === input.toLowerCase();
  29370. },
  29371. meridiem : function (hours, minutes, isLower) {
  29372. if (hours > 11) {
  29373. return isLower ? 'd\'o' : 'D\'O';
  29374. } else {
  29375. return isLower ? 'd\'a' : 'D\'A';
  29376. }
  29377. },
  29378. calendar : {
  29379. sameDay : '[oxhi à] LT',
  29380. nextDay : '[demà à] LT',
  29381. nextWeek : 'dddd [à] LT',
  29382. lastDay : '[ieiri à] LT',
  29383. lastWeek : '[sür el] dddd [lasteu à] LT',
  29384. sameElse : 'L'
  29385. },
  29386. relativeTime : {
  29387. future : 'osprei %s',
  29388. past : 'ja%s',
  29389. s : processRelativeTime$7,
  29390. m : processRelativeTime$7,
  29391. mm : processRelativeTime$7,
  29392. h : processRelativeTime$7,
  29393. hh : processRelativeTime$7,
  29394. d : processRelativeTime$7,
  29395. dd : processRelativeTime$7,
  29396. M : processRelativeTime$7,
  29397. MM : processRelativeTime$7,
  29398. y : processRelativeTime$7,
  29399. yy : processRelativeTime$7
  29400. },
  29401. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29402. ordinal : '%d.',
  29403. week : {
  29404. dow : 1, // Monday is the first day of the week.
  29405. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29406. }
  29407. });
  29408. function processRelativeTime$7(number, withoutSuffix, key, isFuture) {
  29409. var format = {
  29410. 's': ['viensas secunds', '\'iensas secunds'],
  29411. 'm': ['\'n míut', '\'iens míut'],
  29412. 'mm': [number + ' míuts', '' + number + ' míuts'],
  29413. 'h': ['\'n þora', '\'iensa þora'],
  29414. 'hh': [number + ' þoras', '' + number + ' þoras'],
  29415. 'd': ['\'n ziua', '\'iensa ziua'],
  29416. 'dd': [number + ' ziuas', '' + number + ' ziuas'],
  29417. 'M': ['\'n mes', '\'iens mes'],
  29418. 'MM': [number + ' mesen', '' + number + ' mesen'],
  29419. 'y': ['\'n ar', '\'iens ar'],
  29420. 'yy': [number + ' ars', '' + number + ' ars']
  29421. };
  29422. return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1]);
  29423. }
  29424. //! moment.js locale configuration
  29425. //! locale : Central Atlas Tamazight Latin [tzm-latn]
  29426. //! author : Abdel Said : https://github.com/abdelsaid
  29427. hooks.defineLocale('tzm-latn', {
  29428. months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
  29429. monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
  29430. weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  29431. weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  29432. weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  29433. longDateFormat : {
  29434. LT : 'HH:mm',
  29435. LTS : 'HH:mm:ss',
  29436. L : 'DD/MM/YYYY',
  29437. LL : 'D MMMM YYYY',
  29438. LLL : 'D MMMM YYYY HH:mm',
  29439. LLLL : 'dddd D MMMM YYYY HH:mm'
  29440. },
  29441. calendar : {
  29442. sameDay: '[asdkh g] LT',
  29443. nextDay: '[aska g] LT',
  29444. nextWeek: 'dddd [g] LT',
  29445. lastDay: '[assant g] LT',
  29446. lastWeek: 'dddd [g] LT',
  29447. sameElse: 'L'
  29448. },
  29449. relativeTime : {
  29450. future : 'dadkh s yan %s',
  29451. past : 'yan %s',
  29452. s : 'imik',
  29453. m : 'minuḍ',
  29454. mm : '%d minuḍ',
  29455. h : 'saɛa',
  29456. hh : '%d tassaɛin',
  29457. d : 'ass',
  29458. dd : '%d ossan',
  29459. M : 'ayowr',
  29460. MM : '%d iyyirn',
  29461. y : 'asgas',
  29462. yy : '%d isgasn'
  29463. },
  29464. week : {
  29465. dow : 6, // Saturday is the first day of the week.
  29466. doy : 12 // The week that contains Jan 1st is the first week of the year.
  29467. }
  29468. });
  29469. //! moment.js locale configuration
  29470. //! locale : Central Atlas Tamazight [tzm]
  29471. //! author : Abdel Said : https://github.com/abdelsaid
  29472. hooks.defineLocale('tzm', {
  29473. months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
  29474. monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
  29475. weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  29476. weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  29477. weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  29478. longDateFormat : {
  29479. LT : 'HH:mm',
  29480. LTS: 'HH:mm:ss',
  29481. L : 'DD/MM/YYYY',
  29482. LL : 'D MMMM YYYY',
  29483. LLL : 'D MMMM YYYY HH:mm',
  29484. LLLL : 'dddd D MMMM YYYY HH:mm'
  29485. },
  29486. calendar : {
  29487. sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
  29488. nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
  29489. nextWeek: 'dddd [ⴴ] LT',
  29490. lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
  29491. lastWeek: 'dddd [ⴴ] LT',
  29492. sameElse: 'L'
  29493. },
  29494. relativeTime : {
  29495. future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
  29496. past : 'ⵢⴰⵏ %s',
  29497. s : 'ⵉⵎⵉⴽ',
  29498. m : 'ⵎⵉⵏⵓⴺ',
  29499. mm : '%d ⵎⵉⵏⵓⴺ',
  29500. h : 'ⵙⴰⵄⴰ',
  29501. hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
  29502. d : 'ⴰⵙⵙ',
  29503. dd : '%d oⵙⵙⴰⵏ',
  29504. M : 'ⴰⵢoⵓⵔ',
  29505. MM : '%d ⵉⵢⵢⵉⵔⵏ',
  29506. y : 'ⴰⵙⴳⴰⵙ',
  29507. yy : '%d ⵉⵙⴳⴰⵙⵏ'
  29508. },
  29509. week : {
  29510. dow : 6, // Saturday is the first day of the week.
  29511. doy : 12 // The week that contains Jan 1st is the first week of the year.
  29512. }
  29513. });
  29514. //! moment.js locale configuration
  29515. //! locale : Ukrainian [uk]
  29516. //! author : zemlanin : https://github.com/zemlanin
  29517. //! Author : Menelion Elensúle : https://github.com/Oire
  29518. function plural$6(word, num) {
  29519. var forms = word.split('_');
  29520. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  29521. }
  29522. function relativeTimeWithPlural$4(number, withoutSuffix, key) {
  29523. var format = {
  29524. 'mm': withoutSuffix ? 'хвилина_хвилини_хвилин' : 'хвилину_хвилини_хвилин',
  29525. 'hh': withoutSuffix ? 'година_години_годин' : 'годину_години_годин',
  29526. 'dd': 'день_дні_днів',
  29527. 'MM': 'місяць_місяці_місяців',
  29528. 'yy': 'рік_роки_років'
  29529. };
  29530. if (key === 'm') {
  29531. return withoutSuffix ? 'хвилина' : 'хвилину';
  29532. }
  29533. else if (key === 'h') {
  29534. return withoutSuffix ? 'година' : 'годину';
  29535. }
  29536. else {
  29537. return number + ' ' + plural$6(format[key], +number);
  29538. }
  29539. }
  29540. function weekdaysCaseReplace(m, format) {
  29541. var weekdays = {
  29542. 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
  29543. 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
  29544. 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
  29545. };
  29546. if (!m) {
  29547. return weekdays['nominative'];
  29548. }
  29549. var nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
  29550. 'accusative' :
  29551. ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
  29552. 'genitive' :
  29553. 'nominative');
  29554. return weekdays[nounCase][m.day()];
  29555. }
  29556. function processHoursFunction(str) {
  29557. return function () {
  29558. return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
  29559. };
  29560. }
  29561. hooks.defineLocale('uk', {
  29562. months : {
  29563. 'format': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_'),
  29564. 'standalone': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_')
  29565. },
  29566. monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
  29567. weekdays : weekdaysCaseReplace,
  29568. weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  29569. weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  29570. longDateFormat : {
  29571. LT : 'HH:mm',
  29572. LTS : 'HH:mm:ss',
  29573. L : 'DD.MM.YYYY',
  29574. LL : 'D MMMM YYYY р.',
  29575. LLL : 'D MMMM YYYY р., HH:mm',
  29576. LLLL : 'dddd, D MMMM YYYY р., HH:mm'
  29577. },
  29578. calendar : {
  29579. sameDay: processHoursFunction('[Сьогодні '),
  29580. nextDay: processHoursFunction('[Завтра '),
  29581. lastDay: processHoursFunction('[Вчора '),
  29582. nextWeek: processHoursFunction('[У] dddd ['),
  29583. lastWeek: function () {
  29584. switch (this.day()) {
  29585. case 0:
  29586. case 3:
  29587. case 5:
  29588. case 6:
  29589. return processHoursFunction('[Минулої] dddd [').call(this);
  29590. case 1:
  29591. case 2:
  29592. case 4:
  29593. return processHoursFunction('[Минулого] dddd [').call(this);
  29594. }
  29595. },
  29596. sameElse: 'L'
  29597. },
  29598. relativeTime : {
  29599. future : 'за %s',
  29600. past : '%s тому',
  29601. s : 'декілька секунд',
  29602. m : relativeTimeWithPlural$4,
  29603. mm : relativeTimeWithPlural$4,
  29604. h : 'годину',
  29605. hh : relativeTimeWithPlural$4,
  29606. d : 'день',
  29607. dd : relativeTimeWithPlural$4,
  29608. M : 'місяць',
  29609. MM : relativeTimeWithPlural$4,
  29610. y : 'рік',
  29611. yy : relativeTimeWithPlural$4
  29612. },
  29613. // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
  29614. meridiemParse: /ночі|ранку|дня|вечора/,
  29615. isPM: function (input) {
  29616. return /^(дня|вечора)$/.test(input);
  29617. },
  29618. meridiem : function (hour, minute, isLower) {
  29619. if (hour < 4) {
  29620. return 'ночі';
  29621. } else if (hour < 12) {
  29622. return 'ранку';
  29623. } else if (hour < 17) {
  29624. return 'дня';
  29625. } else {
  29626. return 'вечора';
  29627. }
  29628. },
  29629. dayOfMonthOrdinalParse: /\d{1,2}-(й|го)/,
  29630. ordinal: function (number, period) {
  29631. switch (period) {
  29632. case 'M':
  29633. case 'd':
  29634. case 'DDD':
  29635. case 'w':
  29636. case 'W':
  29637. return number + '-й';
  29638. case 'D':
  29639. return number + '-го';
  29640. default:
  29641. return number;
  29642. }
  29643. },
  29644. week : {
  29645. dow : 1, // Monday is the first day of the week.
  29646. doy : 7 // The week that contains Jan 1st is the first week of the year.
  29647. }
  29648. });
  29649. //! moment.js locale configuration
  29650. //! locale : Urdu [ur]
  29651. //! author : Sawood Alam : https://github.com/ibnesayeed
  29652. //! author : Zack : https://github.com/ZackVision
  29653. var months$8 = [
  29654. 'جنوری',
  29655. 'فروری',
  29656. 'مارچ',
  29657. 'اپریل',
  29658. 'مئی',
  29659. 'جون',
  29660. 'جولائی',
  29661. 'اگست',
  29662. 'ستمبر',
  29663. 'اکتوبر',
  29664. 'نومبر',
  29665. 'دسمبر'
  29666. ];
  29667. var days$2 = [
  29668. 'اتوار',
  29669. 'پیر',
  29670. 'منگل',
  29671. 'بدھ',
  29672. 'جمعرات',
  29673. 'جمعہ',
  29674. 'ہفتہ'
  29675. ];
  29676. hooks.defineLocale('ur', {
  29677. months : months$8,
  29678. monthsShort : months$8,
  29679. weekdays : days$2,
  29680. weekdaysShort : days$2,
  29681. weekdaysMin : days$2,
  29682. longDateFormat : {
  29683. LT : 'HH:mm',
  29684. LTS : 'HH:mm:ss',
  29685. L : 'DD/MM/YYYY',
  29686. LL : 'D MMMM YYYY',
  29687. LLL : 'D MMMM YYYY HH:mm',
  29688. LLLL : 'dddd، D MMMM YYYY HH:mm'
  29689. },
  29690. meridiemParse: /صبح|شام/,
  29691. isPM : function (input) {
  29692. return 'شام' === input;
  29693. },
  29694. meridiem : function (hour, minute, isLower) {
  29695. if (hour < 12) {
  29696. return 'صبح';
  29697. }
  29698. return 'شام';
  29699. },
  29700. calendar : {
  29701. sameDay : '[آج بوقت] LT',
  29702. nextDay : '[کل بوقت] LT',
  29703. nextWeek : 'dddd [بوقت] LT',
  29704. lastDay : '[گذشتہ روز بوقت] LT',
  29705. lastWeek : '[گذشتہ] dddd [بوقت] LT',
  29706. sameElse : 'L'
  29707. },
  29708. relativeTime : {
  29709. future : '%s بعد',
  29710. past : '%s قبل',
  29711. s : 'چند سیکنڈ',
  29712. m : 'ایک منٹ',
  29713. mm : '%d منٹ',
  29714. h : 'ایک گھنٹہ',
  29715. hh : '%d گھنٹے',
  29716. d : 'ایک دن',
  29717. dd : '%d دن',
  29718. M : 'ایک ماہ',
  29719. MM : '%d ماہ',
  29720. y : 'ایک سال',
  29721. yy : '%d سال'
  29722. },
  29723. preparse: function (string) {
  29724. return string.replace(/،/g, ',');
  29725. },
  29726. postformat: function (string) {
  29727. return string.replace(/,/g, '،');
  29728. },
  29729. week : {
  29730. dow : 1, // Monday is the first day of the week.
  29731. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29732. }
  29733. });
  29734. //! moment.js locale configuration
  29735. //! locale : Uzbek Latin [uz-latn]
  29736. //! author : Rasulbek Mirzayev : github.com/Rasulbeeek
  29737. hooks.defineLocale('uz-latn', {
  29738. months : 'Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr'.split('_'),
  29739. monthsShort : 'Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek'.split('_'),
  29740. weekdays : 'Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba'.split('_'),
  29741. weekdaysShort : 'Yak_Dush_Sesh_Chor_Pay_Jum_Shan'.split('_'),
  29742. weekdaysMin : 'Ya_Du_Se_Cho_Pa_Ju_Sha'.split('_'),
  29743. longDateFormat : {
  29744. LT : 'HH:mm',
  29745. LTS : 'HH:mm:ss',
  29746. L : 'DD/MM/YYYY',
  29747. LL : 'D MMMM YYYY',
  29748. LLL : 'D MMMM YYYY HH:mm',
  29749. LLLL : 'D MMMM YYYY, dddd HH:mm'
  29750. },
  29751. calendar : {
  29752. sameDay : '[Bugun soat] LT [da]',
  29753. nextDay : '[Ertaga] LT [da]',
  29754. nextWeek : 'dddd [kuni soat] LT [da]',
  29755. lastDay : '[Kecha soat] LT [da]',
  29756. lastWeek : '[O\'tgan] dddd [kuni soat] LT [da]',
  29757. sameElse : 'L'
  29758. },
  29759. relativeTime : {
  29760. future : 'Yaqin %s ichida',
  29761. past : 'Bir necha %s oldin',
  29762. s : 'soniya',
  29763. m : 'bir daqiqa',
  29764. mm : '%d daqiqa',
  29765. h : 'bir soat',
  29766. hh : '%d soat',
  29767. d : 'bir kun',
  29768. dd : '%d kun',
  29769. M : 'bir oy',
  29770. MM : '%d oy',
  29771. y : 'bir yil',
  29772. yy : '%d yil'
  29773. },
  29774. week : {
  29775. dow : 1, // Monday is the first day of the week.
  29776. doy : 7 // The week that contains Jan 1st is the first week of the year.
  29777. }
  29778. });
  29779. //! moment.js locale configuration
  29780. //! locale : Uzbek [uz]
  29781. //! author : Sardor Muminov : https://github.com/muminoff
  29782. hooks.defineLocale('uz', {
  29783. months : 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'),
  29784. monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
  29785. weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
  29786. weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
  29787. weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
  29788. longDateFormat : {
  29789. LT : 'HH:mm',
  29790. LTS : 'HH:mm:ss',
  29791. L : 'DD/MM/YYYY',
  29792. LL : 'D MMMM YYYY',
  29793. LLL : 'D MMMM YYYY HH:mm',
  29794. LLLL : 'D MMMM YYYY, dddd HH:mm'
  29795. },
  29796. calendar : {
  29797. sameDay : '[Бугун соат] LT [да]',
  29798. nextDay : '[Эртага] LT [да]',
  29799. nextWeek : 'dddd [куни соат] LT [да]',
  29800. lastDay : '[Кеча соат] LT [да]',
  29801. lastWeek : '[Утган] dddd [куни соат] LT [да]',
  29802. sameElse : 'L'
  29803. },
  29804. relativeTime : {
  29805. future : 'Якин %s ичида',
  29806. past : 'Бир неча %s олдин',
  29807. s : 'фурсат',
  29808. m : 'бир дакика',
  29809. mm : '%d дакика',
  29810. h : 'бир соат',
  29811. hh : '%d соат',
  29812. d : 'бир кун',
  29813. dd : '%d кун',
  29814. M : 'бир ой',
  29815. MM : '%d ой',
  29816. y : 'бир йил',
  29817. yy : '%d йил'
  29818. },
  29819. week : {
  29820. dow : 1, // Monday is the first day of the week.
  29821. doy : 7 // The week that contains Jan 4th is the first week of the year.
  29822. }
  29823. });
  29824. //! moment.js locale configuration
  29825. //! locale : Vietnamese [vi]
  29826. //! author : Bang Nguyen : https://github.com/bangnk
  29827. hooks.defineLocale('vi', {
  29828. months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
  29829. monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
  29830. monthsParseExact : true,
  29831. weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
  29832. weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
  29833. weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
  29834. weekdaysParseExact : true,
  29835. meridiemParse: /sa|ch/i,
  29836. isPM : function (input) {
  29837. return /^ch$/i.test(input);
  29838. },
  29839. meridiem : function (hours, minutes, isLower) {
  29840. if (hours < 12) {
  29841. return isLower ? 'sa' : 'SA';
  29842. } else {
  29843. return isLower ? 'ch' : 'CH';
  29844. }
  29845. },
  29846. longDateFormat : {
  29847. LT : 'HH:mm',
  29848. LTS : 'HH:mm:ss',
  29849. L : 'DD/MM/YYYY',
  29850. LL : 'D MMMM [năm] YYYY',
  29851. LLL : 'D MMMM [năm] YYYY HH:mm',
  29852. LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
  29853. l : 'DD/M/YYYY',
  29854. ll : 'D MMM YYYY',
  29855. lll : 'D MMM YYYY HH:mm',
  29856. llll : 'ddd, D MMM YYYY HH:mm'
  29857. },
  29858. calendar : {
  29859. sameDay: '[Hôm nay lúc] LT',
  29860. nextDay: '[Ngày mai lúc] LT',
  29861. nextWeek: 'dddd [tuần tới lúc] LT',
  29862. lastDay: '[Hôm qua lúc] LT',
  29863. lastWeek: 'dddd [tuần rồi lúc] LT',
  29864. sameElse: 'L'
  29865. },
  29866. relativeTime : {
  29867. future : '%s tới',
  29868. past : '%s trước',
  29869. s : 'vài giây',
  29870. m : 'một phút',
  29871. mm : '%d phút',
  29872. h : 'một giờ',
  29873. hh : '%d giờ',
  29874. d : 'một ngày',
  29875. dd : '%d ngày',
  29876. M : 'một tháng',
  29877. MM : '%d tháng',
  29878. y : 'một năm',
  29879. yy : '%d năm'
  29880. },
  29881. dayOfMonthOrdinalParse: /\d{1,2}/,
  29882. ordinal : function (number) {
  29883. return number;
  29884. },
  29885. week : {
  29886. dow : 1, // Monday is the first day of the week.
  29887. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29888. }
  29889. });
  29890. //! moment.js locale configuration
  29891. //! locale : Pseudo [x-pseudo]
  29892. //! author : Andrew Hood : https://github.com/andrewhood125
  29893. hooks.defineLocale('x-pseudo', {
  29894. months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
  29895. monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
  29896. monthsParseExact : true,
  29897. weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
  29898. weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
  29899. weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
  29900. weekdaysParseExact : true,
  29901. longDateFormat : {
  29902. LT : 'HH:mm',
  29903. L : 'DD/MM/YYYY',
  29904. LL : 'D MMMM YYYY',
  29905. LLL : 'D MMMM YYYY HH:mm',
  29906. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29907. },
  29908. calendar : {
  29909. sameDay : '[T~ódá~ý át] LT',
  29910. nextDay : '[T~ómó~rró~w át] LT',
  29911. nextWeek : 'dddd [át] LT',
  29912. lastDay : '[Ý~ést~érdá~ý át] LT',
  29913. lastWeek : '[L~ást] dddd [át] LT',
  29914. sameElse : 'L'
  29915. },
  29916. relativeTime : {
  29917. future : 'í~ñ %s',
  29918. past : '%s á~gó',
  29919. s : 'á ~féw ~sécó~ñds',
  29920. m : 'á ~míñ~úté',
  29921. mm : '%d m~íñú~tés',
  29922. h : 'á~ñ hó~úr',
  29923. hh : '%d h~óúrs',
  29924. d : 'á ~dáý',
  29925. dd : '%d d~áýs',
  29926. M : 'á ~móñ~th',
  29927. MM : '%d m~óñt~hs',
  29928. y : 'á ~ýéár',
  29929. yy : '%d ý~éárs'
  29930. },
  29931. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  29932. ordinal : function (number) {
  29933. var b = number % 10,
  29934. output = (~~(number % 100 / 10) === 1) ? 'th' :
  29935. (b === 1) ? 'st' :
  29936. (b === 2) ? 'nd' :
  29937. (b === 3) ? 'rd' : 'th';
  29938. return number + output;
  29939. },
  29940. week : {
  29941. dow : 1, // Monday is the first day of the week.
  29942. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29943. }
  29944. });
  29945. //! moment.js locale configuration
  29946. //! locale : Yoruba Nigeria [yo]
  29947. //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe
  29948. hooks.defineLocale('yo', {
  29949. months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'),
  29950. monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'),
  29951. weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'),
  29952. weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'),
  29953. weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'),
  29954. longDateFormat : {
  29955. LT : 'h:mm A',
  29956. LTS : 'h:mm:ss A',
  29957. L : 'DD/MM/YYYY',
  29958. LL : 'D MMMM YYYY',
  29959. LLL : 'D MMMM YYYY h:mm A',
  29960. LLLL : 'dddd, D MMMM YYYY h:mm A'
  29961. },
  29962. calendar : {
  29963. sameDay : '[Ònì ni] LT',
  29964. nextDay : '[Ọ̀la ni] LT',
  29965. nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT',
  29966. lastDay : '[Àna ni] LT',
  29967. lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT',
  29968. sameElse : 'L'
  29969. },
  29970. relativeTime : {
  29971. future : 'ní %s',
  29972. past : '%s kọjá',
  29973. s : 'ìsẹjú aayá die',
  29974. m : 'ìsẹjú kan',
  29975. mm : 'ìsẹjú %d',
  29976. h : 'wákati kan',
  29977. hh : 'wákati %d',
  29978. d : 'ọjọ́ kan',
  29979. dd : 'ọjọ́ %d',
  29980. M : 'osù kan',
  29981. MM : 'osù %d',
  29982. y : 'ọdún kan',
  29983. yy : 'ọdún %d'
  29984. },
  29985. dayOfMonthOrdinalParse : /ọjọ́\s\d{1,2}/,
  29986. ordinal : 'ọjọ́ %d',
  29987. week : {
  29988. dow : 1, // Monday is the first day of the week.
  29989. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29990. }
  29991. });
  29992. //! moment.js locale configuration
  29993. //! locale : Chinese (China) [zh-cn]
  29994. //! author : suupic : https://github.com/suupic
  29995. //! author : Zeno Zeng : https://github.com/zenozeng
  29996. hooks.defineLocale('zh-cn', {
  29997. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  29998. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  29999. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  30000. weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  30001. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  30002. longDateFormat : {
  30003. LT : 'HH:mm',
  30004. LTS : 'HH:mm:ss',
  30005. L : 'YYYY年MMMD日',
  30006. LL : 'YYYY年MMMD日',
  30007. LLL : 'YYYY年MMMD日Ah点mm分',
  30008. LLLL : 'YYYY年MMMD日ddddAh点mm分',
  30009. l : 'YYYY年MMMD日',
  30010. ll : 'YYYY年MMMD日',
  30011. lll : 'YYYY年MMMD日 HH:mm',
  30012. llll : 'YYYY年MMMD日dddd HH:mm'
  30013. },
  30014. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  30015. meridiemHour: function (hour, meridiem) {
  30016. if (hour === 12) {
  30017. hour = 0;
  30018. }
  30019. if (meridiem === '凌晨' || meridiem === '早上' ||
  30020. meridiem === '上午') {
  30021. return hour;
  30022. } else if (meridiem === '下午' || meridiem === '晚上') {
  30023. return hour + 12;
  30024. } else {
  30025. // '中午'
  30026. return hour >= 11 ? hour : hour + 12;
  30027. }
  30028. },
  30029. meridiem : function (hour, minute, isLower) {
  30030. var hm = hour * 100 + minute;
  30031. if (hm < 600) {
  30032. return '凌晨';
  30033. } else if (hm < 900) {
  30034. return '早上';
  30035. } else if (hm < 1130) {
  30036. return '上午';
  30037. } else if (hm < 1230) {
  30038. return '中午';
  30039. } else if (hm < 1800) {
  30040. return '下午';
  30041. } else {
  30042. return '晚上';
  30043. }
  30044. },
  30045. calendar : {
  30046. sameDay : '[今天]LT',
  30047. nextDay : '[明天]LT',
  30048. nextWeek : '[下]ddddLT',
  30049. lastDay : '[昨天]LT',
  30050. lastWeek : '[上]ddddLT',
  30051. sameElse : 'L'
  30052. },
  30053. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  30054. ordinal : function (number, period) {
  30055. switch (period) {
  30056. case 'd':
  30057. case 'D':
  30058. case 'DDD':
  30059. return number + '日';
  30060. case 'M':
  30061. return number + '月';
  30062. case 'w':
  30063. case 'W':
  30064. return number + '周';
  30065. default:
  30066. return number;
  30067. }
  30068. },
  30069. relativeTime : {
  30070. future : '%s内',
  30071. past : '%s前',
  30072. s : '几秒',
  30073. m : '1 分钟',
  30074. mm : '%d 分钟',
  30075. h : '1 小时',
  30076. hh : '%d 小时',
  30077. d : '1 天',
  30078. dd : '%d 天',
  30079. M : '1 个月',
  30080. MM : '%d 个月',
  30081. y : '1 年',
  30082. yy : '%d 年'
  30083. },
  30084. week : {
  30085. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  30086. dow : 1, // Monday is the first day of the week.
  30087. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30088. }
  30089. });
  30090. //! moment.js locale configuration
  30091. //! locale : Chinese (Hong Kong) [zh-hk]
  30092. //! author : Ben : https://github.com/ben-lin
  30093. //! author : Chris Lam : https://github.com/hehachris
  30094. //! author : Konstantin : https://github.com/skfd
  30095. hooks.defineLocale('zh-hk', {
  30096. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  30097. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  30098. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  30099. weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
  30100. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  30101. longDateFormat : {
  30102. LT : 'HH:mm',
  30103. LTS : 'HH:mm:ss',
  30104. L : 'YYYY年MMMD日',
  30105. LL : 'YYYY年MMMD日',
  30106. LLL : 'YYYY年MMMD日 HH:mm',
  30107. LLLL : 'YYYY年MMMD日dddd HH:mm',
  30108. l : 'YYYY年MMMD日',
  30109. ll : 'YYYY年MMMD日',
  30110. lll : 'YYYY年MMMD日 HH:mm',
  30111. llll : 'YYYY年MMMD日dddd HH:mm'
  30112. },
  30113. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  30114. meridiemHour : function (hour, meridiem) {
  30115. if (hour === 12) {
  30116. hour = 0;
  30117. }
  30118. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  30119. return hour;
  30120. } else if (meridiem === '中午') {
  30121. return hour >= 11 ? hour : hour + 12;
  30122. } else if (meridiem === '下午' || meridiem === '晚上') {
  30123. return hour + 12;
  30124. }
  30125. },
  30126. meridiem : function (hour, minute, isLower) {
  30127. var hm = hour * 100 + minute;
  30128. if (hm < 600) {
  30129. return '凌晨';
  30130. } else if (hm < 900) {
  30131. return '早上';
  30132. } else if (hm < 1130) {
  30133. return '上午';
  30134. } else if (hm < 1230) {
  30135. return '中午';
  30136. } else if (hm < 1800) {
  30137. return '下午';
  30138. } else {
  30139. return '晚上';
  30140. }
  30141. },
  30142. calendar : {
  30143. sameDay : '[今天]LT',
  30144. nextDay : '[明天]LT',
  30145. nextWeek : '[下]ddddLT',
  30146. lastDay : '[昨天]LT',
  30147. lastWeek : '[上]ddddLT',
  30148. sameElse : 'L'
  30149. },
  30150. dayOfMonthOrdinalParse: /\d{1,2}(日|月|週)/,
  30151. ordinal : function (number, period) {
  30152. switch (period) {
  30153. case 'd' :
  30154. case 'D' :
  30155. case 'DDD' :
  30156. return number + '日';
  30157. case 'M' :
  30158. return number + '月';
  30159. case 'w' :
  30160. case 'W' :
  30161. return number + '週';
  30162. default :
  30163. return number;
  30164. }
  30165. },
  30166. relativeTime : {
  30167. future : '%s內',
  30168. past : '%s前',
  30169. s : '幾秒',
  30170. m : '1 分鐘',
  30171. mm : '%d 分鐘',
  30172. h : '1 小時',
  30173. hh : '%d 小時',
  30174. d : '1 天',
  30175. dd : '%d 天',
  30176. M : '1 個月',
  30177. MM : '%d 個月',
  30178. y : '1 年',
  30179. yy : '%d 年'
  30180. }
  30181. });
  30182. //! moment.js locale configuration
  30183. //! locale : Chinese (Taiwan) [zh-tw]
  30184. //! author : Ben : https://github.com/ben-lin
  30185. //! author : Chris Lam : https://github.com/hehachris
  30186. hooks.defineLocale('zh-tw', {
  30187. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  30188. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  30189. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  30190. weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
  30191. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  30192. longDateFormat : {
  30193. LT : 'HH:mm',
  30194. LTS : 'HH:mm:ss',
  30195. L : 'YYYY年MMMD日',
  30196. LL : 'YYYY年MMMD日',
  30197. LLL : 'YYYY年MMMD日 HH:mm',
  30198. LLLL : 'YYYY年MMMD日dddd HH:mm',
  30199. l : 'YYYY年MMMD日',
  30200. ll : 'YYYY年MMMD日',
  30201. lll : 'YYYY年MMMD日 HH:mm',
  30202. llll : 'YYYY年MMMD日dddd HH:mm'
  30203. },
  30204. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  30205. meridiemHour : function (hour, meridiem) {
  30206. if (hour === 12) {
  30207. hour = 0;
  30208. }
  30209. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  30210. return hour;
  30211. } else if (meridiem === '中午') {
  30212. return hour >= 11 ? hour : hour + 12;
  30213. } else if (meridiem === '下午' || meridiem === '晚上') {
  30214. return hour + 12;
  30215. }
  30216. },
  30217. meridiem : function (hour, minute, isLower) {
  30218. var hm = hour * 100 + minute;
  30219. if (hm < 600) {
  30220. return '凌晨';
  30221. } else if (hm < 900) {
  30222. return '早上';
  30223. } else if (hm < 1130) {
  30224. return '上午';
  30225. } else if (hm < 1230) {
  30226. return '中午';
  30227. } else if (hm < 1800) {
  30228. return '下午';
  30229. } else {
  30230. return '晚上';
  30231. }
  30232. },
  30233. calendar : {
  30234. sameDay : '[今天]LT',
  30235. nextDay : '[明天]LT',
  30236. nextWeek : '[下]ddddLT',
  30237. lastDay : '[昨天]LT',
  30238. lastWeek : '[上]ddddLT',
  30239. sameElse : 'L'
  30240. },
  30241. dayOfMonthOrdinalParse: /\d{1,2}(日|月|週)/,
  30242. ordinal : function (number, period) {
  30243. switch (period) {
  30244. case 'd' :
  30245. case 'D' :
  30246. case 'DDD' :
  30247. return number + '日';
  30248. case 'M' :
  30249. return number + '月';
  30250. case 'w' :
  30251. case 'W' :
  30252. return number + '週';
  30253. default :
  30254. return number;
  30255. }
  30256. },
  30257. relativeTime : {
  30258. future : '%s內',
  30259. past : '%s前',
  30260. s : '幾秒',
  30261. m : '1 分鐘',
  30262. mm : '%d 分鐘',
  30263. h : '1 小時',
  30264. hh : '%d 小時',
  30265. d : '1 天',
  30266. dd : '%d 天',
  30267. M : '1 個月',
  30268. MM : '%d 個月',
  30269. y : '1 年',
  30270. yy : '%d 年'
  30271. }
  30272. });
  30273. hooks.locale('en');
  30274. return hooks;
  30275. })));
  30276. // Underscore.js 1.8.3
  30277. // http://underscorejs.org
  30278. // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  30279. // Underscore may be freely distributed under the MIT license.
  30280. (function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this);
  30281. //# sourceMappingURL=underscore-min.map;
  30282. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  30283. // Distributed under an MIT license: http://codemirror.net/LICENSE
  30284. (function(mod) {
  30285. if (typeof exports == "object" && typeof module == "object") // CommonJS
  30286. mod(require("../lib/codemirror"));
  30287. else if (typeof define == "function" && define.amd) // AMD
  30288. define('codemirror/mode/meta',["../lib/codemirror"], mod);
  30289. else // Plain browser env
  30290. mod(CodeMirror);
  30291. })(function(CodeMirror) {
  30292. "use strict";
  30293. CodeMirror.modeInfo = [
  30294. {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
  30295. {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]},
  30296. {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
  30297. {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
  30298. {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
  30299. {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
  30300. {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
  30301. {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
  30302. {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
  30303. {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
  30304. {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
  30305. {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
  30306. {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
  30307. {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
  30308. {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
  30309. {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
  30310. {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
  30311. {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
  30312. {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
  30313. {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
  30314. {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
  30315. {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
  30316. {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
  30317. {name: "Django", mime: "text/x-django", mode: "django"},
  30318. {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
  30319. {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
  30320. {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
  30321. {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
  30322. {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
  30323. {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
  30324. {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
  30325. {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
  30326. {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
  30327. {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
  30328. {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
  30329. {name: "Esper", mime: "text/x-esper", mode: "sql"},
  30330. {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
  30331. {name: "FCL", mime: "text/x-fcl", mode: "fcl"},
  30332. {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
  30333. {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
  30334. {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
  30335. {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
  30336. {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
  30337. {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
  30338. {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
  30339. {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
  30340. {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
  30341. {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
  30342. {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
  30343. {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
  30344. {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
  30345. {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
  30346. {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]},
  30347. {name: "HTTP", mime: "message/http", mode: "http"},
  30348. {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
  30349. {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
  30350. {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
  30351. {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
  30352. {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
  30353. mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
  30354. {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
  30355. {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
  30356. {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
  30357. {name: "Jinja2", mime: "null", mode: "jinja2"},
  30358. {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
  30359. {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
  30360. {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
  30361. {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
  30362. {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
  30363. {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
  30364. {name: "mIRC", mime: "text/mirc", mode: "mirc"},
  30365. {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
  30366. {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
  30367. {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
  30368. {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
  30369. {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
  30370. {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
  30371. {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
  30372. {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
  30373. {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
  30374. {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"],
  30375. mode: "ntriples", ext: ["nt", "nq"]},
  30376. {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
  30377. {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
  30378. {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
  30379. {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
  30380. {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
  30381. {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
  30382. {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
  30383. {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]},
  30384. {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
  30385. {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
  30386. {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
  30387. {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
  30388. {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
  30389. {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
  30390. {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
  30391. {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
  30392. {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
  30393. {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
  30394. {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
  30395. {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
  30396. {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
  30397. {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
  30398. {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
  30399. {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
  30400. {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
  30401. {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
  30402. {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
  30403. {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
  30404. {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
  30405. {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
  30406. {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
  30407. {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
  30408. {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
  30409. {name: "Solr", mime: "text/x-solr", mode: "solr"},
  30410. {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]},
  30411. {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
  30412. {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
  30413. {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
  30414. {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
  30415. {name: "SQLite", mime: "text/x-sqlite", mode: "sql"},
  30416. {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
  30417. {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
  30418. {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
  30419. {name: "sTeX", mime: "text/x-stex", mode: "stex"},
  30420. {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]},
  30421. {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
  30422. {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
  30423. {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
  30424. {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
  30425. {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
  30426. {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
  30427. {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
  30428. {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
  30429. {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
  30430. {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
  30431. {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
  30432. {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
  30433. {name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]},
  30434. {name: "Twig", mime: "text/x-twig", mode: "twig"},
  30435. {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
  30436. {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
  30437. {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
  30438. {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
  30439. {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
  30440. {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
  30441. {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
  30442. {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]},
  30443. {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
  30444. {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
  30445. {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
  30446. {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
  30447. {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
  30448. {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
  30449. {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
  30450. ];
  30451. // Ensure all modes have a mime property for backwards compatibility
  30452. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  30453. var info = CodeMirror.modeInfo[i];
  30454. if (info.mimes) info.mime = info.mimes[0];
  30455. }
  30456. CodeMirror.findModeByMIME = function(mime) {
  30457. mime = mime.toLowerCase();
  30458. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  30459. var info = CodeMirror.modeInfo[i];
  30460. if (info.mime == mime) return info;
  30461. if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
  30462. if (info.mimes[j] == mime) return info;
  30463. }
  30464. if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml")
  30465. if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json")
  30466. };
  30467. CodeMirror.findModeByExtension = function(ext) {
  30468. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  30469. var info = CodeMirror.modeInfo[i];
  30470. if (info.ext) for (var j = 0; j < info.ext.length; j++)
  30471. if (info.ext[j] == ext) return info;
  30472. }
  30473. };
  30474. CodeMirror.findModeByFileName = function(filename) {
  30475. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  30476. var info = CodeMirror.modeInfo[i];
  30477. if (info.file && info.file.test(filename)) return info;
  30478. }
  30479. var dot = filename.lastIndexOf(".");
  30480. var ext = dot > -1 && filename.substring(dot + 1, filename.length);
  30481. if (ext) return CodeMirror.findModeByExtension(ext);
  30482. };
  30483. CodeMirror.findModeByName = function(name) {
  30484. name = name.toLowerCase();
  30485. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  30486. var info = CodeMirror.modeInfo[i];
  30487. if (info.name.toLowerCase() == name) return info;
  30488. if (info.alias) for (var j = 0; j < info.alias.length; j++)
  30489. if (info.alias[j].toLowerCase() == name) return info;
  30490. }
  30491. };
  30492. });
  30493. // Copyright (c) Jupyter Development Team.
  30494. // Distributed under the terms of the Modified BSD License.
  30495. define('base/js/utils',[
  30496. 'jquery',
  30497. 'codemirror/lib/codemirror',
  30498. 'moment',
  30499. 'underscore',
  30500. // silently upgrades CodeMirror
  30501. 'codemirror/mode/meta',
  30502. ], function($, CodeMirror, moment, _){
  30503. "use strict";
  30504. // keep track of which extensions have been loaded already
  30505. var extensions_loaded = [];
  30506. /**
  30507. * Whether or not an extension has been loaded
  30508. * @param {string} extension - name of the extension
  30509. * @return {boolean} true if loaded already
  30510. */
  30511. var is_loaded = function(extension) {
  30512. var ext_path = "nbextensions/" + extension;
  30513. return extensions_loaded.indexOf(ext_path) >= 0;
  30514. };
  30515. /**
  30516. * Load a single extension.
  30517. * @param {string} extension - extension path.
  30518. * @return {Promise} that resolves to an extension module handle
  30519. */
  30520. var load_extension = function (extension) {
  30521. return new Promise(function(resolve, reject) {
  30522. var ext_path = "nbextensions/" + extension;
  30523. requirejs([ext_path], function(module) {
  30524. if (!is_loaded(extension)) {
  30525. console.log("Loading extension: " + extension);
  30526. if (module && module.load_ipython_extension) {
  30527. Promise.resolve(module.load_ipython_extension()).then(function() {
  30528. resolve(module);
  30529. }).catch(reject);
  30530. }
  30531. extensions_loaded.push(ext_path);
  30532. } else {
  30533. console.log("Loaded extension already: " + extension);
  30534. resolve(module);
  30535. }
  30536. }, function(err) {
  30537. reject(err);
  30538. });
  30539. });
  30540. };
  30541. /**
  30542. * Load multiple extensions.
  30543. * Takes n-args, where each arg is a string path to the extension.
  30544. * @return {Promise} that resolves to a list of loaded module handles.
  30545. */
  30546. var load_extensions = function () {
  30547. console.log('load_extensions', arguments);
  30548. return Promise.all(Array.prototype.map.call(arguments, load_extension)).catch(function(err) {
  30549. console.error("Failed to load extension" + (err.requireModules.length>1?'s':'') + ":", err.requireModules, err);
  30550. });
  30551. };
  30552. /**
  30553. * Return a list of extensions that should be active
  30554. * The config for nbextensions comes in as a dict where keys are
  30555. * nbextensions paths and the values are a bool indicating if it
  30556. * should be active. This returns a list of nbextension paths
  30557. * where the value is true
  30558. */
  30559. function filter_extensions(nbext_config) {
  30560. var active = [];
  30561. Object.keys(nbext_config).forEach(function (nbext) {
  30562. if (nbext_config[nbext]) {active.push(nbext);}
  30563. });
  30564. return active;
  30565. }
  30566. /**
  30567. * Wait for a config section to load, and then load the extensions specified
  30568. * in a 'load_extensions' key inside it.
  30569. */
  30570. function load_extensions_from_config(section) {
  30571. return section.loaded.then(function() {
  30572. if (section.data.load_extensions) {
  30573. var active = filter_extensions(section.data.load_extensions);
  30574. return load_extensions.apply(this, active);
  30575. }
  30576. }).catch(utils.reject('Could not load nbextensions from ' + section.section_name + ' config file'));
  30577. }
  30578. //============================================================================
  30579. // Cross-browser RegEx Split
  30580. //============================================================================
  30581. // This code has been MODIFIED from the code licensed below to not replace the
  30582. // default browser split. The license is reproduced here.
  30583. // see http://blog.stevenlevithan.com/archives/cross-browser-split for more info:
  30584. /*!
  30585. * Cross-Browser Split 1.1.1
  30586. * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
  30587. * Available under the MIT License
  30588. * ECMAScript compliant, uniform cross-browser split method
  30589. */
  30590. /**
  30591. * Splits a string into an array of strings using a regex or string
  30592. * separator. Matches of the separator are not included in the result array.
  30593. * However, if `separator` is a regex that contains capturing groups,
  30594. * backreferences are spliced into the result each time `separator` is
  30595. * matched. Fixes browser bugs compared to the native
  30596. * `String.prototype.split` and can be used reliably cross-browser.
  30597. * @param {String} str String to split.
  30598. * @param {RegExp} separator Regex to use for separating
  30599. * the string.
  30600. * @param {Number} [limit] Maximum number of items to include in the result
  30601. * array.
  30602. * @returns {Array} Array of substrings.
  30603. * @example
  30604. *
  30605. * // Basic use
  30606. * regex_split('a b c d', ' ');
  30607. * // -> ['a', 'b', 'c', 'd']
  30608. *
  30609. * // With limit
  30610. * regex_split('a b c d', ' ', 2);
  30611. * // -> ['a', 'b']
  30612. *
  30613. * // Backreferences in result array
  30614. * regex_split('..word1 word2..', /([a-z]+)(\d+)/i);
  30615. * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
  30616. */
  30617. var regex_split = function (str, separator, limit) {
  30618. var output = [],
  30619. flags = (separator.ignoreCase ? "i" : "") +
  30620. (separator.multiline ? "m" : "") +
  30621. (separator.extended ? "x" : "") + // Proposed for ES6
  30622. (separator.sticky ? "y" : ""), // Firefox 3+
  30623. lastLastIndex = 0,
  30624. separator2, match, lastIndex, lastLength;
  30625. // Make `global` and avoid `lastIndex` issues by working with a copy
  30626. separator = new RegExp(separator.source, flags + "g");
  30627. var compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined";
  30628. if (!compliantExecNpcg) {
  30629. // Doesn't need flags gy, but they don't hurt
  30630. separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
  30631. }
  30632. /* Values for `limit`, per the spec:
  30633. * If undefined: 4294967295 // Math.pow(2, 32) - 1
  30634. * If 0, Infinity, or NaN: 0
  30635. * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
  30636. * If negative number: 4294967296 - Math.floor(Math.abs(limit))
  30637. * If other: Type-convert, then use the above rules
  30638. */
  30639. limit = typeof(limit) === "undefined" ?
  30640. -1 >>> 0 : // Math.pow(2, 32) - 1
  30641. limit >>> 0; // ToUint32(limit)
  30642. for (match = separator.exec(str); match; match = separator.exec(str)) {
  30643. // `separator.lastIndex` is not reliable cross-browser
  30644. lastIndex = match.index + match[0].length;
  30645. if (lastIndex > lastLastIndex) {
  30646. output.push(str.slice(lastLastIndex, match.index));
  30647. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  30648. // nonparticipating capturing groups
  30649. if (!compliantExecNpcg && match.length > 1) {
  30650. match[0].replace(separator2, function () {
  30651. for (var i = 1; i < arguments.length - 2; i++) {
  30652. if (typeof(arguments[i]) === "undefined") {
  30653. match[i] = undefined;
  30654. }
  30655. }
  30656. });
  30657. }
  30658. if (match.length > 1 && match.index < str.length) {
  30659. Array.prototype.push.apply(output, match.slice(1));
  30660. }
  30661. lastLength = match[0].length;
  30662. lastLastIndex = lastIndex;
  30663. if (output.length >= limit) {
  30664. break;
  30665. }
  30666. }
  30667. if (separator.lastIndex === match.index) {
  30668. separator.lastIndex++; // Avoid an infinite loop
  30669. }
  30670. }
  30671. if (lastLastIndex === str.length) {
  30672. if (lastLength || !separator.test("")) {
  30673. output.push("");
  30674. }
  30675. } else {
  30676. output.push(str.slice(lastLastIndex));
  30677. }
  30678. return output.length > limit ? output.slice(0, limit) : output;
  30679. };
  30680. //============================================================================
  30681. // End contributed Cross-browser RegEx Split
  30682. //============================================================================
  30683. var uuid = function () {
  30684. /**
  30685. * http://www.ietf.org/rfc/rfc4122.txt
  30686. */
  30687. var s = [];
  30688. var hexDigits = "0123456789abcdef";
  30689. for (var i = 0; i < 32; i++) {
  30690. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  30691. }
  30692. s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  30693. s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  30694. var uuid = s.join("");
  30695. return uuid;
  30696. };
  30697. var _ANSI_COLORS = [
  30698. "ansi-black",
  30699. "ansi-red",
  30700. "ansi-green",
  30701. "ansi-yellow",
  30702. "ansi-blue",
  30703. "ansi-magenta",
  30704. "ansi-cyan",
  30705. "ansi-white",
  30706. "ansi-black-intense",
  30707. "ansi-red-intense",
  30708. "ansi-green-intense",
  30709. "ansi-yellow-intense",
  30710. "ansi-blue-intense",
  30711. "ansi-magenta-intense",
  30712. "ansi-cyan-intense",
  30713. "ansi-white-intense",
  30714. ];
  30715. function _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out) {
  30716. if (chunk) {
  30717. var classes = [];
  30718. var styles = [];
  30719. if (bold && typeof fg === "number" && 0 <= fg && fg < 8) {
  30720. fg += 8; // Bold text uses "intense" colors
  30721. }
  30722. if (inverse) {
  30723. [fg, bg] = [bg, fg];
  30724. }
  30725. if (typeof fg === "number") {
  30726. classes.push(_ANSI_COLORS[fg] + "-fg");
  30727. } else if (fg.length) {
  30728. styles.push("color: rgb(" + fg + ")");
  30729. } else if (inverse) {
  30730. classes.push("ansi-default-inverse-fg");
  30731. }
  30732. if (typeof bg === "number") {
  30733. classes.push(_ANSI_COLORS[bg] + "-bg");
  30734. } else if (bg.length) {
  30735. styles.push("background-color: rgb(" + bg + ")");
  30736. } else if (inverse) {
  30737. classes.push("ansi-default-inverse-bg");
  30738. }
  30739. if (bold) {
  30740. classes.push("ansi-bold");
  30741. }
  30742. if (underline) {
  30743. classes.push("ansi-underline");
  30744. }
  30745. if (classes.length || styles.length) {
  30746. out.push("<span");
  30747. if (classes.length) {
  30748. out.push(' class="' + classes.join(" ") + '"');
  30749. }
  30750. if (styles.length) {
  30751. out.push(' style="' + styles.join("; ") + '"');
  30752. }
  30753. out.push(">");
  30754. out.push(chunk);
  30755. out.push("</span>");
  30756. } else {
  30757. out.push(chunk);
  30758. }
  30759. }
  30760. }
  30761. function _getExtendedColors(numbers) {
  30762. var r, g, b;
  30763. var n = numbers.shift();
  30764. if (n === 2 && numbers.length >= 3) {
  30765. // 24-bit RGB
  30766. r = numbers.shift();
  30767. g = numbers.shift();
  30768. b = numbers.shift();
  30769. if ([r, g, b].some(function (c) { return c < 0 || 255 < c; })) {
  30770. throw new RangeError("Invalid range for RGB colors");
  30771. }
  30772. } else if (n === 5 && numbers.length >= 1) {
  30773. // 256 colors
  30774. var idx = numbers.shift();
  30775. if (idx < 0) {
  30776. throw new RangeError("Color index must be >= 0");
  30777. } else if (idx < 16) {
  30778. // 16 default terminal colors
  30779. return idx;
  30780. } else if (idx < 232) {
  30781. // 6x6x6 color cube, see https://stackoverflow.com/a/27165165/500098
  30782. r = Math.floor((idx - 16) / 36);
  30783. r = r > 0 ? 55 + r * 40 : 0;
  30784. g = Math.floor(((idx - 16) % 36) / 6);
  30785. g = g > 0 ? 55 + g * 40 : 0;
  30786. b = (idx - 16) % 6;
  30787. b = b > 0 ? 55 + b * 40 : 0;
  30788. } else if (idx < 256) {
  30789. // grayscale, see https://stackoverflow.com/a/27165165/500098
  30790. r = g = b = (idx - 232) * 10 + 8;
  30791. } else {
  30792. throw new RangeError("Color index must be < 256");
  30793. }
  30794. } else {
  30795. throw new RangeError("Invalid extended color specification");
  30796. }
  30797. return [r, g, b];
  30798. }
  30799. function _ansispan(str) {
  30800. var ansi_re = /\x1b\[(.*?)([@-~])/g;
  30801. var fg = [];
  30802. var bg = [];
  30803. var bold = false;
  30804. var underline = false;
  30805. var inverse = false;
  30806. var match;
  30807. var out = [];
  30808. var numbers = [];
  30809. var start = 0;
  30810. str += "\x1b[m"; // Ensure markup for trailing text
  30811. while ((match = ansi_re.exec(str))) {
  30812. if (match[2] === "m") {
  30813. var items = match[1].split(";");
  30814. for (var i = 0; i < items.length; i++) {
  30815. var item = items[i];
  30816. if (item === "") {
  30817. numbers.push(0);
  30818. } else if (item.search(/^\d+$/) !== -1) {
  30819. numbers.push(parseInt(item));
  30820. } else {
  30821. // Ignored: Invalid color specification
  30822. numbers.length = 0;
  30823. break;
  30824. }
  30825. }
  30826. } else {
  30827. // Ignored: Not a color code
  30828. }
  30829. var chunk = str.substring(start, match.index);
  30830. _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out);
  30831. start = ansi_re.lastIndex;
  30832. while (numbers.length) {
  30833. var n = numbers.shift();
  30834. switch (n) {
  30835. case 0:
  30836. fg = bg = [];
  30837. bold = false;
  30838. underline = false;
  30839. inverse = false;
  30840. break;
  30841. case 1:
  30842. case 5:
  30843. bold = true;
  30844. break;
  30845. case 4:
  30846. underline = true;
  30847. break;
  30848. case 7:
  30849. inverse = true;
  30850. break;
  30851. case 21:
  30852. case 22:
  30853. bold = false;
  30854. break;
  30855. case 24:
  30856. underline = false;
  30857. break;
  30858. case 27:
  30859. inverse = false;
  30860. break;
  30861. case 30:
  30862. case 31:
  30863. case 32:
  30864. case 33:
  30865. case 34:
  30866. case 35:
  30867. case 36:
  30868. case 37:
  30869. fg = n - 30;
  30870. break;
  30871. case 38:
  30872. try {
  30873. fg = _getExtendedColors(numbers);
  30874. } catch(e) {
  30875. numbers.length = 0;
  30876. }
  30877. break;
  30878. case 39:
  30879. fg = [];
  30880. break;
  30881. case 40:
  30882. case 41:
  30883. case 42:
  30884. case 43:
  30885. case 44:
  30886. case 45:
  30887. case 46:
  30888. case 47:
  30889. bg = n - 40;
  30890. break;
  30891. case 48:
  30892. try {
  30893. bg = _getExtendedColors(numbers);
  30894. } catch(e) {
  30895. numbers.length = 0;
  30896. }
  30897. break;
  30898. case 49:
  30899. bg = [];
  30900. break;
  30901. case 90:
  30902. case 91:
  30903. case 92:
  30904. case 93:
  30905. case 94:
  30906. case 95:
  30907. case 96:
  30908. case 97:
  30909. fg = n - 90 + 8;
  30910. break;
  30911. case 100:
  30912. case 101:
  30913. case 102:
  30914. case 103:
  30915. case 104:
  30916. case 105:
  30917. case 106:
  30918. case 107:
  30919. bg = n - 100 + 8;
  30920. break;
  30921. default:
  30922. // Unknown codes are ignored
  30923. }
  30924. }
  30925. }
  30926. return out.join("");
  30927. }
  30928. // Transform ANSI color escape codes into HTML <span> tags with CSS
  30929. // classes such as "ansi-green-intense-fg".
  30930. // The actual colors used are set in the CSS file.
  30931. // This is supposed to have the same behavior as nbconvert.filters.ansi2html()
  30932. function fixConsole(txt) {
  30933. txt = _.escape(txt);
  30934. // color ansi codes (and remove non-color escape sequences)
  30935. txt = _ansispan(txt);
  30936. return txt;
  30937. }
  30938. // Remove chunks that should be overridden by the effect of
  30939. // carriage return characters
  30940. function fixCarriageReturn(txt) {
  30941. txt = txt.replace(/\r+\n/gm, '\n'); // \r followed by \n --> newline
  30942. while (txt.search(/\r[^$]/g) > -1) {
  30943. var base = txt.match(/^(.*)\r+/m)[1];
  30944. var insert = txt.match(/\r+(.*)$/m)[1];
  30945. insert = insert + base.slice(insert.length, base.length);
  30946. txt = txt.replace(/\r+.*$/m, '\r').replace(/^.*\r/m, insert);
  30947. }
  30948. return txt;
  30949. }
  30950. // Remove characters that are overridden by backspace characters
  30951. function fixBackspace(txt) {
  30952. var tmp = txt;
  30953. do {
  30954. txt = tmp;
  30955. // Cancel out anything-but-newline followed by backspace
  30956. tmp = txt.replace(/[^\n]\x08/gm, '');
  30957. } while (tmp.length < txt.length);
  30958. return txt;
  30959. }
  30960. // Remove characters overridden by backspace and carriage return
  30961. function fixOverwrittenChars(txt) {
  30962. return fixCarriageReturn(fixBackspace(txt));
  30963. }
  30964. // Locate any URLs and convert them to an anchor tag
  30965. function autoLinkUrls(txt) {
  30966. return txt.replace(/(^|\s)(https?|ftp)(:[^'"<>\s]+)/gi,
  30967. "$1<a target=\"_blank\" href=\"$2$3\">$2$3</a>");
  30968. }
  30969. var points_to_pixels = function (points) {
  30970. /**
  30971. * A reasonably good way of converting between points and pixels.
  30972. */
  30973. var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>');
  30974. $('body').append(test);
  30975. var pixel_per_point = test.width()/10000;
  30976. test.remove();
  30977. return Math.floor(points*pixel_per_point);
  30978. };
  30979. var always_new = function (constructor) {
  30980. /**
  30981. * wrapper around contructor to avoid requiring `var a = new constructor()`
  30982. * useful for passing constructors as callbacks,
  30983. * not for programmer laziness.
  30984. * from https://programmers.stackexchange.com/questions/118798
  30985. */
  30986. return function () {
  30987. var obj = Object.create(constructor.prototype);
  30988. constructor.apply(obj, arguments);
  30989. return obj;
  30990. };
  30991. };
  30992. var url_path_join = function () {
  30993. /**
  30994. * join a sequence of url components with '/'
  30995. */
  30996. var url = '';
  30997. for (var i = 0; i < arguments.length; i++) {
  30998. if (arguments[i] === '') {
  30999. continue;
  31000. }
  31001. if (url.length > 0 && url[url.length-1] != '/') {
  31002. url = url + '/' + arguments[i];
  31003. } else {
  31004. url = url + arguments[i];
  31005. }
  31006. }
  31007. url = url.replace(/\/\/+/, '/');
  31008. return url;
  31009. };
  31010. var url_path_split = function (path) {
  31011. /**
  31012. * Like os.path.split for URLs.
  31013. * Always returns two strings, the directory path and the base filename
  31014. */
  31015. var idx = path.lastIndexOf('/');
  31016. if (idx === -1) {
  31017. return ['', path];
  31018. } else {
  31019. return [ path.slice(0, idx), path.slice(idx + 1) ];
  31020. }
  31021. };
  31022. var parse_url = function (url) {
  31023. /**
  31024. * an `a` element with an href allows attr-access to the parsed segments of a URL
  31025. * a = parse_url("http://localhost:8888/path/name#hash")
  31026. * a.protocol = "http:"
  31027. * a.host = "localhost:8888"
  31028. * a.hostname = "localhost"
  31029. * a.port = 8888
  31030. * a.pathname = "/path/name"
  31031. * a.hash = "#hash"
  31032. */
  31033. var a = document.createElement("a");
  31034. a.href = url;
  31035. return a;
  31036. };
  31037. var encode_uri_components = function (uri) {
  31038. /**
  31039. * encode just the components of a multi-segment uri,
  31040. * leaving '/' separators
  31041. */
  31042. return uri.split('/').map(encodeURIComponent).join('/');
  31043. };
  31044. var url_join_encode = function () {
  31045. /**
  31046. * join a sequence of url components with '/',
  31047. * encoding each component with encodeURIComponent
  31048. */
  31049. return encode_uri_components(url_path_join.apply(null, arguments));
  31050. };
  31051. var splitext = function (filename) {
  31052. /**
  31053. * mimic Python os.path.splitext
  31054. * Returns ['base', '.ext']
  31055. */
  31056. var idx = filename.lastIndexOf('.');
  31057. if (idx > 0) {
  31058. return [filename.slice(0, idx), filename.slice(idx)];
  31059. } else {
  31060. return [filename, ''];
  31061. }
  31062. };
  31063. var escape_html = function (text) {
  31064. /**
  31065. * escape text to HTML
  31066. */
  31067. return $("<div/>").text(text).html();
  31068. };
  31069. var get_body_data = function(key) {
  31070. /**
  31071. * get a url-encoded item from body.data and decode it
  31072. * we should never have any encoded URLs anywhere else in code
  31073. * until we are building an actual request
  31074. */
  31075. var val = $('body').data(key);
  31076. if (typeof val === 'undefined')
  31077. return val;
  31078. return decodeURIComponent(val);
  31079. };
  31080. var to_absolute_cursor_pos = function (cm, cursor) {
  31081. console.warn('`utils.to_absolute_cursor_pos(cm, pos)` is deprecated. Use `cm.indexFromPos(cursor)`');
  31082. return cm.indexFromPos(cursor);
  31083. };
  31084. var from_absolute_cursor_pos = function (cm, cursor_pos) {
  31085. console.warn('`utils.from_absolute_cursor_pos(cm, pos)` is deprecated. Use `cm.posFromIndex(index)`');
  31086. return cm.posFromIndex(cursor_pos);
  31087. };
  31088. // https://stackoverflow.com/questions/2400935/browser-detection-in-javascript
  31089. var browser = (function() {
  31090. if (typeof navigator === 'undefined') {
  31091. // navigator undefined in node
  31092. return 'None';
  31093. }
  31094. var N= navigator.appName, ua= navigator.userAgent, tem;
  31095. var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
  31096. if (M && (tem= ua.match(/version\/([\.\d]+)/i)) !== null) M[2]= tem[1];
  31097. M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
  31098. return M;
  31099. })();
  31100. // https://stackoverflow.com/questions/11219582/how-to-detect-my-browser-version-and-operating-system-using-javascript
  31101. var platform = (function () {
  31102. if (typeof navigator === 'undefined') {
  31103. // navigator undefined in node
  31104. return 'None';
  31105. }
  31106. var OSName="None";
  31107. if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
  31108. if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
  31109. if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
  31110. if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
  31111. return OSName;
  31112. })();
  31113. var get_url_param = function (name) {
  31114. // get a URL parameter. I cannot believe we actually need this.
  31115. // Based on https://stackoverflow.com/a/25359264/938949
  31116. var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  31117. if (match){
  31118. return decodeURIComponent(match[1] || '');
  31119. }
  31120. };
  31121. var is_or_has = function (a, b) {
  31122. /**
  31123. * Is b a child of a or a itself?
  31124. */
  31125. return a.has(b).length !==0 || a.is(b);
  31126. };
  31127. var is_focused = function (e) {
  31128. /**
  31129. * Is element e, or one of its children focused?
  31130. */
  31131. e = $(e);
  31132. var target = $(document.activeElement);
  31133. if (target.length > 0) {
  31134. if (is_or_has(e, target)) {
  31135. return true;
  31136. } else {
  31137. return false;
  31138. }
  31139. } else {
  31140. return false;
  31141. }
  31142. };
  31143. var mergeopt = function(_class, options, overwrite){
  31144. options = options || {};
  31145. overwrite = overwrite || {};
  31146. return $.extend(true, {}, _class.options_default, options, overwrite);
  31147. };
  31148. var ajax_error_msg = function (jqXHR) {
  31149. /**
  31150. * Return a JSON error message if there is one,
  31151. * otherwise the basic HTTP status text.
  31152. */
  31153. if (jqXHR.responseJSON && jqXHR.responseJSON.traceback) {
  31154. return jqXHR.responseJSON.traceback;
  31155. } else if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
  31156. return jqXHR.responseJSON.message;
  31157. } else {
  31158. return jqXHR.statusText;
  31159. }
  31160. };
  31161. var log_ajax_error = function (jqXHR, status, error) {
  31162. /**
  31163. * log ajax failures with informative messages
  31164. */
  31165. var msg = "API request failed (" + jqXHR.status + "): ";
  31166. console.log(jqXHR);
  31167. msg += ajax_error_msg(jqXHR);
  31168. console.log(msg);
  31169. };
  31170. var requireCodeMirrorMode = function (mode, callback, errback) {
  31171. /**
  31172. * find a predefined mode or detect from CM metadata then
  31173. * require and callback with the resolveable mode string: mime or
  31174. * custom name
  31175. */
  31176. var modename = (typeof mode == "string") ? mode :
  31177. mode.mode || mode.name;
  31178. // simplest, cheapest check by mode name: mode may also have config
  31179. if (CodeMirror.modes.hasOwnProperty(modename)) {
  31180. // return the full mode object, if it has a name
  31181. callback(mode.name ? mode : modename);
  31182. return;
  31183. }
  31184. // *somehow* get back a CM.modeInfo-like object that has .mode and
  31185. // .mime
  31186. var info = (mode && mode.mode && mode.mime && mode) ||
  31187. CodeMirror.findModeByName(modename) ||
  31188. CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
  31189. CodeMirror.findModeByMIME(modename) ||
  31190. {mode: modename, mime: modename};
  31191. requirejs([
  31192. // might want to use CodeMirror.modeURL here
  31193. ['codemirror/mode', info.mode, info.mode].join('/'),
  31194. ], function() {
  31195. // return the original mode, as from a kernelspec on first load
  31196. // or the mimetype, as for most highlighting
  31197. callback(mode.name ? mode : info.mime);
  31198. }, errback
  31199. );
  31200. };
  31201. /** Error type for wrapped XHR errors. */
  31202. var XHR_ERROR = 'XhrError';
  31203. /**
  31204. * Wraps an AJAX error as an Error object.
  31205. */
  31206. var wrap_ajax_error = function (jqXHR, status, error) {
  31207. var wrapped_error = new Error(ajax_error_msg(jqXHR));
  31208. wrapped_error.name = XHR_ERROR;
  31209. // provide xhr response
  31210. wrapped_error.xhr = jqXHR;
  31211. wrapped_error.xhr_status = status;
  31212. wrapped_error.xhr_error = error;
  31213. return wrapped_error;
  31214. };
  31215. var ajax = function (url, settings) {
  31216. // like $.ajax, but ensure XSRF or Authorization header is set
  31217. if (typeof url === "object") {
  31218. // called with single argument: $.ajax({url: '...'})
  31219. settings = url;
  31220. url = settings.url;
  31221. delete settings.url;
  31222. }
  31223. settings = _add_auth_header(settings);
  31224. return $.ajax(url, settings);
  31225. };
  31226. var _get_cookie = function (name) {
  31227. // from tornado docs: http://www.tornadoweb.org/en/stable/guide/security.html
  31228. var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
  31229. return r ? r[1] : undefined;
  31230. }
  31231. var _add_auth_header = function (settings) {
  31232. /**
  31233. * Adds auth header to jquery ajax settings
  31234. */
  31235. settings = settings || {};
  31236. if (!settings.headers) {
  31237. settings.headers = {};
  31238. }
  31239. if (!settings.headers.Authorization) {
  31240. var xsrf_token = _get_cookie('_xsrf');
  31241. if (xsrf_token) {
  31242. settings.headers['X-XSRFToken'] = xsrf_token;
  31243. }
  31244. }
  31245. return settings;
  31246. };
  31247. var promising_ajax = function(url, settings) {
  31248. /**
  31249. * Like $.ajax, but returning an ES6 promise. success and error settings
  31250. * will be ignored.
  31251. */
  31252. settings = settings || {};
  31253. return new Promise(function(resolve, reject) {
  31254. settings.success = function(data, status, jqXHR) {
  31255. resolve(data);
  31256. };
  31257. settings.error = function(jqXHR, status, error) {
  31258. log_ajax_error(jqXHR, status, error);
  31259. reject(wrap_ajax_error(jqXHR, status, error));
  31260. };
  31261. ajax(url, settings);
  31262. });
  31263. };
  31264. var WrappedError = function(message, error){
  31265. /**
  31266. * Wrappable Error class
  31267. *
  31268. * The Error class doesn't actually act on `this`. Instead it always
  31269. * returns a new instance of Error. Here we capture that instance so we
  31270. * can apply it's properties to `this`.
  31271. */
  31272. var tmp = Error.apply(this, [message]);
  31273. // Copy the properties of the error over to this.
  31274. var properties = Object.getOwnPropertyNames(tmp);
  31275. for (var i = 0; i < properties.length; i++) {
  31276. this[properties[i]] = tmp[properties[i]];
  31277. }
  31278. // Keep a stack of the original error messages.
  31279. if (error instanceof WrappedError) {
  31280. this.error_stack = error.error_stack;
  31281. } else {
  31282. this.error_stack = [error];
  31283. }
  31284. this.error_stack.push(tmp);
  31285. return this;
  31286. };
  31287. WrappedError.prototype = Object.create(Error.prototype, {});
  31288. var load_class = function(class_name, module_name, registry) {
  31289. /**
  31290. * Tries to load a class
  31291. *
  31292. * Tries to load a class from a module using require.js, if a module
  31293. * is specified, otherwise tries to load a class from the global
  31294. * registry, if the global registry is provided.
  31295. */
  31296. return new Promise(function(resolve, reject) {
  31297. // Try loading the view module using require.js
  31298. if (module_name) {
  31299. requirejs([module_name], function(module) {
  31300. if (module[class_name] === undefined) {
  31301. reject(new Error('Class '+class_name+' not found in module '+module_name));
  31302. } else {
  31303. resolve(module[class_name]);
  31304. }
  31305. }, reject);
  31306. } else {
  31307. if (registry && registry[class_name]) {
  31308. resolve(registry[class_name]);
  31309. } else {
  31310. reject(new Error('Class '+class_name+' not found in registry '));
  31311. }
  31312. }
  31313. });
  31314. };
  31315. var resolve_promises_dict = function(d) {
  31316. /**
  31317. * Resolve a promiseful dictionary.
  31318. * Returns a single Promise.
  31319. */
  31320. var keys = Object.keys(d);
  31321. var values = [];
  31322. keys.forEach(function(key) {
  31323. values.push(d[key]);
  31324. });
  31325. return Promise.all(values).then(function(v) {
  31326. d = {};
  31327. for(var i=0; i<keys.length; i++) {
  31328. d[keys[i]] = v[i];
  31329. }
  31330. return d;
  31331. });
  31332. };
  31333. var reject = function(message, log) {
  31334. /**
  31335. * Creates a wrappable Promise rejection function.
  31336. *
  31337. * Creates a function that returns a Promise.reject with a new WrappedError
  31338. * that has the provided message and wraps the original error that
  31339. * caused the promise to reject.
  31340. */
  31341. return function(error) {
  31342. var wrapped_error = new WrappedError(message, error);
  31343. if (log) {
  31344. console.error(message, " -- ", error);
  31345. }
  31346. return Promise.reject(wrapped_error);
  31347. };
  31348. };
  31349. var typeset = function(element, text) {
  31350. /**
  31351. * Apply MathJax rendering to an element, and optionally set its text
  31352. *
  31353. * If MathJax is not available, make no changes.
  31354. *
  31355. * Returns the output any number of typeset elements, or undefined if
  31356. * MathJax was not available.
  31357. *
  31358. * Parameters
  31359. * ----------
  31360. * element: Node, NodeList, or jQuery selection
  31361. * text: option string
  31362. */
  31363. var $el = element.jquery ? element : $(element);
  31364. if(arguments.length > 1){
  31365. $el.text(text);
  31366. }
  31367. if(!window.MathJax){
  31368. return;
  31369. }
  31370. $el.map(function(){
  31371. // MathJax takes a DOM node: $.map makes `this` the context
  31372. MathJax.Hub.Queue(["Typeset", MathJax.Hub, this]);
  31373. try {
  31374. MathJax.Hub.Queue(
  31375. ["Require", MathJax.Ajax, "[MathJax]/extensions/TeX/AMSmath.js"],
  31376. function() { MathJax.InputJax.TeX.resetEquationNumbers(); }
  31377. );
  31378. } catch (e) {
  31379. console.error("Error queueing resetEquationNumbers:", e);
  31380. }
  31381. });
  31382. };
  31383. var parse_b64_data_uri = function(uri) {
  31384. /**
  31385. * Parses a base64 encoded data-uri to extract mimetype and the
  31386. * base64 string.
  31387. *
  31388. * For example, given 'data:image/png;base64,iVBORw', it will return
  31389. * ["image/png", "iVBORw"]
  31390. *
  31391. * Parameters
  31392. */
  31393. // For performance reasons, the non-greedy ? qualifiers are crucial so
  31394. // that the matcher stops early on big blobs. Without them, it will try
  31395. // to match the whole blob which can take ages
  31396. var regex = /^data:(.+?\/.+?);base64,/;
  31397. var matches = uri.match(regex);
  31398. var mime = matches[1];
  31399. // matches[0] contains the whole data-uri prefix
  31400. var b64_data = uri.slice(matches[0].length);
  31401. return [mime, b64_data];
  31402. };
  31403. var time = {};
  31404. time.milliseconds = {};
  31405. time.milliseconds.s = 1000;
  31406. time.milliseconds.m = 60 * time.milliseconds.s;
  31407. time.milliseconds.h = 60 * time.milliseconds.m;
  31408. time.milliseconds.d = 24 * time.milliseconds.h;
  31409. time.thresholds = {
  31410. // moment.js thresholds in milliseconds
  31411. s: moment.relativeTimeThreshold('s') * time.milliseconds.s,
  31412. m: moment.relativeTimeThreshold('m') * time.milliseconds.m,
  31413. h: moment.relativeTimeThreshold('h') * time.milliseconds.h,
  31414. d: moment.relativeTimeThreshold('d') * time.milliseconds.d,
  31415. };
  31416. time.timeout_from_dt = function (dt) {
  31417. /** compute a timeout based on dt
  31418. input and output both in milliseconds
  31419. use moment's relative time thresholds:
  31420. - 10 seconds if in 'seconds ago' territory
  31421. - 1 minute if in 'minutes ago'
  31422. - 1 hour otherwise
  31423. */
  31424. if (dt < time.thresholds.s) {
  31425. return 10 * time.milliseconds.s;
  31426. } else if (dt < time.thresholds.m) {
  31427. return time.milliseconds.m;
  31428. } else {
  31429. return time.milliseconds.h;
  31430. }
  31431. };
  31432. var format_datetime = function(date) {
  31433. var text = moment(date).fromNow();
  31434. return text === 'a few seconds ago' ? 'seconds ago' : text;
  31435. };
  31436. var datetime_sort_helper = function(a, b, order) {
  31437. if (moment(a).isBefore(moment(b))) {
  31438. return (order == 1) ? -1 : 1;
  31439. } else if (moment(a).isSame(moment(b))) {
  31440. return 0;
  31441. } else {
  31442. return (order == 1) ? 1 : -1;
  31443. }
  31444. };
  31445. /**
  31446. source: https://github.com/sindresorhus/pretty-bytes
  31447. The MIT License (MIT)
  31448. Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
  31449. Permission is hereby granted, free of charge, to any person obtaining a copy
  31450. of this software and associated documentation files (the "Software"), to deal
  31451. in the Software without restriction, including without limitation the rights
  31452. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  31453. copies of the Software, and to permit persons to whom the Software is
  31454. furnished to do so, subject to the following conditions:
  31455. The above copyright notice and this permission notice shall be included in
  31456. all copies or substantial portions of the Software.
  31457. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  31458. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  31459. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  31460. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  31461. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  31462. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  31463. THE SOFTWARE.
  31464. **/
  31465. var format_filesize = function(num) {
  31466. if (num === undefined || num === null)
  31467. return;
  31468. var UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  31469. if (!Number.isFinite(num)) {
  31470. console.error("Expected finite number, got ", typeof(num) + ": " + num);
  31471. }
  31472. var neg = num < 0;
  31473. if (neg) {
  31474. num = -num;
  31475. }
  31476. if (num < 1) {
  31477. return (neg ? '-' : '') + num + ' B';
  31478. }
  31479. var exponent = Math.min(Math.floor(Math.log10(num) / 3), UNITS.length - 1);
  31480. var numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
  31481. var unit = UNITS[exponent];
  31482. return (neg ? '-' : '') + numStr + ' ' + unit;
  31483. }
  31484. // javascript stores text as utf16 and string indices use "code units",
  31485. // which stores high-codepoint characters as "surrogate pairs",
  31486. // which occupy two indices in the javascript string.
  31487. // We need to translate cursor_pos in the protocol (in characters)
  31488. // to js offset (with surrogate pairs taking two spots).
  31489. function js_idx_to_char_idx (js_idx, text) {
  31490. var char_idx = js_idx;
  31491. for (var i = 0; i + 1 < text.length && i < js_idx; i++) {
  31492. var char_code = text.charCodeAt(i);
  31493. // check for surrogate pair
  31494. if (char_code >= 0xD800 && char_code <= 0xDBFF) {
  31495. var next_char_code = text.charCodeAt(i+1);
  31496. if (next_char_code >= 0xDC00 && next_char_code <= 0xDFFF) {
  31497. char_idx--;
  31498. i++;
  31499. }
  31500. }
  31501. }
  31502. return char_idx;
  31503. }
  31504. function char_idx_to_js_idx (char_idx, text) {
  31505. var js_idx = char_idx;
  31506. for (var i = 0; i + 1 < text.length && i < js_idx; i++) {
  31507. var char_code = text.charCodeAt(i);
  31508. // check for surrogate pair
  31509. if (char_code >= 0xD800 && char_code <= 0xDBFF) {
  31510. var next_char_code = text.charCodeAt(i+1);
  31511. if (next_char_code >= 0xDC00 && next_char_code <= 0xDFFF) {
  31512. js_idx++;
  31513. i++;
  31514. }
  31515. }
  31516. }
  31517. return js_idx;
  31518. }
  31519. if ('𝐚'.length === 1) {
  31520. // If javascript fixes string indices of non-BMP characters,
  31521. // don't keep shifting offsets to compensate for surrogate pairs
  31522. char_idx_to_js_idx = js_idx_to_char_idx = function (idx, text) { return idx; };
  31523. }
  31524. // Test if a drag'n'drop event contains a file (as opposed to an HTML
  31525. // element/text from the document)
  31526. var dnd_contain_file = function(event) {
  31527. // As per the HTML5 drag'n'drop spec, the dataTransfer.types should
  31528. // contain one "Files" type if a file is being dragged
  31529. // https://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#dom-datatransfer-types
  31530. if (event.dataTransfer.types) {
  31531. for (var i = 0; i < event.dataTransfer.types.length; i++) {
  31532. if (event.dataTransfer.types[i] == "Files") {
  31533. return true;
  31534. }
  31535. }
  31536. }
  31537. return false;
  31538. };
  31539. var throttle = function(fn, time) {
  31540. var pending = null;
  31541. return function () {
  31542. if (pending) return;
  31543. pending = setTimeout(run, time);
  31544. return function () {
  31545. clearTimeout(pending);
  31546. pending = null;
  31547. }
  31548. }
  31549. function run () {
  31550. pending = null;
  31551. fn();
  31552. }
  31553. }
  31554. var change_favicon = function (src) {
  31555. var link = document.createElement('link'),
  31556. oldLink = document.getElementById('favicon');
  31557. link.id = 'favicon';
  31558. link.type = 'image/x-icon';
  31559. link.rel = 'shortcut icon';
  31560. link.href = utils.url_path_join(utils.get_body_data('baseUrl'), src);
  31561. if (oldLink && (link.href === oldLink.href)) {
  31562. // This favicon is already set, don't modify the DOM.
  31563. return;
  31564. }
  31565. if (oldLink) document.head.removeChild(oldLink);
  31566. document.head.appendChild(link);
  31567. };
  31568. var utils = {
  31569. throttle: throttle,
  31570. is_loaded: is_loaded,
  31571. load_extension: load_extension,
  31572. load_extensions: load_extensions,
  31573. filter_extensions: filter_extensions,
  31574. load_extensions_from_config: load_extensions_from_config,
  31575. regex_split : regex_split,
  31576. uuid : uuid,
  31577. fixConsole : fixConsole,
  31578. fixCarriageReturn : fixCarriageReturn,
  31579. fixBackspace : fixBackspace,
  31580. fixOverwrittenChars: fixOverwrittenChars,
  31581. autoLinkUrls : autoLinkUrls,
  31582. points_to_pixels : points_to_pixels,
  31583. get_body_data : get_body_data,
  31584. parse_url : parse_url,
  31585. url_path_split : url_path_split,
  31586. url_path_join : url_path_join,
  31587. url_join_encode : url_join_encode,
  31588. encode_uri_components : encode_uri_components,
  31589. splitext : splitext,
  31590. escape_html : escape_html,
  31591. always_new : always_new,
  31592. to_absolute_cursor_pos : to_absolute_cursor_pos,
  31593. from_absolute_cursor_pos : from_absolute_cursor_pos,
  31594. browser : browser,
  31595. platform: platform,
  31596. get_url_param: get_url_param,
  31597. is_or_has : is_or_has,
  31598. is_focused : is_focused,
  31599. mergeopt: mergeopt,
  31600. requireCodeMirrorMode : requireCodeMirrorMode,
  31601. XHR_ERROR : XHR_ERROR,
  31602. ajax : ajax,
  31603. ajax_error_msg : ajax_error_msg,
  31604. log_ajax_error : log_ajax_error,
  31605. wrap_ajax_error : wrap_ajax_error,
  31606. promising_ajax : promising_ajax,
  31607. WrappedError: WrappedError,
  31608. load_class: load_class,
  31609. resolve_promises_dict: resolve_promises_dict,
  31610. reject: reject,
  31611. typeset: typeset,
  31612. parse_b64_data_uri: parse_b64_data_uri,
  31613. time: time,
  31614. format_datetime: format_datetime,
  31615. format_filesize: format_filesize,
  31616. datetime_sort_helper: datetime_sort_helper,
  31617. dnd_contain_file: dnd_contain_file,
  31618. js_idx_to_char_idx: js_idx_to_char_idx,
  31619. char_idx_to_js_idx: char_idx_to_js_idx,
  31620. _ansispan:_ansispan,
  31621. change_favicon: change_favicon
  31622. };
  31623. return utils;
  31624. });
  31625. // Copyright (c) Jupyter Development Team.
  31626. // Distributed under the terms of the Modified BSD License.
  31627. var Jupyter = Jupyter || {};
  31628. var jprop = function(name, module_path){
  31629. Object.defineProperty(Jupyter, name, {
  31630. get: function() {
  31631. console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'")`');
  31632. return requirejs(module_path);
  31633. },
  31634. enumerable: true,
  31635. configurable: false
  31636. });
  31637. }
  31638. var jglobal = function(name, module_path){
  31639. Object.defineProperty(Jupyter, name, {
  31640. get: function() {
  31641. console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'").'+name+'`');
  31642. return requirejs(module_path)[name];
  31643. },
  31644. enumerable: true,
  31645. configurable: false
  31646. });
  31647. }
  31648. define('base/js/namespace',[],function(){
  31649. "use strict";
  31650. // expose modules
  31651. jprop('utils','base/js/utils')
  31652. //Jupyter.load_extensions = Jupyter.utils.load_extensions;
  31653. //
  31654. jprop('security','base/js/security');
  31655. jprop('keyboard','base/js/keyboard');
  31656. jprop('dialog','base/js/dialog');
  31657. jprop('mathjaxutils','notebook/js/mathjaxutils');
  31658. //// exposed constructors
  31659. jglobal('CommManager','services/kernels/comm')
  31660. jglobal('Comm','services/kernels/comm')
  31661. jglobal('NotificationWidget','base/js/notificationwidget');
  31662. jglobal('Kernel','services/kernels/kernel');
  31663. jglobal('Session','services/sessions/session');
  31664. jglobal('LoginWidget','auth/js/loginwidget');
  31665. jglobal('Page','base/js/page');
  31666. // notebook
  31667. jglobal('TextCell','notebook/js/textcell');
  31668. jglobal('OutputArea','notebook/js/outputarea');
  31669. jglobal('KeyboardManager','notebook/js/keyboardmanager');
  31670. jglobal('Completer','notebook/js/completer');
  31671. jglobal('Notebook','notebook/js/notebook');
  31672. jglobal('Tooltip','notebook/js/tooltip');
  31673. jglobal('Toolbar','notebook/js/toolbar');
  31674. jglobal('SaveWidget','notebook/js/savewidget');
  31675. jglobal('Pager','notebook/js/pager');
  31676. jglobal('QuickHelp','notebook/js/quickhelp');
  31677. jglobal('MarkdownCell','notebook/js/textcell');
  31678. jglobal('RawCell','notebook/js/textcell');
  31679. jglobal('Cell','notebook/js/cell');
  31680. jglobal('MainToolBar','notebook/js/maintoolbar');
  31681. jglobal('NotebookNotificationArea','notebook/js/notificationarea');
  31682. jglobal('NotebookTour', 'notebook/js/tour');
  31683. jglobal('MenuBar', 'notebook/js/menubar');
  31684. // tree
  31685. jglobal('SessionList','tree/js/sessionlist');
  31686. Jupyter.version = "5.7.10";
  31687. Jupyter._target = '_blank';
  31688. return Jupyter;
  31689. });
  31690. // deprecated since 4.0, remove in 5+
  31691. var IPython = Jupyter;
  31692. // Copyright (c) Jupyter Development Team.
  31693. // Distributed under the terms of the Modified BSD License.
  31694. // Give us an object to bind all events to. This object should be created
  31695. // before all other objects so it exists when others register event handlers.
  31696. // To register an event handler:
  31697. //
  31698. // requirejs(['base/js/events'], function (events) {
  31699. // events.on("event.Namespace", function () { do_stuff(); });
  31700. // });
  31701. define('base/js/events',['jquery', 'base/js/namespace'], function($, Jupyter) {
  31702. "use strict";
  31703. // Events singleton
  31704. if (!window._Events) {
  31705. window._Events = function () {};
  31706. window._events = new window._Events();
  31707. }
  31708. // Backwards compatability.
  31709. Jupyter.Events = window._Events;
  31710. Jupyter.events = window._events;
  31711. var events = $([window._events]);
  31712. // catch and log errors in triggered events
  31713. events._original_trigger = events.trigger;
  31714. events.trigger = function (name, data) {
  31715. try {
  31716. this._original_trigger.apply(this, arguments);
  31717. } catch (e) {
  31718. console.error("Exception in event handler for " + name, e, arguments);
  31719. }
  31720. }
  31721. return events;
  31722. });
  31723. // Copyright (c) Jupyter Development Team.
  31724. // Distributed under the terms of the Modified BSD License.
  31725. define('base/js/page',[
  31726. 'jquery',
  31727. 'base/js/events',
  31728. ], function($, events){
  31729. "use strict";
  31730. var Page = function (header_div_selector, site_div_selector) {
  31731. /**
  31732. * Constructor
  31733. *
  31734. * Parameters
  31735. * header_div_selector: string
  31736. * site_div_selector: string
  31737. */
  31738. this.header_div_element = $(header_div_selector || 'div#header');
  31739. this.site_div_element = $(site_div_selector || 'div#site');
  31740. this.bind_events();
  31741. };
  31742. Page.prototype.bind_events = function () {
  31743. // resize site on:
  31744. // - window resize
  31745. // - header change
  31746. // - page load
  31747. var _handle_resize = $.proxy(this._resize_site, this);
  31748. $(window).resize(_handle_resize);
  31749. // On document ready, resize codemirror.
  31750. $(document).ready(_handle_resize);
  31751. events.on('resize-header.Page', _handle_resize);
  31752. };
  31753. Page.prototype.show = function () {
  31754. /**
  31755. * The header and site divs start out hidden to prevent FLOUC.
  31756. * Main scripts should call this method after styling everything.
  31757. */
  31758. this.show_header();
  31759. this.show_site();
  31760. };
  31761. Page.prototype.show_header = function () {
  31762. /**
  31763. * The header and site divs start out hidden to prevent FLOUC.
  31764. * Main scripts should call this method after styling everything.
  31765. */
  31766. this.header_div_element.css('display','block');
  31767. };
  31768. Page.prototype.show_site = function () {
  31769. /**
  31770. * The header and site divs start out hidden to prevent FLOUC.
  31771. * Main scripts should call this method after styling everything.
  31772. */
  31773. this.site_div_element.css('display', 'block');
  31774. this._resize_site();
  31775. };
  31776. Page.prototype._resize_site = function(e) {
  31777. /**
  31778. * Update the site's size.
  31779. */
  31780. // In the case an event is passed in, only trigger if the event does
  31781. // *not* have a target DOM node (i.e., it is not bubbling up). See
  31782. // https://bugs.jquery.com/ticket/9841#comment:8
  31783. if (!(e && e.target && e.target.tagName)) {
  31784. $('div#site').height($(window).height() - $('#header').height());
  31785. }
  31786. };
  31787. return {'Page': Page};
  31788. });
  31789. // Copyright (c) Jupyter Development Team.
  31790. // Distributed under the terms of the Modified BSD License.
  31791. define('auth/js/loginwidget',[
  31792. 'jquery',
  31793. 'base/js/utils',
  31794. ], function($, utils){
  31795. "use strict";
  31796. var LoginWidget = function (selector, options) {
  31797. options = options || {};
  31798. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  31799. this.selector = selector;
  31800. if (this.selector !== undefined) {
  31801. this.element = $(selector);
  31802. this.bind_events();
  31803. }
  31804. };
  31805. LoginWidget.prototype.bind_events = function () {
  31806. var that = this;
  31807. this.element.find("button#logout").click(function () {
  31808. window.location = utils.url_path_join(
  31809. that.base_url,
  31810. "logout"
  31811. );
  31812. });
  31813. this.element.find("button#login").click(function () {
  31814. window.location = utils.url_path_join(
  31815. that.base_url,
  31816. "login"
  31817. );
  31818. });
  31819. };
  31820. return {'LoginWidget': LoginWidget};
  31821. });
  31822. // Copyright (c) Jupyter Development Team.
  31823. // Distributed under the terms of the Modified BSD License.
  31824. define('services/config',[
  31825. 'base/js/utils',
  31826. ],
  31827. function(utils) {
  31828. "use strict";
  31829. var ConfigSection = function(section_name, options) {
  31830. this.section_name = section_name;
  31831. this.base_url = options.base_url;
  31832. this.data = {};
  31833. var that = this;
  31834. /* .loaded is a promise, fulfilled the first time the config is loaded
  31835. * from the server. Code can do:
  31836. * conf.loaded.then(function() { ... using conf.data ... });
  31837. */
  31838. this._one_load_finished = false;
  31839. this.loaded = new Promise(function(resolve, reject) {
  31840. that._finish_firstload = resolve;
  31841. });
  31842. };
  31843. ConfigSection.prototype.api_url = function() {
  31844. return utils.url_path_join(this.base_url, 'api/config',
  31845. utils.encode_uri_components(this.section_name));
  31846. };
  31847. ConfigSection.prototype._load_done = function() {
  31848. if (!this._one_load_finished) {
  31849. this._one_load_finished = true;
  31850. this._finish_firstload();
  31851. }
  31852. };
  31853. ConfigSection.prototype.load = function() {
  31854. var that = this;
  31855. return utils.promising_ajax(this.api_url(), {
  31856. cache: false,
  31857. type: "GET",
  31858. dataType: "json",
  31859. }).then(function(data) {
  31860. that.data = data;
  31861. that._load_done();
  31862. return data;
  31863. });
  31864. };
  31865. /**
  31866. * Modify the config values stored. Update the local data immediately,
  31867. * send the change to the server, and use the updated data from the server
  31868. * when the reply comes.
  31869. */
  31870. ConfigSection.prototype.update = function(newdata) {
  31871. $.extend(true, this.data, newdata); // true -> recursive update
  31872. var that = this;
  31873. return utils.promising_ajax(this.api_url(), {
  31874. processData: false,
  31875. type : "PATCH",
  31876. data: JSON.stringify(newdata),
  31877. dataType : "json",
  31878. contentType: 'application/json',
  31879. }).then(function(data) {
  31880. that.data = data;
  31881. that._load_done();
  31882. return data;
  31883. });
  31884. };
  31885. var ConfigWithDefaults = function(section, defaults, classname) {
  31886. this.section = section;
  31887. this.defaults = defaults;
  31888. this.classname = classname;
  31889. };
  31890. ConfigWithDefaults.prototype._class_data = function() {
  31891. if (this.classname) {
  31892. return this.section.data[this.classname] || {};
  31893. } else {
  31894. return this.section.data;
  31895. }
  31896. };
  31897. /**
  31898. * Wait for config to have loaded, then get a value or the default.
  31899. * Returns a promise.
  31900. */
  31901. ConfigWithDefaults.prototype.get = function(key) {
  31902. var that = this;
  31903. return this.section.loaded.then(function() {
  31904. return that.get_sync(key);
  31905. });
  31906. };
  31907. /**
  31908. * Return a config value. If config is not yet loaded, return the default
  31909. * instead of waiting for it to load.
  31910. */
  31911. ConfigWithDefaults.prototype.get_sync = function(key) {
  31912. var data = this._class_data();
  31913. if (key === undefined) {
  31914. // no key specified, return full config data
  31915. return $.extend(true, {}, this.defaults, data);
  31916. }
  31917. var value = data[key];
  31918. if (value !== undefined) {
  31919. if (typeof value == 'object') {
  31920. // merge with defaults if it's an object
  31921. return $.extend(true, {}, this.defaults[key], value);
  31922. } else {
  31923. return value;
  31924. }
  31925. }
  31926. return this.defaults[key];
  31927. };
  31928. /**
  31929. * Set a config value. Send the update to the server, and change our
  31930. * local copy of the data immediately.
  31931. * Returns a promise which is fulfilled when the server replies to the
  31932. * change.
  31933. */
  31934. ConfigWithDefaults.prototype.set = function(key, value) {
  31935. var d = {};
  31936. d[key] = value;
  31937. if (this.classname) {
  31938. var d2 = {};
  31939. d2[this.classname] = d;
  31940. return this.section.update(d2);
  31941. } else {
  31942. return this.section.update(d);
  31943. }
  31944. };
  31945. return {ConfigSection: ConfigSection,
  31946. ConfigWithDefaults: ConfigWithDefaults,
  31947. };
  31948. });
  31949. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define('xterm',[],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Terminal = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  31950. "use strict";
  31951. Object.defineProperty(exports, "__esModule", { value: true });
  31952. var CircularList_1 = require("./utils/CircularList");
  31953. exports.CHAR_DATA_ATTR_INDEX = 0;
  31954. exports.CHAR_DATA_CHAR_INDEX = 1;
  31955. exports.CHAR_DATA_WIDTH_INDEX = 2;
  31956. exports.CHAR_DATA_CODE_INDEX = 3;
  31957. exports.MAX_BUFFER_SIZE = 4294967295;
  31958. var Buffer = (function () {
  31959. function Buffer(_terminal, _hasScrollback) {
  31960. this._terminal = _terminal;
  31961. this._hasScrollback = _hasScrollback;
  31962. this.clear();
  31963. }
  31964. Object.defineProperty(Buffer.prototype, "lines", {
  31965. get: function () {
  31966. return this._lines;
  31967. },
  31968. enumerable: true,
  31969. configurable: true
  31970. });
  31971. Object.defineProperty(Buffer.prototype, "hasScrollback", {
  31972. get: function () {
  31973. return this._hasScrollback && this.lines.maxLength > this._terminal.rows;
  31974. },
  31975. enumerable: true,
  31976. configurable: true
  31977. });
  31978. Object.defineProperty(Buffer.prototype, "isCursorInViewport", {
  31979. get: function () {
  31980. var absoluteY = this.ybase + this.y;
  31981. var relativeY = absoluteY - this.ydisp;
  31982. return (relativeY >= 0 && relativeY < this._terminal.rows);
  31983. },
  31984. enumerable: true,
  31985. configurable: true
  31986. });
  31987. Buffer.prototype._getCorrectBufferLength = function (rows) {
  31988. if (!this._hasScrollback) {
  31989. return rows;
  31990. }
  31991. var correctBufferLength = rows + this._terminal.options.scrollback;
  31992. return correctBufferLength > exports.MAX_BUFFER_SIZE ? exports.MAX_BUFFER_SIZE : correctBufferLength;
  31993. };
  31994. Buffer.prototype.fillViewportRows = function () {
  31995. if (this._lines.length === 0) {
  31996. var i = this._terminal.rows;
  31997. while (i--) {
  31998. this.lines.push(this._terminal.blankLine());
  31999. }
  32000. }
  32001. };
  32002. Buffer.prototype.clear = function () {
  32003. this.ydisp = 0;
  32004. this.ybase = 0;
  32005. this.y = 0;
  32006. this.x = 0;
  32007. this._lines = new CircularList_1.CircularList(this._getCorrectBufferLength(this._terminal.rows));
  32008. this.scrollTop = 0;
  32009. this.scrollBottom = this._terminal.rows - 1;
  32010. this.setupTabStops();
  32011. };
  32012. Buffer.prototype.resize = function (newCols, newRows) {
  32013. var newMaxLength = this._getCorrectBufferLength(newRows);
  32014. if (newMaxLength > this._lines.maxLength) {
  32015. this._lines.maxLength = newMaxLength;
  32016. }
  32017. if (this._lines.length > 0) {
  32018. if (this._terminal.cols < newCols) {
  32019. var ch = [this._terminal.defAttr, ' ', 1, 32];
  32020. for (var i = 0; i < this._lines.length; i++) {
  32021. while (this._lines.get(i).length < newCols) {
  32022. this._lines.get(i).push(ch);
  32023. }
  32024. }
  32025. }
  32026. var addToY = 0;
  32027. if (this._terminal.rows < newRows) {
  32028. for (var y = this._terminal.rows; y < newRows; y++) {
  32029. if (this._lines.length < newRows + this.ybase) {
  32030. if (this.ybase > 0 && this._lines.length <= this.ybase + this.y + addToY + 1) {
  32031. this.ybase--;
  32032. addToY++;
  32033. if (this.ydisp > 0) {
  32034. this.ydisp--;
  32035. }
  32036. }
  32037. else {
  32038. this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));
  32039. }
  32040. }
  32041. }
  32042. }
  32043. else {
  32044. for (var y = this._terminal.rows; y > newRows; y--) {
  32045. if (this._lines.length > newRows + this.ybase) {
  32046. if (this._lines.length > this.ybase + this.y + 1) {
  32047. this._lines.pop();
  32048. }
  32049. else {
  32050. this.ybase++;
  32051. this.ydisp++;
  32052. }
  32053. }
  32054. }
  32055. }
  32056. if (newMaxLength < this._lines.maxLength) {
  32057. var amountToTrim = this._lines.length - newMaxLength;
  32058. if (amountToTrim > 0) {
  32059. this._lines.trimStart(amountToTrim);
  32060. this.ybase = Math.max(this.ybase - amountToTrim, 0);
  32061. this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
  32062. }
  32063. this._lines.maxLength = newMaxLength;
  32064. }
  32065. this.x = Math.min(this.x, newCols - 1);
  32066. this.y = Math.min(this.y, newRows - 1);
  32067. if (addToY) {
  32068. this.y += addToY;
  32069. }
  32070. this.savedY = Math.min(this.savedY, newRows - 1);
  32071. this.savedX = Math.min(this.savedX, newCols - 1);
  32072. this.scrollTop = 0;
  32073. }
  32074. this.scrollBottom = newRows - 1;
  32075. };
  32076. Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) {
  32077. if (startCol === void 0) { startCol = 0; }
  32078. if (endCol === void 0) { endCol = null; }
  32079. var lineString = '';
  32080. var line = this.lines.get(lineIndex);
  32081. if (!line) {
  32082. return '';
  32083. }
  32084. var startIndex = startCol;
  32085. if (endCol === null) {
  32086. endCol = line.length;
  32087. }
  32088. var endIndex = endCol;
  32089. for (var i = 0; i < line.length; i++) {
  32090. var char = line[i];
  32091. lineString += char[exports.CHAR_DATA_CHAR_INDEX];
  32092. if (char[exports.CHAR_DATA_WIDTH_INDEX] === 0) {
  32093. if (startCol >= i) {
  32094. startIndex--;
  32095. }
  32096. if (endCol >= i) {
  32097. endIndex--;
  32098. }
  32099. }
  32100. else {
  32101. if (char[exports.CHAR_DATA_CHAR_INDEX].length > 1) {
  32102. if (startCol > i) {
  32103. startIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;
  32104. }
  32105. if (endCol > i) {
  32106. endIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;
  32107. }
  32108. }
  32109. }
  32110. }
  32111. if (trimRight) {
  32112. var rightWhitespaceIndex = lineString.search(/\s+$/);
  32113. if (rightWhitespaceIndex !== -1) {
  32114. endIndex = Math.min(endIndex, rightWhitespaceIndex);
  32115. }
  32116. if (endIndex <= startIndex) {
  32117. return '';
  32118. }
  32119. }
  32120. return lineString.substring(startIndex, endIndex);
  32121. };
  32122. Buffer.prototype.setupTabStops = function (i) {
  32123. if (i != null) {
  32124. if (!this.tabs[i]) {
  32125. i = this.prevStop(i);
  32126. }
  32127. }
  32128. else {
  32129. this.tabs = {};
  32130. i = 0;
  32131. }
  32132. for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) {
  32133. this.tabs[i] = true;
  32134. }
  32135. };
  32136. Buffer.prototype.prevStop = function (x) {
  32137. if (x == null) {
  32138. x = this.x;
  32139. }
  32140. while (!this.tabs[--x] && x > 0)
  32141. ;
  32142. return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
  32143. };
  32144. Buffer.prototype.nextStop = function (x) {
  32145. if (x == null) {
  32146. x = this.x;
  32147. }
  32148. while (!this.tabs[++x] && x < this._terminal.cols)
  32149. ;
  32150. return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
  32151. };
  32152. return Buffer;
  32153. }());
  32154. exports.Buffer = Buffer;
  32155. },{"./utils/CircularList":32}],2:[function(require,module,exports){
  32156. "use strict";
  32157. var __extends = (this && this.__extends) || (function () {
  32158. var extendStatics = Object.setPrototypeOf ||
  32159. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32160. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32161. return function (d, b) {
  32162. extendStatics(d, b);
  32163. function __() { this.constructor = d; }
  32164. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32165. };
  32166. })();
  32167. Object.defineProperty(exports, "__esModule", { value: true });
  32168. var Buffer_1 = require("./Buffer");
  32169. var EventEmitter_1 = require("./EventEmitter");
  32170. var BufferSet = (function (_super) {
  32171. __extends(BufferSet, _super);
  32172. function BufferSet(_terminal) {
  32173. var _this = _super.call(this) || this;
  32174. _this._terminal = _terminal;
  32175. _this._normal = new Buffer_1.Buffer(_this._terminal, true);
  32176. _this._normal.fillViewportRows();
  32177. _this._alt = new Buffer_1.Buffer(_this._terminal, false);
  32178. _this._activeBuffer = _this._normal;
  32179. _this.setupTabStops();
  32180. return _this;
  32181. }
  32182. Object.defineProperty(BufferSet.prototype, "alt", {
  32183. get: function () {
  32184. return this._alt;
  32185. },
  32186. enumerable: true,
  32187. configurable: true
  32188. });
  32189. Object.defineProperty(BufferSet.prototype, "active", {
  32190. get: function () {
  32191. return this._activeBuffer;
  32192. },
  32193. enumerable: true,
  32194. configurable: true
  32195. });
  32196. Object.defineProperty(BufferSet.prototype, "normal", {
  32197. get: function () {
  32198. return this._normal;
  32199. },
  32200. enumerable: true,
  32201. configurable: true
  32202. });
  32203. BufferSet.prototype.activateNormalBuffer = function () {
  32204. if (this._activeBuffer === this._normal) {
  32205. return;
  32206. }
  32207. this._alt.clear();
  32208. this._activeBuffer = this._normal;
  32209. this.emit('activate', {
  32210. activeBuffer: this._normal,
  32211. inactiveBuffer: this._alt
  32212. });
  32213. };
  32214. BufferSet.prototype.activateAltBuffer = function () {
  32215. if (this._activeBuffer === this._alt) {
  32216. return;
  32217. }
  32218. this._alt.fillViewportRows();
  32219. this._activeBuffer = this._alt;
  32220. this.emit('activate', {
  32221. activeBuffer: this._alt,
  32222. inactiveBuffer: this._normal
  32223. });
  32224. };
  32225. BufferSet.prototype.resize = function (newCols, newRows) {
  32226. this._normal.resize(newCols, newRows);
  32227. this._alt.resize(newCols, newRows);
  32228. };
  32229. BufferSet.prototype.setupTabStops = function (i) {
  32230. this._normal.setupTabStops(i);
  32231. this._alt.setupTabStops(i);
  32232. };
  32233. return BufferSet;
  32234. }(EventEmitter_1.EventEmitter));
  32235. exports.BufferSet = BufferSet;
  32236. },{"./Buffer":1,"./EventEmitter":7}],3:[function(require,module,exports){
  32237. "use strict";
  32238. Object.defineProperty(exports, "__esModule", { value: true });
  32239. exports.wcwidth = (function (opts) {
  32240. var COMBINING_BMP = [
  32241. [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
  32242. [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
  32243. [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
  32244. [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
  32245. [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
  32246. [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
  32247. [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
  32248. [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
  32249. [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
  32250. [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
  32251. [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
  32252. [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
  32253. [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
  32254. [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
  32255. [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
  32256. [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
  32257. [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
  32258. [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
  32259. [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
  32260. [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
  32261. [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
  32262. [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
  32263. [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
  32264. [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
  32265. [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
  32266. [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
  32267. [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
  32268. [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
  32269. [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
  32270. [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
  32271. [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
  32272. [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
  32273. [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
  32274. [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
  32275. [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
  32276. [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
  32277. [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
  32278. [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
  32279. [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
  32280. [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
  32281. [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
  32282. [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
  32283. [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],
  32284. ];
  32285. var COMBINING_HIGH = [
  32286. [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
  32287. [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
  32288. [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
  32289. [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
  32290. [0xE0100, 0xE01EF]
  32291. ];
  32292. function bisearch(ucs, data) {
  32293. var min = 0;
  32294. var max = data.length - 1;
  32295. var mid;
  32296. if (ucs < data[0][0] || ucs > data[max][1]) {
  32297. return false;
  32298. }
  32299. while (max >= min) {
  32300. mid = (min + max) >> 1;
  32301. if (ucs > data[mid][1]) {
  32302. min = mid + 1;
  32303. }
  32304. else if (ucs < data[mid][0]) {
  32305. max = mid - 1;
  32306. }
  32307. else {
  32308. return true;
  32309. }
  32310. }
  32311. return false;
  32312. }
  32313. function wcwidthBMP(ucs) {
  32314. if (ucs === 0) {
  32315. return opts.nul;
  32316. }
  32317. if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
  32318. return opts.control;
  32319. }
  32320. if (bisearch(ucs, COMBINING_BMP)) {
  32321. return 0;
  32322. }
  32323. if (isWideBMP(ucs)) {
  32324. return 2;
  32325. }
  32326. return 1;
  32327. }
  32328. function isWideBMP(ucs) {
  32329. return (ucs >= 0x1100 && (ucs <= 0x115f ||
  32330. ucs === 0x2329 ||
  32331. ucs === 0x232a ||
  32332. (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) ||
  32333. (ucs >= 0xac00 && ucs <= 0xd7a3) ||
  32334. (ucs >= 0xf900 && ucs <= 0xfaff) ||
  32335. (ucs >= 0xfe10 && ucs <= 0xfe19) ||
  32336. (ucs >= 0xfe30 && ucs <= 0xfe6f) ||
  32337. (ucs >= 0xff00 && ucs <= 0xff60) ||
  32338. (ucs >= 0xffe0 && ucs <= 0xffe6)));
  32339. }
  32340. function wcwidthHigh(ucs) {
  32341. if (bisearch(ucs, COMBINING_HIGH)) {
  32342. return 0;
  32343. }
  32344. if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
  32345. return 2;
  32346. }
  32347. return 1;
  32348. }
  32349. var control = opts.control | 0;
  32350. var table = null;
  32351. function init_table() {
  32352. var CODEPOINTS = 65536;
  32353. var BITWIDTH = 2;
  32354. var ITEMSIZE = 32;
  32355. var CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;
  32356. var CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;
  32357. table = (typeof Uint32Array === 'undefined')
  32358. ? new Array(CONTAINERSIZE)
  32359. : new Uint32Array(CONTAINERSIZE);
  32360. for (var i = 0; i < CONTAINERSIZE; ++i) {
  32361. var num = 0;
  32362. var pos = CODEPOINTS_PER_ITEM;
  32363. while (pos--) {
  32364. num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
  32365. }
  32366. table[i] = num;
  32367. }
  32368. return table;
  32369. }
  32370. return function (num) {
  32371. num = num | 0;
  32372. if (num < 32) {
  32373. return control | 0;
  32374. }
  32375. if (num < 127) {
  32376. return 1;
  32377. }
  32378. var t = table || init_table();
  32379. if (num < 65536) {
  32380. return t[num >> 4] >> ((num & 15) << 1) & 3;
  32381. }
  32382. return wcwidthHigh(num);
  32383. };
  32384. })({ nul: 0, control: 0 });
  32385. },{}],4:[function(require,module,exports){
  32386. "use strict";
  32387. Object.defineProperty(exports, "__esModule", { value: true });
  32388. exports.CHARSETS = {};
  32389. exports.DEFAULT_CHARSET = exports.CHARSETS['B'];
  32390. exports.CHARSETS['0'] = {
  32391. '`': '\u25c6',
  32392. 'a': '\u2592',
  32393. 'b': '\u0009',
  32394. 'c': '\u000c',
  32395. 'd': '\u000d',
  32396. 'e': '\u000a',
  32397. 'f': '\u00b0',
  32398. 'g': '\u00b1',
  32399. 'h': '\u2424',
  32400. 'i': '\u000b',
  32401. 'j': '\u2518',
  32402. 'k': '\u2510',
  32403. 'l': '\u250c',
  32404. 'm': '\u2514',
  32405. 'n': '\u253c',
  32406. 'o': '\u23ba',
  32407. 'p': '\u23bb',
  32408. 'q': '\u2500',
  32409. 'r': '\u23bc',
  32410. 's': '\u23bd',
  32411. 't': '\u251c',
  32412. 'u': '\u2524',
  32413. 'v': '\u2534',
  32414. 'w': '\u252c',
  32415. 'x': '\u2502',
  32416. 'y': '\u2264',
  32417. 'z': '\u2265',
  32418. '{': '\u03c0',
  32419. '|': '\u2260',
  32420. '}': '\u00a3',
  32421. '~': '\u00b7'
  32422. };
  32423. exports.CHARSETS['A'] = {
  32424. '#': '£'
  32425. };
  32426. exports.CHARSETS['B'] = null;
  32427. exports.CHARSETS['4'] = {
  32428. '#': '£',
  32429. '@': '¾',
  32430. '[': 'ij',
  32431. '\\': '½',
  32432. ']': '|',
  32433. '{': '¨',
  32434. '|': 'f',
  32435. '}': '¼',
  32436. '~': '´'
  32437. };
  32438. exports.CHARSETS['C'] =
  32439. exports.CHARSETS['5'] = {
  32440. '[': 'Ä',
  32441. '\\': 'Ö',
  32442. ']': 'Å',
  32443. '^': 'Ü',
  32444. '`': 'é',
  32445. '{': 'ä',
  32446. '|': 'ö',
  32447. '}': 'å',
  32448. '~': 'ü'
  32449. };
  32450. exports.CHARSETS['R'] = {
  32451. '#': '£',
  32452. '@': 'à',
  32453. '[': '°',
  32454. '\\': 'ç',
  32455. ']': '§',
  32456. '{': 'é',
  32457. '|': 'ù',
  32458. '}': 'è',
  32459. '~': '¨'
  32460. };
  32461. exports.CHARSETS['Q'] = {
  32462. '@': 'à',
  32463. '[': 'â',
  32464. '\\': 'ç',
  32465. ']': 'ê',
  32466. '^': 'î',
  32467. '`': 'ô',
  32468. '{': 'é',
  32469. '|': 'ù',
  32470. '}': 'è',
  32471. '~': 'û'
  32472. };
  32473. exports.CHARSETS['K'] = {
  32474. '@': '§',
  32475. '[': 'Ä',
  32476. '\\': 'Ö',
  32477. ']': 'Ü',
  32478. '{': 'ä',
  32479. '|': 'ö',
  32480. '}': 'ü',
  32481. '~': 'ß'
  32482. };
  32483. exports.CHARSETS['Y'] = {
  32484. '#': '£',
  32485. '@': '§',
  32486. '[': '°',
  32487. '\\': 'ç',
  32488. ']': 'é',
  32489. '`': 'ù',
  32490. '{': 'à',
  32491. '|': 'ò',
  32492. '}': 'è',
  32493. '~': 'ì'
  32494. };
  32495. exports.CHARSETS['E'] =
  32496. exports.CHARSETS['6'] = {
  32497. '@': 'Ä',
  32498. '[': 'Æ',
  32499. '\\': 'Ø',
  32500. ']': 'Å',
  32501. '^': 'Ü',
  32502. '`': 'ä',
  32503. '{': 'æ',
  32504. '|': 'ø',
  32505. '}': 'å',
  32506. '~': 'ü'
  32507. };
  32508. exports.CHARSETS['Z'] = {
  32509. '#': '£',
  32510. '@': '§',
  32511. '[': '¡',
  32512. '\\': 'Ñ',
  32513. ']': '¿',
  32514. '{': '°',
  32515. '|': 'ñ',
  32516. '}': 'ç'
  32517. };
  32518. exports.CHARSETS['H'] =
  32519. exports.CHARSETS['7'] = {
  32520. '@': 'É',
  32521. '[': 'Ä',
  32522. '\\': 'Ö',
  32523. ']': 'Å',
  32524. '^': 'Ü',
  32525. '`': 'é',
  32526. '{': 'ä',
  32527. '|': 'ö',
  32528. '}': 'å',
  32529. '~': 'ü'
  32530. };
  32531. exports.CHARSETS['='] = {
  32532. '#': 'ù',
  32533. '@': 'à',
  32534. '[': 'é',
  32535. '\\': 'ç',
  32536. ']': 'ê',
  32537. '^': 'î',
  32538. '_': 'è',
  32539. '`': 'ô',
  32540. '{': 'ä',
  32541. '|': 'ö',
  32542. '}': 'ü',
  32543. '~': 'û'
  32544. };
  32545. },{}],5:[function(require,module,exports){
  32546. "use strict";
  32547. Object.defineProperty(exports, "__esModule", { value: true });
  32548. var CompositionHelper = (function () {
  32549. function CompositionHelper(textarea, compositionView, terminal) {
  32550. this.textarea = textarea;
  32551. this.compositionView = compositionView;
  32552. this.terminal = terminal;
  32553. this.isComposing = false;
  32554. this.isSendingComposition = false;
  32555. this.compositionPosition = { start: null, end: null };
  32556. }
  32557. CompositionHelper.prototype.compositionstart = function () {
  32558. this.isComposing = true;
  32559. this.compositionPosition.start = this.textarea.value.length;
  32560. this.compositionView.textContent = '';
  32561. this.compositionView.classList.add('active');
  32562. };
  32563. CompositionHelper.prototype.compositionupdate = function (ev) {
  32564. var _this = this;
  32565. this.compositionView.textContent = ev.data;
  32566. this.updateCompositionElements();
  32567. setTimeout(function () {
  32568. _this.compositionPosition.end = _this.textarea.value.length;
  32569. }, 0);
  32570. };
  32571. CompositionHelper.prototype.compositionend = function () {
  32572. this.finalizeComposition(true);
  32573. };
  32574. CompositionHelper.prototype.keydown = function (ev) {
  32575. if (this.isComposing || this.isSendingComposition) {
  32576. if (ev.keyCode === 229) {
  32577. return false;
  32578. }
  32579. else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {
  32580. return false;
  32581. }
  32582. else {
  32583. this.finalizeComposition(false);
  32584. }
  32585. }
  32586. if (ev.keyCode === 229) {
  32587. this.handleAnyTextareaChanges();
  32588. return false;
  32589. }
  32590. return true;
  32591. };
  32592. CompositionHelper.prototype.finalizeComposition = function (waitForPropogation) {
  32593. var _this = this;
  32594. this.compositionView.classList.remove('active');
  32595. this.isComposing = false;
  32596. this.clearTextareaPosition();
  32597. if (!waitForPropogation) {
  32598. this.isSendingComposition = false;
  32599. var input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);
  32600. this.terminal.handler(input);
  32601. }
  32602. else {
  32603. var currentCompositionPosition_1 = {
  32604. start: this.compositionPosition.start,
  32605. end: this.compositionPosition.end,
  32606. };
  32607. this.isSendingComposition = true;
  32608. setTimeout(function () {
  32609. if (_this.isSendingComposition) {
  32610. _this.isSendingComposition = false;
  32611. var input = void 0;
  32612. if (_this.isComposing) {
  32613. input = _this.textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);
  32614. }
  32615. else {
  32616. input = _this.textarea.value.substring(currentCompositionPosition_1.start);
  32617. }
  32618. _this.terminal.handler(input);
  32619. }
  32620. }, 0);
  32621. }
  32622. };
  32623. CompositionHelper.prototype.handleAnyTextareaChanges = function () {
  32624. var _this = this;
  32625. var oldValue = this.textarea.value;
  32626. setTimeout(function () {
  32627. if (!_this.isComposing) {
  32628. var newValue = _this.textarea.value;
  32629. var diff = newValue.replace(oldValue, '');
  32630. if (diff.length > 0) {
  32631. _this.terminal.handler(diff);
  32632. }
  32633. }
  32634. }, 0);
  32635. };
  32636. CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) {
  32637. var _this = this;
  32638. if (!this.isComposing) {
  32639. return;
  32640. }
  32641. if (this.terminal.buffer.isCursorInViewport) {
  32642. var cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);
  32643. var cursorTop = this.terminal.buffer.y * cellHeight;
  32644. var cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;
  32645. this.compositionView.style.left = cursorLeft + 'px';
  32646. this.compositionView.style.top = cursorTop + 'px';
  32647. this.compositionView.style.height = cellHeight + 'px';
  32648. this.compositionView.style.lineHeight = cellHeight + 'px';
  32649. var compositionViewBounds = this.compositionView.getBoundingClientRect();
  32650. this.textarea.style.left = cursorLeft + 'px';
  32651. this.textarea.style.top = cursorTop + 'px';
  32652. this.textarea.style.width = compositionViewBounds.width + 'px';
  32653. this.textarea.style.height = compositionViewBounds.height + 'px';
  32654. this.textarea.style.lineHeight = compositionViewBounds.height + 'px';
  32655. }
  32656. if (!dontRecurse) {
  32657. setTimeout(function () { return _this.updateCompositionElements(true); }, 0);
  32658. }
  32659. };
  32660. CompositionHelper.prototype.clearTextareaPosition = function () {
  32661. this.textarea.style.left = '';
  32662. this.textarea.style.top = '';
  32663. };
  32664. return CompositionHelper;
  32665. }());
  32666. exports.CompositionHelper = CompositionHelper;
  32667. },{}],6:[function(require,module,exports){
  32668. "use strict";
  32669. Object.defineProperty(exports, "__esModule", { value: true });
  32670. var C0;
  32671. (function (C0) {
  32672. C0.NUL = '\x00';
  32673. C0.SOH = '\x01';
  32674. C0.STX = '\x02';
  32675. C0.ETX = '\x03';
  32676. C0.EOT = '\x04';
  32677. C0.ENQ = '\x05';
  32678. C0.ACK = '\x06';
  32679. C0.BEL = '\x07';
  32680. C0.BS = '\x08';
  32681. C0.HT = '\x09';
  32682. C0.LF = '\x0a';
  32683. C0.VT = '\x0b';
  32684. C0.FF = '\x0c';
  32685. C0.CR = '\x0d';
  32686. C0.SO = '\x0e';
  32687. C0.SI = '\x0f';
  32688. C0.DLE = '\x10';
  32689. C0.DC1 = '\x11';
  32690. C0.DC2 = '\x12';
  32691. C0.DC3 = '\x13';
  32692. C0.DC4 = '\x14';
  32693. C0.NAK = '\x15';
  32694. C0.SYN = '\x16';
  32695. C0.ETB = '\x17';
  32696. C0.CAN = '\x18';
  32697. C0.EM = '\x19';
  32698. C0.SUB = '\x1a';
  32699. C0.ESC = '\x1b';
  32700. C0.FS = '\x1c';
  32701. C0.GS = '\x1d';
  32702. C0.RS = '\x1e';
  32703. C0.US = '\x1f';
  32704. C0.SP = '\x20';
  32705. C0.DEL = '\x7f';
  32706. })(C0 = exports.C0 || (exports.C0 = {}));
  32707. },{}],7:[function(require,module,exports){
  32708. "use strict";
  32709. Object.defineProperty(exports, "__esModule", { value: true });
  32710. var EventEmitter = (function () {
  32711. function EventEmitter() {
  32712. this._events = this._events || {};
  32713. }
  32714. EventEmitter.prototype.on = function (type, listener) {
  32715. this._events[type] = this._events[type] || [];
  32716. this._events[type].push(listener);
  32717. };
  32718. EventEmitter.prototype.off = function (type, listener) {
  32719. if (!this._events[type]) {
  32720. return;
  32721. }
  32722. var obj = this._events[type];
  32723. var i = obj.length;
  32724. while (i--) {
  32725. if (obj[i] === listener) {
  32726. obj.splice(i, 1);
  32727. return;
  32728. }
  32729. }
  32730. };
  32731. EventEmitter.prototype.removeAllListeners = function (type) {
  32732. if (this._events[type]) {
  32733. delete this._events[type];
  32734. }
  32735. };
  32736. EventEmitter.prototype.emit = function (type) {
  32737. var args = [];
  32738. for (var _i = 1; _i < arguments.length; _i++) {
  32739. args[_i - 1] = arguments[_i];
  32740. }
  32741. if (!this._events[type]) {
  32742. return;
  32743. }
  32744. var obj = this._events[type];
  32745. for (var i = 0; i < obj.length; i++) {
  32746. obj[i].apply(this, args);
  32747. }
  32748. };
  32749. EventEmitter.prototype.listeners = function (type) {
  32750. return this._events[type] || [];
  32751. };
  32752. EventEmitter.prototype.destroy = function () {
  32753. this._events = {};
  32754. };
  32755. return EventEmitter;
  32756. }());
  32757. exports.EventEmitter = EventEmitter;
  32758. },{}],8:[function(require,module,exports){
  32759. "use strict";
  32760. Object.defineProperty(exports, "__esModule", { value: true });
  32761. var EscapeSequences_1 = require("./EscapeSequences");
  32762. var Charsets_1 = require("./Charsets");
  32763. var Buffer_1 = require("./Buffer");
  32764. var Types_1 = require("./renderer/Types");
  32765. var CharWidth_1 = require("./CharWidth");
  32766. var InputHandler = (function () {
  32767. function InputHandler(_terminal) {
  32768. this._terminal = _terminal;
  32769. }
  32770. InputHandler.prototype.addChar = function (char, code) {
  32771. if (char >= ' ') {
  32772. var chWidth = CharWidth_1.wcwidth(code);
  32773. if (this._terminal.charset && this._terminal.charset[char]) {
  32774. char = this._terminal.charset[char];
  32775. }
  32776. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  32777. if (!chWidth && this._terminal.buffer.x) {
  32778. if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1]) {
  32779. if (!this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_WIDTH_INDEX]) {
  32780. if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2]) {
  32781. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;
  32782. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][3] = char.charCodeAt(0);
  32783. }
  32784. }
  32785. else {
  32786. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;
  32787. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][3] = char.charCodeAt(0);
  32788. }
  32789. this._terminal.updateRange(this._terminal.buffer.y);
  32790. }
  32791. return;
  32792. }
  32793. if (this._terminal.buffer.x + chWidth - 1 >= this._terminal.cols) {
  32794. if (this._terminal.wraparoundMode) {
  32795. this._terminal.buffer.x = 0;
  32796. this._terminal.buffer.y++;
  32797. if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {
  32798. this._terminal.buffer.y--;
  32799. this._terminal.scroll(true);
  32800. }
  32801. else {
  32802. this._terminal.buffer.lines.get(this._terminal.buffer.y).isWrapped = true;
  32803. }
  32804. }
  32805. else {
  32806. if (chWidth === 2) {
  32807. return;
  32808. }
  32809. }
  32810. }
  32811. row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  32812. if (this._terminal.insertMode) {
  32813. for (var moves = 0; moves < chWidth; ++moves) {
  32814. var removed = this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).pop();
  32815. if (removed[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0
  32816. && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2]
  32817. && this._terminal.buffer.lines.get(row)[this._terminal.cols - 2][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
  32818. this._terminal.buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)];
  32819. }
  32820. this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]);
  32821. }
  32822. }
  32823. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, char, chWidth, char.charCodeAt(0)];
  32824. this._terminal.buffer.x++;
  32825. this._terminal.updateRange(this._terminal.buffer.y);
  32826. if (chWidth === 2) {
  32827. this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, '', 0, undefined];
  32828. this._terminal.buffer.x++;
  32829. }
  32830. }
  32831. };
  32832. InputHandler.prototype.bell = function () {
  32833. this._terminal.bell();
  32834. };
  32835. InputHandler.prototype.lineFeed = function () {
  32836. if (this._terminal.convertEol) {
  32837. this._terminal.buffer.x = 0;
  32838. }
  32839. this._terminal.buffer.y++;
  32840. if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {
  32841. this._terminal.buffer.y--;
  32842. this._terminal.scroll();
  32843. }
  32844. if (this._terminal.buffer.x >= this._terminal.cols) {
  32845. this._terminal.buffer.x--;
  32846. }
  32847. this._terminal.emit('linefeed');
  32848. };
  32849. InputHandler.prototype.carriageReturn = function () {
  32850. this._terminal.buffer.x = 0;
  32851. };
  32852. InputHandler.prototype.backspace = function () {
  32853. if (this._terminal.buffer.x > 0) {
  32854. this._terminal.buffer.x--;
  32855. }
  32856. };
  32857. InputHandler.prototype.tab = function () {
  32858. this._terminal.buffer.x = this._terminal.buffer.nextStop();
  32859. };
  32860. InputHandler.prototype.shiftOut = function () {
  32861. this._terminal.setgLevel(1);
  32862. };
  32863. InputHandler.prototype.shiftIn = function () {
  32864. this._terminal.setgLevel(0);
  32865. };
  32866. InputHandler.prototype.insertChars = function (params) {
  32867. var param = params[0];
  32868. if (param < 1)
  32869. param = 1;
  32870. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  32871. var j = this._terminal.buffer.x;
  32872. var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
  32873. while (param-- && j < this._terminal.cols) {
  32874. this._terminal.buffer.lines.get(row).splice(j++, 0, ch);
  32875. this._terminal.buffer.lines.get(row).pop();
  32876. }
  32877. };
  32878. InputHandler.prototype.cursorUp = function (params) {
  32879. var param = params[0];
  32880. if (param < 1) {
  32881. param = 1;
  32882. }
  32883. this._terminal.buffer.y -= param;
  32884. if (this._terminal.buffer.y < 0) {
  32885. this._terminal.buffer.y = 0;
  32886. }
  32887. };
  32888. InputHandler.prototype.cursorDown = function (params) {
  32889. var param = params[0];
  32890. if (param < 1) {
  32891. param = 1;
  32892. }
  32893. this._terminal.buffer.y += param;
  32894. if (this._terminal.buffer.y >= this._terminal.rows) {
  32895. this._terminal.buffer.y = this._terminal.rows - 1;
  32896. }
  32897. if (this._terminal.buffer.x >= this._terminal.cols) {
  32898. this._terminal.buffer.x--;
  32899. }
  32900. };
  32901. InputHandler.prototype.cursorForward = function (params) {
  32902. var param = params[0];
  32903. if (param < 1) {
  32904. param = 1;
  32905. }
  32906. this._terminal.buffer.x += param;
  32907. if (this._terminal.buffer.x >= this._terminal.cols) {
  32908. this._terminal.buffer.x = this._terminal.cols - 1;
  32909. }
  32910. };
  32911. InputHandler.prototype.cursorBackward = function (params) {
  32912. var param = params[0];
  32913. if (param < 1) {
  32914. param = 1;
  32915. }
  32916. if (this._terminal.buffer.x >= this._terminal.cols) {
  32917. this._terminal.buffer.x--;
  32918. }
  32919. this._terminal.buffer.x -= param;
  32920. if (this._terminal.buffer.x < 0) {
  32921. this._terminal.buffer.x = 0;
  32922. }
  32923. };
  32924. InputHandler.prototype.cursorNextLine = function (params) {
  32925. var param = params[0];
  32926. if (param < 1) {
  32927. param = 1;
  32928. }
  32929. this._terminal.buffer.y += param;
  32930. if (this._terminal.buffer.y >= this._terminal.rows) {
  32931. this._terminal.buffer.y = this._terminal.rows - 1;
  32932. }
  32933. this._terminal.buffer.x = 0;
  32934. };
  32935. InputHandler.prototype.cursorPrecedingLine = function (params) {
  32936. var param = params[0];
  32937. if (param < 1) {
  32938. param = 1;
  32939. }
  32940. this._terminal.buffer.y -= param;
  32941. if (this._terminal.buffer.y < 0) {
  32942. this._terminal.buffer.y = 0;
  32943. }
  32944. this._terminal.buffer.x = 0;
  32945. };
  32946. InputHandler.prototype.cursorCharAbsolute = function (params) {
  32947. var param = params[0];
  32948. if (param < 1) {
  32949. param = 1;
  32950. }
  32951. this._terminal.buffer.x = param - 1;
  32952. };
  32953. InputHandler.prototype.cursorPosition = function (params) {
  32954. var col;
  32955. var row = params[0] - 1;
  32956. if (params.length >= 2) {
  32957. col = params[1] - 1;
  32958. }
  32959. else {
  32960. col = 0;
  32961. }
  32962. if (row < 0) {
  32963. row = 0;
  32964. }
  32965. else if (row >= this._terminal.rows) {
  32966. row = this._terminal.rows - 1;
  32967. }
  32968. if (col < 0) {
  32969. col = 0;
  32970. }
  32971. else if (col >= this._terminal.cols) {
  32972. col = this._terminal.cols - 1;
  32973. }
  32974. this._terminal.buffer.x = col;
  32975. this._terminal.buffer.y = row;
  32976. };
  32977. InputHandler.prototype.cursorForwardTab = function (params) {
  32978. var param = params[0] || 1;
  32979. while (param--) {
  32980. this._terminal.buffer.x = this._terminal.buffer.nextStop();
  32981. }
  32982. };
  32983. InputHandler.prototype.eraseInDisplay = function (params) {
  32984. var j;
  32985. switch (params[0]) {
  32986. case 0:
  32987. this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);
  32988. j = this._terminal.buffer.y + 1;
  32989. for (; j < this._terminal.rows; j++) {
  32990. this._terminal.eraseLine(j);
  32991. }
  32992. break;
  32993. case 1:
  32994. this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);
  32995. j = this._terminal.buffer.y;
  32996. while (j--) {
  32997. this._terminal.eraseLine(j);
  32998. }
  32999. break;
  33000. case 2:
  33001. j = this._terminal.rows;
  33002. while (j--)
  33003. this._terminal.eraseLine(j);
  33004. break;
  33005. case 3:
  33006. var scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;
  33007. if (scrollBackSize > 0) {
  33008. this._terminal.buffer.lines.trimStart(scrollBackSize);
  33009. this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0);
  33010. this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0);
  33011. this._terminal.emit('scroll', 0);
  33012. }
  33013. break;
  33014. }
  33015. };
  33016. InputHandler.prototype.eraseInLine = function (params) {
  33017. switch (params[0]) {
  33018. case 0:
  33019. this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);
  33020. break;
  33021. case 1:
  33022. this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);
  33023. break;
  33024. case 2:
  33025. this._terminal.eraseLine(this._terminal.buffer.y);
  33026. break;
  33027. }
  33028. };
  33029. InputHandler.prototype.insertLines = function (params) {
  33030. var param = params[0];
  33031. if (param < 1) {
  33032. param = 1;
  33033. }
  33034. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  33035. var scrollBottomRowsOffset = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;
  33036. var scrollBottomAbsolute = this._terminal.rows - 1 + this._terminal.buffer.ybase - scrollBottomRowsOffset + 1;
  33037. while (param--) {
  33038. this._terminal.buffer.lines.splice(scrollBottomAbsolute - 1, 1);
  33039. this._terminal.buffer.lines.splice(row, 0, this._terminal.blankLine(true));
  33040. }
  33041. this._terminal.updateRange(this._terminal.buffer.y);
  33042. this._terminal.updateRange(this._terminal.buffer.scrollBottom);
  33043. };
  33044. InputHandler.prototype.deleteLines = function (params) {
  33045. var param = params[0];
  33046. if (param < 1) {
  33047. param = 1;
  33048. }
  33049. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  33050. var j;
  33051. j = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;
  33052. j = this._terminal.rows - 1 + this._terminal.buffer.ybase - j;
  33053. while (param--) {
  33054. this._terminal.buffer.lines.splice(row, 1);
  33055. this._terminal.buffer.lines.splice(j, 0, this._terminal.blankLine(true));
  33056. }
  33057. this._terminal.updateRange(this._terminal.buffer.y);
  33058. this._terminal.updateRange(this._terminal.buffer.scrollBottom);
  33059. };
  33060. InputHandler.prototype.deleteChars = function (params) {
  33061. var param = params[0];
  33062. if (param < 1) {
  33063. param = 1;
  33064. }
  33065. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  33066. var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
  33067. while (param--) {
  33068. this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 1);
  33069. this._terminal.buffer.lines.get(row).push(ch);
  33070. }
  33071. this._terminal.updateRange(this._terminal.buffer.y);
  33072. };
  33073. InputHandler.prototype.scrollUp = function (params) {
  33074. var param = params[0] || 1;
  33075. while (param--) {
  33076. this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 1);
  33077. this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 0, this._terminal.blankLine());
  33078. }
  33079. this._terminal.updateRange(this._terminal.buffer.scrollTop);
  33080. this._terminal.updateRange(this._terminal.buffer.scrollBottom);
  33081. };
  33082. InputHandler.prototype.scrollDown = function (params) {
  33083. var param = params[0] || 1;
  33084. while (param--) {
  33085. this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 1);
  33086. this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 0, this._terminal.blankLine());
  33087. }
  33088. this._terminal.updateRange(this._terminal.buffer.scrollTop);
  33089. this._terminal.updateRange(this._terminal.buffer.scrollBottom);
  33090. };
  33091. InputHandler.prototype.eraseChars = function (params) {
  33092. var param = params[0];
  33093. if (param < 1) {
  33094. param = 1;
  33095. }
  33096. var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
  33097. var j = this._terminal.buffer.x;
  33098. var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
  33099. while (param-- && j < this._terminal.cols) {
  33100. this._terminal.buffer.lines.get(row)[j++] = ch;
  33101. }
  33102. };
  33103. InputHandler.prototype.cursorBackwardTab = function (params) {
  33104. var param = params[0] || 1;
  33105. while (param--) {
  33106. this._terminal.buffer.x = this._terminal.buffer.prevStop();
  33107. }
  33108. };
  33109. InputHandler.prototype.charPosAbsolute = function (params) {
  33110. var param = params[0];
  33111. if (param < 1) {
  33112. param = 1;
  33113. }
  33114. this._terminal.buffer.x = param - 1;
  33115. if (this._terminal.buffer.x >= this._terminal.cols) {
  33116. this._terminal.buffer.x = this._terminal.cols - 1;
  33117. }
  33118. };
  33119. InputHandler.prototype.HPositionRelative = function (params) {
  33120. var param = params[0];
  33121. if (param < 1) {
  33122. param = 1;
  33123. }
  33124. this._terminal.buffer.x += param;
  33125. if (this._terminal.buffer.x >= this._terminal.cols) {
  33126. this._terminal.buffer.x = this._terminal.cols - 1;
  33127. }
  33128. };
  33129. InputHandler.prototype.repeatPrecedingCharacter = function (params) {
  33130. var param = params[0] || 1;
  33131. var line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + this._terminal.buffer.y);
  33132. var ch = line[this._terminal.buffer.x - 1] || [this._terminal.defAttr, ' ', 1, 32];
  33133. while (param--) {
  33134. line[this._terminal.buffer.x++] = ch;
  33135. }
  33136. };
  33137. InputHandler.prototype.sendDeviceAttributes = function (params) {
  33138. if (params[0] > 0) {
  33139. return;
  33140. }
  33141. if (!this._terminal.prefix) {
  33142. if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
  33143. this._terminal.send(EscapeSequences_1.C0.ESC + '[?1;2c');
  33144. }
  33145. else if (this._terminal.is('linux')) {
  33146. this._terminal.send(EscapeSequences_1.C0.ESC + '[?6c');
  33147. }
  33148. }
  33149. else if (this._terminal.prefix === '>') {
  33150. if (this._terminal.is('xterm')) {
  33151. this._terminal.send(EscapeSequences_1.C0.ESC + '[>0;276;0c');
  33152. }
  33153. else if (this._terminal.is('rxvt-unicode')) {
  33154. this._terminal.send(EscapeSequences_1.C0.ESC + '[>85;95;0c');
  33155. }
  33156. else if (this._terminal.is('linux')) {
  33157. this._terminal.send(params[0] + 'c');
  33158. }
  33159. else if (this._terminal.is('screen')) {
  33160. this._terminal.send(EscapeSequences_1.C0.ESC + '[>83;40003;0c');
  33161. }
  33162. }
  33163. };
  33164. InputHandler.prototype.linePosAbsolute = function (params) {
  33165. var param = params[0];
  33166. if (param < 1) {
  33167. param = 1;
  33168. }
  33169. this._terminal.buffer.y = param - 1;
  33170. if (this._terminal.buffer.y >= this._terminal.rows) {
  33171. this._terminal.buffer.y = this._terminal.rows - 1;
  33172. }
  33173. };
  33174. InputHandler.prototype.VPositionRelative = function (params) {
  33175. var param = params[0];
  33176. if (param < 1) {
  33177. param = 1;
  33178. }
  33179. this._terminal.buffer.y += param;
  33180. if (this._terminal.buffer.y >= this._terminal.rows) {
  33181. this._terminal.buffer.y = this._terminal.rows - 1;
  33182. }
  33183. if (this._terminal.buffer.x >= this._terminal.cols) {
  33184. this._terminal.buffer.x--;
  33185. }
  33186. };
  33187. InputHandler.prototype.HVPosition = function (params) {
  33188. if (params[0] < 1)
  33189. params[0] = 1;
  33190. if (params[1] < 1)
  33191. params[1] = 1;
  33192. this._terminal.buffer.y = params[0] - 1;
  33193. if (this._terminal.buffer.y >= this._terminal.rows) {
  33194. this._terminal.buffer.y = this._terminal.rows - 1;
  33195. }
  33196. this._terminal.buffer.x = params[1] - 1;
  33197. if (this._terminal.buffer.x >= this._terminal.cols) {
  33198. this._terminal.buffer.x = this._terminal.cols - 1;
  33199. }
  33200. };
  33201. InputHandler.prototype.tabClear = function (params) {
  33202. var param = params[0];
  33203. if (param <= 0) {
  33204. delete this._terminal.buffer.tabs[this._terminal.buffer.x];
  33205. }
  33206. else if (param === 3) {
  33207. this._terminal.buffer.tabs = {};
  33208. }
  33209. };
  33210. InputHandler.prototype.setMode = function (params) {
  33211. if (params.length > 1) {
  33212. for (var i = 0; i < params.length; i++) {
  33213. this.setMode([params[i]]);
  33214. }
  33215. return;
  33216. }
  33217. if (!this._terminal.prefix) {
  33218. switch (params[0]) {
  33219. case 4:
  33220. this._terminal.insertMode = true;
  33221. break;
  33222. case 20:
  33223. break;
  33224. }
  33225. }
  33226. else if (this._terminal.prefix === '?') {
  33227. switch (params[0]) {
  33228. case 1:
  33229. this._terminal.applicationCursor = true;
  33230. break;
  33231. case 2:
  33232. this._terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);
  33233. this._terminal.setgCharset(1, Charsets_1.DEFAULT_CHARSET);
  33234. this._terminal.setgCharset(2, Charsets_1.DEFAULT_CHARSET);
  33235. this._terminal.setgCharset(3, Charsets_1.DEFAULT_CHARSET);
  33236. break;
  33237. case 3:
  33238. this._terminal.savedCols = this._terminal.cols;
  33239. this._terminal.resize(132, this._terminal.rows);
  33240. break;
  33241. case 6:
  33242. this._terminal.originMode = true;
  33243. break;
  33244. case 7:
  33245. this._terminal.wraparoundMode = true;
  33246. break;
  33247. case 12:
  33248. break;
  33249. case 66:
  33250. this._terminal.log('Serial port requested application keypad.');
  33251. this._terminal.applicationKeypad = true;
  33252. this._terminal.viewport.syncScrollArea();
  33253. break;
  33254. case 9:
  33255. case 1000:
  33256. case 1002:
  33257. case 1003:
  33258. this._terminal.x10Mouse = params[0] === 9;
  33259. this._terminal.vt200Mouse = params[0] === 1000;
  33260. this._terminal.normalMouse = params[0] > 1000;
  33261. this._terminal.mouseEvents = true;
  33262. this._terminal.element.classList.add('enable-mouse-events');
  33263. this._terminal.selectionManager.disable();
  33264. this._terminal.log('Binding to mouse events.');
  33265. break;
  33266. case 1004:
  33267. this._terminal.sendFocus = true;
  33268. break;
  33269. case 1005:
  33270. this._terminal.utfMouse = true;
  33271. break;
  33272. case 1006:
  33273. this._terminal.sgrMouse = true;
  33274. break;
  33275. case 1015:
  33276. this._terminal.urxvtMouse = true;
  33277. break;
  33278. case 25:
  33279. this._terminal.cursorHidden = false;
  33280. break;
  33281. case 1049:
  33282. case 47:
  33283. case 1047:
  33284. this._terminal.buffers.activateAltBuffer();
  33285. this._terminal.viewport.syncScrollArea();
  33286. this._terminal.showCursor();
  33287. break;
  33288. case 2004:
  33289. this._terminal.bracketedPasteMode = true;
  33290. break;
  33291. }
  33292. }
  33293. };
  33294. InputHandler.prototype.resetMode = function (params) {
  33295. if (params.length > 1) {
  33296. for (var i = 0; i < params.length; i++) {
  33297. this.resetMode([params[i]]);
  33298. }
  33299. return;
  33300. }
  33301. if (!this._terminal.prefix) {
  33302. switch (params[0]) {
  33303. case 4:
  33304. this._terminal.insertMode = false;
  33305. break;
  33306. case 20:
  33307. break;
  33308. }
  33309. }
  33310. else if (this._terminal.prefix === '?') {
  33311. switch (params[0]) {
  33312. case 1:
  33313. this._terminal.applicationCursor = false;
  33314. break;
  33315. case 3:
  33316. if (this._terminal.cols === 132 && this._terminal.savedCols) {
  33317. this._terminal.resize(this._terminal.savedCols, this._terminal.rows);
  33318. }
  33319. delete this._terminal.savedCols;
  33320. break;
  33321. case 6:
  33322. this._terminal.originMode = false;
  33323. break;
  33324. case 7:
  33325. this._terminal.wraparoundMode = false;
  33326. break;
  33327. case 12:
  33328. break;
  33329. case 66:
  33330. this._terminal.log('Switching back to normal keypad.');
  33331. this._terminal.applicationKeypad = false;
  33332. this._terminal.viewport.syncScrollArea();
  33333. break;
  33334. case 9:
  33335. case 1000:
  33336. case 1002:
  33337. case 1003:
  33338. this._terminal.x10Mouse = false;
  33339. this._terminal.vt200Mouse = false;
  33340. this._terminal.normalMouse = false;
  33341. this._terminal.mouseEvents = false;
  33342. this._terminal.element.classList.remove('enable-mouse-events');
  33343. this._terminal.selectionManager.enable();
  33344. break;
  33345. case 1004:
  33346. this._terminal.sendFocus = false;
  33347. break;
  33348. case 1005:
  33349. this._terminal.utfMouse = false;
  33350. break;
  33351. case 1006:
  33352. this._terminal.sgrMouse = false;
  33353. break;
  33354. case 1015:
  33355. this._terminal.urxvtMouse = false;
  33356. break;
  33357. case 25:
  33358. this._terminal.cursorHidden = true;
  33359. break;
  33360. case 1049:
  33361. case 47:
  33362. case 1047:
  33363. this._terminal.buffers.activateNormalBuffer();
  33364. this._terminal.refresh(0, this._terminal.rows - 1);
  33365. this._terminal.viewport.syncScrollArea();
  33366. this._terminal.showCursor();
  33367. break;
  33368. case 2004:
  33369. this._terminal.bracketedPasteMode = false;
  33370. break;
  33371. }
  33372. }
  33373. };
  33374. InputHandler.prototype.charAttributes = function (params) {
  33375. if (params.length === 1 && params[0] === 0) {
  33376. this._terminal.curAttr = this._terminal.defAttr;
  33377. return;
  33378. }
  33379. var l = params.length;
  33380. var flags = this._terminal.curAttr >> 18;
  33381. var fg = (this._terminal.curAttr >> 9) & 0x1ff;
  33382. var bg = this._terminal.curAttr & 0x1ff;
  33383. var p;
  33384. for (var i = 0; i < l; i++) {
  33385. p = params[i];
  33386. if (p >= 30 && p <= 37) {
  33387. fg = p - 30;
  33388. }
  33389. else if (p >= 40 && p <= 47) {
  33390. bg = p - 40;
  33391. }
  33392. else if (p >= 90 && p <= 97) {
  33393. p += 8;
  33394. fg = p - 90;
  33395. }
  33396. else if (p >= 100 && p <= 107) {
  33397. p += 8;
  33398. bg = p - 100;
  33399. }
  33400. else if (p === 0) {
  33401. flags = this._terminal.defAttr >> 18;
  33402. fg = (this._terminal.defAttr >> 9) & 0x1ff;
  33403. bg = this._terminal.defAttr & 0x1ff;
  33404. }
  33405. else if (p === 1) {
  33406. flags |= Types_1.FLAGS.BOLD;
  33407. }
  33408. else if (p === 4) {
  33409. flags |= Types_1.FLAGS.UNDERLINE;
  33410. }
  33411. else if (p === 5) {
  33412. flags |= Types_1.FLAGS.BLINK;
  33413. }
  33414. else if (p === 7) {
  33415. flags |= Types_1.FLAGS.INVERSE;
  33416. }
  33417. else if (p === 8) {
  33418. flags |= Types_1.FLAGS.INVISIBLE;
  33419. }
  33420. else if (p === 2) {
  33421. flags |= Types_1.FLAGS.DIM;
  33422. }
  33423. else if (p === 22) {
  33424. flags &= ~Types_1.FLAGS.BOLD;
  33425. flags &= ~Types_1.FLAGS.DIM;
  33426. }
  33427. else if (p === 24) {
  33428. flags &= ~Types_1.FLAGS.UNDERLINE;
  33429. }
  33430. else if (p === 25) {
  33431. flags &= ~Types_1.FLAGS.BLINK;
  33432. }
  33433. else if (p === 27) {
  33434. flags &= ~Types_1.FLAGS.INVERSE;
  33435. }
  33436. else if (p === 28) {
  33437. flags &= ~Types_1.FLAGS.INVISIBLE;
  33438. }
  33439. else if (p === 39) {
  33440. fg = (this._terminal.defAttr >> 9) & 0x1ff;
  33441. }
  33442. else if (p === 49) {
  33443. bg = this._terminal.defAttr & 0x1ff;
  33444. }
  33445. else if (p === 38) {
  33446. if (params[i + 1] === 2) {
  33447. i += 2;
  33448. fg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);
  33449. if (fg === -1)
  33450. fg = 0x1ff;
  33451. i += 2;
  33452. }
  33453. else if (params[i + 1] === 5) {
  33454. i += 2;
  33455. p = params[i] & 0xff;
  33456. fg = p;
  33457. }
  33458. }
  33459. else if (p === 48) {
  33460. if (params[i + 1] === 2) {
  33461. i += 2;
  33462. bg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);
  33463. if (bg === -1)
  33464. bg = 0x1ff;
  33465. i += 2;
  33466. }
  33467. else if (params[i + 1] === 5) {
  33468. i += 2;
  33469. p = params[i] & 0xff;
  33470. bg = p;
  33471. }
  33472. }
  33473. else if (p === 100) {
  33474. fg = (this._terminal.defAttr >> 9) & 0x1ff;
  33475. bg = this._terminal.defAttr & 0x1ff;
  33476. }
  33477. else {
  33478. this._terminal.error('Unknown SGR attribute: %d.', p);
  33479. }
  33480. }
  33481. this._terminal.curAttr = (flags << 18) | (fg << 9) | bg;
  33482. };
  33483. InputHandler.prototype.deviceStatus = function (params) {
  33484. if (!this._terminal.prefix) {
  33485. switch (params[0]) {
  33486. case 5:
  33487. this._terminal.send(EscapeSequences_1.C0.ESC + '[0n');
  33488. break;
  33489. case 6:
  33490. this._terminal.send(EscapeSequences_1.C0.ESC + '['
  33491. + (this._terminal.buffer.y + 1)
  33492. + ';'
  33493. + (this._terminal.buffer.x + 1)
  33494. + 'R');
  33495. break;
  33496. }
  33497. }
  33498. else if (this._terminal.prefix === '?') {
  33499. switch (params[0]) {
  33500. case 6:
  33501. this._terminal.send(EscapeSequences_1.C0.ESC + '[?'
  33502. + (this._terminal.buffer.y + 1)
  33503. + ';'
  33504. + (this._terminal.buffer.x + 1)
  33505. + 'R');
  33506. break;
  33507. case 15:
  33508. break;
  33509. case 25:
  33510. break;
  33511. case 26:
  33512. break;
  33513. case 53:
  33514. break;
  33515. }
  33516. }
  33517. };
  33518. InputHandler.prototype.softReset = function (params) {
  33519. this._terminal.cursorHidden = false;
  33520. this._terminal.insertMode = false;
  33521. this._terminal.originMode = false;
  33522. this._terminal.wraparoundMode = true;
  33523. this._terminal.applicationKeypad = false;
  33524. this._terminal.viewport.syncScrollArea();
  33525. this._terminal.applicationCursor = false;
  33526. this._terminal.buffer.scrollTop = 0;
  33527. this._terminal.buffer.scrollBottom = this._terminal.rows - 1;
  33528. this._terminal.curAttr = this._terminal.defAttr;
  33529. this._terminal.buffer.x = this._terminal.buffer.y = 0;
  33530. this._terminal.charset = null;
  33531. this._terminal.glevel = 0;
  33532. this._terminal.charsets = [null];
  33533. };
  33534. InputHandler.prototype.setCursorStyle = function (params) {
  33535. var param = params[0] < 1 ? 1 : params[0];
  33536. switch (param) {
  33537. case 1:
  33538. case 2:
  33539. this._terminal.setOption('cursorStyle', 'block');
  33540. break;
  33541. case 3:
  33542. case 4:
  33543. this._terminal.setOption('cursorStyle', 'underline');
  33544. break;
  33545. case 5:
  33546. case 6:
  33547. this._terminal.setOption('cursorStyle', 'bar');
  33548. break;
  33549. }
  33550. var isBlinking = param % 2 === 1;
  33551. this._terminal.setOption('cursorBlink', isBlinking);
  33552. };
  33553. InputHandler.prototype.setScrollRegion = function (params) {
  33554. if (this._terminal.prefix)
  33555. return;
  33556. this._terminal.buffer.scrollTop = (params[0] || 1) - 1;
  33557. this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;
  33558. this._terminal.buffer.x = 0;
  33559. this._terminal.buffer.y = 0;
  33560. };
  33561. InputHandler.prototype.saveCursor = function (params) {
  33562. this._terminal.buffer.savedX = this._terminal.buffer.x;
  33563. this._terminal.buffer.savedY = this._terminal.buffer.y;
  33564. };
  33565. InputHandler.prototype.restoreCursor = function (params) {
  33566. this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
  33567. this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
  33568. };
  33569. return InputHandler;
  33570. }());
  33571. exports.InputHandler = InputHandler;
  33572. },{"./Buffer":1,"./CharWidth":3,"./Charsets":4,"./EscapeSequences":6,"./renderer/Types":28}],9:[function(require,module,exports){
  33573. "use strict";
  33574. var __extends = (this && this.__extends) || (function () {
  33575. var extendStatics = Object.setPrototypeOf ||
  33576. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33577. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33578. return function (d, b) {
  33579. extendStatics(d, b);
  33580. function __() { this.constructor = d; }
  33581. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33582. };
  33583. })();
  33584. Object.defineProperty(exports, "__esModule", { value: true });
  33585. var Types_1 = require("./Types");
  33586. var MouseZoneManager_1 = require("./input/MouseZoneManager");
  33587. var EventEmitter_1 = require("./EventEmitter");
  33588. var protocolClause = '(https?:\\/\\/)';
  33589. var domainCharacterSet = '[\\da-z\\.-]+';
  33590. var negatedDomainCharacterSet = '[^\\da-z\\.-]+';
  33591. var domainBodyClause = '(' + domainCharacterSet + ')';
  33592. var tldClause = '([a-z\\.]{2,6})';
  33593. var ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
  33594. var localHostClause = '(localhost)';
  33595. var portClause = '(:\\d{1,5})';
  33596. var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
  33597. var pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
  33598. var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
  33599. var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
  33600. var hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
  33601. var negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
  33602. var bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
  33603. var start = '(?:^|' + negatedDomainCharacterSet + ')(';
  33604. var end = ')($|' + negatedPathCharacterSet + ')';
  33605. var strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
  33606. var HYPERTEXT_LINK_MATCHER_ID = 0;
  33607. var Linkifier = (function (_super) {
  33608. __extends(Linkifier, _super);
  33609. function Linkifier(_terminal) {
  33610. var _this = _super.call(this) || this;
  33611. _this._terminal = _terminal;
  33612. _this._linkMatchers = [];
  33613. _this._nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;
  33614. _this._rowsToLinkify = {
  33615. start: null,
  33616. end: null
  33617. };
  33618. _this.registerLinkMatcher(strictUrlRegex, null, { matchIndex: 1 });
  33619. return _this;
  33620. }
  33621. Linkifier.prototype.attachToDom = function (mouseZoneManager) {
  33622. this._mouseZoneManager = mouseZoneManager;
  33623. };
  33624. Linkifier.prototype.linkifyRows = function (start, end) {
  33625. var _this = this;
  33626. if (!this._mouseZoneManager) {
  33627. return;
  33628. }
  33629. if (this._rowsToLinkify.start === null) {
  33630. this._rowsToLinkify.start = start;
  33631. this._rowsToLinkify.end = end;
  33632. }
  33633. else {
  33634. this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);
  33635. this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);
  33636. }
  33637. this._mouseZoneManager.clearAll(start, end);
  33638. if (this._rowsTimeoutId) {
  33639. clearTimeout(this._rowsTimeoutId);
  33640. }
  33641. this._rowsTimeoutId = setTimeout(function () { return _this._linkifyRows(); }, Linkifier.TIME_BEFORE_LINKIFY);
  33642. };
  33643. Linkifier.prototype._linkifyRows = function () {
  33644. this._rowsTimeoutId = null;
  33645. for (var i = this._rowsToLinkify.start; i <= this._rowsToLinkify.end; i++) {
  33646. this._linkifyRow(i);
  33647. }
  33648. this._rowsToLinkify.start = null;
  33649. this._rowsToLinkify.end = null;
  33650. };
  33651. Linkifier.prototype.setHypertextLinkHandler = function (handler) {
  33652. this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;
  33653. };
  33654. Linkifier.prototype.setHypertextValidationCallback = function (callback) {
  33655. this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;
  33656. };
  33657. Linkifier.prototype.registerLinkMatcher = function (regex, handler, options) {
  33658. if (options === void 0) { options = {}; }
  33659. if (this._nextLinkMatcherId !== HYPERTEXT_LINK_MATCHER_ID && !handler) {
  33660. throw new Error('handler must be defined');
  33661. }
  33662. var matcher = {
  33663. id: this._nextLinkMatcherId++,
  33664. regex: regex,
  33665. handler: handler,
  33666. matchIndex: options.matchIndex,
  33667. validationCallback: options.validationCallback,
  33668. hoverTooltipCallback: options.tooltipCallback,
  33669. hoverLeaveCallback: options.leaveCallback,
  33670. willLinkActivate: options.willLinkActivate,
  33671. priority: options.priority || 0
  33672. };
  33673. this._addLinkMatcherToList(matcher);
  33674. return matcher.id;
  33675. };
  33676. Linkifier.prototype._addLinkMatcherToList = function (matcher) {
  33677. if (this._linkMatchers.length === 0) {
  33678. this._linkMatchers.push(matcher);
  33679. return;
  33680. }
  33681. for (var i = this._linkMatchers.length - 1; i >= 0; i--) {
  33682. if (matcher.priority <= this._linkMatchers[i].priority) {
  33683. this._linkMatchers.splice(i + 1, 0, matcher);
  33684. return;
  33685. }
  33686. }
  33687. this._linkMatchers.splice(0, 0, matcher);
  33688. };
  33689. Linkifier.prototype.deregisterLinkMatcher = function (matcherId) {
  33690. for (var i = 1; i < this._linkMatchers.length; i++) {
  33691. if (this._linkMatchers[i].id === matcherId) {
  33692. this._linkMatchers.splice(i, 1);
  33693. return true;
  33694. }
  33695. }
  33696. return false;
  33697. };
  33698. Linkifier.prototype._linkifyRow = function (rowIndex) {
  33699. var absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;
  33700. if (absoluteRowIndex >= this._terminal.buffer.lines.length) {
  33701. return;
  33702. }
  33703. var text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
  33704. for (var i = 0; i < this._linkMatchers.length; i++) {
  33705. this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);
  33706. }
  33707. };
  33708. Linkifier.prototype._doLinkifyRow = function (rowIndex, text, matcher, offset) {
  33709. var _this = this;
  33710. if (offset === void 0) { offset = 0; }
  33711. var result = [];
  33712. var isHttpLinkMatcher = matcher.id === HYPERTEXT_LINK_MATCHER_ID;
  33713. var match = text.match(matcher.regex);
  33714. if (!match || match.length === 0) {
  33715. return;
  33716. }
  33717. var uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
  33718. var index = text.indexOf(uri);
  33719. if (matcher.validationCallback) {
  33720. matcher.validationCallback(uri, function (isValid) {
  33721. if (_this._rowsTimeoutId) {
  33722. return;
  33723. }
  33724. if (isValid) {
  33725. _this._addLink(offset + index, rowIndex, uri, matcher);
  33726. }
  33727. });
  33728. }
  33729. else {
  33730. this._addLink(offset + index, rowIndex, uri, matcher);
  33731. }
  33732. var remainingStartIndex = index + uri.length;
  33733. var remainingText = text.substr(remainingStartIndex);
  33734. if (remainingText.length > 0) {
  33735. this._doLinkifyRow(rowIndex, remainingText, matcher, offset + remainingStartIndex);
  33736. }
  33737. };
  33738. Linkifier.prototype._addLink = function (x, y, uri, matcher) {
  33739. var _this = this;
  33740. this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x + 1, x + 1 + uri.length, y + 1, function (e) {
  33741. if (matcher.handler) {
  33742. return matcher.handler(e, uri);
  33743. }
  33744. window.open(uri, '_blank');
  33745. }, function (e) {
  33746. _this.emit(Types_1.LinkHoverEventTypes.HOVER, { x: x, y: y, length: uri.length });
  33747. _this._terminal.element.style.cursor = 'pointer';
  33748. }, function (e) {
  33749. _this.emit(Types_1.LinkHoverEventTypes.TOOLTIP, { x: x, y: y, length: uri.length });
  33750. if (matcher.hoverTooltipCallback) {
  33751. matcher.hoverTooltipCallback(e, uri);
  33752. }
  33753. }, function () {
  33754. _this.emit(Types_1.LinkHoverEventTypes.LEAVE, { x: x, y: y, length: uri.length });
  33755. _this._terminal.element.style.cursor = '';
  33756. if (matcher.hoverLeaveCallback) {
  33757. matcher.hoverLeaveCallback();
  33758. }
  33759. }, function (e) {
  33760. if (matcher.willLinkActivate) {
  33761. return matcher.willLinkActivate(e, uri);
  33762. }
  33763. return true;
  33764. }));
  33765. };
  33766. Linkifier.TIME_BEFORE_LINKIFY = 200;
  33767. return Linkifier;
  33768. }(EventEmitter_1.EventEmitter));
  33769. exports.Linkifier = Linkifier;
  33770. },{"./EventEmitter":7,"./Types":14,"./input/MouseZoneManager":18}],10:[function(require,module,exports){
  33771. "use strict";
  33772. Object.defineProperty(exports, "__esModule", { value: true });
  33773. var EscapeSequences_1 = require("./EscapeSequences");
  33774. var Charsets_1 = require("./Charsets");
  33775. var normalStateHandler = {};
  33776. normalStateHandler[EscapeSequences_1.C0.BEL] = function (parser, handler) { return handler.bell(); };
  33777. normalStateHandler[EscapeSequences_1.C0.LF] = function (parser, handler) { return handler.lineFeed(); };
  33778. normalStateHandler[EscapeSequences_1.C0.VT] = normalStateHandler[EscapeSequences_1.C0.LF];
  33779. normalStateHandler[EscapeSequences_1.C0.FF] = normalStateHandler[EscapeSequences_1.C0.LF];
  33780. normalStateHandler[EscapeSequences_1.C0.CR] = function (parser, handler) { return handler.carriageReturn(); };
  33781. normalStateHandler[EscapeSequences_1.C0.BS] = function (parser, handler) { return handler.backspace(); };
  33782. normalStateHandler[EscapeSequences_1.C0.HT] = function (parser, handler) { return handler.tab(); };
  33783. normalStateHandler[EscapeSequences_1.C0.SO] = function (parser, handler) { return handler.shiftOut(); };
  33784. normalStateHandler[EscapeSequences_1.C0.SI] = function (parser, handler) { return handler.shiftIn(); };
  33785. normalStateHandler[EscapeSequences_1.C0.ESC] = function (parser, handler) { return parser.setState(ParserState.ESCAPED); };
  33786. var escapedStateHandler = {};
  33787. escapedStateHandler['['] = function (parser, terminal) {
  33788. terminal.params = [];
  33789. terminal.currentParam = 0;
  33790. parser.setState(ParserState.CSI_PARAM);
  33791. };
  33792. escapedStateHandler[']'] = function (parser, terminal) {
  33793. terminal.params = [];
  33794. terminal.currentParam = 0;
  33795. parser.setState(ParserState.OSC);
  33796. };
  33797. escapedStateHandler['P'] = function (parser, terminal) {
  33798. terminal.params = [];
  33799. terminal.currentParam = 0;
  33800. parser.setState(ParserState.DCS);
  33801. };
  33802. escapedStateHandler['_'] = function (parser, terminal) {
  33803. parser.setState(ParserState.IGNORE);
  33804. };
  33805. escapedStateHandler['^'] = function (parser, terminal) {
  33806. parser.setState(ParserState.IGNORE);
  33807. };
  33808. escapedStateHandler['c'] = function (parser, terminal) {
  33809. terminal.reset();
  33810. };
  33811. escapedStateHandler['E'] = function (parser, terminal) {
  33812. terminal.buffer.x = 0;
  33813. terminal.index();
  33814. parser.setState(ParserState.NORMAL);
  33815. };
  33816. escapedStateHandler['D'] = function (parser, terminal) {
  33817. terminal.index();
  33818. parser.setState(ParserState.NORMAL);
  33819. };
  33820. escapedStateHandler['M'] = function (parser, terminal) {
  33821. terminal.reverseIndex();
  33822. parser.setState(ParserState.NORMAL);
  33823. };
  33824. escapedStateHandler['%'] = function (parser, terminal) {
  33825. terminal.setgLevel(0);
  33826. terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);
  33827. parser.setState(ParserState.NORMAL);
  33828. parser.skipNextChar();
  33829. };
  33830. escapedStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };
  33831. var csiParamStateHandler = {};
  33832. csiParamStateHandler['?'] = function (parser) { return parser.setPrefix('?'); };
  33833. csiParamStateHandler['>'] = function (parser) { return parser.setPrefix('>'); };
  33834. csiParamStateHandler['!'] = function (parser) { return parser.setPrefix('!'); };
  33835. csiParamStateHandler['0'] = function (parser) { return parser.setParam(parser.getParam() * 10); };
  33836. csiParamStateHandler['1'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 1); };
  33837. csiParamStateHandler['2'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 2); };
  33838. csiParamStateHandler['3'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 3); };
  33839. csiParamStateHandler['4'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 4); };
  33840. csiParamStateHandler['5'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 5); };
  33841. csiParamStateHandler['6'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 6); };
  33842. csiParamStateHandler['7'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 7); };
  33843. csiParamStateHandler['8'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 8); };
  33844. csiParamStateHandler['9'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 9); };
  33845. csiParamStateHandler['$'] = function (parser) { return parser.setPostfix('$'); };
  33846. csiParamStateHandler['"'] = function (parser) { return parser.setPostfix('"'); };
  33847. csiParamStateHandler[' '] = function (parser) { return parser.setPostfix(' '); };
  33848. csiParamStateHandler['\''] = function (parser) { return parser.setPostfix('\''); };
  33849. csiParamStateHandler[';'] = function (parser) { return parser.finalizeParam(); };
  33850. csiParamStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };
  33851. var csiStateHandler = {};
  33852. csiStateHandler['@'] = function (handler, params, prefix) { return handler.insertChars(params); };
  33853. csiStateHandler['A'] = function (handler, params, prefix) { return handler.cursorUp(params); };
  33854. csiStateHandler['B'] = function (handler, params, prefix) { return handler.cursorDown(params); };
  33855. csiStateHandler['C'] = function (handler, params, prefix) { return handler.cursorForward(params); };
  33856. csiStateHandler['D'] = function (handler, params, prefix) { return handler.cursorBackward(params); };
  33857. csiStateHandler['E'] = function (handler, params, prefix) { return handler.cursorNextLine(params); };
  33858. csiStateHandler['F'] = function (handler, params, prefix) { return handler.cursorPrecedingLine(params); };
  33859. csiStateHandler['G'] = function (handler, params, prefix) { return handler.cursorCharAbsolute(params); };
  33860. csiStateHandler['H'] = function (handler, params, prefix) { return handler.cursorPosition(params); };
  33861. csiStateHandler['I'] = function (handler, params, prefix) { return handler.cursorForwardTab(params); };
  33862. csiStateHandler['J'] = function (handler, params, prefix) { return handler.eraseInDisplay(params); };
  33863. csiStateHandler['K'] = function (handler, params, prefix) { return handler.eraseInLine(params); };
  33864. csiStateHandler['L'] = function (handler, params, prefix) { return handler.insertLines(params); };
  33865. csiStateHandler['M'] = function (handler, params, prefix) { return handler.deleteLines(params); };
  33866. csiStateHandler['P'] = function (handler, params, prefix) { return handler.deleteChars(params); };
  33867. csiStateHandler['S'] = function (handler, params, prefix) { return handler.scrollUp(params); };
  33868. csiStateHandler['T'] = function (handler, params, prefix) {
  33869. if (params.length < 2 && !prefix) {
  33870. handler.scrollDown(params);
  33871. }
  33872. };
  33873. csiStateHandler['X'] = function (handler, params, prefix) { return handler.eraseChars(params); };
  33874. csiStateHandler['Z'] = function (handler, params, prefix) { return handler.cursorBackwardTab(params); };
  33875. csiStateHandler['`'] = function (handler, params, prefix) { return handler.charPosAbsolute(params); };
  33876. csiStateHandler['a'] = function (handler, params, prefix) { return handler.HPositionRelative(params); };
  33877. csiStateHandler['b'] = function (handler, params, prefix) { return handler.repeatPrecedingCharacter(params); };
  33878. csiStateHandler['c'] = function (handler, params, prefix) { return handler.sendDeviceAttributes(params); };
  33879. csiStateHandler['d'] = function (handler, params, prefix) { return handler.linePosAbsolute(params); };
  33880. csiStateHandler['e'] = function (handler, params, prefix) { return handler.VPositionRelative(params); };
  33881. csiStateHandler['f'] = function (handler, params, prefix) { return handler.HVPosition(params); };
  33882. csiStateHandler['g'] = function (handler, params, prefix) { return handler.tabClear(params); };
  33883. csiStateHandler['h'] = function (handler, params, prefix) { return handler.setMode(params); };
  33884. csiStateHandler['l'] = function (handler, params, prefix) { return handler.resetMode(params); };
  33885. csiStateHandler['m'] = function (handler, params, prefix) { return handler.charAttributes(params); };
  33886. csiStateHandler['n'] = function (handler, params, prefix) { return handler.deviceStatus(params); };
  33887. csiStateHandler['p'] = function (handler, params, prefix) {
  33888. switch (prefix) {
  33889. case '!':
  33890. handler.softReset(params);
  33891. break;
  33892. }
  33893. };
  33894. csiStateHandler['q'] = function (handler, params, prefix, postfix) {
  33895. if (postfix === ' ') {
  33896. handler.setCursorStyle(params);
  33897. }
  33898. };
  33899. csiStateHandler['r'] = function (handler, params) { return handler.setScrollRegion(params); };
  33900. csiStateHandler['s'] = function (handler, params) { return handler.saveCursor(params); };
  33901. csiStateHandler['u'] = function (handler, params) { return handler.restoreCursor(params); };
  33902. csiStateHandler[EscapeSequences_1.C0.CAN] = function (handler, params, prefix, postfix, parser) { return parser.setState(ParserState.NORMAL); };
  33903. var ParserState;
  33904. (function (ParserState) {
  33905. ParserState[ParserState["NORMAL"] = 0] = "NORMAL";
  33906. ParserState[ParserState["ESCAPED"] = 1] = "ESCAPED";
  33907. ParserState[ParserState["CSI_PARAM"] = 2] = "CSI_PARAM";
  33908. ParserState[ParserState["CSI"] = 3] = "CSI";
  33909. ParserState[ParserState["OSC"] = 4] = "OSC";
  33910. ParserState[ParserState["CHARSET"] = 5] = "CHARSET";
  33911. ParserState[ParserState["DCS"] = 6] = "DCS";
  33912. ParserState[ParserState["IGNORE"] = 7] = "IGNORE";
  33913. })(ParserState = exports.ParserState || (exports.ParserState = {}));
  33914. var Parser = (function () {
  33915. function Parser(_inputHandler, _terminal) {
  33916. this._inputHandler = _inputHandler;
  33917. this._terminal = _terminal;
  33918. this._state = ParserState.NORMAL;
  33919. }
  33920. Parser.prototype.parse = function (data) {
  33921. var l = data.length;
  33922. var j;
  33923. var cs;
  33924. var ch;
  33925. var code;
  33926. var low;
  33927. var cursorStartX = this._terminal.buffer.x;
  33928. var cursorStartY = this._terminal.buffer.y;
  33929. if (this._terminal.debug) {
  33930. this._terminal.log('data: ' + data);
  33931. }
  33932. this._position = 0;
  33933. if (this._terminal.surrogate_high) {
  33934. data = this._terminal.surrogate_high + data;
  33935. this._terminal.surrogate_high = '';
  33936. }
  33937. for (; this._position < l; this._position++) {
  33938. ch = data[this._position];
  33939. code = data.charCodeAt(this._position);
  33940. if (0xD800 <= code && code <= 0xDBFF) {
  33941. low = data.charCodeAt(this._position + 1);
  33942. if (isNaN(low)) {
  33943. this._terminal.surrogate_high = ch;
  33944. continue;
  33945. }
  33946. code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
  33947. ch += data.charAt(this._position + 1);
  33948. }
  33949. if (0xDC00 <= code && code <= 0xDFFF) {
  33950. continue;
  33951. }
  33952. switch (this._state) {
  33953. case ParserState.NORMAL:
  33954. if (ch in normalStateHandler) {
  33955. normalStateHandler[ch](this, this._inputHandler);
  33956. }
  33957. else {
  33958. this._inputHandler.addChar(ch, code);
  33959. }
  33960. break;
  33961. case ParserState.ESCAPED:
  33962. if (ch in escapedStateHandler) {
  33963. escapedStateHandler[ch](this, this._terminal);
  33964. break;
  33965. }
  33966. switch (ch) {
  33967. case '(':
  33968. case ')':
  33969. case '*':
  33970. case '+':
  33971. case '-':
  33972. case '.':
  33973. switch (ch) {
  33974. case '(':
  33975. this._terminal.gcharset = 0;
  33976. break;
  33977. case ')':
  33978. this._terminal.gcharset = 1;
  33979. break;
  33980. case '*':
  33981. this._terminal.gcharset = 2;
  33982. break;
  33983. case '+':
  33984. this._terminal.gcharset = 3;
  33985. break;
  33986. case '-':
  33987. this._terminal.gcharset = 1;
  33988. break;
  33989. case '.':
  33990. this._terminal.gcharset = 2;
  33991. break;
  33992. }
  33993. this._state = ParserState.CHARSET;
  33994. break;
  33995. case '/':
  33996. this._terminal.gcharset = 3;
  33997. this._state = ParserState.CHARSET;
  33998. this._position--;
  33999. break;
  34000. case 'N':
  34001. this._state = ParserState.NORMAL;
  34002. break;
  34003. case 'O':
  34004. this._state = ParserState.NORMAL;
  34005. break;
  34006. case 'n':
  34007. this._terminal.setgLevel(2);
  34008. this._state = ParserState.NORMAL;
  34009. break;
  34010. case 'o':
  34011. this._terminal.setgLevel(3);
  34012. this._state = ParserState.NORMAL;
  34013. break;
  34014. case '|':
  34015. this._terminal.setgLevel(3);
  34016. this._state = ParserState.NORMAL;
  34017. break;
  34018. case '}':
  34019. this._terminal.setgLevel(2);
  34020. this._state = ParserState.NORMAL;
  34021. break;
  34022. case '~':
  34023. this._terminal.setgLevel(1);
  34024. this._state = ParserState.NORMAL;
  34025. break;
  34026. case '7':
  34027. this._inputHandler.saveCursor();
  34028. this._state = ParserState.NORMAL;
  34029. break;
  34030. case '8':
  34031. this._inputHandler.restoreCursor();
  34032. this._state = ParserState.NORMAL;
  34033. break;
  34034. case '#':
  34035. this._state = ParserState.NORMAL;
  34036. this._position++;
  34037. break;
  34038. case 'H':
  34039. this._terminal.tabSet();
  34040. this._state = ParserState.NORMAL;
  34041. break;
  34042. case '=':
  34043. this._terminal.log('Serial port requested application keypad.');
  34044. this._terminal.applicationKeypad = true;
  34045. if (this._terminal.viewport) {
  34046. this._terminal.viewport.syncScrollArea();
  34047. }
  34048. this._state = ParserState.NORMAL;
  34049. break;
  34050. case '>':
  34051. this._terminal.log('Switching back to normal keypad.');
  34052. this._terminal.applicationKeypad = false;
  34053. if (this._terminal.viewport) {
  34054. this._terminal.viewport.syncScrollArea();
  34055. }
  34056. this._state = ParserState.NORMAL;
  34057. break;
  34058. default:
  34059. this._state = ParserState.NORMAL;
  34060. this._terminal.error('Unknown ESC control: %s.', ch);
  34061. break;
  34062. }
  34063. break;
  34064. case ParserState.CHARSET:
  34065. if (ch in Charsets_1.CHARSETS) {
  34066. cs = Charsets_1.CHARSETS[ch];
  34067. if (ch === '/') {
  34068. this.skipNextChar();
  34069. }
  34070. }
  34071. else {
  34072. cs = Charsets_1.DEFAULT_CHARSET;
  34073. }
  34074. this._terminal.setgCharset(this._terminal.gcharset, cs);
  34075. this._terminal.gcharset = null;
  34076. this._state = ParserState.NORMAL;
  34077. break;
  34078. case ParserState.OSC:
  34079. if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
  34080. if (ch === EscapeSequences_1.C0.ESC)
  34081. this._position++;
  34082. this._terminal.params.push(this._terminal.currentParam);
  34083. switch (this._terminal.params[0]) {
  34084. case 0:
  34085. case 1:
  34086. case 2:
  34087. if (this._terminal.params[1]) {
  34088. this._terminal.title = this._terminal.params[1];
  34089. this._terminal.handleTitle(this._terminal.title);
  34090. }
  34091. break;
  34092. case 3:
  34093. break;
  34094. case 4:
  34095. case 5:
  34096. break;
  34097. case 10:
  34098. case 11:
  34099. case 12:
  34100. case 13:
  34101. case 14:
  34102. case 15:
  34103. case 16:
  34104. case 17:
  34105. case 18:
  34106. case 19:
  34107. break;
  34108. case 46:
  34109. break;
  34110. case 50:
  34111. break;
  34112. case 51:
  34113. break;
  34114. case 52:
  34115. break;
  34116. case 104:
  34117. case 105:
  34118. case 110:
  34119. case 111:
  34120. case 112:
  34121. case 113:
  34122. case 114:
  34123. case 115:
  34124. case 116:
  34125. case 117:
  34126. case 118:
  34127. break;
  34128. }
  34129. this._terminal.params = [];
  34130. this._terminal.currentParam = 0;
  34131. this._state = ParserState.NORMAL;
  34132. }
  34133. else {
  34134. if (!this._terminal.params.length) {
  34135. if (ch >= '0' && ch <= '9') {
  34136. this._terminal.currentParam =
  34137. this._terminal.currentParam * 10 + ch.charCodeAt(0) - 48;
  34138. }
  34139. else if (ch === ';') {
  34140. this._terminal.params.push(this._terminal.currentParam);
  34141. this._terminal.currentParam = '';
  34142. }
  34143. }
  34144. else {
  34145. this._terminal.currentParam += ch;
  34146. }
  34147. }
  34148. break;
  34149. case ParserState.CSI_PARAM:
  34150. if (ch in csiParamStateHandler) {
  34151. csiParamStateHandler[ch](this);
  34152. break;
  34153. }
  34154. this.finalizeParam();
  34155. this._state = ParserState.CSI;
  34156. case ParserState.CSI:
  34157. if (ch in csiStateHandler) {
  34158. if (this._terminal.debug) {
  34159. this._terminal.log("CSI " + (this._terminal.prefix ? this._terminal.prefix : '') + " " + (this._terminal.params ? this._terminal.params.join(';') : '') + " " + (this._terminal.postfix ? this._terminal.postfix : '') + " " + ch);
  34160. }
  34161. csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
  34162. }
  34163. else {
  34164. this._terminal.error('Unknown CSI code: %s.', ch);
  34165. }
  34166. this._state = ParserState.NORMAL;
  34167. this._terminal.prefix = '';
  34168. this._terminal.postfix = '';
  34169. break;
  34170. case ParserState.DCS:
  34171. if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
  34172. if (ch === EscapeSequences_1.C0.ESC)
  34173. this._position++;
  34174. var pt = void 0;
  34175. var valid = void 0;
  34176. switch (this._terminal.prefix) {
  34177. case '':
  34178. break;
  34179. case '$q':
  34180. pt = this._terminal.currentParam;
  34181. valid = false;
  34182. switch (pt) {
  34183. case '"q':
  34184. pt = '0"q';
  34185. break;
  34186. case '"p':
  34187. pt = '61"p';
  34188. break;
  34189. case 'r':
  34190. pt = ''
  34191. + (this._terminal.buffer.scrollTop + 1)
  34192. + ';'
  34193. + (this._terminal.buffer.scrollBottom + 1)
  34194. + 'r';
  34195. break;
  34196. case 'm':
  34197. pt = '0m';
  34198. break;
  34199. default:
  34200. this._terminal.error('Unknown DCS Pt: %s.', pt);
  34201. pt = '';
  34202. break;
  34203. }
  34204. this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '$r' + pt + EscapeSequences_1.C0.ESC + '\\');
  34205. break;
  34206. case '+p':
  34207. break;
  34208. case '+q':
  34209. pt = this._terminal.currentParam;
  34210. valid = false;
  34211. this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '+r' + pt + EscapeSequences_1.C0.ESC + '\\');
  34212. break;
  34213. default:
  34214. this._terminal.error('Unknown DCS prefix: %s.', this._terminal.prefix);
  34215. break;
  34216. }
  34217. this._terminal.currentParam = 0;
  34218. this._terminal.prefix = '';
  34219. this._state = ParserState.NORMAL;
  34220. }
  34221. else if (!this._terminal.currentParam) {
  34222. if (!this._terminal.prefix && ch !== '$' && ch !== '+') {
  34223. this._terminal.currentParam = ch;
  34224. }
  34225. else if (this._terminal.prefix.length === 2) {
  34226. this._terminal.currentParam = ch;
  34227. }
  34228. else {
  34229. this._terminal.prefix += ch;
  34230. }
  34231. }
  34232. else {
  34233. this._terminal.currentParam += ch;
  34234. }
  34235. break;
  34236. case ParserState.IGNORE:
  34237. if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
  34238. if (ch === EscapeSequences_1.C0.ESC)
  34239. this._position++;
  34240. this._state = ParserState.NORMAL;
  34241. }
  34242. break;
  34243. }
  34244. }
  34245. if (this._terminal.buffer.x !== cursorStartX || this._terminal.buffer.y !== cursorStartY) {
  34246. this._terminal.emit('cursormove');
  34247. }
  34248. return this._state;
  34249. };
  34250. Parser.prototype.setState = function (state) {
  34251. this._state = state;
  34252. };
  34253. Parser.prototype.setPrefix = function (prefix) {
  34254. this._terminal.prefix = prefix;
  34255. };
  34256. Parser.prototype.setPostfix = function (postfix) {
  34257. this._terminal.postfix = postfix;
  34258. };
  34259. Parser.prototype.setParam = function (param) {
  34260. this._terminal.currentParam = param;
  34261. };
  34262. Parser.prototype.getParam = function () {
  34263. return this._terminal.currentParam;
  34264. };
  34265. Parser.prototype.finalizeParam = function () {
  34266. this._terminal.params.push(this._terminal.currentParam);
  34267. this._terminal.currentParam = 0;
  34268. };
  34269. Parser.prototype.skipNextChar = function () {
  34270. this._position++;
  34271. };
  34272. return Parser;
  34273. }());
  34274. exports.Parser = Parser;
  34275. },{"./Charsets":4,"./EscapeSequences":6}],11:[function(require,module,exports){
  34276. "use strict";
  34277. var __extends = (this && this.__extends) || (function () {
  34278. var extendStatics = Object.setPrototypeOf ||
  34279. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34280. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34281. return function (d, b) {
  34282. extendStatics(d, b);
  34283. function __() { this.constructor = d; }
  34284. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34285. };
  34286. })();
  34287. Object.defineProperty(exports, "__esModule", { value: true });
  34288. var MouseHelper_1 = require("./utils/MouseHelper");
  34289. var Browser = require("./shared/utils/Browser");
  34290. var EventEmitter_1 = require("./EventEmitter");
  34291. var SelectionModel_1 = require("./SelectionModel");
  34292. var Buffer_1 = require("./Buffer");
  34293. var AltClickHandler_1 = require("./handlers/AltClickHandler");
  34294. var DRAG_SCROLL_MAX_THRESHOLD = 50;
  34295. var DRAG_SCROLL_MAX_SPEED = 15;
  34296. var DRAG_SCROLL_INTERVAL = 50;
  34297. var ALT_CLICK_MOVE_CURSOR_TIME = 500;
  34298. var WORD_SEPARATORS = ' ()[]{}\'"';
  34299. var NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
  34300. var ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
  34301. var SelectionMode;
  34302. (function (SelectionMode) {
  34303. SelectionMode[SelectionMode["NORMAL"] = 0] = "NORMAL";
  34304. SelectionMode[SelectionMode["WORD"] = 1] = "WORD";
  34305. SelectionMode[SelectionMode["LINE"] = 2] = "LINE";
  34306. })(SelectionMode || (SelectionMode = {}));
  34307. var SelectionManager = (function (_super) {
  34308. __extends(SelectionManager, _super);
  34309. function SelectionManager(_terminal, _charMeasure) {
  34310. var _this = _super.call(this) || this;
  34311. _this._terminal = _terminal;
  34312. _this._charMeasure = _charMeasure;
  34313. _this._enabled = true;
  34314. _this._initListeners();
  34315. _this.enable();
  34316. _this._model = new SelectionModel_1.SelectionModel(_terminal);
  34317. _this._activeSelectionMode = SelectionMode.NORMAL;
  34318. return _this;
  34319. }
  34320. Object.defineProperty(SelectionManager.prototype, "_buffer", {
  34321. get: function () {
  34322. return this._terminal.buffers.active;
  34323. },
  34324. enumerable: true,
  34325. configurable: true
  34326. });
  34327. SelectionManager.prototype._initListeners = function () {
  34328. var _this = this;
  34329. this._mouseMoveListener = function (event) { return _this._onMouseMove(event); };
  34330. this._mouseUpListener = function (event) { return _this._onMouseUp(event); };
  34331. this._trimListener = function (amount) { return _this._onTrim(amount); };
  34332. this.initBuffersListeners();
  34333. };
  34334. SelectionManager.prototype.initBuffersListeners = function () {
  34335. var _this = this;
  34336. this._terminal.buffer.lines.on('trim', this._trimListener);
  34337. this._terminal.buffers.on('activate', function (e) { return _this._onBufferActivate(e); });
  34338. };
  34339. SelectionManager.prototype.disable = function () {
  34340. this.clearSelection();
  34341. this._enabled = false;
  34342. };
  34343. SelectionManager.prototype.enable = function () {
  34344. this._enabled = true;
  34345. };
  34346. Object.defineProperty(SelectionManager.prototype, "selectionStart", {
  34347. get: function () { return this._model.finalSelectionStart; },
  34348. enumerable: true,
  34349. configurable: true
  34350. });
  34351. Object.defineProperty(SelectionManager.prototype, "selectionEnd", {
  34352. get: function () { return this._model.finalSelectionEnd; },
  34353. enumerable: true,
  34354. configurable: true
  34355. });
  34356. Object.defineProperty(SelectionManager.prototype, "hasSelection", {
  34357. get: function () {
  34358. var start = this._model.finalSelectionStart;
  34359. var end = this._model.finalSelectionEnd;
  34360. if (!start || !end) {
  34361. return false;
  34362. }
  34363. return start[0] !== end[0] || start[1] !== end[1];
  34364. },
  34365. enumerable: true,
  34366. configurable: true
  34367. });
  34368. Object.defineProperty(SelectionManager.prototype, "selectionText", {
  34369. get: function () {
  34370. var start = this._model.finalSelectionStart;
  34371. var end = this._model.finalSelectionEnd;
  34372. if (!start || !end) {
  34373. return '';
  34374. }
  34375. var startRowEndCol = start[1] === end[1] ? end[0] : null;
  34376. var result = [];
  34377. result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
  34378. for (var i = start[1] + 1; i <= end[1] - 1; i++) {
  34379. var bufferLine = this._buffer.lines.get(i);
  34380. var lineText = this._buffer.translateBufferLineToString(i, true);
  34381. if (bufferLine.isWrapped) {
  34382. result[result.length - 1] += lineText;
  34383. }
  34384. else {
  34385. result.push(lineText);
  34386. }
  34387. }
  34388. if (start[1] !== end[1]) {
  34389. var bufferLine = this._buffer.lines.get(end[1]);
  34390. var lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);
  34391. if (bufferLine.isWrapped) {
  34392. result[result.length - 1] += lineText;
  34393. }
  34394. else {
  34395. result.push(lineText);
  34396. }
  34397. }
  34398. var formattedResult = result.map(function (line) {
  34399. return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');
  34400. }).join(Browser.isMSWindows ? '\r\n' : '\n');
  34401. return formattedResult;
  34402. },
  34403. enumerable: true,
  34404. configurable: true
  34405. });
  34406. SelectionManager.prototype.clearSelection = function () {
  34407. this._model.clearSelection();
  34408. this._removeMouseDownListeners();
  34409. this.refresh();
  34410. };
  34411. SelectionManager.prototype.refresh = function (isNewSelection) {
  34412. var _this = this;
  34413. if (!this._refreshAnimationFrame) {
  34414. this._refreshAnimationFrame = window.requestAnimationFrame(function () { return _this._refresh(); });
  34415. }
  34416. if (Browser.isLinux && isNewSelection) {
  34417. var selectionText = this.selectionText;
  34418. if (selectionText.length) {
  34419. this.emit('newselection', this.selectionText);
  34420. }
  34421. }
  34422. };
  34423. SelectionManager.prototype._refresh = function () {
  34424. this._refreshAnimationFrame = null;
  34425. this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });
  34426. };
  34427. SelectionManager.prototype.isClickInSelection = function (event) {
  34428. var coords = this._getMouseBufferCoords(event);
  34429. var start = this._model.finalSelectionStart;
  34430. var end = this._model.finalSelectionEnd;
  34431. if (!start || !end) {
  34432. return false;
  34433. }
  34434. return (coords[1] > start[1] && coords[1] < end[1]) ||
  34435. (start[1] === end[1] && coords[1] === start[1] && coords[0] > start[0] && coords[0] < end[0]) ||
  34436. (start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]);
  34437. };
  34438. SelectionManager.prototype.selectWordAtCursor = function (event) {
  34439. var coords = this._getMouseBufferCoords(event);
  34440. if (coords) {
  34441. this._selectWordAt(coords, false);
  34442. this._model.selectionEnd = null;
  34443. this.refresh(true);
  34444. }
  34445. };
  34446. SelectionManager.prototype.selectAll = function () {
  34447. this._model.isSelectAllActive = true;
  34448. this.refresh();
  34449. this._terminal.emit('selection');
  34450. };
  34451. SelectionManager.prototype._onTrim = function (amount) {
  34452. var needsRefresh = this._model.onTrim(amount);
  34453. if (needsRefresh) {
  34454. this.refresh();
  34455. }
  34456. };
  34457. SelectionManager.prototype._getMouseBufferCoords = function (event) {
  34458. var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);
  34459. if (!coords) {
  34460. return null;
  34461. }
  34462. coords[0]--;
  34463. coords[1]--;
  34464. coords[1] += this._terminal.buffer.ydisp;
  34465. return coords;
  34466. };
  34467. SelectionManager.prototype._getMouseEventScrollAmount = function (event) {
  34468. var offset = MouseHelper_1.MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];
  34469. var terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);
  34470. if (offset >= 0 && offset <= terminalHeight) {
  34471. return 0;
  34472. }
  34473. if (offset > terminalHeight) {
  34474. offset -= terminalHeight;
  34475. }
  34476. offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);
  34477. offset /= DRAG_SCROLL_MAX_THRESHOLD;
  34478. return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
  34479. };
  34480. SelectionManager.prototype.shouldForceSelection = function (event) {
  34481. return Browser.isMac ? event.altKey : event.shiftKey;
  34482. };
  34483. SelectionManager.prototype.onMouseDown = function (event) {
  34484. this._mouseDownTimeStamp = event.timeStamp;
  34485. if (event.button === 2 && this.hasSelection) {
  34486. return;
  34487. }
  34488. if (event.button !== 0) {
  34489. return;
  34490. }
  34491. if (!this._enabled) {
  34492. if (!this.shouldForceSelection(event)) {
  34493. return;
  34494. }
  34495. event.stopPropagation();
  34496. }
  34497. event.preventDefault();
  34498. this._dragScrollAmount = 0;
  34499. if (this._enabled && event.shiftKey) {
  34500. this._onIncrementalClick(event);
  34501. }
  34502. else {
  34503. if (event.detail === 1) {
  34504. this._onSingleClick(event);
  34505. }
  34506. else if (event.detail === 2) {
  34507. this._onDoubleClick(event);
  34508. }
  34509. else if (event.detail === 3) {
  34510. this._onTripleClick(event);
  34511. }
  34512. }
  34513. this._addMouseDownListeners();
  34514. this.refresh(true);
  34515. };
  34516. SelectionManager.prototype._addMouseDownListeners = function () {
  34517. var _this = this;
  34518. this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
  34519. this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
  34520. this._dragScrollIntervalTimer = setInterval(function () { return _this._dragScroll(); }, DRAG_SCROLL_INTERVAL);
  34521. };
  34522. SelectionManager.prototype._removeMouseDownListeners = function () {
  34523. this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
  34524. this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
  34525. clearInterval(this._dragScrollIntervalTimer);
  34526. this._dragScrollIntervalTimer = null;
  34527. };
  34528. SelectionManager.prototype._onIncrementalClick = function (event) {
  34529. if (this._model.selectionStart) {
  34530. this._model.selectionEnd = this._getMouseBufferCoords(event);
  34531. }
  34532. };
  34533. SelectionManager.prototype._onSingleClick = function (event) {
  34534. this._model.selectionStartLength = 0;
  34535. this._model.isSelectAllActive = false;
  34536. this._activeSelectionMode = SelectionMode.NORMAL;
  34537. this._model.selectionStart = this._getMouseBufferCoords(event);
  34538. if (!this._model.selectionStart) {
  34539. return;
  34540. }
  34541. this._model.selectionEnd = null;
  34542. var line = this._buffer.lines.get(this._model.selectionStart[1]);
  34543. if (!line) {
  34544. return;
  34545. }
  34546. if (line.length >= this._model.selectionStart[0]) {
  34547. return;
  34548. }
  34549. var char = line[this._model.selectionStart[0]];
  34550. if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34551. this._model.selectionStart[0]++;
  34552. }
  34553. };
  34554. SelectionManager.prototype._onDoubleClick = function (event) {
  34555. var coords = this._getMouseBufferCoords(event);
  34556. if (coords) {
  34557. this._activeSelectionMode = SelectionMode.WORD;
  34558. this._selectWordAt(coords, true);
  34559. }
  34560. };
  34561. SelectionManager.prototype._onTripleClick = function (event) {
  34562. var coords = this._getMouseBufferCoords(event);
  34563. if (coords) {
  34564. this._activeSelectionMode = SelectionMode.LINE;
  34565. this._selectLineAt(coords[1]);
  34566. }
  34567. };
  34568. SelectionManager.prototype._onMouseMove = function (event) {
  34569. event.stopImmediatePropagation();
  34570. var previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;
  34571. this._model.selectionEnd = this._getMouseBufferCoords(event);
  34572. if (!this._model.selectionEnd) {
  34573. this.refresh(true);
  34574. return;
  34575. }
  34576. if (this._activeSelectionMode === SelectionMode.LINE) {
  34577. if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {
  34578. this._model.selectionEnd[0] = 0;
  34579. }
  34580. else {
  34581. this._model.selectionEnd[0] = this._terminal.cols;
  34582. }
  34583. }
  34584. else if (this._activeSelectionMode === SelectionMode.WORD) {
  34585. this._selectToWordAt(this._model.selectionEnd);
  34586. }
  34587. this._dragScrollAmount = this._getMouseEventScrollAmount(event);
  34588. if (this._dragScrollAmount > 0) {
  34589. this._model.selectionEnd[0] = this._terminal.cols;
  34590. }
  34591. else if (this._dragScrollAmount < 0) {
  34592. this._model.selectionEnd[0] = 0;
  34593. }
  34594. if (this._model.selectionEnd[1] < this._buffer.lines.length) {
  34595. var char = this._buffer.lines.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
  34596. if (char && char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34597. this._model.selectionEnd[0]++;
  34598. }
  34599. }
  34600. if (!previousSelectionEnd ||
  34601. previousSelectionEnd[0] !== this._model.selectionEnd[0] ||
  34602. previousSelectionEnd[1] !== this._model.selectionEnd[1]) {
  34603. this.refresh(true);
  34604. }
  34605. };
  34606. SelectionManager.prototype._dragScroll = function () {
  34607. if (this._dragScrollAmount) {
  34608. this._terminal.scrollLines(this._dragScrollAmount, false);
  34609. if (this._dragScrollAmount > 0) {
  34610. this._model.selectionEnd = [this._terminal.cols - 1, Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1)];
  34611. }
  34612. else {
  34613. this._model.selectionEnd = [0, this._terminal.buffer.ydisp];
  34614. }
  34615. this.refresh();
  34616. }
  34617. };
  34618. SelectionManager.prototype._onMouseUp = function (event) {
  34619. var timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
  34620. this._removeMouseDownListeners();
  34621. if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {
  34622. (new AltClickHandler_1.AltClickHandler(event, this._terminal)).move();
  34623. }
  34624. else if (this.hasSelection) {
  34625. this._terminal.emit('selection');
  34626. }
  34627. };
  34628. SelectionManager.prototype._onBufferActivate = function (e) {
  34629. this.clearSelection();
  34630. e.inactiveBuffer.lines.off('trim', this._trimListener);
  34631. e.activeBuffer.lines.on('trim', this._trimListener);
  34632. };
  34633. SelectionManager.prototype._convertViewportColToCharacterIndex = function (bufferLine, coords) {
  34634. var charIndex = coords[0];
  34635. for (var i = 0; coords[0] >= i; i++) {
  34636. var char = bufferLine[i];
  34637. if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34638. charIndex--;
  34639. }
  34640. else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1 && coords[0] !== i) {
  34641. charIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34642. }
  34643. }
  34644. return charIndex;
  34645. };
  34646. SelectionManager.prototype.setSelection = function (col, row, length) {
  34647. this._model.clearSelection();
  34648. this._removeMouseDownListeners();
  34649. this._model.selectionStart = [col, row];
  34650. this._model.selectionStartLength = length;
  34651. this.refresh();
  34652. };
  34653. SelectionManager.prototype._getWordAt = function (coords, allowWhitespaceOnlySelection) {
  34654. var bufferLine = this._buffer.lines.get(coords[1]);
  34655. if (!bufferLine) {
  34656. return null;
  34657. }
  34658. var line = this._buffer.translateBufferLineToString(coords[1], false);
  34659. var startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);
  34660. var endIndex = startIndex;
  34661. var charOffset = coords[0] - startIndex;
  34662. var leftWideCharCount = 0;
  34663. var rightWideCharCount = 0;
  34664. var leftLongCharOffset = 0;
  34665. var rightLongCharOffset = 0;
  34666. if (line.charAt(startIndex) === ' ') {
  34667. while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {
  34668. startIndex--;
  34669. }
  34670. while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {
  34671. endIndex++;
  34672. }
  34673. }
  34674. else {
  34675. var startCol = coords[0];
  34676. var endCol = coords[0];
  34677. if (bufferLine[startCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34678. leftWideCharCount++;
  34679. startCol--;
  34680. }
  34681. if (bufferLine[endCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
  34682. rightWideCharCount++;
  34683. endCol++;
  34684. }
  34685. if (bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
  34686. rightLongCharOffset += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34687. endIndex += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34688. }
  34689. while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine[startCol - 1])) {
  34690. var char = bufferLine[startCol - 1];
  34691. if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34692. leftWideCharCount++;
  34693. startCol--;
  34694. }
  34695. else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
  34696. leftLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34697. startIndex -= char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34698. }
  34699. startIndex--;
  34700. startCol--;
  34701. }
  34702. while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine[endCol + 1])) {
  34703. var char = bufferLine[endCol + 1];
  34704. if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
  34705. rightWideCharCount++;
  34706. endCol++;
  34707. }
  34708. else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
  34709. rightLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34710. endIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
  34711. }
  34712. endIndex++;
  34713. endCol++;
  34714. }
  34715. }
  34716. endIndex++;
  34717. var start = startIndex
  34718. + charOffset
  34719. - leftWideCharCount
  34720. + leftLongCharOffset;
  34721. var length = Math.min(this._terminal.cols, endIndex
  34722. - startIndex
  34723. + leftWideCharCount
  34724. + rightWideCharCount
  34725. - leftLongCharOffset
  34726. - rightLongCharOffset);
  34727. if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {
  34728. return null;
  34729. }
  34730. return { start: start, length: length };
  34731. };
  34732. SelectionManager.prototype._selectWordAt = function (coords, allowWhitespaceOnlySelection) {
  34733. var wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);
  34734. if (wordPosition) {
  34735. this._model.selectionStart = [wordPosition.start, coords[1]];
  34736. this._model.selectionStartLength = wordPosition.length;
  34737. }
  34738. };
  34739. SelectionManager.prototype._selectToWordAt = function (coords) {
  34740. var wordPosition = this._getWordAt(coords, true);
  34741. if (wordPosition) {
  34742. this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];
  34743. }
  34744. };
  34745. SelectionManager.prototype._isCharWordSeparator = function (charData) {
  34746. if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
  34747. return false;
  34748. }
  34749. return WORD_SEPARATORS.indexOf(charData[Buffer_1.CHAR_DATA_CHAR_INDEX]) >= 0;
  34750. };
  34751. SelectionManager.prototype._selectLineAt = function (line) {
  34752. this._model.selectionStart = [0, line];
  34753. this._model.selectionStartLength = this._terminal.cols;
  34754. };
  34755. return SelectionManager;
  34756. }(EventEmitter_1.EventEmitter));
  34757. exports.SelectionManager = SelectionManager;
  34758. },{"./Buffer":1,"./EventEmitter":7,"./SelectionModel":12,"./handlers/AltClickHandler":16,"./shared/utils/Browser":30,"./utils/MouseHelper":33}],12:[function(require,module,exports){
  34759. "use strict";
  34760. Object.defineProperty(exports, "__esModule", { value: true });
  34761. var SelectionModel = (function () {
  34762. function SelectionModel(_terminal) {
  34763. this._terminal = _terminal;
  34764. this.clearSelection();
  34765. }
  34766. SelectionModel.prototype.clearSelection = function () {
  34767. this.selectionStart = null;
  34768. this.selectionEnd = null;
  34769. this.isSelectAllActive = false;
  34770. this.selectionStartLength = 0;
  34771. };
  34772. Object.defineProperty(SelectionModel.prototype, "finalSelectionStart", {
  34773. get: function () {
  34774. if (this.isSelectAllActive) {
  34775. return [0, 0];
  34776. }
  34777. if (!this.selectionEnd || !this.selectionStart) {
  34778. return this.selectionStart;
  34779. }
  34780. return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
  34781. },
  34782. enumerable: true,
  34783. configurable: true
  34784. });
  34785. Object.defineProperty(SelectionModel.prototype, "finalSelectionEnd", {
  34786. get: function () {
  34787. if (this.isSelectAllActive) {
  34788. return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];
  34789. }
  34790. if (!this.selectionStart) {
  34791. return null;
  34792. }
  34793. if (!this.selectionEnd || this.areSelectionValuesReversed()) {
  34794. return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];
  34795. }
  34796. if (this.selectionStartLength) {
  34797. if (this.selectionEnd[1] === this.selectionStart[1]) {
  34798. return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];
  34799. }
  34800. }
  34801. return this.selectionEnd;
  34802. },
  34803. enumerable: true,
  34804. configurable: true
  34805. });
  34806. SelectionModel.prototype.areSelectionValuesReversed = function () {
  34807. var start = this.selectionStart;
  34808. var end = this.selectionEnd;
  34809. if (!start || !end) {
  34810. return false;
  34811. }
  34812. return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);
  34813. };
  34814. SelectionModel.prototype.onTrim = function (amount) {
  34815. if (this.selectionStart) {
  34816. this.selectionStart[1] -= amount;
  34817. }
  34818. if (this.selectionEnd) {
  34819. this.selectionEnd[1] -= amount;
  34820. }
  34821. if (this.selectionEnd && this.selectionEnd[1] < 0) {
  34822. this.clearSelection();
  34823. return true;
  34824. }
  34825. if (this.selectionStart && this.selectionStart[1] < 0) {
  34826. this.selectionStart[1] = 0;
  34827. }
  34828. return false;
  34829. };
  34830. return SelectionModel;
  34831. }());
  34832. exports.SelectionModel = SelectionModel;
  34833. },{}],13:[function(require,module,exports){
  34834. "use strict";
  34835. var __extends = (this && this.__extends) || (function () {
  34836. var extendStatics = Object.setPrototypeOf ||
  34837. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34838. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34839. return function (d, b) {
  34840. extendStatics(d, b);
  34841. function __() { this.constructor = d; }
  34842. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34843. };
  34844. })();
  34845. Object.defineProperty(exports, "__esModule", { value: true });
  34846. var BufferSet_1 = require("./BufferSet");
  34847. var Buffer_1 = require("./Buffer");
  34848. var CompositionHelper_1 = require("./CompositionHelper");
  34849. var EventEmitter_1 = require("./EventEmitter");
  34850. var Viewport_1 = require("./Viewport");
  34851. var Clipboard_1 = require("./handlers/Clipboard");
  34852. var EscapeSequences_1 = require("./EscapeSequences");
  34853. var InputHandler_1 = require("./InputHandler");
  34854. var Parser_1 = require("./Parser");
  34855. var Renderer_1 = require("./renderer/Renderer");
  34856. var Linkifier_1 = require("./Linkifier");
  34857. var SelectionManager_1 = require("./SelectionManager");
  34858. var CharMeasure_1 = require("./utils/CharMeasure");
  34859. var Browser = require("./shared/utils/Browser");
  34860. var MouseHelper_1 = require("./utils/MouseHelper");
  34861. var Sounds_1 = require("./utils/Sounds");
  34862. var ColorManager_1 = require("./renderer/ColorManager");
  34863. var MouseZoneManager_1 = require("./input/MouseZoneManager");
  34864. var document = (typeof window !== 'undefined') ? window.document : null;
  34865. var WRITE_BUFFER_PAUSE_THRESHOLD = 5;
  34866. var WRITE_BATCH_SIZE = 300;
  34867. var DEFAULT_OPTIONS = {
  34868. cols: 80,
  34869. rows: 24,
  34870. convertEol: false,
  34871. termName: 'xterm',
  34872. cursorBlink: false,
  34873. cursorStyle: 'block',
  34874. bellSound: Sounds_1.BELL_SOUND,
  34875. bellStyle: 'none',
  34876. enableBold: true,
  34877. fontFamily: 'courier-new, courier, monospace',
  34878. fontSize: 15,
  34879. fontWeight: 'normal',
  34880. fontWeightBold: 'bold',
  34881. lineHeight: 1.0,
  34882. letterSpacing: 0,
  34883. scrollback: 1000,
  34884. screenKeys: false,
  34885. debug: false,
  34886. macOptionIsMeta: false,
  34887. cancelEvents: false,
  34888. disableStdin: false,
  34889. useFlowControl: false,
  34890. allowTransparency: false,
  34891. tabStopWidth: 8,
  34892. theme: null,
  34893. rightClickSelectsWord: Browser.isMac
  34894. };
  34895. var Terminal = (function (_super) {
  34896. __extends(Terminal, _super);
  34897. function Terminal(options) {
  34898. if (options === void 0) { options = {}; }
  34899. var _this = _super.call(this) || this;
  34900. _this.browser = Browser;
  34901. _this.options = options;
  34902. _this.setup();
  34903. return _this;
  34904. }
  34905. Terminal.prototype.setup = function () {
  34906. var _this = this;
  34907. Object.keys(DEFAULT_OPTIONS).forEach(function (key) {
  34908. if (_this.options[key] == null) {
  34909. _this.options[key] = DEFAULT_OPTIONS[key];
  34910. }
  34911. _this[key] = _this.options[key];
  34912. });
  34913. this.parent = document ? document.body : null;
  34914. this.cols = this.options.cols;
  34915. this.rows = this.options.rows;
  34916. if (this.options.handler) {
  34917. this.on('data', this.options.handler);
  34918. }
  34919. this.cursorState = 0;
  34920. this.cursorHidden = false;
  34921. this.sendDataQueue = '';
  34922. this.customKeyEventHandler = null;
  34923. this.applicationKeypad = false;
  34924. this.applicationCursor = false;
  34925. this.originMode = false;
  34926. this.insertMode = false;
  34927. this.wraparoundMode = true;
  34928. this.bracketedPasteMode = false;
  34929. this.charset = null;
  34930. this.gcharset = null;
  34931. this.glevel = 0;
  34932. this.charsets = [null];
  34933. this.readable = true;
  34934. this.writable = true;
  34935. this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);
  34936. this.curAttr = (0 << 18) | (257 << 9) | (256 << 0);
  34937. this.params = [];
  34938. this.currentParam = 0;
  34939. this.prefix = '';
  34940. this.postfix = '';
  34941. this.writeBuffer = [];
  34942. this.writeInProgress = false;
  34943. this.xoffSentToCatchUp = false;
  34944. this.writeStopped = false;
  34945. this.surrogateHigh = '';
  34946. this.userScrolling = false;
  34947. this.inputHandler = new InputHandler_1.InputHandler(this);
  34948. this.parser = new Parser_1.Parser(this.inputHandler, this);
  34949. this.renderer = this.renderer || null;
  34950. this.selectionManager = this.selectionManager || null;
  34951. this.linkifier = this.linkifier || new Linkifier_1.Linkifier(this);
  34952. this._mouseZoneManager = this._mouseZoneManager || null;
  34953. this.buffers = new BufferSet_1.BufferSet(this);
  34954. if (this.selectionManager) {
  34955. this.selectionManager.clearSelection();
  34956. this.selectionManager.initBuffersListeners();
  34957. }
  34958. };
  34959. Object.defineProperty(Terminal.prototype, "buffer", {
  34960. get: function () {
  34961. return this.buffers.active;
  34962. },
  34963. enumerable: true,
  34964. configurable: true
  34965. });
  34966. Terminal.prototype.eraseAttr = function () {
  34967. return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);
  34968. };
  34969. Terminal.prototype.focus = function () {
  34970. if (this.textarea) {
  34971. this.textarea.focus();
  34972. }
  34973. };
  34974. Object.defineProperty(Terminal.prototype, "isFocused", {
  34975. get: function () {
  34976. return document.activeElement === this.textarea;
  34977. },
  34978. enumerable: true,
  34979. configurable: true
  34980. });
  34981. Terminal.prototype.getOption = function (key) {
  34982. if (!(key in DEFAULT_OPTIONS)) {
  34983. throw new Error('No option with key "' + key + '"');
  34984. }
  34985. if (typeof this.options[key] !== 'undefined') {
  34986. return this.options[key];
  34987. }
  34988. return this[key];
  34989. };
  34990. Terminal.prototype.setOption = function (key, value) {
  34991. if (!(key in DEFAULT_OPTIONS)) {
  34992. throw new Error('No option with key "' + key + '"');
  34993. }
  34994. switch (key) {
  34995. case 'bellStyle':
  34996. if (!value) {
  34997. value = 'none';
  34998. }
  34999. break;
  35000. case 'cursorStyle':
  35001. if (!value) {
  35002. value = 'block';
  35003. }
  35004. break;
  35005. case 'fontWeight':
  35006. if (!value) {
  35007. value = 'normal';
  35008. }
  35009. break;
  35010. case 'fontWeightBold':
  35011. if (!value) {
  35012. value = 'bold';
  35013. }
  35014. break;
  35015. case 'lineHeight':
  35016. if (value < 1) {
  35017. console.warn(key + " cannot be less than 1, value: " + value);
  35018. return;
  35019. }
  35020. case 'tabStopWidth':
  35021. if (value < 1) {
  35022. console.warn(key + " cannot be less than 1, value: " + value);
  35023. return;
  35024. }
  35025. break;
  35026. case 'theme':
  35027. if (this.renderer) {
  35028. this._setTheme(value);
  35029. return;
  35030. }
  35031. break;
  35032. case 'scrollback':
  35033. value = Math.min(value, Buffer_1.MAX_BUFFER_SIZE);
  35034. if (value < 0) {
  35035. console.warn(key + " cannot be less than 0, value: " + value);
  35036. return;
  35037. }
  35038. if (this.options[key] !== value) {
  35039. var newBufferLength = this.rows + value;
  35040. if (this.buffer.lines.length > newBufferLength) {
  35041. var amountToTrim = this.buffer.lines.length - newBufferLength;
  35042. var needsRefresh = (this.buffer.ydisp - amountToTrim < 0);
  35043. this.buffer.lines.trimStart(amountToTrim);
  35044. this.buffer.ybase = Math.max(this.buffer.ybase - amountToTrim, 0);
  35045. this.buffer.ydisp = Math.max(this.buffer.ydisp - amountToTrim, 0);
  35046. if (needsRefresh) {
  35047. this.refresh(0, this.rows - 1);
  35048. }
  35049. }
  35050. }
  35051. break;
  35052. }
  35053. this[key] = value;
  35054. this.options[key] = value;
  35055. switch (key) {
  35056. case 'fontFamily':
  35057. case 'fontSize':
  35058. this.renderer.clear();
  35059. this.charMeasure.measure(this.options);
  35060. break;
  35061. case 'enableBold':
  35062. case 'letterSpacing':
  35063. case 'lineHeight':
  35064. case 'fontWeight':
  35065. case 'fontWeightBold':
  35066. var didCharSizeChange = (key === 'fontWeight' || key === 'fontWeightBold' || key === 'enableBold');
  35067. this.renderer.clear();
  35068. this.renderer.onResize(this.cols, this.rows, didCharSizeChange);
  35069. this.refresh(0, this.rows - 1);
  35070. case 'scrollback':
  35071. this.buffers.resize(this.cols, this.rows);
  35072. this.viewport.syncScrollArea();
  35073. break;
  35074. case 'tabStopWidth':
  35075. this.buffers.setupTabStops();
  35076. break;
  35077. case 'bellSound':
  35078. case 'bellStyle':
  35079. this.syncBellSound();
  35080. break;
  35081. }
  35082. if (this.renderer) {
  35083. this.renderer.onOptionsChanged();
  35084. }
  35085. };
  35086. Terminal.prototype._onTextAreaFocus = function () {
  35087. if (this.sendFocus) {
  35088. this.send(EscapeSequences_1.C0.ESC + '[I');
  35089. }
  35090. this.element.classList.add('focus');
  35091. this.showCursor();
  35092. this.emit('focus');
  35093. };
  35094. Terminal.prototype.blur = function () {
  35095. return this.textarea.blur();
  35096. };
  35097. Terminal.prototype._onTextAreaBlur = function () {
  35098. this.refresh(this.buffer.y, this.buffer.y);
  35099. if (this.sendFocus) {
  35100. this.send(EscapeSequences_1.C0.ESC + '[O');
  35101. }
  35102. this.element.classList.remove('focus');
  35103. this.emit('blur');
  35104. };
  35105. Terminal.prototype.initGlobal = function () {
  35106. var _this = this;
  35107. this.bindKeys();
  35108. on(this.element, 'copy', function (event) {
  35109. if (!_this.hasSelection()) {
  35110. return;
  35111. }
  35112. Clipboard_1.copyHandler(event, _this, _this.selectionManager);
  35113. });
  35114. var pasteHandlerWrapper = function (event) { return Clipboard_1.pasteHandler(event, _this); };
  35115. on(this.textarea, 'paste', pasteHandlerWrapper);
  35116. on(this.element, 'paste', pasteHandlerWrapper);
  35117. if (Browser.isFirefox) {
  35118. on(this.element, 'mousedown', function (event) {
  35119. if (event.button === 2) {
  35120. Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager, _this.options.rightClickSelectsWord);
  35121. }
  35122. });
  35123. }
  35124. else {
  35125. on(this.element, 'contextmenu', function (event) {
  35126. Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager, _this.options.rightClickSelectsWord);
  35127. });
  35128. }
  35129. if (Browser.isLinux) {
  35130. on(this.element, 'auxclick', function (event) {
  35131. if (event.button === 1) {
  35132. Clipboard_1.moveTextAreaUnderMouseCursor(event, _this.textarea);
  35133. }
  35134. });
  35135. }
  35136. };
  35137. Terminal.prototype.bindKeys = function () {
  35138. var _this = this;
  35139. var self = this;
  35140. on(this.element, 'keydown', function (ev) {
  35141. if (document.activeElement !== this) {
  35142. return;
  35143. }
  35144. self._keyDown(ev);
  35145. }, true);
  35146. on(this.element, 'keypress', function (ev) {
  35147. if (document.activeElement !== this) {
  35148. return;
  35149. }
  35150. self._keyPress(ev);
  35151. }, true);
  35152. on(this.element, 'keyup', function (ev) {
  35153. if (!wasMondifierKeyOnlyEvent(ev)) {
  35154. _this.focus();
  35155. }
  35156. }, true);
  35157. on(this.textarea, 'keydown', function (ev) {
  35158. _this._keyDown(ev);
  35159. }, true);
  35160. on(this.textarea, 'keypress', function (ev) {
  35161. _this._keyPress(ev);
  35162. _this.textarea.value = '';
  35163. }, true);
  35164. on(this.textarea, 'compositionstart', function () { return _this.compositionHelper.compositionstart(); });
  35165. on(this.textarea, 'compositionupdate', function (e) { return _this.compositionHelper.compositionupdate(e); });
  35166. on(this.textarea, 'compositionend', function () { return _this.compositionHelper.compositionend(); });
  35167. this.on('refresh', function () { return _this.compositionHelper.updateCompositionElements(); });
  35168. this.on('refresh', function (data) { return _this.queueLinkification(data.start, data.end); });
  35169. };
  35170. Terminal.prototype.open = function (parent) {
  35171. var _this = this;
  35172. var i = 0;
  35173. var div;
  35174. this.parent = parent || this.parent;
  35175. if (!this.parent) {
  35176. throw new Error('Terminal requires a parent element.');
  35177. }
  35178. this.context = this.parent.ownerDocument.defaultView;
  35179. this.document = this.parent.ownerDocument;
  35180. this.body = this.document.body;
  35181. this.element = this.document.createElement('div');
  35182. this.element.classList.add('terminal');
  35183. this.element.classList.add('xterm');
  35184. this.element.setAttribute('tabindex', '0');
  35185. this.parent.appendChild(this.element);
  35186. var fragment = document.createDocumentFragment();
  35187. this.viewportElement = document.createElement('div');
  35188. this.viewportElement.classList.add('xterm-viewport');
  35189. fragment.appendChild(this.viewportElement);
  35190. this.viewportScrollArea = document.createElement('div');
  35191. this.viewportScrollArea.classList.add('xterm-scroll-area');
  35192. this.viewportElement.appendChild(this.viewportScrollArea);
  35193. this.screenElement = document.createElement('div');
  35194. this.screenElement.classList.add('xterm-screen');
  35195. this.helperContainer = document.createElement('div');
  35196. this.helperContainer.classList.add('xterm-helpers');
  35197. this.screenElement.appendChild(this.helperContainer);
  35198. fragment.appendChild(this.screenElement);
  35199. this._mouseZoneManager = new MouseZoneManager_1.MouseZoneManager(this);
  35200. this.on('scroll', function () { return _this._mouseZoneManager.clearAll(); });
  35201. this.linkifier.attachToDom(this._mouseZoneManager);
  35202. this.textarea = document.createElement('textarea');
  35203. this.textarea.classList.add('xterm-helper-textarea');
  35204. this.textarea.setAttribute('autocorrect', 'off');
  35205. this.textarea.setAttribute('autocapitalize', 'off');
  35206. this.textarea.setAttribute('spellcheck', 'false');
  35207. this.textarea.tabIndex = 0;
  35208. this.textarea.addEventListener('focus', function () { return _this._onTextAreaFocus(); });
  35209. this.textarea.addEventListener('blur', function () { return _this._onTextAreaBlur(); });
  35210. this.helperContainer.appendChild(this.textarea);
  35211. this.compositionView = document.createElement('div');
  35212. this.compositionView.classList.add('composition-view');
  35213. this.compositionHelper = new CompositionHelper_1.CompositionHelper(this.textarea, this.compositionView, this);
  35214. this.helperContainer.appendChild(this.compositionView);
  35215. this.charSizeStyleElement = document.createElement('style');
  35216. this.helperContainer.appendChild(this.charSizeStyleElement);
  35217. this.charMeasure = new CharMeasure_1.CharMeasure(document, this.helperContainer);
  35218. this.syncBellSound();
  35219. this.element.appendChild(fragment);
  35220. this.renderer = new Renderer_1.Renderer(this, this.options.theme);
  35221. this.options.theme = null;
  35222. this.viewport = new Viewport_1.Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
  35223. this.viewport.onThemeChanged(this.renderer.colorManager.colors);
  35224. this.on('cursormove', function () { return _this.renderer.onCursorMove(); });
  35225. this.on('resize', function () { return _this.renderer.onResize(_this.cols, _this.rows, false); });
  35226. this.on('blur', function () { return _this.renderer.onBlur(); });
  35227. this.on('focus', function () { return _this.renderer.onFocus(); });
  35228. this.charMeasure.on('charsizechanged', function () { return _this.renderer.onResize(_this.cols, _this.rows, true); });
  35229. this.renderer.on('resize', function (dimensions) { return _this.viewport.syncScrollArea(); });
  35230. this.selectionManager = new SelectionManager_1.SelectionManager(this, this.charMeasure);
  35231. this.element.addEventListener('mousedown', function (e) { return _this.selectionManager.onMouseDown(e); });
  35232. this.selectionManager.on('refresh', function (data) { return _this.renderer.onSelectionChanged(data.start, data.end); });
  35233. this.selectionManager.on('newselection', function (text) {
  35234. _this.textarea.value = text;
  35235. _this.textarea.focus();
  35236. _this.textarea.select();
  35237. });
  35238. this.on('scroll', function () {
  35239. _this.viewport.syncScrollArea();
  35240. _this.selectionManager.refresh();
  35241. });
  35242. this.viewportElement.addEventListener('scroll', function () { return _this.selectionManager.refresh(); });
  35243. this.mouseHelper = new MouseHelper_1.MouseHelper(this.renderer);
  35244. this.charMeasure.measure(this.options);
  35245. this.refresh(0, this.rows - 1);
  35246. this.initGlobal();
  35247. this.bindMouse();
  35248. };
  35249. Terminal.prototype._setTheme = function (theme) {
  35250. var colors = this.renderer.setTheme(theme);
  35251. if (this.viewport) {
  35252. this.viewport.onThemeChanged(colors);
  35253. }
  35254. };
  35255. Terminal.applyAddon = function (addon) {
  35256. addon.apply(Terminal);
  35257. };
  35258. Terminal.prototype.bindMouse = function () {
  35259. var _this = this;
  35260. var el = this.element;
  35261. var self = this;
  35262. var pressed = 32;
  35263. function sendButton(ev) {
  35264. var button;
  35265. var pos;
  35266. button = getButton(ev);
  35267. pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
  35268. if (!pos)
  35269. return;
  35270. sendEvent(button, pos);
  35271. switch (ev.overrideType || ev.type) {
  35272. case 'mousedown':
  35273. pressed = button;
  35274. break;
  35275. case 'mouseup':
  35276. pressed = 32;
  35277. break;
  35278. case 'wheel':
  35279. break;
  35280. }
  35281. }
  35282. function sendMove(ev) {
  35283. var button = pressed;
  35284. var pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.options.lineHeight, self.cols, self.rows);
  35285. if (!pos)
  35286. return;
  35287. button += 32;
  35288. sendEvent(button, pos);
  35289. }
  35290. function encode(data, ch) {
  35291. if (!self.utfMouse) {
  35292. if (ch === 255) {
  35293. data.push(0);
  35294. return;
  35295. }
  35296. if (ch > 127)
  35297. ch = 127;
  35298. data.push(ch);
  35299. }
  35300. else {
  35301. if (ch === 2047) {
  35302. data.push(0);
  35303. return;
  35304. }
  35305. if (ch < 127) {
  35306. data.push(ch);
  35307. }
  35308. else {
  35309. if (ch > 2047)
  35310. ch = 2047;
  35311. data.push(0xC0 | (ch >> 6));
  35312. data.push(0x80 | (ch & 0x3F));
  35313. }
  35314. }
  35315. }
  35316. function sendEvent(button, pos) {
  35317. if (self.vt300Mouse) {
  35318. button &= 3;
  35319. pos.x -= 32;
  35320. pos.y -= 32;
  35321. var data_1 = EscapeSequences_1.C0.ESC + '[24';
  35322. if (button === 0)
  35323. data_1 += '1';
  35324. else if (button === 1)
  35325. data_1 += '3';
  35326. else if (button === 2)
  35327. data_1 += '5';
  35328. else if (button === 3)
  35329. return;
  35330. else
  35331. data_1 += '0';
  35332. data_1 += '~[' + pos.x + ',' + pos.y + ']\r';
  35333. self.send(data_1);
  35334. return;
  35335. }
  35336. if (self.decLocator) {
  35337. button &= 3;
  35338. pos.x -= 32;
  35339. pos.y -= 32;
  35340. if (button === 0)
  35341. button = 2;
  35342. else if (button === 1)
  35343. button = 4;
  35344. else if (button === 2)
  35345. button = 6;
  35346. else if (button === 3)
  35347. button = 3;
  35348. self.send(EscapeSequences_1.C0.ESC + '['
  35349. + button
  35350. + ';'
  35351. + (button === 3 ? 4 : 0)
  35352. + ';'
  35353. + pos.y
  35354. + ';'
  35355. + pos.x
  35356. + ';'
  35357. + pos.page || 0
  35358. + '&w');
  35359. return;
  35360. }
  35361. if (self.urxvtMouse) {
  35362. pos.x -= 32;
  35363. pos.y -= 32;
  35364. pos.x++;
  35365. pos.y++;
  35366. self.send(EscapeSequences_1.C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');
  35367. return;
  35368. }
  35369. if (self.sgrMouse) {
  35370. pos.x -= 32;
  35371. pos.y -= 32;
  35372. self.send(EscapeSequences_1.C0.ESC + '[<'
  35373. + (((button & 3) === 3 ? button & ~3 : button) - 32)
  35374. + ';'
  35375. + pos.x
  35376. + ';'
  35377. + pos.y
  35378. + ((button & 3) === 3 ? 'm' : 'M'));
  35379. return;
  35380. }
  35381. var data = [];
  35382. encode(data, button);
  35383. encode(data, pos.x);
  35384. encode(data, pos.y);
  35385. self.send(EscapeSequences_1.C0.ESC + '[M' + String.fromCharCode.apply(String, data));
  35386. }
  35387. function getButton(ev) {
  35388. var button;
  35389. var shift;
  35390. var meta;
  35391. var ctrl;
  35392. var mod;
  35393. switch (ev.overrideType || ev.type) {
  35394. case 'mousedown':
  35395. button = ev.button != null
  35396. ? +ev.button
  35397. : ev.which != null
  35398. ? ev.which - 1
  35399. : null;
  35400. if (Browser.isMSIE) {
  35401. button = button === 1 ? 0 : button === 4 ? 1 : button;
  35402. }
  35403. break;
  35404. case 'mouseup':
  35405. button = 3;
  35406. break;
  35407. case 'DOMMouseScroll':
  35408. button = ev.detail < 0
  35409. ? 64
  35410. : 65;
  35411. break;
  35412. case 'wheel':
  35413. button = ev.wheelDeltaY > 0
  35414. ? 64
  35415. : 65;
  35416. break;
  35417. }
  35418. shift = ev.shiftKey ? 4 : 0;
  35419. meta = ev.metaKey ? 8 : 0;
  35420. ctrl = ev.ctrlKey ? 16 : 0;
  35421. mod = shift | meta | ctrl;
  35422. if (self.vt200Mouse) {
  35423. mod &= ctrl;
  35424. }
  35425. else if (!self.normalMouse) {
  35426. mod = 0;
  35427. }
  35428. button = (32 + (mod << 2)) + button;
  35429. return button;
  35430. }
  35431. on(el, 'mousedown', function (ev) {
  35432. ev.preventDefault();
  35433. _this.focus();
  35434. if (!_this.mouseEvents || _this.selectionManager.shouldForceSelection(ev)) {
  35435. return;
  35436. }
  35437. sendButton(ev);
  35438. if (_this.vt200Mouse) {
  35439. ev.overrideType = 'mouseup';
  35440. sendButton(ev);
  35441. return _this.cancel(ev);
  35442. }
  35443. if (_this.normalMouse)
  35444. on(_this.document, 'mousemove', sendMove);
  35445. if (!_this.x10Mouse) {
  35446. var handler_1 = function (ev) {
  35447. sendButton(ev);
  35448. if (_this.normalMouse)
  35449. off(_this.document, 'mousemove', sendMove);
  35450. off(_this.document, 'mouseup', handler_1);
  35451. return _this.cancel(ev);
  35452. };
  35453. on(_this.document, 'mouseup', handler_1);
  35454. }
  35455. return _this.cancel(ev);
  35456. });
  35457. on(el, 'wheel', function (ev) {
  35458. if (!_this.mouseEvents)
  35459. return;
  35460. if (_this.x10Mouse || _this.vt300Mouse || _this.decLocator)
  35461. return;
  35462. sendButton(ev);
  35463. ev.preventDefault();
  35464. });
  35465. on(el, 'wheel', function (ev) {
  35466. if (_this.mouseEvents)
  35467. return;
  35468. _this.viewport.onWheel(ev);
  35469. return _this.cancel(ev);
  35470. });
  35471. on(el, 'touchstart', function (ev) {
  35472. if (_this.mouseEvents)
  35473. return;
  35474. _this.viewport.onTouchStart(ev);
  35475. return _this.cancel(ev);
  35476. });
  35477. on(el, 'touchmove', function (ev) {
  35478. if (_this.mouseEvents)
  35479. return;
  35480. _this.viewport.onTouchMove(ev);
  35481. return _this.cancel(ev);
  35482. });
  35483. };
  35484. Terminal.prototype.destroy = function () {
  35485. _super.prototype.destroy.call(this);
  35486. this.readable = false;
  35487. this.writable = false;
  35488. this.handler = function () { };
  35489. this.write = function () { };
  35490. if (this.element && this.element.parentNode) {
  35491. this.element.parentNode.removeChild(this.element);
  35492. }
  35493. };
  35494. Terminal.prototype.refresh = function (start, end) {
  35495. if (this.renderer) {
  35496. this.renderer.queueRefresh(start, end);
  35497. }
  35498. };
  35499. Terminal.prototype.queueLinkification = function (start, end) {
  35500. if (this.linkifier) {
  35501. this.linkifier.linkifyRows(start, end);
  35502. }
  35503. };
  35504. Terminal.prototype.showCursor = function () {
  35505. if (!this.cursorState) {
  35506. this.cursorState = 1;
  35507. this.refresh(this.buffer.y, this.buffer.y);
  35508. }
  35509. };
  35510. Terminal.prototype.scroll = function (isWrapped) {
  35511. var newLine = this.blankLine(undefined, isWrapped);
  35512. var topRow = this.buffer.ybase + this.buffer.scrollTop;
  35513. var bottomRow = this.buffer.ybase + this.buffer.scrollBottom;
  35514. if (this.buffer.scrollTop === 0) {
  35515. var willBufferBeTrimmed = this.buffer.lines.length === this.buffer.lines.maxLength;
  35516. if (bottomRow === this.buffer.lines.length - 1) {
  35517. this.buffer.lines.push(newLine);
  35518. }
  35519. else {
  35520. this.buffer.lines.splice(bottomRow + 1, 0, newLine);
  35521. }
  35522. if (!willBufferBeTrimmed) {
  35523. this.buffer.ybase++;
  35524. if (!this.userScrolling) {
  35525. this.buffer.ydisp++;
  35526. }
  35527. }
  35528. else {
  35529. if (this.userScrolling) {
  35530. this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);
  35531. }
  35532. }
  35533. }
  35534. else {
  35535. var scrollRegionHeight = bottomRow - topRow + 1;
  35536. this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
  35537. this.buffer.lines.set(bottomRow, newLine);
  35538. }
  35539. if (!this.userScrolling) {
  35540. this.buffer.ydisp = this.buffer.ybase;
  35541. }
  35542. this.updateRange(this.buffer.scrollTop);
  35543. this.updateRange(this.buffer.scrollBottom);
  35544. this.emit('scroll', this.buffer.ydisp);
  35545. };
  35546. Terminal.prototype.scrollLines = function (disp, suppressScrollEvent) {
  35547. if (disp < 0) {
  35548. if (this.buffer.ydisp === 0) {
  35549. return;
  35550. }
  35551. this.userScrolling = true;
  35552. }
  35553. else if (disp + this.buffer.ydisp >= this.buffer.ybase) {
  35554. this.userScrolling = false;
  35555. }
  35556. var oldYdisp = this.buffer.ydisp;
  35557. this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);
  35558. if (oldYdisp === this.buffer.ydisp) {
  35559. return;
  35560. }
  35561. if (!suppressScrollEvent) {
  35562. this.emit('scroll', this.buffer.ydisp);
  35563. }
  35564. this.refresh(0, this.rows - 1);
  35565. };
  35566. Terminal.prototype.scrollPages = function (pageCount) {
  35567. this.scrollLines(pageCount * (this.rows - 1));
  35568. };
  35569. Terminal.prototype.scrollToTop = function () {
  35570. this.scrollLines(-this.buffer.ydisp);
  35571. };
  35572. Terminal.prototype.scrollToBottom = function () {
  35573. this.scrollLines(this.buffer.ybase - this.buffer.ydisp);
  35574. };
  35575. Terminal.prototype.write = function (data) {
  35576. var _this = this;
  35577. this.writeBuffer.push(data);
  35578. if (this.options.useFlowControl && !this.xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
  35579. this.send(EscapeSequences_1.C0.DC3);
  35580. this.xoffSentToCatchUp = true;
  35581. }
  35582. if (!this.writeInProgress && this.writeBuffer.length > 0) {
  35583. this.writeInProgress = true;
  35584. setTimeout(function () {
  35585. _this.innerWrite();
  35586. });
  35587. }
  35588. };
  35589. Terminal.prototype.innerWrite = function () {
  35590. var _this = this;
  35591. var writeBatch = this.writeBuffer.splice(0, WRITE_BATCH_SIZE);
  35592. while (writeBatch.length > 0) {
  35593. var data = writeBatch.shift();
  35594. if (this.xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
  35595. this.send(EscapeSequences_1.C0.DC1);
  35596. this.xoffSentToCatchUp = false;
  35597. }
  35598. this.refreshStart = this.buffer.y;
  35599. this.refreshEnd = this.buffer.y;
  35600. var state = this.parser.parse(data);
  35601. this.parser.setState(state);
  35602. this.updateRange(this.buffer.y);
  35603. this.refresh(this.refreshStart, this.refreshEnd);
  35604. }
  35605. if (this.writeBuffer.length > 0) {
  35606. setTimeout(function () { return _this.innerWrite(); }, 0);
  35607. }
  35608. else {
  35609. this.writeInProgress = false;
  35610. }
  35611. };
  35612. Terminal.prototype.writeln = function (data) {
  35613. this.write(data + '\r\n');
  35614. };
  35615. Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {
  35616. this.customKeyEventHandler = customKeyEventHandler;
  35617. };
  35618. Terminal.prototype.setHypertextLinkHandler = function (handler) {
  35619. if (!this.linkifier) {
  35620. throw new Error('Cannot attach a hypertext link handler before Terminal.open is called');
  35621. }
  35622. this.linkifier.setHypertextLinkHandler(handler);
  35623. this.refresh(0, this.rows - 1);
  35624. };
  35625. Terminal.prototype.setHypertextValidationCallback = function (callback) {
  35626. if (!this.linkifier) {
  35627. throw new Error('Cannot attach a hypertext validation callback before Terminal.open is called');
  35628. }
  35629. this.linkifier.setHypertextValidationCallback(callback);
  35630. this.refresh(0, this.rows - 1);
  35631. };
  35632. Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {
  35633. if (this.linkifier) {
  35634. var matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);
  35635. this.refresh(0, this.rows - 1);
  35636. return matcherId;
  35637. }
  35638. return 0;
  35639. };
  35640. Terminal.prototype.deregisterLinkMatcher = function (matcherId) {
  35641. if (this.linkifier) {
  35642. if (this.linkifier.deregisterLinkMatcher(matcherId)) {
  35643. this.refresh(0, this.rows - 1);
  35644. }
  35645. }
  35646. };
  35647. Terminal.prototype.hasSelection = function () {
  35648. return this.selectionManager ? this.selectionManager.hasSelection : false;
  35649. };
  35650. Terminal.prototype.getSelection = function () {
  35651. return this.selectionManager ? this.selectionManager.selectionText : '';
  35652. };
  35653. Terminal.prototype.clearSelection = function () {
  35654. if (this.selectionManager) {
  35655. this.selectionManager.clearSelection();
  35656. }
  35657. };
  35658. Terminal.prototype.selectAll = function () {
  35659. if (this.selectionManager) {
  35660. this.selectionManager.selectAll();
  35661. }
  35662. };
  35663. Terminal.prototype._keyDown = function (ev) {
  35664. if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {
  35665. return false;
  35666. }
  35667. if (!this.compositionHelper.keydown(ev)) {
  35668. if (this.buffer.ybase !== this.buffer.ydisp) {
  35669. this.scrollToBottom();
  35670. }
  35671. return false;
  35672. }
  35673. var result = this._evaluateKeyEscapeSequence(ev);
  35674. if (result.key === EscapeSequences_1.C0.DC3) {
  35675. this.writeStopped = true;
  35676. }
  35677. else if (result.key === EscapeSequences_1.C0.DC1) {
  35678. this.writeStopped = false;
  35679. }
  35680. if (result.scrollLines) {
  35681. this.scrollLines(result.scrollLines);
  35682. return this.cancel(ev, true);
  35683. }
  35684. if (this._isThirdLevelShift(this.browser, ev)) {
  35685. return true;
  35686. }
  35687. if (result.cancel) {
  35688. this.cancel(ev, true);
  35689. }
  35690. if (!result.key) {
  35691. return true;
  35692. }
  35693. this.emit('keydown', ev);
  35694. this.emit('key', result.key, ev);
  35695. this.showCursor();
  35696. this.handler(result.key);
  35697. return this.cancel(ev, true);
  35698. };
  35699. Terminal.prototype._isThirdLevelShift = function (browser, ev) {
  35700. var thirdLevelKey = (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||
  35701. (browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);
  35702. if (ev.type === 'keypress') {
  35703. return thirdLevelKey;
  35704. }
  35705. return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);
  35706. };
  35707. Terminal.prototype._evaluateKeyEscapeSequence = function (ev) {
  35708. var result = {
  35709. cancel: false,
  35710. key: undefined,
  35711. scrollLines: undefined
  35712. };
  35713. var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);
  35714. switch (ev.keyCode) {
  35715. case 0:
  35716. if (ev.key === 'UIKeyInputUpArrow') {
  35717. if (this.applicationCursor) {
  35718. result.key = EscapeSequences_1.C0.ESC + 'OA';
  35719. }
  35720. else {
  35721. result.key = EscapeSequences_1.C0.ESC + '[A';
  35722. }
  35723. }
  35724. else if (ev.key === 'UIKeyInputLeftArrow') {
  35725. if (this.applicationCursor) {
  35726. result.key = EscapeSequences_1.C0.ESC + 'OD';
  35727. }
  35728. else {
  35729. result.key = EscapeSequences_1.C0.ESC + '[D';
  35730. }
  35731. }
  35732. else if (ev.key === 'UIKeyInputRightArrow') {
  35733. if (this.applicationCursor) {
  35734. result.key = EscapeSequences_1.C0.ESC + 'OC';
  35735. }
  35736. else {
  35737. result.key = EscapeSequences_1.C0.ESC + '[C';
  35738. }
  35739. }
  35740. else if (ev.key === 'UIKeyInputDownArrow') {
  35741. if (this.applicationCursor) {
  35742. result.key = EscapeSequences_1.C0.ESC + 'OB';
  35743. }
  35744. else {
  35745. result.key = EscapeSequences_1.C0.ESC + '[B';
  35746. }
  35747. }
  35748. break;
  35749. case 8:
  35750. if (ev.shiftKey) {
  35751. result.key = EscapeSequences_1.C0.BS;
  35752. break;
  35753. }
  35754. else if (ev.altKey) {
  35755. result.key = EscapeSequences_1.C0.ESC + EscapeSequences_1.C0.DEL;
  35756. break;
  35757. }
  35758. result.key = EscapeSequences_1.C0.DEL;
  35759. break;
  35760. case 9:
  35761. if (ev.shiftKey) {
  35762. result.key = EscapeSequences_1.C0.ESC + '[Z';
  35763. break;
  35764. }
  35765. result.key = EscapeSequences_1.C0.HT;
  35766. result.cancel = true;
  35767. break;
  35768. case 13:
  35769. result.key = EscapeSequences_1.C0.CR;
  35770. result.cancel = true;
  35771. break;
  35772. case 27:
  35773. result.key = EscapeSequences_1.C0.ESC;
  35774. result.cancel = true;
  35775. break;
  35776. case 37:
  35777. if (modifiers) {
  35778. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'D';
  35779. if (result.key === EscapeSequences_1.C0.ESC + '[1;3D') {
  35780. result.key = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'b' : EscapeSequences_1.C0.ESC + '[1;5D';
  35781. }
  35782. }
  35783. else if (this.applicationCursor) {
  35784. result.key = EscapeSequences_1.C0.ESC + 'OD';
  35785. }
  35786. else {
  35787. result.key = EscapeSequences_1.C0.ESC + '[D';
  35788. }
  35789. break;
  35790. case 39:
  35791. if (modifiers) {
  35792. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'C';
  35793. if (result.key === EscapeSequences_1.C0.ESC + '[1;3C') {
  35794. result.key = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'f' : EscapeSequences_1.C0.ESC + '[1;5C';
  35795. }
  35796. }
  35797. else if (this.applicationCursor) {
  35798. result.key = EscapeSequences_1.C0.ESC + 'OC';
  35799. }
  35800. else {
  35801. result.key = EscapeSequences_1.C0.ESC + '[C';
  35802. }
  35803. break;
  35804. case 38:
  35805. if (modifiers) {
  35806. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'A';
  35807. if (result.key === EscapeSequences_1.C0.ESC + '[1;3A') {
  35808. result.key = EscapeSequences_1.C0.ESC + '[1;5A';
  35809. }
  35810. }
  35811. else if (this.applicationCursor) {
  35812. result.key = EscapeSequences_1.C0.ESC + 'OA';
  35813. }
  35814. else {
  35815. result.key = EscapeSequences_1.C0.ESC + '[A';
  35816. }
  35817. break;
  35818. case 40:
  35819. if (modifiers) {
  35820. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'B';
  35821. if (result.key === EscapeSequences_1.C0.ESC + '[1;3B') {
  35822. result.key = EscapeSequences_1.C0.ESC + '[1;5B';
  35823. }
  35824. }
  35825. else if (this.applicationCursor) {
  35826. result.key = EscapeSequences_1.C0.ESC + 'OB';
  35827. }
  35828. else {
  35829. result.key = EscapeSequences_1.C0.ESC + '[B';
  35830. }
  35831. break;
  35832. case 45:
  35833. if (!ev.shiftKey && !ev.ctrlKey) {
  35834. result.key = EscapeSequences_1.C0.ESC + '[2~';
  35835. }
  35836. break;
  35837. case 46:
  35838. if (modifiers) {
  35839. result.key = EscapeSequences_1.C0.ESC + '[3;' + (modifiers + 1) + '~';
  35840. }
  35841. else {
  35842. result.key = EscapeSequences_1.C0.ESC + '[3~';
  35843. }
  35844. break;
  35845. case 36:
  35846. if (modifiers) {
  35847. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'H';
  35848. }
  35849. else if (this.applicationCursor) {
  35850. result.key = EscapeSequences_1.C0.ESC + 'OH';
  35851. }
  35852. else {
  35853. result.key = EscapeSequences_1.C0.ESC + '[H';
  35854. }
  35855. break;
  35856. case 35:
  35857. if (modifiers) {
  35858. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'F';
  35859. }
  35860. else if (this.applicationCursor) {
  35861. result.key = EscapeSequences_1.C0.ESC + 'OF';
  35862. }
  35863. else {
  35864. result.key = EscapeSequences_1.C0.ESC + '[F';
  35865. }
  35866. break;
  35867. case 33:
  35868. if (ev.shiftKey) {
  35869. result.scrollLines = -(this.rows - 1);
  35870. }
  35871. else {
  35872. result.key = EscapeSequences_1.C0.ESC + '[5~';
  35873. }
  35874. break;
  35875. case 34:
  35876. if (ev.shiftKey) {
  35877. result.scrollLines = this.rows - 1;
  35878. }
  35879. else {
  35880. result.key = EscapeSequences_1.C0.ESC + '[6~';
  35881. }
  35882. break;
  35883. case 112:
  35884. if (modifiers) {
  35885. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'P';
  35886. }
  35887. else {
  35888. result.key = EscapeSequences_1.C0.ESC + 'OP';
  35889. }
  35890. break;
  35891. case 113:
  35892. if (modifiers) {
  35893. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'Q';
  35894. }
  35895. else {
  35896. result.key = EscapeSequences_1.C0.ESC + 'OQ';
  35897. }
  35898. break;
  35899. case 114:
  35900. if (modifiers) {
  35901. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'R';
  35902. }
  35903. else {
  35904. result.key = EscapeSequences_1.C0.ESC + 'OR';
  35905. }
  35906. break;
  35907. case 115:
  35908. if (modifiers) {
  35909. result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'S';
  35910. }
  35911. else {
  35912. result.key = EscapeSequences_1.C0.ESC + 'OS';
  35913. }
  35914. break;
  35915. case 116:
  35916. if (modifiers) {
  35917. result.key = EscapeSequences_1.C0.ESC + '[15;' + (modifiers + 1) + '~';
  35918. }
  35919. else {
  35920. result.key = EscapeSequences_1.C0.ESC + '[15~';
  35921. }
  35922. break;
  35923. case 117:
  35924. if (modifiers) {
  35925. result.key = EscapeSequences_1.C0.ESC + '[17;' + (modifiers + 1) + '~';
  35926. }
  35927. else {
  35928. result.key = EscapeSequences_1.C0.ESC + '[17~';
  35929. }
  35930. break;
  35931. case 118:
  35932. if (modifiers) {
  35933. result.key = EscapeSequences_1.C0.ESC + '[18;' + (modifiers + 1) + '~';
  35934. }
  35935. else {
  35936. result.key = EscapeSequences_1.C0.ESC + '[18~';
  35937. }
  35938. break;
  35939. case 119:
  35940. if (modifiers) {
  35941. result.key = EscapeSequences_1.C0.ESC + '[19;' + (modifiers + 1) + '~';
  35942. }
  35943. else {
  35944. result.key = EscapeSequences_1.C0.ESC + '[19~';
  35945. }
  35946. break;
  35947. case 120:
  35948. if (modifiers) {
  35949. result.key = EscapeSequences_1.C0.ESC + '[20;' + (modifiers + 1) + '~';
  35950. }
  35951. else {
  35952. result.key = EscapeSequences_1.C0.ESC + '[20~';
  35953. }
  35954. break;
  35955. case 121:
  35956. if (modifiers) {
  35957. result.key = EscapeSequences_1.C0.ESC + '[21;' + (modifiers + 1) + '~';
  35958. }
  35959. else {
  35960. result.key = EscapeSequences_1.C0.ESC + '[21~';
  35961. }
  35962. break;
  35963. case 122:
  35964. if (modifiers) {
  35965. result.key = EscapeSequences_1.C0.ESC + '[23;' + (modifiers + 1) + '~';
  35966. }
  35967. else {
  35968. result.key = EscapeSequences_1.C0.ESC + '[23~';
  35969. }
  35970. break;
  35971. case 123:
  35972. if (modifiers) {
  35973. result.key = EscapeSequences_1.C0.ESC + '[24;' + (modifiers + 1) + '~';
  35974. }
  35975. else {
  35976. result.key = EscapeSequences_1.C0.ESC + '[24~';
  35977. }
  35978. break;
  35979. default:
  35980. if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
  35981. if (ev.keyCode >= 65 && ev.keyCode <= 90) {
  35982. result.key = String.fromCharCode(ev.keyCode - 64);
  35983. }
  35984. else if (ev.keyCode === 32) {
  35985. result.key = String.fromCharCode(0);
  35986. }
  35987. else if (ev.keyCode >= 51 && ev.keyCode <= 55) {
  35988. result.key = String.fromCharCode(ev.keyCode - 51 + 27);
  35989. }
  35990. else if (ev.keyCode === 56) {
  35991. result.key = String.fromCharCode(127);
  35992. }
  35993. else if (ev.keyCode === 219) {
  35994. result.key = String.fromCharCode(27);
  35995. }
  35996. else if (ev.keyCode === 220) {
  35997. result.key = String.fromCharCode(28);
  35998. }
  35999. else if (ev.keyCode === 221) {
  36000. result.key = String.fromCharCode(29);
  36001. }
  36002. }
  36003. else if ((!this.browser.isMac || this.options.macOptionIsMeta) && ev.altKey && !ev.ctrlKey && !ev.metaKey) {
  36004. if (ev.keyCode >= 65 && ev.keyCode <= 90) {
  36005. result.key = EscapeSequences_1.C0.ESC + String.fromCharCode(ev.keyCode + 32);
  36006. }
  36007. else if (ev.keyCode === 192) {
  36008. result.key = EscapeSequences_1.C0.ESC + '`';
  36009. }
  36010. else if (ev.keyCode >= 48 && ev.keyCode <= 57) {
  36011. result.key = EscapeSequences_1.C0.ESC + (ev.keyCode - 48);
  36012. }
  36013. }
  36014. else if (this.browser.isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {
  36015. if (ev.keyCode === 65) {
  36016. this.selectAll();
  36017. }
  36018. }
  36019. break;
  36020. }
  36021. return result;
  36022. };
  36023. Terminal.prototype.setgLevel = function (g) {
  36024. this.glevel = g;
  36025. this.charset = this.charsets[g];
  36026. };
  36027. Terminal.prototype.setgCharset = function (g, charset) {
  36028. this.charsets[g] = charset;
  36029. if (this.glevel === g) {
  36030. this.charset = charset;
  36031. }
  36032. };
  36033. Terminal.prototype._keyPress = function (ev) {
  36034. var key;
  36035. if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {
  36036. return false;
  36037. }
  36038. this.cancel(ev);
  36039. if (ev.charCode) {
  36040. key = ev.charCode;
  36041. }
  36042. else if (ev.which == null) {
  36043. key = ev.keyCode;
  36044. }
  36045. else if (ev.which !== 0 && ev.charCode !== 0) {
  36046. key = ev.which;
  36047. }
  36048. else {
  36049. return false;
  36050. }
  36051. if (!key || ((ev.altKey || ev.ctrlKey || ev.metaKey) && !this._isThirdLevelShift(this.browser, ev))) {
  36052. return false;
  36053. }
  36054. key = String.fromCharCode(key);
  36055. this.emit('keypress', key, ev);
  36056. this.emit('key', key, ev);
  36057. this.showCursor();
  36058. this.handler(key);
  36059. return true;
  36060. };
  36061. Terminal.prototype.send = function (data) {
  36062. var _this = this;
  36063. if (!this.sendDataQueue) {
  36064. setTimeout(function () {
  36065. _this.handler(_this.sendDataQueue);
  36066. _this.sendDataQueue = '';
  36067. }, 1);
  36068. }
  36069. this.sendDataQueue += data;
  36070. };
  36071. Terminal.prototype.bell = function () {
  36072. var _this = this;
  36073. this.emit('bell');
  36074. if (this.soundBell())
  36075. this.bellAudioElement.play();
  36076. if (this.visualBell()) {
  36077. this.element.classList.add('visual-bell-active');
  36078. clearTimeout(this.visualBellTimer);
  36079. this.visualBellTimer = window.setTimeout(function () {
  36080. _this.element.classList.remove('visual-bell-active');
  36081. }, 200);
  36082. }
  36083. };
  36084. Terminal.prototype.log = function (text, data) {
  36085. if (!this.options.debug)
  36086. return;
  36087. if (!this.context.console || !this.context.console.log)
  36088. return;
  36089. this.context.console.log(text, data);
  36090. };
  36091. Terminal.prototype.error = function (text, data) {
  36092. if (!this.options.debug)
  36093. return;
  36094. if (!this.context.console || !this.context.console.error)
  36095. return;
  36096. this.context.console.error(text, data);
  36097. };
  36098. Terminal.prototype.resize = function (x, y) {
  36099. if (isNaN(x) || isNaN(y)) {
  36100. return;
  36101. }
  36102. if (x === this.cols && y === this.rows) {
  36103. if (!this.charMeasure.width || !this.charMeasure.height) {
  36104. this.charMeasure.measure(this.options);
  36105. }
  36106. return;
  36107. }
  36108. if (x < 1)
  36109. x = 1;
  36110. if (y < 1)
  36111. y = 1;
  36112. this.buffers.resize(x, y);
  36113. this.cols = x;
  36114. this.rows = y;
  36115. this.buffers.setupTabStops(this.cols);
  36116. this.charMeasure.measure(this.options);
  36117. this.refresh(0, this.rows - 1);
  36118. this.emit('resize', { cols: x, rows: y });
  36119. };
  36120. Terminal.prototype.updateRange = function (y) {
  36121. if (y < this.refreshStart)
  36122. this.refreshStart = y;
  36123. if (y > this.refreshEnd)
  36124. this.refreshEnd = y;
  36125. };
  36126. Terminal.prototype.maxRange = function () {
  36127. this.refreshStart = 0;
  36128. this.refreshEnd = this.rows - 1;
  36129. };
  36130. Terminal.prototype.eraseRight = function (x, y) {
  36131. var line = this.buffer.lines.get(this.buffer.ybase + y);
  36132. if (!line) {
  36133. return;
  36134. }
  36135. var ch = [this.eraseAttr(), ' ', 1, 32];
  36136. for (; x < this.cols; x++) {
  36137. line[x] = ch;
  36138. }
  36139. this.updateRange(y);
  36140. };
  36141. Terminal.prototype.eraseLeft = function (x, y) {
  36142. var line = this.buffer.lines.get(this.buffer.ybase + y);
  36143. if (!line) {
  36144. return;
  36145. }
  36146. var ch = [this.eraseAttr(), ' ', 1, 32];
  36147. x++;
  36148. while (x--) {
  36149. line[x] = ch;
  36150. }
  36151. this.updateRange(y);
  36152. };
  36153. Terminal.prototype.clear = function () {
  36154. if (this.buffer.ybase === 0 && this.buffer.y === 0) {
  36155. return;
  36156. }
  36157. this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));
  36158. this.buffer.lines.length = 1;
  36159. this.buffer.ydisp = 0;
  36160. this.buffer.ybase = 0;
  36161. this.buffer.y = 0;
  36162. for (var i = 1; i < this.rows; i++) {
  36163. this.buffer.lines.push(this.blankLine());
  36164. }
  36165. this.refresh(0, this.rows - 1);
  36166. this.emit('scroll', this.buffer.ydisp);
  36167. };
  36168. Terminal.prototype.eraseLine = function (y) {
  36169. this.eraseRight(0, y);
  36170. };
  36171. Terminal.prototype.blankLine = function (cur, isWrapped, cols) {
  36172. var attr = cur ? this.eraseAttr() : this.defAttr;
  36173. var ch = [attr, ' ', 1, 32];
  36174. var line = [];
  36175. if (isWrapped) {
  36176. line.isWrapped = isWrapped;
  36177. }
  36178. cols = cols || this.cols;
  36179. for (var i = 0; i < cols; i++) {
  36180. line[i] = ch;
  36181. }
  36182. return line;
  36183. };
  36184. Terminal.prototype.ch = function (cur) {
  36185. if (cur) {
  36186. return [this.eraseAttr(), ' ', 1, 32];
  36187. }
  36188. return [this.defAttr, ' ', 1, 32];
  36189. };
  36190. Terminal.prototype.is = function (term) {
  36191. return (this.options.termName + '').indexOf(term) === 0;
  36192. };
  36193. Terminal.prototype.handler = function (data) {
  36194. if (this.options.disableStdin) {
  36195. return;
  36196. }
  36197. if (this.selectionManager && this.selectionManager.hasSelection) {
  36198. this.selectionManager.clearSelection();
  36199. }
  36200. if (this.buffer.ybase !== this.buffer.ydisp) {
  36201. this.scrollToBottom();
  36202. }
  36203. this.emit('data', data);
  36204. };
  36205. Terminal.prototype.handleTitle = function (title) {
  36206. this.emit('title', title);
  36207. };
  36208. Terminal.prototype.index = function () {
  36209. this.buffer.y++;
  36210. if (this.buffer.y > this.buffer.scrollBottom) {
  36211. this.buffer.y--;
  36212. this.scroll();
  36213. }
  36214. if (this.buffer.x >= this.cols) {
  36215. this.buffer.x--;
  36216. }
  36217. };
  36218. Terminal.prototype.reverseIndex = function () {
  36219. if (this.buffer.y === this.buffer.scrollTop) {
  36220. var scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop;
  36221. this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);
  36222. this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.blankLine(true));
  36223. this.updateRange(this.buffer.scrollTop);
  36224. this.updateRange(this.buffer.scrollBottom);
  36225. }
  36226. else {
  36227. this.buffer.y--;
  36228. }
  36229. };
  36230. Terminal.prototype.reset = function () {
  36231. this.options.rows = this.rows;
  36232. this.options.cols = this.cols;
  36233. var customKeyEventHandler = this.customKeyEventHandler;
  36234. var inputHandler = this.inputHandler;
  36235. this.setup();
  36236. this.customKeyEventHandler = customKeyEventHandler;
  36237. this.inputHandler = inputHandler;
  36238. this.refresh(0, this.rows - 1);
  36239. this.viewport.syncScrollArea();
  36240. };
  36241. Terminal.prototype.tabSet = function () {
  36242. this.buffer.tabs[this.buffer.x] = true;
  36243. };
  36244. Terminal.prototype.cancel = function (ev, force) {
  36245. if (!this.options.cancelEvents && !force) {
  36246. return;
  36247. }
  36248. ev.preventDefault();
  36249. ev.stopPropagation();
  36250. return false;
  36251. };
  36252. Terminal.prototype.matchColor = function (r1, g1, b1) {
  36253. return matchColor_(r1, g1, b1);
  36254. };
  36255. Terminal.prototype.visualBell = function () {
  36256. return false;
  36257. };
  36258. Terminal.prototype.soundBell = function () {
  36259. return this.options.bellStyle === 'sound';
  36260. };
  36261. Terminal.prototype.syncBellSound = function () {
  36262. if (!this.element) {
  36263. return;
  36264. }
  36265. if (this.soundBell() && this.bellAudioElement) {
  36266. this.bellAudioElement.setAttribute('src', this.options.bellSound);
  36267. }
  36268. else if (this.soundBell()) {
  36269. this.bellAudioElement = document.createElement('audio');
  36270. this.bellAudioElement.setAttribute('preload', 'auto');
  36271. this.bellAudioElement.setAttribute('src', this.options.bellSound);
  36272. this.helperContainer.appendChild(this.bellAudioElement);
  36273. }
  36274. else if (this.bellAudioElement) {
  36275. this.helperContainer.removeChild(this.bellAudioElement);
  36276. }
  36277. };
  36278. return Terminal;
  36279. }(EventEmitter_1.EventEmitter));
  36280. exports.Terminal = Terminal;
  36281. function globalOn(el, type, handler, capture) {
  36282. if (!Array.isArray(el)) {
  36283. el = [el];
  36284. }
  36285. el.forEach(function (element) {
  36286. element.addEventListener(type, handler, capture || false);
  36287. });
  36288. }
  36289. var on = globalOn;
  36290. function off(el, type, handler, capture) {
  36291. if (capture === void 0) { capture = false; }
  36292. el.removeEventListener(type, handler, capture);
  36293. }
  36294. function wasMondifierKeyOnlyEvent(ev) {
  36295. return ev.keyCode === 16 ||
  36296. ev.keyCode === 17 ||
  36297. ev.keyCode === 18;
  36298. }
  36299. var vcolors = (function () {
  36300. var result = ColorManager_1.DEFAULT_ANSI_COLORS.map(function (c) {
  36301. c = c.substring(1);
  36302. return [
  36303. parseInt(c.substring(0, 2), 16),
  36304. parseInt(c.substring(2, 4), 16),
  36305. parseInt(c.substring(4, 6), 16)
  36306. ];
  36307. });
  36308. var r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
  36309. for (var i = 0; i < 216; i++) {
  36310. result.push([
  36311. r[(i / 36) % 6 | 0],
  36312. r[(i / 6) % 6 | 0],
  36313. r[i % 6]
  36314. ]);
  36315. }
  36316. var c;
  36317. for (var i = 0; i < 24; i++) {
  36318. c = 8 + i * 10;
  36319. result.push([c, c, c]);
  36320. }
  36321. return result;
  36322. })();
  36323. var matchColorCache = {};
  36324. function matchColorDistance(r1, g1, b1, r2, g2, b2) {
  36325. return Math.pow(30 * (r1 - r2), 2)
  36326. + Math.pow(59 * (g1 - g2), 2)
  36327. + Math.pow(11 * (b1 - b2), 2);
  36328. }
  36329. function matchColor_(r1, g1, b1) {
  36330. var hash = (r1 << 16) | (g1 << 8) | b1;
  36331. if (matchColorCache[hash] != null) {
  36332. return matchColorCache[hash];
  36333. }
  36334. var ldiff = Infinity;
  36335. var li = -1;
  36336. var i = 0;
  36337. var c;
  36338. var r2;
  36339. var g2;
  36340. var b2;
  36341. var diff;
  36342. for (; i < vcolors.length; i++) {
  36343. c = vcolors[i];
  36344. r2 = c[0];
  36345. g2 = c[1];
  36346. b2 = c[2];
  36347. diff = matchColorDistance(r1, g1, b1, r2, g2, b2);
  36348. if (diff === 0) {
  36349. li = i;
  36350. break;
  36351. }
  36352. if (diff < ldiff) {
  36353. ldiff = diff;
  36354. li = i;
  36355. }
  36356. }
  36357. return matchColorCache[hash] = li;
  36358. }
  36359. },{"./Buffer":1,"./BufferSet":2,"./CompositionHelper":5,"./EscapeSequences":6,"./EventEmitter":7,"./InputHandler":8,"./Linkifier":9,"./Parser":10,"./SelectionManager":11,"./Viewport":15,"./handlers/Clipboard":17,"./input/MouseZoneManager":18,"./renderer/ColorManager":21,"./renderer/Renderer":25,"./shared/utils/Browser":30,"./utils/CharMeasure":31,"./utils/MouseHelper":33,"./utils/Sounds":35}],14:[function(require,module,exports){
  36360. "use strict";
  36361. Object.defineProperty(exports, "__esModule", { value: true });
  36362. var LinkHoverEventTypes;
  36363. (function (LinkHoverEventTypes) {
  36364. LinkHoverEventTypes["HOVER"] = "linkhover";
  36365. LinkHoverEventTypes["TOOLTIP"] = "linktooltip";
  36366. LinkHoverEventTypes["LEAVE"] = "linkleave";
  36367. })(LinkHoverEventTypes = exports.LinkHoverEventTypes || (exports.LinkHoverEventTypes = {}));
  36368. },{}],15:[function(require,module,exports){
  36369. "use strict";
  36370. Object.defineProperty(exports, "__esModule", { value: true });
  36371. var FALLBACK_SCROLL_BAR_WIDTH = 15;
  36372. var Viewport = (function () {
  36373. function Viewport(terminal, viewportElement, scrollArea, charMeasure) {
  36374. var _this = this;
  36375. this.terminal = terminal;
  36376. this.viewportElement = viewportElement;
  36377. this.scrollArea = scrollArea;
  36378. this.charMeasure = charMeasure;
  36379. this.scrollBarWidth = 0;
  36380. this.currentRowHeight = 0;
  36381. this.lastRecordedBufferLength = 0;
  36382. this.lastRecordedViewportHeight = 0;
  36383. this.lastRecordedBufferHeight = 0;
  36384. this.scrollBarWidth = (this.viewportElement.offsetWidth - this.scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
  36385. this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
  36386. setTimeout(function () { return _this.syncScrollArea(); }, 0);
  36387. }
  36388. Viewport.prototype.onThemeChanged = function (colors) {
  36389. this.viewportElement.style.backgroundColor = colors.background;
  36390. };
  36391. Viewport.prototype.refresh = function () {
  36392. if (this.charMeasure.height > 0) {
  36393. this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
  36394. this.lastRecordedViewportHeight = this.viewportElement.offsetHeight;
  36395. var newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength) + (this.lastRecordedViewportHeight - this.terminal.renderer.dimensions.canvasHeight);
  36396. if (this.lastRecordedBufferHeight !== newBufferHeight) {
  36397. this.lastRecordedBufferHeight = newBufferHeight;
  36398. this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';
  36399. }
  36400. }
  36401. };
  36402. Viewport.prototype.syncScrollArea = function () {
  36403. if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {
  36404. this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
  36405. this.refresh();
  36406. }
  36407. else if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {
  36408. this.refresh();
  36409. }
  36410. else {
  36411. if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {
  36412. this.refresh();
  36413. }
  36414. }
  36415. var scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;
  36416. if (this.viewportElement.scrollTop !== scrollTop) {
  36417. this.viewportElement.scrollTop = scrollTop;
  36418. }
  36419. };
  36420. Viewport.prototype.onScroll = function (ev) {
  36421. if (!this.viewportElement.offsetParent) {
  36422. return;
  36423. }
  36424. var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
  36425. var diff = newRow - this.terminal.buffer.ydisp;
  36426. this.terminal.scrollLines(diff, true);
  36427. };
  36428. Viewport.prototype.onWheel = function (ev) {
  36429. if (ev.deltaY === 0) {
  36430. return;
  36431. }
  36432. var multiplier = 1;
  36433. if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
  36434. multiplier = this.currentRowHeight;
  36435. }
  36436. else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  36437. multiplier = this.currentRowHeight * this.terminal.rows;
  36438. }
  36439. this.viewportElement.scrollTop += ev.deltaY * multiplier;
  36440. ev.preventDefault();
  36441. };
  36442. Viewport.prototype.onTouchStart = function (ev) {
  36443. this.lastTouchY = ev.touches[0].pageY;
  36444. };
  36445. Viewport.prototype.onTouchMove = function (ev) {
  36446. var deltaY = this.lastTouchY - ev.touches[0].pageY;
  36447. this.lastTouchY = ev.touches[0].pageY;
  36448. if (deltaY === 0) {
  36449. return;
  36450. }
  36451. this.viewportElement.scrollTop += deltaY;
  36452. ev.preventDefault();
  36453. };
  36454. return Viewport;
  36455. }());
  36456. exports.Viewport = Viewport;
  36457. },{}],16:[function(require,module,exports){
  36458. "use strict";
  36459. Object.defineProperty(exports, "__esModule", { value: true });
  36460. var EscapeSequences_1 = require("../EscapeSequences");
  36461. var Direction;
  36462. (function (Direction) {
  36463. Direction["Up"] = "A";
  36464. Direction["Down"] = "B";
  36465. Direction["Right"] = "C";
  36466. Direction["Left"] = "D";
  36467. })(Direction || (Direction = {}));
  36468. var AltClickHandler = (function () {
  36469. function AltClickHandler(_mouseEvent, _terminal) {
  36470. this._mouseEvent = _mouseEvent;
  36471. this._terminal = _terminal;
  36472. this._lines = this._terminal.buffer.lines;
  36473. this._startCol = this._terminal.buffer.x;
  36474. this._startRow = this._terminal.buffer.y;
  36475. _a = this._terminal.mouseHelper.getCoords(this._mouseEvent, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, false).map(function (coordinate) {
  36476. return coordinate - 1;
  36477. }), this._endCol = _a[0], this._endRow = _a[1];
  36478. var _a;
  36479. }
  36480. AltClickHandler.prototype.move = function () {
  36481. if (this._mouseEvent.altKey) {
  36482. this._terminal.send(this._arrowSequences());
  36483. }
  36484. };
  36485. AltClickHandler.prototype._arrowSequences = function () {
  36486. return this._resetStartingRow() +
  36487. this._moveToRequestedRow() +
  36488. this._moveToRequestedCol();
  36489. };
  36490. AltClickHandler.prototype._resetStartingRow = function () {
  36491. var startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
  36492. var endRow = this._endRow;
  36493. if (this._moveToRequestedRow().length === 0) {
  36494. return '';
  36495. }
  36496. else {
  36497. return repeat(this._bufferLine(this._startCol, this._startRow, this._startCol, this._startRow - this._wrappedRowsForRow(this._startRow), false).length, this._sequence(Direction.Left));
  36498. }
  36499. };
  36500. AltClickHandler.prototype._moveToRequestedRow = function () {
  36501. var startRow = this._startRow - this._wrappedRowsForRow(this._startRow);
  36502. var endRow = this._endRow - this._wrappedRowsForRow(this._endRow);
  36503. var rowsToMove = Math.abs(startRow - endRow) - this._wrappedRowsCount();
  36504. return repeat(rowsToMove, this._sequence(this._verticalDirection()));
  36505. };
  36506. AltClickHandler.prototype._moveToRequestedCol = function () {
  36507. var startRow;
  36508. if (this._moveToRequestedRow().length > 0) {
  36509. startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
  36510. }
  36511. else {
  36512. startRow = this._startRow;
  36513. }
  36514. var endRow = this._endRow;
  36515. var direction = this._horizontalDirection();
  36516. return repeat(this._bufferLine(this._startCol, startRow, this._endCol, endRow, direction === Direction.Right).length, this._sequence(direction));
  36517. };
  36518. AltClickHandler.prototype._wrappedRowsCount = function () {
  36519. var wrappedRows = 0;
  36520. var startRow = this._startRow - this._wrappedRowsForRow(this._startRow);
  36521. var endRow = this._endRow - this._wrappedRowsForRow(this._endRow);
  36522. for (var i = 0; i < Math.abs(startRow - endRow); i++) {
  36523. var direction = this._verticalDirection() === Direction.Up ? -1 : 1;
  36524. if (this._lines.get(startRow + (direction * i)).isWrapped) {
  36525. wrappedRows++;
  36526. }
  36527. }
  36528. return wrappedRows;
  36529. };
  36530. AltClickHandler.prototype._wrappedRowsForRow = function (currentRow) {
  36531. var rowCount = 0;
  36532. var lineWraps = this._lines.get(currentRow).isWrapped;
  36533. while (lineWraps && currentRow >= 0 && currentRow < this._terminal.rows) {
  36534. rowCount++;
  36535. currentRow--;
  36536. lineWraps = this._lines.get(currentRow).isWrapped;
  36537. }
  36538. return rowCount;
  36539. };
  36540. AltClickHandler.prototype._horizontalDirection = function () {
  36541. var startRow;
  36542. if (this._moveToRequestedRow().length > 0) {
  36543. startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
  36544. }
  36545. else {
  36546. startRow = this._startRow;
  36547. }
  36548. if ((this._startCol < this._endCol &&
  36549. startRow <= this._endRow) ||
  36550. (this._startCol >= this._endCol &&
  36551. startRow < this._endRow)) {
  36552. return Direction.Right;
  36553. }
  36554. else {
  36555. return Direction.Left;
  36556. }
  36557. };
  36558. AltClickHandler.prototype._verticalDirection = function () {
  36559. if (this._startRow > this._endRow) {
  36560. return Direction.Up;
  36561. }
  36562. else {
  36563. return Direction.Down;
  36564. }
  36565. };
  36566. AltClickHandler.prototype._bufferLine = function (startCol, startRow, endCol, endRow, forward) {
  36567. var currentCol = startCol;
  36568. var currentRow = startRow;
  36569. var bufferStr = '';
  36570. while (currentCol !== endCol || currentRow !== endRow) {
  36571. currentCol += forward ? 1 : -1;
  36572. if (forward && currentCol > this._terminal.cols - 1) {
  36573. bufferStr += this._terminal.buffer.translateBufferLineToString(currentRow, false, startCol, currentCol);
  36574. currentCol = 0;
  36575. startCol = 0;
  36576. currentRow++;
  36577. }
  36578. else if (!forward && currentCol < 0) {
  36579. bufferStr += this._terminal.buffer.translateBufferLineToString(currentRow, false, 0, startCol + 1);
  36580. currentCol = this._terminal.cols - 1;
  36581. startCol = currentCol;
  36582. currentRow--;
  36583. }
  36584. }
  36585. return bufferStr + this._terminal.buffer.translateBufferLineToString(currentRow, false, startCol, currentCol);
  36586. };
  36587. AltClickHandler.prototype._sequence = function (direction) {
  36588. var mod = this._terminal.applicationCursor ? 'O' : '[';
  36589. return EscapeSequences_1.C0.ESC + mod + direction;
  36590. };
  36591. return AltClickHandler;
  36592. }());
  36593. exports.AltClickHandler = AltClickHandler;
  36594. function repeat(count, str) {
  36595. count = Math.floor(count);
  36596. var rpt = '';
  36597. for (var i = 0; i < count; i++) {
  36598. rpt += str;
  36599. }
  36600. return rpt;
  36601. }
  36602. },{"../EscapeSequences":6}],17:[function(require,module,exports){
  36603. "use strict";
  36604. Object.defineProperty(exports, "__esModule", { value: true });
  36605. function prepareTextForTerminal(text, isMSWindows) {
  36606. if (isMSWindows) {
  36607. return text.replace(/\r?\n/g, '\r');
  36608. }
  36609. return text;
  36610. }
  36611. exports.prepareTextForTerminal = prepareTextForTerminal;
  36612. function bracketTextForPaste(text, bracketedPasteMode) {
  36613. if (bracketedPasteMode) {
  36614. return '\x1b[200~' + text + '\x1b[201~';
  36615. }
  36616. return text;
  36617. }
  36618. exports.bracketTextForPaste = bracketTextForPaste;
  36619. function copyHandler(ev, term, selectionManager) {
  36620. if (term.browser.isMSIE) {
  36621. window.clipboardData.setData('Text', selectionManager.selectionText);
  36622. }
  36623. else {
  36624. ev.clipboardData.setData('text/plain', selectionManager.selectionText);
  36625. }
  36626. ev.preventDefault();
  36627. }
  36628. exports.copyHandler = copyHandler;
  36629. function pasteHandler(ev, term) {
  36630. ev.stopPropagation();
  36631. var text;
  36632. var dispatchPaste = function (text) {
  36633. text = prepareTextForTerminal(text, term.browser.isMSWindows);
  36634. text = bracketTextForPaste(text, term.bracketedPasteMode);
  36635. term.handler(text);
  36636. term.textarea.value = '';
  36637. term.emit('paste', text);
  36638. term.cancel(ev);
  36639. };
  36640. if (term.browser.isMSIE) {
  36641. if (window.clipboardData) {
  36642. text = window.clipboardData.getData('Text');
  36643. dispatchPaste(text);
  36644. }
  36645. }
  36646. else {
  36647. if (ev.clipboardData) {
  36648. text = ev.clipboardData.getData('text/plain');
  36649. dispatchPaste(text);
  36650. }
  36651. }
  36652. }
  36653. exports.pasteHandler = pasteHandler;
  36654. function moveTextAreaUnderMouseCursor(ev, textarea) {
  36655. textarea.style.position = 'fixed';
  36656. textarea.style.width = '20px';
  36657. textarea.style.height = '20px';
  36658. textarea.style.left = (ev.clientX - 10) + 'px';
  36659. textarea.style.top = (ev.clientY - 10) + 'px';
  36660. textarea.style.zIndex = '1000';
  36661. textarea.focus();
  36662. setTimeout(function () {
  36663. textarea.style.position = null;
  36664. textarea.style.width = null;
  36665. textarea.style.height = null;
  36666. textarea.style.left = null;
  36667. textarea.style.top = null;
  36668. textarea.style.zIndex = null;
  36669. }, 200);
  36670. }
  36671. exports.moveTextAreaUnderMouseCursor = moveTextAreaUnderMouseCursor;
  36672. function rightClickHandler(ev, textarea, selectionManager, shouldSelectWord) {
  36673. moveTextAreaUnderMouseCursor(ev, textarea);
  36674. if (shouldSelectWord && !selectionManager.isClickInSelection(ev)) {
  36675. selectionManager.selectWordAtCursor(ev);
  36676. }
  36677. textarea.value = selectionManager.selectionText;
  36678. textarea.select();
  36679. }
  36680. exports.rightClickHandler = rightClickHandler;
  36681. },{}],18:[function(require,module,exports){
  36682. "use strict";
  36683. Object.defineProperty(exports, "__esModule", { value: true });
  36684. var HOVER_DURATION = 500;
  36685. var MouseZoneManager = (function () {
  36686. function MouseZoneManager(_terminal) {
  36687. var _this = this;
  36688. this._terminal = _terminal;
  36689. this._zones = [];
  36690. this._areZonesActive = false;
  36691. this._tooltipTimeout = null;
  36692. this._currentZone = null;
  36693. this._lastHoverCoords = [null, null];
  36694. this._terminal.element.addEventListener('mousedown', function (e) { return _this._onMouseDown(e); });
  36695. this._mouseMoveListener = function (e) { return _this._onMouseMove(e); };
  36696. this._clickListener = function (e) { return _this._onClick(e); };
  36697. }
  36698. MouseZoneManager.prototype.add = function (zone) {
  36699. this._zones.push(zone);
  36700. if (this._zones.length === 1) {
  36701. this._activate();
  36702. }
  36703. };
  36704. MouseZoneManager.prototype.clearAll = function (start, end) {
  36705. if (this._zones.length === 0) {
  36706. return;
  36707. }
  36708. if (!end) {
  36709. start = 0;
  36710. end = this._terminal.rows - 1;
  36711. }
  36712. for (var i = 0; i < this._zones.length; i++) {
  36713. var zone = this._zones[i];
  36714. if (zone.y > start && zone.y <= end + 1) {
  36715. if (this._currentZone && this._currentZone === zone) {
  36716. this._currentZone.leaveCallback();
  36717. this._currentZone = null;
  36718. }
  36719. this._zones.splice(i--, 1);
  36720. }
  36721. }
  36722. if (this._zones.length === 0) {
  36723. this._deactivate();
  36724. }
  36725. };
  36726. MouseZoneManager.prototype._activate = function () {
  36727. if (!this._areZonesActive) {
  36728. this._areZonesActive = true;
  36729. this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);
  36730. this._terminal.element.addEventListener('click', this._clickListener);
  36731. }
  36732. };
  36733. MouseZoneManager.prototype._deactivate = function () {
  36734. if (this._areZonesActive) {
  36735. this._areZonesActive = false;
  36736. this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);
  36737. this._terminal.element.removeEventListener('click', this._clickListener);
  36738. }
  36739. };
  36740. MouseZoneManager.prototype._onMouseMove = function (e) {
  36741. if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {
  36742. this._onHover(e);
  36743. this._lastHoverCoords = [e.pageX, e.pageY];
  36744. }
  36745. };
  36746. MouseZoneManager.prototype._onHover = function (e) {
  36747. var _this = this;
  36748. var zone = this._findZoneEventAt(e);
  36749. if (zone === this._currentZone) {
  36750. return;
  36751. }
  36752. if (this._currentZone) {
  36753. this._currentZone.leaveCallback();
  36754. this._currentZone = null;
  36755. if (this._tooltipTimeout) {
  36756. clearTimeout(this._tooltipTimeout);
  36757. }
  36758. }
  36759. if (!zone) {
  36760. return;
  36761. }
  36762. this._currentZone = zone;
  36763. if (zone.hoverCallback) {
  36764. zone.hoverCallback(e);
  36765. }
  36766. this._tooltipTimeout = setTimeout(function () { return _this._onTooltip(e); }, HOVER_DURATION);
  36767. };
  36768. MouseZoneManager.prototype._onTooltip = function (e) {
  36769. this._tooltipTimeout = null;
  36770. var zone = this._findZoneEventAt(e);
  36771. if (zone && zone.tooltipCallback) {
  36772. zone.tooltipCallback(e);
  36773. }
  36774. };
  36775. MouseZoneManager.prototype._onMouseDown = function (e) {
  36776. if (!this._areZonesActive) {
  36777. return;
  36778. }
  36779. var zone = this._findZoneEventAt(e);
  36780. if (zone) {
  36781. if (zone.willLinkActivate(e)) {
  36782. e.preventDefault();
  36783. e.stopImmediatePropagation();
  36784. }
  36785. }
  36786. };
  36787. MouseZoneManager.prototype._onClick = function (e) {
  36788. var zone = this._findZoneEventAt(e);
  36789. if (zone) {
  36790. zone.clickCallback(e);
  36791. e.preventDefault();
  36792. e.stopImmediatePropagation();
  36793. }
  36794. };
  36795. MouseZoneManager.prototype._findZoneEventAt = function (e) {
  36796. var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
  36797. if (!coords) {
  36798. return null;
  36799. }
  36800. for (var i = 0; i < this._zones.length; i++) {
  36801. var zone = this._zones[i];
  36802. if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
  36803. return zone;
  36804. }
  36805. }
  36806. return null;
  36807. };
  36808. return MouseZoneManager;
  36809. }());
  36810. exports.MouseZoneManager = MouseZoneManager;
  36811. var MouseZone = (function () {
  36812. function MouseZone(x1, x2, y, clickCallback, hoverCallback, tooltipCallback, leaveCallback, willLinkActivate) {
  36813. this.x1 = x1;
  36814. this.x2 = x2;
  36815. this.y = y;
  36816. this.clickCallback = clickCallback;
  36817. this.hoverCallback = hoverCallback;
  36818. this.tooltipCallback = tooltipCallback;
  36819. this.leaveCallback = leaveCallback;
  36820. this.willLinkActivate = willLinkActivate;
  36821. }
  36822. return MouseZone;
  36823. }());
  36824. exports.MouseZone = MouseZone;
  36825. },{}],19:[function(require,module,exports){
  36826. "use strict";
  36827. Object.defineProperty(exports, "__esModule", { value: true });
  36828. var CharAtlas_1 = require("./CharAtlas");
  36829. var Buffer_1 = require("../Buffer");
  36830. exports.INVERTED_DEFAULT_COLOR = -1;
  36831. var DIM_OPACITY = 0.5;
  36832. var BaseRenderLayer = (function () {
  36833. function BaseRenderLayer(_container, id, zIndex, _alpha, _colors) {
  36834. this._container = _container;
  36835. this._alpha = _alpha;
  36836. this._colors = _colors;
  36837. this._scaledCharWidth = 0;
  36838. this._scaledCharHeight = 0;
  36839. this._scaledCellWidth = 0;
  36840. this._scaledCellHeight = 0;
  36841. this._scaledCharLeft = 0;
  36842. this._scaledCharTop = 0;
  36843. this._canvas = document.createElement('canvas');
  36844. this._canvas.classList.add("xterm-" + id + "-layer");
  36845. this._canvas.style.zIndex = zIndex.toString();
  36846. this._initCanvas();
  36847. this._container.appendChild(this._canvas);
  36848. }
  36849. BaseRenderLayer.prototype._initCanvas = function () {
  36850. this._ctx = this._canvas.getContext('2d', { alpha: this._alpha });
  36851. if (!this._alpha) {
  36852. this.clearAll();
  36853. }
  36854. };
  36855. BaseRenderLayer.prototype.onOptionsChanged = function (terminal) { };
  36856. BaseRenderLayer.prototype.onBlur = function (terminal) { };
  36857. BaseRenderLayer.prototype.onFocus = function (terminal) { };
  36858. BaseRenderLayer.prototype.onCursorMove = function (terminal) { };
  36859. BaseRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) { };
  36860. BaseRenderLayer.prototype.onSelectionChanged = function (terminal, start, end) { };
  36861. BaseRenderLayer.prototype.onThemeChanged = function (terminal, colorSet) {
  36862. this._refreshCharAtlas(terminal, colorSet);
  36863. };
  36864. BaseRenderLayer.prototype.setTransparency = function (terminal, alpha) {
  36865. if (alpha === this._alpha) {
  36866. return;
  36867. }
  36868. var oldCanvas = this._canvas;
  36869. this._alpha = alpha;
  36870. this._canvas = this._canvas.cloneNode();
  36871. this._initCanvas();
  36872. this._container.replaceChild(this._canvas, oldCanvas);
  36873. this._refreshCharAtlas(terminal, this._colors);
  36874. this.onGridChanged(terminal, 0, terminal.rows - 1);
  36875. };
  36876. BaseRenderLayer.prototype._refreshCharAtlas = function (terminal, colorSet) {
  36877. var _this = this;
  36878. if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {
  36879. return;
  36880. }
  36881. this._charAtlas = null;
  36882. var result = CharAtlas_1.acquireCharAtlas(terminal, colorSet, this._scaledCharWidth, this._scaledCharHeight);
  36883. if (result instanceof HTMLCanvasElement) {
  36884. this._charAtlas = result;
  36885. }
  36886. else {
  36887. result.then(function (bitmap) { return _this._charAtlas = bitmap; });
  36888. }
  36889. };
  36890. BaseRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
  36891. this._scaledCellWidth = dim.scaledCellWidth;
  36892. this._scaledCellHeight = dim.scaledCellHeight;
  36893. this._scaledCharWidth = dim.scaledCharWidth;
  36894. this._scaledCharHeight = dim.scaledCharHeight;
  36895. this._scaledCharLeft = dim.scaledCharLeft;
  36896. this._scaledCharTop = dim.scaledCharTop;
  36897. this._canvas.width = dim.scaledCanvasWidth;
  36898. this._canvas.height = dim.scaledCanvasHeight;
  36899. this._canvas.style.width = dim.canvasWidth + "px";
  36900. this._canvas.style.height = dim.canvasHeight + "px";
  36901. if (!this._alpha) {
  36902. this.clearAll();
  36903. }
  36904. if (charSizeChanged) {
  36905. this._refreshCharAtlas(terminal, this._colors);
  36906. }
  36907. };
  36908. BaseRenderLayer.prototype.fillCells = function (x, y, width, height) {
  36909. this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
  36910. };
  36911. BaseRenderLayer.prototype.fillBottomLineAtCells = function (x, y, width) {
  36912. if (width === void 0) { width = 1; }
  36913. this._ctx.fillRect(x * this._scaledCellWidth, (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1, width * this._scaledCellWidth, window.devicePixelRatio);
  36914. };
  36915. BaseRenderLayer.prototype.fillLeftLineAtCell = function (x, y) {
  36916. this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, window.devicePixelRatio, this._scaledCellHeight);
  36917. };
  36918. BaseRenderLayer.prototype.strokeRectAtCell = function (x, y, width, height) {
  36919. this._ctx.lineWidth = window.devicePixelRatio;
  36920. this._ctx.strokeRect(x * this._scaledCellWidth + window.devicePixelRatio / 2, y * this._scaledCellHeight + (window.devicePixelRatio / 2), width * this._scaledCellWidth - window.devicePixelRatio, (height * this._scaledCellHeight) - window.devicePixelRatio);
  36921. };
  36922. BaseRenderLayer.prototype.clearAll = function () {
  36923. if (this._alpha) {
  36924. this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
  36925. }
  36926. else {
  36927. this._ctx.fillStyle = this._colors.background;
  36928. this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);
  36929. }
  36930. };
  36931. BaseRenderLayer.prototype.clearCells = function (x, y, width, height) {
  36932. if (this._alpha) {
  36933. this._ctx.clearRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
  36934. }
  36935. else {
  36936. this._ctx.fillStyle = this._colors.background;
  36937. this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
  36938. }
  36939. };
  36940. BaseRenderLayer.prototype.fillCharTrueColor = function (terminal, charData, x, y) {
  36941. this._ctx.font = this._getFont(terminal, false);
  36942. this._ctx.textBaseline = 'top';
  36943. this._clipRow(terminal, y);
  36944. this._ctx.fillText(charData[Buffer_1.CHAR_DATA_CHAR_INDEX], x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
  36945. };
  36946. BaseRenderLayer.prototype.drawChar = function (terminal, char, code, width, x, y, fg, bg, bold, dim) {
  36947. var colorIndex = 0;
  36948. if (fg < 256) {
  36949. colorIndex = fg + 2;
  36950. }
  36951. else {
  36952. if (bold && terminal.options.enableBold) {
  36953. colorIndex = 1;
  36954. }
  36955. }
  36956. var isAscii = code < 256;
  36957. var isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold);
  36958. var isDefaultColor = fg >= 256;
  36959. var isDefaultBackground = bg >= 256;
  36960. if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground) {
  36961. var charAtlasCellWidth = this._scaledCharWidth + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
  36962. var charAtlasCellHeight = this._scaledCharHeight + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
  36963. if (dim) {
  36964. this._ctx.globalAlpha = DIM_OPACITY;
  36965. }
  36966. if (bold && !terminal.options.enableBold) {
  36967. if (colorIndex > 1) {
  36968. colorIndex -= 8;
  36969. }
  36970. }
  36971. this._ctx.drawImage(this._charAtlas, code * charAtlasCellWidth, colorIndex * charAtlasCellHeight, charAtlasCellWidth, this._scaledCharHeight, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop, charAtlasCellWidth, this._scaledCharHeight);
  36972. }
  36973. else {
  36974. this._drawUncachedChar(terminal, char, width, fg, x, y, bold && terminal.options.enableBold, dim);
  36975. }
  36976. };
  36977. BaseRenderLayer.prototype._drawUncachedChar = function (terminal, char, width, fg, x, y, bold, dim) {
  36978. this._ctx.save();
  36979. this._ctx.font = this._getFont(terminal, bold);
  36980. this._ctx.textBaseline = 'top';
  36981. if (fg === exports.INVERTED_DEFAULT_COLOR) {
  36982. this._ctx.fillStyle = this._colors.background;
  36983. }
  36984. else if (fg < 256) {
  36985. this._ctx.fillStyle = this._colors.ansi[fg];
  36986. }
  36987. else {
  36988. this._ctx.fillStyle = this._colors.foreground;
  36989. }
  36990. this._clipRow(terminal, y);
  36991. if (dim) {
  36992. this._ctx.globalAlpha = DIM_OPACITY;
  36993. }
  36994. this._ctx.fillText(char, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
  36995. this._ctx.restore();
  36996. };
  36997. BaseRenderLayer.prototype._clipRow = function (terminal, y) {
  36998. this._ctx.beginPath();
  36999. this._ctx.rect(0, y * this._scaledCellHeight, terminal.cols * this._scaledCellWidth, this._scaledCellHeight);
  37000. this._ctx.clip();
  37001. };
  37002. BaseRenderLayer.prototype._getFont = function (terminal, isBold) {
  37003. var fontWeight = isBold ? terminal.options.fontWeightBold : terminal.options.fontWeight;
  37004. return fontWeight + " " + terminal.options.fontSize * window.devicePixelRatio + "px " + terminal.options.fontFamily;
  37005. };
  37006. return BaseRenderLayer;
  37007. }());
  37008. exports.BaseRenderLayer = BaseRenderLayer;
  37009. },{"../Buffer":1,"./CharAtlas":20}],20:[function(require,module,exports){
  37010. "use strict";
  37011. Object.defineProperty(exports, "__esModule", { value: true });
  37012. var CharAtlasGenerator_1 = require("../shared/CharAtlasGenerator");
  37013. exports.CHAR_ATLAS_CELL_SPACING = 1;
  37014. var charAtlasCache = [];
  37015. function acquireCharAtlas(terminal, colors, scaledCharWidth, scaledCharHeight) {
  37016. var newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);
  37017. for (var i = 0; i < charAtlasCache.length; i++) {
  37018. var entry = charAtlasCache[i];
  37019. var ownedByIndex = entry.ownedBy.indexOf(terminal);
  37020. if (ownedByIndex >= 0) {
  37021. if (configEquals(entry.config, newConfig)) {
  37022. return entry.bitmap;
  37023. }
  37024. else {
  37025. if (entry.ownedBy.length === 1) {
  37026. charAtlasCache.splice(i, 1);
  37027. }
  37028. else {
  37029. entry.ownedBy.splice(ownedByIndex, 1);
  37030. }
  37031. break;
  37032. }
  37033. }
  37034. }
  37035. for (var i = 0; i < charAtlasCache.length; i++) {
  37036. var entry = charAtlasCache[i];
  37037. if (configEquals(entry.config, newConfig)) {
  37038. entry.ownedBy.push(terminal);
  37039. return entry.bitmap;
  37040. }
  37041. }
  37042. var canvasFactory = function (width, height) {
  37043. var canvas = document.createElement('canvas');
  37044. canvas.width = width;
  37045. canvas.height = height;
  37046. return canvas;
  37047. };
  37048. var charAtlasConfig = {
  37049. scaledCharWidth: scaledCharWidth,
  37050. scaledCharHeight: scaledCharHeight,
  37051. fontSize: terminal.options.fontSize,
  37052. fontFamily: terminal.options.fontFamily,
  37053. fontWeight: terminal.options.fontWeight,
  37054. fontWeightBold: terminal.options.fontWeightBold,
  37055. background: colors.background,
  37056. foreground: colors.foreground,
  37057. ansiColors: colors.ansi,
  37058. devicePixelRatio: window.devicePixelRatio,
  37059. allowTransparency: terminal.options.allowTransparency
  37060. };
  37061. var newEntry = {
  37062. bitmap: CharAtlasGenerator_1.generateCharAtlas(window, canvasFactory, charAtlasConfig),
  37063. config: newConfig,
  37064. ownedBy: [terminal]
  37065. };
  37066. charAtlasCache.push(newEntry);
  37067. return newEntry.bitmap;
  37068. }
  37069. exports.acquireCharAtlas = acquireCharAtlas;
  37070. function generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors) {
  37071. var clonedColors = {
  37072. foreground: colors.foreground,
  37073. background: colors.background,
  37074. cursor: null,
  37075. cursorAccent: null,
  37076. selection: null,
  37077. ansi: colors.ansi.slice(0, 16)
  37078. };
  37079. return {
  37080. scaledCharWidth: scaledCharWidth,
  37081. scaledCharHeight: scaledCharHeight,
  37082. fontFamily: terminal.options.fontFamily,
  37083. fontSize: terminal.options.fontSize,
  37084. fontWeight: terminal.options.fontWeight,
  37085. fontWeightBold: terminal.options.fontWeightBold,
  37086. allowTransparency: terminal.options.allowTransparency,
  37087. colors: clonedColors
  37088. };
  37089. }
  37090. function configEquals(a, b) {
  37091. for (var i = 0; i < a.colors.ansi.length; i++) {
  37092. if (a.colors.ansi[i] !== b.colors.ansi[i]) {
  37093. return false;
  37094. }
  37095. }
  37096. return a.fontFamily === b.fontFamily &&
  37097. a.fontSize === b.fontSize &&
  37098. a.fontWeight === b.fontWeight &&
  37099. a.fontWeightBold === b.fontWeightBold &&
  37100. a.allowTransparency === b.allowTransparency &&
  37101. a.scaledCharWidth === b.scaledCharWidth &&
  37102. a.scaledCharHeight === b.scaledCharHeight &&
  37103. a.colors.foreground === b.colors.foreground &&
  37104. a.colors.background === b.colors.background;
  37105. }
  37106. },{"../shared/CharAtlasGenerator":29}],21:[function(require,module,exports){
  37107. "use strict";
  37108. Object.defineProperty(exports, "__esModule", { value: true });
  37109. var DEFAULT_FOREGROUND = '#ffffff';
  37110. var DEFAULT_BACKGROUND = '#000000';
  37111. var DEFAULT_CURSOR = '#ffffff';
  37112. var DEFAULT_CURSOR_ACCENT = '#000000';
  37113. var DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';
  37114. exports.DEFAULT_ANSI_COLORS = [
  37115. '#2e3436',
  37116. '#cc0000',
  37117. '#4e9a06',
  37118. '#c4a000',
  37119. '#3465a4',
  37120. '#75507b',
  37121. '#06989a',
  37122. '#d3d7cf',
  37123. '#555753',
  37124. '#ef2929',
  37125. '#8ae234',
  37126. '#fce94f',
  37127. '#729fcf',
  37128. '#ad7fa8',
  37129. '#34e2e2',
  37130. '#eeeeec'
  37131. ];
  37132. function generate256Colors(first16Colors) {
  37133. var colors = first16Colors.slice();
  37134. var v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
  37135. for (var i = 0; i < 216; i++) {
  37136. var r = toPaddedHex(v[(i / 36) % 6 | 0]);
  37137. var g = toPaddedHex(v[(i / 6) % 6 | 0]);
  37138. var b = toPaddedHex(v[i % 6]);
  37139. colors.push("#" + r + g + b);
  37140. }
  37141. for (var i = 0; i < 24; i++) {
  37142. var c = toPaddedHex(8 + i * 10);
  37143. colors.push("#" + c + c + c);
  37144. }
  37145. return colors;
  37146. }
  37147. function toPaddedHex(c) {
  37148. var s = c.toString(16);
  37149. return s.length < 2 ? '0' + s : s;
  37150. }
  37151. var ColorManager = (function () {
  37152. function ColorManager() {
  37153. this.colors = {
  37154. foreground: DEFAULT_FOREGROUND,
  37155. background: DEFAULT_BACKGROUND,
  37156. cursor: DEFAULT_CURSOR,
  37157. cursorAccent: DEFAULT_CURSOR_ACCENT,
  37158. selection: DEFAULT_SELECTION,
  37159. ansi: generate256Colors(exports.DEFAULT_ANSI_COLORS)
  37160. };
  37161. }
  37162. ColorManager.prototype.setTheme = function (theme) {
  37163. this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;
  37164. this.colors.background = theme.background || DEFAULT_BACKGROUND;
  37165. this.colors.cursor = theme.cursor || DEFAULT_CURSOR;
  37166. this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;
  37167. this.colors.selection = theme.selection || DEFAULT_SELECTION;
  37168. this.colors.ansi[0] = theme.black || exports.DEFAULT_ANSI_COLORS[0];
  37169. this.colors.ansi[1] = theme.red || exports.DEFAULT_ANSI_COLORS[1];
  37170. this.colors.ansi[2] = theme.green || exports.DEFAULT_ANSI_COLORS[2];
  37171. this.colors.ansi[3] = theme.yellow || exports.DEFAULT_ANSI_COLORS[3];
  37172. this.colors.ansi[4] = theme.blue || exports.DEFAULT_ANSI_COLORS[4];
  37173. this.colors.ansi[5] = theme.magenta || exports.DEFAULT_ANSI_COLORS[5];
  37174. this.colors.ansi[6] = theme.cyan || exports.DEFAULT_ANSI_COLORS[6];
  37175. this.colors.ansi[7] = theme.white || exports.DEFAULT_ANSI_COLORS[7];
  37176. this.colors.ansi[8] = theme.brightBlack || exports.DEFAULT_ANSI_COLORS[8];
  37177. this.colors.ansi[9] = theme.brightRed || exports.DEFAULT_ANSI_COLORS[9];
  37178. this.colors.ansi[10] = theme.brightGreen || exports.DEFAULT_ANSI_COLORS[10];
  37179. this.colors.ansi[11] = theme.brightYellow || exports.DEFAULT_ANSI_COLORS[11];
  37180. this.colors.ansi[12] = theme.brightBlue || exports.DEFAULT_ANSI_COLORS[12];
  37181. this.colors.ansi[13] = theme.brightMagenta || exports.DEFAULT_ANSI_COLORS[13];
  37182. this.colors.ansi[14] = theme.brightCyan || exports.DEFAULT_ANSI_COLORS[14];
  37183. this.colors.ansi[15] = theme.brightWhite || exports.DEFAULT_ANSI_COLORS[15];
  37184. };
  37185. return ColorManager;
  37186. }());
  37187. exports.ColorManager = ColorManager;
  37188. },{}],22:[function(require,module,exports){
  37189. "use strict";
  37190. var __extends = (this && this.__extends) || (function () {
  37191. var extendStatics = Object.setPrototypeOf ||
  37192. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37193. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37194. return function (d, b) {
  37195. extendStatics(d, b);
  37196. function __() { this.constructor = d; }
  37197. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37198. };
  37199. })();
  37200. Object.defineProperty(exports, "__esModule", { value: true });
  37201. var Buffer_1 = require("../Buffer");
  37202. var BaseRenderLayer_1 = require("./BaseRenderLayer");
  37203. var BLINK_INTERVAL = 600;
  37204. var CursorRenderLayer = (function (_super) {
  37205. __extends(CursorRenderLayer, _super);
  37206. function CursorRenderLayer(container, zIndex, colors) {
  37207. var _this = _super.call(this, container, 'cursor', zIndex, true, colors) || this;
  37208. _this._state = {
  37209. x: null,
  37210. y: null,
  37211. isFocused: null,
  37212. style: null,
  37213. width: null,
  37214. };
  37215. _this._cursorRenderers = {
  37216. 'bar': _this._renderBarCursor.bind(_this),
  37217. 'block': _this._renderBlockCursor.bind(_this),
  37218. 'underline': _this._renderUnderlineCursor.bind(_this)
  37219. };
  37220. return _this;
  37221. }
  37222. CursorRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
  37223. _super.prototype.resize.call(this, terminal, dim, charSizeChanged);
  37224. this._state = {
  37225. x: null,
  37226. y: null,
  37227. isFocused: null,
  37228. style: null,
  37229. width: null,
  37230. };
  37231. };
  37232. CursorRenderLayer.prototype.reset = function (terminal) {
  37233. this._clearCursor();
  37234. if (this._cursorBlinkStateManager) {
  37235. this._cursorBlinkStateManager.dispose();
  37236. this._cursorBlinkStateManager = null;
  37237. this.onOptionsChanged(terminal);
  37238. }
  37239. };
  37240. CursorRenderLayer.prototype.onBlur = function (terminal) {
  37241. if (this._cursorBlinkStateManager) {
  37242. this._cursorBlinkStateManager.pause();
  37243. }
  37244. terminal.refresh(terminal.buffer.y, terminal.buffer.y);
  37245. };
  37246. CursorRenderLayer.prototype.onFocus = function (terminal) {
  37247. if (this._cursorBlinkStateManager) {
  37248. this._cursorBlinkStateManager.resume(terminal);
  37249. }
  37250. else {
  37251. terminal.refresh(terminal.buffer.y, terminal.buffer.y);
  37252. }
  37253. };
  37254. CursorRenderLayer.prototype.onOptionsChanged = function (terminal) {
  37255. var _this = this;
  37256. if (terminal.options.cursorBlink) {
  37257. if (!this._cursorBlinkStateManager) {
  37258. this._cursorBlinkStateManager = new CursorBlinkStateManager(terminal, function () {
  37259. _this._render(terminal, true);
  37260. });
  37261. }
  37262. }
  37263. else {
  37264. if (this._cursorBlinkStateManager) {
  37265. this._cursorBlinkStateManager.dispose();
  37266. this._cursorBlinkStateManager = null;
  37267. }
  37268. terminal.refresh(terminal.buffer.y, terminal.buffer.y);
  37269. }
  37270. };
  37271. CursorRenderLayer.prototype.onCursorMove = function (terminal) {
  37272. if (this._cursorBlinkStateManager) {
  37273. this._cursorBlinkStateManager.restartBlinkAnimation(terminal);
  37274. }
  37275. };
  37276. CursorRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) {
  37277. if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
  37278. this._render(terminal, false);
  37279. }
  37280. else {
  37281. this._cursorBlinkStateManager.restartBlinkAnimation(terminal);
  37282. }
  37283. };
  37284. CursorRenderLayer.prototype._render = function (terminal, triggeredByAnimationFrame) {
  37285. if (!terminal.cursorState || terminal.cursorHidden) {
  37286. this._clearCursor();
  37287. return;
  37288. }
  37289. var cursorY = terminal.buffer.ybase + terminal.buffer.y;
  37290. var viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;
  37291. if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {
  37292. this._clearCursor();
  37293. return;
  37294. }
  37295. var charData = terminal.buffer.lines.get(cursorY)[terminal.buffer.x];
  37296. if (!charData) {
  37297. return;
  37298. }
  37299. if (!terminal.isFocused) {
  37300. this._clearCursor();
  37301. this._ctx.save();
  37302. this._ctx.fillStyle = this._colors.cursor;
  37303. this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);
  37304. this._ctx.restore();
  37305. this._state.x = terminal.buffer.x;
  37306. this._state.y = viewportRelativeCursorY;
  37307. this._state.isFocused = false;
  37308. this._state.style = terminal.options.cursorStyle;
  37309. this._state.width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
  37310. return;
  37311. }
  37312. if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {
  37313. this._clearCursor();
  37314. return;
  37315. }
  37316. if (this._state) {
  37317. if (this._state.x === terminal.buffer.x &&
  37318. this._state.y === viewportRelativeCursorY &&
  37319. this._state.isFocused === terminal.isFocused &&
  37320. this._state.style === terminal.options.cursorStyle &&
  37321. this._state.width === charData[Buffer_1.CHAR_DATA_WIDTH_INDEX]) {
  37322. return;
  37323. }
  37324. this._clearCursor();
  37325. }
  37326. this._ctx.save();
  37327. this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, charData);
  37328. this._ctx.restore();
  37329. this._state.x = terminal.buffer.x;
  37330. this._state.y = viewportRelativeCursorY;
  37331. this._state.isFocused = false;
  37332. this._state.style = terminal.options.cursorStyle;
  37333. this._state.width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
  37334. };
  37335. CursorRenderLayer.prototype._clearCursor = function () {
  37336. if (this._state) {
  37337. this.clearCells(this._state.x, this._state.y, this._state.width, 1);
  37338. this._state = {
  37339. x: null,
  37340. y: null,
  37341. isFocused: null,
  37342. style: null,
  37343. width: null,
  37344. };
  37345. }
  37346. };
  37347. CursorRenderLayer.prototype._renderBarCursor = function (terminal, x, y, charData) {
  37348. this._ctx.save();
  37349. this._ctx.fillStyle = this._colors.cursor;
  37350. this.fillLeftLineAtCell(x, y);
  37351. this._ctx.restore();
  37352. };
  37353. CursorRenderLayer.prototype._renderBlockCursor = function (terminal, x, y, charData) {
  37354. this._ctx.save();
  37355. this._ctx.fillStyle = this._colors.cursor;
  37356. this.fillCells(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);
  37357. this._ctx.fillStyle = this._colors.cursorAccent;
  37358. this.fillCharTrueColor(terminal, charData, x, y);
  37359. this._ctx.restore();
  37360. };
  37361. CursorRenderLayer.prototype._renderUnderlineCursor = function (terminal, x, y, charData) {
  37362. this._ctx.save();
  37363. this._ctx.fillStyle = this._colors.cursor;
  37364. this.fillBottomLineAtCells(x, y);
  37365. this._ctx.restore();
  37366. };
  37367. CursorRenderLayer.prototype._renderBlurCursor = function (terminal, x, y, charData) {
  37368. this._ctx.save();
  37369. this._ctx.strokeStyle = this._colors.cursor;
  37370. this.strokeRectAtCell(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);
  37371. this._ctx.restore();
  37372. };
  37373. return CursorRenderLayer;
  37374. }(BaseRenderLayer_1.BaseRenderLayer));
  37375. exports.CursorRenderLayer = CursorRenderLayer;
  37376. var CursorBlinkStateManager = (function () {
  37377. function CursorBlinkStateManager(terminal, renderCallback) {
  37378. this.renderCallback = renderCallback;
  37379. this.isCursorVisible = true;
  37380. if (terminal.isFocused) {
  37381. this._restartInterval();
  37382. }
  37383. }
  37384. Object.defineProperty(CursorBlinkStateManager.prototype, "isPaused", {
  37385. get: function () { return !(this._blinkStartTimeout || this._blinkInterval); },
  37386. enumerable: true,
  37387. configurable: true
  37388. });
  37389. CursorBlinkStateManager.prototype.dispose = function () {
  37390. if (this._blinkInterval) {
  37391. window.clearInterval(this._blinkInterval);
  37392. this._blinkInterval = null;
  37393. }
  37394. if (this._blinkStartTimeout) {
  37395. window.clearTimeout(this._blinkStartTimeout);
  37396. this._blinkStartTimeout = null;
  37397. }
  37398. if (this._animationFrame) {
  37399. window.cancelAnimationFrame(this._animationFrame);
  37400. this._animationFrame = null;
  37401. }
  37402. };
  37403. CursorBlinkStateManager.prototype.restartBlinkAnimation = function (terminal) {
  37404. var _this = this;
  37405. if (this.isPaused) {
  37406. return;
  37407. }
  37408. this._animationTimeRestarted = Date.now();
  37409. this.isCursorVisible = true;
  37410. if (!this._animationFrame) {
  37411. this._animationFrame = window.requestAnimationFrame(function () {
  37412. _this.renderCallback();
  37413. _this._animationFrame = null;
  37414. });
  37415. }
  37416. };
  37417. CursorBlinkStateManager.prototype._restartInterval = function (timeToStart) {
  37418. var _this = this;
  37419. if (timeToStart === void 0) { timeToStart = BLINK_INTERVAL; }
  37420. if (this._blinkInterval) {
  37421. window.clearInterval(this._blinkInterval);
  37422. }
  37423. this._blinkStartTimeout = setTimeout(function () {
  37424. if (_this._animationTimeRestarted) {
  37425. var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);
  37426. _this._animationTimeRestarted = null;
  37427. if (time > 0) {
  37428. _this._restartInterval(time);
  37429. return;
  37430. }
  37431. }
  37432. _this.isCursorVisible = false;
  37433. _this._animationFrame = window.requestAnimationFrame(function () {
  37434. _this.renderCallback();
  37435. _this._animationFrame = null;
  37436. });
  37437. _this._blinkInterval = setInterval(function () {
  37438. if (_this._animationTimeRestarted) {
  37439. var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);
  37440. _this._animationTimeRestarted = null;
  37441. _this._restartInterval(time);
  37442. return;
  37443. }
  37444. _this.isCursorVisible = !_this.isCursorVisible;
  37445. _this._animationFrame = window.requestAnimationFrame(function () {
  37446. _this.renderCallback();
  37447. _this._animationFrame = null;
  37448. });
  37449. }, BLINK_INTERVAL);
  37450. }, timeToStart);
  37451. };
  37452. CursorBlinkStateManager.prototype.pause = function () {
  37453. this.isCursorVisible = true;
  37454. if (this._blinkInterval) {
  37455. window.clearInterval(this._blinkInterval);
  37456. this._blinkInterval = null;
  37457. }
  37458. if (this._blinkStartTimeout) {
  37459. window.clearTimeout(this._blinkStartTimeout);
  37460. this._blinkStartTimeout = null;
  37461. }
  37462. if (this._animationFrame) {
  37463. window.cancelAnimationFrame(this._animationFrame);
  37464. this._animationFrame = null;
  37465. }
  37466. };
  37467. CursorBlinkStateManager.prototype.resume = function (terminal) {
  37468. this._animationTimeRestarted = null;
  37469. this._restartInterval();
  37470. this.restartBlinkAnimation(terminal);
  37471. };
  37472. return CursorBlinkStateManager;
  37473. }());
  37474. },{"../Buffer":1,"./BaseRenderLayer":19}],23:[function(require,module,exports){
  37475. "use strict";
  37476. Object.defineProperty(exports, "__esModule", { value: true });
  37477. var GridCache = (function () {
  37478. function GridCache() {
  37479. this.cache = [];
  37480. }
  37481. GridCache.prototype.resize = function (width, height) {
  37482. for (var x = 0; x < width; x++) {
  37483. if (this.cache.length <= x) {
  37484. this.cache.push([]);
  37485. }
  37486. for (var y = this.cache[x].length; y < height; y++) {
  37487. this.cache[x].push(null);
  37488. }
  37489. this.cache[x].length = height;
  37490. }
  37491. this.cache.length = width;
  37492. };
  37493. GridCache.prototype.clear = function () {
  37494. for (var x = 0; x < this.cache.length; x++) {
  37495. for (var y = 0; y < this.cache[x].length; y++) {
  37496. this.cache[x][y] = null;
  37497. }
  37498. }
  37499. };
  37500. return GridCache;
  37501. }());
  37502. exports.GridCache = GridCache;
  37503. },{}],24:[function(require,module,exports){
  37504. "use strict";
  37505. var __extends = (this && this.__extends) || (function () {
  37506. var extendStatics = Object.setPrototypeOf ||
  37507. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37508. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37509. return function (d, b) {
  37510. extendStatics(d, b);
  37511. function __() { this.constructor = d; }
  37512. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37513. };
  37514. })();
  37515. Object.defineProperty(exports, "__esModule", { value: true });
  37516. var Types_1 = require("../Types");
  37517. var BaseRenderLayer_1 = require("./BaseRenderLayer");
  37518. var LinkRenderLayer = (function (_super) {
  37519. __extends(LinkRenderLayer, _super);
  37520. function LinkRenderLayer(container, zIndex, colors, terminal) {
  37521. var _this = _super.call(this, container, 'link', zIndex, true, colors) || this;
  37522. _this._state = null;
  37523. terminal.linkifier.on(Types_1.LinkHoverEventTypes.HOVER, function (e) { return _this._onLinkHover(e); });
  37524. terminal.linkifier.on(Types_1.LinkHoverEventTypes.LEAVE, function (e) { return _this._onLinkLeave(e); });
  37525. return _this;
  37526. }
  37527. LinkRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
  37528. _super.prototype.resize.call(this, terminal, dim, charSizeChanged);
  37529. this._state = null;
  37530. };
  37531. LinkRenderLayer.prototype.reset = function (terminal) {
  37532. this._clearCurrentLink();
  37533. };
  37534. LinkRenderLayer.prototype._clearCurrentLink = function () {
  37535. if (this._state) {
  37536. this.clearCells(this._state.x, this._state.y, this._state.length, 1);
  37537. this._state = null;
  37538. }
  37539. };
  37540. LinkRenderLayer.prototype._onLinkHover = function (e) {
  37541. this._ctx.fillStyle = this._colors.foreground;
  37542. this.fillBottomLineAtCells(e.x, e.y, e.length);
  37543. this._state = e;
  37544. };
  37545. LinkRenderLayer.prototype._onLinkLeave = function (e) {
  37546. this._clearCurrentLink();
  37547. };
  37548. return LinkRenderLayer;
  37549. }(BaseRenderLayer_1.BaseRenderLayer));
  37550. exports.LinkRenderLayer = LinkRenderLayer;
  37551. },{"../Types":14,"./BaseRenderLayer":19}],25:[function(require,module,exports){
  37552. "use strict";
  37553. var __extends = (this && this.__extends) || (function () {
  37554. var extendStatics = Object.setPrototypeOf ||
  37555. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37556. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37557. return function (d, b) {
  37558. extendStatics(d, b);
  37559. function __() { this.constructor = d; }
  37560. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37561. };
  37562. })();
  37563. Object.defineProperty(exports, "__esModule", { value: true });
  37564. var TextRenderLayer_1 = require("./TextRenderLayer");
  37565. var SelectionRenderLayer_1 = require("./SelectionRenderLayer");
  37566. var CursorRenderLayer_1 = require("./CursorRenderLayer");
  37567. var ColorManager_1 = require("./ColorManager");
  37568. var LinkRenderLayer_1 = require("./LinkRenderLayer");
  37569. var EventEmitter_1 = require("../EventEmitter");
  37570. var ScreenDprMonitor_1 = require("../utils/ScreenDprMonitor");
  37571. var Renderer = (function (_super) {
  37572. __extends(Renderer, _super);
  37573. function Renderer(_terminal, theme) {
  37574. var _this = _super.call(this) || this;
  37575. _this._terminal = _terminal;
  37576. _this._refreshRowsQueue = [];
  37577. _this._refreshAnimationFrame = null;
  37578. _this._isPaused = false;
  37579. _this._needsFullRefresh = false;
  37580. _this.colorManager = new ColorManager_1.ColorManager();
  37581. if (theme) {
  37582. _this.colorManager.setTheme(theme);
  37583. }
  37584. _this._renderLayers = [
  37585. new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this.colorManager.colors, _this._terminal.options.allowTransparency),
  37586. new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.screenElement, 1, _this.colorManager.colors),
  37587. new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.screenElement, 2, _this.colorManager.colors, _this._terminal),
  37588. new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.screenElement, 3, _this.colorManager.colors)
  37589. ];
  37590. _this.dimensions = {
  37591. scaledCharWidth: null,
  37592. scaledCharHeight: null,
  37593. scaledCellWidth: null,
  37594. scaledCellHeight: null,
  37595. scaledCharLeft: null,
  37596. scaledCharTop: null,
  37597. scaledCanvasWidth: null,
  37598. scaledCanvasHeight: null,
  37599. canvasWidth: null,
  37600. canvasHeight: null,
  37601. actualCellWidth: null,
  37602. actualCellHeight: null
  37603. };
  37604. _this._devicePixelRatio = window.devicePixelRatio;
  37605. _this._updateDimensions();
  37606. _this.onOptionsChanged();
  37607. _this._screenDprMonitor = new ScreenDprMonitor_1.ScreenDprMonitor();
  37608. _this._screenDprMonitor.setListener(function () { return _this.onWindowResize(window.devicePixelRatio); });
  37609. if ('IntersectionObserver' in window) {
  37610. var observer = new IntersectionObserver(function (e) { return _this.onIntersectionChange(e[0]); }, { threshold: 0 });
  37611. observer.observe(_this._terminal.element);
  37612. }
  37613. return _this;
  37614. }
  37615. Renderer.prototype.onIntersectionChange = function (entry) {
  37616. this._isPaused = entry.intersectionRatio === 0;
  37617. if (!this._isPaused && this._needsFullRefresh) {
  37618. this._terminal.refresh(0, this._terminal.rows - 1);
  37619. }
  37620. };
  37621. Renderer.prototype.onWindowResize = function (devicePixelRatio) {
  37622. if (this._devicePixelRatio !== devicePixelRatio) {
  37623. this._devicePixelRatio = devicePixelRatio;
  37624. this.onResize(this._terminal.cols, this._terminal.rows, true);
  37625. }
  37626. };
  37627. Renderer.prototype.setTheme = function (theme) {
  37628. var _this = this;
  37629. this.colorManager.setTheme(theme);
  37630. this._renderLayers.forEach(function (l) {
  37631. l.onThemeChanged(_this._terminal, _this.colorManager.colors);
  37632. l.reset(_this._terminal);
  37633. });
  37634. if (this._isPaused) {
  37635. this._needsFullRefresh = true;
  37636. }
  37637. else {
  37638. this._terminal.refresh(0, this._terminal.rows - 1);
  37639. }
  37640. return this.colorManager.colors;
  37641. };
  37642. Renderer.prototype.onResize = function (cols, rows, didCharSizeChange) {
  37643. var _this = this;
  37644. this._updateDimensions();
  37645. this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions, didCharSizeChange); });
  37646. if (this._isPaused) {
  37647. this._needsFullRefresh = true;
  37648. }
  37649. else {
  37650. this._terminal.refresh(0, this._terminal.rows - 1);
  37651. }
  37652. this._terminal.screenElement.style.width = this.dimensions.canvasWidth + this._terminal.viewport.scrollBarWidth + "px";
  37653. this._terminal.screenElement.style.height = this.dimensions.canvasHeight + "px";
  37654. this.emit('resize', {
  37655. width: this.dimensions.canvasWidth,
  37656. height: this.dimensions.canvasHeight
  37657. });
  37658. };
  37659. Renderer.prototype.onCharSizeChanged = function () {
  37660. this.onResize(this._terminal.cols, this._terminal.rows, true);
  37661. };
  37662. Renderer.prototype.onBlur = function () {
  37663. var _this = this;
  37664. this._runOperation(function (l) { return l.onBlur(_this._terminal); });
  37665. };
  37666. Renderer.prototype.onFocus = function () {
  37667. var _this = this;
  37668. this._runOperation(function (l) { return l.onFocus(_this._terminal); });
  37669. };
  37670. Renderer.prototype.onSelectionChanged = function (start, end) {
  37671. var _this = this;
  37672. this._runOperation(function (l) { return l.onSelectionChanged(_this._terminal, start, end); });
  37673. };
  37674. Renderer.prototype.onCursorMove = function () {
  37675. var _this = this;
  37676. this._runOperation(function (l) { return l.onCursorMove(_this._terminal); });
  37677. };
  37678. Renderer.prototype.onOptionsChanged = function () {
  37679. var _this = this;
  37680. this._runOperation(function (l) { return l.onOptionsChanged(_this._terminal); });
  37681. };
  37682. Renderer.prototype.clear = function () {
  37683. var _this = this;
  37684. this._runOperation(function (l) { return l.reset(_this._terminal); });
  37685. };
  37686. Renderer.prototype._runOperation = function (operation) {
  37687. if (this._isPaused) {
  37688. this._needsFullRefresh = true;
  37689. }
  37690. else {
  37691. this._renderLayers.forEach(function (l) { return operation(l); });
  37692. }
  37693. };
  37694. Renderer.prototype.queueRefresh = function (start, end) {
  37695. if (this._isPaused) {
  37696. this._needsFullRefresh = true;
  37697. return;
  37698. }
  37699. this._refreshRowsQueue.push({ start: start, end: end });
  37700. if (!this._refreshAnimationFrame) {
  37701. this._refreshAnimationFrame = window.requestAnimationFrame(this._refreshLoop.bind(this));
  37702. }
  37703. };
  37704. Renderer.prototype._refreshLoop = function () {
  37705. var _this = this;
  37706. var start;
  37707. var end;
  37708. if (this._refreshRowsQueue.length > 4) {
  37709. start = 0;
  37710. end = this._terminal.rows - 1;
  37711. }
  37712. else {
  37713. start = this._refreshRowsQueue[0].start;
  37714. end = this._refreshRowsQueue[0].end;
  37715. for (var i = 1; i < this._refreshRowsQueue.length; i++) {
  37716. if (this._refreshRowsQueue[i].start < start) {
  37717. start = this._refreshRowsQueue[i].start;
  37718. }
  37719. if (this._refreshRowsQueue[i].end > end) {
  37720. end = this._refreshRowsQueue[i].end;
  37721. }
  37722. }
  37723. }
  37724. this._refreshRowsQueue = [];
  37725. this._refreshAnimationFrame = null;
  37726. start = Math.max(start, 0);
  37727. end = Math.min(end, this._terminal.rows - 1);
  37728. this._renderLayers.forEach(function (l) { return l.onGridChanged(_this._terminal, start, end); });
  37729. this._terminal.emit('refresh', { start: start, end: end });
  37730. };
  37731. Renderer.prototype._updateDimensions = function () {
  37732. if (!this._terminal.charMeasure.width || !this._terminal.charMeasure.height) {
  37733. return;
  37734. }
  37735. this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
  37736. this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
  37737. this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
  37738. this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);
  37739. this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
  37740. this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);
  37741. this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight;
  37742. this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth;
  37743. this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
  37744. this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
  37745. this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
  37746. this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
  37747. };
  37748. return Renderer;
  37749. }(EventEmitter_1.EventEmitter));
  37750. exports.Renderer = Renderer;
  37751. },{"../EventEmitter":7,"../utils/ScreenDprMonitor":34,"./ColorManager":21,"./CursorRenderLayer":22,"./LinkRenderLayer":24,"./SelectionRenderLayer":26,"./TextRenderLayer":27}],26:[function(require,module,exports){
  37752. "use strict";
  37753. var __extends = (this && this.__extends) || (function () {
  37754. var extendStatics = Object.setPrototypeOf ||
  37755. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37756. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37757. return function (d, b) {
  37758. extendStatics(d, b);
  37759. function __() { this.constructor = d; }
  37760. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37761. };
  37762. })();
  37763. Object.defineProperty(exports, "__esModule", { value: true });
  37764. var BaseRenderLayer_1 = require("./BaseRenderLayer");
  37765. var SelectionRenderLayer = (function (_super) {
  37766. __extends(SelectionRenderLayer, _super);
  37767. function SelectionRenderLayer(container, zIndex, colors) {
  37768. var _this = _super.call(this, container, 'selection', zIndex, true, colors) || this;
  37769. _this._state = {
  37770. start: null,
  37771. end: null
  37772. };
  37773. return _this;
  37774. }
  37775. SelectionRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
  37776. _super.prototype.resize.call(this, terminal, dim, charSizeChanged);
  37777. this._state = {
  37778. start: null,
  37779. end: null
  37780. };
  37781. };
  37782. SelectionRenderLayer.prototype.reset = function (terminal) {
  37783. if (this._state.start && this._state.end) {
  37784. this._state = {
  37785. start: null,
  37786. end: null
  37787. };
  37788. this.clearAll();
  37789. }
  37790. };
  37791. SelectionRenderLayer.prototype.onSelectionChanged = function (terminal, start, end) {
  37792. if (this._state.start === start || this._state.end === end) {
  37793. return;
  37794. }
  37795. this.clearAll();
  37796. if (!start || !end) {
  37797. return;
  37798. }
  37799. var viewportStartRow = start[1] - terminal.buffer.ydisp;
  37800. var viewportEndRow = end[1] - terminal.buffer.ydisp;
  37801. var viewportCappedStartRow = Math.max(viewportStartRow, 0);
  37802. var viewportCappedEndRow = Math.min(viewportEndRow, terminal.rows - 1);
  37803. if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {
  37804. return;
  37805. }
  37806. var startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
  37807. var startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
  37808. this._ctx.fillStyle = this._colors.selection;
  37809. this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
  37810. var middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);
  37811. this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);
  37812. if (viewportCappedStartRow !== viewportCappedEndRow) {
  37813. var endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;
  37814. this.fillCells(0, viewportCappedEndRow, endCol, 1);
  37815. }
  37816. this._state.start = [start[0], start[1]];
  37817. this._state.end = [end[0], end[1]];
  37818. };
  37819. return SelectionRenderLayer;
  37820. }(BaseRenderLayer_1.BaseRenderLayer));
  37821. exports.SelectionRenderLayer = SelectionRenderLayer;
  37822. },{"./BaseRenderLayer":19}],27:[function(require,module,exports){
  37823. "use strict";
  37824. var __extends = (this && this.__extends) || (function () {
  37825. var extendStatics = Object.setPrototypeOf ||
  37826. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37827. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37828. return function (d, b) {
  37829. extendStatics(d, b);
  37830. function __() { this.constructor = d; }
  37831. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37832. };
  37833. })();
  37834. Object.defineProperty(exports, "__esModule", { value: true });
  37835. var Buffer_1 = require("../Buffer");
  37836. var Types_1 = require("./Types");
  37837. var GridCache_1 = require("./GridCache");
  37838. var BaseRenderLayer_1 = require("./BaseRenderLayer");
  37839. var OVERLAP_OWNED_CHAR_DATA = [null, '', 0, -1];
  37840. var TextRenderLayer = (function (_super) {
  37841. __extends(TextRenderLayer, _super);
  37842. function TextRenderLayer(container, zIndex, colors, alpha) {
  37843. var _this = _super.call(this, container, 'text', zIndex, alpha, colors) || this;
  37844. _this._characterOverlapCache = {};
  37845. _this._state = new GridCache_1.GridCache();
  37846. return _this;
  37847. }
  37848. TextRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
  37849. _super.prototype.resize.call(this, terminal, dim, charSizeChanged);
  37850. var terminalFont = this._getFont(terminal, false);
  37851. if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {
  37852. this._characterWidth = dim.scaledCharWidth;
  37853. this._characterFont = terminalFont;
  37854. this._characterOverlapCache = {};
  37855. }
  37856. this._state.clear();
  37857. this._state.resize(terminal.cols, terminal.rows);
  37858. };
  37859. TextRenderLayer.prototype.reset = function (terminal) {
  37860. this._state.clear();
  37861. this.clearAll();
  37862. };
  37863. TextRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) {
  37864. if (this._state.cache.length === 0) {
  37865. return;
  37866. }
  37867. for (var y = startRow; y <= endRow; y++) {
  37868. var row = y + terminal.buffer.ydisp;
  37869. var line = terminal.buffer.lines.get(row);
  37870. this.clearCells(0, y, terminal.cols, 1);
  37871. for (var x = 0; x < terminal.cols; x++) {
  37872. var charData = line[x];
  37873. var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];
  37874. var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];
  37875. var attr = charData[Buffer_1.CHAR_DATA_ATTR_INDEX];
  37876. var width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
  37877. if (width === 0) {
  37878. continue;
  37879. }
  37880. if (code === 32) {
  37881. if (x > 0) {
  37882. var previousChar = line[x - 1];
  37883. if (this._isOverlapping(previousChar)) {
  37884. continue;
  37885. }
  37886. }
  37887. }
  37888. var flags = attr >> 18;
  37889. var bg = attr & 0x1ff;
  37890. var isDefaultBackground = bg >= 256;
  37891. var isInvisible = flags & Types_1.FLAGS.INVISIBLE;
  37892. var isInverted = flags & Types_1.FLAGS.INVERSE;
  37893. if (!code || (code === 32 && isDefaultBackground && !isInverted) || isInvisible) {
  37894. continue;
  37895. }
  37896. if (width !== 0 && this._isOverlapping(charData)) {
  37897. if (x < line.length - 1 && line[x + 1][Buffer_1.CHAR_DATA_CODE_INDEX] === 32) {
  37898. width = 2;
  37899. }
  37900. }
  37901. var fg = (attr >> 9) & 0x1ff;
  37902. if (isInverted) {
  37903. var temp = bg;
  37904. bg = fg;
  37905. fg = temp;
  37906. if (fg === 256) {
  37907. fg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
  37908. }
  37909. if (bg === 257) {
  37910. bg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
  37911. }
  37912. }
  37913. if (width === 2) {
  37914. }
  37915. if (bg < 256) {
  37916. this._ctx.save();
  37917. this._ctx.fillStyle = (bg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);
  37918. this.fillCells(x, y, width, 1);
  37919. this._ctx.restore();
  37920. }
  37921. this._ctx.save();
  37922. if (flags & Types_1.FLAGS.BOLD) {
  37923. this._ctx.font = this._getFont(terminal, true);
  37924. if (fg < 8) {
  37925. fg += 8;
  37926. }
  37927. }
  37928. if (flags & Types_1.FLAGS.UNDERLINE) {
  37929. if (fg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR) {
  37930. this._ctx.fillStyle = this._colors.background;
  37931. }
  37932. else if (fg < 256) {
  37933. this._ctx.fillStyle = this._colors.ansi[fg];
  37934. }
  37935. else {
  37936. this._ctx.fillStyle = this._colors.foreground;
  37937. }
  37938. this.fillBottomLineAtCells(x, y);
  37939. }
  37940. this.drawChar(terminal, char, code, width, x, y, fg, bg, !!(flags & Types_1.FLAGS.BOLD), !!(flags & Types_1.FLAGS.DIM));
  37941. this._ctx.restore();
  37942. }
  37943. }
  37944. };
  37945. TextRenderLayer.prototype.onOptionsChanged = function (terminal) {
  37946. this.setTransparency(terminal, terminal.options.allowTransparency);
  37947. };
  37948. TextRenderLayer.prototype._isOverlapping = function (charData) {
  37949. if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] !== 1) {
  37950. return false;
  37951. }
  37952. var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];
  37953. if (code < 256) {
  37954. return false;
  37955. }
  37956. var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];
  37957. if (this._characterOverlapCache.hasOwnProperty(char)) {
  37958. return this._characterOverlapCache[char];
  37959. }
  37960. this._ctx.save();
  37961. this._ctx.font = this._characterFont;
  37962. var overlaps = Math.floor(this._ctx.measureText(char).width) > this._characterWidth;
  37963. this._ctx.restore();
  37964. this._characterOverlapCache[char] = overlaps;
  37965. return overlaps;
  37966. };
  37967. TextRenderLayer.prototype._clearChar = function (x, y) {
  37968. var colsToClear = 1;
  37969. var state = this._state.cache[x][y];
  37970. if (state && state[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
  37971. colsToClear = 2;
  37972. }
  37973. this.clearCells(x, y, colsToClear, 1);
  37974. };
  37975. return TextRenderLayer;
  37976. }(BaseRenderLayer_1.BaseRenderLayer));
  37977. exports.TextRenderLayer = TextRenderLayer;
  37978. },{"../Buffer":1,"./BaseRenderLayer":19,"./GridCache":23,"./Types":28}],28:[function(require,module,exports){
  37979. "use strict";
  37980. Object.defineProperty(exports, "__esModule", { value: true });
  37981. var FLAGS;
  37982. (function (FLAGS) {
  37983. FLAGS[FLAGS["BOLD"] = 1] = "BOLD";
  37984. FLAGS[FLAGS["UNDERLINE"] = 2] = "UNDERLINE";
  37985. FLAGS[FLAGS["BLINK"] = 4] = "BLINK";
  37986. FLAGS[FLAGS["INVERSE"] = 8] = "INVERSE";
  37987. FLAGS[FLAGS["INVISIBLE"] = 16] = "INVISIBLE";
  37988. FLAGS[FLAGS["DIM"] = 32] = "DIM";
  37989. })(FLAGS = exports.FLAGS || (exports.FLAGS = {}));
  37990. },{}],29:[function(require,module,exports){
  37991. "use strict";
  37992. Object.defineProperty(exports, "__esModule", { value: true });
  37993. var Browser_1 = require("./utils/Browser");
  37994. exports.CHAR_ATLAS_CELL_SPACING = 1;
  37995. function generateCharAtlas(context, canvasFactory, request) {
  37996. var cellWidth = request.scaledCharWidth + exports.CHAR_ATLAS_CELL_SPACING;
  37997. var cellHeight = request.scaledCharHeight + exports.CHAR_ATLAS_CELL_SPACING;
  37998. var canvas = canvasFactory(255 * cellWidth, (2 + 16) * cellHeight);
  37999. var ctx = canvas.getContext('2d', { alpha: request.allowTransparency });
  38000. ctx.fillStyle = request.background;
  38001. ctx.fillRect(0, 0, canvas.width, canvas.height);
  38002. ctx.save();
  38003. ctx.fillStyle = request.foreground;
  38004. ctx.font = getFont(request.fontWeight, request);
  38005. ctx.textBaseline = 'top';
  38006. for (var i = 0; i < 256; i++) {
  38007. ctx.save();
  38008. ctx.beginPath();
  38009. ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);
  38010. ctx.clip();
  38011. ctx.fillText(String.fromCharCode(i), i * cellWidth, 0);
  38012. ctx.restore();
  38013. }
  38014. ctx.save();
  38015. ctx.font = getFont(request.fontWeightBold, request);
  38016. for (var i = 0; i < 256; i++) {
  38017. ctx.save();
  38018. ctx.beginPath();
  38019. ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);
  38020. ctx.clip();
  38021. ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight);
  38022. ctx.restore();
  38023. }
  38024. ctx.restore();
  38025. ctx.font = getFont(request.fontWeight, request);
  38026. for (var colorIndex = 0; colorIndex < 16; colorIndex++) {
  38027. if (colorIndex === 8) {
  38028. ctx.font = getFont(request.fontWeightBold, request);
  38029. }
  38030. var y = (colorIndex + 2) * cellHeight;
  38031. for (var i = 0; i < 256; i++) {
  38032. ctx.save();
  38033. ctx.beginPath();
  38034. ctx.rect(i * cellWidth, y, cellWidth, cellHeight);
  38035. ctx.clip();
  38036. ctx.fillStyle = request.ansiColors[colorIndex];
  38037. ctx.fillText(String.fromCharCode(i), i * cellWidth, y);
  38038. ctx.restore();
  38039. }
  38040. }
  38041. ctx.restore();
  38042. if (!('createImageBitmap' in context) || Browser_1.isFirefox) {
  38043. if (canvas instanceof HTMLCanvasElement) {
  38044. return canvas;
  38045. }
  38046. else {
  38047. return new Promise(function (r) { return r(canvas.transferToImageBitmap()); });
  38048. }
  38049. }
  38050. var charAtlasImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  38051. var r = parseInt(request.background.substr(1, 2), 16);
  38052. var g = parseInt(request.background.substr(3, 2), 16);
  38053. var b = parseInt(request.background.substr(5, 2), 16);
  38054. clearColor(charAtlasImageData, r, g, b);
  38055. return context.createImageBitmap(charAtlasImageData);
  38056. }
  38057. exports.generateCharAtlas = generateCharAtlas;
  38058. function clearColor(imageData, r, g, b) {
  38059. for (var offset = 0; offset < imageData.data.length; offset += 4) {
  38060. if (imageData.data[offset] === r &&
  38061. imageData.data[offset + 1] === g &&
  38062. imageData.data[offset + 2] === b) {
  38063. imageData.data[offset + 3] = 0;
  38064. }
  38065. }
  38066. }
  38067. function getFont(fontWeight, request) {
  38068. return fontWeight + " " + request.fontSize * request.devicePixelRatio + "px " + request.fontFamily;
  38069. }
  38070. },{"./utils/Browser":30}],30:[function(require,module,exports){
  38071. "use strict";
  38072. Object.defineProperty(exports, "__esModule", { value: true });
  38073. var isNode = (typeof navigator === 'undefined') ? true : false;
  38074. var userAgent = (isNode) ? 'node' : navigator.userAgent;
  38075. var platform = (isNode) ? 'node' : navigator.platform;
  38076. exports.isFirefox = !!~userAgent.indexOf('Firefox');
  38077. exports.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
  38078. exports.isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
  38079. exports.isIpad = platform === 'iPad';
  38080. exports.isIphone = platform === 'iPhone';
  38081. exports.isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
  38082. exports.isLinux = platform.indexOf('Linux') >= 0;
  38083. function contains(arr, el) {
  38084. return arr.indexOf(el) >= 0;
  38085. }
  38086. },{}],31:[function(require,module,exports){
  38087. "use strict";
  38088. var __extends = (this && this.__extends) || (function () {
  38089. var extendStatics = Object.setPrototypeOf ||
  38090. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38091. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38092. return function (d, b) {
  38093. extendStatics(d, b);
  38094. function __() { this.constructor = d; }
  38095. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38096. };
  38097. })();
  38098. Object.defineProperty(exports, "__esModule", { value: true });
  38099. var EventEmitter_1 = require("../EventEmitter");
  38100. var CharMeasure = (function (_super) {
  38101. __extends(CharMeasure, _super);
  38102. function CharMeasure(document, parentElement) {
  38103. var _this = _super.call(this) || this;
  38104. _this._document = document;
  38105. _this._parentElement = parentElement;
  38106. _this._measureElement = _this._document.createElement('span');
  38107. _this._measureElement.style.position = 'absolute';
  38108. _this._measureElement.style.top = '0';
  38109. _this._measureElement.style.left = '-9999em';
  38110. _this._measureElement.style.lineHeight = 'normal';
  38111. _this._measureElement.textContent = 'W';
  38112. _this._measureElement.setAttribute('aria-hidden', 'true');
  38113. _this._parentElement.appendChild(_this._measureElement);
  38114. return _this;
  38115. }
  38116. Object.defineProperty(CharMeasure.prototype, "width", {
  38117. get: function () {
  38118. return this._width;
  38119. },
  38120. enumerable: true,
  38121. configurable: true
  38122. });
  38123. Object.defineProperty(CharMeasure.prototype, "height", {
  38124. get: function () {
  38125. return this._height;
  38126. },
  38127. enumerable: true,
  38128. configurable: true
  38129. });
  38130. CharMeasure.prototype.measure = function (options) {
  38131. this._measureElement.style.fontFamily = options.fontFamily;
  38132. this._measureElement.style.fontSize = options.fontSize + "px";
  38133. var geometry = this._measureElement.getBoundingClientRect();
  38134. if (geometry.width === 0 || geometry.height === 0) {
  38135. return;
  38136. }
  38137. if (this._width !== geometry.width || this._height !== geometry.height) {
  38138. this._width = geometry.width;
  38139. this._height = Math.ceil(geometry.height);
  38140. this.emit('charsizechanged');
  38141. }
  38142. };
  38143. return CharMeasure;
  38144. }(EventEmitter_1.EventEmitter));
  38145. exports.CharMeasure = CharMeasure;
  38146. },{"../EventEmitter":7}],32:[function(require,module,exports){
  38147. "use strict";
  38148. var __extends = (this && this.__extends) || (function () {
  38149. var extendStatics = Object.setPrototypeOf ||
  38150. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38151. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38152. return function (d, b) {
  38153. extendStatics(d, b);
  38154. function __() { this.constructor = d; }
  38155. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38156. };
  38157. })();
  38158. Object.defineProperty(exports, "__esModule", { value: true });
  38159. var EventEmitter_1 = require("../EventEmitter");
  38160. var CircularList = (function (_super) {
  38161. __extends(CircularList, _super);
  38162. function CircularList(_maxLength) {
  38163. var _this = _super.call(this) || this;
  38164. _this._maxLength = _maxLength;
  38165. _this._array = new Array(_this._maxLength);
  38166. _this._startIndex = 0;
  38167. _this._length = 0;
  38168. return _this;
  38169. }
  38170. Object.defineProperty(CircularList.prototype, "maxLength", {
  38171. get: function () {
  38172. return this._maxLength;
  38173. },
  38174. set: function (newMaxLength) {
  38175. if (this._maxLength === newMaxLength) {
  38176. return;
  38177. }
  38178. var newArray = new Array(newMaxLength);
  38179. for (var i = 0; i < Math.min(newMaxLength, this.length); i++) {
  38180. newArray[i] = this._array[this._getCyclicIndex(i)];
  38181. }
  38182. this._array = newArray;
  38183. this._maxLength = newMaxLength;
  38184. this._startIndex = 0;
  38185. },
  38186. enumerable: true,
  38187. configurable: true
  38188. });
  38189. Object.defineProperty(CircularList.prototype, "length", {
  38190. get: function () {
  38191. return this._length;
  38192. },
  38193. set: function (newLength) {
  38194. if (newLength > this._length) {
  38195. for (var i = this._length; i < newLength; i++) {
  38196. this._array[i] = undefined;
  38197. }
  38198. }
  38199. this._length = newLength;
  38200. },
  38201. enumerable: true,
  38202. configurable: true
  38203. });
  38204. Object.defineProperty(CircularList.prototype, "forEach", {
  38205. get: function () {
  38206. var _this = this;
  38207. return function (callbackfn) {
  38208. var i = 0;
  38209. var length = _this.length;
  38210. for (var i_1 = 0; i_1 < length; i_1++) {
  38211. callbackfn(_this.get(i_1), i_1);
  38212. }
  38213. };
  38214. },
  38215. enumerable: true,
  38216. configurable: true
  38217. });
  38218. CircularList.prototype.get = function (index) {
  38219. return this._array[this._getCyclicIndex(index)];
  38220. };
  38221. CircularList.prototype.set = function (index, value) {
  38222. this._array[this._getCyclicIndex(index)] = value;
  38223. };
  38224. CircularList.prototype.push = function (value) {
  38225. this._array[this._getCyclicIndex(this._length)] = value;
  38226. if (this._length === this._maxLength) {
  38227. this._startIndex++;
  38228. if (this._startIndex === this._maxLength) {
  38229. this._startIndex = 0;
  38230. }
  38231. this.emit('trim', 1);
  38232. }
  38233. else {
  38234. this._length++;
  38235. }
  38236. };
  38237. CircularList.prototype.pop = function () {
  38238. return this._array[this._getCyclicIndex(this._length-- - 1)];
  38239. };
  38240. CircularList.prototype.splice = function (start, deleteCount) {
  38241. var items = [];
  38242. for (var _i = 2; _i < arguments.length; _i++) {
  38243. items[_i - 2] = arguments[_i];
  38244. }
  38245. if (deleteCount) {
  38246. for (var i = start; i < this._length - deleteCount; i++) {
  38247. this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
  38248. }
  38249. this._length -= deleteCount;
  38250. }
  38251. if (items && items.length) {
  38252. for (var i = this._length - 1; i >= start; i--) {
  38253. this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
  38254. }
  38255. for (var i = 0; i < items.length; i++) {
  38256. this._array[this._getCyclicIndex(start + i)] = items[i];
  38257. }
  38258. if (this._length + items.length > this.maxLength) {
  38259. var countToTrim = (this._length + items.length) - this.maxLength;
  38260. this._startIndex += countToTrim;
  38261. this._length = this.maxLength;
  38262. this.emit('trim', countToTrim);
  38263. }
  38264. else {
  38265. this._length += items.length;
  38266. }
  38267. }
  38268. };
  38269. CircularList.prototype.trimStart = function (count) {
  38270. if (count > this._length) {
  38271. count = this._length;
  38272. }
  38273. this._startIndex += count;
  38274. this._length -= count;
  38275. this.emit('trim', count);
  38276. };
  38277. CircularList.prototype.shiftElements = function (start, count, offset) {
  38278. if (count <= 0) {
  38279. return;
  38280. }
  38281. if (start < 0 || start >= this._length) {
  38282. throw new Error('start argument out of range');
  38283. }
  38284. if (start + offset < 0) {
  38285. throw new Error('Cannot shift elements in list beyond index 0');
  38286. }
  38287. if (offset > 0) {
  38288. for (var i = count - 1; i >= 0; i--) {
  38289. this.set(start + i + offset, this.get(start + i));
  38290. }
  38291. var expandListBy = (start + count + offset) - this._length;
  38292. if (expandListBy > 0) {
  38293. this._length += expandListBy;
  38294. while (this._length > this.maxLength) {
  38295. this._length--;
  38296. this._startIndex++;
  38297. this.emit('trim', 1);
  38298. }
  38299. }
  38300. }
  38301. else {
  38302. for (var i = 0; i < count; i++) {
  38303. this.set(start + i + offset, this.get(start + i));
  38304. }
  38305. }
  38306. };
  38307. CircularList.prototype._getCyclicIndex = function (index) {
  38308. return (this._startIndex + index) % this.maxLength;
  38309. };
  38310. return CircularList;
  38311. }(EventEmitter_1.EventEmitter));
  38312. exports.CircularList = CircularList;
  38313. },{"../EventEmitter":7}],33:[function(require,module,exports){
  38314. "use strict";
  38315. Object.defineProperty(exports, "__esModule", { value: true });
  38316. var MouseHelper = (function () {
  38317. function MouseHelper(_renderer) {
  38318. this._renderer = _renderer;
  38319. }
  38320. MouseHelper.getCoordsRelativeToElement = function (event, element) {
  38321. if (event.pageX == null) {
  38322. return null;
  38323. }
  38324. var originalElement = element;
  38325. var x = event.pageX;
  38326. var y = event.pageY;
  38327. while (element) {
  38328. x -= element.offsetLeft;
  38329. y -= element.offsetTop;
  38330. element = element.offsetParent;
  38331. }
  38332. element = originalElement;
  38333. while (element && element !== element.ownerDocument.body) {
  38334. x += element.scrollLeft;
  38335. y += element.scrollTop;
  38336. element = element.parentElement;
  38337. }
  38338. return [x, y];
  38339. };
  38340. MouseHelper.prototype.getCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount, isSelection) {
  38341. if (!charMeasure.width || !charMeasure.height) {
  38342. return null;
  38343. }
  38344. var coords = MouseHelper.getCoordsRelativeToElement(event, element);
  38345. if (!coords) {
  38346. return null;
  38347. }
  38348. coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);
  38349. coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);
  38350. coords[0] = Math.min(Math.max(coords[0], 1), colCount + (isSelection ? 1 : 0));
  38351. coords[1] = Math.min(Math.max(coords[1], 1), rowCount);
  38352. return coords;
  38353. };
  38354. MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, lineHeight, colCount, rowCount) {
  38355. var coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);
  38356. var x = coords[0];
  38357. var y = coords[1];
  38358. x += 32;
  38359. y += 32;
  38360. return { x: x, y: y };
  38361. };
  38362. return MouseHelper;
  38363. }());
  38364. exports.MouseHelper = MouseHelper;
  38365. },{}],34:[function(require,module,exports){
  38366. "use strict";
  38367. Object.defineProperty(exports, "__esModule", { value: true });
  38368. var ScreenDprMonitor = (function () {
  38369. function ScreenDprMonitor() {
  38370. }
  38371. ScreenDprMonitor.prototype.setListener = function (listener) {
  38372. var _this = this;
  38373. if (this._listener) {
  38374. this.clearListener();
  38375. }
  38376. this._listener = listener;
  38377. this._outerListener = function () {
  38378. _this._listener(window.devicePixelRatio, _this._currentDevicePixelRatio);
  38379. _this._updateDpr();
  38380. };
  38381. this._updateDpr();
  38382. };
  38383. ScreenDprMonitor.prototype._updateDpr = function () {
  38384. if (this._resolutionMediaMatchList) {
  38385. this._resolutionMediaMatchList.removeListener(this._outerListener);
  38386. }
  38387. this._currentDevicePixelRatio = window.devicePixelRatio;
  38388. this._resolutionMediaMatchList = window.matchMedia("screen and (resolution: " + window.devicePixelRatio + "dppx)");
  38389. this._resolutionMediaMatchList.addListener(this._outerListener);
  38390. };
  38391. ScreenDprMonitor.prototype.clearListener = function () {
  38392. if (!this._listener) {
  38393. return;
  38394. }
  38395. this._resolutionMediaMatchList.removeListener(this._outerListener);
  38396. this._listener = null;
  38397. this._outerListener = null;
  38398. };
  38399. return ScreenDprMonitor;
  38400. }());
  38401. exports.ScreenDprMonitor = ScreenDprMonitor;
  38402. },{}],35:[function(require,module,exports){
  38403. "use strict";
  38404. Object.defineProperty(exports, "__esModule", { value: true });
  38405. exports.BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
  38406. },{}],36:[function(require,module,exports){
  38407. "use strict";
  38408. Object.defineProperty(exports, "__esModule", { value: true });
  38409. var Terminal_1 = require("./Terminal");
  38410. module.exports = Terminal_1.Terminal;
  38411. },{"./Terminal":13}]},{},[36])(36)
  38412. });
  38413. //# sourceMappingURL=xterm.js.map
  38414. ;
  38415. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define('xtermjs-fit',[],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  38416. "use strict";
  38417. Object.defineProperty(exports, "__esModule", { value: true });
  38418. function proposeGeometry(term) {
  38419. if (!term.element.parentElement) {
  38420. return null;
  38421. }
  38422. var parentElementStyle = window.getComputedStyle(term.element.parentElement);
  38423. var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
  38424. var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
  38425. var elementStyle = window.getComputedStyle(term.element);
  38426. var elementPadding = {
  38427. top: parseInt(elementStyle.getPropertyValue('padding-top')),
  38428. bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
  38429. right: parseInt(elementStyle.getPropertyValue('padding-right')),
  38430. left: parseInt(elementStyle.getPropertyValue('padding-left'))
  38431. };
  38432. var elementPaddingVer = elementPadding.top + elementPadding.bottom;
  38433. var elementPaddingHor = elementPadding.right + elementPadding.left;
  38434. var availableHeight = parentElementHeight - elementPaddingVer;
  38435. var availableWidth = parentElementWidth - elementPaddingHor - term.viewport.scrollBarWidth;
  38436. var geometry = {
  38437. cols: Math.floor(availableWidth / term.renderer.dimensions.actualCellWidth),
  38438. rows: Math.floor(availableHeight / term.renderer.dimensions.actualCellHeight)
  38439. };
  38440. return geometry;
  38441. }
  38442. exports.proposeGeometry = proposeGeometry;
  38443. function fit(term) {
  38444. var geometry = proposeGeometry(term);
  38445. if (geometry) {
  38446. if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
  38447. term.renderer.clear();
  38448. term.resize(geometry.cols, geometry.rows);
  38449. }
  38450. }
  38451. }
  38452. exports.fit = fit;
  38453. function apply(terminalConstructor) {
  38454. terminalConstructor.prototype.proposeGeometry = function () {
  38455. return proposeGeometry(this);
  38456. };
  38457. terminalConstructor.prototype.fit = function () {
  38458. fit(this);
  38459. };
  38460. }
  38461. exports.apply = apply;
  38462. },{}]},{},[1])(1)
  38463. });
  38464. //# sourceMappingURL=fit.js.map
  38465. ;
  38466. define ('terminal/js/terminado',["xterm", "xtermjs-fit"], function(Terminal, fit) {
  38467. "use strict";
  38468. function make_terminal(element, ws_url) {
  38469. var ws = new WebSocket(ws_url);
  38470. Terminal.applyAddon(fit);
  38471. var term = new Terminal();
  38472. ws.onopen = function(event) {
  38473. term.on('data', function(data) {
  38474. ws.send(JSON.stringify(['stdin', data]));
  38475. });
  38476. term.on('title', function(title) {
  38477. document.title = title;
  38478. });
  38479. term.open(element);
  38480. term.fit();
  38481. // send the terminal size to the server.
  38482. ws.send(JSON.stringify(["set_size", term.rows, term.cols,
  38483. window.innerHeight, window.innerWidth]));
  38484. ws.onmessage = function(event) {
  38485. var json_msg = JSON.parse(event.data);
  38486. switch(json_msg[0]) {
  38487. case "stdout":
  38488. term.write(json_msg[1]);
  38489. break;
  38490. case "disconnect":
  38491. term.write("\r\n\r\n[CLOSED]\r\n");
  38492. break;
  38493. }
  38494. };
  38495. };
  38496. return {socket: ws, term: term};
  38497. }
  38498. return {make_terminal: make_terminal};
  38499. });
  38500. // Copyright (c) Jupyter Development Team.
  38501. // Distributed under the terms of the Modified BSD License.
  38502. requirejs([
  38503. 'jquery',
  38504. 'base/js/utils',
  38505. 'base/js/page',
  38506. 'auth/js/loginwidget',
  38507. 'services/config',
  38508. 'terminal/js/terminado',
  38509. ], function(
  38510. $,
  38511. utils,
  38512. page,
  38513. loginwidget,
  38514. configmod,
  38515. terminado
  38516. ){
  38517. "use strict";
  38518. requirejs(['custom/custom'], function() {});
  38519. page = new page.Page('div#header', 'div#site');
  38520. var common_options = {
  38521. base_url : utils.get_body_data("baseUrl"),
  38522. };
  38523. var config = new configmod.ConfigSection('terminal', common_options);
  38524. config.load();
  38525. var common_config = new configmod.ConfigSection('common', common_options);
  38526. common_config.load();
  38527. // This makes the 'logout' button in the top right work.
  38528. var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
  38529. var base_url = utils.get_body_data('baseUrl').replace(/\/?$/, '/');
  38530. var ws_path = utils.get_body_data('wsPath');
  38531. var ws_url = utils.get_body_data('wsUrl');
  38532. if (!ws_url) {
  38533. // trailing 's' in https will become wss for secure web sockets
  38534. ws_url = location.protocol.replace('http', 'ws') + "//" + location.host;
  38535. }
  38536. ws_url = ws_url + base_url + ws_path;
  38537. page.show_header();
  38538. var terminal = terminado.make_terminal($("#terminado-container")[0], ws_url);
  38539. page.show_site();
  38540. utils.load_extensions_from_config(config);
  38541. utils.load_extensions_from_config(common_config);
  38542. window.onresize = function() {
  38543. terminal.term.fit();
  38544. // send the new size to the server so that it can trigger a resize in the running process.
  38545. terminal.socket.send(JSON.stringify(["set_size", terminal.term.rows, terminal.term.cols,
  38546. $(window).height(), $(window).width()]));
  38547. };
  38548. // Expose terminal for fiddling with in the browser
  38549. window.terminal = terminal;
  38550. });
  38551. define("terminal/js/main", function(){});
  38552. //# sourceMappingURL=main.min.js.map