index.umd.js 273 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('cornerstone-core'), require('cornerstone-wado-image-loader'), require('dicom-parser'), require('react'), require('react-resize-detector'), require('cornerstone-tools')) :
  3. typeof define === 'function' && define.amd ? define(['cornerstone-core', 'cornerstone-wado-image-loader', 'dicom-parser', 'react', 'react-resize-detector', 'cornerstone-tools'], factory) :
  4. (global = global || self, global['react-cornerstone-viewport'] = factory(global.cornerstone, global.cornerstoneWADOImageLoader, global.dicomParser, global.React, global.ReactResizeDetector, global.cornerstoneTools));
  5. }(this, function (cornerstone, cornerstoneWADOImageLoader, dicomParser, React, ReactResizeDetector, cornerstoneTools) { 'use strict';
  6. cornerstone = cornerstone && cornerstone.hasOwnProperty('default') ? cornerstone['default'] : cornerstone;
  7. cornerstoneWADOImageLoader = cornerstoneWADOImageLoader && cornerstoneWADOImageLoader.hasOwnProperty('default') ? cornerstoneWADOImageLoader['default'] : cornerstoneWADOImageLoader;
  8. dicomParser = dicomParser && dicomParser.hasOwnProperty('default') ? dicomParser['default'] : dicomParser;
  9. var React__default = 'default' in React ? React['default'] : React;
  10. ReactResizeDetector = ReactResizeDetector && ReactResizeDetector.hasOwnProperty('default') ? ReactResizeDetector['default'] : ReactResizeDetector;
  11. cornerstoneTools = cornerstoneTools && cornerstoneTools.hasOwnProperty('default') ? cornerstoneTools['default'] : cornerstoneTools;
  12. var _cornerstoneWADOImage = cornerstoneWADOImageLoader.wadors.metaData,
  13. getNumberValue = _cornerstoneWADOImage.getNumberValue,
  14. getValue = _cornerstoneWADOImage.getValue;
  15. function wadoRsMetaDataProvider(type, imageId) {
  16. var metaData = cornerstoneWADOImageLoader.wadors.metaDataManager.get(imageId);
  17. if (!metaData) {
  18. return;
  19. }
  20. if (metaData[type] !== undefined && metaData[type].Value !== undefined && metaData[type].Value.length) {
  21. return metaData[type].Value[0];
  22. }
  23. var typeCleaned = type.replace('x', '');
  24. if (metaData[typeCleaned] !== undefined && metaData[typeCleaned].Value !== undefined && metaData[typeCleaned].Value.length) {
  25. return metaData[typeCleaned].Value[0];
  26. }
  27. if (type === 'generalImageModule') {
  28. return {
  29. instanceNumber: getNumberValue(metaData['00200013']),
  30. lossyImageCompression: getValue(metaData['00282110']),
  31. lossyImageCompressionRatio: getValue(metaData['00282112']),
  32. lossyImageCompressionMethod: getValue(metaData['00282114'])
  33. };
  34. }
  35. if (type === 'patientModule') {
  36. return {
  37. patientName: getValue(metaData['00100010']),
  38. patientId: getValue(metaData['00100020']),
  39. patientSex: getValue(metaData['00100040']),
  40. patientBirthDate: getValue(metaData['00100030'])
  41. };
  42. }
  43. if (type === 'spacingBetweenSlices') {
  44. return getValue(metaData['00180088']);
  45. }
  46. if (type === 'generalStudyModule') {
  47. return {
  48. studyDescription: getValue(metaData['00081030']),
  49. studyDate: getValue(metaData['00080020']),
  50. studyTime: getValue(metaData['00080030']),
  51. accessionNumber: getValue(metaData['00080050'])
  52. };
  53. }
  54. if (type === 'cineModule') {
  55. return {
  56. frameTime: getNumberValue(metaData['00181063'])
  57. };
  58. }
  59. }
  60. cornerstone.metaData.addProvider(wadoRsMetaDataProvider);
  61. function wadoUriMetaDataProvider(type, imageId) {
  62. var _cornerstoneWADOImage2 = cornerstoneWADOImageLoader.wadouri,
  63. parseImageId = _cornerstoneWADOImage2.parseImageId,
  64. dataSetCacheManager = _cornerstoneWADOImage2.dataSetCacheManager;
  65. var parsedImageId = parseImageId(imageId);
  66. var dataSet = dataSetCacheManager.get(parsedImageId.url);
  67. if (!dataSet) {
  68. return;
  69. }
  70. if (type === 'generalImageModule') {
  71. return {
  72. instanceNumber: dataSet.intString('x00200013'),
  73. lossyImageCompression: dataSet.string('x00282110'),
  74. lossyImageCompressionRatio: dataSet.string('x00282112'),
  75. lossyImageCompressionMethod: dataSet.string('x00282114')
  76. };
  77. }
  78. if (type === 'patientModule') {
  79. return {
  80. patientName: dataSet.string('x00100010'),
  81. patientId: dataSet.string('x00100020')
  82. };
  83. }
  84. if (type === 'generalStudyModule') {
  85. return {
  86. studyDescription: dataSet.string('x00081030'),
  87. studyDate: dataSet.string('x00080020'),
  88. studyTime: dataSet.string('x00080030')
  89. };
  90. }
  91. if (type === 'cineModule') {
  92. return {
  93. frameTime: dataSet.float('x00181063')
  94. };
  95. }
  96. if (dataSet.elements[type] !== undefined) {
  97. var element = dataSet.elements[type];
  98. if (!element.vr) {
  99. return;
  100. }
  101. return dicomParser.explicitElementToString(dataSet, element);
  102. }
  103. }
  104. cornerstone.metaData.addProvider(wadoUriMetaDataProvider);
  105. function _classCallCheck(instance, Constructor) {
  106. if (!(instance instanceof Constructor)) {
  107. throw new TypeError("Cannot call a class as a function");
  108. }
  109. }
  110. var classCallCheck = _classCallCheck;
  111. function _defineProperties(target, props) {
  112. for (var i = 0; i < props.length; i++) {
  113. var descriptor = props[i];
  114. descriptor.enumerable = descriptor.enumerable || false;
  115. descriptor.configurable = true;
  116. if ("value" in descriptor) descriptor.writable = true;
  117. Object.defineProperty(target, descriptor.key, descriptor);
  118. }
  119. }
  120. function _createClass(Constructor, protoProps, staticProps) {
  121. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  122. if (staticProps) _defineProperties(Constructor, staticProps);
  123. return Constructor;
  124. }
  125. var createClass = _createClass;
  126. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  127. function commonjsRequire () {
  128. throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
  129. }
  130. function unwrapExports (x) {
  131. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  132. }
  133. function createCommonjsModule(fn, module) {
  134. return module = { exports: {} }, fn(module, module.exports), module.exports;
  135. }
  136. var _typeof_1 = createCommonjsModule(function (module) {
  137. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  138. function _typeof(obj) {
  139. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  140. module.exports = _typeof = function _typeof(obj) {
  141. return _typeof2(obj);
  142. };
  143. } else {
  144. module.exports = _typeof = function _typeof(obj) {
  145. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  146. };
  147. }
  148. return _typeof(obj);
  149. }
  150. module.exports = _typeof;
  151. });
  152. function _assertThisInitialized(self) {
  153. if (self === void 0) {
  154. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  155. }
  156. return self;
  157. }
  158. var assertThisInitialized = _assertThisInitialized;
  159. function _possibleConstructorReturn(self, call) {
  160. if (call && (_typeof_1(call) === "object" || typeof call === "function")) {
  161. return call;
  162. }
  163. return assertThisInitialized(self);
  164. }
  165. var possibleConstructorReturn = _possibleConstructorReturn;
  166. var getPrototypeOf = createCommonjsModule(function (module) {
  167. function _getPrototypeOf(o) {
  168. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  169. return o.__proto__ || Object.getPrototypeOf(o);
  170. };
  171. return _getPrototypeOf(o);
  172. }
  173. module.exports = _getPrototypeOf;
  174. });
  175. var setPrototypeOf = createCommonjsModule(function (module) {
  176. function _setPrototypeOf(o, p) {
  177. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  178. o.__proto__ = p;
  179. return o;
  180. };
  181. return _setPrototypeOf(o, p);
  182. }
  183. module.exports = _setPrototypeOf;
  184. });
  185. function _inherits(subClass, superClass) {
  186. if (typeof superClass !== "function" && superClass !== null) {
  187. throw new TypeError("Super expression must either be null or a function");
  188. }
  189. subClass.prototype = Object.create(superClass && superClass.prototype, {
  190. constructor: {
  191. value: subClass,
  192. writable: true,
  193. configurable: true
  194. }
  195. });
  196. if (superClass) setPrototypeOf(subClass, superClass);
  197. }
  198. var inherits = _inherits;
  199. function _defineProperty(obj, key, value) {
  200. if (key in obj) {
  201. Object.defineProperty(obj, key, {
  202. value: value,
  203. enumerable: true,
  204. configurable: true,
  205. writable: true
  206. });
  207. } else {
  208. obj[key] = value;
  209. }
  210. return obj;
  211. }
  212. var defineProperty = _defineProperty;
  213. var reactIs_production_min = createCommonjsModule(function (module, exports) {
  214. Object.defineProperty(exports,"__esModule",{value:!0});
  215. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
  216. 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118;function x(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
  217. exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
  218. exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
  219. exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
  220. });
  221. unwrapExports(reactIs_production_min);
  222. var reactIs_production_min_1 = reactIs_production_min.typeOf;
  223. var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
  224. var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
  225. var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
  226. var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
  227. var reactIs_production_min_6 = reactIs_production_min.Element;
  228. var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
  229. var reactIs_production_min_8 = reactIs_production_min.Fragment;
  230. var reactIs_production_min_9 = reactIs_production_min.Lazy;
  231. var reactIs_production_min_10 = reactIs_production_min.Memo;
  232. var reactIs_production_min_11 = reactIs_production_min.Portal;
  233. var reactIs_production_min_12 = reactIs_production_min.Profiler;
  234. var reactIs_production_min_13 = reactIs_production_min.StrictMode;
  235. var reactIs_production_min_14 = reactIs_production_min.Suspense;
  236. var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
  237. var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
  238. var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
  239. var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
  240. var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
  241. var reactIs_production_min_20 = reactIs_production_min.isElement;
  242. var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
  243. var reactIs_production_min_22 = reactIs_production_min.isFragment;
  244. var reactIs_production_min_23 = reactIs_production_min.isLazy;
  245. var reactIs_production_min_24 = reactIs_production_min.isMemo;
  246. var reactIs_production_min_25 = reactIs_production_min.isPortal;
  247. var reactIs_production_min_26 = reactIs_production_min.isProfiler;
  248. var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
  249. var reactIs_production_min_28 = reactIs_production_min.isSuspense;
  250. var reactIs_development = createCommonjsModule(function (module, exports) {
  251. if (process.env.NODE_ENV !== "production") {
  252. (function() {
  253. Object.defineProperty(exports, '__esModule', { value: true });
  254. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  255. // nor polyfill, then a plain number is used for performance.
  256. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  257. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  258. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  259. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  260. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  261. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  262. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  263. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  264. // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  265. // (unstable) APIs that have been removed. Can we remove the symbols?
  266. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  267. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  268. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  269. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  270. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  271. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  272. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  273. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  274. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  275. function isValidElementType(type) {
  276. return typeof type === 'string' || typeof type === 'function' ||
  277. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  278. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
  279. }
  280. /**
  281. * Forked from fbjs/warning:
  282. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  283. *
  284. * Only change is we use console.warn instead of console.error,
  285. * and do nothing when 'console' is not supported.
  286. * This really simplifies the code.
  287. * ---
  288. * Similar to invariant but only logs a warning if the condition is not met.
  289. * This can be used to log issues in development environments in critical
  290. * paths. Removing the logging code for production environments will keep the
  291. * same logic and follow the same code paths.
  292. */
  293. var lowPriorityWarning = function () {};
  294. {
  295. var printWarning = function (format) {
  296. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  297. args[_key - 1] = arguments[_key];
  298. }
  299. var argIndex = 0;
  300. var message = 'Warning: ' + format.replace(/%s/g, function () {
  301. return args[argIndex++];
  302. });
  303. if (typeof console !== 'undefined') {
  304. console.warn(message);
  305. }
  306. try {
  307. // --- Welcome to debugging React ---
  308. // This error was thrown as a convenience so that you can use this stack
  309. // to find the callsite that caused this warning to fire.
  310. throw new Error(message);
  311. } catch (x) {}
  312. };
  313. lowPriorityWarning = function (condition, format) {
  314. if (format === undefined) {
  315. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  316. }
  317. if (!condition) {
  318. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  319. args[_key2 - 2] = arguments[_key2];
  320. }
  321. printWarning.apply(undefined, [format].concat(args));
  322. }
  323. };
  324. }
  325. var lowPriorityWarning$1 = lowPriorityWarning;
  326. function typeOf(object) {
  327. if (typeof object === 'object' && object !== null) {
  328. var $$typeof = object.$$typeof;
  329. switch ($$typeof) {
  330. case REACT_ELEMENT_TYPE:
  331. var type = object.type;
  332. switch (type) {
  333. case REACT_ASYNC_MODE_TYPE:
  334. case REACT_CONCURRENT_MODE_TYPE:
  335. case REACT_FRAGMENT_TYPE:
  336. case REACT_PROFILER_TYPE:
  337. case REACT_STRICT_MODE_TYPE:
  338. case REACT_SUSPENSE_TYPE:
  339. return type;
  340. default:
  341. var $$typeofType = type && type.$$typeof;
  342. switch ($$typeofType) {
  343. case REACT_CONTEXT_TYPE:
  344. case REACT_FORWARD_REF_TYPE:
  345. case REACT_PROVIDER_TYPE:
  346. return $$typeofType;
  347. default:
  348. return $$typeof;
  349. }
  350. }
  351. case REACT_LAZY_TYPE:
  352. case REACT_MEMO_TYPE:
  353. case REACT_PORTAL_TYPE:
  354. return $$typeof;
  355. }
  356. }
  357. return undefined;
  358. }
  359. // AsyncMode is deprecated along with isAsyncMode
  360. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  361. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  362. var ContextConsumer = REACT_CONTEXT_TYPE;
  363. var ContextProvider = REACT_PROVIDER_TYPE;
  364. var Element = REACT_ELEMENT_TYPE;
  365. var ForwardRef = REACT_FORWARD_REF_TYPE;
  366. var Fragment = REACT_FRAGMENT_TYPE;
  367. var Lazy = REACT_LAZY_TYPE;
  368. var Memo = REACT_MEMO_TYPE;
  369. var Portal = REACT_PORTAL_TYPE;
  370. var Profiler = REACT_PROFILER_TYPE;
  371. var StrictMode = REACT_STRICT_MODE_TYPE;
  372. var Suspense = REACT_SUSPENSE_TYPE;
  373. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  374. // AsyncMode should be deprecated
  375. function isAsyncMode(object) {
  376. {
  377. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  378. hasWarnedAboutDeprecatedIsAsyncMode = true;
  379. lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  380. }
  381. }
  382. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  383. }
  384. function isConcurrentMode(object) {
  385. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  386. }
  387. function isContextConsumer(object) {
  388. return typeOf(object) === REACT_CONTEXT_TYPE;
  389. }
  390. function isContextProvider(object) {
  391. return typeOf(object) === REACT_PROVIDER_TYPE;
  392. }
  393. function isElement(object) {
  394. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  395. }
  396. function isForwardRef(object) {
  397. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  398. }
  399. function isFragment(object) {
  400. return typeOf(object) === REACT_FRAGMENT_TYPE;
  401. }
  402. function isLazy(object) {
  403. return typeOf(object) === REACT_LAZY_TYPE;
  404. }
  405. function isMemo(object) {
  406. return typeOf(object) === REACT_MEMO_TYPE;
  407. }
  408. function isPortal(object) {
  409. return typeOf(object) === REACT_PORTAL_TYPE;
  410. }
  411. function isProfiler(object) {
  412. return typeOf(object) === REACT_PROFILER_TYPE;
  413. }
  414. function isStrictMode(object) {
  415. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  416. }
  417. function isSuspense(object) {
  418. return typeOf(object) === REACT_SUSPENSE_TYPE;
  419. }
  420. exports.typeOf = typeOf;
  421. exports.AsyncMode = AsyncMode;
  422. exports.ConcurrentMode = ConcurrentMode;
  423. exports.ContextConsumer = ContextConsumer;
  424. exports.ContextProvider = ContextProvider;
  425. exports.Element = Element;
  426. exports.ForwardRef = ForwardRef;
  427. exports.Fragment = Fragment;
  428. exports.Lazy = Lazy;
  429. exports.Memo = Memo;
  430. exports.Portal = Portal;
  431. exports.Profiler = Profiler;
  432. exports.StrictMode = StrictMode;
  433. exports.Suspense = Suspense;
  434. exports.isValidElementType = isValidElementType;
  435. exports.isAsyncMode = isAsyncMode;
  436. exports.isConcurrentMode = isConcurrentMode;
  437. exports.isContextConsumer = isContextConsumer;
  438. exports.isContextProvider = isContextProvider;
  439. exports.isElement = isElement;
  440. exports.isForwardRef = isForwardRef;
  441. exports.isFragment = isFragment;
  442. exports.isLazy = isLazy;
  443. exports.isMemo = isMemo;
  444. exports.isPortal = isPortal;
  445. exports.isProfiler = isProfiler;
  446. exports.isStrictMode = isStrictMode;
  447. exports.isSuspense = isSuspense;
  448. })();
  449. }
  450. });
  451. unwrapExports(reactIs_development);
  452. var reactIs_development_1 = reactIs_development.typeOf;
  453. var reactIs_development_2 = reactIs_development.AsyncMode;
  454. var reactIs_development_3 = reactIs_development.ConcurrentMode;
  455. var reactIs_development_4 = reactIs_development.ContextConsumer;
  456. var reactIs_development_5 = reactIs_development.ContextProvider;
  457. var reactIs_development_6 = reactIs_development.Element;
  458. var reactIs_development_7 = reactIs_development.ForwardRef;
  459. var reactIs_development_8 = reactIs_development.Fragment;
  460. var reactIs_development_9 = reactIs_development.Lazy;
  461. var reactIs_development_10 = reactIs_development.Memo;
  462. var reactIs_development_11 = reactIs_development.Portal;
  463. var reactIs_development_12 = reactIs_development.Profiler;
  464. var reactIs_development_13 = reactIs_development.StrictMode;
  465. var reactIs_development_14 = reactIs_development.Suspense;
  466. var reactIs_development_15 = reactIs_development.isValidElementType;
  467. var reactIs_development_16 = reactIs_development.isAsyncMode;
  468. var reactIs_development_17 = reactIs_development.isConcurrentMode;
  469. var reactIs_development_18 = reactIs_development.isContextConsumer;
  470. var reactIs_development_19 = reactIs_development.isContextProvider;
  471. var reactIs_development_20 = reactIs_development.isElement;
  472. var reactIs_development_21 = reactIs_development.isForwardRef;
  473. var reactIs_development_22 = reactIs_development.isFragment;
  474. var reactIs_development_23 = reactIs_development.isLazy;
  475. var reactIs_development_24 = reactIs_development.isMemo;
  476. var reactIs_development_25 = reactIs_development.isPortal;
  477. var reactIs_development_26 = reactIs_development.isProfiler;
  478. var reactIs_development_27 = reactIs_development.isStrictMode;
  479. var reactIs_development_28 = reactIs_development.isSuspense;
  480. var reactIs = createCommonjsModule(function (module) {
  481. if (process.env.NODE_ENV === 'production') {
  482. module.exports = reactIs_production_min;
  483. } else {
  484. module.exports = reactIs_development;
  485. }
  486. });
  487. /*
  488. object-assign
  489. (c) Sindre Sorhus
  490. @license MIT
  491. */
  492. /* eslint-disable no-unused-vars */
  493. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  494. var hasOwnProperty = Object.prototype.hasOwnProperty;
  495. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  496. function toObject(val) {
  497. if (val === null || val === undefined) {
  498. throw new TypeError('Object.assign cannot be called with null or undefined');
  499. }
  500. return Object(val);
  501. }
  502. function shouldUseNative() {
  503. try {
  504. if (!Object.assign) {
  505. return false;
  506. }
  507. // Detect buggy property enumeration order in older V8 versions.
  508. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  509. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  510. test1[5] = 'de';
  511. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  512. return false;
  513. }
  514. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  515. var test2 = {};
  516. for (var i = 0; i < 10; i++) {
  517. test2['_' + String.fromCharCode(i)] = i;
  518. }
  519. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  520. return test2[n];
  521. });
  522. if (order2.join('') !== '0123456789') {
  523. return false;
  524. }
  525. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  526. var test3 = {};
  527. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  528. test3[letter] = letter;
  529. });
  530. if (Object.keys(Object.assign({}, test3)).join('') !==
  531. 'abcdefghijklmnopqrst') {
  532. return false;
  533. }
  534. return true;
  535. } catch (err) {
  536. // We don't expect any of the above to throw, but better to be safe.
  537. return false;
  538. }
  539. }
  540. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  541. var from;
  542. var to = toObject(target);
  543. var symbols;
  544. for (var s = 1; s < arguments.length; s++) {
  545. from = Object(arguments[s]);
  546. for (var key in from) {
  547. if (hasOwnProperty.call(from, key)) {
  548. to[key] = from[key];
  549. }
  550. }
  551. if (getOwnPropertySymbols) {
  552. symbols = getOwnPropertySymbols(from);
  553. for (var i = 0; i < symbols.length; i++) {
  554. if (propIsEnumerable.call(from, symbols[i])) {
  555. to[symbols[i]] = from[symbols[i]];
  556. }
  557. }
  558. }
  559. }
  560. return to;
  561. };
  562. /**
  563. * Copyright (c) 2013-present, Facebook, Inc.
  564. *
  565. * This source code is licensed under the MIT license found in the
  566. * LICENSE file in the root directory of this source tree.
  567. */
  568. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  569. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  570. var printWarning = function() {};
  571. if (process.env.NODE_ENV !== 'production') {
  572. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  573. var loggedTypeFailures = {};
  574. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  575. printWarning = function(text) {
  576. var message = 'Warning: ' + text;
  577. if (typeof console !== 'undefined') {
  578. console.error(message);
  579. }
  580. try {
  581. // --- Welcome to debugging React ---
  582. // This error was thrown as a convenience so that you can use this stack
  583. // to find the callsite that caused this warning to fire.
  584. throw new Error(message);
  585. } catch (x) {}
  586. };
  587. }
  588. /**
  589. * Assert that the values match with the type specs.
  590. * Error messages are memorized and will only be shown once.
  591. *
  592. * @param {object} typeSpecs Map of name to a ReactPropType
  593. * @param {object} values Runtime values that need to be type-checked
  594. * @param {string} location e.g. "prop", "context", "child context"
  595. * @param {string} componentName Name of the component for error messages.
  596. * @param {?Function} getStack Returns the component stack.
  597. * @private
  598. */
  599. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  600. if (process.env.NODE_ENV !== 'production') {
  601. for (var typeSpecName in typeSpecs) {
  602. if (has(typeSpecs, typeSpecName)) {
  603. var error;
  604. // Prop type validation may throw. In case they do, we don't want to
  605. // fail the render phase where it didn't fail before. So we log it.
  606. // After these have been cleaned up, we'll let them throw.
  607. try {
  608. // This is intentionally an invariant that gets caught. It's the same
  609. // behavior as without this statement except with a better message.
  610. if (typeof typeSpecs[typeSpecName] !== 'function') {
  611. var err = Error(
  612. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  613. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  614. );
  615. err.name = 'Invariant Violation';
  616. throw err;
  617. }
  618. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  619. } catch (ex) {
  620. error = ex;
  621. }
  622. if (error && !(error instanceof Error)) {
  623. printWarning(
  624. (componentName || 'React class') + ': type specification of ' +
  625. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  626. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  627. 'You may have forgotten to pass an argument to the type checker ' +
  628. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  629. 'shape all require an argument).'
  630. );
  631. }
  632. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  633. // Only monitor this failure once because there tends to be a lot of the
  634. // same error.
  635. loggedTypeFailures[error.message] = true;
  636. var stack = getStack ? getStack() : '';
  637. printWarning(
  638. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  639. );
  640. }
  641. }
  642. }
  643. }
  644. }
  645. /**
  646. * Resets warning cache when testing.
  647. *
  648. * @private
  649. */
  650. checkPropTypes.resetWarningCache = function() {
  651. if (process.env.NODE_ENV !== 'production') {
  652. loggedTypeFailures = {};
  653. }
  654. };
  655. var checkPropTypes_1 = checkPropTypes;
  656. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  657. var printWarning$1 = function() {};
  658. if (process.env.NODE_ENV !== 'production') {
  659. printWarning$1 = function(text) {
  660. var message = 'Warning: ' + text;
  661. if (typeof console !== 'undefined') {
  662. console.error(message);
  663. }
  664. try {
  665. // --- Welcome to debugging React ---
  666. // This error was thrown as a convenience so that you can use this stack
  667. // to find the callsite that caused this warning to fire.
  668. throw new Error(message);
  669. } catch (x) {}
  670. };
  671. }
  672. function emptyFunctionThatReturnsNull() {
  673. return null;
  674. }
  675. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  676. /* global Symbol */
  677. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  678. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  679. /**
  680. * Returns the iterator method function contained on the iterable object.
  681. *
  682. * Be sure to invoke the function with the iterable as context:
  683. *
  684. * var iteratorFn = getIteratorFn(myIterable);
  685. * if (iteratorFn) {
  686. * var iterator = iteratorFn.call(myIterable);
  687. * ...
  688. * }
  689. *
  690. * @param {?object} maybeIterable
  691. * @return {?function}
  692. */
  693. function getIteratorFn(maybeIterable) {
  694. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  695. if (typeof iteratorFn === 'function') {
  696. return iteratorFn;
  697. }
  698. }
  699. /**
  700. * Collection of methods that allow declaration and validation of props that are
  701. * supplied to React components. Example usage:
  702. *
  703. * var Props = require('ReactPropTypes');
  704. * var MyArticle = React.createClass({
  705. * propTypes: {
  706. * // An optional string prop named "description".
  707. * description: Props.string,
  708. *
  709. * // A required enum prop named "category".
  710. * category: Props.oneOf(['News','Photos']).isRequired,
  711. *
  712. * // A prop named "dialog" that requires an instance of Dialog.
  713. * dialog: Props.instanceOf(Dialog).isRequired
  714. * },
  715. * render: function() { ... }
  716. * });
  717. *
  718. * A more formal specification of how these methods are used:
  719. *
  720. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  721. * decl := ReactPropTypes.{type}(.isRequired)?
  722. *
  723. * Each and every declaration produces a function with the same signature. This
  724. * allows the creation of custom validation functions. For example:
  725. *
  726. * var MyLink = React.createClass({
  727. * propTypes: {
  728. * // An optional string or URI prop named "href".
  729. * href: function(props, propName, componentName) {
  730. * var propValue = props[propName];
  731. * if (propValue != null && typeof propValue !== 'string' &&
  732. * !(propValue instanceof URI)) {
  733. * return new Error(
  734. * 'Expected a string or an URI for ' + propName + ' in ' +
  735. * componentName
  736. * );
  737. * }
  738. * }
  739. * },
  740. * render: function() {...}
  741. * });
  742. *
  743. * @internal
  744. */
  745. var ANONYMOUS = '<<anonymous>>';
  746. // Important!
  747. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  748. var ReactPropTypes = {
  749. array: createPrimitiveTypeChecker('array'),
  750. bool: createPrimitiveTypeChecker('boolean'),
  751. func: createPrimitiveTypeChecker('function'),
  752. number: createPrimitiveTypeChecker('number'),
  753. object: createPrimitiveTypeChecker('object'),
  754. string: createPrimitiveTypeChecker('string'),
  755. symbol: createPrimitiveTypeChecker('symbol'),
  756. any: createAnyTypeChecker(),
  757. arrayOf: createArrayOfTypeChecker,
  758. element: createElementTypeChecker(),
  759. elementType: createElementTypeTypeChecker(),
  760. instanceOf: createInstanceTypeChecker,
  761. node: createNodeChecker(),
  762. objectOf: createObjectOfTypeChecker,
  763. oneOf: createEnumTypeChecker,
  764. oneOfType: createUnionTypeChecker,
  765. shape: createShapeTypeChecker,
  766. exact: createStrictShapeTypeChecker,
  767. };
  768. /**
  769. * inlined Object.is polyfill to avoid requiring consumers ship their own
  770. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  771. */
  772. /*eslint-disable no-self-compare*/
  773. function is(x, y) {
  774. // SameValue algorithm
  775. if (x === y) {
  776. // Steps 1-5, 7-10
  777. // Steps 6.b-6.e: +0 != -0
  778. return x !== 0 || 1 / x === 1 / y;
  779. } else {
  780. // Step 6.a: NaN == NaN
  781. return x !== x && y !== y;
  782. }
  783. }
  784. /*eslint-enable no-self-compare*/
  785. /**
  786. * We use an Error-like object for backward compatibility as people may call
  787. * PropTypes directly and inspect their output. However, we don't use real
  788. * Errors anymore. We don't inspect their stack anyway, and creating them
  789. * is prohibitively expensive if they are created too often, such as what
  790. * happens in oneOfType() for any type before the one that matched.
  791. */
  792. function PropTypeError(message) {
  793. this.message = message;
  794. this.stack = '';
  795. }
  796. // Make `instanceof Error` still work for returned errors.
  797. PropTypeError.prototype = Error.prototype;
  798. function createChainableTypeChecker(validate) {
  799. if (process.env.NODE_ENV !== 'production') {
  800. var manualPropTypeCallCache = {};
  801. var manualPropTypeWarningCount = 0;
  802. }
  803. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  804. componentName = componentName || ANONYMOUS;
  805. propFullName = propFullName || propName;
  806. if (secret !== ReactPropTypesSecret_1) {
  807. if (throwOnDirectAccess) {
  808. // New behavior only for users of `prop-types` package
  809. var err = new Error(
  810. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  811. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  812. 'Read more at http://fb.me/use-check-prop-types'
  813. );
  814. err.name = 'Invariant Violation';
  815. throw err;
  816. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  817. // Old behavior for people using React.PropTypes
  818. var cacheKey = componentName + ':' + propName;
  819. if (
  820. !manualPropTypeCallCache[cacheKey] &&
  821. // Avoid spamming the console because they are often not actionable except for lib authors
  822. manualPropTypeWarningCount < 3
  823. ) {
  824. printWarning$1(
  825. 'You are manually calling a React.PropTypes validation ' +
  826. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  827. 'and will throw in the standalone `prop-types` package. ' +
  828. 'You may be seeing this warning due to a third-party PropTypes ' +
  829. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  830. );
  831. manualPropTypeCallCache[cacheKey] = true;
  832. manualPropTypeWarningCount++;
  833. }
  834. }
  835. }
  836. if (props[propName] == null) {
  837. if (isRequired) {
  838. if (props[propName] === null) {
  839. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  840. }
  841. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  842. }
  843. return null;
  844. } else {
  845. return validate(props, propName, componentName, location, propFullName);
  846. }
  847. }
  848. var chainedCheckType = checkType.bind(null, false);
  849. chainedCheckType.isRequired = checkType.bind(null, true);
  850. return chainedCheckType;
  851. }
  852. function createPrimitiveTypeChecker(expectedType) {
  853. function validate(props, propName, componentName, location, propFullName, secret) {
  854. var propValue = props[propName];
  855. var propType = getPropType(propValue);
  856. if (propType !== expectedType) {
  857. // `propValue` being instance of, say, date/regexp, pass the 'object'
  858. // check, but we can offer a more precise error message here rather than
  859. // 'of type `object`'.
  860. var preciseType = getPreciseType(propValue);
  861. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  862. }
  863. return null;
  864. }
  865. return createChainableTypeChecker(validate);
  866. }
  867. function createAnyTypeChecker() {
  868. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  869. }
  870. function createArrayOfTypeChecker(typeChecker) {
  871. function validate(props, propName, componentName, location, propFullName) {
  872. if (typeof typeChecker !== 'function') {
  873. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  874. }
  875. var propValue = props[propName];
  876. if (!Array.isArray(propValue)) {
  877. var propType = getPropType(propValue);
  878. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  879. }
  880. for (var i = 0; i < propValue.length; i++) {
  881. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  882. if (error instanceof Error) {
  883. return error;
  884. }
  885. }
  886. return null;
  887. }
  888. return createChainableTypeChecker(validate);
  889. }
  890. function createElementTypeChecker() {
  891. function validate(props, propName, componentName, location, propFullName) {
  892. var propValue = props[propName];
  893. if (!isValidElement(propValue)) {
  894. var propType = getPropType(propValue);
  895. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  896. }
  897. return null;
  898. }
  899. return createChainableTypeChecker(validate);
  900. }
  901. function createElementTypeTypeChecker() {
  902. function validate(props, propName, componentName, location, propFullName) {
  903. var propValue = props[propName];
  904. if (!reactIs.isValidElementType(propValue)) {
  905. var propType = getPropType(propValue);
  906. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  907. }
  908. return null;
  909. }
  910. return createChainableTypeChecker(validate);
  911. }
  912. function createInstanceTypeChecker(expectedClass) {
  913. function validate(props, propName, componentName, location, propFullName) {
  914. if (!(props[propName] instanceof expectedClass)) {
  915. var expectedClassName = expectedClass.name || ANONYMOUS;
  916. var actualClassName = getClassName(props[propName]);
  917. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  918. }
  919. return null;
  920. }
  921. return createChainableTypeChecker(validate);
  922. }
  923. function createEnumTypeChecker(expectedValues) {
  924. if (!Array.isArray(expectedValues)) {
  925. if (process.env.NODE_ENV !== 'production') {
  926. if (arguments.length > 1) {
  927. printWarning$1(
  928. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  929. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  930. );
  931. } else {
  932. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  933. }
  934. }
  935. return emptyFunctionThatReturnsNull;
  936. }
  937. function validate(props, propName, componentName, location, propFullName) {
  938. var propValue = props[propName];
  939. for (var i = 0; i < expectedValues.length; i++) {
  940. if (is(propValue, expectedValues[i])) {
  941. return null;
  942. }
  943. }
  944. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  945. var type = getPreciseType(value);
  946. if (type === 'symbol') {
  947. return String(value);
  948. }
  949. return value;
  950. });
  951. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  952. }
  953. return createChainableTypeChecker(validate);
  954. }
  955. function createObjectOfTypeChecker(typeChecker) {
  956. function validate(props, propName, componentName, location, propFullName) {
  957. if (typeof typeChecker !== 'function') {
  958. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  959. }
  960. var propValue = props[propName];
  961. var propType = getPropType(propValue);
  962. if (propType !== 'object') {
  963. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  964. }
  965. for (var key in propValue) {
  966. if (has$1(propValue, key)) {
  967. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  968. if (error instanceof Error) {
  969. return error;
  970. }
  971. }
  972. }
  973. return null;
  974. }
  975. return createChainableTypeChecker(validate);
  976. }
  977. function createUnionTypeChecker(arrayOfTypeCheckers) {
  978. if (!Array.isArray(arrayOfTypeCheckers)) {
  979. process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  980. return emptyFunctionThatReturnsNull;
  981. }
  982. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  983. var checker = arrayOfTypeCheckers[i];
  984. if (typeof checker !== 'function') {
  985. printWarning$1(
  986. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  987. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  988. );
  989. return emptyFunctionThatReturnsNull;
  990. }
  991. }
  992. function validate(props, propName, componentName, location, propFullName) {
  993. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  994. var checker = arrayOfTypeCheckers[i];
  995. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  996. return null;
  997. }
  998. }
  999. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  1000. }
  1001. return createChainableTypeChecker(validate);
  1002. }
  1003. function createNodeChecker() {
  1004. function validate(props, propName, componentName, location, propFullName) {
  1005. if (!isNode(props[propName])) {
  1006. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  1007. }
  1008. return null;
  1009. }
  1010. return createChainableTypeChecker(validate);
  1011. }
  1012. function createShapeTypeChecker(shapeTypes) {
  1013. function validate(props, propName, componentName, location, propFullName) {
  1014. var propValue = props[propName];
  1015. var propType = getPropType(propValue);
  1016. if (propType !== 'object') {
  1017. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  1018. }
  1019. for (var key in shapeTypes) {
  1020. var checker = shapeTypes[key];
  1021. if (!checker) {
  1022. continue;
  1023. }
  1024. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  1025. if (error) {
  1026. return error;
  1027. }
  1028. }
  1029. return null;
  1030. }
  1031. return createChainableTypeChecker(validate);
  1032. }
  1033. function createStrictShapeTypeChecker(shapeTypes) {
  1034. function validate(props, propName, componentName, location, propFullName) {
  1035. var propValue = props[propName];
  1036. var propType = getPropType(propValue);
  1037. if (propType !== 'object') {
  1038. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  1039. }
  1040. // We need to check all keys in case some are required but missing from
  1041. // props.
  1042. var allKeys = objectAssign({}, props[propName], shapeTypes);
  1043. for (var key in allKeys) {
  1044. var checker = shapeTypes[key];
  1045. if (!checker) {
  1046. return new PropTypeError(
  1047. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  1048. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  1049. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  1050. );
  1051. }
  1052. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  1053. if (error) {
  1054. return error;
  1055. }
  1056. }
  1057. return null;
  1058. }
  1059. return createChainableTypeChecker(validate);
  1060. }
  1061. function isNode(propValue) {
  1062. switch (typeof propValue) {
  1063. case 'number':
  1064. case 'string':
  1065. case 'undefined':
  1066. return true;
  1067. case 'boolean':
  1068. return !propValue;
  1069. case 'object':
  1070. if (Array.isArray(propValue)) {
  1071. return propValue.every(isNode);
  1072. }
  1073. if (propValue === null || isValidElement(propValue)) {
  1074. return true;
  1075. }
  1076. var iteratorFn = getIteratorFn(propValue);
  1077. if (iteratorFn) {
  1078. var iterator = iteratorFn.call(propValue);
  1079. var step;
  1080. if (iteratorFn !== propValue.entries) {
  1081. while (!(step = iterator.next()).done) {
  1082. if (!isNode(step.value)) {
  1083. return false;
  1084. }
  1085. }
  1086. } else {
  1087. // Iterator will provide entry [k,v] tuples rather than values.
  1088. while (!(step = iterator.next()).done) {
  1089. var entry = step.value;
  1090. if (entry) {
  1091. if (!isNode(entry[1])) {
  1092. return false;
  1093. }
  1094. }
  1095. }
  1096. }
  1097. } else {
  1098. return false;
  1099. }
  1100. return true;
  1101. default:
  1102. return false;
  1103. }
  1104. }
  1105. function isSymbol(propType, propValue) {
  1106. // Native Symbol.
  1107. if (propType === 'symbol') {
  1108. return true;
  1109. }
  1110. // falsy value can't be a Symbol
  1111. if (!propValue) {
  1112. return false;
  1113. }
  1114. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  1115. if (propValue['@@toStringTag'] === 'Symbol') {
  1116. return true;
  1117. }
  1118. // Fallback for non-spec compliant Symbols which are polyfilled.
  1119. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  1120. return true;
  1121. }
  1122. return false;
  1123. }
  1124. // Equivalent of `typeof` but with special handling for array and regexp.
  1125. function getPropType(propValue) {
  1126. var propType = typeof propValue;
  1127. if (Array.isArray(propValue)) {
  1128. return 'array';
  1129. }
  1130. if (propValue instanceof RegExp) {
  1131. // Old webkits (at least until Android 4.0) return 'function' rather than
  1132. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  1133. // passes PropTypes.object.
  1134. return 'object';
  1135. }
  1136. if (isSymbol(propType, propValue)) {
  1137. return 'symbol';
  1138. }
  1139. return propType;
  1140. }
  1141. // This handles more types than `getPropType`. Only used for error messages.
  1142. // See `createPrimitiveTypeChecker`.
  1143. function getPreciseType(propValue) {
  1144. if (typeof propValue === 'undefined' || propValue === null) {
  1145. return '' + propValue;
  1146. }
  1147. var propType = getPropType(propValue);
  1148. if (propType === 'object') {
  1149. if (propValue instanceof Date) {
  1150. return 'date';
  1151. } else if (propValue instanceof RegExp) {
  1152. return 'regexp';
  1153. }
  1154. }
  1155. return propType;
  1156. }
  1157. // Returns a string that is postfixed to a warning about an invalid type.
  1158. // For example, "undefined" or "of type array"
  1159. function getPostfixForTypeWarning(value) {
  1160. var type = getPreciseType(value);
  1161. switch (type) {
  1162. case 'array':
  1163. case 'object':
  1164. return 'an ' + type;
  1165. case 'boolean':
  1166. case 'date':
  1167. case 'regexp':
  1168. return 'a ' + type;
  1169. default:
  1170. return type;
  1171. }
  1172. }
  1173. // Returns class name of the object, if any.
  1174. function getClassName(propValue) {
  1175. if (!propValue.constructor || !propValue.constructor.name) {
  1176. return ANONYMOUS;
  1177. }
  1178. return propValue.constructor.name;
  1179. }
  1180. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  1181. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  1182. ReactPropTypes.PropTypes = ReactPropTypes;
  1183. return ReactPropTypes;
  1184. };
  1185. function emptyFunction() {}
  1186. function emptyFunctionWithReset() {}
  1187. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  1188. var factoryWithThrowingShims = function() {
  1189. function shim(props, propName, componentName, location, propFullName, secret) {
  1190. if (secret === ReactPropTypesSecret_1) {
  1191. // It is still safe when called from React.
  1192. return;
  1193. }
  1194. var err = new Error(
  1195. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  1196. 'Use PropTypes.checkPropTypes() to call them. ' +
  1197. 'Read more at http://fb.me/use-check-prop-types'
  1198. );
  1199. err.name = 'Invariant Violation';
  1200. throw err;
  1201. } shim.isRequired = shim;
  1202. function getShim() {
  1203. return shim;
  1204. } // Important!
  1205. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  1206. var ReactPropTypes = {
  1207. array: shim,
  1208. bool: shim,
  1209. func: shim,
  1210. number: shim,
  1211. object: shim,
  1212. string: shim,
  1213. symbol: shim,
  1214. any: shim,
  1215. arrayOf: getShim,
  1216. element: shim,
  1217. elementType: shim,
  1218. instanceOf: getShim,
  1219. node: shim,
  1220. objectOf: getShim,
  1221. oneOf: getShim,
  1222. oneOfType: getShim,
  1223. shape: getShim,
  1224. exact: getShim,
  1225. checkPropTypes: emptyFunctionWithReset,
  1226. resetWarningCache: emptyFunction
  1227. };
  1228. ReactPropTypes.PropTypes = ReactPropTypes;
  1229. return ReactPropTypes;
  1230. };
  1231. var propTypes = createCommonjsModule(function (module) {
  1232. /**
  1233. * Copyright (c) 2013-present, Facebook, Inc.
  1234. *
  1235. * This source code is licensed under the MIT license found in the
  1236. * LICENSE file in the root directory of this source tree.
  1237. */
  1238. if (process.env.NODE_ENV !== 'production') {
  1239. var ReactIs = reactIs;
  1240. // By explicitly using `prop-types` you are opting into new development behavior.
  1241. // http://fb.me/prop-types-in-prod
  1242. var throwOnDirectAccess = true;
  1243. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  1244. } else {
  1245. // By explicitly using `prop-types` you are opting into new production behavior.
  1246. // http://fb.me/prop-types-in-prod
  1247. module.exports = factoryWithThrowingShims();
  1248. }
  1249. });
  1250. /**
  1251. * lodash (Custom Build) <https://lodash.com/>
  1252. * Build: `lodash modularize exports="npm" -o ./`
  1253. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1254. * Released under MIT license <https://lodash.com/license>
  1255. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1256. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1257. */
  1258. /** Used as the `TypeError` message for "Functions" methods. */
  1259. var FUNC_ERROR_TEXT = 'Expected a function';
  1260. /** Used as references for various `Number` constants. */
  1261. var NAN = 0 / 0;
  1262. /** `Object#toString` result references. */
  1263. var symbolTag = '[object Symbol]';
  1264. /** Used to match leading and trailing whitespace. */
  1265. var reTrim = /^\s+|\s+$/g;
  1266. /** Used to detect bad signed hexadecimal string values. */
  1267. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1268. /** Used to detect binary string values. */
  1269. var reIsBinary = /^0b[01]+$/i;
  1270. /** Used to detect octal string values. */
  1271. var reIsOctal = /^0o[0-7]+$/i;
  1272. /** Built-in method references without a dependency on `root`. */
  1273. var freeParseInt = parseInt;
  1274. /** Detect free variable `global` from Node.js. */
  1275. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1276. /** Detect free variable `self`. */
  1277. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1278. /** Used as a reference to the global object. */
  1279. var root = freeGlobal || freeSelf || Function('return this')();
  1280. /** Used for built-in method references. */
  1281. var objectProto = Object.prototype;
  1282. /**
  1283. * Used to resolve the
  1284. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1285. * of values.
  1286. */
  1287. var objectToString = objectProto.toString;
  1288. /* Built-in method references for those with the same name as other `lodash` methods. */
  1289. var nativeMax = Math.max,
  1290. nativeMin = Math.min;
  1291. /**
  1292. * Gets the timestamp of the number of milliseconds that have elapsed since
  1293. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1294. *
  1295. * @static
  1296. * @memberOf _
  1297. * @since 2.4.0
  1298. * @category Date
  1299. * @returns {number} Returns the timestamp.
  1300. * @example
  1301. *
  1302. * _.defer(function(stamp) {
  1303. * console.log(_.now() - stamp);
  1304. * }, _.now());
  1305. * // => Logs the number of milliseconds it took for the deferred invocation.
  1306. */
  1307. var now = function() {
  1308. return root.Date.now();
  1309. };
  1310. /**
  1311. * Creates a debounced function that delays invoking `func` until after `wait`
  1312. * milliseconds have elapsed since the last time the debounced function was
  1313. * invoked. The debounced function comes with a `cancel` method to cancel
  1314. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1315. * Provide `options` to indicate whether `func` should be invoked on the
  1316. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1317. * with the last arguments provided to the debounced function. Subsequent
  1318. * calls to the debounced function return the result of the last `func`
  1319. * invocation.
  1320. *
  1321. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1322. * invoked on the trailing edge of the timeout only if the debounced function
  1323. * is invoked more than once during the `wait` timeout.
  1324. *
  1325. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1326. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1327. *
  1328. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1329. * for details over the differences between `_.debounce` and `_.throttle`.
  1330. *
  1331. * @static
  1332. * @memberOf _
  1333. * @since 0.1.0
  1334. * @category Function
  1335. * @param {Function} func The function to debounce.
  1336. * @param {number} [wait=0] The number of milliseconds to delay.
  1337. * @param {Object} [options={}] The options object.
  1338. * @param {boolean} [options.leading=false]
  1339. * Specify invoking on the leading edge of the timeout.
  1340. * @param {number} [options.maxWait]
  1341. * The maximum time `func` is allowed to be delayed before it's invoked.
  1342. * @param {boolean} [options.trailing=true]
  1343. * Specify invoking on the trailing edge of the timeout.
  1344. * @returns {Function} Returns the new debounced function.
  1345. * @example
  1346. *
  1347. * // Avoid costly calculations while the window size is in flux.
  1348. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1349. *
  1350. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1351. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1352. * 'leading': true,
  1353. * 'trailing': false
  1354. * }));
  1355. *
  1356. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1357. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1358. * var source = new EventSource('/stream');
  1359. * jQuery(source).on('message', debounced);
  1360. *
  1361. * // Cancel the trailing debounced invocation.
  1362. * jQuery(window).on('popstate', debounced.cancel);
  1363. */
  1364. function debounce(func, wait, options) {
  1365. var lastArgs,
  1366. lastThis,
  1367. maxWait,
  1368. result,
  1369. timerId,
  1370. lastCallTime,
  1371. lastInvokeTime = 0,
  1372. leading = false,
  1373. maxing = false,
  1374. trailing = true;
  1375. if (typeof func != 'function') {
  1376. throw new TypeError(FUNC_ERROR_TEXT);
  1377. }
  1378. wait = toNumber(wait) || 0;
  1379. if (isObject(options)) {
  1380. leading = !!options.leading;
  1381. maxing = 'maxWait' in options;
  1382. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  1383. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1384. }
  1385. function invokeFunc(time) {
  1386. var args = lastArgs,
  1387. thisArg = lastThis;
  1388. lastArgs = lastThis = undefined;
  1389. lastInvokeTime = time;
  1390. result = func.apply(thisArg, args);
  1391. return result;
  1392. }
  1393. function leadingEdge(time) {
  1394. // Reset any `maxWait` timer.
  1395. lastInvokeTime = time;
  1396. // Start the timer for the trailing edge.
  1397. timerId = setTimeout(timerExpired, wait);
  1398. // Invoke the leading edge.
  1399. return leading ? invokeFunc(time) : result;
  1400. }
  1401. function remainingWait(time) {
  1402. var timeSinceLastCall = time - lastCallTime,
  1403. timeSinceLastInvoke = time - lastInvokeTime,
  1404. result = wait - timeSinceLastCall;
  1405. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  1406. }
  1407. function shouldInvoke(time) {
  1408. var timeSinceLastCall = time - lastCallTime,
  1409. timeSinceLastInvoke = time - lastInvokeTime;
  1410. // Either this is the first call, activity has stopped and we're at the
  1411. // trailing edge, the system time has gone backwards and we're treating
  1412. // it as the trailing edge, or we've hit the `maxWait` limit.
  1413. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1414. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1415. }
  1416. function timerExpired() {
  1417. var time = now();
  1418. if (shouldInvoke(time)) {
  1419. return trailingEdge(time);
  1420. }
  1421. // Restart the timer.
  1422. timerId = setTimeout(timerExpired, remainingWait(time));
  1423. }
  1424. function trailingEdge(time) {
  1425. timerId = undefined;
  1426. // Only invoke if we have `lastArgs` which means `func` has been
  1427. // debounced at least once.
  1428. if (trailing && lastArgs) {
  1429. return invokeFunc(time);
  1430. }
  1431. lastArgs = lastThis = undefined;
  1432. return result;
  1433. }
  1434. function cancel() {
  1435. if (timerId !== undefined) {
  1436. clearTimeout(timerId);
  1437. }
  1438. lastInvokeTime = 0;
  1439. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1440. }
  1441. function flush() {
  1442. return timerId === undefined ? result : trailingEdge(now());
  1443. }
  1444. function debounced() {
  1445. var time = now(),
  1446. isInvoking = shouldInvoke(time);
  1447. lastArgs = arguments;
  1448. lastThis = this;
  1449. lastCallTime = time;
  1450. if (isInvoking) {
  1451. if (timerId === undefined) {
  1452. return leadingEdge(lastCallTime);
  1453. }
  1454. if (maxing) {
  1455. // Handle invocations in a tight loop.
  1456. timerId = setTimeout(timerExpired, wait);
  1457. return invokeFunc(lastCallTime);
  1458. }
  1459. }
  1460. if (timerId === undefined) {
  1461. timerId = setTimeout(timerExpired, wait);
  1462. }
  1463. return result;
  1464. }
  1465. debounced.cancel = cancel;
  1466. debounced.flush = flush;
  1467. return debounced;
  1468. }
  1469. /**
  1470. * Checks if `value` is the
  1471. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1472. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1473. *
  1474. * @static
  1475. * @memberOf _
  1476. * @since 0.1.0
  1477. * @category Lang
  1478. * @param {*} value The value to check.
  1479. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1480. * @example
  1481. *
  1482. * _.isObject({});
  1483. * // => true
  1484. *
  1485. * _.isObject([1, 2, 3]);
  1486. * // => true
  1487. *
  1488. * _.isObject(_.noop);
  1489. * // => true
  1490. *
  1491. * _.isObject(null);
  1492. * // => false
  1493. */
  1494. function isObject(value) {
  1495. var type = typeof value;
  1496. return !!value && (type == 'object' || type == 'function');
  1497. }
  1498. /**
  1499. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1500. * and has a `typeof` result of "object".
  1501. *
  1502. * @static
  1503. * @memberOf _
  1504. * @since 4.0.0
  1505. * @category Lang
  1506. * @param {*} value The value to check.
  1507. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1508. * @example
  1509. *
  1510. * _.isObjectLike({});
  1511. * // => true
  1512. *
  1513. * _.isObjectLike([1, 2, 3]);
  1514. * // => true
  1515. *
  1516. * _.isObjectLike(_.noop);
  1517. * // => false
  1518. *
  1519. * _.isObjectLike(null);
  1520. * // => false
  1521. */
  1522. function isObjectLike(value) {
  1523. return !!value && typeof value == 'object';
  1524. }
  1525. /**
  1526. * Checks if `value` is classified as a `Symbol` primitive or object.
  1527. *
  1528. * @static
  1529. * @memberOf _
  1530. * @since 4.0.0
  1531. * @category Lang
  1532. * @param {*} value The value to check.
  1533. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1534. * @example
  1535. *
  1536. * _.isSymbol(Symbol.iterator);
  1537. * // => true
  1538. *
  1539. * _.isSymbol('abc');
  1540. * // => false
  1541. */
  1542. function isSymbol(value) {
  1543. return typeof value == 'symbol' ||
  1544. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  1545. }
  1546. /**
  1547. * Converts `value` to a number.
  1548. *
  1549. * @static
  1550. * @memberOf _
  1551. * @since 4.0.0
  1552. * @category Lang
  1553. * @param {*} value The value to process.
  1554. * @returns {number} Returns the number.
  1555. * @example
  1556. *
  1557. * _.toNumber(3.2);
  1558. * // => 3.2
  1559. *
  1560. * _.toNumber(Number.MIN_VALUE);
  1561. * // => 5e-324
  1562. *
  1563. * _.toNumber(Infinity);
  1564. * // => Infinity
  1565. *
  1566. * _.toNumber('3.2');
  1567. * // => 3.2
  1568. */
  1569. function toNumber(value) {
  1570. if (typeof value == 'number') {
  1571. return value;
  1572. }
  1573. if (isSymbol(value)) {
  1574. return NAN;
  1575. }
  1576. if (isObject(value)) {
  1577. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1578. value = isObject(other) ? (other + '') : other;
  1579. }
  1580. if (typeof value != 'string') {
  1581. return value === 0 ? value : +value;
  1582. }
  1583. value = value.replace(reTrim, '');
  1584. var isBinary = reIsBinary.test(value);
  1585. return (isBinary || reIsOctal.test(value))
  1586. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  1587. : (reIsBadHex.test(value) ? NAN : +value);
  1588. }
  1589. var lodash_debounce = debounce;
  1590. function styleInject(css, ref) {
  1591. if ( ref === void 0 ) ref = {};
  1592. var insertAt = ref.insertAt;
  1593. if (!css || typeof document === 'undefined') { return; }
  1594. var head = document.head || document.getElementsByTagName('head')[0];
  1595. var style = document.createElement('style');
  1596. style.type = 'text/css';
  1597. if (insertAt === 'top') {
  1598. if (head.firstChild) {
  1599. head.insertBefore(style, head.firstChild);
  1600. } else {
  1601. head.appendChild(style);
  1602. }
  1603. } else {
  1604. head.appendChild(style);
  1605. }
  1606. if (style.styleSheet) {
  1607. style.styleSheet.cssText = css;
  1608. } else {
  1609. style.appendChild(document.createTextNode(css));
  1610. }
  1611. }
  1612. var css = ".scroll {\n height: 100%;\n padding: 5px;\n position: absolute;\n right: 0;\n top: 0;\n}\n.scroll .scroll-holder {\n height: calc(100% - 20px);\n margin-top: 5px;\n position: relative;\n width: 12px;\n}\n.scroll .scroll-holder .imageSlider {\n height: 12px;\n left: 12px;\n padding: 0;\n position: absolute;\n top: 0;\n transform: rotate(90deg);\n transform-origin: top left;\n -webkit-appearance: none;\n background-color: rgba(0,0,0,0);\n}\n.scroll .scroll-holder .imageSlider:focus {\n outline: none;\n}\n.scroll .scroll-holder .imageSlider::-moz-focus-outer {\n border: none;\n}\n.scroll .scroll-holder .imageSlider::-webkit-slider-runnable-track {\n background-color: rgba(0,0,0,0);\n border: none;\n cursor: pointer;\n height: 5px;\n z-index: 6;\n}\n.scroll .scroll-holder .imageSlider::-moz-range-track {\n background-color: rgba(0,0,0,0);\n border: none;\n cursor: pointer;\n height: 2px;\n z-index: 6;\n}\n.scroll .scroll-holder .imageSlider::-ms-track {\n animate: 0.2s;\n background: transparent;\n border: none;\n border-width: 15px 0;\n color: rgba(0,0,0,0);\n cursor: pointer;\n height: 12px;\n width: 100%;\n}\n.scroll .scroll-holder .imageSlider::-ms-fill-lower {\n background: rgba(0,0,0,0);\n}\n.scroll .scroll-holder .imageSlider::-ms-fill-upper {\n background: rgba(0,0,0,0);\n}\n.scroll .scroll-holder .imageSlider::-webkit-slider-thumb {\n -webkit-appearance: none !important;\n background-color: #163239;\n border: none;\n border-radius: 57px;\n cursor: -webkit-grab;\n height: 12px;\n margin-top: -4px;\n width: 39px;\n}\n.scroll .scroll-holder .imageSlider::-webkit-slider-thumb:active {\n background-color: #20a5d6;\n cursor: -webkit-grabbing;\n}\n.scroll .scroll-holder .imageSlider::-moz-range-thumb {\n background-color: #163239;\n border: none;\n border-radius: 57px;\n cursor: -moz-grab;\n height: 12px;\n width: 39px;\n z-index: 7;\n}\n.scroll .scroll-holder .imageSlider::-moz-range-thumb:active {\n background-color: #20a5d6;\n cursor: -moz-grabbing;\n}\n.scroll .scroll-holder .imageSlider::-ms-thumb {\n background-color: #163239;\n border: none;\n border-radius: 57px;\n cursor: ns-resize;\n height: 12px;\n width: 39px;\n}\n.scroll .scroll-holder .imageSlider::-ms-thumb:active {\n background-color: #20a5d6;\n}\n.scroll .scroll-holder .imageSlider::-ms-tooltip {\n display: none;\n}\n@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n .imageSlider {\n left: 50px;\n }\n}\n";
  1613. styleInject(css);
  1614. var ImageScrollbar =
  1615. /*#__PURE__*/
  1616. function (_PureComponent) {
  1617. inherits(ImageScrollbar, _PureComponent);
  1618. function ImageScrollbar() {
  1619. var _getPrototypeOf2;
  1620. var _this;
  1621. classCallCheck(this, ImageScrollbar);
  1622. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1623. args[_key] = arguments[_key];
  1624. }
  1625. _this = possibleConstructorReturn(this, (_getPrototypeOf2 = getPrototypeOf(ImageScrollbar)).call.apply(_getPrototypeOf2, [this].concat(args)));
  1626. defineProperty(assertThisInitialized(_this), "onChange", function (event) {
  1627. var intValue = parseInt(event.target.value, 10);
  1628. _this.props.onInputCallback(intValue);
  1629. });
  1630. defineProperty(assertThisInitialized(_this), "onKeyDown", function (event) {
  1631. // We don't allow direct keyboard up/down input on the
  1632. // image sliders since the natural direction is reversed (0 is at the top)
  1633. // Store the KeyCodes in an object for readability
  1634. var keys = {
  1635. DOWN: 40,
  1636. UP: 38
  1637. }; // TODO: Enable scroll down / scroll up without depending on ohif-core
  1638. if (event.which === keys.DOWN) {
  1639. //OHIF.commands.run('scrollDown');
  1640. event.preventDefault();
  1641. } else if (event.which === keys.UP) {
  1642. //OHIF.commands.run('scrollUp');
  1643. event.preventDefault();
  1644. }
  1645. });
  1646. return _this;
  1647. }
  1648. createClass(ImageScrollbar, [{
  1649. key: "render",
  1650. value: function render() {
  1651. if (this.props.max === 0) {
  1652. return null;
  1653. }
  1654. this.style = {
  1655. width: "".concat(this.props.height)
  1656. };
  1657. return React__default.createElement("div", {
  1658. className: "scroll"
  1659. }, React__default.createElement("div", {
  1660. className: "scroll-holder"
  1661. }, React__default.createElement("input", {
  1662. className: "imageSlider",
  1663. style: this.style,
  1664. type: "range",
  1665. min: "0",
  1666. max: this.props.max,
  1667. step: "1",
  1668. value: this.props.value,
  1669. onChange: this.onChange,
  1670. onKeyDown: this.onKeyDown
  1671. })));
  1672. }
  1673. }]);
  1674. return ImageScrollbar;
  1675. }(React.PureComponent);
  1676. defineProperty(ImageScrollbar, "propTypes", {
  1677. value: propTypes.number.isRequired,
  1678. max: propTypes.number.isRequired,
  1679. height: propTypes.string.isRequired,
  1680. onInputCallback: propTypes.func.isRequired
  1681. });
  1682. /**
  1683. * Formats a patient name for display purposes
  1684. */
  1685. function formatPN(name) {
  1686. if (!name) {
  1687. return;
  1688. } // Convert the first ^ to a ', '. String.replace() only affects
  1689. // the first appearance of the character.
  1690. var commaBetweenFirstAndLast = name.replace('^', ', '); // Replace any remaining '^' characters with spaces
  1691. var cleaned = commaBetweenFirstAndLast.replace(/\^/g, ' '); // Trim any extraneous whitespace
  1692. return cleaned.trim();
  1693. }
  1694. var moment = createCommonjsModule(function (module, exports) {
  1695. (function (global, factory) {
  1696. module.exports = factory() ;
  1697. }(commonjsGlobal, (function () {
  1698. var hookCallback;
  1699. function hooks () {
  1700. return hookCallback.apply(null, arguments);
  1701. }
  1702. // This is done to register the method called with moment()
  1703. // without creating circular dependencies.
  1704. function setHookCallback (callback) {
  1705. hookCallback = callback;
  1706. }
  1707. function isArray(input) {
  1708. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  1709. }
  1710. function isObject(input) {
  1711. // IE8 will treat undefined and null as object if it wasn't for
  1712. // input != null
  1713. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  1714. }
  1715. function isObjectEmpty(obj) {
  1716. if (Object.getOwnPropertyNames) {
  1717. return (Object.getOwnPropertyNames(obj).length === 0);
  1718. } else {
  1719. var k;
  1720. for (k in obj) {
  1721. if (obj.hasOwnProperty(k)) {
  1722. return false;
  1723. }
  1724. }
  1725. return true;
  1726. }
  1727. }
  1728. function isUndefined(input) {
  1729. return input === void 0;
  1730. }
  1731. function isNumber(input) {
  1732. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  1733. }
  1734. function isDate(input) {
  1735. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  1736. }
  1737. function map(arr, fn) {
  1738. var res = [], i;
  1739. for (i = 0; i < arr.length; ++i) {
  1740. res.push(fn(arr[i], i));
  1741. }
  1742. return res;
  1743. }
  1744. function hasOwnProp(a, b) {
  1745. return Object.prototype.hasOwnProperty.call(a, b);
  1746. }
  1747. function extend(a, b) {
  1748. for (var i in b) {
  1749. if (hasOwnProp(b, i)) {
  1750. a[i] = b[i];
  1751. }
  1752. }
  1753. if (hasOwnProp(b, 'toString')) {
  1754. a.toString = b.toString;
  1755. }
  1756. if (hasOwnProp(b, 'valueOf')) {
  1757. a.valueOf = b.valueOf;
  1758. }
  1759. return a;
  1760. }
  1761. function createUTC (input, format, locale, strict) {
  1762. return createLocalOrUTC(input, format, locale, strict, true).utc();
  1763. }
  1764. function defaultParsingFlags() {
  1765. // We need to deep clone this object.
  1766. return {
  1767. empty : false,
  1768. unusedTokens : [],
  1769. unusedInput : [],
  1770. overflow : -2,
  1771. charsLeftOver : 0,
  1772. nullInput : false,
  1773. invalidMonth : null,
  1774. invalidFormat : false,
  1775. userInvalidated : false,
  1776. iso : false,
  1777. parsedDateParts : [],
  1778. meridiem : null,
  1779. rfc2822 : false,
  1780. weekdayMismatch : false
  1781. };
  1782. }
  1783. function getParsingFlags(m) {
  1784. if (m._pf == null) {
  1785. m._pf = defaultParsingFlags();
  1786. }
  1787. return m._pf;
  1788. }
  1789. var some;
  1790. if (Array.prototype.some) {
  1791. some = Array.prototype.some;
  1792. } else {
  1793. some = function (fun) {
  1794. var t = Object(this);
  1795. var len = t.length >>> 0;
  1796. for (var i = 0; i < len; i++) {
  1797. if (i in t && fun.call(this, t[i], i, t)) {
  1798. return true;
  1799. }
  1800. }
  1801. return false;
  1802. };
  1803. }
  1804. function isValid(m) {
  1805. if (m._isValid == null) {
  1806. var flags = getParsingFlags(m);
  1807. var parsedParts = some.call(flags.parsedDateParts, function (i) {
  1808. return i != null;
  1809. });
  1810. var isNowValid = !isNaN(m._d.getTime()) &&
  1811. flags.overflow < 0 &&
  1812. !flags.empty &&
  1813. !flags.invalidMonth &&
  1814. !flags.invalidWeekday &&
  1815. !flags.weekdayMismatch &&
  1816. !flags.nullInput &&
  1817. !flags.invalidFormat &&
  1818. !flags.userInvalidated &&
  1819. (!flags.meridiem || (flags.meridiem && parsedParts));
  1820. if (m._strict) {
  1821. isNowValid = isNowValid &&
  1822. flags.charsLeftOver === 0 &&
  1823. flags.unusedTokens.length === 0 &&
  1824. flags.bigHour === undefined;
  1825. }
  1826. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  1827. m._isValid = isNowValid;
  1828. }
  1829. else {
  1830. return isNowValid;
  1831. }
  1832. }
  1833. return m._isValid;
  1834. }
  1835. function createInvalid (flags) {
  1836. var m = createUTC(NaN);
  1837. if (flags != null) {
  1838. extend(getParsingFlags(m), flags);
  1839. }
  1840. else {
  1841. getParsingFlags(m).userInvalidated = true;
  1842. }
  1843. return m;
  1844. }
  1845. // Plugins that add properties should also add the key here (null value),
  1846. // so we can properly clone ourselves.
  1847. var momentProperties = hooks.momentProperties = [];
  1848. function copyConfig(to, from) {
  1849. var i, prop, val;
  1850. if (!isUndefined(from._isAMomentObject)) {
  1851. to._isAMomentObject = from._isAMomentObject;
  1852. }
  1853. if (!isUndefined(from._i)) {
  1854. to._i = from._i;
  1855. }
  1856. if (!isUndefined(from._f)) {
  1857. to._f = from._f;
  1858. }
  1859. if (!isUndefined(from._l)) {
  1860. to._l = from._l;
  1861. }
  1862. if (!isUndefined(from._strict)) {
  1863. to._strict = from._strict;
  1864. }
  1865. if (!isUndefined(from._tzm)) {
  1866. to._tzm = from._tzm;
  1867. }
  1868. if (!isUndefined(from._isUTC)) {
  1869. to._isUTC = from._isUTC;
  1870. }
  1871. if (!isUndefined(from._offset)) {
  1872. to._offset = from._offset;
  1873. }
  1874. if (!isUndefined(from._pf)) {
  1875. to._pf = getParsingFlags(from);
  1876. }
  1877. if (!isUndefined(from._locale)) {
  1878. to._locale = from._locale;
  1879. }
  1880. if (momentProperties.length > 0) {
  1881. for (i = 0; i < momentProperties.length; i++) {
  1882. prop = momentProperties[i];
  1883. val = from[prop];
  1884. if (!isUndefined(val)) {
  1885. to[prop] = val;
  1886. }
  1887. }
  1888. }
  1889. return to;
  1890. }
  1891. var updateInProgress = false;
  1892. // Moment prototype object
  1893. function Moment(config) {
  1894. copyConfig(this, config);
  1895. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  1896. if (!this.isValid()) {
  1897. this._d = new Date(NaN);
  1898. }
  1899. // Prevent infinite loop in case updateOffset creates new moment
  1900. // objects.
  1901. if (updateInProgress === false) {
  1902. updateInProgress = true;
  1903. hooks.updateOffset(this);
  1904. updateInProgress = false;
  1905. }
  1906. }
  1907. function isMoment (obj) {
  1908. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  1909. }
  1910. function absFloor (number) {
  1911. if (number < 0) {
  1912. // -0 -> 0
  1913. return Math.ceil(number) || 0;
  1914. } else {
  1915. return Math.floor(number);
  1916. }
  1917. }
  1918. function toInt(argumentForCoercion) {
  1919. var coercedNumber = +argumentForCoercion,
  1920. value = 0;
  1921. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  1922. value = absFloor(coercedNumber);
  1923. }
  1924. return value;
  1925. }
  1926. // compare two arrays, return the number of differences
  1927. function compareArrays(array1, array2, dontConvert) {
  1928. var len = Math.min(array1.length, array2.length),
  1929. lengthDiff = Math.abs(array1.length - array2.length),
  1930. diffs = 0,
  1931. i;
  1932. for (i = 0; i < len; i++) {
  1933. if ((dontConvert && array1[i] !== array2[i]) ||
  1934. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  1935. diffs++;
  1936. }
  1937. }
  1938. return diffs + lengthDiff;
  1939. }
  1940. function warn(msg) {
  1941. if (hooks.suppressDeprecationWarnings === false &&
  1942. (typeof console !== 'undefined') && console.warn) {
  1943. console.warn('Deprecation warning: ' + msg);
  1944. }
  1945. }
  1946. function deprecate(msg, fn) {
  1947. var firstTime = true;
  1948. return extend(function () {
  1949. if (hooks.deprecationHandler != null) {
  1950. hooks.deprecationHandler(null, msg);
  1951. }
  1952. if (firstTime) {
  1953. var args = [];
  1954. var arg;
  1955. for (var i = 0; i < arguments.length; i++) {
  1956. arg = '';
  1957. if (typeof arguments[i] === 'object') {
  1958. arg += '\n[' + i + '] ';
  1959. for (var key in arguments[0]) {
  1960. arg += key + ': ' + arguments[0][key] + ', ';
  1961. }
  1962. arg = arg.slice(0, -2); // Remove trailing comma and space
  1963. } else {
  1964. arg = arguments[i];
  1965. }
  1966. args.push(arg);
  1967. }
  1968. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  1969. firstTime = false;
  1970. }
  1971. return fn.apply(this, arguments);
  1972. }, fn);
  1973. }
  1974. var deprecations = {};
  1975. function deprecateSimple(name, msg) {
  1976. if (hooks.deprecationHandler != null) {
  1977. hooks.deprecationHandler(name, msg);
  1978. }
  1979. if (!deprecations[name]) {
  1980. warn(msg);
  1981. deprecations[name] = true;
  1982. }
  1983. }
  1984. hooks.suppressDeprecationWarnings = false;
  1985. hooks.deprecationHandler = null;
  1986. function isFunction(input) {
  1987. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  1988. }
  1989. function set (config) {
  1990. var prop, i;
  1991. for (i in config) {
  1992. prop = config[i];
  1993. if (isFunction(prop)) {
  1994. this[i] = prop;
  1995. } else {
  1996. this['_' + i] = prop;
  1997. }
  1998. }
  1999. this._config = config;
  2000. // Lenient ordinal parsing accepts just a number in addition to
  2001. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  2002. // TODO: Remove "ordinalParse" fallback in next major release.
  2003. this._dayOfMonthOrdinalParseLenient = new RegExp(
  2004. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  2005. '|' + (/\d{1,2}/).source);
  2006. }
  2007. function mergeConfigs(parentConfig, childConfig) {
  2008. var res = extend({}, parentConfig), prop;
  2009. for (prop in childConfig) {
  2010. if (hasOwnProp(childConfig, prop)) {
  2011. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  2012. res[prop] = {};
  2013. extend(res[prop], parentConfig[prop]);
  2014. extend(res[prop], childConfig[prop]);
  2015. } else if (childConfig[prop] != null) {
  2016. res[prop] = childConfig[prop];
  2017. } else {
  2018. delete res[prop];
  2019. }
  2020. }
  2021. }
  2022. for (prop in parentConfig) {
  2023. if (hasOwnProp(parentConfig, prop) &&
  2024. !hasOwnProp(childConfig, prop) &&
  2025. isObject(parentConfig[prop])) {
  2026. // make sure changes to properties don't modify parent config
  2027. res[prop] = extend({}, res[prop]);
  2028. }
  2029. }
  2030. return res;
  2031. }
  2032. function Locale(config) {
  2033. if (config != null) {
  2034. this.set(config);
  2035. }
  2036. }
  2037. var keys;
  2038. if (Object.keys) {
  2039. keys = Object.keys;
  2040. } else {
  2041. keys = function (obj) {
  2042. var i, res = [];
  2043. for (i in obj) {
  2044. if (hasOwnProp(obj, i)) {
  2045. res.push(i);
  2046. }
  2047. }
  2048. return res;
  2049. };
  2050. }
  2051. var defaultCalendar = {
  2052. sameDay : '[Today at] LT',
  2053. nextDay : '[Tomorrow at] LT',
  2054. nextWeek : 'dddd [at] LT',
  2055. lastDay : '[Yesterday at] LT',
  2056. lastWeek : '[Last] dddd [at] LT',
  2057. sameElse : 'L'
  2058. };
  2059. function calendar (key, mom, now) {
  2060. var output = this._calendar[key] || this._calendar['sameElse'];
  2061. return isFunction(output) ? output.call(mom, now) : output;
  2062. }
  2063. var defaultLongDateFormat = {
  2064. LTS : 'h:mm:ss A',
  2065. LT : 'h:mm A',
  2066. L : 'MM/DD/YYYY',
  2067. LL : 'MMMM D, YYYY',
  2068. LLL : 'MMMM D, YYYY h:mm A',
  2069. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  2070. };
  2071. function longDateFormat (key) {
  2072. var format = this._longDateFormat[key],
  2073. formatUpper = this._longDateFormat[key.toUpperCase()];
  2074. if (format || !formatUpper) {
  2075. return format;
  2076. }
  2077. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  2078. return val.slice(1);
  2079. });
  2080. return this._longDateFormat[key];
  2081. }
  2082. var defaultInvalidDate = 'Invalid date';
  2083. function invalidDate () {
  2084. return this._invalidDate;
  2085. }
  2086. var defaultOrdinal = '%d';
  2087. var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  2088. function ordinal (number) {
  2089. return this._ordinal.replace('%d', number);
  2090. }
  2091. var defaultRelativeTime = {
  2092. future : 'in %s',
  2093. past : '%s ago',
  2094. s : 'a few seconds',
  2095. ss : '%d seconds',
  2096. m : 'a minute',
  2097. mm : '%d minutes',
  2098. h : 'an hour',
  2099. hh : '%d hours',
  2100. d : 'a day',
  2101. dd : '%d days',
  2102. M : 'a month',
  2103. MM : '%d months',
  2104. y : 'a year',
  2105. yy : '%d years'
  2106. };
  2107. function relativeTime (number, withoutSuffix, string, isFuture) {
  2108. var output = this._relativeTime[string];
  2109. return (isFunction(output)) ?
  2110. output(number, withoutSuffix, string, isFuture) :
  2111. output.replace(/%d/i, number);
  2112. }
  2113. function pastFuture (diff, output) {
  2114. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  2115. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  2116. }
  2117. var aliases = {};
  2118. function addUnitAlias (unit, shorthand) {
  2119. var lowerCase = unit.toLowerCase();
  2120. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  2121. }
  2122. function normalizeUnits(units) {
  2123. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  2124. }
  2125. function normalizeObjectUnits(inputObject) {
  2126. var normalizedInput = {},
  2127. normalizedProp,
  2128. prop;
  2129. for (prop in inputObject) {
  2130. if (hasOwnProp(inputObject, prop)) {
  2131. normalizedProp = normalizeUnits(prop);
  2132. if (normalizedProp) {
  2133. normalizedInput[normalizedProp] = inputObject[prop];
  2134. }
  2135. }
  2136. }
  2137. return normalizedInput;
  2138. }
  2139. var priorities = {};
  2140. function addUnitPriority(unit, priority) {
  2141. priorities[unit] = priority;
  2142. }
  2143. function getPrioritizedUnits(unitsObj) {
  2144. var units = [];
  2145. for (var u in unitsObj) {
  2146. units.push({unit: u, priority: priorities[u]});
  2147. }
  2148. units.sort(function (a, b) {
  2149. return a.priority - b.priority;
  2150. });
  2151. return units;
  2152. }
  2153. function zeroFill(number, targetLength, forceSign) {
  2154. var absNumber = '' + Math.abs(number),
  2155. zerosToFill = targetLength - absNumber.length,
  2156. sign = number >= 0;
  2157. return (sign ? (forceSign ? '+' : '') : '-') +
  2158. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  2159. }
  2160. 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;
  2161. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  2162. var formatFunctions = {};
  2163. var formatTokenFunctions = {};
  2164. // token: 'M'
  2165. // padded: ['MM', 2]
  2166. // ordinal: 'Mo'
  2167. // callback: function () { this.month() + 1 }
  2168. function addFormatToken (token, padded, ordinal, callback) {
  2169. var func = callback;
  2170. if (typeof callback === 'string') {
  2171. func = function () {
  2172. return this[callback]();
  2173. };
  2174. }
  2175. if (token) {
  2176. formatTokenFunctions[token] = func;
  2177. }
  2178. if (padded) {
  2179. formatTokenFunctions[padded[0]] = function () {
  2180. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  2181. };
  2182. }
  2183. if (ordinal) {
  2184. formatTokenFunctions[ordinal] = function () {
  2185. return this.localeData().ordinal(func.apply(this, arguments), token);
  2186. };
  2187. }
  2188. }
  2189. function removeFormattingTokens(input) {
  2190. if (input.match(/\[[\s\S]/)) {
  2191. return input.replace(/^\[|\]$/g, '');
  2192. }
  2193. return input.replace(/\\/g, '');
  2194. }
  2195. function makeFormatFunction(format) {
  2196. var array = format.match(formattingTokens), i, length;
  2197. for (i = 0, length = array.length; i < length; i++) {
  2198. if (formatTokenFunctions[array[i]]) {
  2199. array[i] = formatTokenFunctions[array[i]];
  2200. } else {
  2201. array[i] = removeFormattingTokens(array[i]);
  2202. }
  2203. }
  2204. return function (mom) {
  2205. var output = '', i;
  2206. for (i = 0; i < length; i++) {
  2207. output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
  2208. }
  2209. return output;
  2210. };
  2211. }
  2212. // format date using native date object
  2213. function formatMoment(m, format) {
  2214. if (!m.isValid()) {
  2215. return m.localeData().invalidDate();
  2216. }
  2217. format = expandFormat(format, m.localeData());
  2218. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  2219. return formatFunctions[format](m);
  2220. }
  2221. function expandFormat(format, locale) {
  2222. var i = 5;
  2223. function replaceLongDateFormatTokens(input) {
  2224. return locale.longDateFormat(input) || input;
  2225. }
  2226. localFormattingTokens.lastIndex = 0;
  2227. while (i >= 0 && localFormattingTokens.test(format)) {
  2228. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  2229. localFormattingTokens.lastIndex = 0;
  2230. i -= 1;
  2231. }
  2232. return format;
  2233. }
  2234. var match1 = /\d/; // 0 - 9
  2235. var match2 = /\d\d/; // 00 - 99
  2236. var match3 = /\d{3}/; // 000 - 999
  2237. var match4 = /\d{4}/; // 0000 - 9999
  2238. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  2239. var match1to2 = /\d\d?/; // 0 - 99
  2240. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  2241. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  2242. var match1to3 = /\d{1,3}/; // 0 - 999
  2243. var match1to4 = /\d{1,4}/; // 0 - 9999
  2244. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  2245. var matchUnsigned = /\d+/; // 0 - inf
  2246. var matchSigned = /[+-]?\d+/; // -inf - inf
  2247. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  2248. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  2249. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  2250. // any word (or two) characters or numbers including two/three word month in arabic.
  2251. // includes scottish gaelic two word and hyphenated months
  2252. var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
  2253. var regexes = {};
  2254. function addRegexToken (token, regex, strictRegex) {
  2255. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  2256. return (isStrict && strictRegex) ? strictRegex : regex;
  2257. };
  2258. }
  2259. function getParseRegexForToken (token, config) {
  2260. if (!hasOwnProp(regexes, token)) {
  2261. return new RegExp(unescapeFormat(token));
  2262. }
  2263. return regexes[token](config._strict, config._locale);
  2264. }
  2265. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  2266. function unescapeFormat(s) {
  2267. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  2268. return p1 || p2 || p3 || p4;
  2269. }));
  2270. }
  2271. function regexEscape(s) {
  2272. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  2273. }
  2274. var tokens = {};
  2275. function addParseToken (token, callback) {
  2276. var i, func = callback;
  2277. if (typeof token === 'string') {
  2278. token = [token];
  2279. }
  2280. if (isNumber(callback)) {
  2281. func = function (input, array) {
  2282. array[callback] = toInt(input);
  2283. };
  2284. }
  2285. for (i = 0; i < token.length; i++) {
  2286. tokens[token[i]] = func;
  2287. }
  2288. }
  2289. function addWeekParseToken (token, callback) {
  2290. addParseToken(token, function (input, array, config, token) {
  2291. config._w = config._w || {};
  2292. callback(input, config._w, config, token);
  2293. });
  2294. }
  2295. function addTimeToArrayFromToken(token, input, config) {
  2296. if (input != null && hasOwnProp(tokens, token)) {
  2297. tokens[token](input, config._a, config, token);
  2298. }
  2299. }
  2300. var YEAR = 0;
  2301. var MONTH = 1;
  2302. var DATE = 2;
  2303. var HOUR = 3;
  2304. var MINUTE = 4;
  2305. var SECOND = 5;
  2306. var MILLISECOND = 6;
  2307. var WEEK = 7;
  2308. var WEEKDAY = 8;
  2309. // FORMATTING
  2310. addFormatToken('Y', 0, 0, function () {
  2311. var y = this.year();
  2312. return y <= 9999 ? '' + y : '+' + y;
  2313. });
  2314. addFormatToken(0, ['YY', 2], 0, function () {
  2315. return this.year() % 100;
  2316. });
  2317. addFormatToken(0, ['YYYY', 4], 0, 'year');
  2318. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  2319. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  2320. // ALIASES
  2321. addUnitAlias('year', 'y');
  2322. // PRIORITIES
  2323. addUnitPriority('year', 1);
  2324. // PARSING
  2325. addRegexToken('Y', matchSigned);
  2326. addRegexToken('YY', match1to2, match2);
  2327. addRegexToken('YYYY', match1to4, match4);
  2328. addRegexToken('YYYYY', match1to6, match6);
  2329. addRegexToken('YYYYYY', match1to6, match6);
  2330. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  2331. addParseToken('YYYY', function (input, array) {
  2332. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  2333. });
  2334. addParseToken('YY', function (input, array) {
  2335. array[YEAR] = hooks.parseTwoDigitYear(input);
  2336. });
  2337. addParseToken('Y', function (input, array) {
  2338. array[YEAR] = parseInt(input, 10);
  2339. });
  2340. // HELPERS
  2341. function daysInYear(year) {
  2342. return isLeapYear(year) ? 366 : 365;
  2343. }
  2344. function isLeapYear(year) {
  2345. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  2346. }
  2347. // HOOKS
  2348. hooks.parseTwoDigitYear = function (input) {
  2349. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  2350. };
  2351. // MOMENTS
  2352. var getSetYear = makeGetSet('FullYear', true);
  2353. function getIsLeapYear () {
  2354. return isLeapYear(this.year());
  2355. }
  2356. function makeGetSet (unit, keepTime) {
  2357. return function (value) {
  2358. if (value != null) {
  2359. set$1(this, unit, value);
  2360. hooks.updateOffset(this, keepTime);
  2361. return this;
  2362. } else {
  2363. return get(this, unit);
  2364. }
  2365. };
  2366. }
  2367. function get (mom, unit) {
  2368. return mom.isValid() ?
  2369. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  2370. }
  2371. function set$1 (mom, unit, value) {
  2372. if (mom.isValid() && !isNaN(value)) {
  2373. if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
  2374. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
  2375. }
  2376. else {
  2377. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  2378. }
  2379. }
  2380. }
  2381. // MOMENTS
  2382. function stringGet (units) {
  2383. units = normalizeUnits(units);
  2384. if (isFunction(this[units])) {
  2385. return this[units]();
  2386. }
  2387. return this;
  2388. }
  2389. function stringSet (units, value) {
  2390. if (typeof units === 'object') {
  2391. units = normalizeObjectUnits(units);
  2392. var prioritized = getPrioritizedUnits(units);
  2393. for (var i = 0; i < prioritized.length; i++) {
  2394. this[prioritized[i].unit](units[prioritized[i].unit]);
  2395. }
  2396. } else {
  2397. units = normalizeUnits(units);
  2398. if (isFunction(this[units])) {
  2399. return this[units](value);
  2400. }
  2401. }
  2402. return this;
  2403. }
  2404. function mod(n, x) {
  2405. return ((n % x) + x) % x;
  2406. }
  2407. var indexOf;
  2408. if (Array.prototype.indexOf) {
  2409. indexOf = Array.prototype.indexOf;
  2410. } else {
  2411. indexOf = function (o) {
  2412. // I know
  2413. var i;
  2414. for (i = 0; i < this.length; ++i) {
  2415. if (this[i] === o) {
  2416. return i;
  2417. }
  2418. }
  2419. return -1;
  2420. };
  2421. }
  2422. function daysInMonth(year, month) {
  2423. if (isNaN(year) || isNaN(month)) {
  2424. return NaN;
  2425. }
  2426. var modMonth = mod(month, 12);
  2427. year += (month - modMonth) / 12;
  2428. return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
  2429. }
  2430. // FORMATTING
  2431. addFormatToken('M', ['MM', 2], 'Mo', function () {
  2432. return this.month() + 1;
  2433. });
  2434. addFormatToken('MMM', 0, 0, function (format) {
  2435. return this.localeData().monthsShort(this, format);
  2436. });
  2437. addFormatToken('MMMM', 0, 0, function (format) {
  2438. return this.localeData().months(this, format);
  2439. });
  2440. // ALIASES
  2441. addUnitAlias('month', 'M');
  2442. // PRIORITY
  2443. addUnitPriority('month', 8);
  2444. // PARSING
  2445. addRegexToken('M', match1to2);
  2446. addRegexToken('MM', match1to2, match2);
  2447. addRegexToken('MMM', function (isStrict, locale) {
  2448. return locale.monthsShortRegex(isStrict);
  2449. });
  2450. addRegexToken('MMMM', function (isStrict, locale) {
  2451. return locale.monthsRegex(isStrict);
  2452. });
  2453. addParseToken(['M', 'MM'], function (input, array) {
  2454. array[MONTH] = toInt(input) - 1;
  2455. });
  2456. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  2457. var month = config._locale.monthsParse(input, token, config._strict);
  2458. // if we didn't find a month name, mark the date as invalid.
  2459. if (month != null) {
  2460. array[MONTH] = month;
  2461. } else {
  2462. getParsingFlags(config).invalidMonth = input;
  2463. }
  2464. });
  2465. // LOCALES
  2466. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  2467. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  2468. function localeMonths (m, format) {
  2469. if (!m) {
  2470. return isArray(this._months) ? this._months :
  2471. this._months['standalone'];
  2472. }
  2473. return isArray(this._months) ? this._months[m.month()] :
  2474. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  2475. }
  2476. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  2477. function localeMonthsShort (m, format) {
  2478. if (!m) {
  2479. return isArray(this._monthsShort) ? this._monthsShort :
  2480. this._monthsShort['standalone'];
  2481. }
  2482. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  2483. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  2484. }
  2485. function handleStrictParse(monthName, format, strict) {
  2486. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  2487. if (!this._monthsParse) {
  2488. // this is not used
  2489. this._monthsParse = [];
  2490. this._longMonthsParse = [];
  2491. this._shortMonthsParse = [];
  2492. for (i = 0; i < 12; ++i) {
  2493. mom = createUTC([2000, i]);
  2494. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  2495. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  2496. }
  2497. }
  2498. if (strict) {
  2499. if (format === 'MMM') {
  2500. ii = indexOf.call(this._shortMonthsParse, llc);
  2501. return ii !== -1 ? ii : null;
  2502. } else {
  2503. ii = indexOf.call(this._longMonthsParse, llc);
  2504. return ii !== -1 ? ii : null;
  2505. }
  2506. } else {
  2507. if (format === 'MMM') {
  2508. ii = indexOf.call(this._shortMonthsParse, llc);
  2509. if (ii !== -1) {
  2510. return ii;
  2511. }
  2512. ii = indexOf.call(this._longMonthsParse, llc);
  2513. return ii !== -1 ? ii : null;
  2514. } else {
  2515. ii = indexOf.call(this._longMonthsParse, llc);
  2516. if (ii !== -1) {
  2517. return ii;
  2518. }
  2519. ii = indexOf.call(this._shortMonthsParse, llc);
  2520. return ii !== -1 ? ii : null;
  2521. }
  2522. }
  2523. }
  2524. function localeMonthsParse (monthName, format, strict) {
  2525. var i, mom, regex;
  2526. if (this._monthsParseExact) {
  2527. return handleStrictParse.call(this, monthName, format, strict);
  2528. }
  2529. if (!this._monthsParse) {
  2530. this._monthsParse = [];
  2531. this._longMonthsParse = [];
  2532. this._shortMonthsParse = [];
  2533. }
  2534. // TODO: add sorting
  2535. // Sorting makes sure if one month (or abbr) is a prefix of another
  2536. // see sorting in computeMonthsParse
  2537. for (i = 0; i < 12; i++) {
  2538. // make the regex if we don't have it already
  2539. mom = createUTC([2000, i]);
  2540. if (strict && !this._longMonthsParse[i]) {
  2541. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  2542. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  2543. }
  2544. if (!strict && !this._monthsParse[i]) {
  2545. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  2546. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2547. }
  2548. // test the regex
  2549. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  2550. return i;
  2551. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  2552. return i;
  2553. } else if (!strict && this._monthsParse[i].test(monthName)) {
  2554. return i;
  2555. }
  2556. }
  2557. }
  2558. // MOMENTS
  2559. function setMonth (mom, value) {
  2560. var dayOfMonth;
  2561. if (!mom.isValid()) {
  2562. // No op
  2563. return mom;
  2564. }
  2565. if (typeof value === 'string') {
  2566. if (/^\d+$/.test(value)) {
  2567. value = toInt(value);
  2568. } else {
  2569. value = mom.localeData().monthsParse(value);
  2570. // TODO: Another silent failure?
  2571. if (!isNumber(value)) {
  2572. return mom;
  2573. }
  2574. }
  2575. }
  2576. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  2577. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  2578. return mom;
  2579. }
  2580. function getSetMonth (value) {
  2581. if (value != null) {
  2582. setMonth(this, value);
  2583. hooks.updateOffset(this, true);
  2584. return this;
  2585. } else {
  2586. return get(this, 'Month');
  2587. }
  2588. }
  2589. function getDaysInMonth () {
  2590. return daysInMonth(this.year(), this.month());
  2591. }
  2592. var defaultMonthsShortRegex = matchWord;
  2593. function monthsShortRegex (isStrict) {
  2594. if (this._monthsParseExact) {
  2595. if (!hasOwnProp(this, '_monthsRegex')) {
  2596. computeMonthsParse.call(this);
  2597. }
  2598. if (isStrict) {
  2599. return this._monthsShortStrictRegex;
  2600. } else {
  2601. return this._monthsShortRegex;
  2602. }
  2603. } else {
  2604. if (!hasOwnProp(this, '_monthsShortRegex')) {
  2605. this._monthsShortRegex = defaultMonthsShortRegex;
  2606. }
  2607. return this._monthsShortStrictRegex && isStrict ?
  2608. this._monthsShortStrictRegex : this._monthsShortRegex;
  2609. }
  2610. }
  2611. var defaultMonthsRegex = matchWord;
  2612. function monthsRegex (isStrict) {
  2613. if (this._monthsParseExact) {
  2614. if (!hasOwnProp(this, '_monthsRegex')) {
  2615. computeMonthsParse.call(this);
  2616. }
  2617. if (isStrict) {
  2618. return this._monthsStrictRegex;
  2619. } else {
  2620. return this._monthsRegex;
  2621. }
  2622. } else {
  2623. if (!hasOwnProp(this, '_monthsRegex')) {
  2624. this._monthsRegex = defaultMonthsRegex;
  2625. }
  2626. return this._monthsStrictRegex && isStrict ?
  2627. this._monthsStrictRegex : this._monthsRegex;
  2628. }
  2629. }
  2630. function computeMonthsParse () {
  2631. function cmpLenRev(a, b) {
  2632. return b.length - a.length;
  2633. }
  2634. var shortPieces = [], longPieces = [], mixedPieces = [],
  2635. i, mom;
  2636. for (i = 0; i < 12; i++) {
  2637. // make the regex if we don't have it already
  2638. mom = createUTC([2000, i]);
  2639. shortPieces.push(this.monthsShort(mom, ''));
  2640. longPieces.push(this.months(mom, ''));
  2641. mixedPieces.push(this.months(mom, ''));
  2642. mixedPieces.push(this.monthsShort(mom, ''));
  2643. }
  2644. // Sorting makes sure if one month (or abbr) is a prefix of another it
  2645. // will match the longer piece.
  2646. shortPieces.sort(cmpLenRev);
  2647. longPieces.sort(cmpLenRev);
  2648. mixedPieces.sort(cmpLenRev);
  2649. for (i = 0; i < 12; i++) {
  2650. shortPieces[i] = regexEscape(shortPieces[i]);
  2651. longPieces[i] = regexEscape(longPieces[i]);
  2652. }
  2653. for (i = 0; i < 24; i++) {
  2654. mixedPieces[i] = regexEscape(mixedPieces[i]);
  2655. }
  2656. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2657. this._monthsShortRegex = this._monthsRegex;
  2658. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  2659. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  2660. }
  2661. function createDate (y, m, d, h, M, s, ms) {
  2662. // can't just apply() to create a date:
  2663. // https://stackoverflow.com/q/181348
  2664. var date;
  2665. // the date constructor remaps years 0-99 to 1900-1999
  2666. if (y < 100 && y >= 0) {
  2667. // preserve leap years using a full 400 year cycle, then reset
  2668. date = new Date(y + 400, m, d, h, M, s, ms);
  2669. if (isFinite(date.getFullYear())) {
  2670. date.setFullYear(y);
  2671. }
  2672. } else {
  2673. date = new Date(y, m, d, h, M, s, ms);
  2674. }
  2675. return date;
  2676. }
  2677. function createUTCDate (y) {
  2678. var date;
  2679. // the Date.UTC function remaps years 0-99 to 1900-1999
  2680. if (y < 100 && y >= 0) {
  2681. var args = Array.prototype.slice.call(arguments);
  2682. // preserve leap years using a full 400 year cycle, then reset
  2683. args[0] = y + 400;
  2684. date = new Date(Date.UTC.apply(null, args));
  2685. if (isFinite(date.getUTCFullYear())) {
  2686. date.setUTCFullYear(y);
  2687. }
  2688. } else {
  2689. date = new Date(Date.UTC.apply(null, arguments));
  2690. }
  2691. return date;
  2692. }
  2693. // start-of-first-week - start-of-year
  2694. function firstWeekOffset(year, dow, doy) {
  2695. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  2696. fwd = 7 + dow - doy,
  2697. // first-week day local weekday -- which local weekday is fwd
  2698. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  2699. return -fwdlw + fwd - 1;
  2700. }
  2701. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  2702. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  2703. var localWeekday = (7 + weekday - dow) % 7,
  2704. weekOffset = firstWeekOffset(year, dow, doy),
  2705. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  2706. resYear, resDayOfYear;
  2707. if (dayOfYear <= 0) {
  2708. resYear = year - 1;
  2709. resDayOfYear = daysInYear(resYear) + dayOfYear;
  2710. } else if (dayOfYear > daysInYear(year)) {
  2711. resYear = year + 1;
  2712. resDayOfYear = dayOfYear - daysInYear(year);
  2713. } else {
  2714. resYear = year;
  2715. resDayOfYear = dayOfYear;
  2716. }
  2717. return {
  2718. year: resYear,
  2719. dayOfYear: resDayOfYear
  2720. };
  2721. }
  2722. function weekOfYear(mom, dow, doy) {
  2723. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  2724. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  2725. resWeek, resYear;
  2726. if (week < 1) {
  2727. resYear = mom.year() - 1;
  2728. resWeek = week + weeksInYear(resYear, dow, doy);
  2729. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  2730. resWeek = week - weeksInYear(mom.year(), dow, doy);
  2731. resYear = mom.year() + 1;
  2732. } else {
  2733. resYear = mom.year();
  2734. resWeek = week;
  2735. }
  2736. return {
  2737. week: resWeek,
  2738. year: resYear
  2739. };
  2740. }
  2741. function weeksInYear(year, dow, doy) {
  2742. var weekOffset = firstWeekOffset(year, dow, doy),
  2743. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  2744. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  2745. }
  2746. // FORMATTING
  2747. addFormatToken('w', ['ww', 2], 'wo', 'week');
  2748. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  2749. // ALIASES
  2750. addUnitAlias('week', 'w');
  2751. addUnitAlias('isoWeek', 'W');
  2752. // PRIORITIES
  2753. addUnitPriority('week', 5);
  2754. addUnitPriority('isoWeek', 5);
  2755. // PARSING
  2756. addRegexToken('w', match1to2);
  2757. addRegexToken('ww', match1to2, match2);
  2758. addRegexToken('W', match1to2);
  2759. addRegexToken('WW', match1to2, match2);
  2760. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  2761. week[token.substr(0, 1)] = toInt(input);
  2762. });
  2763. // HELPERS
  2764. // LOCALES
  2765. function localeWeek (mom) {
  2766. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  2767. }
  2768. var defaultLocaleWeek = {
  2769. dow : 0, // Sunday is the first day of the week.
  2770. doy : 6 // The week that contains Jan 6th is the first week of the year.
  2771. };
  2772. function localeFirstDayOfWeek () {
  2773. return this._week.dow;
  2774. }
  2775. function localeFirstDayOfYear () {
  2776. return this._week.doy;
  2777. }
  2778. // MOMENTS
  2779. function getSetWeek (input) {
  2780. var week = this.localeData().week(this);
  2781. return input == null ? week : this.add((input - week) * 7, 'd');
  2782. }
  2783. function getSetISOWeek (input) {
  2784. var week = weekOfYear(this, 1, 4).week;
  2785. return input == null ? week : this.add((input - week) * 7, 'd');
  2786. }
  2787. // FORMATTING
  2788. addFormatToken('d', 0, 'do', 'day');
  2789. addFormatToken('dd', 0, 0, function (format) {
  2790. return this.localeData().weekdaysMin(this, format);
  2791. });
  2792. addFormatToken('ddd', 0, 0, function (format) {
  2793. return this.localeData().weekdaysShort(this, format);
  2794. });
  2795. addFormatToken('dddd', 0, 0, function (format) {
  2796. return this.localeData().weekdays(this, format);
  2797. });
  2798. addFormatToken('e', 0, 0, 'weekday');
  2799. addFormatToken('E', 0, 0, 'isoWeekday');
  2800. // ALIASES
  2801. addUnitAlias('day', 'd');
  2802. addUnitAlias('weekday', 'e');
  2803. addUnitAlias('isoWeekday', 'E');
  2804. // PRIORITY
  2805. addUnitPriority('day', 11);
  2806. addUnitPriority('weekday', 11);
  2807. addUnitPriority('isoWeekday', 11);
  2808. // PARSING
  2809. addRegexToken('d', match1to2);
  2810. addRegexToken('e', match1to2);
  2811. addRegexToken('E', match1to2);
  2812. addRegexToken('dd', function (isStrict, locale) {
  2813. return locale.weekdaysMinRegex(isStrict);
  2814. });
  2815. addRegexToken('ddd', function (isStrict, locale) {
  2816. return locale.weekdaysShortRegex(isStrict);
  2817. });
  2818. addRegexToken('dddd', function (isStrict, locale) {
  2819. return locale.weekdaysRegex(isStrict);
  2820. });
  2821. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  2822. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  2823. // if we didn't get a weekday name, mark the date as invalid
  2824. if (weekday != null) {
  2825. week.d = weekday;
  2826. } else {
  2827. getParsingFlags(config).invalidWeekday = input;
  2828. }
  2829. });
  2830. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  2831. week[token] = toInt(input);
  2832. });
  2833. // HELPERS
  2834. function parseWeekday(input, locale) {
  2835. if (typeof input !== 'string') {
  2836. return input;
  2837. }
  2838. if (!isNaN(input)) {
  2839. return parseInt(input, 10);
  2840. }
  2841. input = locale.weekdaysParse(input);
  2842. if (typeof input === 'number') {
  2843. return input;
  2844. }
  2845. return null;
  2846. }
  2847. function parseIsoWeekday(input, locale) {
  2848. if (typeof input === 'string') {
  2849. return locale.weekdaysParse(input) % 7 || 7;
  2850. }
  2851. return isNaN(input) ? null : input;
  2852. }
  2853. // LOCALES
  2854. function shiftWeekdays (ws, n) {
  2855. return ws.slice(n, 7).concat(ws.slice(0, n));
  2856. }
  2857. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  2858. function localeWeekdays (m, format) {
  2859. var weekdays = isArray(this._weekdays) ? this._weekdays :
  2860. this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
  2861. return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
  2862. : (m) ? weekdays[m.day()] : weekdays;
  2863. }
  2864. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  2865. function localeWeekdaysShort (m) {
  2866. return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  2867. : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  2868. }
  2869. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  2870. function localeWeekdaysMin (m) {
  2871. return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  2872. : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  2873. }
  2874. function handleStrictParse$1(weekdayName, format, strict) {
  2875. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  2876. if (!this._weekdaysParse) {
  2877. this._weekdaysParse = [];
  2878. this._shortWeekdaysParse = [];
  2879. this._minWeekdaysParse = [];
  2880. for (i = 0; i < 7; ++i) {
  2881. mom = createUTC([2000, 1]).day(i);
  2882. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  2883. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  2884. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  2885. }
  2886. }
  2887. if (strict) {
  2888. if (format === 'dddd') {
  2889. ii = indexOf.call(this._weekdaysParse, llc);
  2890. return ii !== -1 ? ii : null;
  2891. } else if (format === 'ddd') {
  2892. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2893. return ii !== -1 ? ii : null;
  2894. } else {
  2895. ii = indexOf.call(this._minWeekdaysParse, llc);
  2896. return ii !== -1 ? ii : null;
  2897. }
  2898. } else {
  2899. if (format === 'dddd') {
  2900. ii = indexOf.call(this._weekdaysParse, llc);
  2901. if (ii !== -1) {
  2902. return ii;
  2903. }
  2904. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2905. if (ii !== -1) {
  2906. return ii;
  2907. }
  2908. ii = indexOf.call(this._minWeekdaysParse, llc);
  2909. return ii !== -1 ? ii : null;
  2910. } else if (format === 'ddd') {
  2911. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2912. if (ii !== -1) {
  2913. return ii;
  2914. }
  2915. ii = indexOf.call(this._weekdaysParse, llc);
  2916. if (ii !== -1) {
  2917. return ii;
  2918. }
  2919. ii = indexOf.call(this._minWeekdaysParse, llc);
  2920. return ii !== -1 ? ii : null;
  2921. } else {
  2922. ii = indexOf.call(this._minWeekdaysParse, llc);
  2923. if (ii !== -1) {
  2924. return ii;
  2925. }
  2926. ii = indexOf.call(this._weekdaysParse, llc);
  2927. if (ii !== -1) {
  2928. return ii;
  2929. }
  2930. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2931. return ii !== -1 ? ii : null;
  2932. }
  2933. }
  2934. }
  2935. function localeWeekdaysParse (weekdayName, format, strict) {
  2936. var i, mom, regex;
  2937. if (this._weekdaysParseExact) {
  2938. return handleStrictParse$1.call(this, weekdayName, format, strict);
  2939. }
  2940. if (!this._weekdaysParse) {
  2941. this._weekdaysParse = [];
  2942. this._minWeekdaysParse = [];
  2943. this._shortWeekdaysParse = [];
  2944. this._fullWeekdaysParse = [];
  2945. }
  2946. for (i = 0; i < 7; i++) {
  2947. // make the regex if we don't have it already
  2948. mom = createUTC([2000, 1]).day(i);
  2949. if (strict && !this._fullWeekdaysParse[i]) {
  2950. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
  2951. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
  2952. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
  2953. }
  2954. if (!this._weekdaysParse[i]) {
  2955. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  2956. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2957. }
  2958. // test the regex
  2959. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  2960. return i;
  2961. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  2962. return i;
  2963. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  2964. return i;
  2965. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  2966. return i;
  2967. }
  2968. }
  2969. }
  2970. // MOMENTS
  2971. function getSetDayOfWeek (input) {
  2972. if (!this.isValid()) {
  2973. return input != null ? this : NaN;
  2974. }
  2975. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  2976. if (input != null) {
  2977. input = parseWeekday(input, this.localeData());
  2978. return this.add(input - day, 'd');
  2979. } else {
  2980. return day;
  2981. }
  2982. }
  2983. function getSetLocaleDayOfWeek (input) {
  2984. if (!this.isValid()) {
  2985. return input != null ? this : NaN;
  2986. }
  2987. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  2988. return input == null ? weekday : this.add(input - weekday, 'd');
  2989. }
  2990. function getSetISODayOfWeek (input) {
  2991. if (!this.isValid()) {
  2992. return input != null ? this : NaN;
  2993. }
  2994. // behaves the same as moment#day except
  2995. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  2996. // as a setter, sunday should belong to the previous week.
  2997. if (input != null) {
  2998. var weekday = parseIsoWeekday(input, this.localeData());
  2999. return this.day(this.day() % 7 ? weekday : weekday - 7);
  3000. } else {
  3001. return this.day() || 7;
  3002. }
  3003. }
  3004. var defaultWeekdaysRegex = matchWord;
  3005. function weekdaysRegex (isStrict) {
  3006. if (this._weekdaysParseExact) {
  3007. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3008. computeWeekdaysParse.call(this);
  3009. }
  3010. if (isStrict) {
  3011. return this._weekdaysStrictRegex;
  3012. } else {
  3013. return this._weekdaysRegex;
  3014. }
  3015. } else {
  3016. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3017. this._weekdaysRegex = defaultWeekdaysRegex;
  3018. }
  3019. return this._weekdaysStrictRegex && isStrict ?
  3020. this._weekdaysStrictRegex : this._weekdaysRegex;
  3021. }
  3022. }
  3023. var defaultWeekdaysShortRegex = matchWord;
  3024. function weekdaysShortRegex (isStrict) {
  3025. if (this._weekdaysParseExact) {
  3026. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3027. computeWeekdaysParse.call(this);
  3028. }
  3029. if (isStrict) {
  3030. return this._weekdaysShortStrictRegex;
  3031. } else {
  3032. return this._weekdaysShortRegex;
  3033. }
  3034. } else {
  3035. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  3036. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  3037. }
  3038. return this._weekdaysShortStrictRegex && isStrict ?
  3039. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  3040. }
  3041. }
  3042. var defaultWeekdaysMinRegex = matchWord;
  3043. function weekdaysMinRegex (isStrict) {
  3044. if (this._weekdaysParseExact) {
  3045. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3046. computeWeekdaysParse.call(this);
  3047. }
  3048. if (isStrict) {
  3049. return this._weekdaysMinStrictRegex;
  3050. } else {
  3051. return this._weekdaysMinRegex;
  3052. }
  3053. } else {
  3054. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  3055. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  3056. }
  3057. return this._weekdaysMinStrictRegex && isStrict ?
  3058. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  3059. }
  3060. }
  3061. function computeWeekdaysParse () {
  3062. function cmpLenRev(a, b) {
  3063. return b.length - a.length;
  3064. }
  3065. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  3066. i, mom, minp, shortp, longp;
  3067. for (i = 0; i < 7; i++) {
  3068. // make the regex if we don't have it already
  3069. mom = createUTC([2000, 1]).day(i);
  3070. minp = this.weekdaysMin(mom, '');
  3071. shortp = this.weekdaysShort(mom, '');
  3072. longp = this.weekdays(mom, '');
  3073. minPieces.push(minp);
  3074. shortPieces.push(shortp);
  3075. longPieces.push(longp);
  3076. mixedPieces.push(minp);
  3077. mixedPieces.push(shortp);
  3078. mixedPieces.push(longp);
  3079. }
  3080. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  3081. // will match the longer piece.
  3082. minPieces.sort(cmpLenRev);
  3083. shortPieces.sort(cmpLenRev);
  3084. longPieces.sort(cmpLenRev);
  3085. mixedPieces.sort(cmpLenRev);
  3086. for (i = 0; i < 7; i++) {
  3087. shortPieces[i] = regexEscape(shortPieces[i]);
  3088. longPieces[i] = regexEscape(longPieces[i]);
  3089. mixedPieces[i] = regexEscape(mixedPieces[i]);
  3090. }
  3091. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  3092. this._weekdaysShortRegex = this._weekdaysRegex;
  3093. this._weekdaysMinRegex = this._weekdaysRegex;
  3094. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  3095. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  3096. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  3097. }
  3098. // FORMATTING
  3099. function hFormat() {
  3100. return this.hours() % 12 || 12;
  3101. }
  3102. function kFormat() {
  3103. return this.hours() || 24;
  3104. }
  3105. addFormatToken('H', ['HH', 2], 0, 'hour');
  3106. addFormatToken('h', ['hh', 2], 0, hFormat);
  3107. addFormatToken('k', ['kk', 2], 0, kFormat);
  3108. addFormatToken('hmm', 0, 0, function () {
  3109. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  3110. });
  3111. addFormatToken('hmmss', 0, 0, function () {
  3112. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  3113. zeroFill(this.seconds(), 2);
  3114. });
  3115. addFormatToken('Hmm', 0, 0, function () {
  3116. return '' + this.hours() + zeroFill(this.minutes(), 2);
  3117. });
  3118. addFormatToken('Hmmss', 0, 0, function () {
  3119. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  3120. zeroFill(this.seconds(), 2);
  3121. });
  3122. function meridiem (token, lowercase) {
  3123. addFormatToken(token, 0, 0, function () {
  3124. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  3125. });
  3126. }
  3127. meridiem('a', true);
  3128. meridiem('A', false);
  3129. // ALIASES
  3130. addUnitAlias('hour', 'h');
  3131. // PRIORITY
  3132. addUnitPriority('hour', 13);
  3133. // PARSING
  3134. function matchMeridiem (isStrict, locale) {
  3135. return locale._meridiemParse;
  3136. }
  3137. addRegexToken('a', matchMeridiem);
  3138. addRegexToken('A', matchMeridiem);
  3139. addRegexToken('H', match1to2);
  3140. addRegexToken('h', match1to2);
  3141. addRegexToken('k', match1to2);
  3142. addRegexToken('HH', match1to2, match2);
  3143. addRegexToken('hh', match1to2, match2);
  3144. addRegexToken('kk', match1to2, match2);
  3145. addRegexToken('hmm', match3to4);
  3146. addRegexToken('hmmss', match5to6);
  3147. addRegexToken('Hmm', match3to4);
  3148. addRegexToken('Hmmss', match5to6);
  3149. addParseToken(['H', 'HH'], HOUR);
  3150. addParseToken(['k', 'kk'], function (input, array, config) {
  3151. var kInput = toInt(input);
  3152. array[HOUR] = kInput === 24 ? 0 : kInput;
  3153. });
  3154. addParseToken(['a', 'A'], function (input, array, config) {
  3155. config._isPm = config._locale.isPM(input);
  3156. config._meridiem = input;
  3157. });
  3158. addParseToken(['h', 'hh'], function (input, array, config) {
  3159. array[HOUR] = toInt(input);
  3160. getParsingFlags(config).bigHour = true;
  3161. });
  3162. addParseToken('hmm', function (input, array, config) {
  3163. var pos = input.length - 2;
  3164. array[HOUR] = toInt(input.substr(0, pos));
  3165. array[MINUTE] = toInt(input.substr(pos));
  3166. getParsingFlags(config).bigHour = true;
  3167. });
  3168. addParseToken('hmmss', function (input, array, config) {
  3169. var pos1 = input.length - 4;
  3170. var pos2 = input.length - 2;
  3171. array[HOUR] = toInt(input.substr(0, pos1));
  3172. array[MINUTE] = toInt(input.substr(pos1, 2));
  3173. array[SECOND] = toInt(input.substr(pos2));
  3174. getParsingFlags(config).bigHour = true;
  3175. });
  3176. addParseToken('Hmm', function (input, array, config) {
  3177. var pos = input.length - 2;
  3178. array[HOUR] = toInt(input.substr(0, pos));
  3179. array[MINUTE] = toInt(input.substr(pos));
  3180. });
  3181. addParseToken('Hmmss', function (input, array, config) {
  3182. var pos1 = input.length - 4;
  3183. var pos2 = input.length - 2;
  3184. array[HOUR] = toInt(input.substr(0, pos1));
  3185. array[MINUTE] = toInt(input.substr(pos1, 2));
  3186. array[SECOND] = toInt(input.substr(pos2));
  3187. });
  3188. // LOCALES
  3189. function localeIsPM (input) {
  3190. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  3191. // Using charAt should be more compatible.
  3192. return ((input + '').toLowerCase().charAt(0) === 'p');
  3193. }
  3194. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  3195. function localeMeridiem (hours, minutes, isLower) {
  3196. if (hours > 11) {
  3197. return isLower ? 'pm' : 'PM';
  3198. } else {
  3199. return isLower ? 'am' : 'AM';
  3200. }
  3201. }
  3202. // MOMENTS
  3203. // Setting the hour should keep the time, because the user explicitly
  3204. // specified which hour they want. So trying to maintain the same hour (in
  3205. // a new timezone) makes sense. Adding/subtracting hours does not follow
  3206. // this rule.
  3207. var getSetHour = makeGetSet('Hours', true);
  3208. var baseConfig = {
  3209. calendar: defaultCalendar,
  3210. longDateFormat: defaultLongDateFormat,
  3211. invalidDate: defaultInvalidDate,
  3212. ordinal: defaultOrdinal,
  3213. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  3214. relativeTime: defaultRelativeTime,
  3215. months: defaultLocaleMonths,
  3216. monthsShort: defaultLocaleMonthsShort,
  3217. week: defaultLocaleWeek,
  3218. weekdays: defaultLocaleWeekdays,
  3219. weekdaysMin: defaultLocaleWeekdaysMin,
  3220. weekdaysShort: defaultLocaleWeekdaysShort,
  3221. meridiemParse: defaultLocaleMeridiemParse
  3222. };
  3223. // internal storage for locale config files
  3224. var locales = {};
  3225. var localeFamilies = {};
  3226. var globalLocale;
  3227. function normalizeLocale(key) {
  3228. return key ? key.toLowerCase().replace('_', '-') : key;
  3229. }
  3230. // pick the locale from the array
  3231. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  3232. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  3233. function chooseLocale(names) {
  3234. var i = 0, j, next, locale, split;
  3235. while (i < names.length) {
  3236. split = normalizeLocale(names[i]).split('-');
  3237. j = split.length;
  3238. next = normalizeLocale(names[i + 1]);
  3239. next = next ? next.split('-') : null;
  3240. while (j > 0) {
  3241. locale = loadLocale(split.slice(0, j).join('-'));
  3242. if (locale) {
  3243. return locale;
  3244. }
  3245. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  3246. //the next array item is better than a shallower substring of this one
  3247. break;
  3248. }
  3249. j--;
  3250. }
  3251. i++;
  3252. }
  3253. return globalLocale;
  3254. }
  3255. function loadLocale(name) {
  3256. var oldLocale = null;
  3257. // TODO: Find a better way to register and load all the locales in Node
  3258. if (!locales[name] && ('object' !== 'undefined') &&
  3259. module && module.exports) {
  3260. try {
  3261. oldLocale = globalLocale._abbr;
  3262. var aliasedRequire = commonjsRequire;
  3263. aliasedRequire('./locale/' + name);
  3264. getSetGlobalLocale(oldLocale);
  3265. } catch (e) {}
  3266. }
  3267. return locales[name];
  3268. }
  3269. // This function will load locale and then set the global locale. If
  3270. // no arguments are passed in, it will simply return the current global
  3271. // locale key.
  3272. function getSetGlobalLocale (key, values) {
  3273. var data;
  3274. if (key) {
  3275. if (isUndefined(values)) {
  3276. data = getLocale(key);
  3277. }
  3278. else {
  3279. data = defineLocale(key, values);
  3280. }
  3281. if (data) {
  3282. // moment.duration._locale = moment._locale = data;
  3283. globalLocale = data;
  3284. }
  3285. else {
  3286. if ((typeof console !== 'undefined') && console.warn) {
  3287. //warn user if arguments are passed but the locale could not be set
  3288. console.warn('Locale ' + key + ' not found. Did you forget to load it?');
  3289. }
  3290. }
  3291. }
  3292. return globalLocale._abbr;
  3293. }
  3294. function defineLocale (name, config) {
  3295. if (config !== null) {
  3296. var locale, parentConfig = baseConfig;
  3297. config.abbr = name;
  3298. if (locales[name] != null) {
  3299. deprecateSimple('defineLocaleOverride',
  3300. 'use moment.updateLocale(localeName, config) to change ' +
  3301. 'an existing locale. moment.defineLocale(localeName, ' +
  3302. 'config) should only be used for creating a new locale ' +
  3303. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  3304. parentConfig = locales[name]._config;
  3305. } else if (config.parentLocale != null) {
  3306. if (locales[config.parentLocale] != null) {
  3307. parentConfig = locales[config.parentLocale]._config;
  3308. } else {
  3309. locale = loadLocale(config.parentLocale);
  3310. if (locale != null) {
  3311. parentConfig = locale._config;
  3312. } else {
  3313. if (!localeFamilies[config.parentLocale]) {
  3314. localeFamilies[config.parentLocale] = [];
  3315. }
  3316. localeFamilies[config.parentLocale].push({
  3317. name: name,
  3318. config: config
  3319. });
  3320. return null;
  3321. }
  3322. }
  3323. }
  3324. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  3325. if (localeFamilies[name]) {
  3326. localeFamilies[name].forEach(function (x) {
  3327. defineLocale(x.name, x.config);
  3328. });
  3329. }
  3330. // backwards compat for now: also set the locale
  3331. // make sure we set the locale AFTER all child locales have been
  3332. // created, so we won't end up with the child locale set.
  3333. getSetGlobalLocale(name);
  3334. return locales[name];
  3335. } else {
  3336. // useful for testing
  3337. delete locales[name];
  3338. return null;
  3339. }
  3340. }
  3341. function updateLocale(name, config) {
  3342. if (config != null) {
  3343. var locale, tmpLocale, parentConfig = baseConfig;
  3344. // MERGE
  3345. tmpLocale = loadLocale(name);
  3346. if (tmpLocale != null) {
  3347. parentConfig = tmpLocale._config;
  3348. }
  3349. config = mergeConfigs(parentConfig, config);
  3350. locale = new Locale(config);
  3351. locale.parentLocale = locales[name];
  3352. locales[name] = locale;
  3353. // backwards compat for now: also set the locale
  3354. getSetGlobalLocale(name);
  3355. } else {
  3356. // pass null for config to unupdate, useful for tests
  3357. if (locales[name] != null) {
  3358. if (locales[name].parentLocale != null) {
  3359. locales[name] = locales[name].parentLocale;
  3360. } else if (locales[name] != null) {
  3361. delete locales[name];
  3362. }
  3363. }
  3364. }
  3365. return locales[name];
  3366. }
  3367. // returns locale data
  3368. function getLocale (key) {
  3369. var locale;
  3370. if (key && key._locale && key._locale._abbr) {
  3371. key = key._locale._abbr;
  3372. }
  3373. if (!key) {
  3374. return globalLocale;
  3375. }
  3376. if (!isArray(key)) {
  3377. //short-circuit everything else
  3378. locale = loadLocale(key);
  3379. if (locale) {
  3380. return locale;
  3381. }
  3382. key = [key];
  3383. }
  3384. return chooseLocale(key);
  3385. }
  3386. function listLocales() {
  3387. return keys(locales);
  3388. }
  3389. function checkOverflow (m) {
  3390. var overflow;
  3391. var a = m._a;
  3392. if (a && getParsingFlags(m).overflow === -2) {
  3393. overflow =
  3394. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  3395. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  3396. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  3397. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  3398. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  3399. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  3400. -1;
  3401. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  3402. overflow = DATE;
  3403. }
  3404. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  3405. overflow = WEEK;
  3406. }
  3407. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  3408. overflow = WEEKDAY;
  3409. }
  3410. getParsingFlags(m).overflow = overflow;
  3411. }
  3412. return m;
  3413. }
  3414. // Pick the first defined of two or three arguments.
  3415. function defaults(a, b, c) {
  3416. if (a != null) {
  3417. return a;
  3418. }
  3419. if (b != null) {
  3420. return b;
  3421. }
  3422. return c;
  3423. }
  3424. function currentDateArray(config) {
  3425. // hooks is actually the exported moment object
  3426. var nowValue = new Date(hooks.now());
  3427. if (config._useUTC) {
  3428. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  3429. }
  3430. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  3431. }
  3432. // convert an array to a date.
  3433. // the array should mirror the parameters below
  3434. // note: all values past the year are optional and will default to the lowest possible value.
  3435. // [year, month, day , hour, minute, second, millisecond]
  3436. function configFromArray (config) {
  3437. var i, date, input = [], currentDate, expectedWeekday, yearToUse;
  3438. if (config._d) {
  3439. return;
  3440. }
  3441. currentDate = currentDateArray(config);
  3442. //compute day of the year from weeks and weekdays
  3443. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  3444. dayOfYearFromWeekInfo(config);
  3445. }
  3446. //if the day of the year is set, figure out what it is
  3447. if (config._dayOfYear != null) {
  3448. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  3449. if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
  3450. getParsingFlags(config)._overflowDayOfYear = true;
  3451. }
  3452. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  3453. config._a[MONTH] = date.getUTCMonth();
  3454. config._a[DATE] = date.getUTCDate();
  3455. }
  3456. // Default to current date.
  3457. // * if no year, month, day of month are given, default to today
  3458. // * if day of month is given, default month and year
  3459. // * if month is given, default only year
  3460. // * if year is given, don't default anything
  3461. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  3462. config._a[i] = input[i] = currentDate[i];
  3463. }
  3464. // Zero out whatever was not defaulted, including time
  3465. for (; i < 7; i++) {
  3466. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  3467. }
  3468. // Check for 24:00:00.000
  3469. if (config._a[HOUR] === 24 &&
  3470. config._a[MINUTE] === 0 &&
  3471. config._a[SECOND] === 0 &&
  3472. config._a[MILLISECOND] === 0) {
  3473. config._nextDay = true;
  3474. config._a[HOUR] = 0;
  3475. }
  3476. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  3477. expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
  3478. // Apply timezone offset from input. The actual utcOffset can be changed
  3479. // with parseZone.
  3480. if (config._tzm != null) {
  3481. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3482. }
  3483. if (config._nextDay) {
  3484. config._a[HOUR] = 24;
  3485. }
  3486. // check for mismatching day of week
  3487. if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
  3488. getParsingFlags(config).weekdayMismatch = true;
  3489. }
  3490. }
  3491. function dayOfYearFromWeekInfo(config) {
  3492. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  3493. w = config._w;
  3494. if (w.GG != null || w.W != null || w.E != null) {
  3495. dow = 1;
  3496. doy = 4;
  3497. // TODO: We need to take the current isoWeekYear, but that depends on
  3498. // how we interpret now (local, utc, fixed offset). So create
  3499. // a now version of current config (take local/utc/offset flags, and
  3500. // create now).
  3501. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  3502. week = defaults(w.W, 1);
  3503. weekday = defaults(w.E, 1);
  3504. if (weekday < 1 || weekday > 7) {
  3505. weekdayOverflow = true;
  3506. }
  3507. } else {
  3508. dow = config._locale._week.dow;
  3509. doy = config._locale._week.doy;
  3510. var curWeek = weekOfYear(createLocal(), dow, doy);
  3511. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  3512. // Default to current week.
  3513. week = defaults(w.w, curWeek.week);
  3514. if (w.d != null) {
  3515. // weekday -- low day numbers are considered next week
  3516. weekday = w.d;
  3517. if (weekday < 0 || weekday > 6) {
  3518. weekdayOverflow = true;
  3519. }
  3520. } else if (w.e != null) {
  3521. // local weekday -- counting starts from beginning of week
  3522. weekday = w.e + dow;
  3523. if (w.e < 0 || w.e > 6) {
  3524. weekdayOverflow = true;
  3525. }
  3526. } else {
  3527. // default to beginning of week
  3528. weekday = dow;
  3529. }
  3530. }
  3531. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  3532. getParsingFlags(config)._overflowWeeks = true;
  3533. } else if (weekdayOverflow != null) {
  3534. getParsingFlags(config)._overflowWeekday = true;
  3535. } else {
  3536. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  3537. config._a[YEAR] = temp.year;
  3538. config._dayOfYear = temp.dayOfYear;
  3539. }
  3540. }
  3541. // iso 8601 regex
  3542. // 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)
  3543. 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)?)?$/;
  3544. 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)?)?$/;
  3545. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  3546. var isoDates = [
  3547. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  3548. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  3549. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  3550. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  3551. ['YYYY-DDD', /\d{4}-\d{3}/],
  3552. ['YYYY-MM', /\d{4}-\d\d/, false],
  3553. ['YYYYYYMMDD', /[+-]\d{10}/],
  3554. ['YYYYMMDD', /\d{8}/],
  3555. // YYYYMM is NOT allowed by the standard
  3556. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  3557. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  3558. ['YYYYDDD', /\d{7}/]
  3559. ];
  3560. // iso time formats and regexes
  3561. var isoTimes = [
  3562. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  3563. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  3564. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  3565. ['HH:mm', /\d\d:\d\d/],
  3566. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  3567. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  3568. ['HHmmss', /\d\d\d\d\d\d/],
  3569. ['HHmm', /\d\d\d\d/],
  3570. ['HH', /\d\d/]
  3571. ];
  3572. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  3573. // date from iso format
  3574. function configFromISO(config) {
  3575. var i, l,
  3576. string = config._i,
  3577. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  3578. allowTime, dateFormat, timeFormat, tzFormat;
  3579. if (match) {
  3580. getParsingFlags(config).iso = true;
  3581. for (i = 0, l = isoDates.length; i < l; i++) {
  3582. if (isoDates[i][1].exec(match[1])) {
  3583. dateFormat = isoDates[i][0];
  3584. allowTime = isoDates[i][2] !== false;
  3585. break;
  3586. }
  3587. }
  3588. if (dateFormat == null) {
  3589. config._isValid = false;
  3590. return;
  3591. }
  3592. if (match[3]) {
  3593. for (i = 0, l = isoTimes.length; i < l; i++) {
  3594. if (isoTimes[i][1].exec(match[3])) {
  3595. // match[2] should be 'T' or space
  3596. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  3597. break;
  3598. }
  3599. }
  3600. if (timeFormat == null) {
  3601. config._isValid = false;
  3602. return;
  3603. }
  3604. }
  3605. if (!allowTime && timeFormat != null) {
  3606. config._isValid = false;
  3607. return;
  3608. }
  3609. if (match[4]) {
  3610. if (tzRegex.exec(match[4])) {
  3611. tzFormat = 'Z';
  3612. } else {
  3613. config._isValid = false;
  3614. return;
  3615. }
  3616. }
  3617. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  3618. configFromStringAndFormat(config);
  3619. } else {
  3620. config._isValid = false;
  3621. }
  3622. }
  3623. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  3624. 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}))$/;
  3625. function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  3626. var result = [
  3627. untruncateYear(yearStr),
  3628. defaultLocaleMonthsShort.indexOf(monthStr),
  3629. parseInt(dayStr, 10),
  3630. parseInt(hourStr, 10),
  3631. parseInt(minuteStr, 10)
  3632. ];
  3633. if (secondStr) {
  3634. result.push(parseInt(secondStr, 10));
  3635. }
  3636. return result;
  3637. }
  3638. function untruncateYear(yearStr) {
  3639. var year = parseInt(yearStr, 10);
  3640. if (year <= 49) {
  3641. return 2000 + year;
  3642. } else if (year <= 999) {
  3643. return 1900 + year;
  3644. }
  3645. return year;
  3646. }
  3647. function preprocessRFC2822(s) {
  3648. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  3649. return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  3650. }
  3651. function checkWeekday(weekdayStr, parsedInput, config) {
  3652. if (weekdayStr) {
  3653. // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
  3654. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  3655. weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
  3656. if (weekdayProvided !== weekdayActual) {
  3657. getParsingFlags(config).weekdayMismatch = true;
  3658. config._isValid = false;
  3659. return false;
  3660. }
  3661. }
  3662. return true;
  3663. }
  3664. var obsOffsets = {
  3665. UT: 0,
  3666. GMT: 0,
  3667. EDT: -4 * 60,
  3668. EST: -5 * 60,
  3669. CDT: -5 * 60,
  3670. CST: -6 * 60,
  3671. MDT: -6 * 60,
  3672. MST: -7 * 60,
  3673. PDT: -7 * 60,
  3674. PST: -8 * 60
  3675. };
  3676. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  3677. if (obsOffset) {
  3678. return obsOffsets[obsOffset];
  3679. } else if (militaryOffset) {
  3680. // the only allowed military tz is Z
  3681. return 0;
  3682. } else {
  3683. var hm = parseInt(numOffset, 10);
  3684. var m = hm % 100, h = (hm - m) / 100;
  3685. return h * 60 + m;
  3686. }
  3687. }
  3688. // date and time from ref 2822 format
  3689. function configFromRFC2822(config) {
  3690. var match = rfc2822.exec(preprocessRFC2822(config._i));
  3691. if (match) {
  3692. var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
  3693. if (!checkWeekday(match[1], parsedArray, config)) {
  3694. return;
  3695. }
  3696. config._a = parsedArray;
  3697. config._tzm = calculateOffset(match[8], match[9], match[10]);
  3698. config._d = createUTCDate.apply(null, config._a);
  3699. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3700. getParsingFlags(config).rfc2822 = true;
  3701. } else {
  3702. config._isValid = false;
  3703. }
  3704. }
  3705. // date from iso format or fallback
  3706. function configFromString(config) {
  3707. var matched = aspNetJsonRegex.exec(config._i);
  3708. if (matched !== null) {
  3709. config._d = new Date(+matched[1]);
  3710. return;
  3711. }
  3712. configFromISO(config);
  3713. if (config._isValid === false) {
  3714. delete config._isValid;
  3715. } else {
  3716. return;
  3717. }
  3718. configFromRFC2822(config);
  3719. if (config._isValid === false) {
  3720. delete config._isValid;
  3721. } else {
  3722. return;
  3723. }
  3724. // Final attempt, use Input Fallback
  3725. hooks.createFromInputFallback(config);
  3726. }
  3727. hooks.createFromInputFallback = deprecate(
  3728. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  3729. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  3730. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  3731. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  3732. function (config) {
  3733. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  3734. }
  3735. );
  3736. // constant that refers to the ISO standard
  3737. hooks.ISO_8601 = function () {};
  3738. // constant that refers to the RFC 2822 form
  3739. hooks.RFC_2822 = function () {};
  3740. // date from string and format string
  3741. function configFromStringAndFormat(config) {
  3742. // TODO: Move this to another part of the creation flow to prevent circular deps
  3743. if (config._f === hooks.ISO_8601) {
  3744. configFromISO(config);
  3745. return;
  3746. }
  3747. if (config._f === hooks.RFC_2822) {
  3748. configFromRFC2822(config);
  3749. return;
  3750. }
  3751. config._a = [];
  3752. getParsingFlags(config).empty = true;
  3753. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  3754. var string = '' + config._i,
  3755. i, parsedInput, tokens, token, skipped,
  3756. stringLength = string.length,
  3757. totalParsedInputLength = 0;
  3758. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  3759. for (i = 0; i < tokens.length; i++) {
  3760. token = tokens[i];
  3761. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  3762. // console.log('token', token, 'parsedInput', parsedInput,
  3763. // 'regex', getParseRegexForToken(token, config));
  3764. if (parsedInput) {
  3765. skipped = string.substr(0, string.indexOf(parsedInput));
  3766. if (skipped.length > 0) {
  3767. getParsingFlags(config).unusedInput.push(skipped);
  3768. }
  3769. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  3770. totalParsedInputLength += parsedInput.length;
  3771. }
  3772. // don't parse if it's not a known token
  3773. if (formatTokenFunctions[token]) {
  3774. if (parsedInput) {
  3775. getParsingFlags(config).empty = false;
  3776. }
  3777. else {
  3778. getParsingFlags(config).unusedTokens.push(token);
  3779. }
  3780. addTimeToArrayFromToken(token, parsedInput, config);
  3781. }
  3782. else if (config._strict && !parsedInput) {
  3783. getParsingFlags(config).unusedTokens.push(token);
  3784. }
  3785. }
  3786. // add remaining unparsed input length to the string
  3787. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  3788. if (string.length > 0) {
  3789. getParsingFlags(config).unusedInput.push(string);
  3790. }
  3791. // clear _12h flag if hour is <= 12
  3792. if (config._a[HOUR] <= 12 &&
  3793. getParsingFlags(config).bigHour === true &&
  3794. config._a[HOUR] > 0) {
  3795. getParsingFlags(config).bigHour = undefined;
  3796. }
  3797. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  3798. getParsingFlags(config).meridiem = config._meridiem;
  3799. // handle meridiem
  3800. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  3801. configFromArray(config);
  3802. checkOverflow(config);
  3803. }
  3804. function meridiemFixWrap (locale, hour, meridiem) {
  3805. var isPm;
  3806. if (meridiem == null) {
  3807. // nothing to do
  3808. return hour;
  3809. }
  3810. if (locale.meridiemHour != null) {
  3811. return locale.meridiemHour(hour, meridiem);
  3812. } else if (locale.isPM != null) {
  3813. // Fallback
  3814. isPm = locale.isPM(meridiem);
  3815. if (isPm && hour < 12) {
  3816. hour += 12;
  3817. }
  3818. if (!isPm && hour === 12) {
  3819. hour = 0;
  3820. }
  3821. return hour;
  3822. } else {
  3823. // this is not supposed to happen
  3824. return hour;
  3825. }
  3826. }
  3827. // date from string and array of format strings
  3828. function configFromStringAndArray(config) {
  3829. var tempConfig,
  3830. bestMoment,
  3831. scoreToBeat,
  3832. i,
  3833. currentScore;
  3834. if (config._f.length === 0) {
  3835. getParsingFlags(config).invalidFormat = true;
  3836. config._d = new Date(NaN);
  3837. return;
  3838. }
  3839. for (i = 0; i < config._f.length; i++) {
  3840. currentScore = 0;
  3841. tempConfig = copyConfig({}, config);
  3842. if (config._useUTC != null) {
  3843. tempConfig._useUTC = config._useUTC;
  3844. }
  3845. tempConfig._f = config._f[i];
  3846. configFromStringAndFormat(tempConfig);
  3847. if (!isValid(tempConfig)) {
  3848. continue;
  3849. }
  3850. // if there is any input that was not parsed add a penalty for that format
  3851. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  3852. //or tokens
  3853. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  3854. getParsingFlags(tempConfig).score = currentScore;
  3855. if (scoreToBeat == null || currentScore < scoreToBeat) {
  3856. scoreToBeat = currentScore;
  3857. bestMoment = tempConfig;
  3858. }
  3859. }
  3860. extend(config, bestMoment || tempConfig);
  3861. }
  3862. function configFromObject(config) {
  3863. if (config._d) {
  3864. return;
  3865. }
  3866. var i = normalizeObjectUnits(config._i);
  3867. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  3868. return obj && parseInt(obj, 10);
  3869. });
  3870. configFromArray(config);
  3871. }
  3872. function createFromConfig (config) {
  3873. var res = new Moment(checkOverflow(prepareConfig(config)));
  3874. if (res._nextDay) {
  3875. // Adding is smart enough around DST
  3876. res.add(1, 'd');
  3877. res._nextDay = undefined;
  3878. }
  3879. return res;
  3880. }
  3881. function prepareConfig (config) {
  3882. var input = config._i,
  3883. format = config._f;
  3884. config._locale = config._locale || getLocale(config._l);
  3885. if (input === null || (format === undefined && input === '')) {
  3886. return createInvalid({nullInput: true});
  3887. }
  3888. if (typeof input === 'string') {
  3889. config._i = input = config._locale.preparse(input);
  3890. }
  3891. if (isMoment(input)) {
  3892. return new Moment(checkOverflow(input));
  3893. } else if (isDate(input)) {
  3894. config._d = input;
  3895. } else if (isArray(format)) {
  3896. configFromStringAndArray(config);
  3897. } else if (format) {
  3898. configFromStringAndFormat(config);
  3899. } else {
  3900. configFromInput(config);
  3901. }
  3902. if (!isValid(config)) {
  3903. config._d = null;
  3904. }
  3905. return config;
  3906. }
  3907. function configFromInput(config) {
  3908. var input = config._i;
  3909. if (isUndefined(input)) {
  3910. config._d = new Date(hooks.now());
  3911. } else if (isDate(input)) {
  3912. config._d = new Date(input.valueOf());
  3913. } else if (typeof input === 'string') {
  3914. configFromString(config);
  3915. } else if (isArray(input)) {
  3916. config._a = map(input.slice(0), function (obj) {
  3917. return parseInt(obj, 10);
  3918. });
  3919. configFromArray(config);
  3920. } else if (isObject(input)) {
  3921. configFromObject(config);
  3922. } else if (isNumber(input)) {
  3923. // from milliseconds
  3924. config._d = new Date(input);
  3925. } else {
  3926. hooks.createFromInputFallback(config);
  3927. }
  3928. }
  3929. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  3930. var c = {};
  3931. if (locale === true || locale === false) {
  3932. strict = locale;
  3933. locale = undefined;
  3934. }
  3935. if ((isObject(input) && isObjectEmpty(input)) ||
  3936. (isArray(input) && input.length === 0)) {
  3937. input = undefined;
  3938. }
  3939. // object construction must be done this way.
  3940. // https://github.com/moment/moment/issues/1423
  3941. c._isAMomentObject = true;
  3942. c._useUTC = c._isUTC = isUTC;
  3943. c._l = locale;
  3944. c._i = input;
  3945. c._f = format;
  3946. c._strict = strict;
  3947. return createFromConfig(c);
  3948. }
  3949. function createLocal (input, format, locale, strict) {
  3950. return createLocalOrUTC(input, format, locale, strict, false);
  3951. }
  3952. var prototypeMin = deprecate(
  3953. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  3954. function () {
  3955. var other = createLocal.apply(null, arguments);
  3956. if (this.isValid() && other.isValid()) {
  3957. return other < this ? this : other;
  3958. } else {
  3959. return createInvalid();
  3960. }
  3961. }
  3962. );
  3963. var prototypeMax = deprecate(
  3964. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  3965. function () {
  3966. var other = createLocal.apply(null, arguments);
  3967. if (this.isValid() && other.isValid()) {
  3968. return other > this ? this : other;
  3969. } else {
  3970. return createInvalid();
  3971. }
  3972. }
  3973. );
  3974. // Pick a moment m from moments so that m[fn](other) is true for all
  3975. // other. This relies on the function fn to be transitive.
  3976. //
  3977. // moments should either be an array of moment objects or an array, whose
  3978. // first element is an array of moment objects.
  3979. function pickBy(fn, moments) {
  3980. var res, i;
  3981. if (moments.length === 1 && isArray(moments[0])) {
  3982. moments = moments[0];
  3983. }
  3984. if (!moments.length) {
  3985. return createLocal();
  3986. }
  3987. res = moments[0];
  3988. for (i = 1; i < moments.length; ++i) {
  3989. if (!moments[i].isValid() || moments[i][fn](res)) {
  3990. res = moments[i];
  3991. }
  3992. }
  3993. return res;
  3994. }
  3995. // TODO: Use [].sort instead?
  3996. function min () {
  3997. var args = [].slice.call(arguments, 0);
  3998. return pickBy('isBefore', args);
  3999. }
  4000. function max () {
  4001. var args = [].slice.call(arguments, 0);
  4002. return pickBy('isAfter', args);
  4003. }
  4004. var now = function () {
  4005. return Date.now ? Date.now() : +(new Date());
  4006. };
  4007. var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
  4008. function isDurationValid(m) {
  4009. for (var key in m) {
  4010. if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
  4011. return false;
  4012. }
  4013. }
  4014. var unitHasDecimal = false;
  4015. for (var i = 0; i < ordering.length; ++i) {
  4016. if (m[ordering[i]]) {
  4017. if (unitHasDecimal) {
  4018. return false; // only allow non-integers for smallest unit
  4019. }
  4020. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  4021. unitHasDecimal = true;
  4022. }
  4023. }
  4024. }
  4025. return true;
  4026. }
  4027. function isValid$1() {
  4028. return this._isValid;
  4029. }
  4030. function createInvalid$1() {
  4031. return createDuration(NaN);
  4032. }
  4033. function Duration (duration) {
  4034. var normalizedInput = normalizeObjectUnits(duration),
  4035. years = normalizedInput.year || 0,
  4036. quarters = normalizedInput.quarter || 0,
  4037. months = normalizedInput.month || 0,
  4038. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  4039. days = normalizedInput.day || 0,
  4040. hours = normalizedInput.hour || 0,
  4041. minutes = normalizedInput.minute || 0,
  4042. seconds = normalizedInput.second || 0,
  4043. milliseconds = normalizedInput.millisecond || 0;
  4044. this._isValid = isDurationValid(normalizedInput);
  4045. // representation for dateAddRemove
  4046. this._milliseconds = +milliseconds +
  4047. seconds * 1e3 + // 1000
  4048. minutes * 6e4 + // 1000 * 60
  4049. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  4050. // Because of dateAddRemove treats 24 hours as different from a
  4051. // day when working around DST, we need to store them separately
  4052. this._days = +days +
  4053. weeks * 7;
  4054. // It is impossible to translate months into days without knowing
  4055. // which months you are are talking about, so we have to store
  4056. // it separately.
  4057. this._months = +months +
  4058. quarters * 3 +
  4059. years * 12;
  4060. this._data = {};
  4061. this._locale = getLocale();
  4062. this._bubble();
  4063. }
  4064. function isDuration (obj) {
  4065. return obj instanceof Duration;
  4066. }
  4067. function absRound (number) {
  4068. if (number < 0) {
  4069. return Math.round(-1 * number) * -1;
  4070. } else {
  4071. return Math.round(number);
  4072. }
  4073. }
  4074. // FORMATTING
  4075. function offset (token, separator) {
  4076. addFormatToken(token, 0, 0, function () {
  4077. var offset = this.utcOffset();
  4078. var sign = '+';
  4079. if (offset < 0) {
  4080. offset = -offset;
  4081. sign = '-';
  4082. }
  4083. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  4084. });
  4085. }
  4086. offset('Z', ':');
  4087. offset('ZZ', '');
  4088. // PARSING
  4089. addRegexToken('Z', matchShortOffset);
  4090. addRegexToken('ZZ', matchShortOffset);
  4091. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  4092. config._useUTC = true;
  4093. config._tzm = offsetFromString(matchShortOffset, input);
  4094. });
  4095. // HELPERS
  4096. // timezone chunker
  4097. // '+10:00' > ['10', '00']
  4098. // '-1530' > ['-15', '30']
  4099. var chunkOffset = /([\+\-]|\d\d)/gi;
  4100. function offsetFromString(matcher, string) {
  4101. var matches = (string || '').match(matcher);
  4102. if (matches === null) {
  4103. return null;
  4104. }
  4105. var chunk = matches[matches.length - 1] || [];
  4106. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  4107. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  4108. return minutes === 0 ?
  4109. 0 :
  4110. parts[0] === '+' ? minutes : -minutes;
  4111. }
  4112. // Return a moment from input, that is local/utc/zone equivalent to model.
  4113. function cloneWithOffset(input, model) {
  4114. var res, diff;
  4115. if (model._isUTC) {
  4116. res = model.clone();
  4117. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  4118. // Use low-level api, because this fn is low-level api.
  4119. res._d.setTime(res._d.valueOf() + diff);
  4120. hooks.updateOffset(res, false);
  4121. return res;
  4122. } else {
  4123. return createLocal(input).local();
  4124. }
  4125. }
  4126. function getDateOffset (m) {
  4127. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  4128. // https://github.com/moment/moment/pull/1871
  4129. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  4130. }
  4131. // HOOKS
  4132. // This function will be called whenever a moment is mutated.
  4133. // It is intended to keep the offset in sync with the timezone.
  4134. hooks.updateOffset = function () {};
  4135. // MOMENTS
  4136. // keepLocalTime = true means only change the timezone, without
  4137. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  4138. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  4139. // +0200, so we adjust the time as needed, to be valid.
  4140. //
  4141. // Keeping the time actually adds/subtracts (one hour)
  4142. // from the actual represented time. That is why we call updateOffset
  4143. // a second time. In case it wants us to change the offset again
  4144. // _changeInProgress == true case, then we have to adjust, because
  4145. // there is no such time in the given timezone.
  4146. function getSetOffset (input, keepLocalTime, keepMinutes) {
  4147. var offset = this._offset || 0,
  4148. localAdjust;
  4149. if (!this.isValid()) {
  4150. return input != null ? this : NaN;
  4151. }
  4152. if (input != null) {
  4153. if (typeof input === 'string') {
  4154. input = offsetFromString(matchShortOffset, input);
  4155. if (input === null) {
  4156. return this;
  4157. }
  4158. } else if (Math.abs(input) < 16 && !keepMinutes) {
  4159. input = input * 60;
  4160. }
  4161. if (!this._isUTC && keepLocalTime) {
  4162. localAdjust = getDateOffset(this);
  4163. }
  4164. this._offset = input;
  4165. this._isUTC = true;
  4166. if (localAdjust != null) {
  4167. this.add(localAdjust, 'm');
  4168. }
  4169. if (offset !== input) {
  4170. if (!keepLocalTime || this._changeInProgress) {
  4171. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  4172. } else if (!this._changeInProgress) {
  4173. this._changeInProgress = true;
  4174. hooks.updateOffset(this, true);
  4175. this._changeInProgress = null;
  4176. }
  4177. }
  4178. return this;
  4179. } else {
  4180. return this._isUTC ? offset : getDateOffset(this);
  4181. }
  4182. }
  4183. function getSetZone (input, keepLocalTime) {
  4184. if (input != null) {
  4185. if (typeof input !== 'string') {
  4186. input = -input;
  4187. }
  4188. this.utcOffset(input, keepLocalTime);
  4189. return this;
  4190. } else {
  4191. return -this.utcOffset();
  4192. }
  4193. }
  4194. function setOffsetToUTC (keepLocalTime) {
  4195. return this.utcOffset(0, keepLocalTime);
  4196. }
  4197. function setOffsetToLocal (keepLocalTime) {
  4198. if (this._isUTC) {
  4199. this.utcOffset(0, keepLocalTime);
  4200. this._isUTC = false;
  4201. if (keepLocalTime) {
  4202. this.subtract(getDateOffset(this), 'm');
  4203. }
  4204. }
  4205. return this;
  4206. }
  4207. function setOffsetToParsedOffset () {
  4208. if (this._tzm != null) {
  4209. this.utcOffset(this._tzm, false, true);
  4210. } else if (typeof this._i === 'string') {
  4211. var tZone = offsetFromString(matchOffset, this._i);
  4212. if (tZone != null) {
  4213. this.utcOffset(tZone);
  4214. }
  4215. else {
  4216. this.utcOffset(0, true);
  4217. }
  4218. }
  4219. return this;
  4220. }
  4221. function hasAlignedHourOffset (input) {
  4222. if (!this.isValid()) {
  4223. return false;
  4224. }
  4225. input = input ? createLocal(input).utcOffset() : 0;
  4226. return (this.utcOffset() - input) % 60 === 0;
  4227. }
  4228. function isDaylightSavingTime () {
  4229. return (
  4230. this.utcOffset() > this.clone().month(0).utcOffset() ||
  4231. this.utcOffset() > this.clone().month(5).utcOffset()
  4232. );
  4233. }
  4234. function isDaylightSavingTimeShifted () {
  4235. if (!isUndefined(this._isDSTShifted)) {
  4236. return this._isDSTShifted;
  4237. }
  4238. var c = {};
  4239. copyConfig(c, this);
  4240. c = prepareConfig(c);
  4241. if (c._a) {
  4242. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  4243. this._isDSTShifted = this.isValid() &&
  4244. compareArrays(c._a, other.toArray()) > 0;
  4245. } else {
  4246. this._isDSTShifted = false;
  4247. }
  4248. return this._isDSTShifted;
  4249. }
  4250. function isLocal () {
  4251. return this.isValid() ? !this._isUTC : false;
  4252. }
  4253. function isUtcOffset () {
  4254. return this.isValid() ? this._isUTC : false;
  4255. }
  4256. function isUtc () {
  4257. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  4258. }
  4259. // ASP.NET json date format regex
  4260. var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  4261. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  4262. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  4263. // and further modified to allow for strings containing both week and day
  4264. 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)?)?$/;
  4265. function createDuration (input, key) {
  4266. var duration = input,
  4267. // matching against regexp is expensive, do it on demand
  4268. match = null,
  4269. sign,
  4270. ret,
  4271. diffRes;
  4272. if (isDuration(input)) {
  4273. duration = {
  4274. ms : input._milliseconds,
  4275. d : input._days,
  4276. M : input._months
  4277. };
  4278. } else if (isNumber(input)) {
  4279. duration = {};
  4280. if (key) {
  4281. duration[key] = input;
  4282. } else {
  4283. duration.milliseconds = input;
  4284. }
  4285. } else if (!!(match = aspNetRegex.exec(input))) {
  4286. sign = (match[1] === '-') ? -1 : 1;
  4287. duration = {
  4288. y : 0,
  4289. d : toInt(match[DATE]) * sign,
  4290. h : toInt(match[HOUR]) * sign,
  4291. m : toInt(match[MINUTE]) * sign,
  4292. s : toInt(match[SECOND]) * sign,
  4293. ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  4294. };
  4295. } else if (!!(match = isoRegex.exec(input))) {
  4296. sign = (match[1] === '-') ? -1 : 1;
  4297. duration = {
  4298. y : parseIso(match[2], sign),
  4299. M : parseIso(match[3], sign),
  4300. w : parseIso(match[4], sign),
  4301. d : parseIso(match[5], sign),
  4302. h : parseIso(match[6], sign),
  4303. m : parseIso(match[7], sign),
  4304. s : parseIso(match[8], sign)
  4305. };
  4306. } else if (duration == null) {// checks for null or undefined
  4307. duration = {};
  4308. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  4309. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  4310. duration = {};
  4311. duration.ms = diffRes.milliseconds;
  4312. duration.M = diffRes.months;
  4313. }
  4314. ret = new Duration(duration);
  4315. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  4316. ret._locale = input._locale;
  4317. }
  4318. return ret;
  4319. }
  4320. createDuration.fn = Duration.prototype;
  4321. createDuration.invalid = createInvalid$1;
  4322. function parseIso (inp, sign) {
  4323. // We'd normally use ~~inp for this, but unfortunately it also
  4324. // converts floats to ints.
  4325. // inp may be undefined, so careful calling replace on it.
  4326. var res = inp && parseFloat(inp.replace(',', '.'));
  4327. // apply sign while we're at it
  4328. return (isNaN(res) ? 0 : res) * sign;
  4329. }
  4330. function positiveMomentsDifference(base, other) {
  4331. var res = {};
  4332. res.months = other.month() - base.month() +
  4333. (other.year() - base.year()) * 12;
  4334. if (base.clone().add(res.months, 'M').isAfter(other)) {
  4335. --res.months;
  4336. }
  4337. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  4338. return res;
  4339. }
  4340. function momentsDifference(base, other) {
  4341. var res;
  4342. if (!(base.isValid() && other.isValid())) {
  4343. return {milliseconds: 0, months: 0};
  4344. }
  4345. other = cloneWithOffset(other, base);
  4346. if (base.isBefore(other)) {
  4347. res = positiveMomentsDifference(base, other);
  4348. } else {
  4349. res = positiveMomentsDifference(other, base);
  4350. res.milliseconds = -res.milliseconds;
  4351. res.months = -res.months;
  4352. }
  4353. return res;
  4354. }
  4355. // TODO: remove 'name' arg after deprecation is removed
  4356. function createAdder(direction, name) {
  4357. return function (val, period) {
  4358. var dur, tmp;
  4359. //invert the arguments, but complain about it
  4360. if (period !== null && !isNaN(+period)) {
  4361. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  4362. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  4363. tmp = val; val = period; period = tmp;
  4364. }
  4365. val = typeof val === 'string' ? +val : val;
  4366. dur = createDuration(val, period);
  4367. addSubtract(this, dur, direction);
  4368. return this;
  4369. };
  4370. }
  4371. function addSubtract (mom, duration, isAdding, updateOffset) {
  4372. var milliseconds = duration._milliseconds,
  4373. days = absRound(duration._days),
  4374. months = absRound(duration._months);
  4375. if (!mom.isValid()) {
  4376. // No op
  4377. return;
  4378. }
  4379. updateOffset = updateOffset == null ? true : updateOffset;
  4380. if (months) {
  4381. setMonth(mom, get(mom, 'Month') + months * isAdding);
  4382. }
  4383. if (days) {
  4384. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  4385. }
  4386. if (milliseconds) {
  4387. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  4388. }
  4389. if (updateOffset) {
  4390. hooks.updateOffset(mom, days || months);
  4391. }
  4392. }
  4393. var add = createAdder(1, 'add');
  4394. var subtract = createAdder(-1, 'subtract');
  4395. function getCalendarFormat(myMoment, now) {
  4396. var diff = myMoment.diff(now, 'days', true);
  4397. return diff < -6 ? 'sameElse' :
  4398. diff < -1 ? 'lastWeek' :
  4399. diff < 0 ? 'lastDay' :
  4400. diff < 1 ? 'sameDay' :
  4401. diff < 2 ? 'nextDay' :
  4402. diff < 7 ? 'nextWeek' : 'sameElse';
  4403. }
  4404. function calendar$1 (time, formats) {
  4405. // We want to compare the start of today, vs this.
  4406. // Getting start-of-today depends on whether we're local/utc/offset or not.
  4407. var now = time || createLocal(),
  4408. sod = cloneWithOffset(now, this).startOf('day'),
  4409. format = hooks.calendarFormat(this, sod) || 'sameElse';
  4410. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  4411. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  4412. }
  4413. function clone () {
  4414. return new Moment(this);
  4415. }
  4416. function isAfter (input, units) {
  4417. var localInput = isMoment(input) ? input : createLocal(input);
  4418. if (!(this.isValid() && localInput.isValid())) {
  4419. return false;
  4420. }
  4421. units = normalizeUnits(units) || 'millisecond';
  4422. if (units === 'millisecond') {
  4423. return this.valueOf() > localInput.valueOf();
  4424. } else {
  4425. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  4426. }
  4427. }
  4428. function isBefore (input, units) {
  4429. var localInput = isMoment(input) ? input : createLocal(input);
  4430. if (!(this.isValid() && localInput.isValid())) {
  4431. return false;
  4432. }
  4433. units = normalizeUnits(units) || 'millisecond';
  4434. if (units === 'millisecond') {
  4435. return this.valueOf() < localInput.valueOf();
  4436. } else {
  4437. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  4438. }
  4439. }
  4440. function isBetween (from, to, units, inclusivity) {
  4441. var localFrom = isMoment(from) ? from : createLocal(from),
  4442. localTo = isMoment(to) ? to : createLocal(to);
  4443. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  4444. return false;
  4445. }
  4446. inclusivity = inclusivity || '()';
  4447. return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
  4448. (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
  4449. }
  4450. function isSame (input, units) {
  4451. var localInput = isMoment(input) ? input : createLocal(input),
  4452. inputMs;
  4453. if (!(this.isValid() && localInput.isValid())) {
  4454. return false;
  4455. }
  4456. units = normalizeUnits(units) || 'millisecond';
  4457. if (units === 'millisecond') {
  4458. return this.valueOf() === localInput.valueOf();
  4459. } else {
  4460. inputMs = localInput.valueOf();
  4461. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  4462. }
  4463. }
  4464. function isSameOrAfter (input, units) {
  4465. return this.isSame(input, units) || this.isAfter(input, units);
  4466. }
  4467. function isSameOrBefore (input, units) {
  4468. return this.isSame(input, units) || this.isBefore(input, units);
  4469. }
  4470. function diff (input, units, asFloat) {
  4471. var that,
  4472. zoneDelta,
  4473. output;
  4474. if (!this.isValid()) {
  4475. return NaN;
  4476. }
  4477. that = cloneWithOffset(input, this);
  4478. if (!that.isValid()) {
  4479. return NaN;
  4480. }
  4481. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  4482. units = normalizeUnits(units);
  4483. switch (units) {
  4484. case 'year': output = monthDiff(this, that) / 12; break;
  4485. case 'month': output = monthDiff(this, that); break;
  4486. case 'quarter': output = monthDiff(this, that) / 3; break;
  4487. case 'second': output = (this - that) / 1e3; break; // 1000
  4488. case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
  4489. case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
  4490. case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
  4491. case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
  4492. default: output = this - that;
  4493. }
  4494. return asFloat ? output : absFloor(output);
  4495. }
  4496. function monthDiff (a, b) {
  4497. // difference in months
  4498. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  4499. // b is in (anchor - 1 month, anchor + 1 month)
  4500. anchor = a.clone().add(wholeMonthDiff, 'months'),
  4501. anchor2, adjust;
  4502. if (b - anchor < 0) {
  4503. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  4504. // linear across the month
  4505. adjust = (b - anchor) / (anchor - anchor2);
  4506. } else {
  4507. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  4508. // linear across the month
  4509. adjust = (b - anchor) / (anchor2 - anchor);
  4510. }
  4511. //check for negative zero, return zero if negative zero
  4512. return -(wholeMonthDiff + adjust) || 0;
  4513. }
  4514. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  4515. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  4516. function toString () {
  4517. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  4518. }
  4519. function toISOString(keepOffset) {
  4520. if (!this.isValid()) {
  4521. return null;
  4522. }
  4523. var utc = keepOffset !== true;
  4524. var m = utc ? this.clone().utc() : this;
  4525. if (m.year() < 0 || m.year() > 9999) {
  4526. return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
  4527. }
  4528. if (isFunction(Date.prototype.toISOString)) {
  4529. // native implementation is ~50x faster, use it when we can
  4530. if (utc) {
  4531. return this.toDate().toISOString();
  4532. } else {
  4533. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
  4534. }
  4535. }
  4536. return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
  4537. }
  4538. /**
  4539. * Return a human readable representation of a moment that can
  4540. * also be evaluated to get a new moment which is the same
  4541. *
  4542. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  4543. */
  4544. function inspect () {
  4545. if (!this.isValid()) {
  4546. return 'moment.invalid(/* ' + this._i + ' */)';
  4547. }
  4548. var func = 'moment';
  4549. var zone = '';
  4550. if (!this.isLocal()) {
  4551. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  4552. zone = 'Z';
  4553. }
  4554. var prefix = '[' + func + '("]';
  4555. var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  4556. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  4557. var suffix = zone + '[")]';
  4558. return this.format(prefix + year + datetime + suffix);
  4559. }
  4560. function format (inputString) {
  4561. if (!inputString) {
  4562. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  4563. }
  4564. var output = formatMoment(this, inputString);
  4565. return this.localeData().postformat(output);
  4566. }
  4567. function from (time, withoutSuffix) {
  4568. if (this.isValid() &&
  4569. ((isMoment(time) && time.isValid()) ||
  4570. createLocal(time).isValid())) {
  4571. return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  4572. } else {
  4573. return this.localeData().invalidDate();
  4574. }
  4575. }
  4576. function fromNow (withoutSuffix) {
  4577. return this.from(createLocal(), withoutSuffix);
  4578. }
  4579. function to (time, withoutSuffix) {
  4580. if (this.isValid() &&
  4581. ((isMoment(time) && time.isValid()) ||
  4582. createLocal(time).isValid())) {
  4583. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  4584. } else {
  4585. return this.localeData().invalidDate();
  4586. }
  4587. }
  4588. function toNow (withoutSuffix) {
  4589. return this.to(createLocal(), withoutSuffix);
  4590. }
  4591. // If passed a locale key, it will set the locale for this
  4592. // instance. Otherwise, it will return the locale configuration
  4593. // variables for this instance.
  4594. function locale (key) {
  4595. var newLocaleData;
  4596. if (key === undefined) {
  4597. return this._locale._abbr;
  4598. } else {
  4599. newLocaleData = getLocale(key);
  4600. if (newLocaleData != null) {
  4601. this._locale = newLocaleData;
  4602. }
  4603. return this;
  4604. }
  4605. }
  4606. var lang = deprecate(
  4607. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  4608. function (key) {
  4609. if (key === undefined) {
  4610. return this.localeData();
  4611. } else {
  4612. return this.locale(key);
  4613. }
  4614. }
  4615. );
  4616. function localeData () {
  4617. return this._locale;
  4618. }
  4619. var MS_PER_SECOND = 1000;
  4620. var MS_PER_MINUTE = 60 * MS_PER_SECOND;
  4621. var MS_PER_HOUR = 60 * MS_PER_MINUTE;
  4622. var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  4623. // actual modulo - handles negative numbers (for dates before 1970):
  4624. function mod$1(dividend, divisor) {
  4625. return (dividend % divisor + divisor) % divisor;
  4626. }
  4627. function localStartOfDate(y, m, d) {
  4628. // the date constructor remaps years 0-99 to 1900-1999
  4629. if (y < 100 && y >= 0) {
  4630. // preserve leap years using a full 400 year cycle, then reset
  4631. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  4632. } else {
  4633. return new Date(y, m, d).valueOf();
  4634. }
  4635. }
  4636. function utcStartOfDate(y, m, d) {
  4637. // Date.UTC remaps years 0-99 to 1900-1999
  4638. if (y < 100 && y >= 0) {
  4639. // preserve leap years using a full 400 year cycle, then reset
  4640. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  4641. } else {
  4642. return Date.UTC(y, m, d);
  4643. }
  4644. }
  4645. function startOf (units) {
  4646. var time;
  4647. units = normalizeUnits(units);
  4648. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4649. return this;
  4650. }
  4651. var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4652. switch (units) {
  4653. case 'year':
  4654. time = startOfDate(this.year(), 0, 1);
  4655. break;
  4656. case 'quarter':
  4657. time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
  4658. break;
  4659. case 'month':
  4660. time = startOfDate(this.year(), this.month(), 1);
  4661. break;
  4662. case 'week':
  4663. time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
  4664. break;
  4665. case 'isoWeek':
  4666. time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
  4667. break;
  4668. case 'day':
  4669. case 'date':
  4670. time = startOfDate(this.year(), this.month(), this.date());
  4671. break;
  4672. case 'hour':
  4673. time = this._d.valueOf();
  4674. time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
  4675. break;
  4676. case 'minute':
  4677. time = this._d.valueOf();
  4678. time -= mod$1(time, MS_PER_MINUTE);
  4679. break;
  4680. case 'second':
  4681. time = this._d.valueOf();
  4682. time -= mod$1(time, MS_PER_SECOND);
  4683. break;
  4684. }
  4685. this._d.setTime(time);
  4686. hooks.updateOffset(this, true);
  4687. return this;
  4688. }
  4689. function endOf (units) {
  4690. var time;
  4691. units = normalizeUnits(units);
  4692. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4693. return this;
  4694. }
  4695. var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4696. switch (units) {
  4697. case 'year':
  4698. time = startOfDate(this.year() + 1, 0, 1) - 1;
  4699. break;
  4700. case 'quarter':
  4701. time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
  4702. break;
  4703. case 'month':
  4704. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  4705. break;
  4706. case 'week':
  4707. time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
  4708. break;
  4709. case 'isoWeek':
  4710. time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
  4711. break;
  4712. case 'day':
  4713. case 'date':
  4714. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  4715. break;
  4716. case 'hour':
  4717. time = this._d.valueOf();
  4718. time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
  4719. break;
  4720. case 'minute':
  4721. time = this._d.valueOf();
  4722. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  4723. break;
  4724. case 'second':
  4725. time = this._d.valueOf();
  4726. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  4727. break;
  4728. }
  4729. this._d.setTime(time);
  4730. hooks.updateOffset(this, true);
  4731. return this;
  4732. }
  4733. function valueOf () {
  4734. return this._d.valueOf() - ((this._offset || 0) * 60000);
  4735. }
  4736. function unix () {
  4737. return Math.floor(this.valueOf() / 1000);
  4738. }
  4739. function toDate () {
  4740. return new Date(this.valueOf());
  4741. }
  4742. function toArray () {
  4743. var m = this;
  4744. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  4745. }
  4746. function toObject () {
  4747. var m = this;
  4748. return {
  4749. years: m.year(),
  4750. months: m.month(),
  4751. date: m.date(),
  4752. hours: m.hours(),
  4753. minutes: m.minutes(),
  4754. seconds: m.seconds(),
  4755. milliseconds: m.milliseconds()
  4756. };
  4757. }
  4758. function toJSON () {
  4759. // new Date(NaN).toJSON() === null
  4760. return this.isValid() ? this.toISOString() : null;
  4761. }
  4762. function isValid$2 () {
  4763. return isValid(this);
  4764. }
  4765. function parsingFlags () {
  4766. return extend({}, getParsingFlags(this));
  4767. }
  4768. function invalidAt () {
  4769. return getParsingFlags(this).overflow;
  4770. }
  4771. function creationData() {
  4772. return {
  4773. input: this._i,
  4774. format: this._f,
  4775. locale: this._locale,
  4776. isUTC: this._isUTC,
  4777. strict: this._strict
  4778. };
  4779. }
  4780. // FORMATTING
  4781. addFormatToken(0, ['gg', 2], 0, function () {
  4782. return this.weekYear() % 100;
  4783. });
  4784. addFormatToken(0, ['GG', 2], 0, function () {
  4785. return this.isoWeekYear() % 100;
  4786. });
  4787. function addWeekYearFormatToken (token, getter) {
  4788. addFormatToken(0, [token, token.length], 0, getter);
  4789. }
  4790. addWeekYearFormatToken('gggg', 'weekYear');
  4791. addWeekYearFormatToken('ggggg', 'weekYear');
  4792. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  4793. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  4794. // ALIASES
  4795. addUnitAlias('weekYear', 'gg');
  4796. addUnitAlias('isoWeekYear', 'GG');
  4797. // PRIORITY
  4798. addUnitPriority('weekYear', 1);
  4799. addUnitPriority('isoWeekYear', 1);
  4800. // PARSING
  4801. addRegexToken('G', matchSigned);
  4802. addRegexToken('g', matchSigned);
  4803. addRegexToken('GG', match1to2, match2);
  4804. addRegexToken('gg', match1to2, match2);
  4805. addRegexToken('GGGG', match1to4, match4);
  4806. addRegexToken('gggg', match1to4, match4);
  4807. addRegexToken('GGGGG', match1to6, match6);
  4808. addRegexToken('ggggg', match1to6, match6);
  4809. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  4810. week[token.substr(0, 2)] = toInt(input);
  4811. });
  4812. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  4813. week[token] = hooks.parseTwoDigitYear(input);
  4814. });
  4815. // MOMENTS
  4816. function getSetWeekYear (input) {
  4817. return getSetWeekYearHelper.call(this,
  4818. input,
  4819. this.week(),
  4820. this.weekday(),
  4821. this.localeData()._week.dow,
  4822. this.localeData()._week.doy);
  4823. }
  4824. function getSetISOWeekYear (input) {
  4825. return getSetWeekYearHelper.call(this,
  4826. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  4827. }
  4828. function getISOWeeksInYear () {
  4829. return weeksInYear(this.year(), 1, 4);
  4830. }
  4831. function getWeeksInYear () {
  4832. var weekInfo = this.localeData()._week;
  4833. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  4834. }
  4835. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  4836. var weeksTarget;
  4837. if (input == null) {
  4838. return weekOfYear(this, dow, doy).year;
  4839. } else {
  4840. weeksTarget = weeksInYear(input, dow, doy);
  4841. if (week > weeksTarget) {
  4842. week = weeksTarget;
  4843. }
  4844. return setWeekAll.call(this, input, week, weekday, dow, doy);
  4845. }
  4846. }
  4847. function setWeekAll(weekYear, week, weekday, dow, doy) {
  4848. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  4849. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  4850. this.year(date.getUTCFullYear());
  4851. this.month(date.getUTCMonth());
  4852. this.date(date.getUTCDate());
  4853. return this;
  4854. }
  4855. // FORMATTING
  4856. addFormatToken('Q', 0, 'Qo', 'quarter');
  4857. // ALIASES
  4858. addUnitAlias('quarter', 'Q');
  4859. // PRIORITY
  4860. addUnitPriority('quarter', 7);
  4861. // PARSING
  4862. addRegexToken('Q', match1);
  4863. addParseToken('Q', function (input, array) {
  4864. array[MONTH] = (toInt(input) - 1) * 3;
  4865. });
  4866. // MOMENTS
  4867. function getSetQuarter (input) {
  4868. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  4869. }
  4870. // FORMATTING
  4871. addFormatToken('D', ['DD', 2], 'Do', 'date');
  4872. // ALIASES
  4873. addUnitAlias('date', 'D');
  4874. // PRIORITY
  4875. addUnitPriority('date', 9);
  4876. // PARSING
  4877. addRegexToken('D', match1to2);
  4878. addRegexToken('DD', match1to2, match2);
  4879. addRegexToken('Do', function (isStrict, locale) {
  4880. // TODO: Remove "ordinalParse" fallback in next major release.
  4881. return isStrict ?
  4882. (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
  4883. locale._dayOfMonthOrdinalParseLenient;
  4884. });
  4885. addParseToken(['D', 'DD'], DATE);
  4886. addParseToken('Do', function (input, array) {
  4887. array[DATE] = toInt(input.match(match1to2)[0]);
  4888. });
  4889. // MOMENTS
  4890. var getSetDayOfMonth = makeGetSet('Date', true);
  4891. // FORMATTING
  4892. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  4893. // ALIASES
  4894. addUnitAlias('dayOfYear', 'DDD');
  4895. // PRIORITY
  4896. addUnitPriority('dayOfYear', 4);
  4897. // PARSING
  4898. addRegexToken('DDD', match1to3);
  4899. addRegexToken('DDDD', match3);
  4900. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  4901. config._dayOfYear = toInt(input);
  4902. });
  4903. // HELPERS
  4904. // MOMENTS
  4905. function getSetDayOfYear (input) {
  4906. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  4907. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  4908. }
  4909. // FORMATTING
  4910. addFormatToken('m', ['mm', 2], 0, 'minute');
  4911. // ALIASES
  4912. addUnitAlias('minute', 'm');
  4913. // PRIORITY
  4914. addUnitPriority('minute', 14);
  4915. // PARSING
  4916. addRegexToken('m', match1to2);
  4917. addRegexToken('mm', match1to2, match2);
  4918. addParseToken(['m', 'mm'], MINUTE);
  4919. // MOMENTS
  4920. var getSetMinute = makeGetSet('Minutes', false);
  4921. // FORMATTING
  4922. addFormatToken('s', ['ss', 2], 0, 'second');
  4923. // ALIASES
  4924. addUnitAlias('second', 's');
  4925. // PRIORITY
  4926. addUnitPriority('second', 15);
  4927. // PARSING
  4928. addRegexToken('s', match1to2);
  4929. addRegexToken('ss', match1to2, match2);
  4930. addParseToken(['s', 'ss'], SECOND);
  4931. // MOMENTS
  4932. var getSetSecond = makeGetSet('Seconds', false);
  4933. // FORMATTING
  4934. addFormatToken('S', 0, 0, function () {
  4935. return ~~(this.millisecond() / 100);
  4936. });
  4937. addFormatToken(0, ['SS', 2], 0, function () {
  4938. return ~~(this.millisecond() / 10);
  4939. });
  4940. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  4941. addFormatToken(0, ['SSSS', 4], 0, function () {
  4942. return this.millisecond() * 10;
  4943. });
  4944. addFormatToken(0, ['SSSSS', 5], 0, function () {
  4945. return this.millisecond() * 100;
  4946. });
  4947. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  4948. return this.millisecond() * 1000;
  4949. });
  4950. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  4951. return this.millisecond() * 10000;
  4952. });
  4953. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  4954. return this.millisecond() * 100000;
  4955. });
  4956. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  4957. return this.millisecond() * 1000000;
  4958. });
  4959. // ALIASES
  4960. addUnitAlias('millisecond', 'ms');
  4961. // PRIORITY
  4962. addUnitPriority('millisecond', 16);
  4963. // PARSING
  4964. addRegexToken('S', match1to3, match1);
  4965. addRegexToken('SS', match1to3, match2);
  4966. addRegexToken('SSS', match1to3, match3);
  4967. var token;
  4968. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  4969. addRegexToken(token, matchUnsigned);
  4970. }
  4971. function parseMs(input, array) {
  4972. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  4973. }
  4974. for (token = 'S'; token.length <= 9; token += 'S') {
  4975. addParseToken(token, parseMs);
  4976. }
  4977. // MOMENTS
  4978. var getSetMillisecond = makeGetSet('Milliseconds', false);
  4979. // FORMATTING
  4980. addFormatToken('z', 0, 0, 'zoneAbbr');
  4981. addFormatToken('zz', 0, 0, 'zoneName');
  4982. // MOMENTS
  4983. function getZoneAbbr () {
  4984. return this._isUTC ? 'UTC' : '';
  4985. }
  4986. function getZoneName () {
  4987. return this._isUTC ? 'Coordinated Universal Time' : '';
  4988. }
  4989. var proto = Moment.prototype;
  4990. proto.add = add;
  4991. proto.calendar = calendar$1;
  4992. proto.clone = clone;
  4993. proto.diff = diff;
  4994. proto.endOf = endOf;
  4995. proto.format = format;
  4996. proto.from = from;
  4997. proto.fromNow = fromNow;
  4998. proto.to = to;
  4999. proto.toNow = toNow;
  5000. proto.get = stringGet;
  5001. proto.invalidAt = invalidAt;
  5002. proto.isAfter = isAfter;
  5003. proto.isBefore = isBefore;
  5004. proto.isBetween = isBetween;
  5005. proto.isSame = isSame;
  5006. proto.isSameOrAfter = isSameOrAfter;
  5007. proto.isSameOrBefore = isSameOrBefore;
  5008. proto.isValid = isValid$2;
  5009. proto.lang = lang;
  5010. proto.locale = locale;
  5011. proto.localeData = localeData;
  5012. proto.max = prototypeMax;
  5013. proto.min = prototypeMin;
  5014. proto.parsingFlags = parsingFlags;
  5015. proto.set = stringSet;
  5016. proto.startOf = startOf;
  5017. proto.subtract = subtract;
  5018. proto.toArray = toArray;
  5019. proto.toObject = toObject;
  5020. proto.toDate = toDate;
  5021. proto.toISOString = toISOString;
  5022. proto.inspect = inspect;
  5023. proto.toJSON = toJSON;
  5024. proto.toString = toString;
  5025. proto.unix = unix;
  5026. proto.valueOf = valueOf;
  5027. proto.creationData = creationData;
  5028. proto.year = getSetYear;
  5029. proto.isLeapYear = getIsLeapYear;
  5030. proto.weekYear = getSetWeekYear;
  5031. proto.isoWeekYear = getSetISOWeekYear;
  5032. proto.quarter = proto.quarters = getSetQuarter;
  5033. proto.month = getSetMonth;
  5034. proto.daysInMonth = getDaysInMonth;
  5035. proto.week = proto.weeks = getSetWeek;
  5036. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  5037. proto.weeksInYear = getWeeksInYear;
  5038. proto.isoWeeksInYear = getISOWeeksInYear;
  5039. proto.date = getSetDayOfMonth;
  5040. proto.day = proto.days = getSetDayOfWeek;
  5041. proto.weekday = getSetLocaleDayOfWeek;
  5042. proto.isoWeekday = getSetISODayOfWeek;
  5043. proto.dayOfYear = getSetDayOfYear;
  5044. proto.hour = proto.hours = getSetHour;
  5045. proto.minute = proto.minutes = getSetMinute;
  5046. proto.second = proto.seconds = getSetSecond;
  5047. proto.millisecond = proto.milliseconds = getSetMillisecond;
  5048. proto.utcOffset = getSetOffset;
  5049. proto.utc = setOffsetToUTC;
  5050. proto.local = setOffsetToLocal;
  5051. proto.parseZone = setOffsetToParsedOffset;
  5052. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  5053. proto.isDST = isDaylightSavingTime;
  5054. proto.isLocal = isLocal;
  5055. proto.isUtcOffset = isUtcOffset;
  5056. proto.isUtc = isUtc;
  5057. proto.isUTC = isUtc;
  5058. proto.zoneAbbr = getZoneAbbr;
  5059. proto.zoneName = getZoneName;
  5060. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  5061. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  5062. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  5063. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  5064. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  5065. function createUnix (input) {
  5066. return createLocal(input * 1000);
  5067. }
  5068. function createInZone () {
  5069. return createLocal.apply(null, arguments).parseZone();
  5070. }
  5071. function preParsePostFormat (string) {
  5072. return string;
  5073. }
  5074. var proto$1 = Locale.prototype;
  5075. proto$1.calendar = calendar;
  5076. proto$1.longDateFormat = longDateFormat;
  5077. proto$1.invalidDate = invalidDate;
  5078. proto$1.ordinal = ordinal;
  5079. proto$1.preparse = preParsePostFormat;
  5080. proto$1.postformat = preParsePostFormat;
  5081. proto$1.relativeTime = relativeTime;
  5082. proto$1.pastFuture = pastFuture;
  5083. proto$1.set = set;
  5084. proto$1.months = localeMonths;
  5085. proto$1.monthsShort = localeMonthsShort;
  5086. proto$1.monthsParse = localeMonthsParse;
  5087. proto$1.monthsRegex = monthsRegex;
  5088. proto$1.monthsShortRegex = monthsShortRegex;
  5089. proto$1.week = localeWeek;
  5090. proto$1.firstDayOfYear = localeFirstDayOfYear;
  5091. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  5092. proto$1.weekdays = localeWeekdays;
  5093. proto$1.weekdaysMin = localeWeekdaysMin;
  5094. proto$1.weekdaysShort = localeWeekdaysShort;
  5095. proto$1.weekdaysParse = localeWeekdaysParse;
  5096. proto$1.weekdaysRegex = weekdaysRegex;
  5097. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  5098. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  5099. proto$1.isPM = localeIsPM;
  5100. proto$1.meridiem = localeMeridiem;
  5101. function get$1 (format, index, field, setter) {
  5102. var locale = getLocale();
  5103. var utc = createUTC().set(setter, index);
  5104. return locale[field](utc, format);
  5105. }
  5106. function listMonthsImpl (format, index, field) {
  5107. if (isNumber(format)) {
  5108. index = format;
  5109. format = undefined;
  5110. }
  5111. format = format || '';
  5112. if (index != null) {
  5113. return get$1(format, index, field, 'month');
  5114. }
  5115. var i;
  5116. var out = [];
  5117. for (i = 0; i < 12; i++) {
  5118. out[i] = get$1(format, i, field, 'month');
  5119. }
  5120. return out;
  5121. }
  5122. // ()
  5123. // (5)
  5124. // (fmt, 5)
  5125. // (fmt)
  5126. // (true)
  5127. // (true, 5)
  5128. // (true, fmt, 5)
  5129. // (true, fmt)
  5130. function listWeekdaysImpl (localeSorted, format, index, field) {
  5131. if (typeof localeSorted === 'boolean') {
  5132. if (isNumber(format)) {
  5133. index = format;
  5134. format = undefined;
  5135. }
  5136. format = format || '';
  5137. } else {
  5138. format = localeSorted;
  5139. index = format;
  5140. localeSorted = false;
  5141. if (isNumber(format)) {
  5142. index = format;
  5143. format = undefined;
  5144. }
  5145. format = format || '';
  5146. }
  5147. var locale = getLocale(),
  5148. shift = localeSorted ? locale._week.dow : 0;
  5149. if (index != null) {
  5150. return get$1(format, (index + shift) % 7, field, 'day');
  5151. }
  5152. var i;
  5153. var out = [];
  5154. for (i = 0; i < 7; i++) {
  5155. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  5156. }
  5157. return out;
  5158. }
  5159. function listMonths (format, index) {
  5160. return listMonthsImpl(format, index, 'months');
  5161. }
  5162. function listMonthsShort (format, index) {
  5163. return listMonthsImpl(format, index, 'monthsShort');
  5164. }
  5165. function listWeekdays (localeSorted, format, index) {
  5166. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  5167. }
  5168. function listWeekdaysShort (localeSorted, format, index) {
  5169. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  5170. }
  5171. function listWeekdaysMin (localeSorted, format, index) {
  5172. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  5173. }
  5174. getSetGlobalLocale('en', {
  5175. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  5176. ordinal : function (number) {
  5177. var b = number % 10,
  5178. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  5179. (b === 1) ? 'st' :
  5180. (b === 2) ? 'nd' :
  5181. (b === 3) ? 'rd' : 'th';
  5182. return number + output;
  5183. }
  5184. });
  5185. // Side effect imports
  5186. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  5187. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  5188. var mathAbs = Math.abs;
  5189. function abs () {
  5190. var data = this._data;
  5191. this._milliseconds = mathAbs(this._milliseconds);
  5192. this._days = mathAbs(this._days);
  5193. this._months = mathAbs(this._months);
  5194. data.milliseconds = mathAbs(data.milliseconds);
  5195. data.seconds = mathAbs(data.seconds);
  5196. data.minutes = mathAbs(data.minutes);
  5197. data.hours = mathAbs(data.hours);
  5198. data.months = mathAbs(data.months);
  5199. data.years = mathAbs(data.years);
  5200. return this;
  5201. }
  5202. function addSubtract$1 (duration, input, value, direction) {
  5203. var other = createDuration(input, value);
  5204. duration._milliseconds += direction * other._milliseconds;
  5205. duration._days += direction * other._days;
  5206. duration._months += direction * other._months;
  5207. return duration._bubble();
  5208. }
  5209. // supports only 2.0-style add(1, 's') or add(duration)
  5210. function add$1 (input, value) {
  5211. return addSubtract$1(this, input, value, 1);
  5212. }
  5213. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  5214. function subtract$1 (input, value) {
  5215. return addSubtract$1(this, input, value, -1);
  5216. }
  5217. function absCeil (number) {
  5218. if (number < 0) {
  5219. return Math.floor(number);
  5220. } else {
  5221. return Math.ceil(number);
  5222. }
  5223. }
  5224. function bubble () {
  5225. var milliseconds = this._milliseconds;
  5226. var days = this._days;
  5227. var months = this._months;
  5228. var data = this._data;
  5229. var seconds, minutes, hours, years, monthsFromDays;
  5230. // if we have a mix of positive and negative values, bubble down first
  5231. // check: https://github.com/moment/moment/issues/2166
  5232. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  5233. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  5234. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  5235. days = 0;
  5236. months = 0;
  5237. }
  5238. // The following code bubbles up values, see the tests for
  5239. // examples of what that means.
  5240. data.milliseconds = milliseconds % 1000;
  5241. seconds = absFloor(milliseconds / 1000);
  5242. data.seconds = seconds % 60;
  5243. minutes = absFloor(seconds / 60);
  5244. data.minutes = minutes % 60;
  5245. hours = absFloor(minutes / 60);
  5246. data.hours = hours % 24;
  5247. days += absFloor(hours / 24);
  5248. // convert days to months
  5249. monthsFromDays = absFloor(daysToMonths(days));
  5250. months += monthsFromDays;
  5251. days -= absCeil(monthsToDays(monthsFromDays));
  5252. // 12 months -> 1 year
  5253. years = absFloor(months / 12);
  5254. months %= 12;
  5255. data.days = days;
  5256. data.months = months;
  5257. data.years = years;
  5258. return this;
  5259. }
  5260. function daysToMonths (days) {
  5261. // 400 years have 146097 days (taking into account leap year rules)
  5262. // 400 years have 12 months === 4800
  5263. return days * 4800 / 146097;
  5264. }
  5265. function monthsToDays (months) {
  5266. // the reverse of daysToMonths
  5267. return months * 146097 / 4800;
  5268. }
  5269. function as (units) {
  5270. if (!this.isValid()) {
  5271. return NaN;
  5272. }
  5273. var days;
  5274. var months;
  5275. var milliseconds = this._milliseconds;
  5276. units = normalizeUnits(units);
  5277. if (units === 'month' || units === 'quarter' || units === 'year') {
  5278. days = this._days + milliseconds / 864e5;
  5279. months = this._months + daysToMonths(days);
  5280. switch (units) {
  5281. case 'month': return months;
  5282. case 'quarter': return months / 3;
  5283. case 'year': return months / 12;
  5284. }
  5285. } else {
  5286. // handle milliseconds separately because of floating point math errors (issue #1867)
  5287. days = this._days + Math.round(monthsToDays(this._months));
  5288. switch (units) {
  5289. case 'week' : return days / 7 + milliseconds / 6048e5;
  5290. case 'day' : return days + milliseconds / 864e5;
  5291. case 'hour' : return days * 24 + milliseconds / 36e5;
  5292. case 'minute' : return days * 1440 + milliseconds / 6e4;
  5293. case 'second' : return days * 86400 + milliseconds / 1000;
  5294. // Math.floor prevents floating point math errors here
  5295. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  5296. default: throw new Error('Unknown unit ' + units);
  5297. }
  5298. }
  5299. }
  5300. // TODO: Use this.as('ms')?
  5301. function valueOf$1 () {
  5302. if (!this.isValid()) {
  5303. return NaN;
  5304. }
  5305. return (
  5306. this._milliseconds +
  5307. this._days * 864e5 +
  5308. (this._months % 12) * 2592e6 +
  5309. toInt(this._months / 12) * 31536e6
  5310. );
  5311. }
  5312. function makeAs (alias) {
  5313. return function () {
  5314. return this.as(alias);
  5315. };
  5316. }
  5317. var asMilliseconds = makeAs('ms');
  5318. var asSeconds = makeAs('s');
  5319. var asMinutes = makeAs('m');
  5320. var asHours = makeAs('h');
  5321. var asDays = makeAs('d');
  5322. var asWeeks = makeAs('w');
  5323. var asMonths = makeAs('M');
  5324. var asQuarters = makeAs('Q');
  5325. var asYears = makeAs('y');
  5326. function clone$1 () {
  5327. return createDuration(this);
  5328. }
  5329. function get$2 (units) {
  5330. units = normalizeUnits(units);
  5331. return this.isValid() ? this[units + 's']() : NaN;
  5332. }
  5333. function makeGetter(name) {
  5334. return function () {
  5335. return this.isValid() ? this._data[name] : NaN;
  5336. };
  5337. }
  5338. var milliseconds = makeGetter('milliseconds');
  5339. var seconds = makeGetter('seconds');
  5340. var minutes = makeGetter('minutes');
  5341. var hours = makeGetter('hours');
  5342. var days = makeGetter('days');
  5343. var months = makeGetter('months');
  5344. var years = makeGetter('years');
  5345. function weeks () {
  5346. return absFloor(this.days() / 7);
  5347. }
  5348. var round = Math.round;
  5349. var thresholds = {
  5350. ss: 44, // a few seconds to seconds
  5351. s : 45, // seconds to minute
  5352. m : 45, // minutes to hour
  5353. h : 22, // hours to day
  5354. d : 26, // days to month
  5355. M : 11 // months to year
  5356. };
  5357. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  5358. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  5359. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  5360. }
  5361. function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
  5362. var duration = createDuration(posNegDuration).abs();
  5363. var seconds = round(duration.as('s'));
  5364. var minutes = round(duration.as('m'));
  5365. var hours = round(duration.as('h'));
  5366. var days = round(duration.as('d'));
  5367. var months = round(duration.as('M'));
  5368. var years = round(duration.as('y'));
  5369. var a = seconds <= thresholds.ss && ['s', seconds] ||
  5370. seconds < thresholds.s && ['ss', seconds] ||
  5371. minutes <= 1 && ['m'] ||
  5372. minutes < thresholds.m && ['mm', minutes] ||
  5373. hours <= 1 && ['h'] ||
  5374. hours < thresholds.h && ['hh', hours] ||
  5375. days <= 1 && ['d'] ||
  5376. days < thresholds.d && ['dd', days] ||
  5377. months <= 1 && ['M'] ||
  5378. months < thresholds.M && ['MM', months] ||
  5379. years <= 1 && ['y'] || ['yy', years];
  5380. a[2] = withoutSuffix;
  5381. a[3] = +posNegDuration > 0;
  5382. a[4] = locale;
  5383. return substituteTimeAgo.apply(null, a);
  5384. }
  5385. // This function allows you to set the rounding function for relative time strings
  5386. function getSetRelativeTimeRounding (roundingFunction) {
  5387. if (roundingFunction === undefined) {
  5388. return round;
  5389. }
  5390. if (typeof(roundingFunction) === 'function') {
  5391. round = roundingFunction;
  5392. return true;
  5393. }
  5394. return false;
  5395. }
  5396. // This function allows you to set a threshold for relative time strings
  5397. function getSetRelativeTimeThreshold (threshold, limit) {
  5398. if (thresholds[threshold] === undefined) {
  5399. return false;
  5400. }
  5401. if (limit === undefined) {
  5402. return thresholds[threshold];
  5403. }
  5404. thresholds[threshold] = limit;
  5405. if (threshold === 's') {
  5406. thresholds.ss = limit - 1;
  5407. }
  5408. return true;
  5409. }
  5410. function humanize (withSuffix) {
  5411. if (!this.isValid()) {
  5412. return this.localeData().invalidDate();
  5413. }
  5414. var locale = this.localeData();
  5415. var output = relativeTime$1(this, !withSuffix, locale);
  5416. if (withSuffix) {
  5417. output = locale.pastFuture(+this, output);
  5418. }
  5419. return locale.postformat(output);
  5420. }
  5421. var abs$1 = Math.abs;
  5422. function sign(x) {
  5423. return ((x > 0) - (x < 0)) || +x;
  5424. }
  5425. function toISOString$1() {
  5426. // for ISO strings we do not use the normal bubbling rules:
  5427. // * milliseconds bubble up until they become hours
  5428. // * days do not bubble at all
  5429. // * months bubble up until they become years
  5430. // This is because there is no context-free conversion between hours and days
  5431. // (think of clock changes)
  5432. // and also not between days and months (28-31 days per month)
  5433. if (!this.isValid()) {
  5434. return this.localeData().invalidDate();
  5435. }
  5436. var seconds = abs$1(this._milliseconds) / 1000;
  5437. var days = abs$1(this._days);
  5438. var months = abs$1(this._months);
  5439. var minutes, hours, years;
  5440. // 3600 seconds -> 60 minutes -> 1 hour
  5441. minutes = absFloor(seconds / 60);
  5442. hours = absFloor(minutes / 60);
  5443. seconds %= 60;
  5444. minutes %= 60;
  5445. // 12 months -> 1 year
  5446. years = absFloor(months / 12);
  5447. months %= 12;
  5448. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  5449. var Y = years;
  5450. var M = months;
  5451. var D = days;
  5452. var h = hours;
  5453. var m = minutes;
  5454. var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  5455. var total = this.asSeconds();
  5456. if (!total) {
  5457. // this is the same as C#'s (Noda) and python (isodate)...
  5458. // but not other JS (goog.date)
  5459. return 'P0D';
  5460. }
  5461. var totalSign = total < 0 ? '-' : '';
  5462. var ymSign = sign(this._months) !== sign(total) ? '-' : '';
  5463. var daysSign = sign(this._days) !== sign(total) ? '-' : '';
  5464. var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  5465. return totalSign + 'P' +
  5466. (Y ? ymSign + Y + 'Y' : '') +
  5467. (M ? ymSign + M + 'M' : '') +
  5468. (D ? daysSign + D + 'D' : '') +
  5469. ((h || m || s) ? 'T' : '') +
  5470. (h ? hmsSign + h + 'H' : '') +
  5471. (m ? hmsSign + m + 'M' : '') +
  5472. (s ? hmsSign + s + 'S' : '');
  5473. }
  5474. var proto$2 = Duration.prototype;
  5475. proto$2.isValid = isValid$1;
  5476. proto$2.abs = abs;
  5477. proto$2.add = add$1;
  5478. proto$2.subtract = subtract$1;
  5479. proto$2.as = as;
  5480. proto$2.asMilliseconds = asMilliseconds;
  5481. proto$2.asSeconds = asSeconds;
  5482. proto$2.asMinutes = asMinutes;
  5483. proto$2.asHours = asHours;
  5484. proto$2.asDays = asDays;
  5485. proto$2.asWeeks = asWeeks;
  5486. proto$2.asMonths = asMonths;
  5487. proto$2.asQuarters = asQuarters;
  5488. proto$2.asYears = asYears;
  5489. proto$2.valueOf = valueOf$1;
  5490. proto$2._bubble = bubble;
  5491. proto$2.clone = clone$1;
  5492. proto$2.get = get$2;
  5493. proto$2.milliseconds = milliseconds;
  5494. proto$2.seconds = seconds;
  5495. proto$2.minutes = minutes;
  5496. proto$2.hours = hours;
  5497. proto$2.days = days;
  5498. proto$2.weeks = weeks;
  5499. proto$2.months = months;
  5500. proto$2.years = years;
  5501. proto$2.humanize = humanize;
  5502. proto$2.toISOString = toISOString$1;
  5503. proto$2.toString = toISOString$1;
  5504. proto$2.toJSON = toISOString$1;
  5505. proto$2.locale = locale;
  5506. proto$2.localeData = localeData;
  5507. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  5508. proto$2.lang = lang;
  5509. // Side effect imports
  5510. // FORMATTING
  5511. addFormatToken('X', 0, 0, 'unix');
  5512. addFormatToken('x', 0, 0, 'valueOf');
  5513. // PARSING
  5514. addRegexToken('x', matchSigned);
  5515. addRegexToken('X', matchTimestamp);
  5516. addParseToken('X', function (input, array, config) {
  5517. config._d = new Date(parseFloat(input, 10) * 1000);
  5518. });
  5519. addParseToken('x', function (input, array, config) {
  5520. config._d = new Date(toInt(input));
  5521. });
  5522. // Side effect imports
  5523. hooks.version = '2.24.0';
  5524. setHookCallback(createLocal);
  5525. hooks.fn = proto;
  5526. hooks.min = min;
  5527. hooks.max = max;
  5528. hooks.now = now;
  5529. hooks.utc = createUTC;
  5530. hooks.unix = createUnix;
  5531. hooks.months = listMonths;
  5532. hooks.isDate = isDate;
  5533. hooks.locale = getSetGlobalLocale;
  5534. hooks.invalid = createInvalid;
  5535. hooks.duration = createDuration;
  5536. hooks.isMoment = isMoment;
  5537. hooks.weekdays = listWeekdays;
  5538. hooks.parseZone = createInZone;
  5539. hooks.localeData = getLocale;
  5540. hooks.isDuration = isDuration;
  5541. hooks.monthsShort = listMonthsShort;
  5542. hooks.weekdaysMin = listWeekdaysMin;
  5543. hooks.defineLocale = defineLocale;
  5544. hooks.updateLocale = updateLocale;
  5545. hooks.locales = listLocales;
  5546. hooks.weekdaysShort = listWeekdaysShort;
  5547. hooks.normalizeUnits = normalizeUnits;
  5548. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  5549. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  5550. hooks.calendarFormat = getCalendarFormat;
  5551. hooks.prototype = proto;
  5552. // currently HTML5 input type only supports 24-hour formats
  5553. hooks.HTML5_FMT = {
  5554. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  5555. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  5556. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  5557. DATE: 'YYYY-MM-DD', // <input type="date" />
  5558. TIME: 'HH:mm', // <input type="time" />
  5559. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  5560. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  5561. WEEK: 'GGGG-[W]WW', // <input type="week" />
  5562. MONTH: 'YYYY-MM' // <input type="month" />
  5563. };
  5564. return hooks;
  5565. })));
  5566. });
  5567. function formatDA(date) {
  5568. var strFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'MMM D, YYYY';
  5569. if (!date) {
  5570. return;
  5571. }
  5572. var dateAsMoment = moment(date, 'YYYYMMDD');
  5573. return dateAsMoment.format(strFormat);
  5574. }
  5575. function formatTM(time) {
  5576. var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HH:mm:ss';
  5577. if (!time) {
  5578. return;
  5579. } // DICOM Time is stored as HHmmss.SSS, where:
  5580. // HH 24 hour time:
  5581. // m mm 0..59 Minutes
  5582. // s ss 0..59 Seconds
  5583. // S SS SSS 0..999 Fractional seconds
  5584. //
  5585. // See MomentJS: http://momentjs.com/docs/#/parsing/string-format/
  5586. var dateTime = moment(time, 'HHmmss.SSS');
  5587. return dateTime.format(format);
  5588. }
  5589. function formatNumberPrecision(number, precision) {
  5590. if (number !== null) {
  5591. return parseFloat(number).toFixed(precision);
  5592. }
  5593. }
  5594. function isValidNumber(value) {
  5595. return typeof value === 'number' && !isNaN(value);
  5596. }
  5597. var helpers = {
  5598. formatPN: formatPN,
  5599. formatDA: formatDA,
  5600. formatTM: formatTM,
  5601. formatNumberPrecision: formatNumberPrecision,
  5602. isValidNumber: isValidNumber
  5603. };
  5604. var css$1 = ".imageViewerViewport.empty ~ .ViewportOverlay {\n display: none;\n}\n.ViewportOverlay {\n color: #9ccef9;\n}\n.ViewportOverlay .overlay-element {\n position: absolute;\n font-weight: 400;\n text-shadow: 1px 1px #000;\n pointer-events: none;\n}\n.ViewportOverlay .top-left {\n top: 20px;\n left: 20px;\n}\n.ViewportOverlay .top-center {\n top: 20px;\n padding-top: 20px;\n width: 100%;\n text-align: center;\n}\n.ViewportOverlay .top-right {\n top: 20px;\n right: 20px;\n text-align: right;\n}\n.ViewportOverlay .bottom-left {\n bottom: 20px;\n left: 20px;\n}\n.ViewportOverlay .bottom-right {\n bottom: 20px;\n right: 20px;\n text-align: right;\n}\n.ViewportOverlay.controlsVisible .topright,\n.ViewportOverlay.controlsVisible .bottomright {\n right: calc(20px + 19px);\n}\n.ViewportOverlay svg {\n color: #9ccef9;\n fill: #9ccef9;\n stroke: #9ccef9;\n background-color: transparent;\n margin: 2px;\n width: 18px;\n height: 18px;\n}\n";
  5605. styleInject(css$1);
  5606. var formatPN$1 = helpers.formatPN,
  5607. formatDA$1 = helpers.formatDA,
  5608. formatNumberPrecision$1 = helpers.formatNumberPrecision,
  5609. formatTM$1 = helpers.formatTM,
  5610. isValidNumber$1 = helpers.isValidNumber;
  5611. function getCompression(imageId) {
  5612. var generalImageModule = cornerstone.metaData.get('generalImageModule', imageId) || {};
  5613. var lossyImageCompression = generalImageModule.lossyImageCompression,
  5614. lossyImageCompressionRatio = generalImageModule.lossyImageCompressionRatio,
  5615. lossyImageCompressionMethod = generalImageModule.lossyImageCompressionMethod;
  5616. if (lossyImageCompression === '01' && lossyImageCompressionRatio !== '') {
  5617. var compressionMethod = lossyImageCompressionMethod || 'Lossy: ';
  5618. var compressionRatio = formatNumberPrecision$1(lossyImageCompressionRatio, 2);
  5619. return compressionMethod + compressionRatio + ' : 1';
  5620. }
  5621. return 'Lossless / Uncompressed';
  5622. }
  5623. var ViewportOverlay =
  5624. /*#__PURE__*/
  5625. function (_PureComponent) {
  5626. inherits(ViewportOverlay, _PureComponent);
  5627. function ViewportOverlay() {
  5628. classCallCheck(this, ViewportOverlay);
  5629. return possibleConstructorReturn(this, getPrototypeOf(ViewportOverlay).apply(this, arguments));
  5630. }
  5631. createClass(ViewportOverlay, [{
  5632. key: "render",
  5633. value: function render() {
  5634. var imageId = this.props.imageId;
  5635. if (!imageId) {
  5636. return null;
  5637. }
  5638. var zoom = this.props.viewport.scale * 100;
  5639. var seriesMetadata = cornerstone.metaData.get('generalSeriesModule', imageId) || {};
  5640. var imagePlaneModule = cornerstone.metaData.get('imagePlaneModule', imageId) || {};
  5641. var rows = imagePlaneModule.rows,
  5642. columns = imagePlaneModule.columns,
  5643. sliceThickness = imagePlaneModule.sliceThickness,
  5644. sliceLocation = imagePlaneModule.sliceLocation;
  5645. var seriesNumber = seriesMetadata.seriesNumber,
  5646. seriesDescription = seriesMetadata.seriesDescription;
  5647. var generalStudyModule = cornerstone.metaData.get('generalStudyModule', imageId) || {};
  5648. var studyDate = generalStudyModule.studyDate,
  5649. studyTime = generalStudyModule.studyTime,
  5650. studyDescription = generalStudyModule.studyDescription;
  5651. var patientModule = cornerstone.metaData.get('patientModule', imageId) || {};
  5652. var patientId = patientModule.patientId,
  5653. patientName = patientModule.patientName;
  5654. var generalImageModule = cornerstone.metaData.get('generalImageModule', imageId) || {};
  5655. var instanceNumber = generalImageModule.instanceNumber;
  5656. var cineModule = cornerstone.metaData.get('cineModule', imageId) || {};
  5657. var frameTime = cineModule.frameTime;
  5658. var frameRate = formatNumberPrecision$1(1000 / frameTime, 1);
  5659. var compression = getCompression(imageId);
  5660. var windowWidth = this.props.viewport.voi.windowWidth || 0;
  5661. var windowCenter = this.props.viewport.voi.windowCenter || 0;
  5662. var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));
  5663. var imageIds = this.props.stack.imageIds;
  5664. var imageIndex = imageIds.indexOf(this.props.imageId) + 1;
  5665. var numImages = imageIds.length;
  5666. var imageDimensions = "".concat(columns, " x ").concat(rows);
  5667. var normal = React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
  5668. className: "top-left overlay-element"
  5669. }, React__default.createElement("div", null, formatPN$1(patientName)), React__default.createElement("div", null, patientId)), React__default.createElement("div", {
  5670. className: "top-right overlay-element"
  5671. }, React__default.createElement("div", null, studyDescription), React__default.createElement("div", null, formatDA$1(studyDate), " ", formatTM$1(studyTime))), React__default.createElement("div", {
  5672. className: "bottom-right overlay-element"
  5673. }, React__default.createElement("div", null, "Zoom: ", formatNumberPrecision$1(zoom, 0), "%"), React__default.createElement("div", null, wwwc), React__default.createElement("div", {
  5674. className: "compressionIndicator"
  5675. }, compression)), React__default.createElement("div", {
  5676. className: "bottom-left overlay-element"
  5677. }, React__default.createElement("div", null, seriesNumber >= 0 ? "Ser: ".concat(seriesNumber) : ''), React__default.createElement("div", null, numImages > 1 ? "Img: ".concat(instanceNumber, " ").concat(imageIndex, "/").concat(numImages) : ''), React__default.createElement("div", null, frameRate >= 0 ? "".concat(formatNumberPrecision$1(frameRate, 2), " FPS") : '', React__default.createElement("div", null, imageDimensions), React__default.createElement("div", null, isValidNumber$1(sliceLocation) ? "Loc: ".concat(formatNumberPrecision$1(sliceLocation, 2), " mm ") : '', sliceThickness ? "Thick: ".concat(formatNumberPrecision$1(sliceThickness, 2), " mm") : ''), React__default.createElement("div", null, seriesDescription))));
  5678. var rightOnly = React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
  5679. className: "top-right overlay-element"
  5680. }, React__default.createElement("div", null, formatPN$1(patientName)), React__default.createElement("div", null, patientId), React__default.createElement("div", null, studyDescription), React__default.createElement("div", null, formatDA$1(studyDate), " ", formatTM$1(studyTime))), React__default.createElement("div", {
  5681. className: "bottom-right overlay-element"
  5682. }, React__default.createElement("div", null, seriesNumber >= 0 ? "Ser: ".concat(seriesNumber) : ''), React__default.createElement("div", null, numImages > 1 ? "Img: ".concat(instanceNumber, " ").concat(imageIndex, "/").concat(numImages) : ''), React__default.createElement("div", null, frameRate >= 0 ? "".concat(formatNumberPrecision$1(frameRate, 2), " FPS") : ''), React__default.createElement("div", null, imageDimensions), React__default.createElement("div", null, seriesDescription), React__default.createElement("div", null, "Zoom: ", formatNumberPrecision$1(zoom, 0), "%"), React__default.createElement("div", {
  5683. className: "compressionIndicator"
  5684. }, compression), React__default.createElement("div", null, wwwc)));
  5685. var leftOnly = React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
  5686. className: "top-left overlay-element"
  5687. }, React__default.createElement("div", null, formatPN$1(patientName)), React__default.createElement("div", null, patientId), React__default.createElement("div", null, studyDescription), React__default.createElement("div", null, formatDA$1(studyDate), " ", formatTM$1(studyTime))), React__default.createElement("div", {
  5688. className: "bottom-left overlay-element"
  5689. }, React__default.createElement("div", null, seriesNumber >= 0 ? "Ser: ".concat(seriesNumber) : ''), React__default.createElement("div", null, numImages > 1 ? "Img: ".concat(instanceNumber, " ").concat(imageIndex, "/").concat(numImages) : ''), React__default.createElement("div", null, frameRate >= 0 ? "".concat(formatNumberPrecision$1(frameRate, 2), " FPS") : ''), React__default.createElement("div", null, imageDimensions), React__default.createElement("div", null, seriesDescription), React__default.createElement("div", null, "Zoom: ", formatNumberPrecision$1(zoom, 0), "%"), React__default.createElement("div", {
  5690. className: "compressionIndicator"
  5691. }, compression), React__default.createElement("div", null, wwwc)));
  5692. return React__default.createElement("div", {
  5693. className: "ViewportOverlay"
  5694. }, normal);
  5695. }
  5696. }]);
  5697. return ViewportOverlay;
  5698. }(React.PureComponent);
  5699. defineProperty(ViewportOverlay, "propTypes", {
  5700. viewport: propTypes.object.isRequired,
  5701. imageId: propTypes.string.isRequired,
  5702. stack: propTypes.object.isRequired
  5703. });
  5704. var css$2 = ".imageViewerLoadingIndicator {\n color: #91b9cd;\n}\n.faded {\n opacity: 0.5;\n}\n.imageViewerErrorLoadingIndicator {\n color: #e29e4a;\n}\n.imageViewerErrorLoadingIndicator p,\n.imageViewerErrorLoadingIndicator h4 {\n padding: 4px 0;\n text-align: center;\n word-wrap: break-word;\n}\n.imageViewerErrorLoadingIndicator p {\n font-size: 11pt;\n}\n.loadingIndicator {\n background-color: rgba(0,0,0,0.75);\n font-size: 18px;\n height: 100%;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n top: 0;\n width: 100%;\n z-index: 1;\n}\n.loadingIndicator .indicatorContents {\n font-size: 30px;\n font-weight: 300;\n position: absolute;\n text-align: center;\n top: 50%;\n transform: translateY(-50%);\n width: 100%;\n}\n";
  5705. styleInject(css$2);
  5706. var LoadingIndicator =
  5707. /*#__PURE__*/
  5708. function (_PureComponent) {
  5709. inherits(LoadingIndicator, _PureComponent);
  5710. function LoadingIndicator() {
  5711. classCallCheck(this, LoadingIndicator);
  5712. return possibleConstructorReturn(this, getPrototypeOf(LoadingIndicator).apply(this, arguments));
  5713. }
  5714. createClass(LoadingIndicator, [{
  5715. key: "render",
  5716. value: function render() {
  5717. var percComplete;
  5718. if (this.props.percentComplete && this.props.percentComplete !== 100) {
  5719. percComplete = "".concat(this.props.percentComplete, "%");
  5720. }
  5721. return React__default.createElement(React__default.Fragment, null, this.props.error ? React__default.createElement("div", {
  5722. className: "imageViewerErrorLoadingIndicator loadingIndicator"
  5723. }, React__default.createElement("div", {
  5724. className: "indicatorContents"
  5725. }, React__default.createElement("h4", null, "加载图像时出错"), React__default.createElement("p", {
  5726. className: "description"
  5727. }, "发生错误."), React__default.createElement("p", {
  5728. className: "details"
  5729. }, this.props.error.message))) : React__default.createElement("div", {
  5730. className: "imageViewerLoadingIndicator loadingIndicator"
  5731. }, React__default.createElement("div", {
  5732. className: "indicatorContents"
  5733. }, React__default.createElement("p", null, "Loading... ", React__default.createElement("i", {
  5734. className: "fa fa-spin fa-circle-o-notch fa-fw"
  5735. }), ' ', percComplete))));
  5736. }
  5737. }]);
  5738. return LoadingIndicator;
  5739. }(React.PureComponent);
  5740. defineProperty(LoadingIndicator, "propTypes", {
  5741. percentComplete: propTypes.number.isRequired,
  5742. error: propTypes.object
  5743. });
  5744. defineProperty(LoadingIndicator, "defaultProps", {
  5745. percentComplete: 0,
  5746. error: null
  5747. });
  5748. var css$3 = ".ViewportOrientationMarkers {\n pointer-events: none;\n font-size: 15px;\n color: #ccc;\n line-height: 18px;\n}\n.ViewportOrientationMarkers .orientation-marker {\n position: absolute;\n}\n.ViewportOrientationMarkers .top-mid {\n top: 5px;\n left: 50%;\n}\n.ViewportOrientationMarkers .left-mid {\n top: 47%;\n left: 5px;\n}\n";
  5749. styleInject(css$3);
  5750. /**
  5751. * Computes the orientation labels on a Cornerstone-enabled Viewport element
  5752. * when the viewport settings change (e.g. when a horizontal flip or a rotation occurs)
  5753. *
  5754. * @param imageId The Cornerstone ImageId
  5755. * @param viewport The current viewport
  5756. */
  5757. function getOrientationMarkers(imageId, viewport) {
  5758. var imagePlane = cornerstone.metaData.get('imagePlaneModule', imageId);
  5759. if (!imagePlane || !imagePlane.rowCosines || !imagePlane.columnCosines) {
  5760. return;
  5761. }
  5762. var rowString = cornerstoneTools.orientation.getOrientationString(imagePlane.rowCosines);
  5763. var columnString = cornerstoneTools.orientation.getOrientationString(imagePlane.columnCosines);
  5764. var oppositeRowString = cornerstoneTools.orientation.invertOrientationString(rowString);
  5765. var oppositeColumnString = cornerstoneTools.orientation.invertOrientationString(columnString);
  5766. var markers = {
  5767. top: oppositeColumnString,
  5768. left: oppositeRowString
  5769. }; // If any vertical or horizontal flips are applied, change the orientation strings ahead of
  5770. // the rotation applications
  5771. if (viewport.vflip) {
  5772. markers.top = cornerstoneTools.orientation.invertOrientationString(markers.top);
  5773. }
  5774. if (viewport.hflip) {
  5775. markers.left = cornerstoneTools.orientation.invertOrientationString(markers.left);
  5776. } // Swap the labels accordingly if the viewport has been rotated
  5777. // This could be done in a more complex way for intermediate rotation values (e.g. 45 degrees)
  5778. if (viewport.rotation === 90 || viewport.rotation === -270) {
  5779. return {
  5780. top: markers.left,
  5781. left: cornerstoneTools.orientation.invertOrientationString(markers.top)
  5782. };
  5783. } else if (viewport.rotation === -90 || viewport.rotation === 270) {
  5784. return {
  5785. top: cornerstoneTools.orientation.invertOrientationString(markers.left),
  5786. left: markers.top
  5787. };
  5788. } else if (viewport.rotation === 180 || viewport.rotation === -180) {
  5789. return {
  5790. top: cornerstoneTools.orientation.invertOrientationString(markers.top),
  5791. left: cornerstoneTools.orientation.invertOrientationString(markers.left)
  5792. };
  5793. }
  5794. return markers;
  5795. }
  5796. var ViewportOrientationMarkers =
  5797. /*#__PURE__*/
  5798. function (_PureComponent) {
  5799. inherits(ViewportOrientationMarkers, _PureComponent);
  5800. function ViewportOrientationMarkers() {
  5801. classCallCheck(this, ViewportOrientationMarkers);
  5802. return possibleConstructorReturn(this, getPrototypeOf(ViewportOrientationMarkers).apply(this, arguments));
  5803. }
  5804. createClass(ViewportOrientationMarkers, [{
  5805. key: "render",
  5806. value: function render() {
  5807. var _this$props = this.props,
  5808. imageId = _this$props.imageId,
  5809. viewport = _this$props.viewport;
  5810. if (!imageId) {
  5811. return null;
  5812. }
  5813. var markers = getOrientationMarkers(imageId, viewport);
  5814. if (!markers) {
  5815. return '';
  5816. }
  5817. return React__default.createElement("div", {
  5818. className: "ViewportOrientationMarkers noselect"
  5819. }, React__default.createElement("div", {
  5820. className: "top-mid orientation-marker"
  5821. }, markers.top), React__default.createElement("div", {
  5822. className: "left-mid orientation-marker"
  5823. }, markers.left));
  5824. }
  5825. }]);
  5826. return ViewportOrientationMarkers;
  5827. }(React.PureComponent);
  5828. defineProperty(ViewportOrientationMarkers, "propTypes", {
  5829. imageId: propTypes.string.isRequired,
  5830. viewport: propTypes.object.isRequired
  5831. });
  5832. var css$4 = ".CornerstoneViewport {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.viewport-element {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: black;\n\n /* Prevent the blue outline in Chrome when a viewport is selected */\n outline: 0 !important;\n\n /* Prevents the entire page from getting larger\n when the magnify tool is near the sides/corners of the page */\n overflow: hidden;\n}\n\n.viewportInstructions {\n display: block;\n font-size: 13px;\n /*theme('color', '$textSecondaryColor')*/\n color: #91b9cd;\n line-height: 18px;\n pointer-events: none; /* Necessary for drag/drop through to cornerstone element below */\n text-align: center;\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n margin: auto;\n height: 20px;\n}\n\n/* These are some good CSS settings for a circular magnifying glass\n Try removing the border-radius to make a square magnifying glass */\n.magnifyTool {\n border: 4px white solid;\n box-shadow: 2px 2px 10px #1e1e1e;\n border-radius: 50%;\n display: none;\n cursor: none;\n}\n";
  5833. styleInject(css$4);
  5834. var EVENT_RESIZE = 'resize';
  5835. var scrollToIndex = cornerstoneTools.importInternal('util/scrollToIndex');
  5836. var loadHandlerManager = cornerstoneTools.loadHandlerManager;
  5837. function setToolsPassive(cornerstoneTools, tools) {
  5838. tools.forEach(function (tool) {
  5839. cornerstoneTools.setToolPassive(tool);
  5840. });
  5841. }
  5842. function capitalizeFirstLetter(string) {
  5843. return string.charAt(0).toUpperCase() + string.slice(1);
  5844. }
  5845. function initializeTools(cornerstoneTools, tools, element) {
  5846. Array.from(tools).forEach(function (tool) {
  5847. var apiTool = cornerstoneTools["".concat(tool.name, "Tool")] || tool.apiTool;
  5848. if (apiTool) {
  5849. cornerstoneTools.addToolForElement(element, apiTool, tool.props);
  5850. } else {
  5851. throw new Error("Tool not found: ".concat(tool.name, "Tool"));
  5852. }
  5853. if (tool.mode) {
  5854. cornerstoneTools["setTool".concat(capitalizeFirstLetter(tool.mode), "ForElement")](element, tool.name);
  5855. }
  5856. });
  5857. }
  5858. function areLayoutsEqual(a, b) {
  5859. var viewportIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  5860. var notEqual = false;
  5861. var viewportsExist = a && b && a.viewports && b.viewports && a.viewports.length > 0 && b.viewports.length > 0;
  5862. var wasNotSetAndNowIs = !a && b || !a.viewports && !b.viewports;
  5863. var hasNumViewportsChanged = viewportsExist && a.viewports.length !== b.viewports.length;
  5864. if (wasNotSetAndNowIs || hasNumViewportsChanged) {
  5865. return notEqual;
  5866. }
  5867. var aViewport = a.viewports[viewportIndex];
  5868. var bViewport = b.viewports[viewportIndex];
  5869. return viewportsEqual(aViewport, bViewport);
  5870. }
  5871. function viewportsEqual(a, b) {
  5872. return a.height === b.height && a.width === b.width;
  5873. }
  5874. var CornerstoneViewport =
  5875. /*#__PURE__*/
  5876. function (_Component) {
  5877. inherits(CornerstoneViewport, _Component);
  5878. function CornerstoneViewport(props) {
  5879. var _this;
  5880. classCallCheck(this, CornerstoneViewport);
  5881. _this = possibleConstructorReturn(this, getPrototypeOf(CornerstoneViewport).call(this, props)); // TODO: Allow viewport as a prop
  5882. defineProperty(assertThisInitialized(_this), "updateViewportSpecificData", function () {
  5883. if (!_this.props.setViewportSpecificData) {
  5884. return;
  5885. }
  5886. var stateStack = _this.state.stack;
  5887. var viewportDataStack = _this.props.viewportData.stack; // Skip if study or display set was changed
  5888. if (stateStack.displaySetInstanceUid !== viewportDataStack.displaySetInstanceUid || stateStack.studyInstanceUid !== viewportDataStack.studyInstanceUid) {
  5889. return;
  5890. } // Skip if image was not changed
  5891. if (stateStack.sopInstanceUid && viewportDataStack.sopInstanceUid && stateStack.currentImageIdIndex === viewportDataStack.currentImageIdIndex && stateStack.sopInstanceUid === viewportDataStack.sopInstanceUid) {
  5892. return;
  5893. }
  5894. var stackData = cornerstoneTools.getToolState(_this.element, 'stack');
  5895. var stack = stackData && stackData.data[0]; // Use viewport stack if cornerstone stack is not ready yet
  5896. if (!stack) {
  5897. stack = viewportDataStack;
  5898. }
  5899. var imageId = stack.imageIds[stack.currentImageIdIndex];
  5900. var sopCommonModule = cornerstone.metaData.get('sopCommonModule', imageId);
  5901. if (!sopCommonModule) {
  5902. return;
  5903. }
  5904. _this.props.setViewportSpecificData({
  5905. displaySetInstanceUid: stack.displaySetInstanceUid,
  5906. studyInstanceUid: stack.studyInstanceUid,
  5907. currentImageIdIndex: stack.currentImageIdIndex,
  5908. sopInstanceUid: sopCommonModule.sopInstanceUID
  5909. });
  5910. });
  5911. defineProperty(assertThisInitialized(_this), "onContextMenu", function (event) {
  5912. event.preventDefault();
  5913. });
  5914. defineProperty(assertThisInitialized(_this), "onWindowResize", function () {
  5915. _this.debouncedResize();
  5916. });
  5917. defineProperty(assertThisInitialized(_this), "onImageRendered", function (event) {
  5918. _this.setState({
  5919. viewport: Object.assign({}, event.detail.viewport)
  5920. });
  5921. });
  5922. defineProperty(assertThisInitialized(_this), "onNewImage", function (event) {
  5923. _this.setState({
  5924. imageId: event.detail.image.imageId
  5925. });
  5926. if (_this.props.onNewImage) {
  5927. _this.props.onNewImage(event);
  5928. }
  5929. _this.debouncedUpdateViewportSpecificData();
  5930. });
  5931. defineProperty(assertThisInitialized(_this), "onDoubleClick", function (event) {
  5932. if (_this.props.onDoubleClick) {
  5933. _this.props.onDoubleClick(event);
  5934. }
  5935. });
  5936. defineProperty(assertThisInitialized(_this), "setActiveTool", function (activeTool) {
  5937. // TODO: cache these, update it on componentDidUpdate
  5938. var leftMouseToolNames = _this.props.availableTools.filter(function (tool) {
  5939. if (!tool.mouseButtonMasks) {
  5940. return;
  5941. }
  5942. return tool.mouseButtonMasks.includes(1);
  5943. }).map(function (tool) {
  5944. return tool.name;
  5945. });
  5946. var leftMouseToolsWithAnotherButtonMask = _this.props.availableTools.filter(function (tool) {
  5947. if (!tool.mouseButtonMasks) {
  5948. return;
  5949. }
  5950. return tool.mouseButtonMasks.includes(1) && tool.mouseButtonMasks.length > 1;
  5951. });
  5952. try {
  5953. setToolsPassive(cornerstoneTools, leftMouseToolNames);
  5954. } catch (error) {
  5955. // TODO: Looks like the Brush tool is calling updateImage, which is
  5956. // failing because the image is not available yet in the enabledElement?
  5957. // (Although I would have expected it to be there after displayImage is
  5958. // called...)
  5959. console.warn(error);
  5960. } // This turns e.g. the Zoom and Pan tools back to active, if they
  5961. // were bound to e.g. [1,2] or [1,4]
  5962. leftMouseToolsWithAnotherButtonMask.forEach(function (tool) {
  5963. var mouseButtonMask = tool.mouseButtonMasks.filter(function (mask) {
  5964. return mask !== 1;
  5965. });
  5966. cornerstoneTools.setToolActive(tool.name, {
  5967. mouseButtonMask: mouseButtonMask
  5968. });
  5969. });
  5970. cornerstoneTools.setToolActive(activeTool, {
  5971. mouseButtonMask: 1,
  5972. isTouchActive: true
  5973. });
  5974. });
  5975. defineProperty(assertThisInitialized(_this), "onStackScroll", function (event) {
  5976. _this.setViewportActive();
  5977. var element = event.currentTarget;
  5978. var stackData = cornerstoneTools.getToolState(element, 'stack');
  5979. var stack = stackData.data[0];
  5980. _this.setState({
  5981. stack: stack
  5982. });
  5983. });
  5984. defineProperty(assertThisInitialized(_this), "onImageLoaded", function () {
  5985. _this.setState({
  5986. numImagesLoaded: _this.state.numImagesLoaded + 1
  5987. });
  5988. });
  5989. defineProperty(assertThisInitialized(_this), "startLoadingHandler", function () {
  5990. clearTimeout(_this.loadHandlerTimeout);
  5991. _this.loadHandlerTimeout = setTimeout(function () {
  5992. _this.setState({
  5993. isLoading: true
  5994. });
  5995. }, CornerstoneViewport.loadIndicatorDelay);
  5996. });
  5997. defineProperty(assertThisInitialized(_this), "doneLoadingHandler", function () {
  5998. clearTimeout(_this.loadHandlerTimeout);
  5999. _this.setState({
  6000. isLoading: false
  6001. });
  6002. });
  6003. defineProperty(assertThisInitialized(_this), "onMeasurementAdded", function (event) {
  6004. if (_this.props.onMeasurementsChanged) {
  6005. _this.props.onMeasurementsChanged(event, 'added');
  6006. }
  6007. });
  6008. defineProperty(assertThisInitialized(_this), "onMeasurementRemoved", function (event) {
  6009. if (_this.props.onMeasurementsChanged) {
  6010. _this.props.onMeasurementsChanged(event, 'removed');
  6011. }
  6012. });
  6013. defineProperty(assertThisInitialized(_this), "onMeasurementModified", function (event) {
  6014. if (_this.props.onMeasurementsChanged) {
  6015. _this.props.onMeasurementsChanged(event, 'modified');
  6016. }
  6017. });
  6018. defineProperty(assertThisInitialized(_this), "setViewportActive", function () {
  6019. if (!_this.props.isActive && _this.props.setViewportActive) {
  6020. _this.props.setViewportActive();
  6021. }
  6022. });
  6023. defineProperty(assertThisInitialized(_this), "onMouseClick", function (event) {
  6024. _this.setViewportActive();
  6025. if (event.detail.event.which === 3) {
  6026. if (_this.props.onRightClick) {
  6027. _this.props.onRightClick(event);
  6028. }
  6029. } else {
  6030. if (_this.props.onMouseClick) {
  6031. _this.props.onMouseClick(event);
  6032. }
  6033. }
  6034. });
  6035. defineProperty(assertThisInitialized(_this), "onTouchPress", function (event) {
  6036. _this.setViewportActive();
  6037. if (_this.props.onTouchPress) {
  6038. _this.props.onTouchPress(event);
  6039. }
  6040. });
  6041. defineProperty(assertThisInitialized(_this), "onTouchStart", function (event) {
  6042. _this.setViewportActive();
  6043. if (_this.props.onTouchStart) {
  6044. _this.props.onTouchStart(event);
  6045. }
  6046. });
  6047. defineProperty(assertThisInitialized(_this), "imageSliderOnInputCallback", function (value) {
  6048. _this.setViewportActive();
  6049. scrollToIndex(_this.element, value);
  6050. var stack = _this.state.stack;
  6051. stack.currentImageIdIndex = value;
  6052. _this.setState({
  6053. stack: stack
  6054. });
  6055. });
  6056. var _viewportDataStack = props.viewportData.stack;
  6057. var _stack = Object.assign({}, _viewportDataStack);
  6058. _this.state = {
  6059. stack: _stack,
  6060. displaySetInstanceUid: props.viewportData.displaySetInstanceUid,
  6061. imageId: _stack.imageIds[_stack.currentImageIdIndex || 0],
  6062. viewportHeight: '100%',
  6063. isLoading: true,
  6064. numImagesLoaded: 0,
  6065. error: null,
  6066. viewport: cornerstone.getDefaultViewport(null, undefined)
  6067. };
  6068. _this.debouncedResize = lodash_debounce(function () {
  6069. try {
  6070. cornerstone.getEnabledElement(_this.element);
  6071. } catch (error) {
  6072. console.error(error);
  6073. return;
  6074. }
  6075. cornerstone.resize(_this.element, props.shouldFitToWindowOnResize);
  6076. _this.setState({
  6077. viewportHeight: "".concat(_this.element.clientHeight - 20, "px")
  6078. });
  6079. }, 300);
  6080. _this.debouncedUpdateViewportSpecificData = lodash_debounce(_this.updateViewportSpecificData, 300);
  6081. return _this;
  6082. }
  6083. /**
  6084. * Updates viewportSpecificData only if new image is displayed for the same study and display set (stack scroll, cine play, etc.)
  6085. */
  6086. createClass(CornerstoneViewport, [{
  6087. key: "getOverlay",
  6088. value: function getOverlay() {
  6089. var Component = this.props.viewportOverlayComponent;
  6090. var _this$state = this.state,
  6091. imageId = _this$state.imageId,
  6092. stack = _this$state.stack,
  6093. viewport = _this$state.viewport;
  6094. return React__default.createElement(Component, {
  6095. stack: stack,
  6096. viewport: viewport,
  6097. imageId: imageId
  6098. });
  6099. }
  6100. }, {
  6101. key: "render",
  6102. value: function render() {
  6103. var _this2 = this;
  6104. var isLoading = this.state.isLoading; // TODO: Check this later
  6105. // || this.state.numImagesLoaded < 1;
  6106. var displayLoadingIndicator = isLoading || this.state.error;
  6107. var className = 'CornerstoneViewport';
  6108. if (this.props.isActive) {
  6109. className += ' active';
  6110. }
  6111. return React__default.createElement("div", {
  6112. className: className
  6113. }, ReactResizeDetector && React__default.createElement(ReactResizeDetector, {
  6114. handleWidth: true,
  6115. handleHeight: true,
  6116. onResize: this.onWindowResize
  6117. }), React__default.createElement("div", {
  6118. className: "viewport-element",
  6119. onContextMenu: this.onContextMenu,
  6120. "data-viewport-index": this.props.viewportIndex,
  6121. ref: function ref(input) {
  6122. _this2.element = input;
  6123. }
  6124. }, displayLoadingIndicator && React__default.createElement(LoadingIndicator, {
  6125. error: this.state.error
  6126. }), React__default.createElement("canvas", {
  6127. className: "cornerstone-canvas"
  6128. }), this.getOverlay(), React__default.createElement(ViewportOrientationMarkers, {
  6129. imageId: this.state.imageId,
  6130. viewport: this.state.viewport
  6131. })), React__default.createElement(ImageScrollbar, {
  6132. onInputCallback: this.imageSliderOnInputCallback,
  6133. max: this.state.stack.imageIds.length - 1,
  6134. value: this.state.stack.currentImageIdIndex,
  6135. height: this.state.viewportHeight
  6136. }), this.props.children);
  6137. }
  6138. /**
  6139. * Preventing the default behaviour for right-click is essential to
  6140. * allow right-click tools to work.
  6141. *
  6142. * @param event
  6143. */
  6144. }, {
  6145. key: "componentDidMount",
  6146. value: function componentDidMount() {
  6147. var _this3 = this;
  6148. var element = this.element;
  6149. this.eventHandlerData = [{
  6150. eventTarget: element,
  6151. eventType: cornerstone.EVENTS.IMAGE_RENDERED,
  6152. handler: this.onImageRendered
  6153. }, {
  6154. eventTarget: element,
  6155. eventType: cornerstone.EVENTS.NEW_IMAGE,
  6156. handler: this.onNewImage
  6157. }, {
  6158. eventTarget: element,
  6159. eventType: cornerstoneTools.EVENTS.STACK_SCROLL,
  6160. handler: this.onStackScroll
  6161. }, {
  6162. eventTarget: element,
  6163. eventType: cornerstoneTools.EVENTS.MEASUREMENT_ADDED,
  6164. handler: this.onMeasurementAdded
  6165. }, {
  6166. eventTarget: element,
  6167. eventType: cornerstoneTools.EVENTS.MEASUREMENT_MODIFIED,
  6168. handler: this.onMeasurementModified
  6169. }, {
  6170. eventTarget: element,
  6171. eventType: cornerstoneTools.EVENTS.MEASUREMENT_REMOVED,
  6172. handler: this.onMeasurementRemoved
  6173. }, {
  6174. eventTarget: element,
  6175. eventType: cornerstoneTools.EVENTS.MEASUREMENT_MODIFIED,
  6176. handler: this.onMeasurementModified
  6177. }, {
  6178. eventTarget: element,
  6179. eventType: cornerstoneTools.EVENTS.MOUSE_CLICK,
  6180. handler: this.onMouseClick
  6181. }, {
  6182. eventTarget: element,
  6183. eventType: cornerstoneTools.EVENTS.MOUSE_DOWN,
  6184. handler: this.onMouseClick
  6185. }, {
  6186. eventTarget: element,
  6187. eventType: cornerstoneTools.EVENTS.TOUCH_PRESS,
  6188. handler: this.onTouchPress
  6189. }, {
  6190. eventTarget: element,
  6191. eventType: cornerstoneTools.EVENTS.TOUCH_START,
  6192. handler: this.onTouchStart
  6193. }, {
  6194. eventTarget: element,
  6195. eventType: cornerstoneTools.EVENTS.DOUBLE_CLICK,
  6196. handler: this.onDoubleClick
  6197. }, {
  6198. eventTarget: element,
  6199. eventType: cornerstoneTools.EVENTS.DOUBLE_TAP,
  6200. handler: this.onDoubleClick
  6201. }, {
  6202. eventTarget: window,
  6203. eventType: EVENT_RESIZE,
  6204. handler: this.onWindowResize
  6205. }, {
  6206. eventTarget: cornerstone.events,
  6207. eventType: cornerstone.EVENTS.IMAGE_LOADED,
  6208. handler: this.onImageLoaded
  6209. }];
  6210. this.eventHandlerData.forEach(function (data) {
  6211. var eventTarget = data.eventTarget,
  6212. eventType = data.eventType,
  6213. handler = data.handler;
  6214. eventTarget.addEventListener(eventType, handler);
  6215. }); // Pass ELEMENT_ENABLED event to parent
  6216. var onElementEnabledFn = function onElementEnabledFn(evt) {
  6217. var enabledElement = evt.detail.element;
  6218. if (enabledElement === _this3.element) {
  6219. if (_this3.props.onElementEnabled) {
  6220. _this3.props.onElementEnabled(evt);
  6221. }
  6222. cornerstone.events.removeEventListener(cornerstone.EVENTS.ELEMENT_ENABLED, onElementEnabledFn);
  6223. }
  6224. };
  6225. cornerstone.events.addEventListener(cornerstone.EVENTS.ELEMENT_ENABLED, onElementEnabledFn);
  6226. cornerstone.enable(element, this.props.cornerstoneOptions);
  6227. loadHandlerManager.setStartLoadHandler(this.startLoadingHandler, this.element);
  6228. loadHandlerManager.setEndLoadHandler(this.doneLoadingHandler, this.element); // Handle the case where the imageId isn't loaded correctly and the
  6229. // imagePromise returns undefined
  6230. // To test, uncomment the next line
  6231. //let imageId = 'AfileThatDoesntWork'; // For testing only!
  6232. var imageId = this.state.imageId;
  6233. var imagePromise;
  6234. try {
  6235. imagePromise = cornerstone.loadAndCacheImage(imageId);
  6236. } catch (error) {
  6237. console.error(error);
  6238. if (!imagePromise) {
  6239. this.setState({
  6240. error: error
  6241. });
  6242. return;
  6243. }
  6244. } // Load the first image in the stack
  6245. imagePromise.then(function (image) {
  6246. try {
  6247. cornerstone.getEnabledElement(element);
  6248. } catch (error) {
  6249. // Handle cases where the user ends the session before the image is displayed.
  6250. console.error(error);
  6251. return;
  6252. } // Set Soft Tissue preset for all images by default
  6253. var viewport = cornerstone.getDefaultViewportForImage(element, image); // Display the first image
  6254. cornerstone.displayImage(element, image, viewport); // Clear any previous tool state
  6255. cornerstoneTools.clearToolState(_this3.element, 'stack');
  6256. /* Add the stack tool state to the enabled element, and
  6257. add stack state managers for the stack tool, CINE tool, and reference lines
  6258. */
  6259. var stack = _this3.state.stack;
  6260. cornerstoneTools.addStackStateManager(element, ['stack', 'playClip', 'referenceLines']);
  6261. cornerstoneTools.addToolState(element, 'stack', stack);
  6262. if (_this3.props.enableStackPrefetch) {
  6263. cornerstoneTools.stackPrefetch.enable(_this3.element);
  6264. }
  6265. initializeTools(cornerstoneTools, _this3.props.availableTools, element);
  6266. _this3.setActiveTool(_this3.props.activeTool);
  6267. /* For touch devices, by default we activate:
  6268. - Pinch to zoom
  6269. - Two-finger Pan
  6270. - Three (or more) finger Stack Scroll
  6271. */
  6272. cornerstoneTools.setToolActive('PanMultiTouch', {
  6273. mouseButtonMask: 0,
  6274. isTouchActive: true
  6275. });
  6276. cornerstoneTools.setToolActive('ZoomTouchPinch', {
  6277. mouseButtonMask: 0,
  6278. isTouchActive: true
  6279. });
  6280. cornerstoneTools.setToolActive('StackScrollMultiTouch', {
  6281. mouseButtonMask: 0,
  6282. isTouchActive: true
  6283. }); // TODO: We should probably configure this somewhere else
  6284. cornerstoneTools.stackPrefetch.setConfiguration({
  6285. maxImagesToPrefetch: Infinity,
  6286. preserveExistingPool: false,
  6287. maxSimultaneousRequests: 6
  6288. });
  6289. /* For mouse devices, by default we turn on:
  6290. - Stack scrolling by mouse wheel
  6291. - Stack scrolling by keyboard up / down arrow keys
  6292. - Pan with middle click
  6293. - Zoom with right click
  6294. */
  6295. cornerstoneTools.setToolActive('StackScrollMouseWheel', {
  6296. mouseButtonMask: 0,
  6297. isTouchActive: true
  6298. });
  6299. _this3.setState({
  6300. viewportHeight: "".concat(_this3.element.clientHeight - 20, "px")
  6301. }); // Our `doneLoadingHandler` isn't firing for the initial image load
  6302. // Dropping this here, as the image should definitely be loaded at this point,
  6303. // and we can force the loading state off. TODO: investigate
  6304. setTimeout(function () {
  6305. _this3.setState({
  6306. isLoading: false
  6307. });
  6308. }, CornerstoneViewport.loadIndicatorDelay);
  6309. }, function (error) {
  6310. console.error(error);
  6311. _this3.setState({
  6312. error: error
  6313. });
  6314. });
  6315. }
  6316. }, {
  6317. key: "componentWillUnmount",
  6318. value: function componentWillUnmount() {
  6319. this.eventHandlerData.forEach(function (data) {
  6320. var eventTarget = data.eventTarget,
  6321. eventType = data.eventType,
  6322. handler = data.handler;
  6323. eventTarget.removeEventListener(eventType, handler);
  6324. });
  6325. var element = this.element; // Clear the stack prefetch data
  6326. // TODO[cornerstoneTools]: Make this happen internally
  6327. cornerstoneTools.clearToolState(element, 'stackPrefetch'); // Try to stop any currently playing clips
  6328. // Otherwise the interval will continuously throw errors
  6329. // TODO[cornerstoneTools]: Make this happen internally
  6330. var enabledElement = cornerstone.getEnabledElement(element);
  6331. if (enabledElement) {
  6332. cornerstoneTools.stopClip(element);
  6333. } // Disable the viewport element with Cornerstone
  6334. // This also triggers the removal of the element from all available
  6335. // synchronizers, such as the one used for reference lines.
  6336. cornerstone.disable(element);
  6337. if (this.props.clearViewportSpecificData) {
  6338. this.props.clearViewportSpecificData();
  6339. }
  6340. }
  6341. }, {
  6342. key: "componentDidUpdate",
  6343. value: function componentDidUpdate(prevProps) {
  6344. var _this4 = this;
  6345. // TODO: Add a real object shallow comparison here?
  6346. if (this.state.displaySetInstanceUid !== this.props.viewportData.displaySetInstanceUid) {
  6347. var _this$props$viewportD = this.props.viewportData,
  6348. displaySetInstanceUid = _this$props$viewportD.displaySetInstanceUid,
  6349. studyInstanceUid = _this$props$viewportD.studyInstanceUid;
  6350. var currentImageIdIndex = this.props.viewportData.stack.currentImageIdIndex;
  6351. var stack = this.props.viewportData.stack;
  6352. var stackData = cornerstoneTools.getToolState(this.element, 'stack');
  6353. var currentStack = stackData && stackData.data[0];
  6354. if (!currentStack) {
  6355. currentStack = {
  6356. displaySetInstanceUid: displaySetInstanceUid,
  6357. studyInstanceUid: studyInstanceUid,
  6358. currentImageIdIndex: currentImageIdIndex,
  6359. imageIds: stack.imageIds
  6360. };
  6361. cornerstoneTools.addStackStateManager(this.element, ['stack']);
  6362. cornerstoneTools.addToolState(this.element, 'stack', currentStack);
  6363. } else {
  6364. // TODO: we should make something like setToolState by an ID
  6365. currentStack.displaySetInstanceUid = displaySetInstanceUid;
  6366. currentStack.studyInstanceUid = studyInstanceUid;
  6367. currentStack.currentImageIdIndex = currentImageIdIndex;
  6368. currentStack.imageIds = stack.imageIds;
  6369. }
  6370. var imageId = currentStack.imageIds[currentImageIdIndex] || currentStack.imageIds[0];
  6371. this.setState({
  6372. displaySetInstanceUid: displaySetInstanceUid,
  6373. studyInstanceUid: studyInstanceUid,
  6374. stack: stack,
  6375. imageId: imageId
  6376. });
  6377. cornerstoneTools.stackPrefetch.disable(this.element);
  6378. cornerstone.loadAndCacheImage(imageId).then(function (image) {
  6379. try {
  6380. cornerstone.getEnabledElement(_this4.element);
  6381. } catch (error) {
  6382. // Handle cases where the user ends the session before the image is displayed.
  6383. console.error(error);
  6384. return;
  6385. }
  6386. var viewport = cornerstone.getDefaultViewportForImage(_this4.element, image); // Workaround for Cornerstone issue #304
  6387. viewport.displayedArea.brhc = {
  6388. x: image.width,
  6389. y: image.height
  6390. };
  6391. cornerstone.displayImage(_this4.element, image, viewport);
  6392. cornerstoneTools.stackPrefetch.enable(_this4.element);
  6393. });
  6394. }
  6395. if (this.state.stack.currentImageIdIndex !== this.props.viewportData.stack.currentImageIdIndex && prevProps.viewportData.stack.currentImageIdIndex !== this.props.viewportData.stack.currentImageIdIndex) {
  6396. var _this$props$viewportD2 = this.props.viewportData,
  6397. _displaySetInstanceUid = _this$props$viewportD2.displaySetInstanceUid,
  6398. _studyInstanceUid = _this$props$viewportD2.studyInstanceUid;
  6399. var _currentImageIdIndex = this.props.viewportData.stack.currentImageIdIndex;
  6400. var viewportDataStack = this.props.viewportData.stack;
  6401. var _stack2 = Object.assign({}, viewportDataStack);
  6402. var _stackData = cornerstoneTools.getToolState(this.element, 'stack');
  6403. var _currentStack = _stackData && _stackData.data[0];
  6404. if (!_currentStack) {
  6405. _currentStack = {
  6406. displaySetInstanceUid: _displaySetInstanceUid,
  6407. studyInstanceUid: _studyInstanceUid,
  6408. currentImageIdIndex: _currentImageIdIndex,
  6409. imageIds: _stack2.imageIds
  6410. };
  6411. cornerstoneTools.addStackStateManager(this.element, ['stack']);
  6412. cornerstoneTools.addToolState(this.element, 'stack', _currentStack);
  6413. } else {
  6414. scrollToIndex(this.element, _currentImageIdIndex); // TODO: we should make something like setToolState by an ID
  6415. _currentStack.displaySetInstanceUid = _displaySetInstanceUid;
  6416. _currentStack.studyInstanceUid = _studyInstanceUid;
  6417. _currentStack.currentImageIdIndex = _currentImageIdIndex;
  6418. _currentStack.imageIds = _stack2.imageIds;
  6419. }
  6420. var _imageId = _currentStack.imageIds[_currentImageIdIndex];
  6421. this.setState({
  6422. displaySetInstanceUid: _displaySetInstanceUid,
  6423. studyInstanceUid: _studyInstanceUid,
  6424. stack: _stack2,
  6425. imageId: _imageId
  6426. });
  6427. }
  6428. if (this.props.activeTool !== prevProps.activeTool) {
  6429. this.setActiveTool(this.props.activeTool); // TODO: Why do we need to do this in v3?
  6430. cornerstoneTools.setToolActive('StackScrollMouseWheel', {
  6431. mouseButtonMask: 0,
  6432. isTouchActive: true
  6433. });
  6434. }
  6435. if (this.props.layout && !areLayoutsEqual(this.props.layout, prevProps.layout)) {
  6436. this.debouncedResize();
  6437. }
  6438. if (this.props.enableStackPrefetch !== prevProps.enableStackPrefetch && this.props.enableStackPrefetch === true) {
  6439. cornerstoneTools.stackPrefetch.enable(this.element);
  6440. } else if (this.props.enableStackPrefetch !== prevProps.enableStackPrefetch && this.props.enableStackPrefetch === false) {
  6441. cornerstoneTools.stackPrefetch.disable(this.element);
  6442. }
  6443. if (this.props.cineToolData.isPlaying !== prevProps.cineToolData.isPlaying) {
  6444. if (this.props.cineToolData.isPlaying) {
  6445. cornerstoneTools.playClip(this.element);
  6446. } else {
  6447. cornerstoneTools.stopClip(this.element);
  6448. }
  6449. }
  6450. if (this.props.cineToolData.cineFrameRate !== prevProps.cineToolData.cineFrameRate) {
  6451. if (this.props.cineToolData.isPlaying) {
  6452. cornerstoneTools.playClip(this.element, this.props.cineToolData.cineFrameRate);
  6453. } else {
  6454. cornerstoneTools.stopClip(this.element, this.props.cineToolData.cineFrameRate);
  6455. }
  6456. }
  6457. }
  6458. }]);
  6459. return CornerstoneViewport;
  6460. }(React.Component);
  6461. defineProperty(CornerstoneViewport, "defaultProps", {
  6462. activeTool: 'Wwwc',
  6463. viewportData: {
  6464. stack: {
  6465. imageIds: [],
  6466. currentImageIdIndex: 0
  6467. }
  6468. },
  6469. isActive: false,
  6470. cornerstoneOptions: {},
  6471. enableStackPrefetch: true,
  6472. cineToolData: {
  6473. isPlaying: false,
  6474. cineFrameRate: 24
  6475. },
  6476. availableTools: [{
  6477. name: 'Pan',
  6478. mouseButtonMasks: [1, 4]
  6479. }, {
  6480. name: 'Zoom',
  6481. props: {
  6482. minScale: 0.3,
  6483. maxScale: 25,
  6484. preventZoomOutsideImage: true
  6485. },
  6486. mouseButtonMasks: [1, 2]
  6487. }, {
  6488. name: 'Wwwc',
  6489. mouseButtonMasks: [1]
  6490. }, {
  6491. name: 'Bidirectional',
  6492. mouseButtonMasks: [1]
  6493. }, {
  6494. name: 'Length',
  6495. mouseButtonMasks: [1]
  6496. }, {
  6497. name: 'FreehandRoi',
  6498. mouseButtonMasks: [1]
  6499. }, {
  6500. name: 'Angle',
  6501. mouseButtonMasks: [1]
  6502. }, {
  6503. name: 'StackScroll',
  6504. mouseButtonMasks: [1]
  6505. }, {
  6506. name: 'Brush',
  6507. mouseButtonMasks: [1]
  6508. }, {
  6509. name: 'PanMultiTouch'
  6510. }, {
  6511. name: 'ZoomTouchPinch'
  6512. }, {
  6513. name: 'StackScrollMouseWheel'
  6514. }, {
  6515. name: 'StackScrollMultiTouch'
  6516. }],
  6517. viewportOverlayComponent: ViewportOverlay,
  6518. shouldFitToWindowOnResize: false
  6519. });
  6520. defineProperty(CornerstoneViewport, "propTypes", {
  6521. activeTool: propTypes.string.isRequired,
  6522. viewportData: propTypes.object.isRequired,
  6523. cornerstoneOptions: propTypes.object.isRequired,
  6524. enableStackPrefetch: propTypes.bool.isRequired,
  6525. cineToolData: propTypes.object.isRequired,
  6526. availableTools: propTypes.array.isRequired,
  6527. onMeasurementsChanged: propTypes.func,
  6528. onElementEnabled: propTypes.func,
  6529. isActive: propTypes.bool.isRequired,
  6530. layout: propTypes.object,
  6531. children: propTypes.node,
  6532. onDoubleClick: propTypes.func,
  6533. onRightClick: propTypes.func,
  6534. onMouseClick: propTypes.func,
  6535. onTouchPress: propTypes.func,
  6536. onNewImage: propTypes.func,
  6537. onTouchStart: propTypes.func,
  6538. setViewportActive: propTypes.func,
  6539. setViewportSpecificData: propTypes.func,
  6540. clearViewportSpecificData: propTypes.func,
  6541. viewportOverlayComponent: propTypes.oneOfType([propTypes.string, propTypes.func]),
  6542. shouldFitToWindowOnResize: propTypes.bool,
  6543. viewportIndex: propTypes.number
  6544. });
  6545. defineProperty(CornerstoneViewport, "loadIndicatorDelay", 45);
  6546. return CornerstoneViewport;
  6547. }));
  6548. //# sourceMappingURL=index.umd.js.map