common.js 265 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { InjectionToken, EventEmitter, Injectable, Optional, Inject, ɵfindLocaleData, ɵLocaleDataIndex, ɵgetLocalePluralCase, LOCALE_ID, ɵLOCALE_DATA, ɵisListLikeIterable, ɵstringify, IterableDiffers, KeyValueDiffers, ElementRef, Renderer2, ɵɵdefineDirective, Directive, Input, ɵɵstyling, ɵɵclassMap, ɵɵstylingApply, NgModuleRef, ComponentFactoryResolver, ViewContainerRef, isDevMode, TemplateRef, Host, Attribute, ɵɵstyleMap, Pipe, ɵlooseIdentical, WrappedValue, ɵisPromise, ɵisObservable, ChangeDetectorRef, NgModule, Version, ɵɵdefineInjectable, ɵɵinject, ErrorHandler } from '@angular/core';
  7. /**
  8. * @fileoverview added by tsickle
  9. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10. */
  11. /**
  12. * This class should not be used directly by an application developer. Instead, use
  13. * {\@link Location}.
  14. *
  15. * `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
  16. * agnostic.
  17. * This means that we can have different implementation of `PlatformLocation` for the different
  18. * platforms that angular supports. For example, `\@angular/platform-browser` provides an
  19. * implementation specific to the browser environment, while `\@angular/platform-webworker` provides
  20. * one suitable for use with web workers.
  21. *
  22. * The `PlatformLocation` class is used directly by all implementations of {\@link LocationStrategy}
  23. * when they need to interact with the DOM apis like pushState, popState, etc...
  24. *
  25. * {\@link LocationStrategy} in turn is used by the {\@link Location} service which is used directly
  26. * by the {\@link Router} in order to navigate between routes. Since all interactions between {\@link
  27. * Router} /
  28. * {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
  29. * class they are all platform independent.
  30. *
  31. * \@publicApi
  32. * @abstract
  33. */
  34. class PlatformLocation {
  35. }
  36. /**
  37. * \@description
  38. * Indicates when a location is initialized.
  39. *
  40. * \@publicApi
  41. * @type {?}
  42. */
  43. const LOCATION_INITIALIZED = new InjectionToken('Location Initialized');
  44. /**
  45. * @fileoverview added by tsickle
  46. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  47. */
  48. /**
  49. * Enables the `Location` service to read route state from the browser's URL.
  50. * Angular provides two strategies:
  51. * `HashLocationStrategy` and `PathLocationStrategy`.
  52. *
  53. * Applications should use the `Router` or `Location` services to
  54. * interact with application route state.
  55. *
  56. * For instance, `HashLocationStrategy` produces URLs like
  57. * <code class="no-auto-link">http://example.com#/foo</code>,
  58. * and `PathLocationStrategy` produces
  59. * <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL.
  60. *
  61. * See these two classes for more.
  62. *
  63. * \@publicApi
  64. * @abstract
  65. */
  66. class LocationStrategy {
  67. }
  68. /**
  69. * A predefined [DI token](guide/glossary#di-token) for the base href
  70. * to be used with the `PathLocationStrategy`.
  71. * The base href is the URL prefix that should be preserved when generating
  72. * and recognizing URLs.
  73. *
  74. * \@usageNotes
  75. *
  76. * The following example shows how to use this token to configure the root app injector
  77. * with a base href value, so that the DI framework can supply the dependency anywhere in the app.
  78. *
  79. * ```typescript
  80. * import {Component, NgModule} from '\@angular/core';
  81. * import {APP_BASE_HREF} from '\@angular/common';
  82. *
  83. * \@NgModule({
  84. * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
  85. * })
  86. * class AppModule {}
  87. * ```
  88. *
  89. * \@publicApi
  90. * @type {?}
  91. */
  92. const APP_BASE_HREF = new InjectionToken('appBaseHref');
  93. /**
  94. * @fileoverview added by tsickle
  95. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  96. */
  97. /**
  98. * \@description
  99. *
  100. * A service that applications can use to interact with a browser's URL.
  101. *
  102. * Depending on the `LocationStrategy` used, `Location` will either persist
  103. * to the URL's path or the URL's hash segment.
  104. *
  105. * \@usageNotes
  106. *
  107. * It's better to use the {\@link Router#navigate} service to trigger route changes. Use
  108. * `Location` only if you need to interact with or create normalized URLs outside of
  109. * routing.
  110. *
  111. * `Location` is responsible for normalizing the URL against the application's base href.
  112. * A normalized URL is absolute from the URL host, includes the application's base href, and has no
  113. * trailing slash:
  114. * - `/my/app/user/123` is normalized
  115. * - `my/app/user/123` **is not** normalized
  116. * - `/my/app/user/123/` **is not** normalized
  117. *
  118. * ### Example
  119. *
  120. * <code-example path='common/location/ts/path_location_component.ts'
  121. * region='LocationComponent'></code-example>
  122. *
  123. * \@publicApi
  124. */
  125. class Location {
  126. /**
  127. * @param {?} platformStrategy
  128. * @param {?} platformLocation
  129. */
  130. constructor(platformStrategy, platformLocation) {
  131. /**
  132. * \@internal
  133. */
  134. this._subject = new EventEmitter();
  135. /**
  136. * \@internal
  137. */
  138. this._urlChangeListeners = [];
  139. this._platformStrategy = platformStrategy;
  140. /** @type {?} */
  141. const browserBaseHref = this._platformStrategy.getBaseHref();
  142. this._platformLocation = platformLocation;
  143. this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
  144. this._platformStrategy.onPopState((/**
  145. * @param {?} ev
  146. * @return {?}
  147. */
  148. (ev) => {
  149. this._subject.emit({
  150. 'url': this.path(true),
  151. 'pop': true,
  152. 'state': ev.state,
  153. 'type': ev.type,
  154. });
  155. }));
  156. }
  157. /**
  158. * Returns the normalized URL path.
  159. *
  160. * @param {?=} includeHash Whether path has an anchor fragment.
  161. *
  162. * @return {?} The normalized URL path.
  163. */
  164. // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is
  165. // removed.
  166. path(includeHash = false) {
  167. return this.normalize(this._platformStrategy.path(includeHash));
  168. }
  169. /**
  170. * Returns the current value of the history.state object.
  171. * @return {?}
  172. */
  173. getState() { return this._platformLocation.getState(); }
  174. /**
  175. * Normalizes the given path and compares to the current normalized path.
  176. *
  177. * @param {?} path The given URL path
  178. * @param {?=} query Query parameters
  179. *
  180. * @return {?} `true` if the given URL path is equal to the current normalized path, `false`
  181. * otherwise.
  182. */
  183. isCurrentPathEqualTo(path, query = '') {
  184. return this.path() == this.normalize(path + Location.normalizeQueryParams(query));
  185. }
  186. /**
  187. * Given a string representing a URL, returns the URL path after stripping the
  188. * trailing slashes.
  189. *
  190. * @param {?} url String representing a URL.
  191. *
  192. * @return {?} Normalized URL string.
  193. */
  194. normalize(url) {
  195. return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
  196. }
  197. /**
  198. * Given a string representing a URL, returns the platform-specific external URL path.
  199. * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
  200. * before normalizing. This method also adds a hash if `HashLocationStrategy` is
  201. * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
  202. *
  203. *
  204. * @param {?} url String representing a URL.
  205. *
  206. * @return {?} A normalized platform-specific URL.
  207. */
  208. prepareExternalUrl(url) {
  209. if (url && url[0] !== '/') {
  210. url = '/' + url;
  211. }
  212. return this._platformStrategy.prepareExternalUrl(url);
  213. }
  214. // TODO: rename this method to pushState
  215. /**
  216. * Changes the browsers URL to a normalized version of the given URL, and pushes a
  217. * new item onto the platform's history.
  218. *
  219. * @param {?} path URL path to normalizze
  220. * @param {?=} query Query parameters
  221. * @param {?=} state Location history state
  222. *
  223. * @return {?}
  224. */
  225. go(path, query = '', state = null) {
  226. this._platformStrategy.pushState(state, '', path, query);
  227. this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location.normalizeQueryParams(query)), state);
  228. }
  229. /**
  230. * Changes the browser's URL to a normalized version of the given URL, and replaces
  231. * the top item on the platform's history stack.
  232. *
  233. * @param {?} path URL path to normalizze
  234. * @param {?=} query Query parameters
  235. * @param {?=} state Location history state
  236. * @return {?}
  237. */
  238. replaceState(path, query = '', state = null) {
  239. this._platformStrategy.replaceState(state, '', path, query);
  240. this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location.normalizeQueryParams(query)), state);
  241. }
  242. /**
  243. * Navigates forward in the platform's history.
  244. * @return {?}
  245. */
  246. forward() { this._platformStrategy.forward(); }
  247. /**
  248. * Navigates back in the platform's history.
  249. * @return {?}
  250. */
  251. back() { this._platformStrategy.back(); }
  252. /**
  253. * Register URL change listeners. This API can be used to catch updates performed by the Angular
  254. * framework. These are not detectible through "popstate" or "hashchange" events.
  255. * @param {?} fn
  256. * @return {?}
  257. */
  258. onUrlChange(fn) {
  259. this._urlChangeListeners.push(fn);
  260. this.subscribe((/**
  261. * @param {?} v
  262. * @return {?}
  263. */
  264. v => { this._notifyUrlChangeListeners(v.url, v.state); }));
  265. }
  266. /**
  267. * \@internal
  268. * @param {?=} url
  269. * @param {?=} state
  270. * @return {?}
  271. */
  272. _notifyUrlChangeListeners(url = '', state) {
  273. this._urlChangeListeners.forEach((/**
  274. * @param {?} fn
  275. * @return {?}
  276. */
  277. fn => fn(url, state)));
  278. }
  279. /**
  280. * Subscribe to the platform's `popState` events.
  281. *
  282. * @param {?} onNext
  283. * @param {?=} onThrow
  284. * @param {?=} onReturn
  285. * @return {?} Subscribed events.
  286. */
  287. subscribe(onNext, onThrow, onReturn) {
  288. return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
  289. }
  290. /**
  291. * Given a string of url parameters, prepend with `?` if needed, otherwise return the
  292. * parameters as is.
  293. *
  294. * @param {?} params String of URL parameters
  295. *
  296. * @return {?} URL parameters prepended with `?` or the parameters as is.
  297. */
  298. static normalizeQueryParams(params) {
  299. return params && params[0] !== '?' ? '?' + params : params;
  300. }
  301. /**
  302. * Given 2 parts of a URL, join them with a slash if needed.
  303. *
  304. * @param {?} start URL string
  305. * @param {?} end URL string
  306. *
  307. *
  308. * @return {?} Given URL strings joined with a slash, if needed.
  309. */
  310. static joinWithSlash(start, end) {
  311. if (start.length == 0) {
  312. return end;
  313. }
  314. if (end.length == 0) {
  315. return start;
  316. }
  317. /** @type {?} */
  318. let slashes = 0;
  319. if (start.endsWith('/')) {
  320. slashes++;
  321. }
  322. if (end.startsWith('/')) {
  323. slashes++;
  324. }
  325. if (slashes == 2) {
  326. return start + end.substring(1);
  327. }
  328. if (slashes == 1) {
  329. return start + end;
  330. }
  331. return start + '/' + end;
  332. }
  333. /**
  334. * If URL has a trailing slash, remove it, otherwise return the URL as is. The
  335. * method looks for the first occurrence of either `#`, `?`, or the end of the
  336. * line as `/` characters and removes the trailing slash if one exists.
  337. *
  338. * @param {?} url URL string
  339. *
  340. * @return {?} Returns a URL string after removing the trailing slash if one exists, otherwise
  341. * returns the string as is.
  342. */
  343. static stripTrailingSlash(url) {
  344. /** @type {?} */
  345. const match = url.match(/#|\?|$/);
  346. /** @type {?} */
  347. const pathEndIdx = match && match.index || url.length;
  348. /** @type {?} */
  349. const droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
  350. return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
  351. }
  352. }
  353. Location.decorators = [
  354. { type: Injectable }
  355. ];
  356. /** @nocollapse */
  357. Location.ctorParameters = () => [
  358. { type: LocationStrategy },
  359. { type: PlatformLocation }
  360. ];
  361. /**
  362. * @param {?} baseHref
  363. * @param {?} url
  364. * @return {?}
  365. */
  366. function _stripBaseHref(baseHref, url) {
  367. return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
  368. }
  369. /**
  370. * @param {?} url
  371. * @return {?}
  372. */
  373. function _stripIndexHtml(url) {
  374. return url.replace(/\/index.html$/, '');
  375. }
  376. /**
  377. * @fileoverview added by tsickle
  378. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  379. */
  380. /**
  381. * \@description
  382. * A {\@link LocationStrategy} used to configure the {\@link Location} service to
  383. * represent its state in the
  384. * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
  385. * of the browser's URL.
  386. *
  387. * For instance, if you call `location.go('/foo')`, the browser's URL will become
  388. * `example.com#/foo`.
  389. *
  390. * \@usageNotes
  391. *
  392. * ### Example
  393. *
  394. * {\@example common/location/ts/hash_location_component.ts region='LocationComponent'}
  395. *
  396. * \@publicApi
  397. */
  398. class HashLocationStrategy extends LocationStrategy {
  399. /**
  400. * @param {?} _platformLocation
  401. * @param {?=} _baseHref
  402. */
  403. constructor(_platformLocation, _baseHref) {
  404. super();
  405. this._platformLocation = _platformLocation;
  406. this._baseHref = '';
  407. if (_baseHref != null) {
  408. this._baseHref = _baseHref;
  409. }
  410. }
  411. /**
  412. * @param {?} fn
  413. * @return {?}
  414. */
  415. onPopState(fn) {
  416. this._platformLocation.onPopState(fn);
  417. this._platformLocation.onHashChange(fn);
  418. }
  419. /**
  420. * @return {?}
  421. */
  422. getBaseHref() { return this._baseHref; }
  423. /**
  424. * @param {?=} includeHash
  425. * @return {?}
  426. */
  427. path(includeHash = false) {
  428. // the hash value is always prefixed with a `#`
  429. // and if it is empty then it will stay empty
  430. /** @type {?} */
  431. let path = this._platformLocation.hash;
  432. if (path == null)
  433. path = '#';
  434. return path.length > 0 ? path.substring(1) : path;
  435. }
  436. /**
  437. * @param {?} internal
  438. * @return {?}
  439. */
  440. prepareExternalUrl(internal) {
  441. /** @type {?} */
  442. const url = Location.joinWithSlash(this._baseHref, internal);
  443. return url.length > 0 ? ('#' + url) : url;
  444. }
  445. /**
  446. * @param {?} state
  447. * @param {?} title
  448. * @param {?} path
  449. * @param {?} queryParams
  450. * @return {?}
  451. */
  452. pushState(state, title, path, queryParams) {
  453. /** @type {?} */
  454. let url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
  455. if (url.length == 0) {
  456. url = this._platformLocation.pathname;
  457. }
  458. this._platformLocation.pushState(state, title, url);
  459. }
  460. /**
  461. * @param {?} state
  462. * @param {?} title
  463. * @param {?} path
  464. * @param {?} queryParams
  465. * @return {?}
  466. */
  467. replaceState(state, title, path, queryParams) {
  468. /** @type {?} */
  469. let url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
  470. if (url.length == 0) {
  471. url = this._platformLocation.pathname;
  472. }
  473. this._platformLocation.replaceState(state, title, url);
  474. }
  475. /**
  476. * @return {?}
  477. */
  478. forward() { this._platformLocation.forward(); }
  479. /**
  480. * @return {?}
  481. */
  482. back() { this._platformLocation.back(); }
  483. }
  484. HashLocationStrategy.decorators = [
  485. { type: Injectable }
  486. ];
  487. /** @nocollapse */
  488. HashLocationStrategy.ctorParameters = () => [
  489. { type: PlatformLocation },
  490. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] }] }
  491. ];
  492. /**
  493. * @fileoverview added by tsickle
  494. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  495. */
  496. /**
  497. * \@description
  498. * A {\@link LocationStrategy} used to configure the {\@link Location} service to
  499. * represent its state in the
  500. * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
  501. * browser's URL.
  502. *
  503. * If you're using `PathLocationStrategy`, you must provide a {\@link APP_BASE_HREF}
  504. * or add a base element to the document. This URL prefix that will be preserved
  505. * when generating and recognizing URLs.
  506. *
  507. * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
  508. * `location.go('/foo')`, the browser's URL will become
  509. * `example.com/my/app/foo`.
  510. *
  511. * Similarly, if you add `<base href='/my/app'/>` to the document and call
  512. * `location.go('/foo')`, the browser's URL will become
  513. * `example.com/my/app/foo`.
  514. *
  515. * \@usageNotes
  516. *
  517. * ### Example
  518. *
  519. * {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
  520. *
  521. * \@publicApi
  522. */
  523. class PathLocationStrategy extends LocationStrategy {
  524. /**
  525. * @param {?} _platformLocation
  526. * @param {?=} href
  527. */
  528. constructor(_platformLocation, href) {
  529. super();
  530. this._platformLocation = _platformLocation;
  531. if (href == null) {
  532. href = this._platformLocation.getBaseHrefFromDOM();
  533. }
  534. if (href == null) {
  535. throw new Error(`No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.`);
  536. }
  537. this._baseHref = href;
  538. }
  539. /**
  540. * @param {?} fn
  541. * @return {?}
  542. */
  543. onPopState(fn) {
  544. this._platformLocation.onPopState(fn);
  545. this._platformLocation.onHashChange(fn);
  546. }
  547. /**
  548. * @return {?}
  549. */
  550. getBaseHref() { return this._baseHref; }
  551. /**
  552. * @param {?} internal
  553. * @return {?}
  554. */
  555. prepareExternalUrl(internal) {
  556. return Location.joinWithSlash(this._baseHref, internal);
  557. }
  558. /**
  559. * @param {?=} includeHash
  560. * @return {?}
  561. */
  562. path(includeHash = false) {
  563. /** @type {?} */
  564. const pathname = this._platformLocation.pathname +
  565. Location.normalizeQueryParams(this._platformLocation.search);
  566. /** @type {?} */
  567. const hash = this._platformLocation.hash;
  568. return hash && includeHash ? `${pathname}${hash}` : pathname;
  569. }
  570. /**
  571. * @param {?} state
  572. * @param {?} title
  573. * @param {?} url
  574. * @param {?} queryParams
  575. * @return {?}
  576. */
  577. pushState(state, title, url, queryParams) {
  578. /** @type {?} */
  579. const externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
  580. this._platformLocation.pushState(state, title, externalUrl);
  581. }
  582. /**
  583. * @param {?} state
  584. * @param {?} title
  585. * @param {?} url
  586. * @param {?} queryParams
  587. * @return {?}
  588. */
  589. replaceState(state, title, url, queryParams) {
  590. /** @type {?} */
  591. const externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
  592. this._platformLocation.replaceState(state, title, externalUrl);
  593. }
  594. /**
  595. * @return {?}
  596. */
  597. forward() { this._platformLocation.forward(); }
  598. /**
  599. * @return {?}
  600. */
  601. back() { this._platformLocation.back(); }
  602. }
  603. PathLocationStrategy.decorators = [
  604. { type: Injectable }
  605. ];
  606. /** @nocollapse */
  607. PathLocationStrategy.ctorParameters = () => [
  608. { type: PlatformLocation },
  609. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] }] }
  610. ];
  611. /**
  612. * @fileoverview added by tsickle
  613. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  614. */
  615. /**
  616. * @fileoverview added by tsickle
  617. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  618. */
  619. /**
  620. * @license
  621. * Copyright Google Inc. All Rights Reserved.
  622. *
  623. * Use of this source code is governed by an MIT-style license that can be
  624. * found in the LICENSE file at https://angular.io/license
  625. */
  626. // THIS CODE IS GENERATED - DO NOT MODIFY
  627. // See angular/tools/gulp-tasks/cldr/extract.js
  628. /**
  629. * \@internal
  630. * @type {?}
  631. */
  632. const CURRENCIES_EN = {
  633. 'ADP': [undefined, undefined, 0],
  634. 'AFN': [undefined, undefined, 0],
  635. 'ALL': [undefined, undefined, 0],
  636. 'AMD': [undefined, undefined, 0],
  637. 'AOA': [undefined, 'Kz'],
  638. 'ARS': [undefined, '$'],
  639. 'AUD': ['A$', '$'],
  640. 'BAM': [undefined, 'KM'],
  641. 'BBD': [undefined, '$'],
  642. 'BDT': [undefined, '৳'],
  643. 'BHD': [undefined, undefined, 3],
  644. 'BIF': [undefined, undefined, 0],
  645. 'BMD': [undefined, '$'],
  646. 'BND': [undefined, '$'],
  647. 'BOB': [undefined, 'Bs'],
  648. 'BRL': ['R$'],
  649. 'BSD': [undefined, '$'],
  650. 'BWP': [undefined, 'P'],
  651. 'BYN': [undefined, 'р.', 2],
  652. 'BYR': [undefined, undefined, 0],
  653. 'BZD': [undefined, '$'],
  654. 'CAD': ['CA$', '$', 2],
  655. 'CHF': [undefined, undefined, 2],
  656. 'CLF': [undefined, undefined, 4],
  657. 'CLP': [undefined, '$', 0],
  658. 'CNY': ['CN¥', '¥'],
  659. 'COP': [undefined, '$', 0],
  660. 'CRC': [undefined, '₡', 2],
  661. 'CUC': [undefined, '$'],
  662. 'CUP': [undefined, '$'],
  663. 'CZK': [undefined, 'Kč', 2],
  664. 'DJF': [undefined, undefined, 0],
  665. 'DKK': [undefined, 'kr', 2],
  666. 'DOP': [undefined, '$'],
  667. 'EGP': [undefined, 'E£'],
  668. 'ESP': [undefined, '₧', 0],
  669. 'EUR': ['€'],
  670. 'FJD': [undefined, '$'],
  671. 'FKP': [undefined, '£'],
  672. 'GBP': ['£'],
  673. 'GEL': [undefined, '₾'],
  674. 'GIP': [undefined, '£'],
  675. 'GNF': [undefined, 'FG', 0],
  676. 'GTQ': [undefined, 'Q'],
  677. 'GYD': [undefined, '$', 0],
  678. 'HKD': ['HK$', '$'],
  679. 'HNL': [undefined, 'L'],
  680. 'HRK': [undefined, 'kn'],
  681. 'HUF': [undefined, 'Ft', 2],
  682. 'IDR': [undefined, 'Rp', 0],
  683. 'ILS': ['₪'],
  684. 'INR': ['₹'],
  685. 'IQD': [undefined, undefined, 0],
  686. 'IRR': [undefined, undefined, 0],
  687. 'ISK': [undefined, 'kr', 0],
  688. 'ITL': [undefined, undefined, 0],
  689. 'JMD': [undefined, '$'],
  690. 'JOD': [undefined, undefined, 3],
  691. 'JPY': ['¥', undefined, 0],
  692. 'KHR': [undefined, '៛'],
  693. 'KMF': [undefined, 'CF', 0],
  694. 'KPW': [undefined, '₩', 0],
  695. 'KRW': ['₩', undefined, 0],
  696. 'KWD': [undefined, undefined, 3],
  697. 'KYD': [undefined, '$'],
  698. 'KZT': [undefined, '₸'],
  699. 'LAK': [undefined, '₭', 0],
  700. 'LBP': [undefined, 'L£', 0],
  701. 'LKR': [undefined, 'Rs'],
  702. 'LRD': [undefined, '$'],
  703. 'LTL': [undefined, 'Lt'],
  704. 'LUF': [undefined, undefined, 0],
  705. 'LVL': [undefined, 'Ls'],
  706. 'LYD': [undefined, undefined, 3],
  707. 'MGA': [undefined, 'Ar', 0],
  708. 'MGF': [undefined, undefined, 0],
  709. 'MMK': [undefined, 'K', 0],
  710. 'MNT': [undefined, '₮', 0],
  711. 'MRO': [undefined, undefined, 0],
  712. 'MUR': [undefined, 'Rs', 0],
  713. 'MXN': ['MX$', '$'],
  714. 'MYR': [undefined, 'RM'],
  715. 'NAD': [undefined, '$'],
  716. 'NGN': [undefined, '₦'],
  717. 'NIO': [undefined, 'C$'],
  718. 'NOK': [undefined, 'kr', 2],
  719. 'NPR': [undefined, 'Rs'],
  720. 'NZD': ['NZ$', '$'],
  721. 'OMR': [undefined, undefined, 3],
  722. 'PHP': [undefined, '₱'],
  723. 'PKR': [undefined, 'Rs', 0],
  724. 'PLN': [undefined, 'zł'],
  725. 'PYG': [undefined, '₲', 0],
  726. 'RON': [undefined, 'lei'],
  727. 'RSD': [undefined, undefined, 0],
  728. 'RUB': [undefined, '₽'],
  729. 'RUR': [undefined, 'р.'],
  730. 'RWF': [undefined, 'RF', 0],
  731. 'SBD': [undefined, '$'],
  732. 'SEK': [undefined, 'kr', 2],
  733. 'SGD': [undefined, '$'],
  734. 'SHP': [undefined, '£'],
  735. 'SLL': [undefined, undefined, 0],
  736. 'SOS': [undefined, undefined, 0],
  737. 'SRD': [undefined, '$'],
  738. 'SSP': [undefined, '£'],
  739. 'STD': [undefined, undefined, 0],
  740. 'STN': [undefined, 'Db'],
  741. 'SYP': [undefined, '£', 0],
  742. 'THB': [undefined, '฿'],
  743. 'TMM': [undefined, undefined, 0],
  744. 'TND': [undefined, undefined, 3],
  745. 'TOP': [undefined, 'T$'],
  746. 'TRL': [undefined, undefined, 0],
  747. 'TRY': [undefined, '₺'],
  748. 'TTD': [undefined, '$'],
  749. 'TWD': ['NT$', '$', 2],
  750. 'TZS': [undefined, undefined, 0],
  751. 'UAH': [undefined, '₴'],
  752. 'UGX': [undefined, undefined, 0],
  753. 'USD': ['$'],
  754. 'UYI': [undefined, undefined, 0],
  755. 'UYU': [undefined, '$'],
  756. 'UZS': [undefined, undefined, 0],
  757. 'VEF': [undefined, 'Bs'],
  758. 'VND': ['₫', undefined, 0],
  759. 'VUV': [undefined, undefined, 0],
  760. 'XAF': ['FCFA', undefined, 0],
  761. 'XCD': ['EC$', '$'],
  762. 'XOF': ['CFA', undefined, 0],
  763. 'XPF': ['CFPF', undefined, 0],
  764. 'YER': [undefined, undefined, 0],
  765. 'ZAR': [undefined, 'R'],
  766. 'ZMK': [undefined, undefined, 0],
  767. 'ZMW': [undefined, 'ZK'],
  768. 'ZWD': [undefined, undefined, 0]
  769. };
  770. /**
  771. * @fileoverview added by tsickle
  772. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  773. */
  774. /** @enum {number} */
  775. const NumberFormatStyle = {
  776. Decimal: 0,
  777. Percent: 1,
  778. Currency: 2,
  779. Scientific: 3,
  780. };
  781. NumberFormatStyle[NumberFormatStyle.Decimal] = 'Decimal';
  782. NumberFormatStyle[NumberFormatStyle.Percent] = 'Percent';
  783. NumberFormatStyle[NumberFormatStyle.Currency] = 'Currency';
  784. NumberFormatStyle[NumberFormatStyle.Scientific] = 'Scientific';
  785. /** @enum {number} */
  786. const Plural = {
  787. Zero: 0,
  788. One: 1,
  789. Two: 2,
  790. Few: 3,
  791. Many: 4,
  792. Other: 5,
  793. };
  794. Plural[Plural.Zero] = 'Zero';
  795. Plural[Plural.One] = 'One';
  796. Plural[Plural.Two] = 'Two';
  797. Plural[Plural.Few] = 'Few';
  798. Plural[Plural.Many] = 'Many';
  799. Plural[Plural.Other] = 'Other';
  800. /** @enum {number} */
  801. const FormStyle = {
  802. Format: 0,
  803. Standalone: 1,
  804. };
  805. FormStyle[FormStyle.Format] = 'Format';
  806. FormStyle[FormStyle.Standalone] = 'Standalone';
  807. /** @enum {number} */
  808. const TranslationWidth = {
  809. /** 1 character for `en-US`. For example: 'S' */
  810. Narrow: 0,
  811. /** 3 characters for `en-US`. For example: 'Sun' */
  812. Abbreviated: 1,
  813. /** Full length for `en-US`. For example: "Sunday" */
  814. Wide: 2,
  815. /** 2 characters for `en-US`, For example: "Su" */
  816. Short: 3,
  817. };
  818. TranslationWidth[TranslationWidth.Narrow] = 'Narrow';
  819. TranslationWidth[TranslationWidth.Abbreviated] = 'Abbreviated';
  820. TranslationWidth[TranslationWidth.Wide] = 'Wide';
  821. TranslationWidth[TranslationWidth.Short] = 'Short';
  822. /** @enum {number} */
  823. const FormatWidth = {
  824. /**
  825. * For `en-US`, 'M/d/yy, h:mm a'`
  826. * (Example: `6/15/15, 9:03 AM`)
  827. */
  828. Short: 0,
  829. /**
  830. * For `en-US`, `'MMM d, y, h:mm:ss a'`
  831. * (Example: `Jun 15, 2015, 9:03:01 AM`)
  832. */
  833. Medium: 1,
  834. /**
  835. * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
  836. * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
  837. */
  838. Long: 2,
  839. /**
  840. * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
  841. * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
  842. */
  843. Full: 3,
  844. };
  845. FormatWidth[FormatWidth.Short] = 'Short';
  846. FormatWidth[FormatWidth.Medium] = 'Medium';
  847. FormatWidth[FormatWidth.Long] = 'Long';
  848. FormatWidth[FormatWidth.Full] = 'Full';
  849. /** @enum {number} */
  850. const NumberSymbol = {
  851. /**
  852. * Decimal separator.
  853. * For `en-US`, the dot character.
  854. * Example : 2,345`.`67
  855. */
  856. Decimal: 0,
  857. /**
  858. * Grouping separator, typically for thousands.
  859. * For `en-US`, the comma character.
  860. * Example: 2`,`345.67
  861. */
  862. Group: 1,
  863. /**
  864. * List-item separator.
  865. * Example: "one, two, and three"
  866. */
  867. List: 2,
  868. /**
  869. * Sign for percentage (out of 100).
  870. * Example: 23.4%
  871. */
  872. PercentSign: 3,
  873. /**
  874. * Sign for positive numbers.
  875. * Example: +23
  876. */
  877. PlusSign: 4,
  878. /**
  879. * Sign for negative numbers.
  880. * Example: -23
  881. */
  882. MinusSign: 5,
  883. /**
  884. * Computer notation for exponential value (n times a power of 10).
  885. * Example: 1.2E3
  886. */
  887. Exponential: 6,
  888. /**
  889. * Human-readable format of exponential.
  890. * Example: 1.2x103
  891. */
  892. SuperscriptingExponent: 7,
  893. /**
  894. * Sign for permille (out of 1000).
  895. * Example: 23.4‰
  896. */
  897. PerMille: 8,
  898. /**
  899. * Infinity, can be used with plus and minus.
  900. * Example: ∞, +∞, -∞
  901. */
  902. Infinity: 9,
  903. /**
  904. * Not a number.
  905. * Example: NaN
  906. */
  907. NaN: 10,
  908. /**
  909. * Symbol used between time units.
  910. * Example: 10:52
  911. */
  912. TimeSeparator: 11,
  913. /**
  914. * Decimal separator for currency values (fallback to `Decimal`).
  915. * Example: $2,345.67
  916. */
  917. CurrencyDecimal: 12,
  918. /**
  919. * Group separator for currency values (fallback to `Group`).
  920. * Example: $2,345.67
  921. */
  922. CurrencyGroup: 13,
  923. };
  924. NumberSymbol[NumberSymbol.Decimal] = 'Decimal';
  925. NumberSymbol[NumberSymbol.Group] = 'Group';
  926. NumberSymbol[NumberSymbol.List] = 'List';
  927. NumberSymbol[NumberSymbol.PercentSign] = 'PercentSign';
  928. NumberSymbol[NumberSymbol.PlusSign] = 'PlusSign';
  929. NumberSymbol[NumberSymbol.MinusSign] = 'MinusSign';
  930. NumberSymbol[NumberSymbol.Exponential] = 'Exponential';
  931. NumberSymbol[NumberSymbol.SuperscriptingExponent] = 'SuperscriptingExponent';
  932. NumberSymbol[NumberSymbol.PerMille] = 'PerMille';
  933. NumberSymbol[NumberSymbol.Infinity] = 'Infinity';
  934. NumberSymbol[NumberSymbol.NaN] = 'NaN';
  935. NumberSymbol[NumberSymbol.TimeSeparator] = 'TimeSeparator';
  936. NumberSymbol[NumberSymbol.CurrencyDecimal] = 'CurrencyDecimal';
  937. NumberSymbol[NumberSymbol.CurrencyGroup] = 'CurrencyGroup';
  938. /** @enum {number} */
  939. const WeekDay = {
  940. Sunday: 0,
  941. Monday: 1,
  942. Tuesday: 2,
  943. Wednesday: 3,
  944. Thursday: 4,
  945. Friday: 5,
  946. Saturday: 6,
  947. };
  948. WeekDay[WeekDay.Sunday] = 'Sunday';
  949. WeekDay[WeekDay.Monday] = 'Monday';
  950. WeekDay[WeekDay.Tuesday] = 'Tuesday';
  951. WeekDay[WeekDay.Wednesday] = 'Wednesday';
  952. WeekDay[WeekDay.Thursday] = 'Thursday';
  953. WeekDay[WeekDay.Friday] = 'Friday';
  954. WeekDay[WeekDay.Saturday] = 'Saturday';
  955. /**
  956. * Retrieves the locale ID from the currently loaded locale.
  957. * The loaded locale could be, for example, a global one rather than a regional one.
  958. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  959. *
  960. * \@publicApi
  961. * @param {?} locale A locale code, such as `fr-FR`.
  962. * @return {?} The locale code. For example, `fr`.
  963. */
  964. function getLocaleId(locale) {
  965. return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId];
  966. }
  967. /**
  968. * Retrieves day period strings for the given locale.
  969. *
  970. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  971. *
  972. * \@publicApi
  973. * @param {?} locale A locale code for the locale format rules to use.
  974. * @param {?} formStyle The required grammatical form.
  975. * @param {?} width The required character width.
  976. * @return {?} An array of localized period strings. For example, `[AM, PM]` for `en-US`.
  977. */
  978. function getLocaleDayPeriods(locale, formStyle, width) {
  979. /** @type {?} */
  980. const data = ɵfindLocaleData(locale);
  981. /** @type {?} */
  982. const amPmData = (/** @type {?} */ ([data[ɵLocaleDataIndex.DayPeriodsFormat], data[ɵLocaleDataIndex.DayPeriodsStandalone]]));
  983. /** @type {?} */
  984. const amPm = getLastDefinedValue(amPmData, formStyle);
  985. return getLastDefinedValue(amPm, width);
  986. }
  987. /**
  988. * Retrieves days of the week for the given locale, using the Gregorian calendar.
  989. *
  990. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  991. *
  992. * \@publicApi
  993. * @param {?} locale A locale code for the locale format rules to use.
  994. * @param {?} formStyle The required grammatical form.
  995. * @param {?} width The required character width.
  996. * @return {?} An array of localized name strings.
  997. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
  998. */
  999. function getLocaleDayNames(locale, formStyle, width) {
  1000. /** @type {?} */
  1001. const data = ɵfindLocaleData(locale);
  1002. /** @type {?} */
  1003. const daysData = (/** @type {?} */ ([data[ɵLocaleDataIndex.DaysFormat], data[ɵLocaleDataIndex.DaysStandalone]]));
  1004. /** @type {?} */
  1005. const days = getLastDefinedValue(daysData, formStyle);
  1006. return getLastDefinedValue(days, width);
  1007. }
  1008. /**
  1009. * Retrieves months of the year for the given locale, using the Gregorian calendar.
  1010. *
  1011. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1012. *
  1013. * \@publicApi
  1014. * @param {?} locale A locale code for the locale format rules to use.
  1015. * @param {?} formStyle The required grammatical form.
  1016. * @param {?} width The required character width.
  1017. * @return {?} An array of localized name strings.
  1018. * For example, `[January, February, ...]` for `en-US`.
  1019. */
  1020. function getLocaleMonthNames(locale, formStyle, width) {
  1021. /** @type {?} */
  1022. const data = ɵfindLocaleData(locale);
  1023. /** @type {?} */
  1024. const monthsData = (/** @type {?} */ ([data[ɵLocaleDataIndex.MonthsFormat], data[ɵLocaleDataIndex.MonthsStandalone]]));
  1025. /** @type {?} */
  1026. const months = getLastDefinedValue(monthsData, formStyle);
  1027. return getLastDefinedValue(months, width);
  1028. }
  1029. /**
  1030. * Retrieves Gregorian-calendar eras for the given locale.
  1031. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1032. *
  1033. * \@publicApi
  1034. * @param {?} locale A locale code for the locale format rules to use.
  1035. * @param {?} width The required character width.
  1036. * @return {?} An array of localized era strings.
  1037. * For example, `[AD, BC]` for `en-US`.
  1038. */
  1039. function getLocaleEraNames(locale, width) {
  1040. /** @type {?} */
  1041. const data = ɵfindLocaleData(locale);
  1042. /** @type {?} */
  1043. const erasData = (/** @type {?} */ (data[ɵLocaleDataIndex.Eras]));
  1044. return getLastDefinedValue(erasData, width);
  1045. }
  1046. /**
  1047. * Retrieves the first day of the week for the given locale.
  1048. *
  1049. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1050. *
  1051. * \@publicApi
  1052. * @param {?} locale A locale code for the locale format rules to use.
  1053. * @return {?} A day index number, using the 0-based week-day index for `en-US`
  1054. * (Sunday = 0, Monday = 1, ...).
  1055. * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
  1056. */
  1057. function getLocaleFirstDayOfWeek(locale) {
  1058. /** @type {?} */
  1059. const data = ɵfindLocaleData(locale);
  1060. return data[ɵLocaleDataIndex.FirstDayOfWeek];
  1061. }
  1062. /**
  1063. * Range of week days that are considered the week-end for the given locale.
  1064. *
  1065. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1066. *
  1067. * \@publicApi
  1068. * @param {?} locale A locale code for the locale format rules to use.
  1069. * @return {?} The range of day values, `[startDay, endDay]`.
  1070. */
  1071. function getLocaleWeekEndRange(locale) {
  1072. /** @type {?} */
  1073. const data = ɵfindLocaleData(locale);
  1074. return data[ɵLocaleDataIndex.WeekendRange];
  1075. }
  1076. /**
  1077. * Retrieves a localized date-value formating string.
  1078. *
  1079. * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1080. *
  1081. * \@publicApi
  1082. * @param {?} locale A locale code for the locale format rules to use.
  1083. * @param {?} width The format type.
  1084. * @return {?} The localized formating string.
  1085. */
  1086. function getLocaleDateFormat(locale, width) {
  1087. /** @type {?} */
  1088. const data = ɵfindLocaleData(locale);
  1089. return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width);
  1090. }
  1091. /**
  1092. * Retrieves a localized time-value formatting string.
  1093. *
  1094. * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1095. * \@publicApi
  1096. * @param {?} locale A locale code for the locale format rules to use.
  1097. * @param {?} width The format type.
  1098. * @return {?} The localized formatting string.
  1099. */
  1100. function getLocaleTimeFormat(locale, width) {
  1101. /** @type {?} */
  1102. const data = ɵfindLocaleData(locale);
  1103. return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width);
  1104. }
  1105. /**
  1106. * Retrieves a localized date-time formatting string.
  1107. *
  1108. * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1109. *
  1110. * \@publicApi
  1111. * @param {?} locale A locale code for the locale format rules to use.
  1112. * @param {?} width The format type.
  1113. * @return {?} The localized formatting string.
  1114. */
  1115. function getLocaleDateTimeFormat(locale, width) {
  1116. /** @type {?} */
  1117. const data = ɵfindLocaleData(locale);
  1118. /** @type {?} */
  1119. const dateTimeFormatData = (/** @type {?} */ (data[ɵLocaleDataIndex.DateTimeFormat]));
  1120. return getLastDefinedValue(dateTimeFormatData, width);
  1121. }
  1122. /**
  1123. * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
  1124. * @see `NumberSymbol` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1125. *
  1126. * \@publicApi
  1127. * @param {?} locale The locale code.
  1128. * @param {?} symbol The symbol to localize.
  1129. * @return {?} The character for the localized symbol.
  1130. */
  1131. function getLocaleNumberSymbol(locale, symbol) {
  1132. /** @type {?} */
  1133. const data = ɵfindLocaleData(locale);
  1134. /** @type {?} */
  1135. const res = data[ɵLocaleDataIndex.NumberSymbols][symbol];
  1136. if (typeof res === 'undefined') {
  1137. if (symbol === NumberSymbol.CurrencyDecimal) {
  1138. return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
  1139. }
  1140. else if (symbol === NumberSymbol.CurrencyGroup) {
  1141. return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group];
  1142. }
  1143. }
  1144. return res;
  1145. }
  1146. /**
  1147. * Retrieves a number format for a given locale.
  1148. *
  1149. * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
  1150. * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
  1151. * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
  1152. *
  1153. * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
  1154. * that stand for the decimal separator, and so on, and are NOT real characters.
  1155. * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
  1156. * your language the decimal point is written with a comma. The symbols should be replaced by the
  1157. * local equivalents, using the appropriate `NumberSymbol` for your language.
  1158. *
  1159. * Here are the special characters used in number patterns:
  1160. *
  1161. * | Symbol | Meaning |
  1162. * |--------|---------|
  1163. * | . | Replaced automatically by the character used for the decimal point. |
  1164. * | , | Replaced by the "grouping" (thousands) separator. |
  1165. * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
  1166. * | # | Replaced by a digit (or nothing if there aren't enough). |
  1167. * | ¤ | Replaced by a currency symbol, such as $ or USD. |
  1168. * | % | Marks a percent format. The % symbol may change position, but must be retained. |
  1169. * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
  1170. * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
  1171. *
  1172. * @see `NumberFormatStyle` / [CLDR website](http://cldr.unicode.org/translation/number-patterns) / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1173. *
  1174. * \@publicApi
  1175. * @param {?} locale A locale code for the locale format rules to use.
  1176. * @param {?} type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
  1177. * @return {?} The localized format string.
  1178. */
  1179. function getLocaleNumberFormat(locale, type) {
  1180. /** @type {?} */
  1181. const data = ɵfindLocaleData(locale);
  1182. return data[ɵLocaleDataIndex.NumberFormats][type];
  1183. }
  1184. /**
  1185. * Retrieves the symbol used to represent the currency for the main country
  1186. * corresponding to a given locale. For example, '$' for `en-US`.
  1187. *
  1188. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1189. *
  1190. * \@publicApi
  1191. * @param {?} locale A locale code for the locale format rules to use.
  1192. * @return {?} The localized symbol character,
  1193. * or `null` if the main country cannot be determined.
  1194. */
  1195. function getLocaleCurrencySymbol(locale) {
  1196. /** @type {?} */
  1197. const data = ɵfindLocaleData(locale);
  1198. return data[ɵLocaleDataIndex.CurrencySymbol] || null;
  1199. }
  1200. /**
  1201. * Retrieves the name of the currency for the main country corresponding
  1202. * to a given locale. For example, 'US Dollar' for `en-US`.
  1203. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1204. *
  1205. * \@publicApi
  1206. * @param {?} locale A locale code for the locale format rules to use.
  1207. * @return {?} The currency name,
  1208. * or `null` if the main country cannot be determined.
  1209. */
  1210. function getLocaleCurrencyName(locale) {
  1211. /** @type {?} */
  1212. const data = ɵfindLocaleData(locale);
  1213. return data[ɵLocaleDataIndex.CurrencyName] || null;
  1214. }
  1215. /**
  1216. * Retrieves the currency values for a given locale.
  1217. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1218. * @param {?} locale A locale code for the locale format rules to use.
  1219. * @return {?} The currency values.
  1220. */
  1221. function getLocaleCurrencies(locale) {
  1222. /** @type {?} */
  1223. const data = ɵfindLocaleData(locale);
  1224. return data[ɵLocaleDataIndex.Currencies];
  1225. }
  1226. /**
  1227. * \@alias core/ɵgetLocalePluralCase
  1228. * \@publicApi
  1229. * @type {?}
  1230. */
  1231. const getLocalePluralCase = ɵgetLocalePluralCase;
  1232. /**
  1233. * @param {?} data
  1234. * @return {?}
  1235. */
  1236. function checkFullData(data) {
  1237. if (!data[ɵLocaleDataIndex.ExtraData]) {
  1238. throw new Error(`Missing extra locale data for the locale "${data[ɵLocaleDataIndex.LocaleId]}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`);
  1239. }
  1240. }
  1241. /**
  1242. * Retrieves locale-specific rules used to determine which day period to use
  1243. * when more than one period is defined for a locale.
  1244. *
  1245. * There is a rule for each defined day period. The
  1246. * first rule is applied to the first day period and so on.
  1247. * Fall back to AM/PM when no rules are available.
  1248. *
  1249. * A rule can specify a period as time range, or as a single time value.
  1250. *
  1251. * This functionality is only available when you have loaded the full locale data.
  1252. * See the ["I18n guide"](guide/i18n#i18n-pipes).
  1253. *
  1254. * @see `getLocaleExtraDayPeriods()` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1255. *
  1256. * \@publicApi
  1257. * @param {?} locale A locale code for the locale format rules to use.
  1258. * @return {?} The rules for the locale, a single time value or array of *from-time, to-time*,
  1259. * or null if no periods are available.
  1260. *
  1261. */
  1262. function getLocaleExtraDayPeriodRules(locale) {
  1263. /** @type {?} */
  1264. const data = ɵfindLocaleData(locale);
  1265. checkFullData(data);
  1266. /** @type {?} */
  1267. const rules = data[ɵLocaleDataIndex.ExtraData][2 /* ExtraDayPeriodsRules */] || [];
  1268. return rules.map((/**
  1269. * @param {?} rule
  1270. * @return {?}
  1271. */
  1272. (rule) => {
  1273. if (typeof rule === 'string') {
  1274. return extractTime(rule);
  1275. }
  1276. return [extractTime(rule[0]), extractTime(rule[1])];
  1277. }));
  1278. }
  1279. /**
  1280. * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
  1281. * in different languages.
  1282. * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
  1283. *
  1284. * This functionality is only available when you have loaded the full locale data.
  1285. * See the ["I18n guide"](guide/i18n#i18n-pipes).
  1286. *
  1287. * @see `getLocaleExtraDayPeriodRules()` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1288. *
  1289. * \@publicApi
  1290. * @param {?} locale A locale code for the locale format rules to use.
  1291. * @param {?} formStyle The required grammatical form.
  1292. * @param {?} width The required character width.
  1293. * @return {?} The translated day-period strings.
  1294. */
  1295. function getLocaleExtraDayPeriods(locale, formStyle, width) {
  1296. /** @type {?} */
  1297. const data = ɵfindLocaleData(locale);
  1298. checkFullData(data);
  1299. /** @type {?} */
  1300. const dayPeriodsData = (/** @type {?} */ ([
  1301. data[ɵLocaleDataIndex.ExtraData][0 /* ExtraDayPeriodFormats */],
  1302. data[ɵLocaleDataIndex.ExtraData][1 /* ExtraDayPeriodStandalone */]
  1303. ]));
  1304. /** @type {?} */
  1305. const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
  1306. return getLastDefinedValue(dayPeriods, width) || [];
  1307. }
  1308. /**
  1309. * Retrieves the first value that is defined in an array, going backwards from an index position.
  1310. *
  1311. * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
  1312. * add the first value to the locale data arrays, and add other values only if they are different.
  1313. *
  1314. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1315. *
  1316. * \@publicApi
  1317. * @template T
  1318. * @param {?} data The data array to retrieve from.
  1319. * @param {?} index A 0-based index into the array to start from.
  1320. * @return {?} The value immediately before the given index position.
  1321. */
  1322. function getLastDefinedValue(data, index) {
  1323. for (let i = index; i > -1; i--) {
  1324. if (typeof data[i] !== 'undefined') {
  1325. return data[i];
  1326. }
  1327. }
  1328. throw new Error('Locale data API: locale data undefined');
  1329. }
  1330. /**
  1331. * Extracts the hours and minutes from a string like "15:45"
  1332. * @param {?} time
  1333. * @return {?}
  1334. */
  1335. function extractTime(time) {
  1336. const [h, m] = time.split(':');
  1337. return { hours: +h, minutes: +m };
  1338. }
  1339. /**
  1340. * Retrieves the currency symbol for a given currency code.
  1341. *
  1342. * For example, for the default `en-US` locale, the code `USD` can
  1343. * be represented by the narrow symbol `$` or the wide symbol `US$`.
  1344. *
  1345. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1346. *
  1347. * \@publicApi
  1348. * @param {?} code The currency code.
  1349. * @param {?} format The format, `wide` or `narrow`.
  1350. * @param {?=} locale A locale code for the locale format rules to use.
  1351. *
  1352. * @return {?} The symbol, or the currency code if no symbol is available.0
  1353. */
  1354. function getCurrencySymbol(code, format, locale = 'en') {
  1355. /** @type {?} */
  1356. const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
  1357. /** @type {?} */
  1358. const symbolNarrow = currency[1 /* SymbolNarrow */];
  1359. if (format === 'narrow' && typeof symbolNarrow === 'string') {
  1360. return symbolNarrow;
  1361. }
  1362. return currency[0 /* Symbol */] || code;
  1363. }
  1364. // Most currencies have cents, that's why the default is 2
  1365. /** @type {?} */
  1366. const DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
  1367. /**
  1368. * Reports the number of decimal digits for a given currency.
  1369. * The value depends upon the presence of cents in that particular currency.
  1370. *
  1371. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1372. *
  1373. * \@publicApi
  1374. * @param {?} code The currency code.
  1375. * @return {?} The number of decimal digits, typically 0 or 2.
  1376. */
  1377. function getNumberOfCurrencyDigits(code) {
  1378. /** @type {?} */
  1379. let digits;
  1380. /** @type {?} */
  1381. const currency = CURRENCIES_EN[code];
  1382. if (currency) {
  1383. digits = currency[2 /* NbOfDigits */];
  1384. }
  1385. return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
  1386. }
  1387. /**
  1388. * @fileoverview added by tsickle
  1389. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1390. */
  1391. /** @type {?} */
  1392. const ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
  1393. // 1 2 3 4 5 6 7 8 9 10 11
  1394. /** @type {?} */
  1395. const NAMED_FORMATS = {};
  1396. /** @type {?} */
  1397. const DATE_FORMATS_SPLIT = /((?:[^GyMLwWdEabBhHmsSzZO']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\s\S]*)/;
  1398. /** @enum {number} */
  1399. const ZoneWidth = {
  1400. Short: 0,
  1401. ShortGMT: 1,
  1402. Long: 2,
  1403. Extended: 3,
  1404. };
  1405. ZoneWidth[ZoneWidth.Short] = 'Short';
  1406. ZoneWidth[ZoneWidth.ShortGMT] = 'ShortGMT';
  1407. ZoneWidth[ZoneWidth.Long] = 'Long';
  1408. ZoneWidth[ZoneWidth.Extended] = 'Extended';
  1409. /** @enum {number} */
  1410. const DateType = {
  1411. FullYear: 0,
  1412. Month: 1,
  1413. Date: 2,
  1414. Hours: 3,
  1415. Minutes: 4,
  1416. Seconds: 5,
  1417. FractionalSeconds: 6,
  1418. Day: 7,
  1419. };
  1420. DateType[DateType.FullYear] = 'FullYear';
  1421. DateType[DateType.Month] = 'Month';
  1422. DateType[DateType.Date] = 'Date';
  1423. DateType[DateType.Hours] = 'Hours';
  1424. DateType[DateType.Minutes] = 'Minutes';
  1425. DateType[DateType.Seconds] = 'Seconds';
  1426. DateType[DateType.FractionalSeconds] = 'FractionalSeconds';
  1427. DateType[DateType.Day] = 'Day';
  1428. /** @enum {number} */
  1429. const TranslationType = {
  1430. DayPeriods: 0,
  1431. Days: 1,
  1432. Months: 2,
  1433. Eras: 3,
  1434. };
  1435. TranslationType[TranslationType.DayPeriods] = 'DayPeriods';
  1436. TranslationType[TranslationType.Days] = 'Days';
  1437. TranslationType[TranslationType.Months] = 'Months';
  1438. TranslationType[TranslationType.Eras] = 'Eras';
  1439. /**
  1440. * \@ngModule CommonModule
  1441. * \@description
  1442. *
  1443. * Formats a date according to locale rules.
  1444. *
  1445. * @see `DatePipe` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1446. *
  1447. * \@publicApi
  1448. * @param {?} value The date to format, as a Date, or a number (milliseconds since UTC epoch)
  1449. * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
  1450. * @param {?} format The date-time components to include. See `DatePipe` for details.
  1451. * @param {?} locale A locale code for the locale format rules to use.
  1452. * @param {?=} timezone The time zone. A time zone offset from GMT (such as `'+0430'`),
  1453. * or a standard UTC/GMT or continental US time zone abbreviation.
  1454. * If not specified, uses host system settings.
  1455. *
  1456. * @return {?} The formatted date string.
  1457. *
  1458. */
  1459. function formatDate(value, format, locale, timezone) {
  1460. /** @type {?} */
  1461. let date = toDate(value);
  1462. /** @type {?} */
  1463. const namedFormat = getNamedFormat(locale, format);
  1464. format = namedFormat || format;
  1465. /** @type {?} */
  1466. let parts = [];
  1467. /** @type {?} */
  1468. let match;
  1469. while (format) {
  1470. match = DATE_FORMATS_SPLIT.exec(format);
  1471. if (match) {
  1472. parts = parts.concat(match.slice(1));
  1473. /** @type {?} */
  1474. const part = parts.pop();
  1475. if (!part) {
  1476. break;
  1477. }
  1478. format = part;
  1479. }
  1480. else {
  1481. parts.push(format);
  1482. break;
  1483. }
  1484. }
  1485. /** @type {?} */
  1486. let dateTimezoneOffset = date.getTimezoneOffset();
  1487. if (timezone) {
  1488. dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  1489. date = convertTimezoneToLocal(date, timezone, true);
  1490. }
  1491. /** @type {?} */
  1492. let text = '';
  1493. parts.forEach((/**
  1494. * @param {?} value
  1495. * @return {?}
  1496. */
  1497. value => {
  1498. /** @type {?} */
  1499. const dateFormatter = getDateFormatter(value);
  1500. text += dateFormatter ?
  1501. dateFormatter(date, locale, dateTimezoneOffset) :
  1502. value === '\'\'' ? '\'' : value.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
  1503. }));
  1504. return text;
  1505. }
  1506. /**
  1507. * @param {?} locale
  1508. * @param {?} format
  1509. * @return {?}
  1510. */
  1511. function getNamedFormat(locale, format) {
  1512. /** @type {?} */
  1513. const localeId = getLocaleId(locale);
  1514. NAMED_FORMATS[localeId] = NAMED_FORMATS[localeId] || {};
  1515. if (NAMED_FORMATS[localeId][format]) {
  1516. return NAMED_FORMATS[localeId][format];
  1517. }
  1518. /** @type {?} */
  1519. let formatValue = '';
  1520. switch (format) {
  1521. case 'shortDate':
  1522. formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
  1523. break;
  1524. case 'mediumDate':
  1525. formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
  1526. break;
  1527. case 'longDate':
  1528. formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
  1529. break;
  1530. case 'fullDate':
  1531. formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
  1532. break;
  1533. case 'shortTime':
  1534. formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
  1535. break;
  1536. case 'mediumTime':
  1537. formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
  1538. break;
  1539. case 'longTime':
  1540. formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
  1541. break;
  1542. case 'fullTime':
  1543. formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
  1544. break;
  1545. case 'short':
  1546. /** @type {?} */
  1547. const shortTime = getNamedFormat(locale, 'shortTime');
  1548. /** @type {?} */
  1549. const shortDate = getNamedFormat(locale, 'shortDate');
  1550. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [shortTime, shortDate]);
  1551. break;
  1552. case 'medium':
  1553. /** @type {?} */
  1554. const mediumTime = getNamedFormat(locale, 'mediumTime');
  1555. /** @type {?} */
  1556. const mediumDate = getNamedFormat(locale, 'mediumDate');
  1557. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [mediumTime, mediumDate]);
  1558. break;
  1559. case 'long':
  1560. /** @type {?} */
  1561. const longTime = getNamedFormat(locale, 'longTime');
  1562. /** @type {?} */
  1563. const longDate = getNamedFormat(locale, 'longDate');
  1564. formatValue =
  1565. formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [longTime, longDate]);
  1566. break;
  1567. case 'full':
  1568. /** @type {?} */
  1569. const fullTime = getNamedFormat(locale, 'fullTime');
  1570. /** @type {?} */
  1571. const fullDate = getNamedFormat(locale, 'fullDate');
  1572. formatValue =
  1573. formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [fullTime, fullDate]);
  1574. break;
  1575. }
  1576. if (formatValue) {
  1577. NAMED_FORMATS[localeId][format] = formatValue;
  1578. }
  1579. return formatValue;
  1580. }
  1581. /**
  1582. * @param {?} str
  1583. * @param {?} opt_values
  1584. * @return {?}
  1585. */
  1586. function formatDateTime(str, opt_values) {
  1587. if (opt_values) {
  1588. str = str.replace(/\{([^}]+)}/g, (/**
  1589. * @param {?} match
  1590. * @param {?} key
  1591. * @return {?}
  1592. */
  1593. function (match, key) {
  1594. return (opt_values != null && key in opt_values) ? opt_values[key] : match;
  1595. }));
  1596. }
  1597. return str;
  1598. }
  1599. /**
  1600. * @param {?} num
  1601. * @param {?} digits
  1602. * @param {?=} minusSign
  1603. * @param {?=} trim
  1604. * @param {?=} negWrap
  1605. * @return {?}
  1606. */
  1607. function padNumber(num, digits, minusSign = '-', trim, negWrap) {
  1608. /** @type {?} */
  1609. let neg = '';
  1610. if (num < 0 || (negWrap && num <= 0)) {
  1611. if (negWrap) {
  1612. num = -num + 1;
  1613. }
  1614. else {
  1615. num = -num;
  1616. neg = minusSign;
  1617. }
  1618. }
  1619. /** @type {?} */
  1620. let strNum = String(num);
  1621. while (strNum.length < digits) {
  1622. strNum = '0' + strNum;
  1623. }
  1624. if (trim) {
  1625. strNum = strNum.substr(strNum.length - digits);
  1626. }
  1627. return neg + strNum;
  1628. }
  1629. /**
  1630. * @param {?} milliseconds
  1631. * @param {?} digits
  1632. * @return {?}
  1633. */
  1634. function formatFractionalSeconds(milliseconds, digits) {
  1635. /** @type {?} */
  1636. const strMs = padNumber(milliseconds, 3);
  1637. return strMs.substr(0, digits);
  1638. }
  1639. /**
  1640. * Returns a date formatter that transforms a date into its locale digit representation
  1641. * @param {?} name
  1642. * @param {?} size
  1643. * @param {?=} offset
  1644. * @param {?=} trim
  1645. * @param {?=} negWrap
  1646. * @return {?}
  1647. */
  1648. function dateGetter(name, size, offset = 0, trim = false, negWrap = false) {
  1649. return (/**
  1650. * @param {?} date
  1651. * @param {?} locale
  1652. * @return {?}
  1653. */
  1654. function (date, locale) {
  1655. /** @type {?} */
  1656. let part = getDatePart(name, date);
  1657. if (offset > 0 || part > -offset) {
  1658. part += offset;
  1659. }
  1660. if (name === DateType.Hours) {
  1661. if (part === 0 && offset === -12) {
  1662. part = 12;
  1663. }
  1664. }
  1665. else if (name === DateType.FractionalSeconds) {
  1666. return formatFractionalSeconds(part, size);
  1667. }
  1668. /** @type {?} */
  1669. const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1670. return padNumber(part, size, localeMinus, trim, negWrap);
  1671. });
  1672. }
  1673. /**
  1674. * @param {?} part
  1675. * @param {?} date
  1676. * @return {?}
  1677. */
  1678. function getDatePart(part, date) {
  1679. switch (part) {
  1680. case DateType.FullYear:
  1681. return date.getFullYear();
  1682. case DateType.Month:
  1683. return date.getMonth();
  1684. case DateType.Date:
  1685. return date.getDate();
  1686. case DateType.Hours:
  1687. return date.getHours();
  1688. case DateType.Minutes:
  1689. return date.getMinutes();
  1690. case DateType.Seconds:
  1691. return date.getSeconds();
  1692. case DateType.FractionalSeconds:
  1693. return date.getMilliseconds();
  1694. case DateType.Day:
  1695. return date.getDay();
  1696. default:
  1697. throw new Error(`Unknown DateType value "${part}".`);
  1698. }
  1699. }
  1700. /**
  1701. * Returns a date formatter that transforms a date into its locale string representation
  1702. * @param {?} name
  1703. * @param {?} width
  1704. * @param {?=} form
  1705. * @param {?=} extended
  1706. * @return {?}
  1707. */
  1708. function dateStrGetter(name, width, form = FormStyle.Format, extended = false) {
  1709. return (/**
  1710. * @param {?} date
  1711. * @param {?} locale
  1712. * @return {?}
  1713. */
  1714. function (date, locale) {
  1715. return getDateTranslation(date, locale, name, width, form, extended);
  1716. });
  1717. }
  1718. /**
  1719. * Returns the locale translation of a date for a given form, type and width
  1720. * @param {?} date
  1721. * @param {?} locale
  1722. * @param {?} name
  1723. * @param {?} width
  1724. * @param {?} form
  1725. * @param {?} extended
  1726. * @return {?}
  1727. */
  1728. function getDateTranslation(date, locale, name, width, form, extended) {
  1729. switch (name) {
  1730. case TranslationType.Months:
  1731. return getLocaleMonthNames(locale, form, width)[date.getMonth()];
  1732. case TranslationType.Days:
  1733. return getLocaleDayNames(locale, form, width)[date.getDay()];
  1734. case TranslationType.DayPeriods:
  1735. /** @type {?} */
  1736. const currentHours = date.getHours();
  1737. /** @type {?} */
  1738. const currentMinutes = date.getMinutes();
  1739. if (extended) {
  1740. /** @type {?} */
  1741. const rules = getLocaleExtraDayPeriodRules(locale);
  1742. /** @type {?} */
  1743. const dayPeriods = getLocaleExtraDayPeriods(locale, form, width);
  1744. /** @type {?} */
  1745. let result;
  1746. rules.forEach((/**
  1747. * @param {?} rule
  1748. * @param {?} index
  1749. * @return {?}
  1750. */
  1751. (rule, index) => {
  1752. if (Array.isArray(rule)) {
  1753. // morning, afternoon, evening, night
  1754. const { hours: hoursFrom, minutes: minutesFrom } = rule[0];
  1755. const { hours: hoursTo, minutes: minutesTo } = rule[1];
  1756. if (currentHours >= hoursFrom && currentMinutes >= minutesFrom &&
  1757. (currentHours < hoursTo ||
  1758. (currentHours === hoursTo && currentMinutes < minutesTo))) {
  1759. result = dayPeriods[index];
  1760. }
  1761. }
  1762. else { // noon or midnight
  1763. // noon or midnight
  1764. const { hours, minutes } = rule;
  1765. if (hours === currentHours && minutes === currentMinutes) {
  1766. result = dayPeriods[index];
  1767. }
  1768. }
  1769. }));
  1770. if (result) {
  1771. return result;
  1772. }
  1773. }
  1774. // if no rules for the day periods, we use am/pm by default
  1775. return getLocaleDayPeriods(locale, form, (/** @type {?} */ (width)))[currentHours < 12 ? 0 : 1];
  1776. case TranslationType.Eras:
  1777. return getLocaleEraNames(locale, (/** @type {?} */ (width)))[date.getFullYear() <= 0 ? 0 : 1];
  1778. default:
  1779. // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
  1780. // However Closure Compiler does not understand that and reports an error in typed mode.
  1781. // The `throw new Error` below works around the problem, and the unexpected: never variable
  1782. // makes sure tsc still checks this code is unreachable.
  1783. /** @type {?} */
  1784. const unexpected = name;
  1785. throw new Error(`unexpected translation type ${unexpected}`);
  1786. }
  1787. }
  1788. /**
  1789. * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
  1790. * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
  1791. * extended = +04:30)
  1792. * @param {?} width
  1793. * @return {?}
  1794. */
  1795. function timeZoneGetter(width) {
  1796. return (/**
  1797. * @param {?} date
  1798. * @param {?} locale
  1799. * @param {?} offset
  1800. * @return {?}
  1801. */
  1802. function (date, locale, offset) {
  1803. /** @type {?} */
  1804. const zone = -1 * offset;
  1805. /** @type {?} */
  1806. const minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1807. /** @type {?} */
  1808. const hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
  1809. switch (width) {
  1810. case ZoneWidth.Short:
  1811. return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) +
  1812. padNumber(Math.abs(zone % 60), 2, minusSign);
  1813. case ZoneWidth.ShortGMT:
  1814. return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 1, minusSign);
  1815. case ZoneWidth.Long:
  1816. return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
  1817. padNumber(Math.abs(zone % 60), 2, minusSign);
  1818. case ZoneWidth.Extended:
  1819. if (offset === 0) {
  1820. return 'Z';
  1821. }
  1822. else {
  1823. return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
  1824. padNumber(Math.abs(zone % 60), 2, minusSign);
  1825. }
  1826. default:
  1827. throw new Error(`Unknown zone width "${width}"`);
  1828. }
  1829. });
  1830. }
  1831. /** @type {?} */
  1832. const JANUARY = 0;
  1833. /** @type {?} */
  1834. const THURSDAY = 4;
  1835. /**
  1836. * @param {?} year
  1837. * @return {?}
  1838. */
  1839. function getFirstThursdayOfYear(year) {
  1840. /** @type {?} */
  1841. const firstDayOfYear = (new Date(year, JANUARY, 1)).getDay();
  1842. return new Date(year, 0, 1 + ((firstDayOfYear <= THURSDAY) ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
  1843. }
  1844. /**
  1845. * @param {?} datetime
  1846. * @return {?}
  1847. */
  1848. function getThursdayThisWeek(datetime) {
  1849. return new Date(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + (THURSDAY - datetime.getDay()));
  1850. }
  1851. /**
  1852. * @param {?} size
  1853. * @param {?=} monthBased
  1854. * @return {?}
  1855. */
  1856. function weekGetter(size, monthBased = false) {
  1857. return (/**
  1858. * @param {?} date
  1859. * @param {?} locale
  1860. * @return {?}
  1861. */
  1862. function (date, locale) {
  1863. /** @type {?} */
  1864. let result;
  1865. if (monthBased) {
  1866. /** @type {?} */
  1867. const nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
  1868. /** @type {?} */
  1869. const today = date.getDate();
  1870. result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
  1871. }
  1872. else {
  1873. /** @type {?} */
  1874. const firstThurs = getFirstThursdayOfYear(date.getFullYear());
  1875. /** @type {?} */
  1876. const thisThurs = getThursdayThisWeek(date);
  1877. /** @type {?} */
  1878. const diff = thisThurs.getTime() - firstThurs.getTime();
  1879. result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
  1880. }
  1881. return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1882. });
  1883. }
  1884. /** @type {?} */
  1885. const DATE_FORMATS = {};
  1886. // Based on CLDR formats:
  1887. // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
  1888. // See also explanations: http://cldr.unicode.org/translation/date-time
  1889. // TODO(ocombe): support all missing cldr formats: Y, U, Q, D, F, e, c, j, J, C, A, v, V, X, x
  1890. /**
  1891. * @param {?} format
  1892. * @return {?}
  1893. */
  1894. function getDateFormatter(format) {
  1895. if (DATE_FORMATS[format]) {
  1896. return DATE_FORMATS[format];
  1897. }
  1898. /** @type {?} */
  1899. let formatter;
  1900. switch (format) {
  1901. // Era name (AD/BC)
  1902. case 'G':
  1903. case 'GG':
  1904. case 'GGG':
  1905. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated);
  1906. break;
  1907. case 'GGGG':
  1908. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide);
  1909. break;
  1910. case 'GGGGG':
  1911. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow);
  1912. break;
  1913. // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
  1914. case 'y':
  1915. formatter = dateGetter(DateType.FullYear, 1, 0, false, true);
  1916. break;
  1917. // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
  1918. case 'yy':
  1919. formatter = dateGetter(DateType.FullYear, 2, 0, true, true);
  1920. break;
  1921. // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
  1922. case 'yyy':
  1923. formatter = dateGetter(DateType.FullYear, 3, 0, false, true);
  1924. break;
  1925. // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
  1926. case 'yyyy':
  1927. formatter = dateGetter(DateType.FullYear, 4, 0, false, true);
  1928. break;
  1929. // Month of the year (1-12), numeric
  1930. case 'M':
  1931. case 'L':
  1932. formatter = dateGetter(DateType.Month, 1, 1);
  1933. break;
  1934. case 'MM':
  1935. case 'LL':
  1936. formatter = dateGetter(DateType.Month, 2, 1);
  1937. break;
  1938. // Month of the year (January, ...), string, format
  1939. case 'MMM':
  1940. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated);
  1941. break;
  1942. case 'MMMM':
  1943. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide);
  1944. break;
  1945. case 'MMMMM':
  1946. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow);
  1947. break;
  1948. // Month of the year (January, ...), string, standalone
  1949. case 'LLL':
  1950. formatter =
  1951. dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone);
  1952. break;
  1953. case 'LLLL':
  1954. formatter =
  1955. dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone);
  1956. break;
  1957. case 'LLLLL':
  1958. formatter =
  1959. dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone);
  1960. break;
  1961. // Week of the year (1, ... 52)
  1962. case 'w':
  1963. formatter = weekGetter(1);
  1964. break;
  1965. case 'ww':
  1966. formatter = weekGetter(2);
  1967. break;
  1968. // Week of the month (1, ...)
  1969. case 'W':
  1970. formatter = weekGetter(1, true);
  1971. break;
  1972. // Day of the month (1-31)
  1973. case 'd':
  1974. formatter = dateGetter(DateType.Date, 1);
  1975. break;
  1976. case 'dd':
  1977. formatter = dateGetter(DateType.Date, 2);
  1978. break;
  1979. // Day of the Week
  1980. case 'E':
  1981. case 'EE':
  1982. case 'EEE':
  1983. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated);
  1984. break;
  1985. case 'EEEE':
  1986. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide);
  1987. break;
  1988. case 'EEEEE':
  1989. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow);
  1990. break;
  1991. case 'EEEEEE':
  1992. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short);
  1993. break;
  1994. // Generic period of the day (am-pm)
  1995. case 'a':
  1996. case 'aa':
  1997. case 'aaa':
  1998. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated);
  1999. break;
  2000. case 'aaaa':
  2001. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide);
  2002. break;
  2003. case 'aaaaa':
  2004. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow);
  2005. break;
  2006. // Extended period of the day (midnight, at night, ...), standalone
  2007. case 'b':
  2008. case 'bb':
  2009. case 'bbb':
  2010. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
  2011. break;
  2012. case 'bbbb':
  2013. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true);
  2014. break;
  2015. case 'bbbbb':
  2016. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true);
  2017. break;
  2018. // Extended period of the day (midnight, night, ...), standalone
  2019. case 'B':
  2020. case 'BB':
  2021. case 'BBB':
  2022. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true);
  2023. break;
  2024. case 'BBBB':
  2025. formatter =
  2026. dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true);
  2027. break;
  2028. case 'BBBBB':
  2029. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true);
  2030. break;
  2031. // Hour in AM/PM, (1-12)
  2032. case 'h':
  2033. formatter = dateGetter(DateType.Hours, 1, -12);
  2034. break;
  2035. case 'hh':
  2036. formatter = dateGetter(DateType.Hours, 2, -12);
  2037. break;
  2038. // Hour of the day (0-23)
  2039. case 'H':
  2040. formatter = dateGetter(DateType.Hours, 1);
  2041. break;
  2042. // Hour in day, padded (00-23)
  2043. case 'HH':
  2044. formatter = dateGetter(DateType.Hours, 2);
  2045. break;
  2046. // Minute of the hour (0-59)
  2047. case 'm':
  2048. formatter = dateGetter(DateType.Minutes, 1);
  2049. break;
  2050. case 'mm':
  2051. formatter = dateGetter(DateType.Minutes, 2);
  2052. break;
  2053. // Second of the minute (0-59)
  2054. case 's':
  2055. formatter = dateGetter(DateType.Seconds, 1);
  2056. break;
  2057. case 'ss':
  2058. formatter = dateGetter(DateType.Seconds, 2);
  2059. break;
  2060. // Fractional second
  2061. case 'S':
  2062. formatter = dateGetter(DateType.FractionalSeconds, 1);
  2063. break;
  2064. case 'SS':
  2065. formatter = dateGetter(DateType.FractionalSeconds, 2);
  2066. break;
  2067. case 'SSS':
  2068. formatter = dateGetter(DateType.FractionalSeconds, 3);
  2069. break;
  2070. // Timezone ISO8601 short format (-0430)
  2071. case 'Z':
  2072. case 'ZZ':
  2073. case 'ZZZ':
  2074. formatter = timeZoneGetter(ZoneWidth.Short);
  2075. break;
  2076. // Timezone ISO8601 extended format (-04:30)
  2077. case 'ZZZZZ':
  2078. formatter = timeZoneGetter(ZoneWidth.Extended);
  2079. break;
  2080. // Timezone GMT short format (GMT+4)
  2081. case 'O':
  2082. case 'OO':
  2083. case 'OOO':
  2084. // Should be location, but fallback to format O instead because we don't have the data yet
  2085. case 'z':
  2086. case 'zz':
  2087. case 'zzz':
  2088. formatter = timeZoneGetter(ZoneWidth.ShortGMT);
  2089. break;
  2090. // Timezone GMT long format (GMT+0430)
  2091. case 'OOOO':
  2092. case 'ZZZZ':
  2093. // Should be location, but fallback to format O instead because we don't have the data yet
  2094. case 'zzzz':
  2095. formatter = timeZoneGetter(ZoneWidth.Long);
  2096. break;
  2097. default:
  2098. return null;
  2099. }
  2100. DATE_FORMATS[format] = formatter;
  2101. return formatter;
  2102. }
  2103. /**
  2104. * @param {?} timezone
  2105. * @param {?} fallback
  2106. * @return {?}
  2107. */
  2108. function timezoneToOffset(timezone, fallback) {
  2109. // Support: IE 9-11 only, Edge 13-15+
  2110. // IE/Edge do not "understand" colon (`:`) in timezone
  2111. timezone = timezone.replace(/:/g, '');
  2112. /** @type {?} */
  2113. const requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
  2114. return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
  2115. }
  2116. /**
  2117. * @param {?} date
  2118. * @param {?} minutes
  2119. * @return {?}
  2120. */
  2121. function addDateMinutes(date, minutes) {
  2122. date = new Date(date.getTime());
  2123. date.setMinutes(date.getMinutes() + minutes);
  2124. return date;
  2125. }
  2126. /**
  2127. * @param {?} date
  2128. * @param {?} timezone
  2129. * @param {?} reverse
  2130. * @return {?}
  2131. */
  2132. function convertTimezoneToLocal(date, timezone, reverse) {
  2133. /** @type {?} */
  2134. const reverseValue = reverse ? -1 : 1;
  2135. /** @type {?} */
  2136. const dateTimezoneOffset = date.getTimezoneOffset();
  2137. /** @type {?} */
  2138. const timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  2139. return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
  2140. }
  2141. /**
  2142. * Converts a value to date.
  2143. *
  2144. * Supported input formats:
  2145. * - `Date`
  2146. * - number: timestamp
  2147. * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
  2148. * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
  2149. * Note: ISO strings without time return a date without timeoffset.
  2150. *
  2151. * Throws if unable to convert to a date.
  2152. * @param {?} value
  2153. * @return {?}
  2154. */
  2155. function toDate(value) {
  2156. if (isDate(value)) {
  2157. return value;
  2158. }
  2159. if (typeof value === 'number' && !isNaN(value)) {
  2160. return new Date(value);
  2161. }
  2162. if (typeof value === 'string') {
  2163. value = value.trim();
  2164. /** @type {?} */
  2165. const parsedNb = parseFloat(value);
  2166. // any string that only contains numbers, like "1234" but not like "1234hello"
  2167. if (!isNaN((/** @type {?} */ (value)) - parsedNb)) {
  2168. return new Date(parsedNb);
  2169. }
  2170. if (/^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
  2171. /* For ISO Strings without time the day, month and year must be extracted from the ISO String
  2172. before Date creation to avoid time offset and errors in the new Date.
  2173. If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
  2174. date, some browsers (e.g. IE 9) will throw an invalid Date error.
  2175. If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
  2176. is applied.
  2177. Note: ISO months are 0 for January, 1 for February, ... */
  2178. const [y, m, d] = value.split('-').map((/**
  2179. * @param {?} val
  2180. * @return {?}
  2181. */
  2182. (val) => +val));
  2183. return new Date(y, m - 1, d);
  2184. }
  2185. /** @type {?} */
  2186. let match;
  2187. if (match = value.match(ISO8601_DATE_REGEX)) {
  2188. return isoStringToDate(match);
  2189. }
  2190. }
  2191. /** @type {?} */
  2192. const date = new Date((/** @type {?} */ (value)));
  2193. if (!isDate(date)) {
  2194. throw new Error(`Unable to convert "${value}" into a date`);
  2195. }
  2196. return date;
  2197. }
  2198. /**
  2199. * Converts a date in ISO8601 to a Date.
  2200. * Used instead of `Date.parse` because of browser discrepancies.
  2201. * @param {?} match
  2202. * @return {?}
  2203. */
  2204. function isoStringToDate(match) {
  2205. /** @type {?} */
  2206. const date = new Date(0);
  2207. /** @type {?} */
  2208. let tzHour = 0;
  2209. /** @type {?} */
  2210. let tzMin = 0;
  2211. // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
  2212. /** @type {?} */
  2213. const dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
  2214. /** @type {?} */
  2215. const timeSetter = match[8] ? date.setUTCHours : date.setHours;
  2216. // if there is a timezone defined like "+01:00" or "+0100"
  2217. if (match[9]) {
  2218. tzHour = Number(match[9] + match[10]);
  2219. tzMin = Number(match[9] + match[11]);
  2220. }
  2221. dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
  2222. /** @type {?} */
  2223. const h = Number(match[4] || 0) - tzHour;
  2224. /** @type {?} */
  2225. const m = Number(match[5] || 0) - tzMin;
  2226. /** @type {?} */
  2227. const s = Number(match[6] || 0);
  2228. /** @type {?} */
  2229. const ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
  2230. timeSetter.call(date, h, m, s, ms);
  2231. return date;
  2232. }
  2233. /**
  2234. * @param {?} value
  2235. * @return {?}
  2236. */
  2237. function isDate(value) {
  2238. return value instanceof Date && !isNaN(value.valueOf());
  2239. }
  2240. /**
  2241. * @fileoverview added by tsickle
  2242. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2243. */
  2244. /** @type {?} */
  2245. const NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
  2246. /** @type {?} */
  2247. const MAX_DIGITS = 22;
  2248. /** @type {?} */
  2249. const DECIMAL_SEP = '.';
  2250. /** @type {?} */
  2251. const ZERO_CHAR = '0';
  2252. /** @type {?} */
  2253. const PATTERN_SEP = ';';
  2254. /** @type {?} */
  2255. const GROUP_SEP = ',';
  2256. /** @type {?} */
  2257. const DIGIT_CHAR = '#';
  2258. /** @type {?} */
  2259. const CURRENCY_CHAR = '¤';
  2260. /** @type {?} */
  2261. const PERCENT_CHAR = '%';
  2262. /**
  2263. * Transforms a number to a locale string based on a style and a format.
  2264. * @param {?} value
  2265. * @param {?} pattern
  2266. * @param {?} locale
  2267. * @param {?} groupSymbol
  2268. * @param {?} decimalSymbol
  2269. * @param {?=} digitsInfo
  2270. * @param {?=} isPercent
  2271. * @return {?}
  2272. */
  2273. function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent = false) {
  2274. /** @type {?} */
  2275. let formattedText = '';
  2276. /** @type {?} */
  2277. let isZero = false;
  2278. if (!isFinite(value)) {
  2279. formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
  2280. }
  2281. else {
  2282. /** @type {?} */
  2283. let parsedNumber = parseNumber(value);
  2284. if (isPercent) {
  2285. parsedNumber = toPercent(parsedNumber);
  2286. }
  2287. /** @type {?} */
  2288. let minInt = pattern.minInt;
  2289. /** @type {?} */
  2290. let minFraction = pattern.minFrac;
  2291. /** @type {?} */
  2292. let maxFraction = pattern.maxFrac;
  2293. if (digitsInfo) {
  2294. /** @type {?} */
  2295. const parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
  2296. if (parts === null) {
  2297. throw new Error(`${digitsInfo} is not a valid digit info`);
  2298. }
  2299. /** @type {?} */
  2300. const minIntPart = parts[1];
  2301. /** @type {?} */
  2302. const minFractionPart = parts[3];
  2303. /** @type {?} */
  2304. const maxFractionPart = parts[5];
  2305. if (minIntPart != null) {
  2306. minInt = parseIntAutoRadix(minIntPart);
  2307. }
  2308. if (minFractionPart != null) {
  2309. minFraction = parseIntAutoRadix(minFractionPart);
  2310. }
  2311. if (maxFractionPart != null) {
  2312. maxFraction = parseIntAutoRadix(maxFractionPart);
  2313. }
  2314. else if (minFractionPart != null && minFraction > maxFraction) {
  2315. maxFraction = minFraction;
  2316. }
  2317. }
  2318. roundNumber(parsedNumber, minFraction, maxFraction);
  2319. /** @type {?} */
  2320. let digits = parsedNumber.digits;
  2321. /** @type {?} */
  2322. let integerLen = parsedNumber.integerLen;
  2323. /** @type {?} */
  2324. const exponent = parsedNumber.exponent;
  2325. /** @type {?} */
  2326. let decimals = [];
  2327. isZero = digits.every((/**
  2328. * @param {?} d
  2329. * @return {?}
  2330. */
  2331. d => !d));
  2332. // pad zeros for small numbers
  2333. for (; integerLen < minInt; integerLen++) {
  2334. digits.unshift(0);
  2335. }
  2336. // pad zeros for small numbers
  2337. for (; integerLen < 0; integerLen++) {
  2338. digits.unshift(0);
  2339. }
  2340. // extract decimals digits
  2341. if (integerLen > 0) {
  2342. decimals = digits.splice(integerLen, digits.length);
  2343. }
  2344. else {
  2345. decimals = digits;
  2346. digits = [0];
  2347. }
  2348. // format the integer digits with grouping separators
  2349. /** @type {?} */
  2350. const groups = [];
  2351. if (digits.length >= pattern.lgSize) {
  2352. groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
  2353. }
  2354. while (digits.length > pattern.gSize) {
  2355. groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
  2356. }
  2357. if (digits.length) {
  2358. groups.unshift(digits.join(''));
  2359. }
  2360. formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
  2361. // append the decimal digits
  2362. if (decimals.length) {
  2363. formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
  2364. }
  2365. if (exponent) {
  2366. formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
  2367. }
  2368. }
  2369. if (value < 0 && !isZero) {
  2370. formattedText = pattern.negPre + formattedText + pattern.negSuf;
  2371. }
  2372. else {
  2373. formattedText = pattern.posPre + formattedText + pattern.posSuf;
  2374. }
  2375. return formattedText;
  2376. }
  2377. /**
  2378. * \@ngModule CommonModule
  2379. * \@description
  2380. *
  2381. * Formats a number as currency using locale rules.
  2382. *
  2383. * @see `formatNumber()` / `DecimalPipe` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2384. *
  2385. * \@publicApi
  2386. * @param {?} value The number to format.
  2387. * @param {?} locale A locale code for the locale format rules to use.
  2388. * @param {?} currency A string containing the currency symbol or its name,
  2389. * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
  2390. * of the function.
  2391. * @param {?=} currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
  2392. * currency code to use in the result string, such as `USD` for the US dollar and `EUR` for the euro.
  2393. * @param {?=} digitsInfo
  2394. * @return {?} The formatted currency value.
  2395. *
  2396. */
  2397. function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
  2398. /** @type {?} */
  2399. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
  2400. /** @type {?} */
  2401. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2402. pattern.minFrac = getNumberOfCurrencyDigits((/** @type {?} */ (currencyCode)));
  2403. pattern.maxFrac = pattern.minFrac;
  2404. /** @type {?} */
  2405. const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
  2406. return res
  2407. .replace(CURRENCY_CHAR, currency)
  2408. // if we have 2 time the currency character, the second one is ignored
  2409. .replace(CURRENCY_CHAR, '');
  2410. }
  2411. /**
  2412. * \@ngModule CommonModule
  2413. * \@description
  2414. *
  2415. * Formats a number as a percentage according to locale rules.
  2416. *
  2417. * @see `formatNumber()` / `DecimalPipe` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2418. * \@publicApi
  2419. *
  2420. * @param {?} value The number to format.
  2421. * @param {?} locale A locale code for the locale format rules to use.
  2422. * @param {?=} digitsInfo
  2423. * @return {?} The formatted percentage value.
  2424. *
  2425. */
  2426. function formatPercent(value, locale, digitsInfo) {
  2427. /** @type {?} */
  2428. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
  2429. /** @type {?} */
  2430. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2431. /** @type {?} */
  2432. const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
  2433. return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
  2434. }
  2435. /**
  2436. * \@ngModule CommonModule
  2437. * \@description
  2438. *
  2439. * Formats a number as text, with group sizing, separator, and other
  2440. * parameters based on the locale.
  2441. *
  2442. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2443. *
  2444. * \@publicApi
  2445. * @param {?} value The number to format.
  2446. * @param {?} locale A locale code for the locale format rules to use.
  2447. * @param {?=} digitsInfo
  2448. * @return {?} The formatted text string.
  2449. */
  2450. function formatNumber(value, locale, digitsInfo) {
  2451. /** @type {?} */
  2452. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
  2453. /** @type {?} */
  2454. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2455. return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
  2456. }
  2457. /**
  2458. * @param {?} format
  2459. * @param {?=} minusSign
  2460. * @return {?}
  2461. */
  2462. function parseNumberFormat(format, minusSign = '-') {
  2463. /** @type {?} */
  2464. const p = {
  2465. minInt: 1,
  2466. minFrac: 0,
  2467. maxFrac: 0,
  2468. posPre: '',
  2469. posSuf: '',
  2470. negPre: '',
  2471. negSuf: '',
  2472. gSize: 0,
  2473. lgSize: 0
  2474. };
  2475. /** @type {?} */
  2476. const patternParts = format.split(PATTERN_SEP);
  2477. /** @type {?} */
  2478. const positive = patternParts[0];
  2479. /** @type {?} */
  2480. const negative = patternParts[1];
  2481. /** @type {?} */
  2482. const positiveParts = positive.indexOf(DECIMAL_SEP) !== -1 ?
  2483. positive.split(DECIMAL_SEP) :
  2484. [
  2485. positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
  2486. positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1)
  2487. ];
  2488. /** @type {?} */
  2489. const integer = positiveParts[0];
  2490. /** @type {?} */
  2491. const fraction = positiveParts[1] || '';
  2492. p.posPre = integer.substr(0, integer.indexOf(DIGIT_CHAR));
  2493. for (let i = 0; i < fraction.length; i++) {
  2494. /** @type {?} */
  2495. const ch = fraction.charAt(i);
  2496. if (ch === ZERO_CHAR) {
  2497. p.minFrac = p.maxFrac = i + 1;
  2498. }
  2499. else if (ch === DIGIT_CHAR) {
  2500. p.maxFrac = i + 1;
  2501. }
  2502. else {
  2503. p.posSuf += ch;
  2504. }
  2505. }
  2506. /** @type {?} */
  2507. const groups = integer.split(GROUP_SEP);
  2508. p.gSize = groups[1] ? groups[1].length : 0;
  2509. p.lgSize = (groups[2] || groups[1]) ? (groups[2] || groups[1]).length : 0;
  2510. if (negative) {
  2511. /** @type {?} */
  2512. const trunkLen = positive.length - p.posPre.length - p.posSuf.length;
  2513. /** @type {?} */
  2514. const pos = negative.indexOf(DIGIT_CHAR);
  2515. p.negPre = negative.substr(0, pos).replace(/'/g, '');
  2516. p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, '');
  2517. }
  2518. else {
  2519. p.negPre = minusSign + p.posPre;
  2520. p.negSuf = p.posSuf;
  2521. }
  2522. return p;
  2523. }
  2524. // Transforms a parsed number into a percentage by multiplying it by 100
  2525. /**
  2526. * @param {?} parsedNumber
  2527. * @return {?}
  2528. */
  2529. function toPercent(parsedNumber) {
  2530. // if the number is 0, don't do anything
  2531. if (parsedNumber.digits[0] === 0) {
  2532. return parsedNumber;
  2533. }
  2534. // Getting the current number of decimals
  2535. /** @type {?} */
  2536. const fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
  2537. if (parsedNumber.exponent) {
  2538. parsedNumber.exponent += 2;
  2539. }
  2540. else {
  2541. if (fractionLen === 0) {
  2542. parsedNumber.digits.push(0, 0);
  2543. }
  2544. else if (fractionLen === 1) {
  2545. parsedNumber.digits.push(0);
  2546. }
  2547. parsedNumber.integerLen += 2;
  2548. }
  2549. return parsedNumber;
  2550. }
  2551. /**
  2552. * Parses a number.
  2553. * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
  2554. * @param {?} num
  2555. * @return {?}
  2556. */
  2557. function parseNumber(num) {
  2558. /** @type {?} */
  2559. let numStr = Math.abs(num) + '';
  2560. /** @type {?} */
  2561. let exponent = 0;
  2562. /** @type {?} */
  2563. let digits;
  2564. /** @type {?} */
  2565. let integerLen;
  2566. /** @type {?} */
  2567. let i;
  2568. /** @type {?} */
  2569. let j;
  2570. /** @type {?} */
  2571. let zeros;
  2572. // Decimal point?
  2573. if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
  2574. numStr = numStr.replace(DECIMAL_SEP, '');
  2575. }
  2576. // Exponential form?
  2577. if ((i = numStr.search(/e/i)) > 0) {
  2578. // Work out the exponent.
  2579. if (integerLen < 0)
  2580. integerLen = i;
  2581. integerLen += +numStr.slice(i + 1);
  2582. numStr = numStr.substring(0, i);
  2583. }
  2584. else if (integerLen < 0) {
  2585. // There was no decimal point or exponent so it is an integer.
  2586. integerLen = numStr.length;
  2587. }
  2588. // Count the number of leading zeros.
  2589. for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) { /* empty */
  2590. }
  2591. if (i === (zeros = numStr.length)) {
  2592. // The digits are all zero.
  2593. digits = [0];
  2594. integerLen = 1;
  2595. }
  2596. else {
  2597. // Count the number of trailing zeros
  2598. zeros--;
  2599. while (numStr.charAt(zeros) === ZERO_CHAR)
  2600. zeros--;
  2601. // Trailing zeros are insignificant so ignore them
  2602. integerLen -= i;
  2603. digits = [];
  2604. // Convert string to array of digits without leading/trailing zeros.
  2605. for (j = 0; i <= zeros; i++, j++) {
  2606. digits[j] = Number(numStr.charAt(i));
  2607. }
  2608. }
  2609. // If the number overflows the maximum allowed digits then use an exponent.
  2610. if (integerLen > MAX_DIGITS) {
  2611. digits = digits.splice(0, MAX_DIGITS - 1);
  2612. exponent = integerLen - 1;
  2613. integerLen = 1;
  2614. }
  2615. return { digits, exponent, integerLen };
  2616. }
  2617. /**
  2618. * Round the parsed number to the specified number of decimal places
  2619. * This function changes the parsedNumber in-place
  2620. * @param {?} parsedNumber
  2621. * @param {?} minFrac
  2622. * @param {?} maxFrac
  2623. * @return {?}
  2624. */
  2625. function roundNumber(parsedNumber, minFrac, maxFrac) {
  2626. if (minFrac > maxFrac) {
  2627. throw new Error(`The minimum number of digits after fraction (${minFrac}) is higher than the maximum (${maxFrac}).`);
  2628. }
  2629. /** @type {?} */
  2630. let digits = parsedNumber.digits;
  2631. /** @type {?} */
  2632. let fractionLen = digits.length - parsedNumber.integerLen;
  2633. /** @type {?} */
  2634. const fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
  2635. // The index of the digit to where rounding is to occur
  2636. /** @type {?} */
  2637. let roundAt = fractionSize + parsedNumber.integerLen;
  2638. /** @type {?} */
  2639. let digit = digits[roundAt];
  2640. if (roundAt > 0) {
  2641. // Drop fractional digits beyond `roundAt`
  2642. digits.splice(Math.max(parsedNumber.integerLen, roundAt));
  2643. // Set non-fractional digits beyond `roundAt` to 0
  2644. for (let j = roundAt; j < digits.length; j++) {
  2645. digits[j] = 0;
  2646. }
  2647. }
  2648. else {
  2649. // We rounded to zero so reset the parsedNumber
  2650. fractionLen = Math.max(0, fractionLen);
  2651. parsedNumber.integerLen = 1;
  2652. digits.length = Math.max(1, roundAt = fractionSize + 1);
  2653. digits[0] = 0;
  2654. for (let i = 1; i < roundAt; i++)
  2655. digits[i] = 0;
  2656. }
  2657. if (digit >= 5) {
  2658. if (roundAt - 1 < 0) {
  2659. for (let k = 0; k > roundAt; k--) {
  2660. digits.unshift(0);
  2661. parsedNumber.integerLen++;
  2662. }
  2663. digits.unshift(1);
  2664. parsedNumber.integerLen++;
  2665. }
  2666. else {
  2667. digits[roundAt - 1]++;
  2668. }
  2669. }
  2670. // Pad out with zeros to get the required fraction length
  2671. for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
  2672. digits.push(0);
  2673. /** @type {?} */
  2674. let dropTrailingZeros = fractionSize !== 0;
  2675. // Minimal length = nb of decimals required + current nb of integers
  2676. // Any number besides that is optional and can be removed if it's a trailing 0
  2677. /** @type {?} */
  2678. const minLen = minFrac + parsedNumber.integerLen;
  2679. // Do any carrying, e.g. a digit was rounded up to 10
  2680. /** @type {?} */
  2681. const carry = digits.reduceRight((/**
  2682. * @param {?} carry
  2683. * @param {?} d
  2684. * @param {?} i
  2685. * @param {?} digits
  2686. * @return {?}
  2687. */
  2688. function (carry, d, i, digits) {
  2689. d = d + carry;
  2690. digits[i] = d < 10 ? d : d - 10; // d % 10
  2691. if (dropTrailingZeros) {
  2692. // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
  2693. if (digits[i] === 0 && i >= minLen) {
  2694. digits.pop();
  2695. }
  2696. else {
  2697. dropTrailingZeros = false;
  2698. }
  2699. }
  2700. return d >= 10 ? 1 : 0; // Math.floor(d / 10);
  2701. }), 0);
  2702. if (carry) {
  2703. digits.unshift(carry);
  2704. parsedNumber.integerLen++;
  2705. }
  2706. }
  2707. /**
  2708. * @param {?} text
  2709. * @return {?}
  2710. */
  2711. function parseIntAutoRadix(text) {
  2712. /** @type {?} */
  2713. const result = parseInt(text);
  2714. if (isNaN(result)) {
  2715. throw new Error('Invalid integer literal when parsing ' + text);
  2716. }
  2717. return result;
  2718. }
  2719. /**
  2720. * @fileoverview added by tsickle
  2721. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2722. */
  2723. /**
  2724. * @deprecated from v5
  2725. * @type {?}
  2726. */
  2727. const DEPRECATED_PLURAL_FN = new InjectionToken('UseV4Plurals');
  2728. /**
  2729. * \@publicApi
  2730. * @abstract
  2731. */
  2732. class NgLocalization {
  2733. }
  2734. /**
  2735. * Returns the plural category for a given value.
  2736. * - "=value" when the case exists,
  2737. * - the plural category otherwise
  2738. * @param {?} value
  2739. * @param {?} cases
  2740. * @param {?} ngLocalization
  2741. * @param {?=} locale
  2742. * @return {?}
  2743. */
  2744. function getPluralCategory(value, cases, ngLocalization, locale) {
  2745. /** @type {?} */
  2746. let key = `=${value}`;
  2747. if (cases.indexOf(key) > -1) {
  2748. return key;
  2749. }
  2750. key = ngLocalization.getPluralCategory(value, locale);
  2751. if (cases.indexOf(key) > -1) {
  2752. return key;
  2753. }
  2754. if (cases.indexOf('other') > -1) {
  2755. return 'other';
  2756. }
  2757. throw new Error(`No plural message found for value "${value}"`);
  2758. }
  2759. /**
  2760. * Returns the plural case based on the locale
  2761. *
  2762. * \@publicApi
  2763. */
  2764. class NgLocaleLocalization extends NgLocalization {
  2765. /**
  2766. * @param {?} locale
  2767. * @param {?=} deprecatedPluralFn
  2768. */
  2769. constructor(locale, deprecatedPluralFn) {
  2770. super();
  2771. this.locale = locale;
  2772. this.deprecatedPluralFn = deprecatedPluralFn;
  2773. }
  2774. /**
  2775. * @param {?} value
  2776. * @param {?=} locale
  2777. * @return {?}
  2778. */
  2779. getPluralCategory(value, locale) {
  2780. /** @type {?} */
  2781. const plural = this.deprecatedPluralFn ? this.deprecatedPluralFn(locale || this.locale, value) :
  2782. getLocalePluralCase(locale || this.locale)(value);
  2783. switch (plural) {
  2784. case Plural.Zero:
  2785. return 'zero';
  2786. case Plural.One:
  2787. return 'one';
  2788. case Plural.Two:
  2789. return 'two';
  2790. case Plural.Few:
  2791. return 'few';
  2792. case Plural.Many:
  2793. return 'many';
  2794. default:
  2795. return 'other';
  2796. }
  2797. }
  2798. }
  2799. NgLocaleLocalization.decorators = [
  2800. { type: Injectable }
  2801. ];
  2802. /** @nocollapse */
  2803. NgLocaleLocalization.ctorParameters = () => [
  2804. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] },
  2805. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DEPRECATED_PLURAL_FN,] }] }
  2806. ];
  2807. /**
  2808. * Returns the plural case based on the locale
  2809. *
  2810. * @deprecated from v5 the plural case function is in locale data files common/locales/*.ts
  2811. * \@publicApi
  2812. * @param {?} locale
  2813. * @param {?} nLike
  2814. * @return {?}
  2815. */
  2816. function getPluralCase(locale, nLike) {
  2817. // TODO(vicb): lazy compute
  2818. if (typeof nLike === 'string') {
  2819. nLike = parseInt((/** @type {?} */ (nLike)), 10);
  2820. }
  2821. /** @type {?} */
  2822. const n = (/** @type {?} */ (nLike));
  2823. /** @type {?} */
  2824. const nDecimal = n.toString().replace(/^[^.]*\.?/, '');
  2825. /** @type {?} */
  2826. const i = Math.floor(Math.abs(n));
  2827. /** @type {?} */
  2828. const v = nDecimal.length;
  2829. /** @type {?} */
  2830. const f = parseInt(nDecimal, 10);
  2831. /** @type {?} */
  2832. const t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
  2833. /** @type {?} */
  2834. const lang = locale.split('-')[0].toLowerCase();
  2835. switch (lang) {
  2836. case 'af':
  2837. case 'asa':
  2838. case 'az':
  2839. case 'bem':
  2840. case 'bez':
  2841. case 'bg':
  2842. case 'brx':
  2843. case 'ce':
  2844. case 'cgg':
  2845. case 'chr':
  2846. case 'ckb':
  2847. case 'ee':
  2848. case 'el':
  2849. case 'eo':
  2850. case 'es':
  2851. case 'eu':
  2852. case 'fo':
  2853. case 'fur':
  2854. case 'gsw':
  2855. case 'ha':
  2856. case 'haw':
  2857. case 'hu':
  2858. case 'jgo':
  2859. case 'jmc':
  2860. case 'ka':
  2861. case 'kk':
  2862. case 'kkj':
  2863. case 'kl':
  2864. case 'ks':
  2865. case 'ksb':
  2866. case 'ky':
  2867. case 'lb':
  2868. case 'lg':
  2869. case 'mas':
  2870. case 'mgo':
  2871. case 'ml':
  2872. case 'mn':
  2873. case 'nb':
  2874. case 'nd':
  2875. case 'ne':
  2876. case 'nn':
  2877. case 'nnh':
  2878. case 'nyn':
  2879. case 'om':
  2880. case 'or':
  2881. case 'os':
  2882. case 'ps':
  2883. case 'rm':
  2884. case 'rof':
  2885. case 'rwk':
  2886. case 'saq':
  2887. case 'seh':
  2888. case 'sn':
  2889. case 'so':
  2890. case 'sq':
  2891. case 'ta':
  2892. case 'te':
  2893. case 'teo':
  2894. case 'tk':
  2895. case 'tr':
  2896. case 'ug':
  2897. case 'uz':
  2898. case 'vo':
  2899. case 'vun':
  2900. case 'wae':
  2901. case 'xog':
  2902. if (n === 1)
  2903. return Plural.One;
  2904. return Plural.Other;
  2905. case 'ak':
  2906. case 'ln':
  2907. case 'mg':
  2908. case 'pa':
  2909. case 'ti':
  2910. if (n === Math.floor(n) && n >= 0 && n <= 1)
  2911. return Plural.One;
  2912. return Plural.Other;
  2913. case 'am':
  2914. case 'as':
  2915. case 'bn':
  2916. case 'fa':
  2917. case 'gu':
  2918. case 'hi':
  2919. case 'kn':
  2920. case 'mr':
  2921. case 'zu':
  2922. if (i === 0 || n === 1)
  2923. return Plural.One;
  2924. return Plural.Other;
  2925. case 'ar':
  2926. if (n === 0)
  2927. return Plural.Zero;
  2928. if (n === 1)
  2929. return Plural.One;
  2930. if (n === 2)
  2931. return Plural.Two;
  2932. if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
  2933. return Plural.Few;
  2934. if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
  2935. return Plural.Many;
  2936. return Plural.Other;
  2937. case 'ast':
  2938. case 'ca':
  2939. case 'de':
  2940. case 'en':
  2941. case 'et':
  2942. case 'fi':
  2943. case 'fy':
  2944. case 'gl':
  2945. case 'it':
  2946. case 'nl':
  2947. case 'sv':
  2948. case 'sw':
  2949. case 'ur':
  2950. case 'yi':
  2951. if (i === 1 && v === 0)
  2952. return Plural.One;
  2953. return Plural.Other;
  2954. case 'be':
  2955. if (n % 10 === 1 && !(n % 100 === 11))
  2956. return Plural.One;
  2957. if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
  2958. !(n % 100 >= 12 && n % 100 <= 14))
  2959. return Plural.Few;
  2960. if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
  2961. n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
  2962. return Plural.Many;
  2963. return Plural.Other;
  2964. case 'br':
  2965. if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
  2966. return Plural.One;
  2967. if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
  2968. return Plural.Two;
  2969. if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
  2970. !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
  2971. n % 100 >= 90 && n % 100 <= 99))
  2972. return Plural.Few;
  2973. if (!(n === 0) && n % 1e6 === 0)
  2974. return Plural.Many;
  2975. return Plural.Other;
  2976. case 'bs':
  2977. case 'hr':
  2978. case 'sr':
  2979. if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
  2980. return Plural.One;
  2981. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  2982. !(i % 100 >= 12 && i % 100 <= 14) ||
  2983. f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
  2984. !(f % 100 >= 12 && f % 100 <= 14))
  2985. return Plural.Few;
  2986. return Plural.Other;
  2987. case 'cs':
  2988. case 'sk':
  2989. if (i === 1 && v === 0)
  2990. return Plural.One;
  2991. if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
  2992. return Plural.Few;
  2993. if (!(v === 0))
  2994. return Plural.Many;
  2995. return Plural.Other;
  2996. case 'cy':
  2997. if (n === 0)
  2998. return Plural.Zero;
  2999. if (n === 1)
  3000. return Plural.One;
  3001. if (n === 2)
  3002. return Plural.Two;
  3003. if (n === 3)
  3004. return Plural.Few;
  3005. if (n === 6)
  3006. return Plural.Many;
  3007. return Plural.Other;
  3008. case 'da':
  3009. if (n === 1 || !(t === 0) && (i === 0 || i === 1))
  3010. return Plural.One;
  3011. return Plural.Other;
  3012. case 'dsb':
  3013. case 'hsb':
  3014. if (v === 0 && i % 100 === 1 || f % 100 === 1)
  3015. return Plural.One;
  3016. if (v === 0 && i % 100 === 2 || f % 100 === 2)
  3017. return Plural.Two;
  3018. if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
  3019. f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
  3020. return Plural.Few;
  3021. return Plural.Other;
  3022. case 'ff':
  3023. case 'fr':
  3024. case 'hy':
  3025. case 'kab':
  3026. if (i === 0 || i === 1)
  3027. return Plural.One;
  3028. return Plural.Other;
  3029. case 'fil':
  3030. if (v === 0 && (i === 1 || i === 2 || i === 3) ||
  3031. v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
  3032. !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
  3033. return Plural.One;
  3034. return Plural.Other;
  3035. case 'ga':
  3036. if (n === 1)
  3037. return Plural.One;
  3038. if (n === 2)
  3039. return Plural.Two;
  3040. if (n === Math.floor(n) && n >= 3 && n <= 6)
  3041. return Plural.Few;
  3042. if (n === Math.floor(n) && n >= 7 && n <= 10)
  3043. return Plural.Many;
  3044. return Plural.Other;
  3045. case 'gd':
  3046. if (n === 1 || n === 11)
  3047. return Plural.One;
  3048. if (n === 2 || n === 12)
  3049. return Plural.Two;
  3050. if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
  3051. return Plural.Few;
  3052. return Plural.Other;
  3053. case 'gv':
  3054. if (v === 0 && i % 10 === 1)
  3055. return Plural.One;
  3056. if (v === 0 && i % 10 === 2)
  3057. return Plural.Two;
  3058. if (v === 0 &&
  3059. (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
  3060. return Plural.Few;
  3061. if (!(v === 0))
  3062. return Plural.Many;
  3063. return Plural.Other;
  3064. case 'he':
  3065. if (i === 1 && v === 0)
  3066. return Plural.One;
  3067. if (i === 2 && v === 0)
  3068. return Plural.Two;
  3069. if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
  3070. return Plural.Many;
  3071. return Plural.Other;
  3072. case 'is':
  3073. if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
  3074. return Plural.One;
  3075. return Plural.Other;
  3076. case 'ksh':
  3077. if (n === 0)
  3078. return Plural.Zero;
  3079. if (n === 1)
  3080. return Plural.One;
  3081. return Plural.Other;
  3082. case 'kw':
  3083. case 'naq':
  3084. case 'se':
  3085. case 'smn':
  3086. if (n === 1)
  3087. return Plural.One;
  3088. if (n === 2)
  3089. return Plural.Two;
  3090. return Plural.Other;
  3091. case 'lag':
  3092. if (n === 0)
  3093. return Plural.Zero;
  3094. if ((i === 0 || i === 1) && !(n === 0))
  3095. return Plural.One;
  3096. return Plural.Other;
  3097. case 'lt':
  3098. if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
  3099. return Plural.One;
  3100. if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
  3101. !(n % 100 >= 11 && n % 100 <= 19))
  3102. return Plural.Few;
  3103. if (!(f === 0))
  3104. return Plural.Many;
  3105. return Plural.Other;
  3106. case 'lv':
  3107. case 'prg':
  3108. if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
  3109. v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
  3110. return Plural.Zero;
  3111. if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
  3112. !(v === 2) && f % 10 === 1)
  3113. return Plural.One;
  3114. return Plural.Other;
  3115. case 'mk':
  3116. if (v === 0 && i % 10 === 1 || f % 10 === 1)
  3117. return Plural.One;
  3118. return Plural.Other;
  3119. case 'mt':
  3120. if (n === 1)
  3121. return Plural.One;
  3122. if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
  3123. return Plural.Few;
  3124. if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
  3125. return Plural.Many;
  3126. return Plural.Other;
  3127. case 'pl':
  3128. if (i === 1 && v === 0)
  3129. return Plural.One;
  3130. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  3131. !(i % 100 >= 12 && i % 100 <= 14))
  3132. return Plural.Few;
  3133. if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
  3134. v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
  3135. v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
  3136. return Plural.Many;
  3137. return Plural.Other;
  3138. case 'pt':
  3139. if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
  3140. return Plural.One;
  3141. return Plural.Other;
  3142. case 'ro':
  3143. if (i === 1 && v === 0)
  3144. return Plural.One;
  3145. if (!(v === 0) || n === 0 ||
  3146. !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
  3147. return Plural.Few;
  3148. return Plural.Other;
  3149. case 'ru':
  3150. case 'uk':
  3151. if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
  3152. return Plural.One;
  3153. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  3154. !(i % 100 >= 12 && i % 100 <= 14))
  3155. return Plural.Few;
  3156. if (v === 0 && i % 10 === 0 ||
  3157. v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
  3158. v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
  3159. return Plural.Many;
  3160. return Plural.Other;
  3161. case 'shi':
  3162. if (i === 0 || n === 1)
  3163. return Plural.One;
  3164. if (n === Math.floor(n) && n >= 2 && n <= 10)
  3165. return Plural.Few;
  3166. return Plural.Other;
  3167. case 'si':
  3168. if (n === 0 || n === 1 || i === 0 && f === 1)
  3169. return Plural.One;
  3170. return Plural.Other;
  3171. case 'sl':
  3172. if (v === 0 && i % 100 === 1)
  3173. return Plural.One;
  3174. if (v === 0 && i % 100 === 2)
  3175. return Plural.Two;
  3176. if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
  3177. return Plural.Few;
  3178. return Plural.Other;
  3179. case 'tzm':
  3180. if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
  3181. return Plural.One;
  3182. return Plural.Other;
  3183. // When there is no specification, the default is always "other"
  3184. // Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
  3185. // > other (required—general plural form — also used if the language only has a single form)
  3186. default:
  3187. return Plural.Other;
  3188. }
  3189. }
  3190. /**
  3191. * @fileoverview added by tsickle
  3192. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3193. */
  3194. /**
  3195. * Register global data to be used internally by Angular. See the
  3196. * ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale data.
  3197. *
  3198. * \@publicApi
  3199. * @param {?} data
  3200. * @param {?=} localeId
  3201. * @param {?=} extraData
  3202. * @return {?}
  3203. */
  3204. // The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1
  3205. function registerLocaleData(data, localeId, extraData) {
  3206. if (typeof localeId !== 'string') {
  3207. extraData = localeId;
  3208. localeId = data[ɵLocaleDataIndex.LocaleId];
  3209. }
  3210. localeId = localeId.toLowerCase().replace(/_/g, '-');
  3211. ɵLOCALE_DATA[localeId] = data;
  3212. if (extraData) {
  3213. ɵLOCALE_DATA[localeId][ɵLocaleDataIndex.ExtraData] = extraData;
  3214. }
  3215. }
  3216. /**
  3217. * @fileoverview added by tsickle
  3218. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3219. */
  3220. /**
  3221. * @license
  3222. * Copyright Google Inc. All Rights Reserved.
  3223. *
  3224. * Use of this source code is governed by an MIT-style license that can be
  3225. * found in the LICENSE file at https://angular.io/license
  3226. */
  3227. /**
  3228. * @param {?} cookieStr
  3229. * @param {?} name
  3230. * @return {?}
  3231. */
  3232. function parseCookieValue(cookieStr, name) {
  3233. name = encodeURIComponent(name);
  3234. for (const cookie of cookieStr.split(';')) {
  3235. /** @type {?} */
  3236. const eqIndex = cookie.indexOf('=');
  3237. const [cookieName, cookieValue] = eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)];
  3238. if (cookieName.trim() === name) {
  3239. return decodeURIComponent(cookieValue);
  3240. }
  3241. }
  3242. return null;
  3243. }
  3244. /**
  3245. * @fileoverview added by tsickle
  3246. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3247. */
  3248. /**
  3249. * @license
  3250. * Copyright Google Inc. All Rights Reserved.
  3251. *
  3252. * Use of this source code is governed by an MIT-style license that can be
  3253. * found in the LICENSE file at https://angular.io/license
  3254. */
  3255. /**
  3256. * Used to diff and convert ngStyle/ngClass instructions into [style] and [class] bindings.
  3257. *
  3258. * ngStyle and ngClass both accept various forms of input and behave differently than that
  3259. * of how [style] and [class] behave in Angular.
  3260. *
  3261. * The differences are:
  3262. * - ngStyle and ngClass both **watch** their binding values for changes each time CD runs
  3263. * while [style] and [class] bindings do not (they check for identity changes)
  3264. * - ngStyle allows for unit-based keys (e.g. `{'max-width.px':value}`) and [style] does not
  3265. * - ngClass supports arrays of class values and [class] only accepts map and string values
  3266. * - ngClass allows for multiple className keys (space-separated) within an array or map
  3267. * (as the * key) while [class] only accepts a simple key/value map object
  3268. *
  3269. * Having Angular understand and adapt to all the different forms of behavior is complicated
  3270. * and unnecessary. Instead, ngClass and ngStyle should have their input values be converted
  3271. * into something that the core-level [style] and [class] bindings understand.
  3272. *
  3273. * This [StylingDiffer] class handles this conversion by creating a new input value each time
  3274. * the inner representation of the binding value have changed.
  3275. *
  3276. * ## Why do we care about ngStyle/ngClass?
  3277. * The styling algorithm code (documented inside of `render3/interfaces/styling.ts`) needs to
  3278. * respect and understand the styling values emitted through ngStyle and ngClass (when they
  3279. * are present and used in a template).
  3280. *
  3281. * Instead of having these directives manage styling on their own, they should be included
  3282. * into the Angular styling algorithm that exists for [style] and [class] bindings.
  3283. *
  3284. * Here's why:
  3285. *
  3286. * - If ngStyle/ngClass is used in combination with [style]/[class] bindings then the
  3287. * styles and classes would fall out of sync and be applied and updated at
  3288. * inconsistent times
  3289. * - Both ngClass/ngStyle do not respect [class.name] and [style.prop] bindings
  3290. * (they will write over them given the right combination of events)
  3291. *
  3292. * ```
  3293. * <!-- if `w1` is updated then it will always override `w2`
  3294. * if `w2` is updated then it will always override `w1`
  3295. * if both are updated at the same time then `w1` wins -->
  3296. * <div [ngStyle]="{width:w1}" [style.width]="w2">...</div>
  3297. *
  3298. * <!-- if `w1` is updated then it will always lose to `w2`
  3299. * if `w2` is updated then it will always override `w1`
  3300. * if both are updated at the same time then `w2` wins -->
  3301. * <div [style]="{width:w1}" [style.width]="w2">...</div>
  3302. * ```
  3303. * - ngClass/ngStyle were written as a directives and made use of maps, closures and other
  3304. * expensive data structures which were evaluated each time CD runs
  3305. * @template T
  3306. */
  3307. class StylingDiffer {
  3308. /**
  3309. * @param {?} _name
  3310. * @param {?} _options
  3311. */
  3312. constructor(_name, _options) {
  3313. this._name = _name;
  3314. this._options = _options;
  3315. this.value = null;
  3316. this._lastSetValue = null;
  3317. this._lastSetValueType = 0 /* Null */;
  3318. this._lastSetValueIdentityChange = false;
  3319. }
  3320. /**
  3321. * Sets (updates) the styling value within the differ.
  3322. *
  3323. * Only when `hasValueChanged` is called then this new value will be evaluted
  3324. * and checked against the previous value.
  3325. *
  3326. * @param {?} value the new styling value provided from the ngClass/ngStyle binding
  3327. * @return {?}
  3328. */
  3329. setValue(value) {
  3330. if (Array.isArray(value)) {
  3331. this._lastSetValueType = 4 /* Array */;
  3332. }
  3333. else if (value instanceof Set) {
  3334. this._lastSetValueType = 8 /* Set */;
  3335. }
  3336. else if (value && typeof value === 'string') {
  3337. if (!(this._options & 4 /* AllowStringValue */)) {
  3338. throw new Error(this._name + ' string values are not allowed');
  3339. }
  3340. this._lastSetValueType = 1 /* String */;
  3341. }
  3342. else {
  3343. this._lastSetValueType = value ? 2 /* Map */ : 0 /* Null */;
  3344. }
  3345. this._lastSetValueIdentityChange = true;
  3346. this._lastSetValue = value || null;
  3347. }
  3348. /**
  3349. * Determines whether or not the value has changed.
  3350. *
  3351. * This function can be called right after `setValue()` is called, but it can also be
  3352. * called incase the existing value (if it's a collection) changes internally. If the
  3353. * value is indeed a collection it will do the necessary diffing work and produce a
  3354. * new object value as assign that to `value`.
  3355. *
  3356. * @return {?} whether or not the value has changed in some way.
  3357. */
  3358. hasValueChanged() {
  3359. /** @type {?} */
  3360. let valueHasChanged = this._lastSetValueIdentityChange;
  3361. if (!valueHasChanged && !(this._lastSetValueType & 14 /* Collection */))
  3362. return false;
  3363. /** @type {?} */
  3364. let finalValue = null;
  3365. /** @type {?} */
  3366. const trimValues = (this._options & 1 /* TrimProperties */) ? true : false;
  3367. /** @type {?} */
  3368. const parseOutUnits = (this._options & 8 /* AllowUnits */) ? true : false;
  3369. /** @type {?} */
  3370. const allowSubKeys = (this._options & 2 /* AllowSubKeys */) ? true : false;
  3371. switch (this._lastSetValueType) {
  3372. // case 1: [input]="string"
  3373. case 1 /* String */:
  3374. /** @type {?} */
  3375. const tokens = ((/** @type {?} */ (this._lastSetValue))).split(/\s+/g);
  3376. if (this._options & 16 /* ForceAsMap */) {
  3377. finalValue = {};
  3378. tokens.forEach((/**
  3379. * @param {?} token
  3380. * @param {?} i
  3381. * @return {?}
  3382. */
  3383. (token, i) => ((/** @type {?} */ (finalValue)))[token] = true));
  3384. }
  3385. else {
  3386. finalValue = tokens.reduce((/**
  3387. * @param {?} str
  3388. * @param {?} token
  3389. * @param {?} i
  3390. * @return {?}
  3391. */
  3392. (str, token, i) => str + (i ? ' ' : '') + token));
  3393. }
  3394. break;
  3395. // case 2: [input]="{key:value}"
  3396. case 2 /* Map */:
  3397. /** @type {?} */
  3398. const map = (/** @type {?} */ (this._lastSetValue));
  3399. /** @type {?} */
  3400. const keys = Object.keys(map);
  3401. if (!valueHasChanged) {
  3402. if (this.value) {
  3403. // we know that the classExp value exists and that it is
  3404. // a map (otherwise an identity change would have occurred)
  3405. valueHasChanged = mapHasChanged(keys, (/** @type {?} */ (this.value)), map);
  3406. }
  3407. else {
  3408. valueHasChanged = true;
  3409. }
  3410. }
  3411. if (valueHasChanged) {
  3412. finalValue =
  3413. bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, map, keys);
  3414. }
  3415. break;
  3416. // case 3a: [input]="[str1, str2, ...]"
  3417. // case 3b: [input]="Set"
  3418. case 4 /* Array */:
  3419. case 8 /* Set */:
  3420. /** @type {?} */
  3421. const values = Array.from((/** @type {?} */ (this._lastSetValue)));
  3422. if (!valueHasChanged) {
  3423. /** @type {?} */
  3424. const keys = Object.keys((/** @type {?} */ (this.value)));
  3425. valueHasChanged = !arrayEqualsArray(keys, values);
  3426. }
  3427. if (valueHasChanged) {
  3428. finalValue =
  3429. bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, values);
  3430. }
  3431. break;
  3432. // case 4: [input]="null|undefined"
  3433. default:
  3434. finalValue = null;
  3435. break;
  3436. }
  3437. if (valueHasChanged) {
  3438. ((/** @type {?} */ (this))).value = (/** @type {?} */ (finalValue));
  3439. }
  3440. return valueHasChanged;
  3441. }
  3442. }
  3443. /**
  3444. * builds and returns a map based on the values input value
  3445. *
  3446. * If the `keys` param is provided then the `values` param is treated as a
  3447. * string map. Otherwise `values` is treated as a string array.
  3448. * @param {?} errorPrefix
  3449. * @param {?} trim
  3450. * @param {?} parseOutUnits
  3451. * @param {?} allowSubKeys
  3452. * @param {?} values
  3453. * @param {?=} keys
  3454. * @return {?}
  3455. */
  3456. function bulidMapFromValues(errorPrefix, trim, parseOutUnits, allowSubKeys, values, keys) {
  3457. /** @type {?} */
  3458. const map = {};
  3459. if (keys) {
  3460. // case 1: map
  3461. for (let i = 0; i < keys.length; i++) {
  3462. /** @type {?} */
  3463. let key = keys[i];
  3464. key = trim ? key.trim() : key;
  3465. /** @type {?} */
  3466. const value = ((/** @type {?} */ (values)))[key];
  3467. setMapValues(map, key, value, parseOutUnits, allowSubKeys);
  3468. }
  3469. }
  3470. else {
  3471. // case 2: array
  3472. for (let i = 0; i < values.length; i++) {
  3473. /** @type {?} */
  3474. let value = ((/** @type {?} */ (values)))[i];
  3475. assertValidValue(errorPrefix, value);
  3476. value = trim ? value.trim() : value;
  3477. setMapValues(map, value, true, false, allowSubKeys);
  3478. }
  3479. }
  3480. return map;
  3481. }
  3482. /**
  3483. * @param {?} errorPrefix
  3484. * @param {?} value
  3485. * @return {?}
  3486. */
  3487. function assertValidValue(errorPrefix, value) {
  3488. if (typeof value !== 'string') {
  3489. throw new Error(`${errorPrefix} can only toggle CSS classes expressed as strings, got ${value}`);
  3490. }
  3491. }
  3492. /**
  3493. * @param {?} map
  3494. * @param {?} key
  3495. * @param {?} value
  3496. * @param {?} parseOutUnits
  3497. * @param {?} allowSubKeys
  3498. * @return {?}
  3499. */
  3500. function setMapValues(map, key, value, parseOutUnits, allowSubKeys) {
  3501. if (allowSubKeys && key.indexOf(' ') > 0) {
  3502. /** @type {?} */
  3503. const innerKeys = key.split(/\s+/g);
  3504. for (let j = 0; j < innerKeys.length; j++) {
  3505. setIndividualMapValue(map, innerKeys[j], value, parseOutUnits);
  3506. }
  3507. }
  3508. else {
  3509. setIndividualMapValue(map, key, value, parseOutUnits);
  3510. }
  3511. }
  3512. /**
  3513. * @param {?} map
  3514. * @param {?} key
  3515. * @param {?} value
  3516. * @param {?} parseOutUnits
  3517. * @return {?}
  3518. */
  3519. function setIndividualMapValue(map, key, value, parseOutUnits) {
  3520. if (parseOutUnits) {
  3521. /** @type {?} */
  3522. const values = normalizeStyleKeyAndValue(key, value);
  3523. value = values.value;
  3524. key = values.key;
  3525. }
  3526. map[key] = value;
  3527. }
  3528. /**
  3529. * @param {?} key
  3530. * @param {?} value
  3531. * @return {?}
  3532. */
  3533. function normalizeStyleKeyAndValue(key, value) {
  3534. /** @type {?} */
  3535. const index = key.indexOf('.');
  3536. if (index > 0) {
  3537. /** @type {?} */
  3538. const unit = key.substr(index + 1);
  3539. key = key.substring(0, index);
  3540. if (value != null) { // we should not convert null values to string
  3541. value += unit;
  3542. }
  3543. }
  3544. return { key, value };
  3545. }
  3546. /**
  3547. * @param {?} keys
  3548. * @param {?} a
  3549. * @param {?} b
  3550. * @return {?}
  3551. */
  3552. function mapHasChanged(keys, a, b) {
  3553. /** @type {?} */
  3554. const oldKeys = Object.keys(a);
  3555. /** @type {?} */
  3556. const newKeys = keys;
  3557. // the keys are different which means the map changed
  3558. if (!arrayEqualsArray(oldKeys, newKeys)) {
  3559. return true;
  3560. }
  3561. for (let i = 0; i < newKeys.length; i++) {
  3562. /** @type {?} */
  3563. const key = newKeys[i];
  3564. if (a[key] !== b[key]) {
  3565. return true;
  3566. }
  3567. }
  3568. return false;
  3569. }
  3570. /**
  3571. * @param {?} a
  3572. * @param {?} b
  3573. * @return {?}
  3574. */
  3575. function arrayEqualsArray(a, b) {
  3576. if (a && b) {
  3577. if (a.length !== b.length)
  3578. return false;
  3579. for (let i = 0; i < a.length; i++) {
  3580. if (b.indexOf(a[i]) === -1)
  3581. return false;
  3582. }
  3583. return true;
  3584. }
  3585. return false;
  3586. }
  3587. /**
  3588. * @fileoverview added by tsickle
  3589. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3590. */
  3591. /**
  3592. * Used as a token for an injected service within the NgClass directive.
  3593. *
  3594. * NgClass behaves differenly whether or not VE is being used or not. If
  3595. * present then the legacy ngClass diffing algorithm will be used as an
  3596. * injected service. Otherwise the new diffing algorithm (which delegates
  3597. * to the `[class]` binding) will be used. This toggle behavior is done so
  3598. * via the ivy_switch mechanism.
  3599. * @abstract
  3600. */
  3601. class NgClassImpl {
  3602. }
  3603. class NgClassR2Impl {
  3604. /**
  3605. * @param {?} _iterableDiffers
  3606. * @param {?} _keyValueDiffers
  3607. * @param {?} _ngEl
  3608. * @param {?} _renderer
  3609. */
  3610. constructor(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
  3611. this._iterableDiffers = _iterableDiffers;
  3612. this._keyValueDiffers = _keyValueDiffers;
  3613. this._ngEl = _ngEl;
  3614. this._renderer = _renderer;
  3615. this._initialClasses = [];
  3616. }
  3617. /**
  3618. * @return {?}
  3619. */
  3620. getValue() { return null; }
  3621. /**
  3622. * @param {?} value
  3623. * @return {?}
  3624. */
  3625. setClass(value) {
  3626. this._removeClasses(this._initialClasses);
  3627. this._initialClasses = typeof value === 'string' ? value.split(/\s+/) : [];
  3628. this._applyClasses(this._initialClasses);
  3629. this._applyClasses(this._rawClass);
  3630. }
  3631. /**
  3632. * @param {?} value
  3633. * @return {?}
  3634. */
  3635. setNgClass(value) {
  3636. this._removeClasses(this._rawClass);
  3637. this._applyClasses(this._initialClasses);
  3638. this._iterableDiffer = null;
  3639. this._keyValueDiffer = null;
  3640. this._rawClass = typeof value === 'string' ? value.split(/\s+/) : value;
  3641. if (this._rawClass) {
  3642. if (ɵisListLikeIterable(this._rawClass)) {
  3643. this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
  3644. }
  3645. else {
  3646. this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
  3647. }
  3648. }
  3649. }
  3650. /**
  3651. * @return {?}
  3652. */
  3653. applyChanges() {
  3654. if (this._iterableDiffer) {
  3655. /** @type {?} */
  3656. const iterableChanges = this._iterableDiffer.diff((/** @type {?} */ (this._rawClass)));
  3657. if (iterableChanges) {
  3658. this._applyIterableChanges(iterableChanges);
  3659. }
  3660. }
  3661. else if (this._keyValueDiffer) {
  3662. /** @type {?} */
  3663. const keyValueChanges = this._keyValueDiffer.diff((/** @type {?} */ (this._rawClass)));
  3664. if (keyValueChanges) {
  3665. this._applyKeyValueChanges(keyValueChanges);
  3666. }
  3667. }
  3668. }
  3669. /**
  3670. * @private
  3671. * @param {?} changes
  3672. * @return {?}
  3673. */
  3674. _applyKeyValueChanges(changes) {
  3675. changes.forEachAddedItem((/**
  3676. * @param {?} record
  3677. * @return {?}
  3678. */
  3679. (record) => this._toggleClass(record.key, record.currentValue)));
  3680. changes.forEachChangedItem((/**
  3681. * @param {?} record
  3682. * @return {?}
  3683. */
  3684. (record) => this._toggleClass(record.key, record.currentValue)));
  3685. changes.forEachRemovedItem((/**
  3686. * @param {?} record
  3687. * @return {?}
  3688. */
  3689. (record) => {
  3690. if (record.previousValue) {
  3691. this._toggleClass(record.key, false);
  3692. }
  3693. }));
  3694. }
  3695. /**
  3696. * @private
  3697. * @param {?} changes
  3698. * @return {?}
  3699. */
  3700. _applyIterableChanges(changes) {
  3701. changes.forEachAddedItem((/**
  3702. * @param {?} record
  3703. * @return {?}
  3704. */
  3705. (record) => {
  3706. if (typeof record.item === 'string') {
  3707. this._toggleClass(record.item, true);
  3708. }
  3709. else {
  3710. throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${ɵstringify(record.item)}`);
  3711. }
  3712. }));
  3713. changes.forEachRemovedItem((/**
  3714. * @param {?} record
  3715. * @return {?}
  3716. */
  3717. (record) => this._toggleClass(record.item, false)));
  3718. }
  3719. /**
  3720. * Applies a collection of CSS classes to the DOM element.
  3721. *
  3722. * For argument of type Set and Array CSS class names contained in those collections are always
  3723. * added.
  3724. * For argument of type Map CSS class name in the map's key is toggled based on the value (added
  3725. * for truthy and removed for falsy).
  3726. * @private
  3727. * @param {?} rawClassVal
  3728. * @return {?}
  3729. */
  3730. _applyClasses(rawClassVal) {
  3731. if (rawClassVal) {
  3732. if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
  3733. ((/** @type {?} */ (rawClassVal))).forEach((/**
  3734. * @param {?} klass
  3735. * @return {?}
  3736. */
  3737. (klass) => this._toggleClass(klass, true)));
  3738. }
  3739. else {
  3740. Object.keys(rawClassVal).forEach((/**
  3741. * @param {?} klass
  3742. * @return {?}
  3743. */
  3744. klass => this._toggleClass(klass, !!rawClassVal[klass])));
  3745. }
  3746. }
  3747. }
  3748. /**
  3749. * Removes a collection of CSS classes from the DOM element. This is mostly useful for cleanup
  3750. * purposes.
  3751. * @private
  3752. * @param {?} rawClassVal
  3753. * @return {?}
  3754. */
  3755. _removeClasses(rawClassVal) {
  3756. if (rawClassVal) {
  3757. if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
  3758. ((/** @type {?} */ (rawClassVal))).forEach((/**
  3759. * @param {?} klass
  3760. * @return {?}
  3761. */
  3762. (klass) => this._toggleClass(klass, false)));
  3763. }
  3764. else {
  3765. Object.keys(rawClassVal).forEach((/**
  3766. * @param {?} klass
  3767. * @return {?}
  3768. */
  3769. klass => this._toggleClass(klass, false)));
  3770. }
  3771. }
  3772. }
  3773. /**
  3774. * @private
  3775. * @param {?} klass
  3776. * @param {?} enabled
  3777. * @return {?}
  3778. */
  3779. _toggleClass(klass, enabled) {
  3780. klass = klass.trim();
  3781. if (klass) {
  3782. klass.split(/\s+/g).forEach((/**
  3783. * @param {?} klass
  3784. * @return {?}
  3785. */
  3786. klass => {
  3787. if (enabled) {
  3788. this._renderer.addClass(this._ngEl.nativeElement, klass);
  3789. }
  3790. else {
  3791. this._renderer.removeClass(this._ngEl.nativeElement, klass);
  3792. }
  3793. }));
  3794. }
  3795. }
  3796. }
  3797. NgClassR2Impl.decorators = [
  3798. { type: Injectable }
  3799. ];
  3800. /** @nocollapse */
  3801. NgClassR2Impl.ctorParameters = () => [
  3802. { type: IterableDiffers },
  3803. { type: KeyValueDiffers },
  3804. { type: ElementRef },
  3805. { type: Renderer2 }
  3806. ];
  3807. class NgClassR3Impl {
  3808. constructor() {
  3809. this._value = null;
  3810. this._ngClassDiffer = new StylingDiffer('NgClass', 1 /* TrimProperties */ |
  3811. 2 /* AllowSubKeys */ |
  3812. 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
  3813. this._classStringDiffer = null;
  3814. }
  3815. /**
  3816. * @return {?}
  3817. */
  3818. getValue() { return this._value; }
  3819. /**
  3820. * @param {?} value
  3821. * @return {?}
  3822. */
  3823. setClass(value) {
  3824. // early exit incase the binding gets emitted as an empty value which
  3825. // means there is no reason to instantiate and diff the values...
  3826. if (!value && !this._classStringDiffer)
  3827. return;
  3828. this._classStringDiffer = this._classStringDiffer ||
  3829. new StylingDiffer('class', 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
  3830. this._classStringDiffer.setValue(value);
  3831. }
  3832. /**
  3833. * @param {?} value
  3834. * @return {?}
  3835. */
  3836. setNgClass(value) {
  3837. this._ngClassDiffer.setValue(value);
  3838. }
  3839. /**
  3840. * @return {?}
  3841. */
  3842. applyChanges() {
  3843. /** @type {?} */
  3844. const classChanged = this._classStringDiffer ? this._classStringDiffer.hasValueChanged() : false;
  3845. /** @type {?} */
  3846. const ngClassChanged = this._ngClassDiffer.hasValueChanged();
  3847. if (classChanged || ngClassChanged) {
  3848. /** @type {?} */
  3849. let value = this._ngClassDiffer.value;
  3850. if (this._classStringDiffer) {
  3851. /** @type {?} */
  3852. let classValue = this._classStringDiffer.value;
  3853. if (classValue) {
  3854. value = value ? Object.assign({}, classValue, value) : classValue;
  3855. }
  3856. }
  3857. this._value = value;
  3858. }
  3859. }
  3860. }
  3861. NgClassR3Impl.decorators = [
  3862. { type: Injectable }
  3863. ];
  3864. // the implementation for both NgStyleR2Impl and NgStyleR3Impl are
  3865. // not ivy_switch'd away, instead they are only hooked up into the
  3866. // DI via NgStyle's directive's provider property.
  3867. /** @type {?} */
  3868. const NgClassImplProvider__PRE_R3__ = {
  3869. provide: NgClassImpl,
  3870. useClass: NgClassR2Impl
  3871. };
  3872. /** @type {?} */
  3873. const NgClassImplProvider__POST_R3__ = {
  3874. provide: NgClassImpl,
  3875. useClass: NgClassR3Impl
  3876. };
  3877. /** @type {?} */
  3878. const NgClassImplProvider = NgClassImplProvider__PRE_R3__;
  3879. /**
  3880. * @fileoverview added by tsickle
  3881. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3882. */
  3883. /*
  3884. * NgClass (as well as NgStyle) behaves differently when loaded in the VE and when not.
  3885. *
  3886. * If the VE is present (which is for older versions of Angular) then NgClass will inject
  3887. * the legacy diffing algorithm as a service and delegate all styling changes to that.
  3888. *
  3889. * If the VE is not present then NgStyle will normalize (through the injected service) and
  3890. * then write all styling changes to the `[style]` binding directly (through a host binding).
  3891. * Then Angular will notice the host binding change and treat the changes as styling
  3892. * changes and apply them via the core styling instructions that exist within Angular.
  3893. */
  3894. // used when the VE is present
  3895. /** @type {?} */
  3896. const ngClassDirectiveDef__PRE_R3__ = undefined;
  3897. // used when the VE is not present (note the directive will
  3898. // never be instantiated normally because it is apart of a
  3899. // base class)
  3900. const ɵ0 = /**
  3901. * @return {?}
  3902. */
  3903. function () { }, ɵ1 = /**
  3904. * @return {?}
  3905. */
  3906. () => { }, ɵ2 = /**
  3907. * @param {?} rf
  3908. * @param {?} ctx
  3909. * @param {?} elIndex
  3910. * @return {?}
  3911. */
  3912. function (rf, ctx, elIndex) {
  3913. if (rf & 1 /* Create */) {
  3914. ɵɵstyling();
  3915. }
  3916. if (rf & 2 /* Update */) {
  3917. ɵɵclassMap(ctx.getValue());
  3918. ɵɵstylingApply();
  3919. }
  3920. };
  3921. /** @type {?} */
  3922. const ngClassDirectiveDef__POST_R3__ = ɵɵdefineDirective({
  3923. type: (/** @type {?} */ ((ɵ0))),
  3924. selectors: (/** @type {?} */ (null)),
  3925. factory: (ɵ1),
  3926. hostBindings: (ɵ2)
  3927. });
  3928. /** @type {?} */
  3929. const ngClassDirectiveDef = ngClassDirectiveDef__PRE_R3__;
  3930. /**
  3931. * Serves as the base non-VE container for NgClass.
  3932. *
  3933. * While this is a base class that NgClass extends from, the
  3934. * class itself acts as a container for non-VE code to setup
  3935. * a link to the `[class]` host binding (via the static
  3936. * `ngDirectiveDef` property on the class).
  3937. *
  3938. * Note that the `ngDirectiveDef` property's code is switched
  3939. * depending if VE is present or not (this allows for the
  3940. * binding code to be set only for newer versions of Angular).
  3941. *
  3942. * \@publicApi
  3943. */
  3944. class NgClassBase {
  3945. /**
  3946. * @param {?} _delegate
  3947. */
  3948. constructor(_delegate) {
  3949. this._delegate = _delegate;
  3950. }
  3951. /**
  3952. * @return {?}
  3953. */
  3954. getValue() { return this._delegate.getValue(); }
  3955. }
  3956. /** @nocollapse */ NgClassBase.ngDirectiveDef = ngClassDirectiveDef;
  3957. /**
  3958. * \@ngModule CommonModule
  3959. *
  3960. * \@usageNotes
  3961. * ```
  3962. * <some-element [ngClass]="'first second'">...</some-element>
  3963. *
  3964. * <some-element [ngClass]="['first', 'second']">...</some-element>
  3965. *
  3966. * <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
  3967. *
  3968. * <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
  3969. *
  3970. * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
  3971. * ```
  3972. *
  3973. * \@description
  3974. *
  3975. * Adds and removes CSS classes on an HTML element.
  3976. *
  3977. * The CSS classes are updated as follows, depending on the type of the expression evaluation:
  3978. * - `string` - the CSS classes listed in the string (space delimited) are added,
  3979. * - `Array` - the CSS classes declared as Array elements are added,
  3980. * - `Object` - keys are CSS classes that get added when the expression given in the value
  3981. * evaluates to a truthy value, otherwise they are removed.
  3982. *
  3983. * \@publicApi
  3984. */
  3985. class NgClass extends NgClassBase {
  3986. /**
  3987. * @param {?} delegate
  3988. */
  3989. constructor(delegate) { super(delegate); }
  3990. /**
  3991. * @param {?} value
  3992. * @return {?}
  3993. */
  3994. set klass(value) { this._delegate.setClass(value); }
  3995. /**
  3996. * @param {?} value
  3997. * @return {?}
  3998. */
  3999. set ngClass(value) {
  4000. this._delegate.setNgClass(value);
  4001. }
  4002. /**
  4003. * @return {?}
  4004. */
  4005. ngDoCheck() { this._delegate.applyChanges(); }
  4006. }
  4007. NgClass.decorators = [
  4008. { type: Directive, args: [{ selector: '[ngClass]', providers: [NgClassImplProvider] },] }
  4009. ];
  4010. /** @nocollapse */
  4011. NgClass.ctorParameters = () => [
  4012. { type: NgClassImpl }
  4013. ];
  4014. NgClass.propDecorators = {
  4015. klass: [{ type: Input, args: ['class',] }],
  4016. ngClass: [{ type: Input, args: ['ngClass',] }]
  4017. };
  4018. /**
  4019. * @fileoverview added by tsickle
  4020. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4021. */
  4022. /**
  4023. * Instantiates a single {\@link Component} type and inserts its Host View into current View.
  4024. * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
  4025. *
  4026. * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
  4027. * any existing component will get destroyed.
  4028. *
  4029. * \@usageNotes
  4030. *
  4031. * ### Fine tune control
  4032. *
  4033. * You can control the component creation process by using the following optional attributes:
  4034. *
  4035. * * `ngComponentOutletInjector`: Optional custom {\@link Injector} that will be used as parent for
  4036. * the Component. Defaults to the injector of the current view container.
  4037. *
  4038. * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
  4039. * section of the component, if exists.
  4040. *
  4041. * * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
  4042. * module, then load a component from that module.
  4043. *
  4044. * ### Syntax
  4045. *
  4046. * Simple
  4047. * ```
  4048. * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
  4049. * ```
  4050. *
  4051. * Customized injector/content
  4052. * ```
  4053. * <ng-container *ngComponentOutlet="componentTypeExpression;
  4054. * injector: injectorExpression;
  4055. * content: contentNodesExpression;">
  4056. * </ng-container>
  4057. * ```
  4058. *
  4059. * Customized ngModuleFactory
  4060. * ```
  4061. * <ng-container *ngComponentOutlet="componentTypeExpression;
  4062. * ngModuleFactory: moduleFactory;">
  4063. * </ng-container>
  4064. * ```
  4065. *
  4066. * ### A simple example
  4067. *
  4068. * {\@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
  4069. *
  4070. * A more complete example with additional options:
  4071. *
  4072. * {\@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
  4073. *
  4074. * \@publicApi
  4075. * \@ngModule CommonModule
  4076. */
  4077. class NgComponentOutlet {
  4078. /**
  4079. * @param {?} _viewContainerRef
  4080. */
  4081. constructor(_viewContainerRef) {
  4082. this._viewContainerRef = _viewContainerRef;
  4083. this._componentRef = null;
  4084. this._moduleRef = null;
  4085. }
  4086. /**
  4087. * @param {?} changes
  4088. * @return {?}
  4089. */
  4090. ngOnChanges(changes) {
  4091. this._viewContainerRef.clear();
  4092. this._componentRef = null;
  4093. if (this.ngComponentOutlet) {
  4094. /** @type {?} */
  4095. const elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
  4096. if (changes['ngComponentOutletNgModuleFactory']) {
  4097. if (this._moduleRef)
  4098. this._moduleRef.destroy();
  4099. if (this.ngComponentOutletNgModuleFactory) {
  4100. /** @type {?} */
  4101. const parentModule = elInjector.get(NgModuleRef);
  4102. this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
  4103. }
  4104. else {
  4105. this._moduleRef = null;
  4106. }
  4107. }
  4108. /** @type {?} */
  4109. const componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
  4110. elInjector.get(ComponentFactoryResolver);
  4111. /** @type {?} */
  4112. const componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
  4113. this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
  4114. }
  4115. }
  4116. /**
  4117. * @return {?}
  4118. */
  4119. ngOnDestroy() {
  4120. if (this._moduleRef)
  4121. this._moduleRef.destroy();
  4122. }
  4123. }
  4124. NgComponentOutlet.decorators = [
  4125. { type: Directive, args: [{ selector: '[ngComponentOutlet]' },] }
  4126. ];
  4127. /** @nocollapse */
  4128. NgComponentOutlet.ctorParameters = () => [
  4129. { type: ViewContainerRef }
  4130. ];
  4131. NgComponentOutlet.propDecorators = {
  4132. ngComponentOutlet: [{ type: Input }],
  4133. ngComponentOutletInjector: [{ type: Input }],
  4134. ngComponentOutletContent: [{ type: Input }],
  4135. ngComponentOutletNgModuleFactory: [{ type: Input }]
  4136. };
  4137. /**
  4138. * @fileoverview added by tsickle
  4139. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4140. */
  4141. /**
  4142. * \@publicApi
  4143. * @template T
  4144. */
  4145. class NgForOfContext {
  4146. /**
  4147. * @param {?} $implicit
  4148. * @param {?} ngForOf
  4149. * @param {?} index
  4150. * @param {?} count
  4151. */
  4152. constructor($implicit, ngForOf, index, count) {
  4153. this.$implicit = $implicit;
  4154. this.ngForOf = ngForOf;
  4155. this.index = index;
  4156. this.count = count;
  4157. }
  4158. /**
  4159. * @return {?}
  4160. */
  4161. get first() { return this.index === 0; }
  4162. /**
  4163. * @return {?}
  4164. */
  4165. get last() { return this.index === this.count - 1; }
  4166. /**
  4167. * @return {?}
  4168. */
  4169. get even() { return this.index % 2 === 0; }
  4170. /**
  4171. * @return {?}
  4172. */
  4173. get odd() { return !this.even; }
  4174. }
  4175. /**
  4176. * A [structural directive](guide/structural-directives) that renders
  4177. * a template for each item in a collection.
  4178. * The directive is placed on an element, which becomes the parent
  4179. * of the cloned templates.
  4180. *
  4181. * The `ngForOf` directive is generally used in the
  4182. * [shorthand form](guide/structural-directives#the-asterisk--prefix) `*ngFor`.
  4183. * In this form, the template to be rendered for each iteration is the content
  4184. * of an anchor element containing the directive.
  4185. *
  4186. * The following example shows the shorthand syntax with some options,
  4187. * contained in an `<li>` element.
  4188. *
  4189. * ```
  4190. * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
  4191. * ```
  4192. *
  4193. * The shorthand form expands into a long form that uses the `ngForOf` selector
  4194. * on an `<ng-template>` element.
  4195. * The content of the `<ng-template>` element is the `<li>` element that held the
  4196. * short-form directive.
  4197. *
  4198. * Here is the expanded version of the short-form example.
  4199. *
  4200. * ```
  4201. * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
  4202. * <li>...</li>
  4203. * </ng-template>
  4204. * ```
  4205. *
  4206. * Angular automatically expands the shorthand syntax as it compiles the template.
  4207. * The context for each embedded view is logically merged to the current component
  4208. * context according to its lexical position.
  4209. *
  4210. * When using the shorthand syntax, Angular allows only [one structural directive
  4211. * on an element](guide/structural-directives#one-structural-directive-per-host-element).
  4212. * If you want to iterate conditionally, for example,
  4213. * put the `*ngIf` on a container element that wraps the `*ngFor` element.
  4214. * For futher discussion, see
  4215. * [Structural Directives](guide/structural-directives#one-per-element).
  4216. *
  4217. * \@usageNotes
  4218. *
  4219. * ### Local variables
  4220. *
  4221. * `NgForOf` provides exported values that can be aliased to local variables.
  4222. * For example:
  4223. *
  4224. * ```
  4225. * <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
  4226. * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
  4227. * </li>
  4228. * ```
  4229. *
  4230. * The following exported values can be aliased to local variables:
  4231. *
  4232. * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
  4233. * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
  4234. * more complex then a property access, for example when using the async pipe (`userStreams |
  4235. * async`).
  4236. * - `index: number`: The index of the current item in the iterable.
  4237. * - `first: boolean`: True when the item is the first item in the iterable.
  4238. * - `last: boolean`: True when the item is the last item in the iterable.
  4239. * - `even: boolean`: True when the item has an even index in the iterable.
  4240. * - `odd: boolean`: True when the item has an odd index in the iterable.
  4241. *
  4242. * ### Change propagation
  4243. *
  4244. * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
  4245. *
  4246. * * When an item is added, a new instance of the template is added to the DOM.
  4247. * * When an item is removed, its template instance is removed from the DOM.
  4248. * * When items are reordered, their respective templates are reordered in the DOM.
  4249. *
  4250. * Angular uses object identity to track insertions and deletions within the iterator and reproduce
  4251. * those changes in the DOM. This has important implications for animations and any stateful
  4252. * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
  4253. * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
  4254. * such as user input.
  4255. * For more on animations, see [Transitions and Triggers](guide/transition-and-triggers).
  4256. *
  4257. * The identities of elements in the iterator can change while the data does not.
  4258. * This can happen, for example, if the iterator is produced from an RPC to the server, and that
  4259. * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
  4260. * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
  4261. * elements were deleted and all new elements inserted).
  4262. *
  4263. * To avoid this expensive operation, you can customize the default tracking algorithm.
  4264. * by supplying the `trackBy` option to `NgForOf`.
  4265. * `trackBy` takes a function that has two arguments: `index` and `item`.
  4266. * If `trackBy` is given, Angular tracks changes by the return value of the function.
  4267. *
  4268. * @see [Structural Directives](guide/structural-directives)
  4269. * \@ngModule CommonModule
  4270. * \@publicApi
  4271. * @template T
  4272. */
  4273. class NgForOf {
  4274. /**
  4275. * @param {?} _viewContainer
  4276. * @param {?} _template
  4277. * @param {?} _differs
  4278. */
  4279. constructor(_viewContainer, _template, _differs) {
  4280. this._viewContainer = _viewContainer;
  4281. this._template = _template;
  4282. this._differs = _differs;
  4283. this._ngForOfDirty = true;
  4284. this._differ = null;
  4285. }
  4286. /**
  4287. * The value of the iterable expression, which can be used as a
  4288. * [template input variable](guide/structural-directives#template-input-variable).
  4289. * @param {?} ngForOf
  4290. * @return {?}
  4291. */
  4292. set ngForOf(ngForOf) {
  4293. this._ngForOf = ngForOf;
  4294. this._ngForOfDirty = true;
  4295. }
  4296. /**
  4297. * A function that defines how to track changes for items in the iterable.
  4298. *
  4299. * When items are added, moved, or removed in the iterable,
  4300. * the directive must re-render the appropriate DOM nodes.
  4301. * To minimize churn in the DOM, only nodes that have changed
  4302. * are re-rendered.
  4303. *
  4304. * By default, the change detector assumes that
  4305. * the object instance identifies the node in the iterable.
  4306. * When this function is supplied, the directive uses
  4307. * the result of calling this function to identify the item node,
  4308. * rather than the identity of the object itself.
  4309. *
  4310. * The function receives two inputs,
  4311. * the iteration index and the node object ID.
  4312. * @param {?} fn
  4313. * @return {?}
  4314. */
  4315. set ngForTrackBy(fn) {
  4316. if (isDevMode() && fn != null && typeof fn !== 'function') {
  4317. // TODO(vicb): use a log service once there is a public one available
  4318. if ((/** @type {?} */ (console)) && (/** @type {?} */ (console.warn))) {
  4319. console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
  4320. `See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.`);
  4321. }
  4322. }
  4323. this._trackByFn = fn;
  4324. }
  4325. /**
  4326. * @return {?}
  4327. */
  4328. get ngForTrackBy() { return this._trackByFn; }
  4329. /**
  4330. * A reference to the template that is stamped out for each item in the iterable.
  4331. * @see [template reference variable](guide/template-syntax#template-reference-variables--var-)
  4332. * @param {?} value
  4333. * @return {?}
  4334. */
  4335. set ngForTemplate(value) {
  4336. // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
  4337. // The current type is too restrictive; a template that just uses index, for example,
  4338. // should be acceptable.
  4339. if (value) {
  4340. this._template = value;
  4341. }
  4342. }
  4343. /**
  4344. * Applies the changes when needed.
  4345. * @return {?}
  4346. */
  4347. ngDoCheck() {
  4348. if (this._ngForOfDirty) {
  4349. this._ngForOfDirty = false;
  4350. // React on ngForOf changes only once all inputs have been initialized
  4351. /** @type {?} */
  4352. const value = this._ngForOf;
  4353. if (!this._differ && value) {
  4354. try {
  4355. this._differ = this._differs.find(value).create(this.ngForTrackBy);
  4356. }
  4357. catch (_a) {
  4358. throw new Error(`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
  4359. }
  4360. }
  4361. }
  4362. if (this._differ) {
  4363. /** @type {?} */
  4364. const changes = this._differ.diff(this._ngForOf);
  4365. if (changes)
  4366. this._applyChanges(changes);
  4367. }
  4368. }
  4369. /**
  4370. * @private
  4371. * @param {?} changes
  4372. * @return {?}
  4373. */
  4374. _applyChanges(changes) {
  4375. /** @type {?} */
  4376. const insertTuples = [];
  4377. changes.forEachOperation((/**
  4378. * @param {?} item
  4379. * @param {?} adjustedPreviousIndex
  4380. * @param {?} currentIndex
  4381. * @return {?}
  4382. */
  4383. (item, adjustedPreviousIndex, currentIndex) => {
  4384. if (item.previousIndex == null) {
  4385. /** @type {?} */
  4386. const view = this._viewContainer.createEmbeddedView(this._template, new NgForOfContext((/** @type {?} */ (null)), this._ngForOf, -1, -1), currentIndex);
  4387. /** @type {?} */
  4388. const tuple = new RecordViewTuple(item, view);
  4389. insertTuples.push(tuple);
  4390. }
  4391. else if (currentIndex == null) {
  4392. this._viewContainer.remove(adjustedPreviousIndex);
  4393. }
  4394. else {
  4395. /** @type {?} */
  4396. const view = (/** @type {?} */ (this._viewContainer.get(adjustedPreviousIndex)));
  4397. this._viewContainer.move(view, currentIndex);
  4398. /** @type {?} */
  4399. const tuple = new RecordViewTuple(item, (/** @type {?} */ (view)));
  4400. insertTuples.push(tuple);
  4401. }
  4402. }));
  4403. for (let i = 0; i < insertTuples.length; i++) {
  4404. this._perViewChange(insertTuples[i].view, insertTuples[i].record);
  4405. }
  4406. for (let i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
  4407. /** @type {?} */
  4408. const viewRef = (/** @type {?} */ (this._viewContainer.get(i)));
  4409. viewRef.context.index = i;
  4410. viewRef.context.count = ilen;
  4411. viewRef.context.ngForOf = this._ngForOf;
  4412. }
  4413. changes.forEachIdentityChange((/**
  4414. * @param {?} record
  4415. * @return {?}
  4416. */
  4417. (record) => {
  4418. /** @type {?} */
  4419. const viewRef = (/** @type {?} */ (this._viewContainer.get(record.currentIndex)));
  4420. viewRef.context.$implicit = record.item;
  4421. }));
  4422. }
  4423. /**
  4424. * @private
  4425. * @param {?} view
  4426. * @param {?} record
  4427. * @return {?}
  4428. */
  4429. _perViewChange(view, record) {
  4430. view.context.$implicit = record.item;
  4431. }
  4432. /**
  4433. * Asserts the correct type of the context for the template that `NgForOf` will render.
  4434. *
  4435. * The presence of this method is a signal to the Ivy template type-check compiler that the
  4436. * `NgForOf` structural directive renders its template with a specific context type.
  4437. * @template T
  4438. * @param {?} dir
  4439. * @param {?} ctx
  4440. * @return {?}
  4441. */
  4442. static ngTemplateContextGuard(dir, ctx) {
  4443. return true;
  4444. }
  4445. }
  4446. NgForOf.decorators = [
  4447. { type: Directive, args: [{ selector: '[ngFor][ngForOf]' },] }
  4448. ];
  4449. /** @nocollapse */
  4450. NgForOf.ctorParameters = () => [
  4451. { type: ViewContainerRef },
  4452. { type: TemplateRef },
  4453. { type: IterableDiffers }
  4454. ];
  4455. NgForOf.propDecorators = {
  4456. ngForOf: [{ type: Input }],
  4457. ngForTrackBy: [{ type: Input }],
  4458. ngForTemplate: [{ type: Input }]
  4459. };
  4460. /**
  4461. * @template T
  4462. */
  4463. class RecordViewTuple {
  4464. /**
  4465. * @param {?} record
  4466. * @param {?} view
  4467. */
  4468. constructor(record, view) {
  4469. this.record = record;
  4470. this.view = view;
  4471. }
  4472. }
  4473. /**
  4474. * @param {?} type
  4475. * @return {?}
  4476. */
  4477. function getTypeName(type) {
  4478. return type['name'] || typeof type;
  4479. }
  4480. /**
  4481. * @fileoverview added by tsickle
  4482. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4483. */
  4484. /**
  4485. * A structural directive that conditionally includes a template based on the value of
  4486. * an expression coerced to Boolean.
  4487. * When the expression evaluates to true, Angular renders the template
  4488. * provided in a `then` clause, and when false or null,
  4489. * Angular renders the template provided in an optional `else` clause. The default
  4490. * template for the `else` clause is blank.
  4491. *
  4492. * A [shorthand form](guide/structural-directives#the-asterisk--prefix) of the directive,
  4493. * `*ngIf="condition"`, is generally used, provided
  4494. * as an attribute of the anchor element for the inserted template.
  4495. * Angular expands this into a more explicit version, in which the anchor element
  4496. * is contained in an `<ng-template>` element.
  4497. *
  4498. * Simple form with shorthand syntax:
  4499. *
  4500. * ```
  4501. * <div *ngIf="condition">Content to render when condition is true.</div>
  4502. * ```
  4503. *
  4504. * Simple form with expanded syntax:
  4505. *
  4506. * ```
  4507. * <ng-template [ngIf]="condition"><div>Content to render when condition is
  4508. * true.</div></ng-template>
  4509. * ```
  4510. *
  4511. * Form with an "else" block:
  4512. *
  4513. * ```
  4514. * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
  4515. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  4516. * ```
  4517. *
  4518. * Shorthand form with "then" and "else" blocks:
  4519. *
  4520. * ```
  4521. * <div *ngIf="condition; then thenBlock else elseBlock"></div>
  4522. * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
  4523. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  4524. * ```
  4525. *
  4526. * Form with storing the value locally:
  4527. *
  4528. * ```
  4529. * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
  4530. * <ng-template #elseBlock>Content to render when value is null.</ng-template>
  4531. * ```
  4532. *
  4533. * \@usageNotes
  4534. *
  4535. * The `*ngIf` directive is most commonly used to conditionally show an inline template,
  4536. * as seen in the following example.
  4537. * The default `else` template is blank.
  4538. *
  4539. * {\@example common/ngIf/ts/module.ts region='NgIfSimple'}
  4540. *
  4541. * ### Showing an alternative template using `else`
  4542. *
  4543. * To display a template when `expression` evaluates to false, use an `else` template
  4544. * binding as shown in the following example.
  4545. * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
  4546. * The template can be defined anywhere in the component view, but is typically placed right after
  4547. * `ngIf` for readability.
  4548. *
  4549. * {\@example common/ngIf/ts/module.ts region='NgIfElse'}
  4550. *
  4551. * ### Using an external `then` template
  4552. *
  4553. * In the previous example, the then-clause template is specified inline, as the content of the
  4554. * tag that contains the `ngIf` directive. You can also specify a template that is defined
  4555. * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
  4556. * change which template to use at runtime, as shown in the following example.
  4557. *
  4558. * {\@example common/ngIf/ts/module.ts region='NgIfThenElse'}
  4559. *
  4560. * ### Storing a conditional result in a variable
  4561. *
  4562. * You might want to show a set of properties from the same object. If you are waiting
  4563. * for asynchronous data, the object can be undefined.
  4564. * In this case, you can use `ngIf` and store the result of the condition in a local
  4565. * variable as shown in the the following example.
  4566. *
  4567. * {\@example common/ngIf/ts/module.ts region='NgIfAs'}
  4568. *
  4569. * This code uses only one `AsyncPipe`, so only one subscription is created.
  4570. * The conditional statement stores the result of `userStream|async` in the local variable `user`.
  4571. * You can then bind the local `user` repeatedly.
  4572. *
  4573. * The conditional displays the data only if `userStream` returns a value,
  4574. * so you don't need to use the
  4575. * [safe-navigation-operator](guide/template-syntax#safe-navigation-operator) (`?.`)
  4576. * to guard against null values when accessing properties.
  4577. * You can display an alternative template while waiting for the data.
  4578. *
  4579. * ### Shorthand syntax
  4580. *
  4581. * The shorthand syntax `*ngIf` expands into two separate template specifications
  4582. * for the "then" and "else" clauses. For example, consider the following shorthand statement,
  4583. * that is meant to show a loading page while waiting for data to be loaded.
  4584. *
  4585. * ```
  4586. * <div class="hero-list" *ngIf="heroes else loading">
  4587. * ...
  4588. * </div>
  4589. *
  4590. * <ng-template #loading>
  4591. * <div>Loading...</div>
  4592. * </ng-template>
  4593. * ```
  4594. *
  4595. * You can see that the "else" clause references the `<ng-template>`
  4596. * with the `#loading` label, and the template for the "then" clause
  4597. * is provided as the content of the anchor element.
  4598. *
  4599. * However, when Angular expands the shorthand syntax, it creates
  4600. * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
  4601. * The anchor element containing the template for the "then" clause becomes
  4602. * the content of this unlabeled `<ng-template>` tag.
  4603. *
  4604. * ```
  4605. * <ng-template [ngIf]="hero-list" [ngIfElse]="loading">
  4606. * <div class="hero-list">
  4607. * ...
  4608. * </div>
  4609. * </ng-template>
  4610. *
  4611. * <ng-template #loading>
  4612. * <div>Loading...</div>
  4613. * </ng-template>
  4614. * ```
  4615. *
  4616. * The presence of the implicit template object has implications for the nesting of
  4617. * structural directives. For more on this subject, see
  4618. * [Structural Directives](https://angular.io/guide/structural-directives#one-per-element).
  4619. *
  4620. * \@ngModule CommonModule
  4621. * \@publicApi
  4622. */
  4623. class NgIf {
  4624. /**
  4625. * @param {?} _viewContainer
  4626. * @param {?} templateRef
  4627. */
  4628. constructor(_viewContainer, templateRef) {
  4629. this._viewContainer = _viewContainer;
  4630. this._context = new NgIfContext();
  4631. this._thenTemplateRef = null;
  4632. this._elseTemplateRef = null;
  4633. this._thenViewRef = null;
  4634. this._elseViewRef = null;
  4635. this._thenTemplateRef = templateRef;
  4636. }
  4637. /**
  4638. * The Boolean expression to evaluate as the condition for showing a template.
  4639. * @param {?} condition
  4640. * @return {?}
  4641. */
  4642. set ngIf(condition) {
  4643. this._context.$implicit = this._context.ngIf = condition;
  4644. this._updateView();
  4645. }
  4646. /**
  4647. * A template to show if the condition expression evaluates to true.
  4648. * @param {?} templateRef
  4649. * @return {?}
  4650. */
  4651. set ngIfThen(templateRef) {
  4652. assertTemplate('ngIfThen', templateRef);
  4653. this._thenTemplateRef = templateRef;
  4654. this._thenViewRef = null; // clear previous view if any.
  4655. this._updateView();
  4656. }
  4657. /**
  4658. * A template to show if the condition expression evaluates to false.
  4659. * @param {?} templateRef
  4660. * @return {?}
  4661. */
  4662. set ngIfElse(templateRef) {
  4663. assertTemplate('ngIfElse', templateRef);
  4664. this._elseTemplateRef = templateRef;
  4665. this._elseViewRef = null; // clear previous view if any.
  4666. this._updateView();
  4667. }
  4668. /**
  4669. * @private
  4670. * @return {?}
  4671. */
  4672. _updateView() {
  4673. if (this._context.$implicit) {
  4674. if (!this._thenViewRef) {
  4675. this._viewContainer.clear();
  4676. this._elseViewRef = null;
  4677. if (this._thenTemplateRef) {
  4678. this._thenViewRef =
  4679. this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
  4680. }
  4681. }
  4682. }
  4683. else {
  4684. if (!this._elseViewRef) {
  4685. this._viewContainer.clear();
  4686. this._thenViewRef = null;
  4687. if (this._elseTemplateRef) {
  4688. this._elseViewRef =
  4689. this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
  4690. }
  4691. }
  4692. }
  4693. }
  4694. }
  4695. NgIf.decorators = [
  4696. { type: Directive, args: [{ selector: '[ngIf]' },] }
  4697. ];
  4698. /** @nocollapse */
  4699. NgIf.ctorParameters = () => [
  4700. { type: ViewContainerRef },
  4701. { type: TemplateRef }
  4702. ];
  4703. NgIf.propDecorators = {
  4704. ngIf: [{ type: Input }],
  4705. ngIfThen: [{ type: Input }],
  4706. ngIfElse: [{ type: Input }]
  4707. };
  4708. /**
  4709. * \@publicApi
  4710. */
  4711. class NgIfContext {
  4712. constructor() {
  4713. this.$implicit = null;
  4714. this.ngIf = null;
  4715. }
  4716. }
  4717. /**
  4718. * @param {?} property
  4719. * @param {?} templateRef
  4720. * @return {?}
  4721. */
  4722. function assertTemplate(property, templateRef) {
  4723. /** @type {?} */
  4724. const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
  4725. if (!isTemplateRefOrNull) {
  4726. throw new Error(`${property} must be a TemplateRef, but received '${ɵstringify(templateRef)}'.`);
  4727. }
  4728. }
  4729. /**
  4730. * @fileoverview added by tsickle
  4731. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4732. */
  4733. class SwitchView {
  4734. /**
  4735. * @param {?} _viewContainerRef
  4736. * @param {?} _templateRef
  4737. */
  4738. constructor(_viewContainerRef, _templateRef) {
  4739. this._viewContainerRef = _viewContainerRef;
  4740. this._templateRef = _templateRef;
  4741. this._created = false;
  4742. }
  4743. /**
  4744. * @return {?}
  4745. */
  4746. create() {
  4747. this._created = true;
  4748. this._viewContainerRef.createEmbeddedView(this._templateRef);
  4749. }
  4750. /**
  4751. * @return {?}
  4752. */
  4753. destroy() {
  4754. this._created = false;
  4755. this._viewContainerRef.clear();
  4756. }
  4757. /**
  4758. * @param {?} created
  4759. * @return {?}
  4760. */
  4761. enforceState(created) {
  4762. if (created && !this._created) {
  4763. this.create();
  4764. }
  4765. else if (!created && this._created) {
  4766. this.destroy();
  4767. }
  4768. }
  4769. }
  4770. /**
  4771. * \@ngModule CommonModule
  4772. *
  4773. * \@description A structural directive that adds or removes templates (displaying or hiding views)
  4774. * when the next match expression matches the switch expression.
  4775. *
  4776. * The `[ngSwitch]` directive on a container specifies an expression to match against.
  4777. * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
  4778. * - Every view that matches is rendered.
  4779. * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
  4780. * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
  4781. * or `ngSwitchDefault` directive are preserved at the location.
  4782. *
  4783. * \@usageNotes
  4784. * Define a container element for the directive, and specify the switch expression
  4785. * to match against as an attribute:
  4786. *
  4787. * ```
  4788. * <container-element [ngSwitch]="switch_expression">
  4789. * ```
  4790. *
  4791. * Within the container, `*ngSwitchCase` statements specify the match expressions
  4792. * as attributes. Include `*ngSwitchDefault` as the final case.
  4793. *
  4794. * ```
  4795. * <container-element [ngSwitch]="switch_expression">
  4796. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4797. * ...
  4798. * <some-element *ngSwitchDefault>...</some-element>
  4799. * </container-element>
  4800. * ```
  4801. *
  4802. * ### Usage Examples
  4803. *
  4804. * The following example shows how to use more than one case to display the same view:
  4805. *
  4806. * ```
  4807. * <container-element [ngSwitch]="switch_expression">
  4808. * <!-- the same view can be shown in more than one case -->
  4809. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4810. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  4811. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  4812. * <!--default case when there are no matches -->
  4813. * <some-element *ngSwitchDefault>...</some-element>
  4814. * </container-element>
  4815. * ```
  4816. *
  4817. * The following example shows how cases can be nested:
  4818. * ```
  4819. * <container-element [ngSwitch]="switch_expression">
  4820. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4821. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  4822. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  4823. * <ng-container *ngSwitchCase="match_expression_3">
  4824. * <!-- use a ng-container to group multiple root nodes -->
  4825. * <inner-element></inner-element>
  4826. * <inner-other-element></inner-other-element>
  4827. * </ng-container>
  4828. * <some-element *ngSwitchDefault>...</some-element>
  4829. * </container-element>
  4830. * ```
  4831. *
  4832. * \@publicApi
  4833. * @see `NgSwitchCase`
  4834. * @see `NgSwitchDefault`
  4835. * @see [Structural Directives](guide/structural-directives)
  4836. *
  4837. */
  4838. class NgSwitch {
  4839. constructor() {
  4840. this._defaultUsed = false;
  4841. this._caseCount = 0;
  4842. this._lastCaseCheckIndex = 0;
  4843. this._lastCasesMatched = false;
  4844. }
  4845. /**
  4846. * @param {?} newValue
  4847. * @return {?}
  4848. */
  4849. set ngSwitch(newValue) {
  4850. this._ngSwitch = newValue;
  4851. if (this._caseCount === 0) {
  4852. this._updateDefaultCases(true);
  4853. }
  4854. }
  4855. /**
  4856. * \@internal
  4857. * @return {?}
  4858. */
  4859. _addCase() { return this._caseCount++; }
  4860. /**
  4861. * \@internal
  4862. * @param {?} view
  4863. * @return {?}
  4864. */
  4865. _addDefault(view) {
  4866. if (!this._defaultViews) {
  4867. this._defaultViews = [];
  4868. }
  4869. this._defaultViews.push(view);
  4870. }
  4871. /**
  4872. * \@internal
  4873. * @param {?} value
  4874. * @return {?}
  4875. */
  4876. _matchCase(value) {
  4877. /** @type {?} */
  4878. const matched = value == this._ngSwitch;
  4879. this._lastCasesMatched = this._lastCasesMatched || matched;
  4880. this._lastCaseCheckIndex++;
  4881. if (this._lastCaseCheckIndex === this._caseCount) {
  4882. this._updateDefaultCases(!this._lastCasesMatched);
  4883. this._lastCaseCheckIndex = 0;
  4884. this._lastCasesMatched = false;
  4885. }
  4886. return matched;
  4887. }
  4888. /**
  4889. * @private
  4890. * @param {?} useDefault
  4891. * @return {?}
  4892. */
  4893. _updateDefaultCases(useDefault) {
  4894. if (this._defaultViews && useDefault !== this._defaultUsed) {
  4895. this._defaultUsed = useDefault;
  4896. for (let i = 0; i < this._defaultViews.length; i++) {
  4897. /** @type {?} */
  4898. const defaultView = this._defaultViews[i];
  4899. defaultView.enforceState(useDefault);
  4900. }
  4901. }
  4902. }
  4903. }
  4904. NgSwitch.decorators = [
  4905. { type: Directive, args: [{ selector: '[ngSwitch]' },] }
  4906. ];
  4907. NgSwitch.propDecorators = {
  4908. ngSwitch: [{ type: Input }]
  4909. };
  4910. /**
  4911. * \@ngModule CommonModule
  4912. *
  4913. * \@description
  4914. * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
  4915. * When the expressions match, the given `NgSwitchCase` template is rendered.
  4916. * If multiple match expressions match the switch expression value, all of them are displayed.
  4917. *
  4918. * \@usageNotes
  4919. *
  4920. * Within a switch container, `*ngSwitchCase` statements specify the match expressions
  4921. * as attributes. Include `*ngSwitchDefault` as the final case.
  4922. *
  4923. * ```
  4924. * <container-element [ngSwitch]="switch_expression">
  4925. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4926. * ...
  4927. * <some-element *ngSwitchDefault>...</some-element>
  4928. * </container-element>
  4929. * ```
  4930. *
  4931. * Each switch-case statement contains an in-line HTML template or template reference
  4932. * that defines the subtree to be selected if the value of the match expression
  4933. * matches the value of the switch expression.
  4934. *
  4935. * Unlike JavaScript, which uses strict equality, Angular uses loose equality.
  4936. * This means that the empty string, `""` matches 0.
  4937. *
  4938. * \@publicApi
  4939. * @see `NgSwitch`
  4940. * @see `NgSwitchDefault`
  4941. *
  4942. */
  4943. class NgSwitchCase {
  4944. /**
  4945. * @param {?} viewContainer
  4946. * @param {?} templateRef
  4947. * @param {?} ngSwitch
  4948. */
  4949. constructor(viewContainer, templateRef, ngSwitch) {
  4950. this.ngSwitch = ngSwitch;
  4951. ngSwitch._addCase();
  4952. this._view = new SwitchView(viewContainer, templateRef);
  4953. }
  4954. /**
  4955. * Performs case matching. For internal use only.
  4956. * @return {?}
  4957. */
  4958. ngDoCheck() { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); }
  4959. }
  4960. NgSwitchCase.decorators = [
  4961. { type: Directive, args: [{ selector: '[ngSwitchCase]' },] }
  4962. ];
  4963. /** @nocollapse */
  4964. NgSwitchCase.ctorParameters = () => [
  4965. { type: ViewContainerRef },
  4966. { type: TemplateRef },
  4967. { type: NgSwitch, decorators: [{ type: Host }] }
  4968. ];
  4969. NgSwitchCase.propDecorators = {
  4970. ngSwitchCase: [{ type: Input }]
  4971. };
  4972. /**
  4973. * \@ngModule CommonModule
  4974. *
  4975. * \@description
  4976. *
  4977. * Creates a view that is rendered when no `NgSwitchCase` expressions
  4978. * match the `NgSwitch` expression.
  4979. * This statement should be the final case in an `NgSwitch`.
  4980. *
  4981. * \@publicApi
  4982. * @see `NgSwitch`
  4983. * @see `NgSwitchCase`
  4984. *
  4985. */
  4986. class NgSwitchDefault {
  4987. /**
  4988. * @param {?} viewContainer
  4989. * @param {?} templateRef
  4990. * @param {?} ngSwitch
  4991. */
  4992. constructor(viewContainer, templateRef, ngSwitch) {
  4993. ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
  4994. }
  4995. }
  4996. NgSwitchDefault.decorators = [
  4997. { type: Directive, args: [{ selector: '[ngSwitchDefault]' },] }
  4998. ];
  4999. /** @nocollapse */
  5000. NgSwitchDefault.ctorParameters = () => [
  5001. { type: ViewContainerRef },
  5002. { type: TemplateRef },
  5003. { type: NgSwitch, decorators: [{ type: Host }] }
  5004. ];
  5005. /**
  5006. * @fileoverview added by tsickle
  5007. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5008. */
  5009. /**
  5010. * \@ngModule CommonModule
  5011. *
  5012. * \@usageNotes
  5013. * ```
  5014. * <some-element [ngPlural]="value">
  5015. * <ng-template ngPluralCase="=0">there is nothing</ng-template>
  5016. * <ng-template ngPluralCase="=1">there is one</ng-template>
  5017. * <ng-template ngPluralCase="few">there are a few</ng-template>
  5018. * </some-element>
  5019. * ```
  5020. *
  5021. * \@description
  5022. *
  5023. * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
  5024. *
  5025. * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
  5026. * that match the switch expression's pluralization category.
  5027. *
  5028. * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
  5029. * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
  5030. * expression:
  5031. * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
  5032. * matches the switch expression exactly,
  5033. * - otherwise, the view will be treated as a "category match", and will only display if exact
  5034. * value matches aren't found and the value maps to its category for the defined locale.
  5035. *
  5036. * See http://cldr.unicode.org/index/cldr-spec/plural-rules
  5037. *
  5038. * \@publicApi
  5039. */
  5040. class NgPlural {
  5041. /**
  5042. * @param {?} _localization
  5043. */
  5044. constructor(_localization) {
  5045. this._localization = _localization;
  5046. this._caseViews = {};
  5047. }
  5048. /**
  5049. * @param {?} value
  5050. * @return {?}
  5051. */
  5052. set ngPlural(value) {
  5053. this._switchValue = value;
  5054. this._updateView();
  5055. }
  5056. /**
  5057. * @param {?} value
  5058. * @param {?} switchView
  5059. * @return {?}
  5060. */
  5061. addCase(value, switchView) { this._caseViews[value] = switchView; }
  5062. /**
  5063. * @private
  5064. * @return {?}
  5065. */
  5066. _updateView() {
  5067. this._clearViews();
  5068. /** @type {?} */
  5069. const cases = Object.keys(this._caseViews);
  5070. /** @type {?} */
  5071. const key = getPluralCategory(this._switchValue, cases, this._localization);
  5072. this._activateView(this._caseViews[key]);
  5073. }
  5074. /**
  5075. * @private
  5076. * @return {?}
  5077. */
  5078. _clearViews() {
  5079. if (this._activeView)
  5080. this._activeView.destroy();
  5081. }
  5082. /**
  5083. * @private
  5084. * @param {?} view
  5085. * @return {?}
  5086. */
  5087. _activateView(view) {
  5088. if (view) {
  5089. this._activeView = view;
  5090. this._activeView.create();
  5091. }
  5092. }
  5093. }
  5094. NgPlural.decorators = [
  5095. { type: Directive, args: [{ selector: '[ngPlural]' },] }
  5096. ];
  5097. /** @nocollapse */
  5098. NgPlural.ctorParameters = () => [
  5099. { type: NgLocalization }
  5100. ];
  5101. NgPlural.propDecorators = {
  5102. ngPlural: [{ type: Input }]
  5103. };
  5104. /**
  5105. * \@ngModule CommonModule
  5106. *
  5107. * \@description
  5108. *
  5109. * Creates a view that will be added/removed from the parent {\@link NgPlural} when the
  5110. * given expression matches the plural expression according to CLDR rules.
  5111. *
  5112. * \@usageNotes
  5113. * ```
  5114. * <some-element [ngPlural]="value">
  5115. * <ng-template ngPluralCase="=0">...</ng-template>
  5116. * <ng-template ngPluralCase="other">...</ng-template>
  5117. * </some-element>
  5118. * ```
  5119. *
  5120. * See {\@link NgPlural} for more details and example.
  5121. *
  5122. * \@publicApi
  5123. */
  5124. class NgPluralCase {
  5125. /**
  5126. * @param {?} value
  5127. * @param {?} template
  5128. * @param {?} viewContainer
  5129. * @param {?} ngPlural
  5130. */
  5131. constructor(value, template, viewContainer, ngPlural) {
  5132. this.value = value;
  5133. /** @type {?} */
  5134. const isANumber = !isNaN(Number(value));
  5135. ngPlural.addCase(isANumber ? `=${value}` : value, new SwitchView(viewContainer, template));
  5136. }
  5137. }
  5138. NgPluralCase.decorators = [
  5139. { type: Directive, args: [{ selector: '[ngPluralCase]' },] }
  5140. ];
  5141. /** @nocollapse */
  5142. NgPluralCase.ctorParameters = () => [
  5143. { type: String, decorators: [{ type: Attribute, args: ['ngPluralCase',] }] },
  5144. { type: TemplateRef },
  5145. { type: ViewContainerRef },
  5146. { type: NgPlural, decorators: [{ type: Host }] }
  5147. ];
  5148. /**
  5149. * @fileoverview added by tsickle
  5150. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5151. */
  5152. /**
  5153. * Used as a token for an injected service within the NgStyle directive.
  5154. *
  5155. * NgStyle behaves differenly whether or not VE is being used or not. If
  5156. * present then the legacy ngClass diffing algorithm will be used as an
  5157. * injected service. Otherwise the new diffing algorithm (which delegates
  5158. * to the `[style]` binding) will be used. This toggle behavior is done so
  5159. * via the ivy_switch mechanism.
  5160. * @abstract
  5161. */
  5162. class NgStyleImpl {
  5163. }
  5164. class NgStyleR2Impl {
  5165. /**
  5166. * @param {?} _ngEl
  5167. * @param {?} _differs
  5168. * @param {?} _renderer
  5169. */
  5170. constructor(_ngEl, _differs, _renderer) {
  5171. this._ngEl = _ngEl;
  5172. this._differs = _differs;
  5173. this._renderer = _renderer;
  5174. }
  5175. /**
  5176. * @return {?}
  5177. */
  5178. getValue() { return null; }
  5179. /**
  5180. * A map of style properties, specified as colon-separated
  5181. * key-value pairs.
  5182. * * The key is a style name, with an optional `.<unit>` suffix
  5183. * (such as 'top.px', 'font-style.em').
  5184. * * The value is an expression to be evaluated.
  5185. * @param {?} values
  5186. * @return {?}
  5187. */
  5188. setNgStyle(values) {
  5189. this._ngStyle = values;
  5190. if (!this._differ && values) {
  5191. this._differ = this._differs.find(values).create();
  5192. }
  5193. }
  5194. /**
  5195. * Applies the new styles if needed.
  5196. * @return {?}
  5197. */
  5198. applyChanges() {
  5199. if (this._differ) {
  5200. /** @type {?} */
  5201. const changes = this._differ.diff(this._ngStyle);
  5202. if (changes) {
  5203. this._applyChanges(changes);
  5204. }
  5205. }
  5206. }
  5207. /**
  5208. * @private
  5209. * @param {?} changes
  5210. * @return {?}
  5211. */
  5212. _applyChanges(changes) {
  5213. changes.forEachRemovedItem((/**
  5214. * @param {?} record
  5215. * @return {?}
  5216. */
  5217. (record) => this._setStyle(record.key, null)));
  5218. changes.forEachAddedItem((/**
  5219. * @param {?} record
  5220. * @return {?}
  5221. */
  5222. (record) => this._setStyle(record.key, record.currentValue)));
  5223. changes.forEachChangedItem((/**
  5224. * @param {?} record
  5225. * @return {?}
  5226. */
  5227. (record) => this._setStyle(record.key, record.currentValue)));
  5228. }
  5229. /**
  5230. * @private
  5231. * @param {?} nameAndUnit
  5232. * @param {?} value
  5233. * @return {?}
  5234. */
  5235. _setStyle(nameAndUnit, value) {
  5236. const [name, unit] = nameAndUnit.split('.');
  5237. value = value != null && unit ? `${value}${unit}` : value;
  5238. if (value != null) {
  5239. this._renderer.setStyle(this._ngEl.nativeElement, name, (/** @type {?} */ (value)));
  5240. }
  5241. else {
  5242. this._renderer.removeStyle(this._ngEl.nativeElement, name);
  5243. }
  5244. }
  5245. }
  5246. NgStyleR2Impl.decorators = [
  5247. { type: Injectable }
  5248. ];
  5249. /** @nocollapse */
  5250. NgStyleR2Impl.ctorParameters = () => [
  5251. { type: ElementRef },
  5252. { type: KeyValueDiffers },
  5253. { type: Renderer2 }
  5254. ];
  5255. class NgStyleR3Impl {
  5256. constructor() {
  5257. this._differ = new StylingDiffer('NgStyle', 8 /* AllowUnits */);
  5258. this._value = null;
  5259. }
  5260. /**
  5261. * @return {?}
  5262. */
  5263. getValue() { return this._value; }
  5264. /**
  5265. * @param {?} value
  5266. * @return {?}
  5267. */
  5268. setNgStyle(value) { this._differ.setValue(value); }
  5269. /**
  5270. * @return {?}
  5271. */
  5272. applyChanges() {
  5273. if (this._differ.hasValueChanged()) {
  5274. this._value = this._differ.value;
  5275. }
  5276. }
  5277. }
  5278. NgStyleR3Impl.decorators = [
  5279. { type: Injectable }
  5280. ];
  5281. // the implementation for both NgClassR2Impl and NgClassR3Impl are
  5282. // not ivy_switch'd away, instead they are only hooked up into the
  5283. // DI via NgStyle's directive's provider property.
  5284. /** @type {?} */
  5285. const NgStyleImplProvider__PRE_R3__ = {
  5286. provide: NgStyleImpl,
  5287. useClass: NgStyleR2Impl
  5288. };
  5289. /** @type {?} */
  5290. const NgStyleImplProvider__POST_R3__ = {
  5291. provide: NgStyleImpl,
  5292. useClass: NgStyleR3Impl
  5293. };
  5294. /** @type {?} */
  5295. const NgStyleImplProvider = NgStyleImplProvider__PRE_R3__;
  5296. /**
  5297. * @fileoverview added by tsickle
  5298. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5299. */
  5300. /*
  5301. * NgStyle (as well as NgClass) behaves differently when loaded in the VE and when not.
  5302. *
  5303. * If the VE is present (which is for older versions of Angular) then NgStyle will inject
  5304. * the legacy diffing algorithm as a service and delegate all styling changes to that.
  5305. *
  5306. * If the VE is not present then NgStyle will normalize (through the injected service) and
  5307. * then write all styling changes to the `[style]` binding directly (through a host binding).
  5308. * Then Angular will notice the host binding change and treat the changes as styling
  5309. * changes and apply them via the core styling instructions that exist within Angular.
  5310. */
  5311. // used when the VE is present
  5312. /** @type {?} */
  5313. const ngStyleDirectiveDef__PRE_R3__ = undefined;
  5314. // used when the VE is not present (note the directive will
  5315. // never be instantiated normally because it is apart of a
  5316. // base class)
  5317. const ɵ0$1 = /**
  5318. * @return {?}
  5319. */
  5320. function () { }, ɵ1$1 = /**
  5321. * @return {?}
  5322. */
  5323. () => { }, ɵ2$1 = /**
  5324. * @param {?} rf
  5325. * @param {?} ctx
  5326. * @param {?} elIndex
  5327. * @return {?}
  5328. */
  5329. function (rf, ctx, elIndex) {
  5330. if (rf & 1 /* Create */) {
  5331. ɵɵstyling();
  5332. }
  5333. if (rf & 2 /* Update */) {
  5334. ɵɵstyleMap(ctx.getValue());
  5335. ɵɵstylingApply();
  5336. }
  5337. };
  5338. /** @type {?} */
  5339. const ngStyleDirectiveDef__POST_R3__ = ɵɵdefineDirective({
  5340. type: (/** @type {?} */ ((ɵ0$1))),
  5341. selectors: (/** @type {?} */ (null)),
  5342. factory: (ɵ1$1),
  5343. hostBindings: (ɵ2$1)
  5344. });
  5345. /** @type {?} */
  5346. const ngStyleDirectiveDef = ngStyleDirectiveDef__PRE_R3__;
  5347. /**
  5348. * Serves as the base non-VE container for NgStyle.
  5349. *
  5350. * While this is a base class that NgStyle extends from, the
  5351. * class itself acts as a container for non-VE code to setup
  5352. * a link to the `[style]` host binding (via the static
  5353. * `ngDirectiveDef` property on the class).
  5354. *
  5355. * Note that the `ngDirectiveDef` property's code is switched
  5356. * depending if VE is present or not (this allows for the
  5357. * binding code to be set only for newer versions of Angular).
  5358. *
  5359. * \@publicApi
  5360. */
  5361. class NgStyleBase {
  5362. /**
  5363. * @param {?} _delegate
  5364. */
  5365. constructor(_delegate) {
  5366. this._delegate = _delegate;
  5367. }
  5368. /**
  5369. * @return {?}
  5370. */
  5371. getValue() { return this._delegate.getValue(); }
  5372. }
  5373. /** @nocollapse */ NgStyleBase.ngDirectiveDef = ngStyleDirectiveDef;
  5374. /**
  5375. * \@ngModule CommonModule
  5376. *
  5377. * \@usageNotes
  5378. *
  5379. * Set the font of the containing element to the result of an expression.
  5380. *
  5381. * ```
  5382. * <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
  5383. * ```
  5384. *
  5385. * Set the width of the containing element to a pixel value returned by an expression.
  5386. *
  5387. * ```
  5388. * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
  5389. * ```
  5390. *
  5391. * Set a collection of style values using an expression that returns key-value pairs.
  5392. *
  5393. * ```
  5394. * <some-element [ngStyle]="objExp">...</some-element>
  5395. * ```
  5396. *
  5397. * \@description
  5398. *
  5399. * An attribute directive that updates styles for the containing HTML element.
  5400. * Sets one or more style properties, specified as colon-separated key-value pairs.
  5401. * The key is a style name, with an optional `.<unit>` suffix
  5402. * (such as 'top.px', 'font-style.em').
  5403. * The value is an expression to be evaluated.
  5404. * The resulting non-null value, expressed in the given unit,
  5405. * is assigned to the given style property.
  5406. * If the result of evaluation is null, the corresponding style is removed.
  5407. *
  5408. * \@publicApi
  5409. */
  5410. class NgStyle extends NgStyleBase {
  5411. /**
  5412. * @param {?} delegate
  5413. */
  5414. constructor(delegate) { super(delegate); }
  5415. /**
  5416. * @param {?} value
  5417. * @return {?}
  5418. */
  5419. set ngStyle(value) { this._delegate.setNgStyle(value); }
  5420. /**
  5421. * @return {?}
  5422. */
  5423. ngDoCheck() { this._delegate.applyChanges(); }
  5424. }
  5425. NgStyle.decorators = [
  5426. { type: Directive, args: [{ selector: '[ngStyle]', providers: [NgStyleImplProvider] },] }
  5427. ];
  5428. /** @nocollapse */
  5429. NgStyle.ctorParameters = () => [
  5430. { type: NgStyleImpl }
  5431. ];
  5432. NgStyle.propDecorators = {
  5433. ngStyle: [{ type: Input, args: ['ngStyle',] }]
  5434. };
  5435. /**
  5436. * @fileoverview added by tsickle
  5437. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5438. */
  5439. /**
  5440. * \@ngModule CommonModule
  5441. *
  5442. * \@description
  5443. *
  5444. * Inserts an embedded view from a prepared `TemplateRef`.
  5445. *
  5446. * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
  5447. * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
  5448. * by the local template `let` declarations.
  5449. *
  5450. * \@usageNotes
  5451. * ```
  5452. * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
  5453. * ```
  5454. *
  5455. * Using the key `$implicit` in the context object will set its value as default.
  5456. *
  5457. * ### Example
  5458. *
  5459. * {\@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
  5460. *
  5461. * \@publicApi
  5462. */
  5463. class NgTemplateOutlet {
  5464. /**
  5465. * @param {?} _viewContainerRef
  5466. */
  5467. constructor(_viewContainerRef) {
  5468. this._viewContainerRef = _viewContainerRef;
  5469. this._viewRef = null;
  5470. /**
  5471. * A context object to attach to the {\@link EmbeddedViewRef}. This should be an
  5472. * object, the object's keys will be available for binding by the local template `let`
  5473. * declarations.
  5474. * Using the key `$implicit` in the context object will set its value as default.
  5475. */
  5476. this.ngTemplateOutletContext = null;
  5477. /**
  5478. * A string defining the template reference and optionally the context object for the template.
  5479. */
  5480. this.ngTemplateOutlet = null;
  5481. }
  5482. /**
  5483. * @param {?} changes
  5484. * @return {?}
  5485. */
  5486. ngOnChanges(changes) {
  5487. /** @type {?} */
  5488. const recreateView = this._shouldRecreateView(changes);
  5489. if (recreateView) {
  5490. if (this._viewRef) {
  5491. this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
  5492. }
  5493. if (this.ngTemplateOutlet) {
  5494. this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
  5495. }
  5496. }
  5497. else {
  5498. if (this._viewRef && this.ngTemplateOutletContext) {
  5499. this._updateExistingContext(this.ngTemplateOutletContext);
  5500. }
  5501. }
  5502. }
  5503. /**
  5504. * We need to re-create existing embedded view if:
  5505. * - templateRef has changed
  5506. * - context has changes
  5507. *
  5508. * We mark context object as changed when the corresponding object
  5509. * shape changes (new properties are added or existing properties are removed).
  5510. * In other words we consider context with the same properties as "the same" even
  5511. * if object reference changes (see https://github.com/angular/angular/issues/13407).
  5512. * @private
  5513. * @param {?} changes
  5514. * @return {?}
  5515. */
  5516. _shouldRecreateView(changes) {
  5517. /** @type {?} */
  5518. const ctxChange = changes['ngTemplateOutletContext'];
  5519. return !!changes['ngTemplateOutlet'] || (ctxChange && this._hasContextShapeChanged(ctxChange));
  5520. }
  5521. /**
  5522. * @private
  5523. * @param {?} ctxChange
  5524. * @return {?}
  5525. */
  5526. _hasContextShapeChanged(ctxChange) {
  5527. /** @type {?} */
  5528. const prevCtxKeys = Object.keys(ctxChange.previousValue || {});
  5529. /** @type {?} */
  5530. const currCtxKeys = Object.keys(ctxChange.currentValue || {});
  5531. if (prevCtxKeys.length === currCtxKeys.length) {
  5532. for (let propName of currCtxKeys) {
  5533. if (prevCtxKeys.indexOf(propName) === -1) {
  5534. return true;
  5535. }
  5536. }
  5537. return false;
  5538. }
  5539. else {
  5540. return true;
  5541. }
  5542. }
  5543. /**
  5544. * @private
  5545. * @param {?} ctx
  5546. * @return {?}
  5547. */
  5548. _updateExistingContext(ctx) {
  5549. for (let propName of Object.keys(ctx)) {
  5550. ((/** @type {?} */ ((/** @type {?} */ (this._viewRef)).context)))[propName] = ((/** @type {?} */ (this.ngTemplateOutletContext)))[propName];
  5551. }
  5552. }
  5553. }
  5554. NgTemplateOutlet.decorators = [
  5555. { type: Directive, args: [{ selector: '[ngTemplateOutlet]' },] }
  5556. ];
  5557. /** @nocollapse */
  5558. NgTemplateOutlet.ctorParameters = () => [
  5559. { type: ViewContainerRef }
  5560. ];
  5561. NgTemplateOutlet.propDecorators = {
  5562. ngTemplateOutletContext: [{ type: Input }],
  5563. ngTemplateOutlet: [{ type: Input }]
  5564. };
  5565. /**
  5566. * @fileoverview added by tsickle
  5567. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5568. */
  5569. /**
  5570. * A collection of Angular directives that are likely to be used in each and every Angular
  5571. * application.
  5572. * @type {?}
  5573. */
  5574. const COMMON_DIRECTIVES = [
  5575. NgClass,
  5576. NgComponentOutlet,
  5577. NgForOf,
  5578. NgIf,
  5579. NgTemplateOutlet,
  5580. NgStyle,
  5581. NgSwitch,
  5582. NgSwitchCase,
  5583. NgSwitchDefault,
  5584. NgPlural,
  5585. NgPluralCase,
  5586. ];
  5587. /**
  5588. * @fileoverview added by tsickle
  5589. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5590. */
  5591. /**
  5592. * @param {?} type
  5593. * @param {?} value
  5594. * @return {?}
  5595. */
  5596. function invalidPipeArgumentError(type, value) {
  5597. return Error(`InvalidPipeArgument: '${value}' for pipe '${ɵstringify(type)}'`);
  5598. }
  5599. /**
  5600. * @fileoverview added by tsickle
  5601. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5602. */
  5603. class NumberFormatter {
  5604. /**
  5605. * @param {?} num
  5606. * @param {?} locale
  5607. * @param {?} style
  5608. * @param {?=} opts
  5609. * @return {?}
  5610. */
  5611. static format(num, locale, style, opts = {}) {
  5612. const { minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits, currency, currencyAsSymbol = false } = opts;
  5613. /** @type {?} */
  5614. const options = {
  5615. minimumIntegerDigits,
  5616. minimumFractionDigits,
  5617. maximumFractionDigits,
  5618. style: NumberFormatStyle[style].toLowerCase()
  5619. };
  5620. if (style == NumberFormatStyle.Currency) {
  5621. options.currency = typeof currency == 'string' ? currency : undefined;
  5622. options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
  5623. }
  5624. return new Intl.NumberFormat(locale, options).format(num);
  5625. }
  5626. }
  5627. /** @type {?} */
  5628. const DATE_FORMATS_SPLIT$1 = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
  5629. /** @type {?} */
  5630. const PATTERN_ALIASES = {
  5631. // Keys are quoted so they do not get renamed during closure compilation.
  5632. 'yMMMdjms': datePartGetterFactory(combine([
  5633. digitCondition('year', 1),
  5634. nameCondition('month', 3),
  5635. digitCondition('day', 1),
  5636. digitCondition('hour', 1),
  5637. digitCondition('minute', 1),
  5638. digitCondition('second', 1),
  5639. ])),
  5640. 'yMdjm': datePartGetterFactory(combine([
  5641. digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
  5642. digitCondition('hour', 1), digitCondition('minute', 1)
  5643. ])),
  5644. 'yMMMMEEEEd': datePartGetterFactory(combine([
  5645. digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
  5646. digitCondition('day', 1)
  5647. ])),
  5648. 'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
  5649. 'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
  5650. 'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
  5651. 'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
  5652. 'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
  5653. };
  5654. /** @type {?} */
  5655. const DATE_FORMATS$1 = {
  5656. // Keys are quoted so they do not get renamed.
  5657. 'yyyy': datePartGetterFactory(digitCondition('year', 4)),
  5658. 'yy': datePartGetterFactory(digitCondition('year', 2)),
  5659. 'y': datePartGetterFactory(digitCondition('year', 1)),
  5660. 'MMMM': datePartGetterFactory(nameCondition('month', 4)),
  5661. 'MMM': datePartGetterFactory(nameCondition('month', 3)),
  5662. 'MM': datePartGetterFactory(digitCondition('month', 2)),
  5663. 'M': datePartGetterFactory(digitCondition('month', 1)),
  5664. 'LLLL': datePartGetterFactory(nameCondition('month', 4)),
  5665. 'L': datePartGetterFactory(nameCondition('month', 1)),
  5666. 'dd': datePartGetterFactory(digitCondition('day', 2)),
  5667. 'd': datePartGetterFactory(digitCondition('day', 1)),
  5668. 'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
  5669. 'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
  5670. 'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
  5671. 'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
  5672. 'jj': datePartGetterFactory(digitCondition('hour', 2)),
  5673. 'j': datePartGetterFactory(digitCondition('hour', 1)),
  5674. 'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
  5675. 'm': datePartGetterFactory(digitCondition('minute', 1)),
  5676. 'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
  5677. 's': datePartGetterFactory(digitCondition('second', 1)),
  5678. // while ISO 8601 requires fractions to be prefixed with `.` or `,`
  5679. // we can be just safely rely on using `sss` since we currently don't support single or two digit
  5680. // fractions
  5681. 'sss': datePartGetterFactory(digitCondition('second', 3)),
  5682. 'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
  5683. 'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
  5684. 'EE': datePartGetterFactory(nameCondition('weekday', 2)),
  5685. 'E': datePartGetterFactory(nameCondition('weekday', 1)),
  5686. 'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
  5687. 'Z': timeZoneGetter$1('short'),
  5688. 'z': timeZoneGetter$1('long'),
  5689. 'ww': datePartGetterFactory({}),
  5690. // Week of year, padded (00-53). Week 01 is the week with the
  5691. // first Thursday of the year. not support ?
  5692. 'w': datePartGetterFactory({}),
  5693. // Week of year (0-53). Week 1 is the week with the first Thursday
  5694. // of the year not support ?
  5695. 'G': datePartGetterFactory(nameCondition('era', 1)),
  5696. 'GG': datePartGetterFactory(nameCondition('era', 2)),
  5697. 'GGG': datePartGetterFactory(nameCondition('era', 3)),
  5698. 'GGGG': datePartGetterFactory(nameCondition('era', 4))
  5699. };
  5700. /**
  5701. * @param {?} inner
  5702. * @return {?}
  5703. */
  5704. function digitModifier(inner) {
  5705. return (/**
  5706. * @param {?} date
  5707. * @param {?} locale
  5708. * @return {?}
  5709. */
  5710. function (date, locale) {
  5711. /** @type {?} */
  5712. const result = inner(date, locale);
  5713. return result.length == 1 ? '0' + result : result;
  5714. });
  5715. }
  5716. /**
  5717. * @param {?} inner
  5718. * @return {?}
  5719. */
  5720. function hourClockExtractor(inner) {
  5721. return (/**
  5722. * @param {?} date
  5723. * @param {?} locale
  5724. * @return {?}
  5725. */
  5726. function (date, locale) { return inner(date, locale).split(' ')[1]; });
  5727. }
  5728. /**
  5729. * @param {?} inner
  5730. * @return {?}
  5731. */
  5732. function hourExtractor(inner) {
  5733. return (/**
  5734. * @param {?} date
  5735. * @param {?} locale
  5736. * @return {?}
  5737. */
  5738. function (date, locale) { return inner(date, locale).split(' ')[0]; });
  5739. }
  5740. /**
  5741. * @param {?} date
  5742. * @param {?} locale
  5743. * @param {?} options
  5744. * @return {?}
  5745. */
  5746. function intlDateFormat(date, locale, options) {
  5747. return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
  5748. }
  5749. /**
  5750. * @param {?} timezone
  5751. * @return {?}
  5752. */
  5753. function timeZoneGetter$1(timezone) {
  5754. // To workaround `Intl` API restriction for single timezone let format with 24 hours
  5755. /** @type {?} */
  5756. const options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
  5757. return (/**
  5758. * @param {?} date
  5759. * @param {?} locale
  5760. * @return {?}
  5761. */
  5762. function (date, locale) {
  5763. /** @type {?} */
  5764. const result = intlDateFormat(date, locale, options);
  5765. // Then extract first 3 letters that related to hours
  5766. return result ? result.substring(3) : '';
  5767. });
  5768. }
  5769. /**
  5770. * @param {?} options
  5771. * @param {?} value
  5772. * @return {?}
  5773. */
  5774. function hour12Modify(options, value) {
  5775. options.hour12 = value;
  5776. return options;
  5777. }
  5778. /**
  5779. * @param {?} prop
  5780. * @param {?} len
  5781. * @return {?}
  5782. */
  5783. function digitCondition(prop, len) {
  5784. /** @type {?} */
  5785. const result = {};
  5786. result[prop] = len === 2 ? '2-digit' : 'numeric';
  5787. return result;
  5788. }
  5789. /**
  5790. * @param {?} prop
  5791. * @param {?} len
  5792. * @return {?}
  5793. */
  5794. function nameCondition(prop, len) {
  5795. /** @type {?} */
  5796. const result = {};
  5797. if (len < 4) {
  5798. result[prop] = len > 1 ? 'short' : 'narrow';
  5799. }
  5800. else {
  5801. result[prop] = 'long';
  5802. }
  5803. return result;
  5804. }
  5805. /**
  5806. * @param {?} options
  5807. * @return {?}
  5808. */
  5809. function combine(options) {
  5810. return options.reduce((/**
  5811. * @param {?} merged
  5812. * @param {?} opt
  5813. * @return {?}
  5814. */
  5815. (merged, opt) => (Object.assign({}, merged, opt))), {});
  5816. }
  5817. /**
  5818. * @param {?} ret
  5819. * @return {?}
  5820. */
  5821. function datePartGetterFactory(ret) {
  5822. return (/**
  5823. * @param {?} date
  5824. * @param {?} locale
  5825. * @return {?}
  5826. */
  5827. (date, locale) => intlDateFormat(date, locale, ret));
  5828. }
  5829. /** @type {?} */
  5830. const DATE_FORMATTER_CACHE = new Map();
  5831. /**
  5832. * @param {?} format
  5833. * @param {?} date
  5834. * @param {?} locale
  5835. * @return {?}
  5836. */
  5837. function dateFormatter(format, date, locale) {
  5838. /** @type {?} */
  5839. const fn = PATTERN_ALIASES[format];
  5840. if (fn)
  5841. return fn(date, locale);
  5842. /** @type {?} */
  5843. const cacheKey = format;
  5844. /** @type {?} */
  5845. let parts = DATE_FORMATTER_CACHE.get(cacheKey);
  5846. if (!parts) {
  5847. parts = [];
  5848. /** @type {?} */
  5849. let match;
  5850. DATE_FORMATS_SPLIT$1.exec(format);
  5851. /** @type {?} */
  5852. let _format = format;
  5853. while (_format) {
  5854. match = DATE_FORMATS_SPLIT$1.exec(_format);
  5855. if (match) {
  5856. parts = parts.concat(match.slice(1));
  5857. _format = (/** @type {?} */ (parts.pop()));
  5858. }
  5859. else {
  5860. parts.push(_format);
  5861. _format = null;
  5862. }
  5863. }
  5864. DATE_FORMATTER_CACHE.set(cacheKey, parts);
  5865. }
  5866. return parts.reduce((/**
  5867. * @param {?} text
  5868. * @param {?} part
  5869. * @return {?}
  5870. */
  5871. (text, part) => {
  5872. /** @type {?} */
  5873. const fn = DATE_FORMATS$1[part];
  5874. return text + (fn ? fn(date, locale) : partToTime(part));
  5875. }), '');
  5876. }
  5877. /**
  5878. * @param {?} part
  5879. * @return {?}
  5880. */
  5881. function partToTime(part) {
  5882. return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
  5883. }
  5884. class DateFormatter {
  5885. /**
  5886. * @param {?} date
  5887. * @param {?} locale
  5888. * @param {?} pattern
  5889. * @return {?}
  5890. */
  5891. static format(date, locale, pattern) {
  5892. return dateFormatter(pattern, date, locale);
  5893. }
  5894. }
  5895. /**
  5896. * @fileoverview added by tsickle
  5897. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5898. */
  5899. /**
  5900. * \@ngModule CommonModule
  5901. * \@description
  5902. *
  5903. * Formats a date according to locale rules.
  5904. *
  5905. * Where:
  5906. * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
  5907. * (https://www.w3.org/TR/NOTE-datetime).
  5908. * - `format` indicates which date/time components to include. The format can be predefined as
  5909. * shown below or custom as shown in the table.
  5910. * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
  5911. * - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
  5912. * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
  5913. * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
  5914. * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
  5915. * - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
  5916. * - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
  5917. * - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
  5918. *
  5919. *
  5920. * | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
  5921. * |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
  5922. * | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
  5923. * | year | y | - | - | - | y (2015) | yy (15) |
  5924. * | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
  5925. * | day | d | - | - | - | d (3) | dd (03) |
  5926. * | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
  5927. * | hour | j | - | - | - | j (13) | jj (13) |
  5928. * | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)|
  5929. * | hour24 | H | - | - | - | H (13) | HH (13) |
  5930. * | minute | m | - | - | - | m (5) | mm (05) |
  5931. * | second | s | - | - | - | s (9) | ss (09) |
  5932. * | timezone | z | - | - | z (Pacific Standard Time)| - | - |
  5933. * | timezone | Z | - | Z (GMT-8:00) | - | - | - |
  5934. * | timezone | a | - | a (PM) | - | - | - |
  5935. *
  5936. * In javascript, only the components specified will be respected (not the ordering,
  5937. * punctuations, ...) and details of the formatting will be dependent on the locale.
  5938. *
  5939. * Timezone of the formatted text will be the local system timezone of the end-user's machine.
  5940. *
  5941. * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
  5942. * applied and the formatted text will have the same day, month and year of the expression.
  5943. *
  5944. * WARNINGS:
  5945. * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
  5946. * Instead users should treat the date as an immutable object and change the reference when the
  5947. * pipe needs to re-run (this is to avoid reformatting the date on every change detection run
  5948. * which would be an expensive operation).
  5949. * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
  5950. * browsers.
  5951. *
  5952. * \@usageNotes
  5953. *
  5954. * ### Examples
  5955. *
  5956. * Assuming `dateObj` is (year: 2010, month: 9, day: 3, hour: 12 PM, minute: 05, second: 08)
  5957. * in the _local_ time and locale is 'en-US':
  5958. *
  5959. * {\@example common/pipes/ts/date_pipe.ts region='DeprecatedDatePipe'}
  5960. *
  5961. * \@publicApi
  5962. */
  5963. class DeprecatedDatePipe {
  5964. /**
  5965. * @param {?} _locale
  5966. */
  5967. constructor(_locale) {
  5968. this._locale = _locale;
  5969. }
  5970. /**
  5971. * @param {?} value
  5972. * @param {?=} pattern
  5973. * @return {?}
  5974. */
  5975. transform(value, pattern = 'mediumDate') {
  5976. if (value == null || value === '' || value !== value)
  5977. return null;
  5978. /** @type {?} */
  5979. let date;
  5980. if (typeof value === 'string') {
  5981. value = value.trim();
  5982. }
  5983. if (isDate$1(value)) {
  5984. date = value;
  5985. }
  5986. else if (!isNaN(value - parseFloat(value))) {
  5987. date = new Date(parseFloat(value));
  5988. }
  5989. else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
  5990. /**
  5991. * For ISO Strings without time the day, month and year must be extracted from the ISO String
  5992. * before Date creation to avoid time offset and errors in the new Date.
  5993. * If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
  5994. * date, some browsers (e.g. IE 9) will throw an invalid Date error
  5995. * If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the
  5996. * timeoffset
  5997. * is applied
  5998. * Note: ISO months are 0 for January, 1 for February, ...
  5999. */
  6000. const [y, m, d] = value.split('-').map((/**
  6001. * @param {?} val
  6002. * @return {?}
  6003. */
  6004. (val) => parseInt(val, 10)));
  6005. date = new Date(y, m - 1, d);
  6006. }
  6007. else {
  6008. date = new Date(value);
  6009. }
  6010. if (!isDate$1(date)) {
  6011. /** @type {?} */
  6012. let match;
  6013. if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
  6014. date = isoStringToDate(match);
  6015. }
  6016. else {
  6017. throw invalidPipeArgumentError(DeprecatedDatePipe, value);
  6018. }
  6019. }
  6020. return DateFormatter.format(date, this._locale, DeprecatedDatePipe._ALIASES[pattern] || pattern);
  6021. }
  6022. }
  6023. /**
  6024. * \@internal
  6025. */
  6026. DeprecatedDatePipe._ALIASES = {
  6027. 'medium': 'yMMMdjms',
  6028. 'short': 'yMdjm',
  6029. 'fullDate': 'yMMMMEEEEd',
  6030. 'longDate': 'yMMMMd',
  6031. 'mediumDate': 'yMMMd',
  6032. 'shortDate': 'yMd',
  6033. 'mediumTime': 'jms',
  6034. 'shortTime': 'jm'
  6035. };
  6036. DeprecatedDatePipe.decorators = [
  6037. { type: Pipe, args: [{ name: 'date', pure: true },] }
  6038. ];
  6039. /** @nocollapse */
  6040. DeprecatedDatePipe.ctorParameters = () => [
  6041. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  6042. ];
  6043. /**
  6044. * @param {?} value
  6045. * @return {?}
  6046. */
  6047. function isDate$1(value) {
  6048. return value instanceof Date && !isNaN(value.valueOf());
  6049. }
  6050. /**
  6051. * @fileoverview added by tsickle
  6052. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6053. */
  6054. /**
  6055. * @param {?} pipe
  6056. * @param {?} locale
  6057. * @param {?} value
  6058. * @param {?} style
  6059. * @param {?=} digits
  6060. * @param {?=} currency
  6061. * @param {?=} currencyAsSymbol
  6062. * @return {?}
  6063. */
  6064. function formatNumber$1(pipe, locale, value, style, digits, currency = null, currencyAsSymbol = false) {
  6065. if (value == null)
  6066. return null;
  6067. // Convert strings to numbers
  6068. value = typeof value === 'string' && !isNaN(+value - parseFloat(value)) ? +value : value;
  6069. if (typeof value !== 'number') {
  6070. throw invalidPipeArgumentError(pipe, value);
  6071. }
  6072. /** @type {?} */
  6073. let minInt;
  6074. /** @type {?} */
  6075. let minFraction;
  6076. /** @type {?} */
  6077. let maxFraction;
  6078. if (style !== NumberFormatStyle.Currency) {
  6079. // rely on Intl default for currency
  6080. minInt = 1;
  6081. minFraction = 0;
  6082. maxFraction = 3;
  6083. }
  6084. if (digits) {
  6085. /** @type {?} */
  6086. const parts = digits.match(NUMBER_FORMAT_REGEXP);
  6087. if (parts === null) {
  6088. throw new Error(`${digits} is not a valid digit info for number pipes`);
  6089. }
  6090. if (parts[1] != null) { // min integer digits
  6091. minInt = parseIntAutoRadix(parts[1]);
  6092. }
  6093. if (parts[3] != null) { // min fraction digits
  6094. minFraction = parseIntAutoRadix(parts[3]);
  6095. }
  6096. if (parts[5] != null) { // max fraction digits
  6097. maxFraction = parseIntAutoRadix(parts[5]);
  6098. }
  6099. }
  6100. return NumberFormatter.format((/** @type {?} */ (value)), locale, style, {
  6101. minimumIntegerDigits: minInt,
  6102. minimumFractionDigits: minFraction,
  6103. maximumFractionDigits: maxFraction,
  6104. currency: currency,
  6105. currencyAsSymbol: currencyAsSymbol,
  6106. });
  6107. }
  6108. /**
  6109. * Formats a number as text. Group sizing and separator and other locale-specific
  6110. * configurations are based on the active locale.
  6111. *
  6112. * where `expression` is a number:
  6113. * - `digitInfo` is a `string` which has a following format: <br>
  6114. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
  6115. * - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
  6116. * - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
  6117. * - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
  6118. *
  6119. * For more information on the acceptable range for each of these numbers and other
  6120. * details see your native internationalization library.
  6121. *
  6122. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  6123. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  6124. *
  6125. * \@usageNotes
  6126. *
  6127. * ### Example
  6128. *
  6129. * {\@example common/pipes/ts/number_pipe.ts region='DeprecatedNumberPipe'}
  6130. *
  6131. * \@ngModule CommonModule
  6132. * \@publicApi
  6133. */
  6134. class DeprecatedDecimalPipe {
  6135. /**
  6136. * @param {?} _locale
  6137. */
  6138. constructor(_locale) {
  6139. this._locale = _locale;
  6140. }
  6141. /**
  6142. * @param {?} value
  6143. * @param {?=} digits
  6144. * @return {?}
  6145. */
  6146. transform(value, digits) {
  6147. return formatNumber$1(DeprecatedDecimalPipe, this._locale, value, NumberFormatStyle.Decimal, digits);
  6148. }
  6149. }
  6150. DeprecatedDecimalPipe.decorators = [
  6151. { type: Pipe, args: [{ name: 'number' },] }
  6152. ];
  6153. /** @nocollapse */
  6154. DeprecatedDecimalPipe.ctorParameters = () => [
  6155. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  6156. ];
  6157. /**
  6158. * \@ngModule CommonModule
  6159. *
  6160. * \@description
  6161. *
  6162. * Formats a number as percentage according to locale rules.
  6163. *
  6164. * - `digitInfo` See {\@link DecimalPipe} for detailed description.
  6165. *
  6166. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  6167. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  6168. *
  6169. * \@usageNotes
  6170. *
  6171. * ### Example
  6172. *
  6173. * {\@example common/pipes/ts/percent_pipe.ts region='DeprecatedPercentPipe'}
  6174. *
  6175. * \@publicApi
  6176. */
  6177. class DeprecatedPercentPipe {
  6178. /**
  6179. * @param {?} _locale
  6180. */
  6181. constructor(_locale) {
  6182. this._locale = _locale;
  6183. }
  6184. /**
  6185. * @param {?} value
  6186. * @param {?=} digits
  6187. * @return {?}
  6188. */
  6189. transform(value, digits) {
  6190. return formatNumber$1(DeprecatedPercentPipe, this._locale, value, NumberFormatStyle.Percent, digits);
  6191. }
  6192. }
  6193. DeprecatedPercentPipe.decorators = [
  6194. { type: Pipe, args: [{ name: 'percent' },] }
  6195. ];
  6196. /** @nocollapse */
  6197. DeprecatedPercentPipe.ctorParameters = () => [
  6198. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  6199. ];
  6200. /**
  6201. * \@ngModule CommonModule
  6202. * \@description
  6203. *
  6204. * Formats a number as currency using locale rules.
  6205. *
  6206. * Use `currency` to format a number as currency.
  6207. *
  6208. * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
  6209. * as `USD` for the US dollar and `EUR` for the euro.
  6210. * - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
  6211. * - `true`: use symbol (e.g. `$`).
  6212. * - `false`(default): use code (e.g. `USD`).
  6213. * - `digitInfo` See {\@link DecimalPipe} for detailed description.
  6214. *
  6215. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  6216. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  6217. *
  6218. * \@usageNotes
  6219. *
  6220. * ### Example
  6221. *
  6222. * {\@example common/pipes/ts/currency_pipe.ts region='DeprecatedCurrencyPipe'}
  6223. *
  6224. * \@publicApi
  6225. */
  6226. class DeprecatedCurrencyPipe {
  6227. /**
  6228. * @param {?} _locale
  6229. */
  6230. constructor(_locale) {
  6231. this._locale = _locale;
  6232. }
  6233. /**
  6234. * @param {?} value
  6235. * @param {?=} currencyCode
  6236. * @param {?=} symbolDisplay
  6237. * @param {?=} digits
  6238. * @return {?}
  6239. */
  6240. transform(value, currencyCode = 'USD', symbolDisplay = false, digits) {
  6241. return formatNumber$1(DeprecatedCurrencyPipe, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
  6242. }
  6243. }
  6244. DeprecatedCurrencyPipe.decorators = [
  6245. { type: Pipe, args: [{ name: 'currency' },] }
  6246. ];
  6247. /** @nocollapse */
  6248. DeprecatedCurrencyPipe.ctorParameters = () => [
  6249. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  6250. ];
  6251. /**
  6252. * @fileoverview added by tsickle
  6253. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6254. */
  6255. /**
  6256. * A collection of deprecated i18n pipes that require intl api
  6257. *
  6258. * @deprecated from v5
  6259. * @type {?}
  6260. */
  6261. const COMMON_DEPRECATED_I18N_PIPES = [DeprecatedDecimalPipe, DeprecatedPercentPipe, DeprecatedCurrencyPipe, DeprecatedDatePipe];
  6262. /**
  6263. * @fileoverview added by tsickle
  6264. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6265. */
  6266. class ObservableStrategy {
  6267. /**
  6268. * @param {?} async
  6269. * @param {?} updateLatestValue
  6270. * @return {?}
  6271. */
  6272. createSubscription(async, updateLatestValue) {
  6273. return async.subscribe({ next: updateLatestValue, error: (/**
  6274. * @param {?} e
  6275. * @return {?}
  6276. */
  6277. (e) => { throw e; }) });
  6278. }
  6279. /**
  6280. * @param {?} subscription
  6281. * @return {?}
  6282. */
  6283. dispose(subscription) { subscription.unsubscribe(); }
  6284. /**
  6285. * @param {?} subscription
  6286. * @return {?}
  6287. */
  6288. onDestroy(subscription) { subscription.unsubscribe(); }
  6289. }
  6290. class PromiseStrategy {
  6291. /**
  6292. * @param {?} async
  6293. * @param {?} updateLatestValue
  6294. * @return {?}
  6295. */
  6296. createSubscription(async, updateLatestValue) {
  6297. return async.then(updateLatestValue, (/**
  6298. * @param {?} e
  6299. * @return {?}
  6300. */
  6301. e => { throw e; }));
  6302. }
  6303. /**
  6304. * @param {?} subscription
  6305. * @return {?}
  6306. */
  6307. dispose(subscription) { }
  6308. /**
  6309. * @param {?} subscription
  6310. * @return {?}
  6311. */
  6312. onDestroy(subscription) { }
  6313. }
  6314. /** @type {?} */
  6315. const _promiseStrategy = new PromiseStrategy();
  6316. /** @type {?} */
  6317. const _observableStrategy = new ObservableStrategy();
  6318. /**
  6319. * \@ngModule CommonModule
  6320. * \@description
  6321. *
  6322. * Unwraps a value from an asynchronous primitive.
  6323. *
  6324. * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
  6325. * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
  6326. * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
  6327. * potential memory leaks.
  6328. *
  6329. * \@usageNotes
  6330. *
  6331. * ### Examples
  6332. *
  6333. * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
  6334. * promise.
  6335. *
  6336. * {\@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
  6337. *
  6338. * It's also possible to use `async` with Observables. The example below binds the `time` Observable
  6339. * to the view. The Observable continuously updates the view with the current time.
  6340. *
  6341. * {\@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
  6342. *
  6343. * \@publicApi
  6344. */
  6345. class AsyncPipe {
  6346. /**
  6347. * @param {?} _ref
  6348. */
  6349. constructor(_ref) {
  6350. this._ref = _ref;
  6351. this._latestValue = null;
  6352. this._latestReturnedValue = null;
  6353. this._subscription = null;
  6354. this._obj = null;
  6355. this._strategy = (/** @type {?} */ (null));
  6356. }
  6357. /**
  6358. * @return {?}
  6359. */
  6360. ngOnDestroy() {
  6361. if (this._subscription) {
  6362. this._dispose();
  6363. }
  6364. }
  6365. /**
  6366. * @param {?} obj
  6367. * @return {?}
  6368. */
  6369. transform(obj) {
  6370. if (!this._obj) {
  6371. if (obj) {
  6372. this._subscribe(obj);
  6373. }
  6374. this._latestReturnedValue = this._latestValue;
  6375. return this._latestValue;
  6376. }
  6377. if (obj !== this._obj) {
  6378. this._dispose();
  6379. return this.transform((/** @type {?} */ (obj)));
  6380. }
  6381. if (ɵlooseIdentical(this._latestValue, this._latestReturnedValue)) {
  6382. return this._latestReturnedValue;
  6383. }
  6384. this._latestReturnedValue = this._latestValue;
  6385. return WrappedValue.wrap(this._latestValue);
  6386. }
  6387. /**
  6388. * @private
  6389. * @param {?} obj
  6390. * @return {?}
  6391. */
  6392. _subscribe(obj) {
  6393. this._obj = obj;
  6394. this._strategy = this._selectStrategy(obj);
  6395. this._subscription = this._strategy.createSubscription(obj, (/**
  6396. * @param {?} value
  6397. * @return {?}
  6398. */
  6399. (value) => this._updateLatestValue(obj, value)));
  6400. }
  6401. /**
  6402. * @private
  6403. * @param {?} obj
  6404. * @return {?}
  6405. */
  6406. _selectStrategy(obj) {
  6407. if (ɵisPromise(obj)) {
  6408. return _promiseStrategy;
  6409. }
  6410. if (ɵisObservable(obj)) {
  6411. return _observableStrategy;
  6412. }
  6413. throw invalidPipeArgumentError(AsyncPipe, obj);
  6414. }
  6415. /**
  6416. * @private
  6417. * @return {?}
  6418. */
  6419. _dispose() {
  6420. this._strategy.dispose((/** @type {?} */ (this._subscription)));
  6421. this._latestValue = null;
  6422. this._latestReturnedValue = null;
  6423. this._subscription = null;
  6424. this._obj = null;
  6425. }
  6426. /**
  6427. * @private
  6428. * @param {?} async
  6429. * @param {?} value
  6430. * @return {?}
  6431. */
  6432. _updateLatestValue(async, value) {
  6433. if (async === this._obj) {
  6434. this._latestValue = value;
  6435. this._ref.markForCheck();
  6436. }
  6437. }
  6438. }
  6439. AsyncPipe.decorators = [
  6440. { type: Injectable },
  6441. { type: Pipe, args: [{ name: 'async', pure: false },] }
  6442. ];
  6443. /** @nocollapse */
  6444. AsyncPipe.ctorParameters = () => [
  6445. { type: ChangeDetectorRef }
  6446. ];
  6447. /**
  6448. * @fileoverview added by tsickle
  6449. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6450. */
  6451. /**
  6452. * Transforms text to all lower case.
  6453. *
  6454. * @see `UpperCasePipe`
  6455. * @see `TitleCasePipe`
  6456. * \@usageNotes
  6457. *
  6458. * The following example defines a view that allows the user to enter
  6459. * text, and then uses the pipe to convert the input text to all lower case.
  6460. *
  6461. * <code-example path="common/pipes/ts/lowerupper_pipe.ts" region='LowerUpperPipe'></code-example>
  6462. *
  6463. * \@ngModule CommonModule
  6464. * \@publicApi
  6465. */
  6466. class LowerCasePipe {
  6467. /**
  6468. * @param {?} value The string to transform to lower case.
  6469. * @return {?}
  6470. */
  6471. transform(value) {
  6472. if (!value)
  6473. return value;
  6474. if (typeof value !== 'string') {
  6475. throw invalidPipeArgumentError(LowerCasePipe, value);
  6476. }
  6477. return value.toLowerCase();
  6478. }
  6479. }
  6480. LowerCasePipe.decorators = [
  6481. { type: Injectable },
  6482. { type: Pipe, args: [{ name: 'lowercase' },] }
  6483. ];
  6484. //
  6485. // Regex below matches any Unicode word and compatible with ES5. In ES2018 the same result
  6486. // can be achieved by using /\p{L}\S*/gu and also known as Unicode Property Escapes
  6487. // (http://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
  6488. // transpilation of this functionality down to ES5 without external tool, the only solution is
  6489. // to use already transpiled form. Example can be found here -
  6490. // https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BL%7D/u%3B&unicodePropertyEscape=1
  6491. //
  6492. /** @type {?} */
  6493. const unicodeWordMatch = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D])\S*/g;
  6494. /**
  6495. * Transforms text to title case.
  6496. * Capitalizes the first letter of each word, and transforms the
  6497. * rest of the word to lower case.
  6498. * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
  6499. *
  6500. * @see `LowerCasePipe`
  6501. * @see `UpperCasePipe`
  6502. *
  6503. * \@usageNotes
  6504. * The following example shows the result of transforming various strings into title case.
  6505. *
  6506. * <code-example path="common/pipes/ts/titlecase_pipe.ts" region='TitleCasePipe'></code-example>
  6507. *
  6508. * \@ngModule CommonModule
  6509. * \@publicApi
  6510. */
  6511. class TitleCasePipe {
  6512. /**
  6513. * @param {?} value The string to transform to title case.
  6514. * @return {?}
  6515. */
  6516. transform(value) {
  6517. if (!value)
  6518. return value;
  6519. if (typeof value !== 'string') {
  6520. throw invalidPipeArgumentError(TitleCasePipe, value);
  6521. }
  6522. return value.replace(unicodeWordMatch, ((/**
  6523. * @param {?} txt
  6524. * @return {?}
  6525. */
  6526. txt => txt[0].toUpperCase() + txt.substr(1).toLowerCase())));
  6527. }
  6528. }
  6529. TitleCasePipe.decorators = [
  6530. { type: Injectable },
  6531. { type: Pipe, args: [{ name: 'titlecase' },] }
  6532. ];
  6533. /**
  6534. * Transforms text to all upper case.
  6535. * @see `LowerCasePipe`
  6536. * @see `TitleCasePipe`
  6537. *
  6538. * \@ngModule CommonModule
  6539. * \@publicApi
  6540. */
  6541. class UpperCasePipe {
  6542. /**
  6543. * @param {?} value The string to transform to upper case.
  6544. * @return {?}
  6545. */
  6546. transform(value) {
  6547. if (!value)
  6548. return value;
  6549. if (typeof value !== 'string') {
  6550. throw invalidPipeArgumentError(UpperCasePipe, value);
  6551. }
  6552. return value.toUpperCase();
  6553. }
  6554. }
  6555. UpperCasePipe.decorators = [
  6556. { type: Injectable },
  6557. { type: Pipe, args: [{ name: 'uppercase' },] }
  6558. ];
  6559. /**
  6560. * @fileoverview added by tsickle
  6561. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6562. */
  6563. // clang-format off
  6564. /**
  6565. * \@ngModule CommonModule
  6566. * \@description
  6567. *
  6568. * Formats a date value according to locale rules.
  6569. *
  6570. * Only the `en-US` locale data comes with Angular. To localize dates
  6571. * in another language, you must import the corresponding locale data.
  6572. * See the [I18n guide](guide/i18n#i18n-pipes) for more information.
  6573. *
  6574. * @see `formatDate()`
  6575. *
  6576. *
  6577. * \@usageNotes
  6578. *
  6579. * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
  6580. * reformat the date on every change-detection cycle, treat the date as an immutable object
  6581. * and change the reference when the pipe needs to run again.
  6582. *
  6583. * ### Pre-defined format options
  6584. *
  6585. * Examples are given in `en-US` locale.
  6586. *
  6587. * - `'short'`: equivalent to `'M/d/yy, h:mm a'` (`6/15/15, 9:03 AM`).
  6588. * - `'medium'`: equivalent to `'MMM d, y, h:mm:ss a'` (`Jun 15, 2015, 9:03:01 AM`).
  6589. * - `'long'`: equivalent to `'MMMM d, y, h:mm:ss a z'` (`June 15, 2015 at 9:03:01 AM
  6590. * GMT+1`).
  6591. * - `'full'`: equivalent to `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (`Monday, June 15, 2015 at
  6592. * 9:03:01 AM GMT+01:00`).
  6593. * - `'shortDate'`: equivalent to `'M/d/yy'` (`6/15/15`).
  6594. * - `'mediumDate'`: equivalent to `'MMM d, y'` (`Jun 15, 2015`).
  6595. * - `'longDate'`: equivalent to `'MMMM d, y'` (`June 15, 2015`).
  6596. * - `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` (`Monday, June 15, 2015`).
  6597. * - `'shortTime'`: equivalent to `'h:mm a'` (`9:03 AM`).
  6598. * - `'mediumTime'`: equivalent to `'h:mm:ss a'` (`9:03:01 AM`).
  6599. * - `'longTime'`: equivalent to `'h:mm:ss a z'` (`9:03:01 AM GMT+1`).
  6600. * - `'fullTime'`: equivalent to `'h:mm:ss a zzzz'` (`9:03:01 AM GMT+01:00`).
  6601. *
  6602. * ### Custom format options
  6603. *
  6604. * You can construct a format string using symbols to specify the components
  6605. * of a date-time value, as described in the following table.
  6606. * Format details depend on the locale.
  6607. * Fields marked with (*) are only available in the extra data set for the given locale.
  6608. *
  6609. * | Field type | Format | Description | Example Value |
  6610. * |--------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
  6611. * | Era | G, GG & GGG | Abbreviated | AD |
  6612. * | | GGGG | Wide | Anno Domini |
  6613. * | | GGGGG | Narrow | A |
  6614. * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  6615. * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  6616. * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  6617. * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  6618. * | Month | M | Numeric: 1 digit | 9, 12 |
  6619. * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
  6620. * | | MMM | Abbreviated | Sep |
  6621. * | | MMMM | Wide | September |
  6622. * | | MMMMM | Narrow | S |
  6623. * | Month standalone | L | Numeric: 1 digit | 9, 12 |
  6624. * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
  6625. * | | LLL | Abbreviated | Sep |
  6626. * | | LLLL | Wide | September |
  6627. * | | LLLLL | Narrow | S |
  6628. * | Week of year | w | Numeric: minimum digits | 1... 53 |
  6629. * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
  6630. * | Week of month | W | Numeric: 1 digit | 1... 5 |
  6631. * | Day of month | d | Numeric: minimum digits | 1 |
  6632. * | | dd | Numeric: 2 digits + zero padded | 01 |
  6633. * | Week day | E, EE & EEE | Abbreviated | Tue |
  6634. * | | EEEE | Wide | Tuesday |
  6635. * | | EEEEE | Narrow | T |
  6636. * | | EEEEEE | Short | Tu |
  6637. * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
  6638. * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
  6639. * | | aaaaa | Narrow | a/p |
  6640. * | Period* | B, BB & BBB | Abbreviated | mid. |
  6641. * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  6642. * | | BBBBB | Narrow | md |
  6643. * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
  6644. * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  6645. * | | bbbbb | Narrow | md |
  6646. * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
  6647. * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
  6648. * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
  6649. * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
  6650. * | Minute | m | Numeric: minimum digits | 8, 59 |
  6651. * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
  6652. * | Second | s | Numeric: minimum digits | 0... 59 |
  6653. * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
  6654. * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
  6655. * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
  6656. * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
  6657. * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
  6658. * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
  6659. * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
  6660. * | | ZZZZ | Long localized GMT format | GMT-8:00 |
  6661. * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
  6662. * | | O, OO & OOO | Short localized GMT format | GMT-8 |
  6663. * | | OOOO | Long localized GMT format | GMT-08:00 |
  6664. *
  6665. * Note that timezone correction is not applied to an ISO string that has no time component, such as "2016-09-19"
  6666. *
  6667. * ### Format examples
  6668. *
  6669. * These examples transform a date into various formats,
  6670. * assuming that `dateObj` is a JavaScript `Date` object for
  6671. * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
  6672. * given in the local time for the `en-US` locale.
  6673. *
  6674. * ```
  6675. * {{ dateObj | date }} // output is 'Jun 15, 2015'
  6676. * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
  6677. * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
  6678. * {{ dateObj | date:'mm:ss' }} // output is '43:11'
  6679. * ```
  6680. *
  6681. * ### Usage example
  6682. *
  6683. * The following component uses a date pipe to display the current date in different formats.
  6684. *
  6685. * ```
  6686. * \@Component({
  6687. * selector: 'date-pipe',
  6688. * template: `<div>
  6689. * <p>Today is {{today | date}}</p>
  6690. * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
  6691. * <p>The time is {{today | date:'h:mm a z'}}</p>
  6692. * </div>`
  6693. * })
  6694. * // Get the current date and time as a date-time value.
  6695. * export class DatePipeComponent {
  6696. * today: number = Date.now();
  6697. * }
  6698. * ```
  6699. *
  6700. * \@publicApi
  6701. */
  6702. // clang-format on
  6703. class DatePipe {
  6704. /**
  6705. * @param {?} locale
  6706. */
  6707. constructor(locale) {
  6708. this.locale = locale;
  6709. }
  6710. /**
  6711. * @param {?} value The date expression: a `Date` object, a number
  6712. * (milliseconds since UTC epoch), or an ISO string (https://www.w3.org/TR/NOTE-datetime).
  6713. * @param {?=} format The date/time components to include, using predefined options or a
  6714. * custom format string.
  6715. * @param {?=} timezone A timezone offset (such as `'+0430'`), or a standard
  6716. * UTC/GMT or continental US timezone abbreviation. Default is
  6717. * the local system timezone of the end-user's machine.
  6718. * @param {?=} locale A locale code for the locale format rules to use.
  6719. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  6720. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  6721. * @return {?} A date string in the desired format.
  6722. */
  6723. transform(value, format = 'mediumDate', timezone, locale) {
  6724. if (value == null || value === '' || value !== value)
  6725. return null;
  6726. try {
  6727. return formatDate(value, format, locale || this.locale, timezone);
  6728. }
  6729. catch (error) {
  6730. throw invalidPipeArgumentError(DatePipe, error.message);
  6731. }
  6732. }
  6733. }
  6734. DatePipe.decorators = [
  6735. { type: Injectable },
  6736. { type: Pipe, args: [{ name: 'date', pure: true },] }
  6737. ];
  6738. /** @nocollapse */
  6739. DatePipe.ctorParameters = () => [
  6740. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  6741. ];
  6742. /**
  6743. * @fileoverview added by tsickle
  6744. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6745. */
  6746. /** @type {?} */
  6747. const _INTERPOLATION_REGEXP = /#/g;
  6748. /**
  6749. * \@ngModule CommonModule
  6750. * \@description
  6751. *
  6752. * Maps a value to a string that pluralizes the value according to locale rules.
  6753. *
  6754. * \@usageNotes
  6755. *
  6756. * ### Example
  6757. *
  6758. * {\@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
  6759. *
  6760. * \@publicApi
  6761. */
  6762. class I18nPluralPipe {
  6763. /**
  6764. * @param {?} _localization
  6765. */
  6766. constructor(_localization) {
  6767. this._localization = _localization;
  6768. }
  6769. /**
  6770. * @param {?} value the number to be formatted
  6771. * @param {?} pluralMap an object that mimics the ICU format, see
  6772. * http://userguide.icu-project.org/formatparse/messages.
  6773. * @param {?=} locale a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
  6774. * default).
  6775. * @return {?}
  6776. */
  6777. transform(value, pluralMap, locale) {
  6778. if (value == null)
  6779. return '';
  6780. if (typeof pluralMap !== 'object' || pluralMap === null) {
  6781. throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
  6782. }
  6783. /** @type {?} */
  6784. const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
  6785. return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
  6786. }
  6787. }
  6788. I18nPluralPipe.decorators = [
  6789. { type: Injectable },
  6790. { type: Pipe, args: [{ name: 'i18nPlural', pure: true },] }
  6791. ];
  6792. /** @nocollapse */
  6793. I18nPluralPipe.ctorParameters = () => [
  6794. { type: NgLocalization }
  6795. ];
  6796. /**
  6797. * @fileoverview added by tsickle
  6798. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6799. */
  6800. /**
  6801. * \@ngModule CommonModule
  6802. * \@description
  6803. *
  6804. * Generic selector that displays the string that matches the current value.
  6805. *
  6806. * If none of the keys of the `mapping` match the `value`, then the content
  6807. * of the `other` key is returned when present, otherwise an empty string is returned.
  6808. *
  6809. * \@usageNotes
  6810. *
  6811. * ### Example
  6812. *
  6813. * {\@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
  6814. *
  6815. * \@publicApi
  6816. */
  6817. class I18nSelectPipe {
  6818. /**
  6819. * @param {?} value a string to be internationalized.
  6820. * @param {?} mapping an object that indicates the text that should be displayed
  6821. * for different values of the provided `value`.
  6822. * @return {?}
  6823. */
  6824. transform(value, mapping) {
  6825. if (value == null)
  6826. return '';
  6827. if (typeof mapping !== 'object' || typeof value !== 'string') {
  6828. throw invalidPipeArgumentError(I18nSelectPipe, mapping);
  6829. }
  6830. if (mapping.hasOwnProperty(value)) {
  6831. return mapping[value];
  6832. }
  6833. if (mapping.hasOwnProperty('other')) {
  6834. return mapping['other'];
  6835. }
  6836. return '';
  6837. }
  6838. }
  6839. I18nSelectPipe.decorators = [
  6840. { type: Injectable },
  6841. { type: Pipe, args: [{ name: 'i18nSelect', pure: true },] }
  6842. ];
  6843. /**
  6844. * @fileoverview added by tsickle
  6845. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6846. */
  6847. /**
  6848. * \@ngModule CommonModule
  6849. * \@description
  6850. *
  6851. * Converts a value into its JSON-format representation. Useful for debugging.
  6852. *
  6853. * \@usageNotes
  6854. *
  6855. * The following component uses a JSON pipe to convert an object
  6856. * to JSON format, and displays the string in both formats for comparison.
  6857. *
  6858. * {\@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
  6859. *
  6860. * \@publicApi
  6861. */
  6862. class JsonPipe {
  6863. /**
  6864. * @param {?} value A value of any type to convert into a JSON-format string.
  6865. * @return {?}
  6866. */
  6867. transform(value) { return JSON.stringify(value, null, 2); }
  6868. }
  6869. JsonPipe.decorators = [
  6870. { type: Injectable },
  6871. { type: Pipe, args: [{ name: 'json', pure: false },] }
  6872. ];
  6873. /**
  6874. * @fileoverview added by tsickle
  6875. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6876. */
  6877. /**
  6878. * @template K, V
  6879. * @param {?} key
  6880. * @param {?} value
  6881. * @return {?}
  6882. */
  6883. function makeKeyValuePair(key, value) {
  6884. return { key: key, value: value };
  6885. }
  6886. /**
  6887. * \@ngModule CommonModule
  6888. * \@description
  6889. *
  6890. * Transforms Object or Map into an array of key value pairs.
  6891. *
  6892. * The output array will be ordered by keys.
  6893. * By default the comparator will be by Unicode point value.
  6894. * You can optionally pass a compareFn if your keys are complex types.
  6895. *
  6896. * \@usageNotes
  6897. * ### Examples
  6898. *
  6899. * This examples show how an Object or a Map can be iterated by ngFor with the use of this keyvalue
  6900. * pipe.
  6901. *
  6902. * {\@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
  6903. *
  6904. * \@publicApi
  6905. */
  6906. class KeyValuePipe {
  6907. /**
  6908. * @param {?} differs
  6909. */
  6910. constructor(differs) {
  6911. this.differs = differs;
  6912. this.keyValues = [];
  6913. }
  6914. /**
  6915. * @template K, V
  6916. * @param {?} input
  6917. * @param {?=} compareFn
  6918. * @return {?}
  6919. */
  6920. transform(input, compareFn = defaultComparator) {
  6921. if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
  6922. return null;
  6923. }
  6924. if (!this.differ) {
  6925. // make a differ for whatever type we've been passed in
  6926. this.differ = this.differs.find(input).create();
  6927. }
  6928. /** @type {?} */
  6929. const differChanges = this.differ.diff((/** @type {?} */ (input)));
  6930. if (differChanges) {
  6931. this.keyValues = [];
  6932. differChanges.forEachItem((/**
  6933. * @param {?} r
  6934. * @return {?}
  6935. */
  6936. (r) => {
  6937. this.keyValues.push(makeKeyValuePair(r.key, (/** @type {?} */ (r.currentValue))));
  6938. }));
  6939. this.keyValues.sort(compareFn);
  6940. }
  6941. return this.keyValues;
  6942. }
  6943. }
  6944. KeyValuePipe.decorators = [
  6945. { type: Injectable },
  6946. { type: Pipe, args: [{ name: 'keyvalue', pure: false },] }
  6947. ];
  6948. /** @nocollapse */
  6949. KeyValuePipe.ctorParameters = () => [
  6950. { type: KeyValueDiffers }
  6951. ];
  6952. /**
  6953. * @template K, V
  6954. * @param {?} keyValueA
  6955. * @param {?} keyValueB
  6956. * @return {?}
  6957. */
  6958. function defaultComparator(keyValueA, keyValueB) {
  6959. /** @type {?} */
  6960. const a = keyValueA.key;
  6961. /** @type {?} */
  6962. const b = keyValueB.key;
  6963. // if same exit with 0;
  6964. if (a === b)
  6965. return 0;
  6966. // make sure that undefined are at the end of the sort.
  6967. if (a === undefined)
  6968. return 1;
  6969. if (b === undefined)
  6970. return -1;
  6971. // make sure that nulls are at the end of the sort.
  6972. if (a === null)
  6973. return 1;
  6974. if (b === null)
  6975. return -1;
  6976. if (typeof a == 'string' && typeof b == 'string') {
  6977. return a < b ? -1 : 1;
  6978. }
  6979. if (typeof a == 'number' && typeof b == 'number') {
  6980. return a - b;
  6981. }
  6982. if (typeof a == 'boolean' && typeof b == 'boolean') {
  6983. return a < b ? -1 : 1;
  6984. }
  6985. // `a` and `b` are of different types. Compare their string values.
  6986. /** @type {?} */
  6987. const aString = String(a);
  6988. /** @type {?} */
  6989. const bString = String(b);
  6990. return aString == bString ? 0 : aString < bString ? -1 : 1;
  6991. }
  6992. /**
  6993. * @fileoverview added by tsickle
  6994. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6995. */
  6996. /**
  6997. * \@ngModule CommonModule
  6998. * \@description
  6999. *
  7000. * Transforms a number into a string,
  7001. * formatted according to locale rules that determine group sizing and
  7002. * separator, decimal-point character, and other locale-specific
  7003. * configurations.
  7004. *
  7005. * If no parameters are specified, the function rounds off to the nearest value using this
  7006. * [rounding method](https://en.wikibooks.org/wiki/Arithmetic/Rounding).
  7007. * The behavior differs from that of the JavaScript ```Math.round()``` function.
  7008. * In the following case for example, the pipe rounds down where
  7009. * ```Math.round()``` rounds up:
  7010. *
  7011. * ```html
  7012. * -2.5 | number:'1.0-0'
  7013. * > -3
  7014. * Math.round(-2.5)
  7015. * > -2
  7016. * ```
  7017. *
  7018. * @see `formatNumber()`
  7019. *
  7020. * \@usageNotes
  7021. * The following code shows how the pipe transforms numbers
  7022. * into text strings, according to various format specifications,
  7023. * where the caller's default locale is `en-US`.
  7024. *
  7025. * ### Example
  7026. *
  7027. * <code-example path="common/pipes/ts/number_pipe.ts" region='NumberPipe'></code-example>
  7028. *
  7029. * \@publicApi
  7030. */
  7031. class DecimalPipe {
  7032. /**
  7033. * @param {?} _locale
  7034. */
  7035. constructor(_locale) {
  7036. this._locale = _locale;
  7037. }
  7038. /**
  7039. * @param {?} value The number to be formatted.
  7040. * @param {?=} digitsInfo Decimal representation options, specified by a string
  7041. * in the following format:<br>
  7042. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  7043. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  7044. * Default is `1`.
  7045. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  7046. * Default is `0`.
  7047. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  7048. * Default is `3`.
  7049. * @param {?=} locale A locale code for the locale format rules to use.
  7050. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  7051. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  7052. * @return {?}
  7053. */
  7054. transform(value, digitsInfo, locale) {
  7055. if (isEmpty(value))
  7056. return null;
  7057. locale = locale || this._locale;
  7058. try {
  7059. /** @type {?} */
  7060. const num = strToNumber(value);
  7061. return formatNumber(num, locale, digitsInfo);
  7062. }
  7063. catch (error) {
  7064. throw invalidPipeArgumentError(DecimalPipe, error.message);
  7065. }
  7066. }
  7067. }
  7068. DecimalPipe.decorators = [
  7069. { type: Injectable },
  7070. { type: Pipe, args: [{ name: 'number' },] }
  7071. ];
  7072. /** @nocollapse */
  7073. DecimalPipe.ctorParameters = () => [
  7074. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  7075. ];
  7076. /**
  7077. * \@ngModule CommonModule
  7078. * \@description
  7079. *
  7080. * Transforms a number to a percentage
  7081. * string, formatted according to locale rules that determine group sizing and
  7082. * separator, decimal-point character, and other locale-specific
  7083. * configurations.
  7084. *
  7085. * @see `formatPercent()`
  7086. *
  7087. * \@usageNotes
  7088. * The following code shows how the pipe transforms numbers
  7089. * into text strings, according to various format specifications,
  7090. * where the caller's default locale is `en-US`.
  7091. *
  7092. * <code-example path="common/pipes/ts/percent_pipe.ts" region='PercentPipe'></code-example>
  7093. *
  7094. * \@publicApi
  7095. */
  7096. class PercentPipe {
  7097. /**
  7098. * @param {?} _locale
  7099. */
  7100. constructor(_locale) {
  7101. this._locale = _locale;
  7102. }
  7103. /**
  7104. *
  7105. * @param {?} value The number to be formatted as a percentage.
  7106. * @param {?=} digitsInfo Decimal representation options, specified by a string
  7107. * in the following format:<br>
  7108. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  7109. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  7110. * Default is `1`.
  7111. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  7112. * Default is `0`.
  7113. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  7114. * Default is `0`.
  7115. * @param {?=} locale A locale code for the locale format rules to use.
  7116. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  7117. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  7118. * @return {?}
  7119. */
  7120. transform(value, digitsInfo, locale) {
  7121. if (isEmpty(value))
  7122. return null;
  7123. locale = locale || this._locale;
  7124. try {
  7125. /** @type {?} */
  7126. const num = strToNumber(value);
  7127. return formatPercent(num, locale, digitsInfo);
  7128. }
  7129. catch (error) {
  7130. throw invalidPipeArgumentError(PercentPipe, error.message);
  7131. }
  7132. }
  7133. }
  7134. PercentPipe.decorators = [
  7135. { type: Injectable },
  7136. { type: Pipe, args: [{ name: 'percent' },] }
  7137. ];
  7138. /** @nocollapse */
  7139. PercentPipe.ctorParameters = () => [
  7140. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  7141. ];
  7142. /**
  7143. * \@ngModule CommonModule
  7144. * \@description
  7145. *
  7146. * Transforms a number to a currency string, formatted according to locale rules
  7147. * that determine group sizing and separator, decimal-point character,
  7148. * and other locale-specific configurations.
  7149. *
  7150. * @see `getCurrencySymbol()`
  7151. * @see `formatCurrency()`
  7152. *
  7153. * \@usageNotes
  7154. * The following code shows how the pipe transforms numbers
  7155. * into text strings, according to various format specifications,
  7156. * where the caller's default locale is `en-US`.
  7157. *
  7158. * <code-example path="common/pipes/ts/currency_pipe.ts" region='CurrencyPipe'></code-example>
  7159. *
  7160. * \@publicApi
  7161. */
  7162. class CurrencyPipe {
  7163. /**
  7164. * @param {?} _locale
  7165. */
  7166. constructor(_locale) {
  7167. this._locale = _locale;
  7168. }
  7169. /**
  7170. *
  7171. * @param {?} value The number to be formatted as currency.
  7172. * @param {?=} currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code,
  7173. * such as `USD` for the US dollar and `EUR` for the euro.
  7174. * @param {?=} display The format for the currency indicator. One of the following:
  7175. * - `code`: Show the code (such as `USD`).
  7176. * - `symbol`(default): Show the symbol (such as `$`).
  7177. * - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their
  7178. * currency.
  7179. * For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the
  7180. * locale has no narrow symbol, uses the standard symbol for the locale.
  7181. * - String: Use the given string value instead of a code or a symbol.
  7182. * For example, an empty string will suppress the currency & symbol.
  7183. * - Boolean (marked deprecated in v5): `true` for symbol and false for `code`.
  7184. *
  7185. * @param {?=} digitsInfo Decimal representation options, specified by a string
  7186. * in the following format:<br>
  7187. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  7188. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  7189. * Default is `1`.
  7190. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  7191. * Default is `2`.
  7192. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  7193. * Default is `2`.
  7194. * If not provided, the number will be formatted with the proper amount of digits,
  7195. * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.
  7196. * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.
  7197. * @param {?=} locale A locale code for the locale format rules to use.
  7198. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  7199. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  7200. * @return {?}
  7201. */
  7202. transform(value, currencyCode, display = 'symbol', digitsInfo, locale) {
  7203. if (isEmpty(value))
  7204. return null;
  7205. locale = locale || this._locale;
  7206. if (typeof display === 'boolean') {
  7207. if ((/** @type {?} */ (console)) && (/** @type {?} */ (console.warn))) {
  7208. console.warn(`Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are "code", "symbol" or "symbol-narrow".`);
  7209. }
  7210. display = display ? 'symbol' : 'code';
  7211. }
  7212. /** @type {?} */
  7213. let currency = currencyCode || 'USD';
  7214. if (display !== 'code') {
  7215. if (display === 'symbol' || display === 'symbol-narrow') {
  7216. currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
  7217. }
  7218. else {
  7219. currency = display;
  7220. }
  7221. }
  7222. try {
  7223. /** @type {?} */
  7224. const num = strToNumber(value);
  7225. return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
  7226. }
  7227. catch (error) {
  7228. throw invalidPipeArgumentError(CurrencyPipe, error.message);
  7229. }
  7230. }
  7231. }
  7232. CurrencyPipe.decorators = [
  7233. { type: Injectable },
  7234. { type: Pipe, args: [{ name: 'currency' },] }
  7235. ];
  7236. /** @nocollapse */
  7237. CurrencyPipe.ctorParameters = () => [
  7238. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  7239. ];
  7240. /**
  7241. * @param {?} value
  7242. * @return {?}
  7243. */
  7244. function isEmpty(value) {
  7245. return value == null || value === '' || value !== value;
  7246. }
  7247. /**
  7248. * Transforms a string into a number (if needed).
  7249. * @param {?} value
  7250. * @return {?}
  7251. */
  7252. function strToNumber(value) {
  7253. // Convert strings to numbers
  7254. if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
  7255. return Number(value);
  7256. }
  7257. if (typeof value !== 'number') {
  7258. throw new Error(`${value} is not a number`);
  7259. }
  7260. return value;
  7261. }
  7262. /**
  7263. * @fileoverview added by tsickle
  7264. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7265. */
  7266. /**
  7267. * \@ngModule CommonModule
  7268. * \@description
  7269. *
  7270. * Creates a new `Array` or `String` containing a subset (slice) of the elements.
  7271. *
  7272. * \@usageNotes
  7273. *
  7274. * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
  7275. * and `String.prototype.slice()`.
  7276. *
  7277. * When operating on an `Array`, the returned `Array` is always a copy even when all
  7278. * the elements are being returned.
  7279. *
  7280. * When operating on a blank value, the pipe returns the blank value.
  7281. *
  7282. * ### List Example
  7283. *
  7284. * This `ngFor` example:
  7285. *
  7286. * {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
  7287. *
  7288. * produces the following:
  7289. *
  7290. * ```html
  7291. * <li>b</li>
  7292. * <li>c</li>
  7293. * ```
  7294. *
  7295. * ### String Examples
  7296. *
  7297. * {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
  7298. *
  7299. * \@publicApi
  7300. */
  7301. class SlicePipe {
  7302. /**
  7303. * @param {?} value
  7304. * @param {?} start
  7305. * @param {?=} end
  7306. * @return {?}
  7307. */
  7308. transform(value, start, end) {
  7309. if (value == null)
  7310. return value;
  7311. if (!this.supports(value)) {
  7312. throw invalidPipeArgumentError(SlicePipe, value);
  7313. }
  7314. return value.slice(start, end);
  7315. }
  7316. /**
  7317. * @private
  7318. * @param {?} obj
  7319. * @return {?}
  7320. */
  7321. supports(obj) { return typeof obj === 'string' || Array.isArray(obj); }
  7322. }
  7323. SlicePipe.decorators = [
  7324. { type: Injectable },
  7325. { type: Pipe, args: [{ name: 'slice', pure: false },] }
  7326. ];
  7327. /**
  7328. * @fileoverview added by tsickle
  7329. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7330. */
  7331. /**
  7332. * A collection of Angular pipes that are likely to be used in each and every application.
  7333. * @type {?}
  7334. */
  7335. const COMMON_PIPES = [
  7336. AsyncPipe,
  7337. UpperCasePipe,
  7338. LowerCasePipe,
  7339. JsonPipe,
  7340. SlicePipe,
  7341. DecimalPipe,
  7342. PercentPipe,
  7343. TitleCasePipe,
  7344. CurrencyPipe,
  7345. DatePipe,
  7346. I18nPluralPipe,
  7347. I18nSelectPipe,
  7348. KeyValuePipe,
  7349. ];
  7350. /**
  7351. * @fileoverview added by tsickle
  7352. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7353. */
  7354. // Note: This does not contain the location providers,
  7355. // as they need some platform specific implementations to work.
  7356. /**
  7357. * Exports all the basic Angular directives and pipes,
  7358. * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
  7359. * Re-exported by `BrowserModule`, which is included automatically in the root
  7360. * `AppModule` when you create a new app with the CLI `new` command.
  7361. *
  7362. * * The `providers` options configure the NgModule's injector to provide
  7363. * localization dependencies to members.
  7364. * * The `exports` options make the declared directives and pipes available for import
  7365. * by other NgModules.
  7366. *
  7367. * \@publicApi
  7368. */
  7369. class CommonModule {
  7370. }
  7371. CommonModule.decorators = [
  7372. { type: NgModule, args: [{
  7373. declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
  7374. exports: [COMMON_DIRECTIVES, COMMON_PIPES],
  7375. providers: [
  7376. { provide: NgLocalization, useClass: NgLocaleLocalization },
  7377. ],
  7378. },] }
  7379. ];
  7380. const ɵ0$2 = getPluralCase;
  7381. /**
  7382. * A module that contains the deprecated i18n pipes.
  7383. *
  7384. * @deprecated from v5
  7385. * \@publicApi
  7386. */
  7387. class DeprecatedI18NPipesModule {
  7388. }
  7389. DeprecatedI18NPipesModule.decorators = [
  7390. { type: NgModule, args: [{
  7391. declarations: [COMMON_DEPRECATED_I18N_PIPES],
  7392. exports: [COMMON_DEPRECATED_I18N_PIPES],
  7393. providers: [{ provide: DEPRECATED_PLURAL_FN, useValue: ɵ0$2 }],
  7394. },] }
  7395. ];
  7396. /**
  7397. * @fileoverview added by tsickle
  7398. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7399. */
  7400. /**
  7401. * A DI Token representing the main rendering context. In a browser this is the DOM Document.
  7402. *
  7403. * Note: Document might not be available in the Application Context when Application and Rendering
  7404. * Contexts are not the same (e.g. when running the application into a Web Worker).
  7405. *
  7406. * \@publicApi
  7407. * @type {?}
  7408. */
  7409. const DOCUMENT = new InjectionToken('DocumentToken');
  7410. /**
  7411. * @fileoverview added by tsickle
  7412. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7413. */
  7414. /**
  7415. * @license
  7416. * Copyright Google Inc. All Rights Reserved.
  7417. *
  7418. * Use of this source code is governed by an MIT-style license that can be
  7419. * found in the LICENSE file at https://angular.io/license
  7420. */
  7421. /** @type {?} */
  7422. const PLATFORM_BROWSER_ID = 'browser';
  7423. /** @type {?} */
  7424. const PLATFORM_SERVER_ID = 'server';
  7425. /** @type {?} */
  7426. const PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
  7427. /** @type {?} */
  7428. const PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
  7429. /**
  7430. * Returns whether a platform id represents a browser platform.
  7431. * \@publicApi
  7432. * @param {?} platformId
  7433. * @return {?}
  7434. */
  7435. function isPlatformBrowser(platformId) {
  7436. return platformId === PLATFORM_BROWSER_ID;
  7437. }
  7438. /**
  7439. * Returns whether a platform id represents a server platform.
  7440. * \@publicApi
  7441. * @param {?} platformId
  7442. * @return {?}
  7443. */
  7444. function isPlatformServer(platformId) {
  7445. return platformId === PLATFORM_SERVER_ID;
  7446. }
  7447. /**
  7448. * Returns whether a platform id represents a web worker app platform.
  7449. * \@publicApi
  7450. * @param {?} platformId
  7451. * @return {?}
  7452. */
  7453. function isPlatformWorkerApp(platformId) {
  7454. return platformId === PLATFORM_WORKER_APP_ID;
  7455. }
  7456. /**
  7457. * Returns whether a platform id represents a web worker UI platform.
  7458. * \@publicApi
  7459. * @param {?} platformId
  7460. * @return {?}
  7461. */
  7462. function isPlatformWorkerUi(platformId) {
  7463. return platformId === PLATFORM_WORKER_UI_ID;
  7464. }
  7465. /**
  7466. * @fileoverview added by tsickle
  7467. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7468. */
  7469. /**
  7470. * \@publicApi
  7471. * @type {?}
  7472. */
  7473. const VERSION = new Version('8.1.0');
  7474. /**
  7475. * @fileoverview added by tsickle
  7476. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7477. */
  7478. /**
  7479. * Defines a scroll position manager. Implemented by `BrowserViewportScroller`.
  7480. *
  7481. * \@publicApi
  7482. * @abstract
  7483. */
  7484. class ViewportScroller {
  7485. }
  7486. // De-sugared tree-shakable injection
  7487. // See #23917
  7488. /** @nocollapse */
  7489. /** @nocollapse */ ViewportScroller.ngInjectableDef = ɵɵdefineInjectable({
  7490. token: ViewportScroller,
  7491. providedIn: 'root',
  7492. factory: (/**
  7493. * @nocollapse @return {?}
  7494. */
  7495. () => new BrowserViewportScroller(ɵɵinject(DOCUMENT), window, ɵɵinject(ErrorHandler)))
  7496. });
  7497. /**
  7498. * Manages the scroll position for a browser window.
  7499. */
  7500. class BrowserViewportScroller {
  7501. /**
  7502. * @param {?} document
  7503. * @param {?} window
  7504. * @param {?} errorHandler
  7505. */
  7506. constructor(document, window, errorHandler) {
  7507. this.document = document;
  7508. this.window = window;
  7509. this.errorHandler = errorHandler;
  7510. this.offset = (/**
  7511. * @return {?}
  7512. */
  7513. () => [0, 0]);
  7514. }
  7515. /**
  7516. * Configures the top offset used when scrolling to an anchor.
  7517. * @param {?} offset A position in screen coordinates (a tuple with x and y values)
  7518. * or a function that returns the top offset position.
  7519. *
  7520. * @return {?}
  7521. */
  7522. setOffset(offset) {
  7523. if (Array.isArray(offset)) {
  7524. this.offset = (/**
  7525. * @return {?}
  7526. */
  7527. () => offset);
  7528. }
  7529. else {
  7530. this.offset = offset;
  7531. }
  7532. }
  7533. /**
  7534. * Retrieves the current scroll position.
  7535. * @return {?} The position in screen coordinates.
  7536. */
  7537. getScrollPosition() {
  7538. if (this.supportScrollRestoration()) {
  7539. return [this.window.scrollX, this.window.scrollY];
  7540. }
  7541. else {
  7542. return [0, 0];
  7543. }
  7544. }
  7545. /**
  7546. * Sets the scroll position.
  7547. * @param {?} position The new position in screen coordinates.
  7548. * @return {?}
  7549. */
  7550. scrollToPosition(position) {
  7551. if (this.supportScrollRestoration()) {
  7552. this.window.scrollTo(position[0], position[1]);
  7553. }
  7554. }
  7555. /**
  7556. * Scrolls to an anchor element.
  7557. * @param {?} anchor The ID of the anchor element.
  7558. * @return {?}
  7559. */
  7560. scrollToAnchor(anchor) {
  7561. if (this.supportScrollRestoration()) {
  7562. // Escape anything passed to `querySelector` as it can throw errors and stop the application
  7563. // from working if invalid values are passed.
  7564. if (this.window.CSS && this.window.CSS.escape) {
  7565. anchor = this.window.CSS.escape(anchor);
  7566. }
  7567. else {
  7568. anchor = anchor.replace(/(\"|\'\ |:|\.|\[|\]|,|=)/g, '\\$1');
  7569. }
  7570. try {
  7571. /** @type {?} */
  7572. const elSelectedById = this.document.querySelector(`#${anchor}`);
  7573. if (elSelectedById) {
  7574. this.scrollToElement(elSelectedById);
  7575. return;
  7576. }
  7577. /** @type {?} */
  7578. const elSelectedByName = this.document.querySelector(`[name='${anchor}']`);
  7579. if (elSelectedByName) {
  7580. this.scrollToElement(elSelectedByName);
  7581. return;
  7582. }
  7583. }
  7584. catch (e) {
  7585. this.errorHandler.handleError(e);
  7586. }
  7587. }
  7588. }
  7589. /**
  7590. * Disables automatic scroll restoration provided by the browser.
  7591. * @param {?} scrollRestoration
  7592. * @return {?}
  7593. */
  7594. setHistoryScrollRestoration(scrollRestoration) {
  7595. if (this.supportScrollRestoration()) {
  7596. /** @type {?} */
  7597. const history = this.window.history;
  7598. if (history && history.scrollRestoration) {
  7599. history.scrollRestoration = scrollRestoration;
  7600. }
  7601. }
  7602. }
  7603. /**
  7604. * @private
  7605. * @param {?} el
  7606. * @return {?}
  7607. */
  7608. scrollToElement(el) {
  7609. /** @type {?} */
  7610. const rect = el.getBoundingClientRect();
  7611. /** @type {?} */
  7612. const left = rect.left + this.window.pageXOffset;
  7613. /** @type {?} */
  7614. const top = rect.top + this.window.pageYOffset;
  7615. /** @type {?} */
  7616. const offset = this.offset();
  7617. this.window.scrollTo(left - offset[0], top - offset[1]);
  7618. }
  7619. /**
  7620. * We only support scroll restoration when we can get a hold of window.
  7621. * This means that we do not support this behavior when running in a web worker.
  7622. *
  7623. * Lifting this restriction right now would require more changes in the dom adapter.
  7624. * Since webworkers aren't widely used, we will lift it once RouterScroller is
  7625. * battle-tested.
  7626. * @private
  7627. * @return {?}
  7628. */
  7629. supportScrollRestoration() {
  7630. try {
  7631. return !!this.window && !!this.window.scrollTo;
  7632. }
  7633. catch (_a) {
  7634. return false;
  7635. }
  7636. }
  7637. }
  7638. /**
  7639. * Provides an empty implementation of the viewport scroller. This will
  7640. * live in \@angular/common as it will be used by both platform-server and platform-webworker.
  7641. */
  7642. class NullViewportScroller {
  7643. /**
  7644. * Empty implementation
  7645. * @param {?} offset
  7646. * @return {?}
  7647. */
  7648. setOffset(offset) { }
  7649. /**
  7650. * Empty implementation
  7651. * @return {?}
  7652. */
  7653. getScrollPosition() { return [0, 0]; }
  7654. /**
  7655. * Empty implementation
  7656. * @param {?} position
  7657. * @return {?}
  7658. */
  7659. scrollToPosition(position) { }
  7660. /**
  7661. * Empty implementation
  7662. * @param {?} anchor
  7663. * @return {?}
  7664. */
  7665. scrollToAnchor(anchor) { }
  7666. /**
  7667. * Empty implementation
  7668. * @param {?} scrollRestoration
  7669. * @return {?}
  7670. */
  7671. setHistoryScrollRestoration(scrollRestoration) { }
  7672. }
  7673. /**
  7674. * @fileoverview added by tsickle
  7675. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7676. */
  7677. /**
  7678. * @fileoverview added by tsickle
  7679. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7680. */
  7681. /**
  7682. * @fileoverview added by tsickle
  7683. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7684. */
  7685. /**
  7686. * Generated bundle index. Do not edit.
  7687. */
  7688. export { COMMON_DIRECTIVES as ɵangular_packages_common_common_c, NgClassImplProvider as ɵangular_packages_common_common_h, NgClassImplProvider__PRE_R3__ as ɵangular_packages_common_common_g, NgClassR3Impl as ɵangular_packages_common_common_f, NgStyleImplProvider as ɵangular_packages_common_common_k, NgStyleImplProvider__PRE_R3__ as ɵangular_packages_common_common_j, NgStyleR3Impl as ɵangular_packages_common_common_i, DEPRECATED_PLURAL_FN as ɵangular_packages_common_common_a, getPluralCase as ɵangular_packages_common_common_b, COMMON_DEPRECATED_I18N_PIPES as ɵangular_packages_common_common_e, COMMON_PIPES as ɵangular_packages_common_common_d, registerLocaleData as ɵregisterLocaleData, registerLocaleData, formatDate, formatCurrency, formatNumber, formatPercent, NgLocaleLocalization, NgLocalization, Plural, NumberFormatStyle, FormStyle, TranslationWidth, FormatWidth, NumberSymbol, WeekDay, getNumberOfCurrencyDigits, getCurrencySymbol, getLocaleDayPeriods, getLocaleDayNames, getLocaleMonthNames, getLocaleId, getLocaleEraNames, getLocaleWeekEndRange, getLocaleFirstDayOfWeek, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocalePluralCase, getLocaleTimeFormat, getLocaleNumberSymbol, getLocaleNumberFormat, getLocaleCurrencyName, getLocaleCurrencySymbol, parseCookieValue as ɵparseCookieValue, CommonModule, DeprecatedI18NPipesModule, NgClass, NgClassBase, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgStyleBase, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet, DOCUMENT, AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe, KeyValuePipe, DeprecatedDatePipe, DeprecatedCurrencyPipe, DeprecatedDecimalPipe, DeprecatedPercentPipe, PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PLATFORM_WORKER_APP_ID as ɵPLATFORM_WORKER_APP_ID, PLATFORM_WORKER_UI_ID as ɵPLATFORM_WORKER_UI_ID, isPlatformBrowser, isPlatformServer, isPlatformWorkerApp, isPlatformWorkerUi, VERSION, ViewportScroller, NullViewportScroller as ɵNullViewportScroller, NgClassImplProvider__POST_R3__ as ɵNgClassImplProvider__POST_R3__, NgClassR2Impl as ɵNgClassR2Impl, NgClassImpl as ɵNgClassImpl, NgStyleImplProvider__POST_R3__ as ɵNgStyleImplProvider__POST_R3__, NgStyleR2Impl as ɵNgStyleR2Impl, NgStyleImpl as ɵNgStyleImpl, ngStyleDirectiveDef__POST_R3__ as ɵngStyleDirectiveDef__POST_R3__, ngClassDirectiveDef__POST_R3__ as ɵngClassDirectiveDef__POST_R3__, PlatformLocation, LOCATION_INITIALIZED, LocationStrategy, APP_BASE_HREF, HashLocationStrategy, PathLocationStrategy, Location };
  7689. //# sourceMappingURL=common.js.map