common_module-Dx7dWex5.mjs 201 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { Optional, Inject, Injectable, ɵgetLocalePluralCase as _getLocalePluralCase, ɵfindLocaleData as _findLocaleData, ɵLocaleDataIndex as _LocaleDataIndex, ɵgetLocaleCurrencyCode as _getLocaleCurrencyCode, LOCALE_ID, ɵstringify as _stringify, Input, Directive, createNgModule, NgModuleRef, ɵRuntimeError as _RuntimeError, Host, Attribute, RendererStyleFlags2, ɵisPromise as _isPromise, ɵisSubscribable as _isSubscribable, untracked, Pipe, InjectionToken, DEFAULT_CURRENCY_CODE, NgModule } from '@angular/core';
  8. import { LocationStrategy, joinWithSlash, normalizeQueryParams, PlatformLocation, APP_BASE_HREF } from './location-Dq4mJT-A.mjs';
  9. /**
  10. * @description
  11. * A {@link LocationStrategy} used to configure the {@link Location} service to
  12. * represent its state in the
  13. * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
  14. * of the browser's URL.
  15. *
  16. * For instance, if you call `location.go('/foo')`, the browser's URL will become
  17. * `example.com#/foo`.
  18. *
  19. * @usageNotes
  20. *
  21. * ### Example
  22. *
  23. * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}
  24. *
  25. * @publicApi
  26. */
  27. class HashLocationStrategy extends LocationStrategy {
  28. _platformLocation;
  29. _baseHref = '';
  30. _removeListenerFns = [];
  31. constructor(_platformLocation, _baseHref) {
  32. super();
  33. this._platformLocation = _platformLocation;
  34. if (_baseHref != null) {
  35. this._baseHref = _baseHref;
  36. }
  37. }
  38. /** @docs-private */
  39. ngOnDestroy() {
  40. while (this._removeListenerFns.length) {
  41. this._removeListenerFns.pop()();
  42. }
  43. }
  44. onPopState(fn) {
  45. this._removeListenerFns.push(this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn));
  46. }
  47. getBaseHref() {
  48. return this._baseHref;
  49. }
  50. path(includeHash = false) {
  51. // the hash value is always prefixed with a `#`
  52. // and if it is empty then it will stay empty
  53. const path = this._platformLocation.hash ?? '#';
  54. return path.length > 0 ? path.substring(1) : path;
  55. }
  56. prepareExternalUrl(internal) {
  57. const url = joinWithSlash(this._baseHref, internal);
  58. return url.length > 0 ? '#' + url : url;
  59. }
  60. pushState(state, title, path, queryParams) {
  61. const url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)) ||
  62. this._platformLocation.pathname;
  63. this._platformLocation.pushState(state, title, url);
  64. }
  65. replaceState(state, title, path, queryParams) {
  66. const url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)) ||
  67. this._platformLocation.pathname;
  68. this._platformLocation.replaceState(state, title, url);
  69. }
  70. forward() {
  71. this._platformLocation.forward();
  72. }
  73. back() {
  74. this._platformLocation.back();
  75. }
  76. getState() {
  77. return this._platformLocation.getState();
  78. }
  79. historyGo(relativePosition = 0) {
  80. this._platformLocation.historyGo?.(relativePosition);
  81. }
  82. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: HashLocationStrategy, deps: [{ token: PlatformLocation }, { token: APP_BASE_HREF, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
  83. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: HashLocationStrategy });
  84. }
  85. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: HashLocationStrategy, decorators: [{
  86. type: Injectable
  87. }], ctorParameters: () => [{ type: PlatformLocation }, { type: undefined, decorators: [{
  88. type: Optional
  89. }, {
  90. type: Inject,
  91. args: [APP_BASE_HREF]
  92. }] }] });
  93. /** @internal */
  94. const CURRENCIES_EN = { "ADP": [undefined, undefined, 0], "AFN": [undefined, "؋", 0], "ALL": [undefined, undefined, 0], "AMD": [undefined, "֏", 2], "AOA": [undefined, "Kz"], "ARS": [undefined, "$"], "AUD": ["A$", "$"], "AZN": [undefined, "₼"], "BAM": [undefined, "KM"], "BBD": [undefined, "$"], "BDT": [undefined, "৳"], "BHD": [undefined, undefined, 3], "BIF": [undefined, undefined, 0], "BMD": [undefined, "$"], "BND": [undefined, "$"], "BOB": [undefined, "Bs"], "BRL": ["R$"], "BSD": [undefined, "$"], "BWP": [undefined, "P"], "BYN": [undefined, undefined, 2], "BYR": [undefined, undefined, 0], "BZD": [undefined, "$"], "CAD": ["CA$", "$", 2], "CHF": [undefined, undefined, 2], "CLF": [undefined, undefined, 4], "CLP": [undefined, "$", 0], "CNY": ["CN¥", "¥"], "COP": [undefined, "$", 2], "CRC": [undefined, "₡", 2], "CUC": [undefined, "$"], "CUP": [undefined, "$"], "CZK": [undefined, "Kč", 2], "DJF": [undefined, undefined, 0], "DKK": [undefined, "kr", 2], "DOP": [undefined, "$"], "EGP": [undefined, "E£"], "ESP": [undefined, "₧", 0], "EUR": ["€"], "FJD": [undefined, "$"], "FKP": [undefined, "£"], "GBP": ["£"], "GEL": [undefined, "₾"], "GHS": [undefined, "GH₵"], "GIP": [undefined, "£"], "GNF": [undefined, "FG", 0], "GTQ": [undefined, "Q"], "GYD": [undefined, "$", 2], "HKD": ["HK$", "$"], "HNL": [undefined, "L"], "HRK": [undefined, "kn"], "HUF": [undefined, "Ft", 2], "IDR": [undefined, "Rp", 2], "ILS": ["₪"], "INR": ["₹"], "IQD": [undefined, undefined, 0], "IRR": [undefined, undefined, 0], "ISK": [undefined, "kr", 0], "ITL": [undefined, undefined, 0], "JMD": [undefined, "$"], "JOD": [undefined, undefined, 3], "JPY": ["¥", undefined, 0], "KHR": [undefined, "៛"], "KMF": [undefined, "CF", 0], "KPW": [undefined, "₩", 0], "KRW": ["₩", undefined, 0], "KWD": [undefined, undefined, 3], "KYD": [undefined, "$"], "KZT": [undefined, "₸"], "LAK": [undefined, "₭", 0], "LBP": [undefined, "L£", 0], "LKR": [undefined, "Rs"], "LRD": [undefined, "$"], "LTL": [undefined, "Lt"], "LUF": [undefined, undefined, 0], "LVL": [undefined, "Ls"], "LYD": [undefined, undefined, 3], "MGA": [undefined, "Ar", 0], "MGF": [undefined, undefined, 0], "MMK": [undefined, "K", 0], "MNT": [undefined, "₮", 2], "MRO": [undefined, undefined, 0], "MUR": [undefined, "Rs", 2], "MXN": ["MX$", "$"], "MYR": [undefined, "RM"], "NAD": [undefined, "$"], "NGN": [undefined, "₦"], "NIO": [undefined, "C$"], "NOK": [undefined, "kr", 2], "NPR": [undefined, "Rs"], "NZD": ["NZ$", "$"], "OMR": [undefined, undefined, 3], "PHP": ["₱"], "PKR": [undefined, "Rs", 2], "PLN": [undefined, "zł"], "PYG": [undefined, "₲", 0], "RON": [undefined, "lei"], "RSD": [undefined, undefined, 0], "RUB": [undefined, "₽"], "RWF": [undefined, "RF", 0], "SBD": [undefined, "$"], "SEK": [undefined, "kr", 2], "SGD": [undefined, "$"], "SHP": [undefined, "£"], "SLE": [undefined, undefined, 2], "SLL": [undefined, undefined, 0], "SOS": [undefined, undefined, 0], "SRD": [undefined, "$"], "SSP": [undefined, "£"], "STD": [undefined, undefined, 0], "STN": [undefined, "Db"], "SYP": [undefined, "£", 0], "THB": [undefined, "฿"], "TMM": [undefined, undefined, 0], "TND": [undefined, undefined, 3], "TOP": [undefined, "T$"], "TRL": [undefined, undefined, 0], "TRY": [undefined, "₺"], "TTD": [undefined, "$"], "TWD": ["NT$", "$", 2], "TZS": [undefined, undefined, 2], "UAH": [undefined, "₴"], "UGX": [undefined, undefined, 0], "USD": ["$"], "UYI": [undefined, undefined, 0], "UYU": [undefined, "$"], "UYW": [undefined, undefined, 4], "UZS": [undefined, undefined, 2], "VEF": [undefined, "Bs", 2], "VND": ["₫", undefined, 0], "VUV": [undefined, undefined, 0], "XAF": ["FCFA", undefined, 0], "XCD": ["EC$", "$"], "XOF": ["F CFA", undefined, 0], "XPF": ["CFPF", undefined, 0], "XXX": ["¤"], "YER": [undefined, undefined, 0], "ZAR": [undefined, "R"], "ZMK": [undefined, undefined, 0], "ZMW": [undefined, "ZK"], "ZWD": [undefined, undefined, 0] };
  95. /**
  96. * Format styles that can be used to represent numbers.
  97. * @see {@link getLocaleNumberFormat}
  98. * @see [Internationalization (i18n) Guide](guide/i18n)
  99. *
  100. * @publicApi
  101. *
  102. * @deprecated `getLocaleNumberFormat` is deprecated
  103. */
  104. var NumberFormatStyle;
  105. (function (NumberFormatStyle) {
  106. NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
  107. NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
  108. NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
  109. NumberFormatStyle[NumberFormatStyle["Scientific"] = 3] = "Scientific";
  110. })(NumberFormatStyle || (NumberFormatStyle = {}));
  111. /**
  112. * Plurality cases used for translating plurals to different languages.
  113. *
  114. * @see {@link NgPlural}
  115. * @see {@link NgPluralCase}
  116. * @see [Internationalization (i18n) Guide](guide/i18n)
  117. *
  118. * @publicApi
  119. *
  120. * @deprecated `getLocalePluralCase` is deprecated
  121. */
  122. var Plural;
  123. (function (Plural) {
  124. Plural[Plural["Zero"] = 0] = "Zero";
  125. Plural[Plural["One"] = 1] = "One";
  126. Plural[Plural["Two"] = 2] = "Two";
  127. Plural[Plural["Few"] = 3] = "Few";
  128. Plural[Plural["Many"] = 4] = "Many";
  129. Plural[Plural["Other"] = 5] = "Other";
  130. })(Plural || (Plural = {}));
  131. /**
  132. * Context-dependant translation forms for strings.
  133. * Typically the standalone version is for the nominative form of the word,
  134. * and the format version is used for the genitive case.
  135. * @see [CLDR website](http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles)
  136. * @see [Internationalization (i18n) Guide](guide/i18n)
  137. *
  138. * @publicApi
  139. *
  140. * @deprecated locale data getters are deprecated
  141. */
  142. var FormStyle;
  143. (function (FormStyle) {
  144. FormStyle[FormStyle["Format"] = 0] = "Format";
  145. FormStyle[FormStyle["Standalone"] = 1] = "Standalone";
  146. })(FormStyle || (FormStyle = {}));
  147. /**
  148. * String widths available for translations.
  149. * The specific character widths are locale-specific.
  150. * Examples are given for the word "Sunday" in English.
  151. *
  152. * @publicApi
  153. *
  154. * @deprecated locale data getters are deprecated
  155. */
  156. var TranslationWidth;
  157. (function (TranslationWidth) {
  158. /** 1 character for `en-US`. For example: 'S' */
  159. TranslationWidth[TranslationWidth["Narrow"] = 0] = "Narrow";
  160. /** 3 characters for `en-US`. For example: 'Sun' */
  161. TranslationWidth[TranslationWidth["Abbreviated"] = 1] = "Abbreviated";
  162. /** Full length for `en-US`. For example: "Sunday" */
  163. TranslationWidth[TranslationWidth["Wide"] = 2] = "Wide";
  164. /** 2 characters for `en-US`, For example: "Su" */
  165. TranslationWidth[TranslationWidth["Short"] = 3] = "Short";
  166. })(TranslationWidth || (TranslationWidth = {}));
  167. /**
  168. * String widths available for date-time formats.
  169. * The specific character widths are locale-specific.
  170. * Examples are given for `en-US`.
  171. *
  172. * @see {@link getLocaleDateFormat}
  173. * @see {@link getLocaleTimeFormat}
  174. * @see {@link getLocaleDateTimeFormat}
  175. * @see [Internationalization (i18n) Guide](guide/i18n)
  176. * @publicApi
  177. *
  178. * @deprecated Date locale data getters are deprecated
  179. */
  180. var FormatWidth;
  181. (function (FormatWidth) {
  182. /**
  183. * For `en-US`, `'M/d/yy, h:mm a'`
  184. * (Example: `6/15/15, 9:03 AM`)
  185. */
  186. FormatWidth[FormatWidth["Short"] = 0] = "Short";
  187. /**
  188. * For `en-US`, `'MMM d, y, h:mm:ss a'`
  189. * (Example: `Jun 15, 2015, 9:03:01 AM`)
  190. */
  191. FormatWidth[FormatWidth["Medium"] = 1] = "Medium";
  192. /**
  193. * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
  194. * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
  195. */
  196. FormatWidth[FormatWidth["Long"] = 2] = "Long";
  197. /**
  198. * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
  199. * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
  200. */
  201. FormatWidth[FormatWidth["Full"] = 3] = "Full";
  202. })(FormatWidth || (FormatWidth = {}));
  203. // This needs to be an object literal, rather than an enum, because TypeScript 5.4+
  204. // doesn't allow numeric keys and we have `Infinity` and `NaN`.
  205. /**
  206. * Symbols that can be used to replace placeholders in number patterns.
  207. * Examples are based on `en-US` values.
  208. *
  209. * @see {@link getLocaleNumberSymbol}
  210. * @see [Internationalization (i18n) Guide](guide/i18n)
  211. *
  212. * @publicApi
  213. *
  214. * @deprecated `getLocaleNumberSymbol` is deprecated
  215. *
  216. * @object-literal-as-enum
  217. */
  218. const NumberSymbol = {
  219. /**
  220. * Decimal separator.
  221. * For `en-US`, the dot character.
  222. * Example: 2,345`.`67
  223. */
  224. Decimal: 0,
  225. /**
  226. * Grouping separator, typically for thousands.
  227. * For `en-US`, the comma character.
  228. * Example: 2`,`345.67
  229. */
  230. Group: 1,
  231. /**
  232. * List-item separator.
  233. * Example: "one, two, and three"
  234. */
  235. List: 2,
  236. /**
  237. * Sign for percentage (out of 100).
  238. * Example: 23.4%
  239. */
  240. PercentSign: 3,
  241. /**
  242. * Sign for positive numbers.
  243. * Example: +23
  244. */
  245. PlusSign: 4,
  246. /**
  247. * Sign for negative numbers.
  248. * Example: -23
  249. */
  250. MinusSign: 5,
  251. /**
  252. * Computer notation for exponential value (n times a power of 10).
  253. * Example: 1.2E3
  254. */
  255. Exponential: 6,
  256. /**
  257. * Human-readable format of exponential.
  258. * Example: 1.2x103
  259. */
  260. SuperscriptingExponent: 7,
  261. /**
  262. * Sign for permille (out of 1000).
  263. * Example: 23.4‰
  264. */
  265. PerMille: 8,
  266. /**
  267. * Infinity, can be used with plus and minus.
  268. * Example: ∞, +∞, -∞
  269. */
  270. Infinity: 9,
  271. /**
  272. * Not a number.
  273. * Example: NaN
  274. */
  275. NaN: 10,
  276. /**
  277. * Symbol used between time units.
  278. * Example: 10:52
  279. */
  280. TimeSeparator: 11,
  281. /**
  282. * Decimal separator for currency values (fallback to `Decimal`).
  283. * Example: $2,345.67
  284. */
  285. CurrencyDecimal: 12,
  286. /**
  287. * Group separator for currency values (fallback to `Group`).
  288. * Example: $2,345.67
  289. */
  290. CurrencyGroup: 13,
  291. };
  292. /**
  293. * The value for each day of the week, based on the `en-US` locale
  294. *
  295. * @publicApi
  296. *
  297. * @deprecated Week locale getters are deprecated
  298. */
  299. var WeekDay;
  300. (function (WeekDay) {
  301. WeekDay[WeekDay["Sunday"] = 0] = "Sunday";
  302. WeekDay[WeekDay["Monday"] = 1] = "Monday";
  303. WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday";
  304. WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday";
  305. WeekDay[WeekDay["Thursday"] = 4] = "Thursday";
  306. WeekDay[WeekDay["Friday"] = 5] = "Friday";
  307. WeekDay[WeekDay["Saturday"] = 6] = "Saturday";
  308. })(WeekDay || (WeekDay = {}));
  309. /**
  310. * Retrieves the locale ID from the currently loaded locale.
  311. * The loaded locale could be, for example, a global one rather than a regional one.
  312. * @param locale A locale code, such as `fr-FR`.
  313. * @returns The locale code. For example, `fr`.
  314. * @see [Internationalization (i18n) Guide](guide/i18n)
  315. *
  316. * @publicApi
  317. *
  318. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  319. * This function serves no purpose when relying on the `Intl` API.
  320. */
  321. function getLocaleId(locale) {
  322. return _findLocaleData(locale)[_LocaleDataIndex.LocaleId];
  323. }
  324. /**
  325. * Retrieves day period strings for the given locale.
  326. *
  327. * @param locale A locale code for the locale format rules to use.
  328. * @param formStyle The required grammatical form.
  329. * @param width The required character width.
  330. * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.
  331. * @see [Internationalization (i18n) Guide](guide/i18n)
  332. *
  333. * @publicApi
  334. *
  335. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  336. * Use `Intl.DateTimeFormat` for date formating instead.
  337. */
  338. function getLocaleDayPeriods(locale, formStyle, width) {
  339. const data = _findLocaleData(locale);
  340. const amPmData = [
  341. data[_LocaleDataIndex.DayPeriodsFormat],
  342. data[_LocaleDataIndex.DayPeriodsStandalone],
  343. ];
  344. const amPm = getLastDefinedValue(amPmData, formStyle);
  345. return getLastDefinedValue(amPm, width);
  346. }
  347. /**
  348. * Retrieves days of the week for the given locale, using the Gregorian calendar.
  349. *
  350. * @param locale A locale code for the locale format rules to use.
  351. * @param formStyle The required grammatical form.
  352. * @param width The required character width.
  353. * @returns An array of localized name strings.
  354. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
  355. * @see [Internationalization (i18n) Guide](guide/i18n)
  356. *
  357. * @publicApi
  358. *
  359. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  360. * Use `Intl.DateTimeFormat` for date formating instead.
  361. */
  362. function getLocaleDayNames(locale, formStyle, width) {
  363. const data = _findLocaleData(locale);
  364. const daysData = [
  365. data[_LocaleDataIndex.DaysFormat],
  366. data[_LocaleDataIndex.DaysStandalone],
  367. ];
  368. const days = getLastDefinedValue(daysData, formStyle);
  369. return getLastDefinedValue(days, width);
  370. }
  371. /**
  372. * Retrieves months of the year for the given locale, using the Gregorian calendar.
  373. *
  374. * @param locale A locale code for the locale format rules to use.
  375. * @param formStyle The required grammatical form.
  376. * @param width The required character width.
  377. * @returns An array of localized name strings.
  378. * For example, `[January, February, ...]` for `en-US`.
  379. * @see [Internationalization (i18n) Guide](guide/i18n)
  380. *
  381. * @publicApi
  382. *
  383. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  384. * Use `Intl.DateTimeFormat` for date formating instead.
  385. */
  386. function getLocaleMonthNames(locale, formStyle, width) {
  387. const data = _findLocaleData(locale);
  388. const monthsData = [
  389. data[_LocaleDataIndex.MonthsFormat],
  390. data[_LocaleDataIndex.MonthsStandalone],
  391. ];
  392. const months = getLastDefinedValue(monthsData, formStyle);
  393. return getLastDefinedValue(months, width);
  394. }
  395. /**
  396. * Retrieves Gregorian-calendar eras for the given locale.
  397. * @param locale A locale code for the locale format rules to use.
  398. * @param width The required character width.
  399. * @returns An array of localized era strings.
  400. * For example, `[AD, BC]` for `en-US`.
  401. * @see [Internationalization (i18n) Guide](guide/i18n)
  402. *
  403. * @publicApi
  404. *
  405. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  406. * Use `Intl.DateTimeFormat` for date formating instead.
  407. */
  408. function getLocaleEraNames(locale, width) {
  409. const data = _findLocaleData(locale);
  410. const erasData = data[_LocaleDataIndex.Eras];
  411. return getLastDefinedValue(erasData, width);
  412. }
  413. /**
  414. * Retrieves the first day of the week for the given locale.
  415. *
  416. * @param locale A locale code for the locale format rules to use.
  417. * @returns A day index number, using the 0-based week-day index for `en-US`
  418. * (Sunday = 0, Monday = 1, ...).
  419. * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
  420. * @see [Internationalization (i18n) Guide](guide/i18n)
  421. *
  422. * @publicApi
  423. *
  424. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  425. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
  426. * You may want to rely on the following alternatives:
  427. * - Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (monday) if `getWeekInfo` is not supported.
  428. * - Other librairies like [`date-fns`](https://date-fns.org/), [`day.js`](https://day.js.org/en/) or [`weekstart`](https://www.npmjs.com/package/weekstart) library provide their own locale based data for the first day of the week.
  429. */
  430. function getLocaleFirstDayOfWeek(locale) {
  431. const data = _findLocaleData(locale);
  432. return data[_LocaleDataIndex.FirstDayOfWeek];
  433. }
  434. /**
  435. * Range of week days that are considered the week-end for the given locale.
  436. *
  437. * @param locale A locale code for the locale format rules to use.
  438. * @returns The range of day values, `[startDay, endDay]`.
  439. * @see [Internationalization (i18n) Guide](guide/i18n)
  440. *
  441. * @publicApi
  442. *
  443. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  444. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
  445. * Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (Saturday+Sunday) if `getWeekInfo` is not supported .
  446. */
  447. function getLocaleWeekEndRange(locale) {
  448. const data = _findLocaleData(locale);
  449. return data[_LocaleDataIndex.WeekendRange];
  450. }
  451. /**
  452. * Retrieves a localized date-value formatting string.
  453. *
  454. * @param locale A locale code for the locale format rules to use.
  455. * @param width The format type.
  456. * @returns The localized formatting string.
  457. * @see {@link FormatWidth}
  458. * @see [Internationalization (i18n) Guide](guide/i18n)
  459. *
  460. * @publicApi
  461. *
  462. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  463. * Use `Intl.DateTimeFormat` for date formating instead.
  464. */
  465. function getLocaleDateFormat(locale, width) {
  466. const data = _findLocaleData(locale);
  467. return getLastDefinedValue(data[_LocaleDataIndex.DateFormat], width);
  468. }
  469. /**
  470. * Retrieves a localized time-value formatting string.
  471. *
  472. * @param locale A locale code for the locale format rules to use.
  473. * @param width The format type.
  474. * @returns The localized formatting string.
  475. * @see {@link FormatWidth}
  476. * @see [Internationalization (i18n) Guide](guide/i18n)
  477. * @publicApi
  478. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  479. * Use `Intl.DateTimeFormat` for date formating instead.
  480. */
  481. function getLocaleTimeFormat(locale, width) {
  482. const data = _findLocaleData(locale);
  483. return getLastDefinedValue(data[_LocaleDataIndex.TimeFormat], width);
  484. }
  485. /**
  486. * Retrieves a localized date-time formatting string.
  487. *
  488. * @param locale A locale code for the locale format rules to use.
  489. * @param width The format type.
  490. * @returns The localized formatting string.
  491. * @see {@link FormatWidth}
  492. * @see [Internationalization (i18n) Guide](guide/i18n)
  493. *
  494. * @publicApi
  495. *
  496. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  497. * Use `Intl.DateTimeFormat` for date formating instead.
  498. */
  499. function getLocaleDateTimeFormat(locale, width) {
  500. const data = _findLocaleData(locale);
  501. const dateTimeFormatData = data[_LocaleDataIndex.DateTimeFormat];
  502. return getLastDefinedValue(dateTimeFormatData, width);
  503. }
  504. /**
  505. * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
  506. * @param locale The locale code.
  507. * @param symbol The symbol to localize. Must be one of `NumberSymbol`.
  508. * @returns The character for the localized symbol.
  509. * @see {@link NumberSymbol}
  510. * @see [Internationalization (i18n) Guide](guide/i18n)
  511. *
  512. * @publicApi
  513. *
  514. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  515. * Use `Intl.NumberFormat` to format numbers instead.
  516. */
  517. function getLocaleNumberSymbol(locale, symbol) {
  518. const data = _findLocaleData(locale);
  519. const res = data[_LocaleDataIndex.NumberSymbols][symbol];
  520. if (typeof res === 'undefined') {
  521. if (symbol === NumberSymbol.CurrencyDecimal) {
  522. return data[_LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
  523. }
  524. else if (symbol === NumberSymbol.CurrencyGroup) {
  525. return data[_LocaleDataIndex.NumberSymbols][NumberSymbol.Group];
  526. }
  527. }
  528. return res;
  529. }
  530. /**
  531. * Retrieves a number format for a given locale.
  532. *
  533. * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
  534. * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
  535. * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
  536. *
  537. * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
  538. * that stand for the decimal separator, and so on, and are NOT real characters.
  539. * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
  540. * your language the decimal point is written with a comma. The symbols should be replaced by the
  541. * local equivalents, using the appropriate `NumberSymbol` for your language.
  542. *
  543. * Here are the special characters used in number patterns:
  544. *
  545. * | Symbol | Meaning |
  546. * |--------|---------|
  547. * | . | Replaced automatically by the character used for the decimal point. |
  548. * | , | Replaced by the "grouping" (thousands) separator. |
  549. * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
  550. * | # | Replaced by a digit (or nothing if there aren't enough). |
  551. * | ¤ | Replaced by a currency symbol, such as $ or USD. |
  552. * | % | Marks a percent format. The % symbol may change position, but must be retained. |
  553. * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
  554. * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
  555. *
  556. * @param locale A locale code for the locale format rules to use.
  557. * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
  558. * @returns The localized format string.
  559. * @see {@link NumberFormatStyle}
  560. * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)
  561. * @see [Internationalization (i18n) Guide](guide/i18n)
  562. *
  563. * @publicApi
  564. *
  565. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  566. * Let `Intl.NumberFormat` determine the number format instead
  567. */
  568. function getLocaleNumberFormat(locale, type) {
  569. const data = _findLocaleData(locale);
  570. return data[_LocaleDataIndex.NumberFormats][type];
  571. }
  572. /**
  573. * Retrieves the symbol used to represent the currency for the main country
  574. * corresponding to a given locale. For example, '$' for `en-US`.
  575. *
  576. * @param locale A locale code for the locale format rules to use.
  577. * @returns The localized symbol character,
  578. * or `null` if the main country cannot be determined.
  579. * @see [Internationalization (i18n) Guide](guide/i18n)
  580. *
  581. * @publicApi
  582. *
  583. * @deprecated Use the `Intl` API to format a currency with from currency code
  584. */
  585. function getLocaleCurrencySymbol(locale) {
  586. const data = _findLocaleData(locale);
  587. return data[_LocaleDataIndex.CurrencySymbol] || null;
  588. }
  589. /**
  590. * Retrieves the name of the currency for the main country corresponding
  591. * to a given locale. For example, 'US Dollar' for `en-US`.
  592. * @param locale A locale code for the locale format rules to use.
  593. * @returns The currency name,
  594. * or `null` if the main country cannot be determined.
  595. * @see [Internationalization (i18n) Guide](guide/i18n)
  596. *
  597. * @publicApi
  598. *
  599. * @deprecated Use the `Intl` API to format a currency with from currency code
  600. */
  601. function getLocaleCurrencyName(locale) {
  602. const data = _findLocaleData(locale);
  603. return data[_LocaleDataIndex.CurrencyName] || null;
  604. }
  605. /**
  606. * Retrieves the default currency code for the given locale.
  607. *
  608. * The default is defined as the first currency which is still in use.
  609. *
  610. * @param locale The code of the locale whose currency code we want.
  611. * @returns The code of the default currency for the given locale.
  612. *
  613. * @publicApi
  614. *
  615. * @deprecated We recommend you create a map of locale to ISO 4217 currency codes.
  616. * Time relative currency data is provided by the CLDR project. See https://www.unicode.org/cldr/charts/44/supplemental/detailed_territory_currency_information.html
  617. */
  618. function getLocaleCurrencyCode(locale) {
  619. return _getLocaleCurrencyCode(locale);
  620. }
  621. /**
  622. * Retrieves the currency values for a given locale.
  623. * @param locale A locale code for the locale format rules to use.
  624. * @returns The currency values.
  625. * @see [Internationalization (i18n) Guide](guide/i18n)
  626. */
  627. function getLocaleCurrencies(locale) {
  628. const data = _findLocaleData(locale);
  629. return data[_LocaleDataIndex.Currencies];
  630. }
  631. /**
  632. * @publicApi
  633. *
  634. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  635. * Use `Intl.PluralRules` instead
  636. */
  637. const getLocalePluralCase = _getLocalePluralCase;
  638. function checkFullData(data) {
  639. if (!data[_LocaleDataIndex.ExtraData]) {
  640. 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.`);
  641. }
  642. }
  643. /**
  644. * Retrieves locale-specific rules used to determine which day period to use
  645. * when more than one period is defined for a locale.
  646. *
  647. * There is a rule for each defined day period. The
  648. * first rule is applied to the first day period and so on.
  649. * Fall back to AM/PM when no rules are available.
  650. *
  651. * A rule can specify a period as time range, or as a single time value.
  652. *
  653. * This functionality is only available when you have loaded the full locale data.
  654. * See the ["I18n guide"](guide/i18n/format-data-locale).
  655. *
  656. * @param locale A locale code for the locale format rules to use.
  657. * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
  658. * or null if no periods are available.
  659. *
  660. * @see {@link getLocaleExtraDayPeriods}
  661. * @see [Internationalization (i18n) Guide](guide/i18n)
  662. *
  663. * @publicApi
  664. *
  665. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  666. * Let `Intl.DateTimeFormat` determine the day period instead.
  667. */
  668. function getLocaleExtraDayPeriodRules(locale) {
  669. const data = _findLocaleData(locale);
  670. checkFullData(data);
  671. const rules = data[_LocaleDataIndex.ExtraData][2 /* ɵExtraLocaleDataIndex.ExtraDayPeriodsRules */] || [];
  672. return rules.map((rule) => {
  673. if (typeof rule === 'string') {
  674. return extractTime(rule);
  675. }
  676. return [extractTime(rule[0]), extractTime(rule[1])];
  677. });
  678. }
  679. /**
  680. * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
  681. * in different languages.
  682. * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
  683. *
  684. * This functionality is only available when you have loaded the full locale data.
  685. * See the ["I18n guide"](guide/i18n/format-data-locale).
  686. *
  687. * @param locale A locale code for the locale format rules to use.
  688. * @param formStyle The required grammatical form.
  689. * @param width The required character width.
  690. * @returns The translated day-period strings.
  691. * @see {@link getLocaleExtraDayPeriodRules}
  692. * @see [Internationalization (i18n) Guide](guide/i18n)
  693. *
  694. * @publicApi
  695. *
  696. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  697. * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead.
  698. */
  699. function getLocaleExtraDayPeriods(locale, formStyle, width) {
  700. const data = _findLocaleData(locale);
  701. checkFullData(data);
  702. const dayPeriodsData = [
  703. data[_LocaleDataIndex.ExtraData][0 /* ɵExtraLocaleDataIndex.ExtraDayPeriodFormats */],
  704. data[_LocaleDataIndex.ExtraData][1 /* ɵExtraLocaleDataIndex.ExtraDayPeriodStandalone */],
  705. ];
  706. const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
  707. return getLastDefinedValue(dayPeriods, width) || [];
  708. }
  709. /**
  710. * Retrieves the writing direction of a specified locale
  711. * @param locale A locale code for the locale format rules to use.
  712. * @publicApi
  713. * @returns 'rtl' or 'ltr'
  714. * @see [Internationalization (i18n) Guide](guide/i18n)
  715. *
  716. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  717. * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction.
  718. * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo).
  719. * has only partial support (Chromium M99 & Safari 17).
  720. * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue.
  721. */
  722. function getLocaleDirection(locale) {
  723. const data = _findLocaleData(locale);
  724. return data[_LocaleDataIndex.Directionality];
  725. }
  726. /**
  727. * Retrieves the first value that is defined in an array, going backwards from an index position.
  728. *
  729. * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
  730. * add the first value to the locale data arrays, and add other values only if they are different.
  731. *
  732. * @param data The data array to retrieve from.
  733. * @param index A 0-based index into the array to start from.
  734. * @returns The value immediately before the given index position.
  735. * @see [Internationalization (i18n) Guide](guide/i18n)
  736. *
  737. */
  738. function getLastDefinedValue(data, index) {
  739. for (let i = index; i > -1; i--) {
  740. if (typeof data[i] !== 'undefined') {
  741. return data[i];
  742. }
  743. }
  744. throw new Error('Locale data API: locale data undefined');
  745. }
  746. /**
  747. * Extracts the hours and minutes from a string like "15:45"
  748. */
  749. function extractTime(time) {
  750. const [h, m] = time.split(':');
  751. return { hours: +h, minutes: +m };
  752. }
  753. /**
  754. * Retrieves the currency symbol for a given currency code.
  755. *
  756. * For example, for the default `en-US` locale, the code `USD` can
  757. * be represented by the narrow symbol `$` or the wide symbol `US$`.
  758. *
  759. * @param code The currency code.
  760. * @param format The format, `wide` or `narrow`.
  761. * @param locale A locale code for the locale format rules to use.
  762. *
  763. * @returns The symbol, or the currency code if no symbol is available.
  764. * @see [Internationalization (i18n) Guide](guide/i18n)
  765. *
  766. * @publicApi
  767. *
  768. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  769. * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol.
  770. * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value`
  771. * returns `$` for USD currency code in the `en` locale.
  772. * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.
  773. */
  774. function getCurrencySymbol(code, format, locale = 'en') {
  775. const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
  776. const symbolNarrow = currency[1 /* ɵCurrencyIndex.SymbolNarrow */];
  777. if (format === 'narrow' && typeof symbolNarrow === 'string') {
  778. return symbolNarrow;
  779. }
  780. return currency[0 /* ɵCurrencyIndex.Symbol */] || code;
  781. }
  782. // Most currencies have cents, that's why the default is 2
  783. const DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
  784. /**
  785. * Reports the number of decimal digits for a given currency.
  786. * The value depends upon the presence of cents in that particular currency.
  787. *
  788. * @param code The currency code.
  789. * @returns The number of decimal digits, typically 0 or 2.
  790. * @see [Internationalization (i18n) Guide](guide/i18n)
  791. *
  792. * @publicApi
  793. *
  794. * @deprecated Angular recommends relying on the `Intl` API for i18n.
  795. * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency
  796. */
  797. function getNumberOfCurrencyDigits(code) {
  798. let digits;
  799. const currency = CURRENCIES_EN[code];
  800. if (currency) {
  801. digits = currency[2 /* ɵCurrencyIndex.NbOfDigits */];
  802. }
  803. return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
  804. }
  805. const ISO8601_DATE_REGEX = /^(\d{4,})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
  806. // 1 2 3 4 5 6 7 8 9 10 11
  807. const NAMED_FORMATS = {};
  808. const DATE_FORMATS_SPLIT = /((?:[^BEGHLMOSWYZabcdhmswyz']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|Y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|c{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]*)/;
  809. /**
  810. * @ngModule CommonModule
  811. * @description
  812. *
  813. * Formats a date according to locale rules.
  814. *
  815. * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
  816. * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
  817. * @param format The date-time components to include. See `DatePipe` for details.
  818. * @param locale A locale code for the locale format rules to use.
  819. * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`).
  820. * If not specified, uses host system settings.
  821. *
  822. * @returns The formatted date string.
  823. *
  824. * @see {@link DatePipe}
  825. * @see [Internationalization (i18n) Guide](guide/i18n)
  826. *
  827. * @publicApi
  828. */
  829. function formatDate(value, format, locale, timezone) {
  830. let date = toDate(value);
  831. const namedFormat = getNamedFormat(locale, format);
  832. format = namedFormat || format;
  833. let parts = [];
  834. let match;
  835. while (format) {
  836. match = DATE_FORMATS_SPLIT.exec(format);
  837. if (match) {
  838. parts = parts.concat(match.slice(1));
  839. const part = parts.pop();
  840. if (!part) {
  841. break;
  842. }
  843. format = part;
  844. }
  845. else {
  846. parts.push(format);
  847. break;
  848. }
  849. }
  850. let dateTimezoneOffset = date.getTimezoneOffset();
  851. if (timezone) {
  852. dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  853. date = convertTimezoneToLocal(date, timezone);
  854. }
  855. let text = '';
  856. parts.forEach((value) => {
  857. const dateFormatter = getDateFormatter(value);
  858. text += dateFormatter
  859. ? dateFormatter(date, locale, dateTimezoneOffset)
  860. : value === "''"
  861. ? "'"
  862. : value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
  863. });
  864. return text;
  865. }
  866. /**
  867. * Create a new Date object with the given date value, and the time set to midnight.
  868. *
  869. * We cannot use `new Date(year, month, date)` because it maps years between 0 and 99 to 1900-1999.
  870. * See: https://github.com/angular/angular/issues/40377
  871. *
  872. * Note that this function returns a Date object whose time is midnight in the current locale's
  873. * timezone. In the future we might want to change this to be midnight in UTC, but this would be a
  874. * considerable breaking change.
  875. */
  876. function createDate(year, month, date) {
  877. // The `newDate` is set to midnight (UTC) on January 1st 1970.
  878. // - In PST this will be December 31st 1969 at 4pm.
  879. // - In GMT this will be January 1st 1970 at 1am.
  880. // Note that they even have different years, dates and months!
  881. const newDate = new Date(0);
  882. // `setFullYear()` allows years like 0001 to be set correctly. This function does not
  883. // change the internal time of the date.
  884. // Consider calling `setFullYear(2019, 8, 20)` (September 20, 2019).
  885. // - In PST this will now be September 20, 2019 at 4pm
  886. // - In GMT this will now be September 20, 2019 at 1am
  887. newDate.setFullYear(year, month, date);
  888. // We want the final date to be at local midnight, so we reset the time.
  889. // - In PST this will now be September 20, 2019 at 12am
  890. // - In GMT this will now be September 20, 2019 at 12am
  891. newDate.setHours(0, 0, 0);
  892. return newDate;
  893. }
  894. function getNamedFormat(locale, format) {
  895. const localeId = getLocaleId(locale);
  896. NAMED_FORMATS[localeId] ??= {};
  897. if (NAMED_FORMATS[localeId][format]) {
  898. return NAMED_FORMATS[localeId][format];
  899. }
  900. let formatValue = '';
  901. switch (format) {
  902. case 'shortDate':
  903. formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
  904. break;
  905. case 'mediumDate':
  906. formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
  907. break;
  908. case 'longDate':
  909. formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
  910. break;
  911. case 'fullDate':
  912. formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
  913. break;
  914. case 'shortTime':
  915. formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
  916. break;
  917. case 'mediumTime':
  918. formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
  919. break;
  920. case 'longTime':
  921. formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
  922. break;
  923. case 'fullTime':
  924. formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
  925. break;
  926. case 'short':
  927. const shortTime = getNamedFormat(locale, 'shortTime');
  928. const shortDate = getNamedFormat(locale, 'shortDate');
  929. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [
  930. shortTime,
  931. shortDate,
  932. ]);
  933. break;
  934. case 'medium':
  935. const mediumTime = getNamedFormat(locale, 'mediumTime');
  936. const mediumDate = getNamedFormat(locale, 'mediumDate');
  937. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [
  938. mediumTime,
  939. mediumDate,
  940. ]);
  941. break;
  942. case 'long':
  943. const longTime = getNamedFormat(locale, 'longTime');
  944. const longDate = getNamedFormat(locale, 'longDate');
  945. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [
  946. longTime,
  947. longDate,
  948. ]);
  949. break;
  950. case 'full':
  951. const fullTime = getNamedFormat(locale, 'fullTime');
  952. const fullDate = getNamedFormat(locale, 'fullDate');
  953. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [
  954. fullTime,
  955. fullDate,
  956. ]);
  957. break;
  958. }
  959. if (formatValue) {
  960. NAMED_FORMATS[localeId][format] = formatValue;
  961. }
  962. return formatValue;
  963. }
  964. function formatDateTime(str, opt_values) {
  965. if (opt_values) {
  966. str = str.replace(/\{([^}]+)}/g, function (match, key) {
  967. return opt_values != null && key in opt_values ? opt_values[key] : match;
  968. });
  969. }
  970. return str;
  971. }
  972. function padNumber(num, digits, minusSign = '-', trim, negWrap) {
  973. let neg = '';
  974. if (num < 0 || (negWrap && num <= 0)) {
  975. if (negWrap) {
  976. num = -num + 1;
  977. }
  978. else {
  979. num = -num;
  980. neg = minusSign;
  981. }
  982. }
  983. let strNum = String(num);
  984. while (strNum.length < digits) {
  985. strNum = '0' + strNum;
  986. }
  987. if (trim) {
  988. strNum = strNum.slice(strNum.length - digits);
  989. }
  990. return neg + strNum;
  991. }
  992. function formatFractionalSeconds(milliseconds, digits) {
  993. const strMs = padNumber(milliseconds, 3);
  994. return strMs.substring(0, digits);
  995. }
  996. /**
  997. * Returns a date formatter that transforms a date into its locale digit representation
  998. */
  999. function dateGetter(name, size, offset = 0, trim = false, negWrap = false) {
  1000. return function (date, locale) {
  1001. let part = getDatePart(name, date);
  1002. if (offset > 0 || part > -offset) {
  1003. part += offset;
  1004. }
  1005. if (name === 3 /* DateType.Hours */) {
  1006. if (part === 0 && offset === -12) {
  1007. part = 12;
  1008. }
  1009. }
  1010. else if (name === 6 /* DateType.FractionalSeconds */) {
  1011. return formatFractionalSeconds(part, size);
  1012. }
  1013. const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1014. return padNumber(part, size, localeMinus, trim, negWrap);
  1015. };
  1016. }
  1017. function getDatePart(part, date) {
  1018. switch (part) {
  1019. case 0 /* DateType.FullYear */:
  1020. return date.getFullYear();
  1021. case 1 /* DateType.Month */:
  1022. return date.getMonth();
  1023. case 2 /* DateType.Date */:
  1024. return date.getDate();
  1025. case 3 /* DateType.Hours */:
  1026. return date.getHours();
  1027. case 4 /* DateType.Minutes */:
  1028. return date.getMinutes();
  1029. case 5 /* DateType.Seconds */:
  1030. return date.getSeconds();
  1031. case 6 /* DateType.FractionalSeconds */:
  1032. return date.getMilliseconds();
  1033. case 7 /* DateType.Day */:
  1034. return date.getDay();
  1035. default:
  1036. throw new Error(`Unknown DateType value "${part}".`);
  1037. }
  1038. }
  1039. /**
  1040. * Returns a date formatter that transforms a date into its locale string representation
  1041. */
  1042. function dateStrGetter(name, width, form = FormStyle.Format, extended = false) {
  1043. return function (date, locale) {
  1044. return getDateTranslation(date, locale, name, width, form, extended);
  1045. };
  1046. }
  1047. /**
  1048. * Returns the locale translation of a date for a given form, type and width
  1049. */
  1050. function getDateTranslation(date, locale, name, width, form, extended) {
  1051. switch (name) {
  1052. case 2 /* TranslationType.Months */:
  1053. return getLocaleMonthNames(locale, form, width)[date.getMonth()];
  1054. case 1 /* TranslationType.Days */:
  1055. return getLocaleDayNames(locale, form, width)[date.getDay()];
  1056. case 0 /* TranslationType.DayPeriods */:
  1057. const currentHours = date.getHours();
  1058. const currentMinutes = date.getMinutes();
  1059. if (extended) {
  1060. const rules = getLocaleExtraDayPeriodRules(locale);
  1061. const dayPeriods = getLocaleExtraDayPeriods(locale, form, width);
  1062. const index = rules.findIndex((rule) => {
  1063. if (Array.isArray(rule)) {
  1064. // morning, afternoon, evening, night
  1065. const [from, to] = rule;
  1066. const afterFrom = currentHours >= from.hours && currentMinutes >= from.minutes;
  1067. const beforeTo = currentHours < to.hours || (currentHours === to.hours && currentMinutes < to.minutes);
  1068. // We must account for normal rules that span a period during the day (e.g. 6am-9am)
  1069. // where `from` is less (earlier) than `to`. But also rules that span midnight (e.g.
  1070. // 10pm - 5am) where `from` is greater (later!) than `to`.
  1071. //
  1072. // In the first case the current time must be BOTH after `from` AND before `to`
  1073. // (e.g. 8am is after 6am AND before 10am).
  1074. //
  1075. // In the second case the current time must be EITHER after `from` OR before `to`
  1076. // (e.g. 4am is before 5am but not after 10pm; and 11pm is not before 5am but it is
  1077. // after 10pm).
  1078. if (from.hours < to.hours) {
  1079. if (afterFrom && beforeTo) {
  1080. return true;
  1081. }
  1082. }
  1083. else if (afterFrom || beforeTo) {
  1084. return true;
  1085. }
  1086. }
  1087. else {
  1088. // noon or midnight
  1089. if (rule.hours === currentHours && rule.minutes === currentMinutes) {
  1090. return true;
  1091. }
  1092. }
  1093. return false;
  1094. });
  1095. if (index !== -1) {
  1096. return dayPeriods[index];
  1097. }
  1098. }
  1099. // if no rules for the day periods, we use am/pm by default
  1100. return getLocaleDayPeriods(locale, form, width)[currentHours < 12 ? 0 : 1];
  1101. case 3 /* TranslationType.Eras */:
  1102. return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];
  1103. default:
  1104. // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
  1105. // However Closure Compiler does not understand that and reports an error in typed mode.
  1106. // The `throw new Error` below works around the problem, and the unexpected: never variable
  1107. // makes sure tsc still checks this code is unreachable.
  1108. const unexpected = name;
  1109. throw new Error(`unexpected translation type ${unexpected}`);
  1110. }
  1111. }
  1112. /**
  1113. * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
  1114. * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
  1115. * extended = +04:30)
  1116. */
  1117. function timeZoneGetter(width) {
  1118. return function (date, locale, offset) {
  1119. const zone = -1 * offset;
  1120. const minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1121. const hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
  1122. switch (width) {
  1123. case 0 /* ZoneWidth.Short */:
  1124. return ((zone >= 0 ? '+' : '') +
  1125. padNumber(hours, 2, minusSign) +
  1126. padNumber(Math.abs(zone % 60), 2, minusSign));
  1127. case 1 /* ZoneWidth.ShortGMT */:
  1128. return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 1, minusSign);
  1129. case 2 /* ZoneWidth.Long */:
  1130. return ('GMT' +
  1131. (zone >= 0 ? '+' : '') +
  1132. padNumber(hours, 2, minusSign) +
  1133. ':' +
  1134. padNumber(Math.abs(zone % 60), 2, minusSign));
  1135. case 3 /* ZoneWidth.Extended */:
  1136. if (offset === 0) {
  1137. return 'Z';
  1138. }
  1139. else {
  1140. return ((zone >= 0 ? '+' : '') +
  1141. padNumber(hours, 2, minusSign) +
  1142. ':' +
  1143. padNumber(Math.abs(zone % 60), 2, minusSign));
  1144. }
  1145. default:
  1146. throw new Error(`Unknown zone width "${width}"`);
  1147. }
  1148. };
  1149. }
  1150. const JANUARY = 0;
  1151. const THURSDAY = 4;
  1152. function getFirstThursdayOfYear(year) {
  1153. const firstDayOfYear = createDate(year, JANUARY, 1).getDay();
  1154. return createDate(year, 0, 1 + (firstDayOfYear <= THURSDAY ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
  1155. }
  1156. /**
  1157. * ISO Week starts on day 1 (Monday) and ends with day 0 (Sunday)
  1158. */
  1159. function getThursdayThisIsoWeek(datetime) {
  1160. // getDay returns 0-6 range with sunday as 0.
  1161. const currentDay = datetime.getDay();
  1162. // On a Sunday, read the previous Thursday since ISO weeks start on Monday.
  1163. const deltaToThursday = currentDay === 0 ? -3 : THURSDAY - currentDay;
  1164. return createDate(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + deltaToThursday);
  1165. }
  1166. function weekGetter(size, monthBased = false) {
  1167. return function (date, locale) {
  1168. let result;
  1169. if (monthBased) {
  1170. const nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
  1171. const today = date.getDate();
  1172. result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
  1173. }
  1174. else {
  1175. const thisThurs = getThursdayThisIsoWeek(date);
  1176. // Some days of a year are part of next year according to ISO 8601.
  1177. // Compute the firstThurs from the year of this week's Thursday
  1178. const firstThurs = getFirstThursdayOfYear(thisThurs.getFullYear());
  1179. const diff = thisThurs.getTime() - firstThurs.getTime();
  1180. result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
  1181. }
  1182. return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1183. };
  1184. }
  1185. /**
  1186. * Returns a date formatter that provides the week-numbering year for the input date.
  1187. */
  1188. function weekNumberingYearGetter(size, trim = false) {
  1189. return function (date, locale) {
  1190. const thisThurs = getThursdayThisIsoWeek(date);
  1191. const weekNumberingYear = thisThurs.getFullYear();
  1192. return padNumber(weekNumberingYear, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign), trim);
  1193. };
  1194. }
  1195. const DATE_FORMATS = {};
  1196. // Based on CLDR formats:
  1197. // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
  1198. // See also explanations: http://cldr.unicode.org/translation/date-time
  1199. // TODO(ocombe): support all missing cldr formats: U, Q, D, F, e, j, J, C, A, v, V, X, x
  1200. function getDateFormatter(format) {
  1201. if (DATE_FORMATS[format]) {
  1202. return DATE_FORMATS[format];
  1203. }
  1204. let formatter;
  1205. switch (format) {
  1206. // Era name (AD/BC)
  1207. case 'G':
  1208. case 'GG':
  1209. case 'GGG':
  1210. formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Abbreviated);
  1211. break;
  1212. case 'GGGG':
  1213. formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Wide);
  1214. break;
  1215. case 'GGGGG':
  1216. formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Narrow);
  1217. break;
  1218. // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
  1219. case 'y':
  1220. formatter = dateGetter(0 /* DateType.FullYear */, 1, 0, false, true);
  1221. break;
  1222. // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
  1223. case 'yy':
  1224. formatter = dateGetter(0 /* DateType.FullYear */, 2, 0, true, true);
  1225. break;
  1226. // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
  1227. case 'yyy':
  1228. formatter = dateGetter(0 /* DateType.FullYear */, 3, 0, false, true);
  1229. break;
  1230. // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
  1231. case 'yyyy':
  1232. formatter = dateGetter(0 /* DateType.FullYear */, 4, 0, false, true);
  1233. break;
  1234. // 1 digit representation of the week-numbering year, e.g. (AD 1 => 1, AD 199 => 199)
  1235. case 'Y':
  1236. formatter = weekNumberingYearGetter(1);
  1237. break;
  1238. // 2 digit representation of the week-numbering year, padded (00-99). (e.g. AD 2001 => 01, AD
  1239. // 2010 => 10)
  1240. case 'YY':
  1241. formatter = weekNumberingYearGetter(2, true);
  1242. break;
  1243. // 3 digit representation of the week-numbering year, padded (000-999). (e.g. AD 1 => 001, AD
  1244. // 2010 => 2010)
  1245. case 'YYY':
  1246. formatter = weekNumberingYearGetter(3);
  1247. break;
  1248. // 4 digit representation of the week-numbering year (e.g. AD 1 => 0001, AD 2010 => 2010)
  1249. case 'YYYY':
  1250. formatter = weekNumberingYearGetter(4);
  1251. break;
  1252. // Month of the year (1-12), numeric
  1253. case 'M':
  1254. case 'L':
  1255. formatter = dateGetter(1 /* DateType.Month */, 1, 1);
  1256. break;
  1257. case 'MM':
  1258. case 'LL':
  1259. formatter = dateGetter(1 /* DateType.Month */, 2, 1);
  1260. break;
  1261. // Month of the year (January, ...), string, format
  1262. case 'MMM':
  1263. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated);
  1264. break;
  1265. case 'MMMM':
  1266. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide);
  1267. break;
  1268. case 'MMMMM':
  1269. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow);
  1270. break;
  1271. // Month of the year (January, ...), string, standalone
  1272. case 'LLL':
  1273. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated, FormStyle.Standalone);
  1274. break;
  1275. case 'LLLL':
  1276. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide, FormStyle.Standalone);
  1277. break;
  1278. case 'LLLLL':
  1279. formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow, FormStyle.Standalone);
  1280. break;
  1281. // Week of the year (1, ... 52)
  1282. case 'w':
  1283. formatter = weekGetter(1);
  1284. break;
  1285. case 'ww':
  1286. formatter = weekGetter(2);
  1287. break;
  1288. // Week of the month (1, ...)
  1289. case 'W':
  1290. formatter = weekGetter(1, true);
  1291. break;
  1292. // Day of the month (1-31)
  1293. case 'd':
  1294. formatter = dateGetter(2 /* DateType.Date */, 1);
  1295. break;
  1296. case 'dd':
  1297. formatter = dateGetter(2 /* DateType.Date */, 2);
  1298. break;
  1299. // Day of the Week StandAlone (1, 1, Mon, Monday, M, Mo)
  1300. case 'c':
  1301. case 'cc':
  1302. formatter = dateGetter(7 /* DateType.Day */, 1);
  1303. break;
  1304. case 'ccc':
  1305. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated, FormStyle.Standalone);
  1306. break;
  1307. case 'cccc':
  1308. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide, FormStyle.Standalone);
  1309. break;
  1310. case 'ccccc':
  1311. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow, FormStyle.Standalone);
  1312. break;
  1313. case 'cccccc':
  1314. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short, FormStyle.Standalone);
  1315. break;
  1316. // Day of the Week
  1317. case 'E':
  1318. case 'EE':
  1319. case 'EEE':
  1320. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated);
  1321. break;
  1322. case 'EEEE':
  1323. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide);
  1324. break;
  1325. case 'EEEEE':
  1326. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow);
  1327. break;
  1328. case 'EEEEEE':
  1329. formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short);
  1330. break;
  1331. // Generic period of the day (am-pm)
  1332. case 'a':
  1333. case 'aa':
  1334. case 'aaa':
  1335. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated);
  1336. break;
  1337. case 'aaaa':
  1338. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide);
  1339. break;
  1340. case 'aaaaa':
  1341. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow);
  1342. break;
  1343. // Extended period of the day (midnight, at night, ...), standalone
  1344. case 'b':
  1345. case 'bb':
  1346. case 'bbb':
  1347. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
  1348. break;
  1349. case 'bbbb':
  1350. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Standalone, true);
  1351. break;
  1352. case 'bbbbb':
  1353. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Standalone, true);
  1354. break;
  1355. // Extended period of the day (midnight, night, ...), standalone
  1356. case 'B':
  1357. case 'BB':
  1358. case 'BBB':
  1359. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Format, true);
  1360. break;
  1361. case 'BBBB':
  1362. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Format, true);
  1363. break;
  1364. case 'BBBBB':
  1365. formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Format, true);
  1366. break;
  1367. // Hour in AM/PM, (1-12)
  1368. case 'h':
  1369. formatter = dateGetter(3 /* DateType.Hours */, 1, -12);
  1370. break;
  1371. case 'hh':
  1372. formatter = dateGetter(3 /* DateType.Hours */, 2, -12);
  1373. break;
  1374. // Hour of the day (0-23)
  1375. case 'H':
  1376. formatter = dateGetter(3 /* DateType.Hours */, 1);
  1377. break;
  1378. // Hour in day, padded (00-23)
  1379. case 'HH':
  1380. formatter = dateGetter(3 /* DateType.Hours */, 2);
  1381. break;
  1382. // Minute of the hour (0-59)
  1383. case 'm':
  1384. formatter = dateGetter(4 /* DateType.Minutes */, 1);
  1385. break;
  1386. case 'mm':
  1387. formatter = dateGetter(4 /* DateType.Minutes */, 2);
  1388. break;
  1389. // Second of the minute (0-59)
  1390. case 's':
  1391. formatter = dateGetter(5 /* DateType.Seconds */, 1);
  1392. break;
  1393. case 'ss':
  1394. formatter = dateGetter(5 /* DateType.Seconds */, 2);
  1395. break;
  1396. // Fractional second
  1397. case 'S':
  1398. formatter = dateGetter(6 /* DateType.FractionalSeconds */, 1);
  1399. break;
  1400. case 'SS':
  1401. formatter = dateGetter(6 /* DateType.FractionalSeconds */, 2);
  1402. break;
  1403. case 'SSS':
  1404. formatter = dateGetter(6 /* DateType.FractionalSeconds */, 3);
  1405. break;
  1406. // Timezone ISO8601 short format (-0430)
  1407. case 'Z':
  1408. case 'ZZ':
  1409. case 'ZZZ':
  1410. formatter = timeZoneGetter(0 /* ZoneWidth.Short */);
  1411. break;
  1412. // Timezone ISO8601 extended format (-04:30)
  1413. case 'ZZZZZ':
  1414. formatter = timeZoneGetter(3 /* ZoneWidth.Extended */);
  1415. break;
  1416. // Timezone GMT short format (GMT+4)
  1417. case 'O':
  1418. case 'OO':
  1419. case 'OOO':
  1420. // Should be location, but fallback to format O instead because we don't have the data yet
  1421. case 'z':
  1422. case 'zz':
  1423. case 'zzz':
  1424. formatter = timeZoneGetter(1 /* ZoneWidth.ShortGMT */);
  1425. break;
  1426. // Timezone GMT long format (GMT+0430)
  1427. case 'OOOO':
  1428. case 'ZZZZ':
  1429. // Should be location, but fallback to format O instead because we don't have the data yet
  1430. case 'zzzz':
  1431. formatter = timeZoneGetter(2 /* ZoneWidth.Long */);
  1432. break;
  1433. default:
  1434. return null;
  1435. }
  1436. DATE_FORMATS[format] = formatter;
  1437. return formatter;
  1438. }
  1439. function timezoneToOffset(timezone, fallback) {
  1440. // Support: IE 11 only, Edge 13-15+
  1441. // IE/Edge do not "understand" colon (`:`) in timezone
  1442. timezone = timezone.replace(/:/g, '');
  1443. const requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
  1444. return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
  1445. }
  1446. function addDateMinutes(date, minutes) {
  1447. date = new Date(date.getTime());
  1448. date.setMinutes(date.getMinutes() + minutes);
  1449. return date;
  1450. }
  1451. function convertTimezoneToLocal(date, timezone, reverse) {
  1452. const reverseValue = -1 ;
  1453. const dateTimezoneOffset = date.getTimezoneOffset();
  1454. const timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  1455. return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
  1456. }
  1457. /**
  1458. * Converts a value to date.
  1459. *
  1460. * Supported input formats:
  1461. * - `Date`
  1462. * - number: timestamp
  1463. * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
  1464. * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
  1465. * Note: ISO strings without time return a date without timeoffset.
  1466. *
  1467. * Throws if unable to convert to a date.
  1468. */
  1469. function toDate(value) {
  1470. if (isDate(value)) {
  1471. return value;
  1472. }
  1473. if (typeof value === 'number' && !isNaN(value)) {
  1474. return new Date(value);
  1475. }
  1476. if (typeof value === 'string') {
  1477. value = value.trim();
  1478. if (/^(\d{4}(-\d{1,2}(-\d{1,2})?)?)$/.test(value)) {
  1479. /* For ISO Strings without time the day, month and year must be extracted from the ISO String
  1480. before Date creation to avoid time offset and errors in the new Date.
  1481. If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
  1482. date, some browsers (e.g. IE 9) will throw an invalid Date error.
  1483. If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
  1484. is applied.
  1485. Note: ISO months are 0 for January, 1 for February, ... */
  1486. const [y, m = 1, d = 1] = value.split('-').map((val) => +val);
  1487. return createDate(y, m - 1, d);
  1488. }
  1489. const parsedNb = parseFloat(value);
  1490. // any string that only contains numbers, like "1234" but not like "1234hello"
  1491. if (!isNaN(value - parsedNb)) {
  1492. return new Date(parsedNb);
  1493. }
  1494. let match;
  1495. if ((match = value.match(ISO8601_DATE_REGEX))) {
  1496. return isoStringToDate(match);
  1497. }
  1498. }
  1499. const date = new Date(value);
  1500. if (!isDate(date)) {
  1501. throw new Error(`Unable to convert "${value}" into a date`);
  1502. }
  1503. return date;
  1504. }
  1505. /**
  1506. * Converts a date in ISO8601 to a Date.
  1507. * Used instead of `Date.parse` because of browser discrepancies.
  1508. */
  1509. function isoStringToDate(match) {
  1510. const date = new Date(0);
  1511. let tzHour = 0;
  1512. let tzMin = 0;
  1513. // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
  1514. const dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
  1515. const timeSetter = match[8] ? date.setUTCHours : date.setHours;
  1516. // if there is a timezone defined like "+01:00" or "+0100"
  1517. if (match[9]) {
  1518. tzHour = Number(match[9] + match[10]);
  1519. tzMin = Number(match[9] + match[11]);
  1520. }
  1521. dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
  1522. const h = Number(match[4] || 0) - tzHour;
  1523. const m = Number(match[5] || 0) - tzMin;
  1524. const s = Number(match[6] || 0);
  1525. // The ECMAScript specification (https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.11)
  1526. // defines that `DateTime` milliseconds should always be rounded down, so that `999.9ms`
  1527. // becomes `999ms`.
  1528. const ms = Math.floor(parseFloat('0.' + (match[7] || 0)) * 1000);
  1529. timeSetter.call(date, h, m, s, ms);
  1530. return date;
  1531. }
  1532. function isDate(value) {
  1533. return value instanceof Date && !isNaN(value.valueOf());
  1534. }
  1535. const NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
  1536. const MAX_DIGITS = 22;
  1537. const DECIMAL_SEP = '.';
  1538. const ZERO_CHAR = '0';
  1539. const PATTERN_SEP = ';';
  1540. const GROUP_SEP = ',';
  1541. const DIGIT_CHAR = '#';
  1542. const CURRENCY_CHAR = '¤';
  1543. const PERCENT_CHAR = '%';
  1544. /**
  1545. * Transforms a number to a locale string based on a style and a format.
  1546. */
  1547. function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent = false) {
  1548. let formattedText = '';
  1549. let isZero = false;
  1550. if (!isFinite(value)) {
  1551. formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
  1552. }
  1553. else {
  1554. let parsedNumber = parseNumber(value);
  1555. if (isPercent) {
  1556. parsedNumber = toPercent(parsedNumber);
  1557. }
  1558. let minInt = pattern.minInt;
  1559. let minFraction = pattern.minFrac;
  1560. let maxFraction = pattern.maxFrac;
  1561. if (digitsInfo) {
  1562. const parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
  1563. if (parts === null) {
  1564. throw new Error(`${digitsInfo} is not a valid digit info`);
  1565. }
  1566. const minIntPart = parts[1];
  1567. const minFractionPart = parts[3];
  1568. const maxFractionPart = parts[5];
  1569. if (minIntPart != null) {
  1570. minInt = parseIntAutoRadix(minIntPart);
  1571. }
  1572. if (minFractionPart != null) {
  1573. minFraction = parseIntAutoRadix(minFractionPart);
  1574. }
  1575. if (maxFractionPart != null) {
  1576. maxFraction = parseIntAutoRadix(maxFractionPart);
  1577. }
  1578. else if (minFractionPart != null && minFraction > maxFraction) {
  1579. maxFraction = minFraction;
  1580. }
  1581. }
  1582. roundNumber(parsedNumber, minFraction, maxFraction);
  1583. let digits = parsedNumber.digits;
  1584. let integerLen = parsedNumber.integerLen;
  1585. const exponent = parsedNumber.exponent;
  1586. let decimals = [];
  1587. isZero = digits.every((d) => !d);
  1588. // pad zeros for small numbers
  1589. for (; integerLen < minInt; integerLen++) {
  1590. digits.unshift(0);
  1591. }
  1592. // pad zeros for small numbers
  1593. for (; integerLen < 0; integerLen++) {
  1594. digits.unshift(0);
  1595. }
  1596. // extract decimals digits
  1597. if (integerLen > 0) {
  1598. decimals = digits.splice(integerLen, digits.length);
  1599. }
  1600. else {
  1601. decimals = digits;
  1602. digits = [0];
  1603. }
  1604. // format the integer digits with grouping separators
  1605. const groups = [];
  1606. if (digits.length >= pattern.lgSize) {
  1607. groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
  1608. }
  1609. while (digits.length > pattern.gSize) {
  1610. groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
  1611. }
  1612. if (digits.length) {
  1613. groups.unshift(digits.join(''));
  1614. }
  1615. formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
  1616. // append the decimal digits
  1617. if (decimals.length) {
  1618. formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
  1619. }
  1620. if (exponent) {
  1621. formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
  1622. }
  1623. }
  1624. if (value < 0 && !isZero) {
  1625. formattedText = pattern.negPre + formattedText + pattern.negSuf;
  1626. }
  1627. else {
  1628. formattedText = pattern.posPre + formattedText + pattern.posSuf;
  1629. }
  1630. return formattedText;
  1631. }
  1632. /**
  1633. * @ngModule CommonModule
  1634. * @description
  1635. *
  1636. * Formats a number as currency using locale rules.
  1637. *
  1638. * @param value The number to format.
  1639. * @param locale A locale code for the locale format rules to use.
  1640. * @param currency A string containing the currency symbol or its name,
  1641. * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
  1642. * of the function.
  1643. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
  1644. * currency code, such as `USD` for the US dollar and `EUR` for the euro.
  1645. * Used to determine the number of digits in the decimal part.
  1646. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  1647. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  1648. *
  1649. * @returns The formatted currency value.
  1650. *
  1651. * @see {@link formatNumber}
  1652. * @see {@link DecimalPipe}
  1653. * @see [Internationalization (i18n) Guide](guide/i18n)
  1654. *
  1655. * @publicApi
  1656. */
  1657. function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
  1658. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
  1659. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1660. pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);
  1661. pattern.maxFrac = pattern.minFrac;
  1662. const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
  1663. return (res
  1664. .replace(CURRENCY_CHAR, currency)
  1665. // if we have 2 time the currency character, the second one is ignored
  1666. .replace(CURRENCY_CHAR, '')
  1667. // If there is a spacing between currency character and the value and
  1668. // the currency character is suppressed by passing an empty string, the
  1669. // spacing character would remain as part of the string. Then we
  1670. // should remove it.
  1671. .trim());
  1672. }
  1673. /**
  1674. * @ngModule CommonModule
  1675. * @description
  1676. *
  1677. * Formats a number as a percentage according to locale rules.
  1678. *
  1679. * @param value The number to format.
  1680. * @param locale A locale code for the locale format rules to use.
  1681. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  1682. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  1683. *
  1684. * @returns The formatted percentage value.
  1685. *
  1686. * @see {@link formatNumber}
  1687. * @see {@link DecimalPipe}
  1688. * @see [Internationalization (i18n) Guide](guide/i18n)
  1689. * @publicApi
  1690. *
  1691. */
  1692. function formatPercent(value, locale, digitsInfo) {
  1693. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
  1694. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1695. const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
  1696. return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
  1697. }
  1698. /**
  1699. * @ngModule CommonModule
  1700. * @description
  1701. *
  1702. * Formats a number as text, with group sizing, separator, and other
  1703. * parameters based on the locale.
  1704. *
  1705. * @param value The number to format.
  1706. * @param locale A locale code for the locale format rules to use.
  1707. * @param digitsInfo Decimal representation options, specified by a string in the following format:
  1708. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  1709. *
  1710. * @returns The formatted text string.
  1711. * @see [Internationalization (i18n) Guide](guide/i18n)
  1712. *
  1713. * @publicApi
  1714. */
  1715. function formatNumber(value, locale, digitsInfo) {
  1716. const format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
  1717. const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1718. return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
  1719. }
  1720. function parseNumberFormat(format, minusSign = '-') {
  1721. const p = {
  1722. minInt: 1,
  1723. minFrac: 0,
  1724. maxFrac: 0,
  1725. posPre: '',
  1726. posSuf: '',
  1727. negPre: '',
  1728. negSuf: '',
  1729. gSize: 0,
  1730. lgSize: 0,
  1731. };
  1732. const patternParts = format.split(PATTERN_SEP);
  1733. const positive = patternParts[0];
  1734. const negative = patternParts[1];
  1735. const positiveParts = positive.indexOf(DECIMAL_SEP) !== -1
  1736. ? positive.split(DECIMAL_SEP)
  1737. : [
  1738. positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
  1739. positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1),
  1740. ], integer = positiveParts[0], fraction = positiveParts[1] || '';
  1741. p.posPre = integer.substring(0, integer.indexOf(DIGIT_CHAR));
  1742. for (let i = 0; i < fraction.length; i++) {
  1743. const ch = fraction.charAt(i);
  1744. if (ch === ZERO_CHAR) {
  1745. p.minFrac = p.maxFrac = i + 1;
  1746. }
  1747. else if (ch === DIGIT_CHAR) {
  1748. p.maxFrac = i + 1;
  1749. }
  1750. else {
  1751. p.posSuf += ch;
  1752. }
  1753. }
  1754. const groups = integer.split(GROUP_SEP);
  1755. p.gSize = groups[1] ? groups[1].length : 0;
  1756. p.lgSize = groups[2] || groups[1] ? (groups[2] || groups[1]).length : 0;
  1757. if (negative) {
  1758. const trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);
  1759. p.negPre = negative.substring(0, pos).replace(/'/g, '');
  1760. p.negSuf = negative.slice(pos + trunkLen).replace(/'/g, '');
  1761. }
  1762. else {
  1763. p.negPre = minusSign + p.posPre;
  1764. p.negSuf = p.posSuf;
  1765. }
  1766. return p;
  1767. }
  1768. // Transforms a parsed number into a percentage by multiplying it by 100
  1769. function toPercent(parsedNumber) {
  1770. // if the number is 0, don't do anything
  1771. if (parsedNumber.digits[0] === 0) {
  1772. return parsedNumber;
  1773. }
  1774. // Getting the current number of decimals
  1775. const fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
  1776. if (parsedNumber.exponent) {
  1777. parsedNumber.exponent += 2;
  1778. }
  1779. else {
  1780. if (fractionLen === 0) {
  1781. parsedNumber.digits.push(0, 0);
  1782. }
  1783. else if (fractionLen === 1) {
  1784. parsedNumber.digits.push(0);
  1785. }
  1786. parsedNumber.integerLen += 2;
  1787. }
  1788. return parsedNumber;
  1789. }
  1790. /**
  1791. * Parses a number.
  1792. * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
  1793. */
  1794. function parseNumber(num) {
  1795. let numStr = Math.abs(num) + '';
  1796. let exponent = 0, digits, integerLen;
  1797. let i, j, zeros;
  1798. // Decimal point?
  1799. if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
  1800. numStr = numStr.replace(DECIMAL_SEP, '');
  1801. }
  1802. // Exponential form?
  1803. if ((i = numStr.search(/e/i)) > 0) {
  1804. // Work out the exponent.
  1805. if (integerLen < 0)
  1806. integerLen = i;
  1807. integerLen += +numStr.slice(i + 1);
  1808. numStr = numStr.substring(0, i);
  1809. }
  1810. else if (integerLen < 0) {
  1811. // There was no decimal point or exponent so it is an integer.
  1812. integerLen = numStr.length;
  1813. }
  1814. // Count the number of leading zeros.
  1815. for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) {
  1816. /* empty */
  1817. }
  1818. if (i === (zeros = numStr.length)) {
  1819. // The digits are all zero.
  1820. digits = [0];
  1821. integerLen = 1;
  1822. }
  1823. else {
  1824. // Count the number of trailing zeros
  1825. zeros--;
  1826. while (numStr.charAt(zeros) === ZERO_CHAR)
  1827. zeros--;
  1828. // Trailing zeros are insignificant so ignore them
  1829. integerLen -= i;
  1830. digits = [];
  1831. // Convert string to array of digits without leading/trailing zeros.
  1832. for (j = 0; i <= zeros; i++, j++) {
  1833. digits[j] = Number(numStr.charAt(i));
  1834. }
  1835. }
  1836. // If the number overflows the maximum allowed digits then use an exponent.
  1837. if (integerLen > MAX_DIGITS) {
  1838. digits = digits.splice(0, MAX_DIGITS - 1);
  1839. exponent = integerLen - 1;
  1840. integerLen = 1;
  1841. }
  1842. return { digits, exponent, integerLen };
  1843. }
  1844. /**
  1845. * Round the parsed number to the specified number of decimal places
  1846. * This function changes the parsedNumber in-place
  1847. */
  1848. function roundNumber(parsedNumber, minFrac, maxFrac) {
  1849. if (minFrac > maxFrac) {
  1850. throw new Error(`The minimum number of digits after fraction (${minFrac}) is higher than the maximum (${maxFrac}).`);
  1851. }
  1852. let digits = parsedNumber.digits;
  1853. let fractionLen = digits.length - parsedNumber.integerLen;
  1854. const fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
  1855. // The index of the digit to where rounding is to occur
  1856. let roundAt = fractionSize + parsedNumber.integerLen;
  1857. let digit = digits[roundAt];
  1858. if (roundAt > 0) {
  1859. // Drop fractional digits beyond `roundAt`
  1860. digits.splice(Math.max(parsedNumber.integerLen, roundAt));
  1861. // Set non-fractional digits beyond `roundAt` to 0
  1862. for (let j = roundAt; j < digits.length; j++) {
  1863. digits[j] = 0;
  1864. }
  1865. }
  1866. else {
  1867. // We rounded to zero so reset the parsedNumber
  1868. fractionLen = Math.max(0, fractionLen);
  1869. parsedNumber.integerLen = 1;
  1870. digits.length = Math.max(1, (roundAt = fractionSize + 1));
  1871. digits[0] = 0;
  1872. for (let i = 1; i < roundAt; i++)
  1873. digits[i] = 0;
  1874. }
  1875. if (digit >= 5) {
  1876. if (roundAt - 1 < 0) {
  1877. for (let k = 0; k > roundAt; k--) {
  1878. digits.unshift(0);
  1879. parsedNumber.integerLen++;
  1880. }
  1881. digits.unshift(1);
  1882. parsedNumber.integerLen++;
  1883. }
  1884. else {
  1885. digits[roundAt - 1]++;
  1886. }
  1887. }
  1888. // Pad out with zeros to get the required fraction length
  1889. for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
  1890. digits.push(0);
  1891. let dropTrailingZeros = fractionSize !== 0;
  1892. // Minimal length = nb of decimals required + current nb of integers
  1893. // Any number besides that is optional and can be removed if it's a trailing 0
  1894. const minLen = minFrac + parsedNumber.integerLen;
  1895. // Do any carrying, e.g. a digit was rounded up to 10
  1896. const carry = digits.reduceRight(function (carry, d, i, digits) {
  1897. d = d + carry;
  1898. digits[i] = d < 10 ? d : d - 10; // d % 10
  1899. if (dropTrailingZeros) {
  1900. // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
  1901. if (digits[i] === 0 && i >= minLen) {
  1902. digits.pop();
  1903. }
  1904. else {
  1905. dropTrailingZeros = false;
  1906. }
  1907. }
  1908. return d >= 10 ? 1 : 0; // Math.floor(d / 10);
  1909. }, 0);
  1910. if (carry) {
  1911. digits.unshift(carry);
  1912. parsedNumber.integerLen++;
  1913. }
  1914. }
  1915. function parseIntAutoRadix(text) {
  1916. const result = parseInt(text);
  1917. if (isNaN(result)) {
  1918. throw new Error('Invalid integer literal when parsing ' + text);
  1919. }
  1920. return result;
  1921. }
  1922. /**
  1923. * @publicApi
  1924. */
  1925. class NgLocalization {
  1926. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocalization, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  1927. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocalization, providedIn: 'root', useFactory: (locale) => new NgLocaleLocalization(locale), deps: [{ token: LOCALE_ID }] });
  1928. }
  1929. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocalization, decorators: [{
  1930. type: Injectable,
  1931. args: [{
  1932. providedIn: 'root',
  1933. useFactory: (locale) => new NgLocaleLocalization(locale),
  1934. deps: [LOCALE_ID],
  1935. }]
  1936. }] });
  1937. /**
  1938. * Returns the plural category for a given value.
  1939. * - "=value" when the case exists,
  1940. * - the plural category otherwise
  1941. */
  1942. function getPluralCategory(value, cases, ngLocalization, locale) {
  1943. let key = `=${value}`;
  1944. if (cases.indexOf(key) > -1) {
  1945. return key;
  1946. }
  1947. key = ngLocalization.getPluralCategory(value, locale);
  1948. if (cases.indexOf(key) > -1) {
  1949. return key;
  1950. }
  1951. if (cases.indexOf('other') > -1) {
  1952. return 'other';
  1953. }
  1954. throw new Error(`No plural message found for value "${value}"`);
  1955. }
  1956. /**
  1957. * Returns the plural case based on the locale
  1958. *
  1959. * @publicApi
  1960. */
  1961. class NgLocaleLocalization extends NgLocalization {
  1962. locale;
  1963. constructor(locale) {
  1964. super();
  1965. this.locale = locale;
  1966. }
  1967. getPluralCategory(value, locale) {
  1968. const plural = getLocalePluralCase(locale || this.locale)(value);
  1969. switch (plural) {
  1970. case Plural.Zero:
  1971. return 'zero';
  1972. case Plural.One:
  1973. return 'one';
  1974. case Plural.Two:
  1975. return 'two';
  1976. case Plural.Few:
  1977. return 'few';
  1978. case Plural.Many:
  1979. return 'many';
  1980. default:
  1981. return 'other';
  1982. }
  1983. }
  1984. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocaleLocalization, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });
  1985. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocaleLocalization });
  1986. }
  1987. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgLocaleLocalization, decorators: [{
  1988. type: Injectable
  1989. }], ctorParameters: () => [{ type: undefined, decorators: [{
  1990. type: Inject,
  1991. args: [LOCALE_ID]
  1992. }] }] });
  1993. const WS_REGEXP = /\s+/;
  1994. const EMPTY_ARRAY = [];
  1995. /**
  1996. * @ngModule CommonModule
  1997. *
  1998. * @usageNotes
  1999. * ```html
  2000. * <some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element>
  2001. *
  2002. * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
  2003. * ```
  2004. *
  2005. * For more simple use cases you can use the [class bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
  2006. * It doesn't require importing a directive.
  2007. *
  2008. * ```html
  2009. * <some-element [class]="'first second'">...</some-element>
  2010. *
  2011. * <some-element [class.expanded]="isExpanded">...</some-element>
  2012. *
  2013. * <some-element [class]="['first', 'second']">...</some-element>
  2014. *
  2015. * <some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element>
  2016. * ```
  2017. * @description
  2018. *
  2019. * Adds and removes CSS classes on an HTML element.
  2020. *
  2021. * The CSS classes are updated as follows, depending on the type of the expression evaluation:
  2022. * - `string` - the CSS classes listed in the string (space delimited) are added,
  2023. * - `Array` - the CSS classes declared as Array elements are added,
  2024. * - `Object` - keys are CSS classes that get added when the expression given in the value
  2025. * evaluates to a truthy value, otherwise they are removed.
  2026. *
  2027. *
  2028. * @see [Class bindings](/guide/templates/binding#css-class-and-style-property-bindings)
  2029. *
  2030. * @publicApi
  2031. */
  2032. class NgClass {
  2033. _ngEl;
  2034. _renderer;
  2035. initialClasses = EMPTY_ARRAY;
  2036. rawClass;
  2037. stateMap = new Map();
  2038. constructor(_ngEl, _renderer) {
  2039. this._ngEl = _ngEl;
  2040. this._renderer = _renderer;
  2041. }
  2042. set klass(value) {
  2043. this.initialClasses = value != null ? value.trim().split(WS_REGEXP) : EMPTY_ARRAY;
  2044. }
  2045. set ngClass(value) {
  2046. this.rawClass = typeof value === 'string' ? value.trim().split(WS_REGEXP) : value;
  2047. }
  2048. /*
  2049. The NgClass directive uses the custom change detection algorithm for its inputs. The custom
  2050. algorithm is necessary since inputs are represented as complex object or arrays that need to be
  2051. deeply-compared.
  2052. This algorithm is perf-sensitive since NgClass is used very frequently and its poor performance
  2053. might negatively impact runtime performance of the entire change detection cycle. The design of
  2054. this algorithm is making sure that:
  2055. - there is no unnecessary DOM manipulation (CSS classes are added / removed from the DOM only when
  2056. needed), even if references to bound objects change;
  2057. - there is no memory allocation if nothing changes (even relatively modest memory allocation
  2058. during the change detection cycle can result in GC pauses for some of the CD cycles).
  2059. The algorithm works by iterating over the set of bound classes, staring with [class] binding and
  2060. then going over [ngClass] binding. For each CSS class name:
  2061. - check if it was seen before (this information is tracked in the state map) and if its value
  2062. changed;
  2063. - mark it as "touched" - names that are not marked are not present in the latest set of binding
  2064. and we can remove such class name from the internal data structures;
  2065. After iteration over all the CSS class names we've got data structure with all the information
  2066. necessary to synchronize changes to the DOM - it is enough to iterate over the state map, flush
  2067. changes to the DOM and reset internal data structures so those are ready for the next change
  2068. detection cycle.
  2069. */
  2070. ngDoCheck() {
  2071. // classes from the [class] binding
  2072. for (const klass of this.initialClasses) {
  2073. this._updateState(klass, true);
  2074. }
  2075. // classes from the [ngClass] binding
  2076. const rawClass = this.rawClass;
  2077. if (Array.isArray(rawClass) || rawClass instanceof Set) {
  2078. for (const klass of rawClass) {
  2079. this._updateState(klass, true);
  2080. }
  2081. }
  2082. else if (rawClass != null) {
  2083. for (const klass of Object.keys(rawClass)) {
  2084. this._updateState(klass, Boolean(rawClass[klass]));
  2085. }
  2086. }
  2087. this._applyStateDiff();
  2088. }
  2089. _updateState(klass, nextEnabled) {
  2090. const state = this.stateMap.get(klass);
  2091. if (state !== undefined) {
  2092. if (state.enabled !== nextEnabled) {
  2093. state.changed = true;
  2094. state.enabled = nextEnabled;
  2095. }
  2096. state.touched = true;
  2097. }
  2098. else {
  2099. this.stateMap.set(klass, { enabled: nextEnabled, changed: true, touched: true });
  2100. }
  2101. }
  2102. _applyStateDiff() {
  2103. for (const stateEntry of this.stateMap) {
  2104. const klass = stateEntry[0];
  2105. const state = stateEntry[1];
  2106. if (state.changed) {
  2107. this._toggleClass(klass, state.enabled);
  2108. state.changed = false;
  2109. }
  2110. else if (!state.touched) {
  2111. // A class that was previously active got removed from the new collection of classes -
  2112. // remove from the DOM as well.
  2113. if (state.enabled) {
  2114. this._toggleClass(klass, false);
  2115. }
  2116. this.stateMap.delete(klass);
  2117. }
  2118. state.touched = false;
  2119. }
  2120. }
  2121. _toggleClass(klass, enabled) {
  2122. if (ngDevMode) {
  2123. if (typeof klass !== 'string') {
  2124. throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${_stringify(klass)}`);
  2125. }
  2126. }
  2127. klass = klass.trim();
  2128. if (klass.length > 0) {
  2129. klass.split(WS_REGEXP).forEach((klass) => {
  2130. if (enabled) {
  2131. this._renderer.addClass(this._ngEl.nativeElement, klass);
  2132. }
  2133. else {
  2134. this._renderer.removeClass(this._ngEl.nativeElement, klass);
  2135. }
  2136. });
  2137. }
  2138. }
  2139. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgClass, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
  2140. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgClass, isStandalone: true, selector: "[ngClass]", inputs: { klass: ["class", "klass"], ngClass: "ngClass" }, ngImport: i0 });
  2141. }
  2142. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgClass, decorators: [{
  2143. type: Directive,
  2144. args: [{
  2145. selector: '[ngClass]',
  2146. }]
  2147. }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { klass: [{
  2148. type: Input,
  2149. args: ['class']
  2150. }], ngClass: [{
  2151. type: Input,
  2152. args: ['ngClass']
  2153. }] } });
  2154. /**
  2155. * Instantiates a {@link /api/core/Component Component} type and inserts its Host View into the current View.
  2156. * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
  2157. *
  2158. * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
  2159. * any existing component will be destroyed.
  2160. *
  2161. * @usageNotes
  2162. *
  2163. * ### Fine tune control
  2164. *
  2165. * You can control the component creation process by using the following optional attributes:
  2166. *
  2167. * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the
  2168. * component.
  2169. *
  2170. * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
  2171. * the Component. Defaults to the injector of the current view container.
  2172. *
  2173. * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
  2174. * section of the component, if it exists.
  2175. *
  2176. * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another
  2177. * module dynamically, then loading a component from that module.
  2178. *
  2179. * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional
  2180. * NgModule factory to allow loading another module dynamically, then loading a component from that
  2181. * module. Use `ngComponentOutletNgModule` instead.
  2182. *
  2183. * ### Syntax
  2184. *
  2185. * Simple
  2186. * ```html
  2187. * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
  2188. * ```
  2189. *
  2190. * With inputs
  2191. * ```html
  2192. * <ng-container *ngComponentOutlet="componentTypeExpression;
  2193. * inputs: inputsExpression;">
  2194. * </ng-container>
  2195. * ```
  2196. *
  2197. * Customized injector/content
  2198. * ```html
  2199. * <ng-container *ngComponentOutlet="componentTypeExpression;
  2200. * injector: injectorExpression;
  2201. * content: contentNodesExpression;">
  2202. * </ng-container>
  2203. * ```
  2204. *
  2205. * Customized NgModule reference
  2206. * ```html
  2207. * <ng-container *ngComponentOutlet="componentTypeExpression;
  2208. * ngModule: ngModuleClass;">
  2209. * </ng-container>
  2210. * ```
  2211. *
  2212. * ### A simple example
  2213. *
  2214. * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
  2215. *
  2216. * A more complete example with additional options:
  2217. *
  2218. * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
  2219. *
  2220. * @publicApi
  2221. * @ngModule CommonModule
  2222. */
  2223. class NgComponentOutlet {
  2224. _viewContainerRef;
  2225. // TODO(crisbeto): this should be `Type<T>`, but doing so broke a few
  2226. // targets in a TGP so we need to do it in a major version.
  2227. /** Component that should be rendered in the outlet. */
  2228. ngComponentOutlet = null;
  2229. ngComponentOutletInputs;
  2230. ngComponentOutletInjector;
  2231. ngComponentOutletContent;
  2232. ngComponentOutletNgModule;
  2233. /**
  2234. * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.
  2235. */
  2236. ngComponentOutletNgModuleFactory;
  2237. _componentRef;
  2238. _moduleRef;
  2239. /**
  2240. * A helper data structure that allows us to track inputs that were part of the
  2241. * ngComponentOutletInputs expression. Tracking inputs is necessary for proper removal of ones
  2242. * that are no longer referenced.
  2243. */
  2244. _inputsUsed = new Map();
  2245. /**
  2246. * Gets the instance of the currently-rendered component.
  2247. * Will be null if no component has been rendered.
  2248. */
  2249. get componentInstance() {
  2250. return this._componentRef?.instance ?? null;
  2251. }
  2252. constructor(_viewContainerRef) {
  2253. this._viewContainerRef = _viewContainerRef;
  2254. }
  2255. _needToReCreateNgModuleInstance(changes) {
  2256. // Note: square brackets property accessor is safe for Closure compiler optimizations (the
  2257. // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
  2258. // were changed).
  2259. return (changes['ngComponentOutletNgModule'] !== undefined ||
  2260. changes['ngComponentOutletNgModuleFactory'] !== undefined);
  2261. }
  2262. _needToReCreateComponentInstance(changes) {
  2263. // Note: square brackets property accessor is safe for Closure compiler optimizations (the
  2264. // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
  2265. // were changed).
  2266. return (changes['ngComponentOutlet'] !== undefined ||
  2267. changes['ngComponentOutletContent'] !== undefined ||
  2268. changes['ngComponentOutletInjector'] !== undefined ||
  2269. this._needToReCreateNgModuleInstance(changes));
  2270. }
  2271. /** @docs-private */
  2272. ngOnChanges(changes) {
  2273. if (this._needToReCreateComponentInstance(changes)) {
  2274. this._viewContainerRef.clear();
  2275. this._inputsUsed.clear();
  2276. this._componentRef = undefined;
  2277. if (this.ngComponentOutlet) {
  2278. const injector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
  2279. if (this._needToReCreateNgModuleInstance(changes)) {
  2280. this._moduleRef?.destroy();
  2281. if (this.ngComponentOutletNgModule) {
  2282. this._moduleRef = createNgModule(this.ngComponentOutletNgModule, getParentInjector(injector));
  2283. }
  2284. else if (this.ngComponentOutletNgModuleFactory) {
  2285. this._moduleRef = this.ngComponentOutletNgModuleFactory.create(getParentInjector(injector));
  2286. }
  2287. else {
  2288. this._moduleRef = undefined;
  2289. }
  2290. }
  2291. this._componentRef = this._viewContainerRef.createComponent(this.ngComponentOutlet, {
  2292. injector,
  2293. ngModuleRef: this._moduleRef,
  2294. projectableNodes: this.ngComponentOutletContent,
  2295. });
  2296. }
  2297. }
  2298. }
  2299. /** @docs-private */
  2300. ngDoCheck() {
  2301. if (this._componentRef) {
  2302. if (this.ngComponentOutletInputs) {
  2303. for (const inputName of Object.keys(this.ngComponentOutletInputs)) {
  2304. this._inputsUsed.set(inputName, true);
  2305. }
  2306. }
  2307. this._applyInputStateDiff(this._componentRef);
  2308. }
  2309. }
  2310. /** @docs-private */
  2311. ngOnDestroy() {
  2312. this._moduleRef?.destroy();
  2313. }
  2314. _applyInputStateDiff(componentRef) {
  2315. for (const [inputName, touched] of this._inputsUsed) {
  2316. if (!touched) {
  2317. // The input that was previously active no longer exists and needs to be set to undefined.
  2318. componentRef.setInput(inputName, undefined);
  2319. this._inputsUsed.delete(inputName);
  2320. }
  2321. else {
  2322. // Since touched is true, it can be asserted that the inputs object is not empty.
  2323. componentRef.setInput(inputName, this.ngComponentOutletInputs[inputName]);
  2324. this._inputsUsed.set(inputName, false);
  2325. }
  2326. }
  2327. }
  2328. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgComponentOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
  2329. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgComponentOutlet, isStandalone: true, selector: "[ngComponentOutlet]", inputs: { ngComponentOutlet: "ngComponentOutlet", ngComponentOutletInputs: "ngComponentOutletInputs", ngComponentOutletInjector: "ngComponentOutletInjector", ngComponentOutletContent: "ngComponentOutletContent", ngComponentOutletNgModule: "ngComponentOutletNgModule", ngComponentOutletNgModuleFactory: "ngComponentOutletNgModuleFactory" }, exportAs: ["ngComponentOutlet"], usesOnChanges: true, ngImport: i0 });
  2330. }
  2331. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgComponentOutlet, decorators: [{
  2332. type: Directive,
  2333. args: [{
  2334. selector: '[ngComponentOutlet]',
  2335. exportAs: 'ngComponentOutlet',
  2336. }]
  2337. }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngComponentOutlet: [{
  2338. type: Input
  2339. }], ngComponentOutletInputs: [{
  2340. type: Input
  2341. }], ngComponentOutletInjector: [{
  2342. type: Input
  2343. }], ngComponentOutletContent: [{
  2344. type: Input
  2345. }], ngComponentOutletNgModule: [{
  2346. type: Input
  2347. }], ngComponentOutletNgModuleFactory: [{
  2348. type: Input
  2349. }] } });
  2350. // Helper function that returns an Injector instance of a parent NgModule.
  2351. function getParentInjector(injector) {
  2352. const parentNgModule = injector.get(NgModuleRef);
  2353. return parentNgModule.injector;
  2354. }
  2355. /**
  2356. * @publicApi
  2357. */
  2358. class NgForOfContext {
  2359. $implicit;
  2360. ngForOf;
  2361. index;
  2362. count;
  2363. constructor(
  2364. /** Reference to the current item from the collection. */
  2365. $implicit,
  2366. /**
  2367. * The value of the iterable expression. Useful when the expression is
  2368. * more complex then a property access, for example when using the async pipe
  2369. * (`userStreams | async`).
  2370. */
  2371. ngForOf,
  2372. /** Returns an index of the current item in the collection. */
  2373. index,
  2374. /** Returns total amount of items in the collection. */
  2375. count) {
  2376. this.$implicit = $implicit;
  2377. this.ngForOf = ngForOf;
  2378. this.index = index;
  2379. this.count = count;
  2380. }
  2381. // Indicates whether this is the first item in the collection.
  2382. get first() {
  2383. return this.index === 0;
  2384. }
  2385. // Indicates whether this is the last item in the collection.
  2386. get last() {
  2387. return this.index === this.count - 1;
  2388. }
  2389. // Indicates whether an index of this item in the collection is even.
  2390. get even() {
  2391. return this.index % 2 === 0;
  2392. }
  2393. // Indicates whether an index of this item in the collection is odd.
  2394. get odd() {
  2395. return !this.even;
  2396. }
  2397. }
  2398. /**
  2399. * A [structural directive](guide/directives/structural-directives) that renders
  2400. * a template for each item in a collection.
  2401. * The directive is placed on an element, which becomes the parent
  2402. * of the cloned templates.
  2403. *
  2404. * The `ngForOf` directive is generally used in the
  2405. * [shorthand form](guide/directives/structural-directives#asterisk) `*ngFor`.
  2406. * In this form, the template to be rendered for each iteration is the content
  2407. * of an anchor element containing the directive.
  2408. *
  2409. * The following example shows the shorthand syntax with some options,
  2410. * contained in an `<li>` element.
  2411. *
  2412. * ```html
  2413. * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
  2414. * ```
  2415. *
  2416. * The shorthand form expands into a long form that uses the `ngForOf` selector
  2417. * on an `<ng-template>` element.
  2418. * The content of the `<ng-template>` element is the `<li>` element that held the
  2419. * short-form directive.
  2420. *
  2421. * Here is the expanded version of the short-form example.
  2422. *
  2423. * ```html
  2424. * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
  2425. * <li>...</li>
  2426. * </ng-template>
  2427. * ```
  2428. *
  2429. * Angular automatically expands the shorthand syntax as it compiles the template.
  2430. * The context for each embedded view is logically merged to the current component
  2431. * context according to its lexical position.
  2432. *
  2433. * When using the shorthand syntax, Angular allows only [one structural directive
  2434. * on an element](guide/directives/structural-directives#one-per-element).
  2435. * If you want to iterate conditionally, for example,
  2436. * put the `*ngIf` on a container element that wraps the `*ngFor` element.
  2437. * For further discussion, see
  2438. * [Structural Directives](guide/directives/structural-directives#one-per-element).
  2439. *
  2440. * @usageNotes
  2441. *
  2442. * ### Local variables
  2443. *
  2444. * `NgForOf` provides exported values that can be aliased to local variables.
  2445. * For example:
  2446. *
  2447. * ```html
  2448. * <li *ngFor="let user of users; index as i; first as isFirst">
  2449. * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
  2450. * </li>
  2451. * ```
  2452. *
  2453. * The following exported values can be aliased to local variables:
  2454. *
  2455. * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
  2456. * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
  2457. * more complex then a property access, for example when using the async pipe (`userStreams |
  2458. * async`).
  2459. * - `index: number`: The index of the current item in the iterable.
  2460. * - `count: number`: The length of the iterable.
  2461. * - `first: boolean`: True when the item is the first item in the iterable.
  2462. * - `last: boolean`: True when the item is the last item in the iterable.
  2463. * - `even: boolean`: True when the item has an even index in the iterable.
  2464. * - `odd: boolean`: True when the item has an odd index in the iterable.
  2465. *
  2466. * ### Change propagation
  2467. *
  2468. * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
  2469. *
  2470. * * When an item is added, a new instance of the template is added to the DOM.
  2471. * * When an item is removed, its template instance is removed from the DOM.
  2472. * * When items are reordered, their respective templates are reordered in the DOM.
  2473. *
  2474. * Angular uses object identity to track insertions and deletions within the iterator and reproduce
  2475. * those changes in the DOM. This has important implications for animations and any stateful
  2476. * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
  2477. * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
  2478. * such as user input.
  2479. * For more on animations, see [Transitions and Triggers](guide/animations/transition-and-triggers).
  2480. *
  2481. * The identities of elements in the iterator can change while the data does not.
  2482. * This can happen, for example, if the iterator is produced from an RPC to the server, and that
  2483. * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
  2484. * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
  2485. * elements were deleted and all new elements inserted).
  2486. *
  2487. * To avoid this expensive operation, you can customize the default tracking algorithm.
  2488. * by supplying the `trackBy` option to `NgForOf`.
  2489. * `trackBy` takes a function that has two arguments: `index` and `item`.
  2490. * If `trackBy` is given, Angular tracks changes by the return value of the function.
  2491. *
  2492. * @see [Structural Directives](guide/directives/structural-directives)
  2493. * @ngModule CommonModule
  2494. * @publicApi
  2495. */
  2496. class NgForOf {
  2497. _viewContainer;
  2498. _template;
  2499. _differs;
  2500. /**
  2501. * The value of the iterable expression, which can be used as a
  2502. * [template input variable](guide/directives/structural-directives#shorthand).
  2503. */
  2504. set ngForOf(ngForOf) {
  2505. this._ngForOf = ngForOf;
  2506. this._ngForOfDirty = true;
  2507. }
  2508. /**
  2509. * Specifies a custom `TrackByFunction` to compute the identity of items in an iterable.
  2510. *
  2511. * If a custom `TrackByFunction` is not provided, `NgForOf` will use the item's [object
  2512. * identity](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
  2513. * as the key.
  2514. *
  2515. * `NgForOf` uses the computed key to associate items in an iterable with DOM elements
  2516. * it produces for these items.
  2517. *
  2518. * A custom `TrackByFunction` is useful to provide good user experience in cases when items in an
  2519. * iterable rendered using `NgForOf` have a natural identifier (for example, custom ID or a
  2520. * primary key), and this iterable could be updated with new object instances that still
  2521. * represent the same underlying entity (for example, when data is re-fetched from the server,
  2522. * and the iterable is recreated and re-rendered, but most of the data is still the same).
  2523. *
  2524. * @see {@link TrackByFunction}
  2525. */
  2526. set ngForTrackBy(fn) {
  2527. if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {
  2528. console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
  2529. `See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
  2530. }
  2531. this._trackByFn = fn;
  2532. }
  2533. get ngForTrackBy() {
  2534. return this._trackByFn;
  2535. }
  2536. _ngForOf = null;
  2537. _ngForOfDirty = true;
  2538. _differ = null;
  2539. // waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for
  2540. // the getter
  2541. _trackByFn;
  2542. constructor(_viewContainer, _template, _differs) {
  2543. this._viewContainer = _viewContainer;
  2544. this._template = _template;
  2545. this._differs = _differs;
  2546. }
  2547. /**
  2548. * A reference to the template that is stamped out for each item in the iterable.
  2549. * @see [template reference variable](guide/templates/variables#template-reference-variables)
  2550. */
  2551. set ngForTemplate(value) {
  2552. // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
  2553. // The current type is too restrictive; a template that just uses index, for example,
  2554. // should be acceptable.
  2555. if (value) {
  2556. this._template = value;
  2557. }
  2558. }
  2559. /**
  2560. * Applies the changes when needed.
  2561. * @docs-private
  2562. */
  2563. ngDoCheck() {
  2564. if (this._ngForOfDirty) {
  2565. this._ngForOfDirty = false;
  2566. // React on ngForOf changes only once all inputs have been initialized
  2567. const value = this._ngForOf;
  2568. if (!this._differ && value) {
  2569. if (typeof ngDevMode === 'undefined' || ngDevMode) {
  2570. try {
  2571. // CAUTION: this logic is duplicated for production mode below, as the try-catch
  2572. // is only present in development builds.
  2573. this._differ = this._differs.find(value).create(this.ngForTrackBy);
  2574. }
  2575. catch {
  2576. let errorMessage = `Cannot find a differ supporting object '${value}' of type '` +
  2577. `${getTypeName(value)}'. NgFor only supports binding to Iterables, such as Arrays.`;
  2578. if (typeof value === 'object') {
  2579. errorMessage += ' Did you mean to use the keyvalue pipe?';
  2580. }
  2581. throw new _RuntimeError(-2200 /* RuntimeErrorCode.NG_FOR_MISSING_DIFFER */, errorMessage);
  2582. }
  2583. }
  2584. else {
  2585. // CAUTION: this logic is duplicated for development mode above, as the try-catch
  2586. // is only present in development builds.
  2587. this._differ = this._differs.find(value).create(this.ngForTrackBy);
  2588. }
  2589. }
  2590. }
  2591. if (this._differ) {
  2592. const changes = this._differ.diff(this._ngForOf);
  2593. if (changes)
  2594. this._applyChanges(changes);
  2595. }
  2596. }
  2597. _applyChanges(changes) {
  2598. const viewContainer = this._viewContainer;
  2599. changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
  2600. if (item.previousIndex == null) {
  2601. // NgForOf is never "null" or "undefined" here because the differ detected
  2602. // that a new item needs to be inserted from the iterable. This implies that
  2603. // there is an iterable value for "_ngForOf".
  2604. viewContainer.createEmbeddedView(this._template, new NgForOfContext(item.item, this._ngForOf, -1, -1), currentIndex === null ? undefined : currentIndex);
  2605. }
  2606. else if (currentIndex == null) {
  2607. viewContainer.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
  2608. }
  2609. else if (adjustedPreviousIndex !== null) {
  2610. const view = viewContainer.get(adjustedPreviousIndex);
  2611. viewContainer.move(view, currentIndex);
  2612. applyViewChange(view, item);
  2613. }
  2614. });
  2615. for (let i = 0, ilen = viewContainer.length; i < ilen; i++) {
  2616. const viewRef = viewContainer.get(i);
  2617. const context = viewRef.context;
  2618. context.index = i;
  2619. context.count = ilen;
  2620. context.ngForOf = this._ngForOf;
  2621. }
  2622. changes.forEachIdentityChange((record) => {
  2623. const viewRef = viewContainer.get(record.currentIndex);
  2624. applyViewChange(viewRef, record);
  2625. });
  2626. }
  2627. /**
  2628. * Asserts the correct type of the context for the template that `NgForOf` will render.
  2629. *
  2630. * The presence of this method is a signal to the Ivy template type-check compiler that the
  2631. * `NgForOf` structural directive renders its template with a specific context type.
  2632. */
  2633. static ngTemplateContextGuard(dir, ctx) {
  2634. return true;
  2635. }
  2636. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });
  2637. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgForOf, isStandalone: true, selector: "[ngFor][ngForOf]", inputs: { ngForOf: "ngForOf", ngForTrackBy: "ngForTrackBy", ngForTemplate: "ngForTemplate" }, ngImport: i0 });
  2638. }
  2639. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgForOf, decorators: [{
  2640. type: Directive,
  2641. args: [{
  2642. selector: '[ngFor][ngForOf]',
  2643. }]
  2644. }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }], propDecorators: { ngForOf: [{
  2645. type: Input
  2646. }], ngForTrackBy: [{
  2647. type: Input
  2648. }], ngForTemplate: [{
  2649. type: Input
  2650. }] } });
  2651. function applyViewChange(view, record) {
  2652. view.context.$implicit = record.item;
  2653. }
  2654. function getTypeName(type) {
  2655. return type['name'] || typeof type;
  2656. }
  2657. /**
  2658. * A structural directive that conditionally includes a template based on the value of
  2659. * an expression coerced to Boolean.
  2660. * When the expression evaluates to true, Angular renders the template
  2661. * provided in a `then` clause, and when false or null,
  2662. * Angular renders the template provided in an optional `else` clause. The default
  2663. * template for the `else` clause is blank.
  2664. *
  2665. * A [shorthand form](guide/directives/structural-directives#asterisk) of the directive,
  2666. * `*ngIf="condition"`, is generally used, provided
  2667. * as an attribute of the anchor element for the inserted template.
  2668. * Angular expands this into a more explicit version, in which the anchor element
  2669. * is contained in an `<ng-template>` element.
  2670. *
  2671. * Simple form with shorthand syntax:
  2672. *
  2673. * ```html
  2674. * <div *ngIf="condition">Content to render when condition is true.</div>
  2675. * ```
  2676. *
  2677. * Simple form with expanded syntax:
  2678. *
  2679. * ```html
  2680. * <ng-template [ngIf]="condition"><div>Content to render when condition is
  2681. * true.</div></ng-template>
  2682. * ```
  2683. *
  2684. * Form with an "else" block:
  2685. *
  2686. * ```html
  2687. * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
  2688. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  2689. * ```
  2690. *
  2691. * Shorthand form with "then" and "else" blocks:
  2692. *
  2693. * ```html
  2694. * <div *ngIf="condition; then thenBlock else elseBlock"></div>
  2695. * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
  2696. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  2697. * ```
  2698. *
  2699. * Form with storing the value locally:
  2700. *
  2701. * ```html
  2702. * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
  2703. * <ng-template #elseBlock>Content to render when value is null.</ng-template>
  2704. * ```
  2705. *
  2706. * @usageNotes
  2707. *
  2708. * The `*ngIf` directive is most commonly used to conditionally show an inline template,
  2709. * as seen in the following example.
  2710. * The default `else` template is blank.
  2711. *
  2712. * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
  2713. *
  2714. * ### Showing an alternative template using `else`
  2715. *
  2716. * To display a template when `expression` evaluates to false, use an `else` template
  2717. * binding as shown in the following example.
  2718. * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
  2719. * The template can be defined anywhere in the component view, but is typically placed right after
  2720. * `ngIf` for readability.
  2721. *
  2722. * {@example common/ngIf/ts/module.ts region='NgIfElse'}
  2723. *
  2724. * ### Using an external `then` template
  2725. *
  2726. * In the previous example, the then-clause template is specified inline, as the content of the
  2727. * tag that contains the `ngIf` directive. You can also specify a template that is defined
  2728. * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
  2729. * change which template to use at runtime, as shown in the following example.
  2730. *
  2731. * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
  2732. *
  2733. * ### Storing a conditional result in a variable
  2734. *
  2735. * You might want to show a set of properties from the same object. If you are waiting
  2736. * for asynchronous data, the object can be undefined.
  2737. * In this case, you can use `ngIf` and store the result of the condition in a local
  2738. * variable as shown in the following example.
  2739. *
  2740. * {@example common/ngIf/ts/module.ts region='NgIfAs'}
  2741. *
  2742. * This code uses only one `AsyncPipe`, so only one subscription is created.
  2743. * The conditional statement stores the result of `userStream|async` in the local variable `user`.
  2744. * You can then bind the local `user` repeatedly.
  2745. *
  2746. * The conditional displays the data only if `userStream` returns a value,
  2747. * so you don't need to use the
  2748. * safe-navigation-operator (`?.`)
  2749. * to guard against null values when accessing properties.
  2750. * You can display an alternative template while waiting for the data.
  2751. *
  2752. * ### Shorthand syntax
  2753. *
  2754. * The shorthand syntax `*ngIf` expands into two separate template specifications
  2755. * for the "then" and "else" clauses. For example, consider the following shorthand statement,
  2756. * that is meant to show a loading page while waiting for data to be loaded.
  2757. *
  2758. * ```html
  2759. * <div class="hero-list" *ngIf="heroes else loading">
  2760. * ...
  2761. * </div>
  2762. *
  2763. * <ng-template #loading>
  2764. * <div>Loading...</div>
  2765. * </ng-template>
  2766. * ```
  2767. *
  2768. * You can see that the "else" clause references the `<ng-template>`
  2769. * with the `#loading` label, and the template for the "then" clause
  2770. * is provided as the content of the anchor element.
  2771. *
  2772. * However, when Angular expands the shorthand syntax, it creates
  2773. * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
  2774. * The anchor element containing the template for the "then" clause becomes
  2775. * the content of this unlabeled `<ng-template>` tag.
  2776. *
  2777. * ```html
  2778. * <ng-template [ngIf]="heroes" [ngIfElse]="loading">
  2779. * <div class="hero-list">
  2780. * ...
  2781. * </div>
  2782. * </ng-template>
  2783. *
  2784. * <ng-template #loading>
  2785. * <div>Loading...</div>
  2786. * </ng-template>
  2787. * ```
  2788. *
  2789. * The presence of the implicit template object has implications for the nesting of
  2790. * structural directives. For more on this subject, see
  2791. * [Structural Directives](guide/directives/structural-directives#one-per-element).
  2792. *
  2793. * @ngModule CommonModule
  2794. * @publicApi
  2795. */
  2796. class NgIf {
  2797. _viewContainer;
  2798. _context = new NgIfContext();
  2799. _thenTemplateRef = null;
  2800. _elseTemplateRef = null;
  2801. _thenViewRef = null;
  2802. _elseViewRef = null;
  2803. constructor(_viewContainer, templateRef) {
  2804. this._viewContainer = _viewContainer;
  2805. this._thenTemplateRef = templateRef;
  2806. }
  2807. /**
  2808. * The Boolean expression to evaluate as the condition for showing a template.
  2809. */
  2810. set ngIf(condition) {
  2811. this._context.$implicit = this._context.ngIf = condition;
  2812. this._updateView();
  2813. }
  2814. /**
  2815. * A template to show if the condition expression evaluates to true.
  2816. */
  2817. set ngIfThen(templateRef) {
  2818. assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfThen');
  2819. this._thenTemplateRef = templateRef;
  2820. this._thenViewRef = null; // clear previous view if any.
  2821. this._updateView();
  2822. }
  2823. /**
  2824. * A template to show if the condition expression evaluates to false.
  2825. */
  2826. set ngIfElse(templateRef) {
  2827. assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfElse');
  2828. this._elseTemplateRef = templateRef;
  2829. this._elseViewRef = null; // clear previous view if any.
  2830. this._updateView();
  2831. }
  2832. _updateView() {
  2833. if (this._context.$implicit) {
  2834. if (!this._thenViewRef) {
  2835. this._viewContainer.clear();
  2836. this._elseViewRef = null;
  2837. if (this._thenTemplateRef) {
  2838. this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
  2839. }
  2840. }
  2841. }
  2842. else {
  2843. if (!this._elseViewRef) {
  2844. this._viewContainer.clear();
  2845. this._thenViewRef = null;
  2846. if (this._elseTemplateRef) {
  2847. this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
  2848. }
  2849. }
  2850. }
  2851. }
  2852. /** @internal */
  2853. static ngIfUseIfTypeGuard;
  2854. /**
  2855. * Assert the correct type of the expression bound to the `ngIf` input within the template.
  2856. *
  2857. * The presence of this static field is a signal to the Ivy template type check compiler that
  2858. * when the `NgIf` structural directive renders its template, the type of the expression bound
  2859. * to `ngIf` should be narrowed in some way. For `NgIf`, the binding expression itself is used to
  2860. * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `NgIf`.
  2861. */
  2862. static ngTemplateGuard_ngIf;
  2863. /**
  2864. * Asserts the correct type of the context for the template that `NgIf` will render.
  2865. *
  2866. * The presence of this method is a signal to the Ivy template type-check compiler that the
  2867. * `NgIf` structural directive renders its template with a specific context type.
  2868. */
  2869. static ngTemplateContextGuard(dir, ctx) {
  2870. return true;
  2871. }
  2872. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgIf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
  2873. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgIf, isStandalone: true, selector: "[ngIf]", inputs: { ngIf: "ngIf", ngIfThen: "ngIfThen", ngIfElse: "ngIfElse" }, ngImport: i0 });
  2874. }
  2875. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgIf, decorators: [{
  2876. type: Directive,
  2877. args: [{
  2878. selector: '[ngIf]',
  2879. }]
  2880. }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }], propDecorators: { ngIf: [{
  2881. type: Input
  2882. }], ngIfThen: [{
  2883. type: Input
  2884. }], ngIfElse: [{
  2885. type: Input
  2886. }] } });
  2887. /**
  2888. * @publicApi
  2889. */
  2890. class NgIfContext {
  2891. $implicit = null;
  2892. ngIf = null;
  2893. }
  2894. function assertTemplate(templateRef, property) {
  2895. if (templateRef && !templateRef.createEmbeddedView) {
  2896. throw new _RuntimeError(2020 /* RuntimeErrorCode.NG_IF_NOT_A_TEMPLATE_REF */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
  2897. `${property} must be a TemplateRef, but received '${_stringify(templateRef)}'.`);
  2898. }
  2899. }
  2900. class SwitchView {
  2901. _viewContainerRef;
  2902. _templateRef;
  2903. _created = false;
  2904. constructor(_viewContainerRef, _templateRef) {
  2905. this._viewContainerRef = _viewContainerRef;
  2906. this._templateRef = _templateRef;
  2907. }
  2908. create() {
  2909. this._created = true;
  2910. this._viewContainerRef.createEmbeddedView(this._templateRef);
  2911. }
  2912. destroy() {
  2913. this._created = false;
  2914. this._viewContainerRef.clear();
  2915. }
  2916. enforceState(created) {
  2917. if (created && !this._created) {
  2918. this.create();
  2919. }
  2920. else if (!created && this._created) {
  2921. this.destroy();
  2922. }
  2923. }
  2924. }
  2925. /**
  2926. * @ngModule CommonModule
  2927. *
  2928. * @description
  2929. * The `[ngSwitch]` directive on a container specifies an expression to match against.
  2930. * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
  2931. * - Every view that matches is rendered.
  2932. * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
  2933. * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
  2934. * or `ngSwitchDefault` directive are preserved at the location.
  2935. *
  2936. * @usageNotes
  2937. * Define a container element for the directive, and specify the switch expression
  2938. * to match against as an attribute:
  2939. *
  2940. * ```html
  2941. * <container-element [ngSwitch]="switch_expression">
  2942. * ```
  2943. *
  2944. * Within the container, `*ngSwitchCase` statements specify the match expressions
  2945. * as attributes. Include `*ngSwitchDefault` as the final case.
  2946. *
  2947. * ```html
  2948. * <container-element [ngSwitch]="switch_expression">
  2949. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  2950. * ...
  2951. * <some-element *ngSwitchDefault>...</some-element>
  2952. * </container-element>
  2953. * ```
  2954. *
  2955. * ### Usage Examples
  2956. *
  2957. * The following example shows how to use more than one case to display the same view:
  2958. *
  2959. * ```html
  2960. * <container-element [ngSwitch]="switch_expression">
  2961. * <!-- the same view can be shown in more than one case -->
  2962. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  2963. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  2964. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  2965. * <!--default case when there are no matches -->
  2966. * <some-element *ngSwitchDefault>...</some-element>
  2967. * </container-element>
  2968. * ```
  2969. *
  2970. * The following example shows how cases can be nested:
  2971. * ```html
  2972. * <container-element [ngSwitch]="switch_expression">
  2973. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  2974. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  2975. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  2976. * <ng-container *ngSwitchCase="match_expression_3">
  2977. * <!-- use a ng-container to group multiple root nodes -->
  2978. * <inner-element></inner-element>
  2979. * <inner-other-element></inner-other-element>
  2980. * </ng-container>
  2981. * <some-element *ngSwitchDefault>...</some-element>
  2982. * </container-element>
  2983. * ```
  2984. *
  2985. * @publicApi
  2986. * @see {@link NgSwitchCase}
  2987. * @see {@link NgSwitchDefault}
  2988. * @see [Structural Directives](guide/directives/structural-directives)
  2989. *
  2990. */
  2991. class NgSwitch {
  2992. _defaultViews = [];
  2993. _defaultUsed = false;
  2994. _caseCount = 0;
  2995. _lastCaseCheckIndex = 0;
  2996. _lastCasesMatched = false;
  2997. _ngSwitch;
  2998. set ngSwitch(newValue) {
  2999. this._ngSwitch = newValue;
  3000. if (this._caseCount === 0) {
  3001. this._updateDefaultCases(true);
  3002. }
  3003. }
  3004. /** @internal */
  3005. _addCase() {
  3006. return this._caseCount++;
  3007. }
  3008. /** @internal */
  3009. _addDefault(view) {
  3010. this._defaultViews.push(view);
  3011. }
  3012. /** @internal */
  3013. _matchCase(value) {
  3014. const matched = value === this._ngSwitch;
  3015. this._lastCasesMatched ||= matched;
  3016. this._lastCaseCheckIndex++;
  3017. if (this._lastCaseCheckIndex === this._caseCount) {
  3018. this._updateDefaultCases(!this._lastCasesMatched);
  3019. this._lastCaseCheckIndex = 0;
  3020. this._lastCasesMatched = false;
  3021. }
  3022. return matched;
  3023. }
  3024. _updateDefaultCases(useDefault) {
  3025. if (this._defaultViews.length > 0 && useDefault !== this._defaultUsed) {
  3026. this._defaultUsed = useDefault;
  3027. for (const defaultView of this._defaultViews) {
  3028. defaultView.enforceState(useDefault);
  3029. }
  3030. }
  3031. }
  3032. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  3033. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgSwitch, isStandalone: true, selector: "[ngSwitch]", inputs: { ngSwitch: "ngSwitch" }, ngImport: i0 });
  3034. }
  3035. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitch, decorators: [{
  3036. type: Directive,
  3037. args: [{
  3038. selector: '[ngSwitch]',
  3039. }]
  3040. }], propDecorators: { ngSwitch: [{
  3041. type: Input
  3042. }] } });
  3043. /**
  3044. * @ngModule CommonModule
  3045. *
  3046. * @description
  3047. * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
  3048. * When the expressions match, the given `NgSwitchCase` template is rendered.
  3049. * If multiple match expressions match the switch expression value, all of them are displayed.
  3050. *
  3051. * @usageNotes
  3052. *
  3053. * Within a switch container, `*ngSwitchCase` statements specify the match expressions
  3054. * as attributes. Include `*ngSwitchDefault` as the final case.
  3055. *
  3056. * ```html
  3057. * <container-element [ngSwitch]="switch_expression">
  3058. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  3059. * ...
  3060. * <some-element *ngSwitchDefault>...</some-element>
  3061. * </container-element>
  3062. * ```
  3063. *
  3064. * Each switch-case statement contains an in-line HTML template or template reference
  3065. * that defines the subtree to be selected if the value of the match expression
  3066. * matches the value of the switch expression.
  3067. *
  3068. * As of Angular v17 the NgSwitch directive uses strict equality comparison (`===`) instead of
  3069. * loose equality (`==`) to match different cases.
  3070. *
  3071. * @publicApi
  3072. * @see {@link NgSwitch}
  3073. * @see {@link NgSwitchDefault}
  3074. *
  3075. */
  3076. class NgSwitchCase {
  3077. ngSwitch;
  3078. _view;
  3079. /**
  3080. * Stores the HTML template to be selected on match.
  3081. */
  3082. ngSwitchCase;
  3083. constructor(viewContainer, templateRef, ngSwitch) {
  3084. this.ngSwitch = ngSwitch;
  3085. if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
  3086. throwNgSwitchProviderNotFoundError('ngSwitchCase', 'NgSwitchCase');
  3087. }
  3088. ngSwitch._addCase();
  3089. this._view = new SwitchView(viewContainer, templateRef);
  3090. }
  3091. /**
  3092. * Performs case matching. For internal use only.
  3093. * @docs-private
  3094. */
  3095. ngDoCheck() {
  3096. this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));
  3097. }
  3098. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitchCase, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
  3099. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgSwitchCase, isStandalone: true, selector: "[ngSwitchCase]", inputs: { ngSwitchCase: "ngSwitchCase" }, ngImport: i0 });
  3100. }
  3101. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitchCase, decorators: [{
  3102. type: Directive,
  3103. args: [{
  3104. selector: '[ngSwitchCase]',
  3105. }]
  3106. }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
  3107. type: Optional
  3108. }, {
  3109. type: Host
  3110. }] }], propDecorators: { ngSwitchCase: [{
  3111. type: Input
  3112. }] } });
  3113. /**
  3114. * @ngModule CommonModule
  3115. *
  3116. * @description
  3117. *
  3118. * Creates a view that is rendered when no `NgSwitchCase` expressions
  3119. * match the `NgSwitch` expression.
  3120. * This statement should be the final case in an `NgSwitch`.
  3121. *
  3122. * @publicApi
  3123. * @see {@link NgSwitch}
  3124. * @see {@link NgSwitchCase}
  3125. *
  3126. */
  3127. class NgSwitchDefault {
  3128. constructor(viewContainer, templateRef, ngSwitch) {
  3129. if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
  3130. throwNgSwitchProviderNotFoundError('ngSwitchDefault', 'NgSwitchDefault');
  3131. }
  3132. ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
  3133. }
  3134. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitchDefault, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
  3135. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgSwitchDefault, isStandalone: true, selector: "[ngSwitchDefault]", ngImport: i0 });
  3136. }
  3137. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgSwitchDefault, decorators: [{
  3138. type: Directive,
  3139. args: [{
  3140. selector: '[ngSwitchDefault]',
  3141. }]
  3142. }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
  3143. type: Optional
  3144. }, {
  3145. type: Host
  3146. }] }] });
  3147. function throwNgSwitchProviderNotFoundError(attrName, directiveName) {
  3148. throw new _RuntimeError(2000 /* RuntimeErrorCode.PARENT_NG_SWITCH_NOT_FOUND */, `An element with the "${attrName}" attribute ` +
  3149. `(matching the "${directiveName}" directive) must be located inside an element with the "ngSwitch" attribute ` +
  3150. `(matching "NgSwitch" directive)`);
  3151. }
  3152. /**
  3153. * @ngModule CommonModule
  3154. *
  3155. * @usageNotes
  3156. * ```html
  3157. * <some-element [ngPlural]="value">
  3158. * <ng-template ngPluralCase="=0">there is nothing</ng-template>
  3159. * <ng-template ngPluralCase="=1">there is one</ng-template>
  3160. * <ng-template ngPluralCase="few">there are a few</ng-template>
  3161. * </some-element>
  3162. * ```
  3163. *
  3164. * @description
  3165. *
  3166. * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
  3167. *
  3168. * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
  3169. * that match the switch expression's pluralization category.
  3170. *
  3171. * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
  3172. * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
  3173. * expression:
  3174. * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
  3175. * matches the switch expression exactly,
  3176. * - otherwise, the view will be treated as a "category match", and will only display if exact
  3177. * value matches aren't found and the value maps to its category for the defined locale.
  3178. *
  3179. * See http://cldr.unicode.org/index/cldr-spec/plural-rules
  3180. *
  3181. * @publicApi
  3182. */
  3183. class NgPlural {
  3184. _localization;
  3185. _activeView;
  3186. _caseViews = {};
  3187. constructor(_localization) {
  3188. this._localization = _localization;
  3189. }
  3190. set ngPlural(value) {
  3191. this._updateView(value);
  3192. }
  3193. addCase(value, switchView) {
  3194. this._caseViews[value] = switchView;
  3195. }
  3196. _updateView(switchValue) {
  3197. this._clearViews();
  3198. const cases = Object.keys(this._caseViews);
  3199. const key = getPluralCategory(switchValue, cases, this._localization);
  3200. this._activateView(this._caseViews[key]);
  3201. }
  3202. _clearViews() {
  3203. if (this._activeView)
  3204. this._activeView.destroy();
  3205. }
  3206. _activateView(view) {
  3207. if (view) {
  3208. this._activeView = view;
  3209. this._activeView.create();
  3210. }
  3211. }
  3212. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgPlural, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Directive });
  3213. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgPlural, isStandalone: true, selector: "[ngPlural]", inputs: { ngPlural: "ngPlural" }, ngImport: i0 });
  3214. }
  3215. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgPlural, decorators: [{
  3216. type: Directive,
  3217. args: [{
  3218. selector: '[ngPlural]',
  3219. }]
  3220. }], ctorParameters: () => [{ type: NgLocalization }], propDecorators: { ngPlural: [{
  3221. type: Input
  3222. }] } });
  3223. /**
  3224. * @ngModule CommonModule
  3225. *
  3226. * @description
  3227. *
  3228. * Creates a view that will be added/removed from the parent {@link NgPlural} when the
  3229. * given expression matches the plural expression according to CLDR rules.
  3230. *
  3231. * @usageNotes
  3232. * ```html
  3233. * <some-element [ngPlural]="value">
  3234. * <ng-template ngPluralCase="=0">...</ng-template>
  3235. * <ng-template ngPluralCase="other">...</ng-template>
  3236. * </some-element>
  3237. *```
  3238. *
  3239. * See {@link NgPlural} for more details and example.
  3240. *
  3241. * @publicApi
  3242. */
  3243. class NgPluralCase {
  3244. value;
  3245. constructor(value, template, viewContainer, ngPlural) {
  3246. this.value = value;
  3247. const isANumber = !isNaN(Number(value));
  3248. ngPlural.addCase(isANumber ? `=${value}` : value, new SwitchView(viewContainer, template));
  3249. }
  3250. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgPluralCase, deps: [{ token: 'ngPluralCase', attribute: true }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: NgPlural, host: true }], target: i0.ɵɵFactoryTarget.Directive });
  3251. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgPluralCase, isStandalone: true, selector: "[ngPluralCase]", ngImport: i0 });
  3252. }
  3253. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgPluralCase, decorators: [{
  3254. type: Directive,
  3255. args: [{
  3256. selector: '[ngPluralCase]',
  3257. }]
  3258. }], ctorParameters: () => [{ type: undefined, decorators: [{
  3259. type: Attribute,
  3260. args: ['ngPluralCase']
  3261. }] }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: NgPlural, decorators: [{
  3262. type: Host
  3263. }] }] });
  3264. /**
  3265. * @ngModule CommonModule
  3266. *
  3267. * @usageNotes
  3268. *
  3269. * Set the width of the containing element to a pixel value returned by an expression.
  3270. *
  3271. * ```html
  3272. * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
  3273. * ```
  3274. *
  3275. * Set a collection of style values using an expression that returns key-value pairs.
  3276. *
  3277. * ```html
  3278. * <some-element [ngStyle]="objExp">...</some-element>
  3279. * ```
  3280. *
  3281. * For more simple use cases you can use the [style bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
  3282. * It doesn't require importing a directive.
  3283. *
  3284. * Set the font of the containing element to the result of an expression.
  3285. *
  3286. * ```html
  3287. * <some-element [style]="{'font-style': styleExp}">...</some-element>
  3288. * ```
  3289. *
  3290. * @description
  3291. *
  3292. * An attribute directive that updates styles for the containing HTML element.
  3293. * Sets one or more style properties, specified as colon-separated key-value pairs.
  3294. * The key is a style name, with an optional `.<unit>` suffix
  3295. * (such as 'top.px', 'font-style.em').
  3296. * The value is an expression to be evaluated.
  3297. * The resulting non-null value, expressed in the given unit,
  3298. * is assigned to the given style property.
  3299. * If the result of evaluation is null, the corresponding style is removed.
  3300. *
  3301. * @see [Style bindings](/guide/templates/binding#css-class-and-style-property-bindings)
  3302. *
  3303. * @publicApi
  3304. */
  3305. class NgStyle {
  3306. _ngEl;
  3307. _differs;
  3308. _renderer;
  3309. _ngStyle = null;
  3310. _differ = null;
  3311. constructor(_ngEl, _differs, _renderer) {
  3312. this._ngEl = _ngEl;
  3313. this._differs = _differs;
  3314. this._renderer = _renderer;
  3315. }
  3316. set ngStyle(values) {
  3317. this._ngStyle = values;
  3318. if (!this._differ && values) {
  3319. this._differ = this._differs.find(values).create();
  3320. }
  3321. }
  3322. ngDoCheck() {
  3323. if (this._differ) {
  3324. const changes = this._differ.diff(this._ngStyle);
  3325. if (changes) {
  3326. this._applyChanges(changes);
  3327. }
  3328. }
  3329. }
  3330. _setStyle(nameAndUnit, value) {
  3331. const [name, unit] = nameAndUnit.split('.');
  3332. const flags = name.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
  3333. if (value != null) {
  3334. this._renderer.setStyle(this._ngEl.nativeElement, name, unit ? `${value}${unit}` : value, flags);
  3335. }
  3336. else {
  3337. this._renderer.removeStyle(this._ngEl.nativeElement, name, flags);
  3338. }
  3339. }
  3340. _applyChanges(changes) {
  3341. changes.forEachRemovedItem((record) => this._setStyle(record.key, null));
  3342. changes.forEachAddedItem((record) => this._setStyle(record.key, record.currentValue));
  3343. changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));
  3344. }
  3345. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgStyle, deps: [{ token: i0.ElementRef }, { token: i0.KeyValueDiffers }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
  3346. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgStyle, isStandalone: true, selector: "[ngStyle]", inputs: { ngStyle: "ngStyle" }, ngImport: i0 });
  3347. }
  3348. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgStyle, decorators: [{
  3349. type: Directive,
  3350. args: [{
  3351. selector: '[ngStyle]',
  3352. }]
  3353. }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.KeyValueDiffers }, { type: i0.Renderer2 }], propDecorators: { ngStyle: [{
  3354. type: Input,
  3355. args: ['ngStyle']
  3356. }] } });
  3357. /**
  3358. * @ngModule CommonModule
  3359. *
  3360. * @description
  3361. *
  3362. * Inserts an embedded view from a prepared `TemplateRef`.
  3363. *
  3364. * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
  3365. * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
  3366. * by the local template `let` declarations.
  3367. *
  3368. * @usageNotes
  3369. * ```html
  3370. * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
  3371. * ```
  3372. *
  3373. * Using the key `$implicit` in the context object will set its value as default.
  3374. *
  3375. * ### Example
  3376. *
  3377. * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
  3378. *
  3379. * @publicApi
  3380. */
  3381. class NgTemplateOutlet {
  3382. _viewContainerRef;
  3383. _viewRef = null;
  3384. /**
  3385. * A context object to attach to the {@link EmbeddedViewRef}. This should be an
  3386. * object, the object's keys will be available for binding by the local template `let`
  3387. * declarations.
  3388. * Using the key `$implicit` in the context object will set its value as default.
  3389. */
  3390. ngTemplateOutletContext = null;
  3391. /**
  3392. * A string defining the template reference and optionally the context object for the template.
  3393. */
  3394. ngTemplateOutlet = null;
  3395. /** Injector to be used within the embedded view. */
  3396. ngTemplateOutletInjector = null;
  3397. constructor(_viewContainerRef) {
  3398. this._viewContainerRef = _viewContainerRef;
  3399. }
  3400. ngOnChanges(changes) {
  3401. if (this._shouldRecreateView(changes)) {
  3402. const viewContainerRef = this._viewContainerRef;
  3403. if (this._viewRef) {
  3404. viewContainerRef.remove(viewContainerRef.indexOf(this._viewRef));
  3405. }
  3406. // If there is no outlet, clear the destroyed view ref.
  3407. if (!this.ngTemplateOutlet) {
  3408. this._viewRef = null;
  3409. return;
  3410. }
  3411. // Create a context forward `Proxy` that will always bind to the user-specified context,
  3412. // without having to destroy and re-create views whenever the context changes.
  3413. const viewContext = this._createContextForwardProxy();
  3414. this._viewRef = viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, viewContext, {
  3415. injector: this.ngTemplateOutletInjector ?? undefined,
  3416. });
  3417. }
  3418. }
  3419. /**
  3420. * We need to re-create existing embedded view if either is true:
  3421. * - the outlet changed.
  3422. * - the injector changed.
  3423. */
  3424. _shouldRecreateView(changes) {
  3425. return !!changes['ngTemplateOutlet'] || !!changes['ngTemplateOutletInjector'];
  3426. }
  3427. /**
  3428. * For a given outlet instance, we create a proxy object that delegates
  3429. * to the user-specified context. This allows changing, or swapping out
  3430. * the context object completely without having to destroy/re-create the view.
  3431. */
  3432. _createContextForwardProxy() {
  3433. return new Proxy({}, {
  3434. set: (_target, prop, newValue) => {
  3435. if (!this.ngTemplateOutletContext) {
  3436. return false;
  3437. }
  3438. return Reflect.set(this.ngTemplateOutletContext, prop, newValue);
  3439. },
  3440. get: (_target, prop, receiver) => {
  3441. if (!this.ngTemplateOutletContext) {
  3442. return undefined;
  3443. }
  3444. return Reflect.get(this.ngTemplateOutletContext, prop, receiver);
  3445. },
  3446. });
  3447. }
  3448. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgTemplateOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
  3449. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.13", type: NgTemplateOutlet, isStandalone: true, selector: "[ngTemplateOutlet]", inputs: { ngTemplateOutletContext: "ngTemplateOutletContext", ngTemplateOutlet: "ngTemplateOutlet", ngTemplateOutletInjector: "ngTemplateOutletInjector" }, usesOnChanges: true, ngImport: i0 });
  3450. }
  3451. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: NgTemplateOutlet, decorators: [{
  3452. type: Directive,
  3453. args: [{
  3454. selector: '[ngTemplateOutlet]',
  3455. }]
  3456. }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngTemplateOutletContext: [{
  3457. type: Input
  3458. }], ngTemplateOutlet: [{
  3459. type: Input
  3460. }], ngTemplateOutletInjector: [{
  3461. type: Input
  3462. }] } });
  3463. /**
  3464. * A collection of Angular directives that are likely to be used in each and every Angular
  3465. * application.
  3466. */
  3467. const COMMON_DIRECTIVES = [
  3468. NgClass,
  3469. NgComponentOutlet,
  3470. NgForOf,
  3471. NgIf,
  3472. NgTemplateOutlet,
  3473. NgStyle,
  3474. NgSwitch,
  3475. NgSwitchCase,
  3476. NgSwitchDefault,
  3477. NgPlural,
  3478. NgPluralCase,
  3479. ];
  3480. function invalidPipeArgumentError(type, value) {
  3481. return new _RuntimeError(2100 /* RuntimeErrorCode.INVALID_PIPE_ARGUMENT */, ngDevMode && `InvalidPipeArgument: '${value}' for pipe '${_stringify(type)}'`);
  3482. }
  3483. class SubscribableStrategy {
  3484. createSubscription(async, updateLatestValue) {
  3485. // Subscription can be side-effectful, and we don't want any signal reads which happen in the
  3486. // side effect of the subscription to be tracked by a component's template when that
  3487. // subscription is triggered via the async pipe. So we wrap the subscription in `untracked` to
  3488. // decouple from the current reactive context.
  3489. //
  3490. // `untracked` also prevents signal _writes_ which happen in the subscription side effect from
  3491. // being treated as signal writes during the template evaluation (which throws errors).
  3492. return untracked(() => async.subscribe({
  3493. next: updateLatestValue,
  3494. error: (e) => {
  3495. throw e;
  3496. },
  3497. }));
  3498. }
  3499. dispose(subscription) {
  3500. // See the comment in `createSubscription` above on the use of `untracked`.
  3501. untracked(() => subscription.unsubscribe());
  3502. }
  3503. }
  3504. class PromiseStrategy {
  3505. createSubscription(async, updateLatestValue) {
  3506. // According to the promise specification, promises are not cancellable by default.
  3507. // Once a promise is created, it will either resolve or reject, and it doesn't
  3508. // provide a built-in mechanism to cancel it.
  3509. // There may be situations where a promise is provided, and it either resolves after
  3510. // the pipe has been destroyed or never resolves at all. If the promise never
  3511. // resolves — potentially due to factors beyond our control, such as third-party
  3512. // libraries — this can lead to a memory leak.
  3513. // When we use `async.then(updateLatestValue)`, the engine captures a reference to the
  3514. // `updateLatestValue` function. This allows the promise to invoke that function when it
  3515. // resolves. In this case, the promise directly captures a reference to the
  3516. // `updateLatestValue` function. If the promise resolves later, it retains a reference
  3517. // to the original `updateLatestValue`, meaning that even if the context where
  3518. // `updateLatestValue` was defined has been destroyed, the function reference remains in memory.
  3519. // This can lead to memory leaks if `updateLatestValue` is no longer needed or if it holds
  3520. // onto resources that should be released.
  3521. // When we do `async.then(v => ...)` the promise captures a reference to the lambda
  3522. // function (the arrow function).
  3523. // When we assign `updateLatestValue = null` within the context of an `unsubscribe` function,
  3524. // we're changing the reference of `updateLatestValue` in the current scope to `null`.
  3525. // The lambda will no longer have access to it after the assignment, effectively
  3526. // preventing any further calls to the original function and allowing it to be garbage collected.
  3527. async.then(
  3528. // Using optional chaining because we may have set it to `null`; since the promise
  3529. // is async, the view might be destroyed by the time the promise resolves.
  3530. (v) => updateLatestValue?.(v), (e) => {
  3531. throw e;
  3532. });
  3533. return {
  3534. unsubscribe: () => {
  3535. updateLatestValue = null;
  3536. },
  3537. };
  3538. }
  3539. dispose(subscription) {
  3540. subscription.unsubscribe();
  3541. }
  3542. }
  3543. const _promiseStrategy = new PromiseStrategy();
  3544. const _subscribableStrategy = new SubscribableStrategy();
  3545. /**
  3546. * @ngModule CommonModule
  3547. * @description
  3548. *
  3549. * Unwraps a value from an asynchronous primitive.
  3550. *
  3551. * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
  3552. * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
  3553. * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
  3554. * potential memory leaks. When the reference of the expression changes, the `async` pipe
  3555. * automatically unsubscribes from the old `Observable` or `Promise` and subscribes to the new one.
  3556. *
  3557. * @usageNotes
  3558. *
  3559. * ### Examples
  3560. *
  3561. * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
  3562. * promise.
  3563. *
  3564. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
  3565. *
  3566. * It's also possible to use `async` with Observables. The example below binds the `time` Observable
  3567. * to the view. The Observable continuously updates the view with the current time.
  3568. *
  3569. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
  3570. *
  3571. * @publicApi
  3572. */
  3573. class AsyncPipe {
  3574. _ref;
  3575. _latestValue = null;
  3576. markForCheckOnValueUpdate = true;
  3577. _subscription = null;
  3578. _obj = null;
  3579. _strategy = null;
  3580. constructor(ref) {
  3581. // Assign `ref` into `this._ref` manually instead of declaring `_ref` in the constructor
  3582. // parameter list, as the type of `this._ref` includes `null` unlike the type of `ref`.
  3583. this._ref = ref;
  3584. }
  3585. ngOnDestroy() {
  3586. if (this._subscription) {
  3587. this._dispose();
  3588. }
  3589. // Clear the `ChangeDetectorRef` and its association with the view data, to mitigate
  3590. // potential memory leaks in Observables that could otherwise cause the view data to
  3591. // be retained.
  3592. // https://github.com/angular/angular/issues/17624
  3593. this._ref = null;
  3594. }
  3595. transform(obj) {
  3596. if (!this._obj) {
  3597. if (obj) {
  3598. try {
  3599. // Only call `markForCheck` if the value is updated asynchronously.
  3600. // Synchronous updates _during_ subscription should not wastefully mark for check -
  3601. // this value is already going to be returned from the transform function.
  3602. this.markForCheckOnValueUpdate = false;
  3603. this._subscribe(obj);
  3604. }
  3605. finally {
  3606. this.markForCheckOnValueUpdate = true;
  3607. }
  3608. }
  3609. return this._latestValue;
  3610. }
  3611. if (obj !== this._obj) {
  3612. this._dispose();
  3613. return this.transform(obj);
  3614. }
  3615. return this._latestValue;
  3616. }
  3617. _subscribe(obj) {
  3618. this._obj = obj;
  3619. this._strategy = this._selectStrategy(obj);
  3620. this._subscription = this._strategy.createSubscription(obj, (value) => this._updateLatestValue(obj, value));
  3621. }
  3622. _selectStrategy(obj) {
  3623. if (_isPromise(obj)) {
  3624. return _promiseStrategy;
  3625. }
  3626. if (_isSubscribable(obj)) {
  3627. return _subscribableStrategy;
  3628. }
  3629. throw invalidPipeArgumentError(AsyncPipe, obj);
  3630. }
  3631. _dispose() {
  3632. // Note: `dispose` is only called if a subscription has been initialized before, indicating
  3633. // that `this._strategy` is also available.
  3634. this._strategy.dispose(this._subscription);
  3635. this._latestValue = null;
  3636. this._subscription = null;
  3637. this._obj = null;
  3638. }
  3639. _updateLatestValue(async, value) {
  3640. if (async === this._obj) {
  3641. this._latestValue = value;
  3642. if (this.markForCheckOnValueUpdate) {
  3643. this._ref?.markForCheck();
  3644. }
  3645. }
  3646. }
  3647. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AsyncPipe, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Pipe });
  3648. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: AsyncPipe, isStandalone: true, name: "async", pure: false });
  3649. }
  3650. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AsyncPipe, decorators: [{
  3651. type: Pipe,
  3652. args: [{
  3653. name: 'async',
  3654. pure: false,
  3655. }]
  3656. }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }] });
  3657. /**
  3658. * Transforms text to all lower case.
  3659. *
  3660. * @see {@link UpperCasePipe}
  3661. * @see {@link TitleCasePipe}
  3662. * @usageNotes
  3663. *
  3664. * The following example defines a view that allows the user to enter
  3665. * text, and then uses the pipe to convert the input text to all lower case.
  3666. *
  3667. * {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}
  3668. *
  3669. * @ngModule CommonModule
  3670. * @publicApi
  3671. */
  3672. class LowerCasePipe {
  3673. transform(value) {
  3674. if (value == null)
  3675. return null;
  3676. if (typeof value !== 'string') {
  3677. throw invalidPipeArgumentError(LowerCasePipe, value);
  3678. }
  3679. return value.toLowerCase();
  3680. }
  3681. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: LowerCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  3682. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: LowerCasePipe, isStandalone: true, name: "lowercase" });
  3683. }
  3684. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: LowerCasePipe, decorators: [{
  3685. type: Pipe,
  3686. args: [{
  3687. name: 'lowercase',
  3688. }]
  3689. }] });
  3690. //
  3691. // Regex below matches any Unicode word and number compatible with ES5. In ES2018 the same result
  3692. // can be achieved by using /[0-9\p{L}]\S*/gu and also known as Unicode Property Escapes
  3693. // (https://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
  3694. // transpilation of this functionality down to ES5 without external tool, the only solution is
  3695. // to use already transpiled form. Example can be found here -
  3696. // https://mothereff.in/regexpu#input=var+regex+%3D+%2F%5B0-9%5Cp%7BL%7D%5D%5CS*%2Fgu%3B%0A%0A&unicodePropertyEscape=1
  3697. //
  3698. const unicodeWordMatch = /(?:[0-9A-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\u0560-\u0588\u05D0-\u05EA\u05EF-\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\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\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\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\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\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\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-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\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-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\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-\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-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\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-\uAB69\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\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\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-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\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\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\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]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\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-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])\S*/g;
  3699. /**
  3700. * Transforms text to title case.
  3701. * Capitalizes the first letter of each word and transforms the
  3702. * rest of the word to lower case.
  3703. * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
  3704. *
  3705. * @see {@link LowerCasePipe}
  3706. * @see {@link UpperCasePipe}
  3707. *
  3708. * @usageNotes
  3709. * The following example shows the result of transforming various strings into title case.
  3710. *
  3711. * {@example common/pipes/ts/titlecase_pipe.ts region='TitleCasePipe'}
  3712. *
  3713. * @ngModule CommonModule
  3714. * @publicApi
  3715. */
  3716. class TitleCasePipe {
  3717. transform(value) {
  3718. if (value == null)
  3719. return null;
  3720. if (typeof value !== 'string') {
  3721. throw invalidPipeArgumentError(TitleCasePipe, value);
  3722. }
  3723. return value.replace(unicodeWordMatch, (txt) => txt[0].toUpperCase() + txt.slice(1).toLowerCase());
  3724. }
  3725. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: TitleCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  3726. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: TitleCasePipe, isStandalone: true, name: "titlecase" });
  3727. }
  3728. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: TitleCasePipe, decorators: [{
  3729. type: Pipe,
  3730. args: [{
  3731. name: 'titlecase',
  3732. }]
  3733. }] });
  3734. /**
  3735. * Transforms text to all upper case.
  3736. * @see {@link LowerCasePipe}
  3737. * @see {@link TitleCasePipe}
  3738. *
  3739. * @ngModule CommonModule
  3740. * @publicApi
  3741. */
  3742. class UpperCasePipe {
  3743. transform(value) {
  3744. if (value == null)
  3745. return null;
  3746. if (typeof value !== 'string') {
  3747. throw invalidPipeArgumentError(UpperCasePipe, value);
  3748. }
  3749. return value.toUpperCase();
  3750. }
  3751. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: UpperCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  3752. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: UpperCasePipe, isStandalone: true, name: "uppercase" });
  3753. }
  3754. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: UpperCasePipe, decorators: [{
  3755. type: Pipe,
  3756. args: [{
  3757. name: 'uppercase',
  3758. }]
  3759. }] });
  3760. /**
  3761. * The default date format of Angular date pipe, which corresponds to the following format:
  3762. * `'MMM d,y'` (e.g. `Jun 15, 2015`)
  3763. */
  3764. const DEFAULT_DATE_FORMAT = 'mediumDate';
  3765. /**
  3766. * Optionally-provided default timezone to use for all instances of `DatePipe` (such as `'+0430'`).
  3767. * If the value isn't provided, the `DatePipe` will use the end-user's local system timezone.
  3768. *
  3769. * @deprecated use DATE_PIPE_DEFAULT_OPTIONS token to configure DatePipe
  3770. */
  3771. const DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_TIMEZONE' : '');
  3772. /**
  3773. * DI token that allows to provide default configuration for the `DatePipe` instances in an
  3774. * application. The value is an object which can include the following fields:
  3775. * - `dateFormat`: configures the default date format. If not provided, the `DatePipe`
  3776. * will use the 'mediumDate' as a value.
  3777. * - `timezone`: configures the default timezone. If not provided, the `DatePipe` will
  3778. * use the end-user's local system timezone.
  3779. *
  3780. * @see {@link DatePipeConfig}
  3781. *
  3782. * @usageNotes
  3783. *
  3784. * Various date pipe default values can be overwritten by providing this token with
  3785. * the value that has this interface.
  3786. *
  3787. * For example:
  3788. *
  3789. * Override the default date format by providing a value using the token:
  3790. * ```ts
  3791. * providers: [
  3792. * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}
  3793. * ]
  3794. * ```
  3795. *
  3796. * Override the default timezone by providing a value using the token:
  3797. * ```ts
  3798. * providers: [
  3799. * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}
  3800. * ]
  3801. * ```
  3802. */
  3803. const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_OPTIONS' : '');
  3804. /**
  3805. * @ngModule CommonModule
  3806. * @description
  3807. *
  3808. * Formats a date value according to locale rules.
  3809. *
  3810. * `DatePipe` is executed only when it detects a pure change to the input value.
  3811. * A pure change is either a change to a primitive input value
  3812. * (such as `String`, `Number`, `Boolean`, or `Symbol`),
  3813. * or a changed object reference (such as `Date`, `Array`, `Function`, or `Object`).
  3814. *
  3815. * Note that mutating a `Date` object does not cause the pipe to be rendered again.
  3816. * To ensure that the pipe is executed, you must create a new `Date` object.
  3817. *
  3818. * Only the `en-US` locale data comes with Angular. To localize dates
  3819. * in another language, you must import the corresponding locale data.
  3820. * See the [I18n guide](guide/i18n/format-data-locale) for more information.
  3821. *
  3822. * The time zone of the formatted value can be specified either by passing it in as the second
  3823. * parameter of the pipe, or by setting the default through the `DATE_PIPE_DEFAULT_OPTIONS`
  3824. * injection token. The value that is passed in as the second parameter takes precedence over
  3825. * the one defined using the injection token.
  3826. *
  3827. * @see {@link formatDate}
  3828. *
  3829. *
  3830. * @usageNotes
  3831. *
  3832. * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
  3833. * reformat the date on every change-detection cycle, treat the date as an immutable object
  3834. * and change the reference when the pipe needs to run again.
  3835. *
  3836. * ### Pre-defined format options
  3837. *
  3838. * | Option | Equivalent to | Examples (given in `en-US` locale) |
  3839. * |---------------|-------------------------------------|-------------------------------------------------|
  3840. * | `'short'` | `'M/d/yy, h:mm a'` | `6/15/15, 9:03 AM` |
  3841. * | `'medium'` | `'MMM d, y, h:mm:ss a'` | `Jun 15, 2015, 9:03:01 AM` |
  3842. * | `'long'` | `'MMMM d, y, h:mm:ss a z'` | `June 15, 2015 at 9:03:01 AM GMT+1` |
  3843. * | `'full'` | `'EEEE, MMMM d, y, h:mm:ss a zzzz'` | `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00` |
  3844. * | `'shortDate'` | `'M/d/yy'` | `6/15/15` |
  3845. * | `'mediumDate'`| `'MMM d, y'` | `Jun 15, 2015` |
  3846. * | `'longDate'` | `'MMMM d, y'` | `June 15, 2015` |
  3847. * | `'fullDate'` | `'EEEE, MMMM d, y'` | `Monday, June 15, 2015` |
  3848. * | `'shortTime'` | `'h:mm a'` | `9:03 AM` |
  3849. * | `'mediumTime'`| `'h:mm:ss a'` | `9:03:01 AM` |
  3850. * | `'longTime'` | `'h:mm:ss a z'` | `9:03:01 AM GMT+1` |
  3851. * | `'fullTime'` | `'h:mm:ss a zzzz'` | `9:03:01 AM GMT+01:00` |
  3852. *
  3853. * ### Custom format options
  3854. *
  3855. * You can construct a format string using symbols to specify the components
  3856. * of a date-time value, as described in the following table.
  3857. * Format details depend on the locale.
  3858. * Fields marked with (*) are only available in the extra data set for the given locale.
  3859. *
  3860. * | Field type | Format | Description | Example Value |
  3861. * |-------------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
  3862. * | Era | G, GG & GGG | Abbreviated | AD |
  3863. * | | GGGG | Wide | Anno Domini |
  3864. * | | GGGGG | Narrow | A |
  3865. * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  3866. * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  3867. * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  3868. * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  3869. * | ISO Week-numbering year | Y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  3870. * | | YY | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  3871. * | | YYY | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  3872. * | | YYYY | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  3873. * | Month | M | Numeric: 1 digit | 9, 12 |
  3874. * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
  3875. * | | MMM | Abbreviated | Sep |
  3876. * | | MMMM | Wide | September |
  3877. * | | MMMMM | Narrow | S |
  3878. * | Month standalone | L | Numeric: 1 digit | 9, 12 |
  3879. * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
  3880. * | | LLL | Abbreviated | Sep |
  3881. * | | LLLL | Wide | September |
  3882. * | | LLLLL | Narrow | S |
  3883. * | ISO Week of year | w | Numeric: minimum digits | 1... 53 |
  3884. * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
  3885. * | Week of month | W | Numeric: 1 digit | 1... 5 |
  3886. * | Day of month | d | Numeric: minimum digits | 1 |
  3887. * | | dd | Numeric: 2 digits + zero padded | 01 |
  3888. * | Week day | E, EE & EEE | Abbreviated | Tue |
  3889. * | | EEEE | Wide | Tuesday |
  3890. * | | EEEEE | Narrow | T |
  3891. * | | EEEEEE | Short | Tu |
  3892. * | Week day standalone | c, cc | Numeric: 1 digit | 2 |
  3893. * | | ccc | Abbreviated | Tue |
  3894. * | | cccc | Wide | Tuesday |
  3895. * | | ccccc | Narrow | T |
  3896. * | | cccccc | Short | Tu |
  3897. * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
  3898. * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
  3899. * | | aaaaa | Narrow | a/p |
  3900. * | Period* | B, BB & BBB | Abbreviated | mid. |
  3901. * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  3902. * | | BBBBB | Narrow | md |
  3903. * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
  3904. * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  3905. * | | bbbbb | Narrow | md |
  3906. * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
  3907. * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
  3908. * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
  3909. * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
  3910. * | Minute | m | Numeric: minimum digits | 8, 59 |
  3911. * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
  3912. * | Second | s | Numeric: minimum digits | 0... 59 |
  3913. * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
  3914. * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
  3915. * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
  3916. * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
  3917. * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
  3918. * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
  3919. * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
  3920. * | | ZZZZ | Long localized GMT format | GMT-8:00 |
  3921. * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
  3922. * | | O, OO & OOO | Short localized GMT format | GMT-8 |
  3923. * | | OOOO | Long localized GMT format | GMT-08:00 |
  3924. *
  3925. *
  3926. * ### Format examples
  3927. *
  3928. * These examples transform a date into various formats,
  3929. * assuming that `dateObj` is a JavaScript `Date` object for
  3930. * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
  3931. * given in the local time for the `en-US` locale.
  3932. *
  3933. * ```
  3934. * {{ dateObj | date }} // output is 'Jun 15, 2015'
  3935. * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
  3936. * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
  3937. * {{ dateObj | date:'mm:ss' }} // output is '43:11'
  3938. * {{ dateObj | date:"MMM dd, yyyy 'at' hh:mm a" }} // output is 'Jun 15, 2015 at 09:43 PM'
  3939. * ```
  3940. *
  3941. * ### Usage example
  3942. *
  3943. * The following component uses a date pipe to display the current date in different formats.
  3944. *
  3945. * ```angular-ts
  3946. * @Component({
  3947. * selector: 'date-pipe',
  3948. * template: `<div>
  3949. * <p>Today is {{today | date}}</p>
  3950. * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
  3951. * <p>The time is {{today | date:'h:mm a z'}}</p>
  3952. * </div>`
  3953. * })
  3954. * // Get the current date and time as a date-time value.
  3955. * export class DatePipeComponent {
  3956. * today: number = Date.now();
  3957. * }
  3958. * ```
  3959. *
  3960. * @publicApi
  3961. */
  3962. class DatePipe {
  3963. locale;
  3964. defaultTimezone;
  3965. defaultOptions;
  3966. constructor(locale, defaultTimezone, defaultOptions) {
  3967. this.locale = locale;
  3968. this.defaultTimezone = defaultTimezone;
  3969. this.defaultOptions = defaultOptions;
  3970. }
  3971. transform(value, format, timezone, locale) {
  3972. if (value == null || value === '' || value !== value)
  3973. return null;
  3974. try {
  3975. const _format = format ?? this.defaultOptions?.dateFormat ?? DEFAULT_DATE_FORMAT;
  3976. const _timezone = timezone ?? this.defaultOptions?.timezone ?? this.defaultTimezone ?? undefined;
  3977. return formatDate(value, _format, locale || this.locale, _timezone);
  3978. }
  3979. catch (error) {
  3980. throw invalidPipeArgumentError(DatePipe, error.message);
  3981. }
  3982. }
  3983. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: DatePipe, deps: [{ token: LOCALE_ID }, { token: DATE_PIPE_DEFAULT_TIMEZONE, optional: true }, { token: DATE_PIPE_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Pipe });
  3984. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: DatePipe, isStandalone: true, name: "date" });
  3985. }
  3986. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: DatePipe, decorators: [{
  3987. type: Pipe,
  3988. args: [{
  3989. name: 'date',
  3990. }]
  3991. }], ctorParameters: () => [{ type: undefined, decorators: [{
  3992. type: Inject,
  3993. args: [LOCALE_ID]
  3994. }] }, { type: undefined, decorators: [{
  3995. type: Inject,
  3996. args: [DATE_PIPE_DEFAULT_TIMEZONE]
  3997. }, {
  3998. type: Optional
  3999. }] }, { type: undefined, decorators: [{
  4000. type: Inject,
  4001. args: [DATE_PIPE_DEFAULT_OPTIONS]
  4002. }, {
  4003. type: Optional
  4004. }] }] });
  4005. const _INTERPOLATION_REGEXP = /#/g;
  4006. /**
  4007. * @ngModule CommonModule
  4008. * @description
  4009. *
  4010. * Maps a value to a string that pluralizes the value according to locale rules.
  4011. *
  4012. * @usageNotes
  4013. *
  4014. * ### Example
  4015. *
  4016. * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
  4017. *
  4018. * @publicApi
  4019. */
  4020. class I18nPluralPipe {
  4021. _localization;
  4022. constructor(_localization) {
  4023. this._localization = _localization;
  4024. }
  4025. /**
  4026. * @param value the number to be formatted
  4027. * @param pluralMap an object that mimics the ICU format, see
  4028. * https://unicode-org.github.io/icu/userguide/format_parse/messages/.
  4029. * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
  4030. * default).
  4031. */
  4032. transform(value, pluralMap, locale) {
  4033. if (value == null)
  4034. return '';
  4035. if (typeof pluralMap !== 'object' || pluralMap === null) {
  4036. throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
  4037. }
  4038. const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
  4039. return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
  4040. }
  4041. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: I18nPluralPipe, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Pipe });
  4042. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: I18nPluralPipe, isStandalone: true, name: "i18nPlural" });
  4043. }
  4044. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: I18nPluralPipe, decorators: [{
  4045. type: Pipe,
  4046. args: [{
  4047. name: 'i18nPlural',
  4048. }]
  4049. }], ctorParameters: () => [{ type: NgLocalization }] });
  4050. /**
  4051. * @ngModule CommonModule
  4052. * @description
  4053. *
  4054. * Generic selector that displays the string that matches the current value.
  4055. *
  4056. * If none of the keys of the `mapping` match the `value`, then the content
  4057. * of the `other` key is returned when present, otherwise an empty string is returned.
  4058. *
  4059. * @usageNotes
  4060. *
  4061. * ### Example
  4062. *
  4063. * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
  4064. *
  4065. * @publicApi
  4066. */
  4067. class I18nSelectPipe {
  4068. /**
  4069. * @param value a string to be internationalized.
  4070. * @param mapping an object that indicates the text that should be displayed
  4071. * for different values of the provided `value`.
  4072. */
  4073. transform(value, mapping) {
  4074. if (value == null)
  4075. return '';
  4076. if (typeof mapping !== 'object' || typeof value !== 'string') {
  4077. throw invalidPipeArgumentError(I18nSelectPipe, mapping);
  4078. }
  4079. if (mapping.hasOwnProperty(value)) {
  4080. return mapping[value];
  4081. }
  4082. if (mapping.hasOwnProperty('other')) {
  4083. return mapping['other'];
  4084. }
  4085. return '';
  4086. }
  4087. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: I18nSelectPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  4088. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: I18nSelectPipe, isStandalone: true, name: "i18nSelect" });
  4089. }
  4090. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: I18nSelectPipe, decorators: [{
  4091. type: Pipe,
  4092. args: [{
  4093. name: 'i18nSelect',
  4094. }]
  4095. }] });
  4096. /**
  4097. * @ngModule CommonModule
  4098. * @description
  4099. *
  4100. * Converts a value into its JSON-format representation. Useful for debugging.
  4101. *
  4102. * @usageNotes
  4103. *
  4104. * The following component uses a JSON pipe to convert an object
  4105. * to JSON format, and displays the string in both formats for comparison.
  4106. *
  4107. * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
  4108. *
  4109. * @publicApi
  4110. */
  4111. class JsonPipe {
  4112. /**
  4113. * @param value A value of any type to convert into a JSON-format string.
  4114. */
  4115. transform(value) {
  4116. return JSON.stringify(value, null, 2);
  4117. }
  4118. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: JsonPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  4119. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: JsonPipe, isStandalone: true, name: "json", pure: false });
  4120. }
  4121. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: JsonPipe, decorators: [{
  4122. type: Pipe,
  4123. args: [{
  4124. name: 'json',
  4125. pure: false,
  4126. }]
  4127. }] });
  4128. function makeKeyValuePair(key, value) {
  4129. return { key: key, value: value };
  4130. }
  4131. /**
  4132. * @ngModule CommonModule
  4133. * @description
  4134. *
  4135. * Transforms Object or Map into an array of key value pairs.
  4136. *
  4137. * The output array will be ordered by keys.
  4138. * By default the comparator will be by Unicode point value.
  4139. * You can optionally pass a compareFn if your keys are complex types.
  4140. * Passing `null` as the compareFn will use natural ordering of the input.
  4141. *
  4142. * @usageNotes
  4143. * ### Examples
  4144. *
  4145. * This examples show how an Object or a Map can be iterated by ngFor with the use of this
  4146. * keyvalue pipe.
  4147. *
  4148. * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
  4149. *
  4150. * @publicApi
  4151. */
  4152. class KeyValuePipe {
  4153. differs;
  4154. constructor(differs) {
  4155. this.differs = differs;
  4156. }
  4157. differ;
  4158. keyValues = [];
  4159. compareFn = defaultComparator;
  4160. transform(input, compareFn = defaultComparator) {
  4161. if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
  4162. return null;
  4163. }
  4164. // make a differ for whatever type we've been passed in
  4165. this.differ ??= this.differs.find(input).create();
  4166. const differChanges = this.differ.diff(input);
  4167. const compareFnChanged = compareFn !== this.compareFn;
  4168. if (differChanges) {
  4169. this.keyValues = [];
  4170. differChanges.forEachItem((r) => {
  4171. this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
  4172. });
  4173. }
  4174. if (differChanges || compareFnChanged) {
  4175. if (compareFn) {
  4176. this.keyValues.sort(compareFn);
  4177. }
  4178. this.compareFn = compareFn;
  4179. }
  4180. return this.keyValues;
  4181. }
  4182. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: KeyValuePipe, deps: [{ token: i0.KeyValueDiffers }], target: i0.ɵɵFactoryTarget.Pipe });
  4183. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: KeyValuePipe, isStandalone: true, name: "keyvalue", pure: false });
  4184. }
  4185. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: KeyValuePipe, decorators: [{
  4186. type: Pipe,
  4187. args: [{
  4188. name: 'keyvalue',
  4189. pure: false,
  4190. }]
  4191. }], ctorParameters: () => [{ type: i0.KeyValueDiffers }] });
  4192. function defaultComparator(keyValueA, keyValueB) {
  4193. const a = keyValueA.key;
  4194. const b = keyValueB.key;
  4195. // If both keys are the same, return 0 (no sorting needed).
  4196. if (a === b)
  4197. return 0;
  4198. // If one of the keys is `null` or `undefined`, place it at the end of the sort.
  4199. if (a == null)
  4200. return 1; // `a` comes after `b`.
  4201. if (b == null)
  4202. return -1; // `b` comes after `a`.
  4203. // If both keys are strings, compare them lexicographically.
  4204. if (typeof a == 'string' && typeof b == 'string') {
  4205. return a < b ? -1 : 1;
  4206. }
  4207. // If both keys are numbers, sort them numerically.
  4208. if (typeof a == 'number' && typeof b == 'number') {
  4209. return a - b;
  4210. }
  4211. // If both keys are booleans, sort `false` before `true`.
  4212. if (typeof a == 'boolean' && typeof b == 'boolean') {
  4213. return a < b ? -1 : 1;
  4214. }
  4215. // Fallback case: if keys are of different types, compare their string representations.
  4216. const aString = String(a);
  4217. const bString = String(b);
  4218. // Compare the string representations lexicographically.
  4219. return aString == bString ? 0 : aString < bString ? -1 : 1;
  4220. }
  4221. /**
  4222. * @ngModule CommonModule
  4223. * @description
  4224. *
  4225. * Formats a value according to digit options and locale rules.
  4226. * Locale determines group sizing and separator,
  4227. * decimal point character, and other locale-specific configurations.
  4228. *
  4229. * @see {@link formatNumber}
  4230. *
  4231. * @usageNotes
  4232. *
  4233. * ### digitsInfo
  4234. *
  4235. * The value's decimal representation is specified by the `digitsInfo`
  4236. * parameter, written in the following format:<br>
  4237. *
  4238. * ```
  4239. * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
  4240. * ```
  4241. *
  4242. * - `minIntegerDigits`:
  4243. * The minimum number of integer digits before the decimal point.
  4244. * Default is 1.
  4245. *
  4246. * - `minFractionDigits`:
  4247. * The minimum number of digits after the decimal point.
  4248. * Default is 0.
  4249. *
  4250. * - `maxFractionDigits`:
  4251. * The maximum number of digits after the decimal point.
  4252. * Default is 3.
  4253. *
  4254. * If the formatted value is truncated it will be rounded using the "to-nearest" method:
  4255. *
  4256. * ```
  4257. * {{3.6 | number: '1.0-0'}}
  4258. * <!--will output '4'-->
  4259. *
  4260. * {{-3.6 | number:'1.0-0'}}
  4261. * <!--will output '-4'-->
  4262. * ```
  4263. *
  4264. * ### locale
  4265. *
  4266. * `locale` will format a value according to locale rules.
  4267. * Locale determines group sizing and separator,
  4268. * decimal point character, and other locale-specific configurations.
  4269. *
  4270. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  4271. *
  4272. * See [Setting your app locale](guide/i18n/locale-id).
  4273. *
  4274. * ### Example
  4275. *
  4276. * The following code shows how the pipe transforms values
  4277. * according to various format specifications,
  4278. * where the caller's default locale is `en-US`.
  4279. *
  4280. * {@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
  4281. *
  4282. * @publicApi
  4283. */
  4284. class DecimalPipe {
  4285. _locale;
  4286. constructor(_locale) {
  4287. this._locale = _locale;
  4288. }
  4289. transform(value, digitsInfo, locale) {
  4290. if (!isValue(value))
  4291. return null;
  4292. locale ||= this._locale;
  4293. try {
  4294. const num = strToNumber(value);
  4295. return formatNumber(num, locale, digitsInfo);
  4296. }
  4297. catch (error) {
  4298. throw invalidPipeArgumentError(DecimalPipe, error.message);
  4299. }
  4300. }
  4301. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: DecimalPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
  4302. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: DecimalPipe, isStandalone: true, name: "number" });
  4303. }
  4304. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: DecimalPipe, decorators: [{
  4305. type: Pipe,
  4306. args: [{
  4307. name: 'number',
  4308. }]
  4309. }], ctorParameters: () => [{ type: undefined, decorators: [{
  4310. type: Inject,
  4311. args: [LOCALE_ID]
  4312. }] }] });
  4313. /**
  4314. * @ngModule CommonModule
  4315. * @description
  4316. *
  4317. * Transforms a number to a percentage
  4318. * string, formatted according to locale rules that determine group sizing and
  4319. * separator, decimal-point character, and other locale-specific
  4320. * configurations.
  4321. *
  4322. * @see {@link formatPercent}
  4323. *
  4324. * @usageNotes
  4325. * The following code shows how the pipe transforms numbers
  4326. * into text strings, according to various format specifications,
  4327. * where the caller's default locale is `en-US`.
  4328. *
  4329. * {@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}
  4330. *
  4331. * @publicApi
  4332. */
  4333. class PercentPipe {
  4334. _locale;
  4335. constructor(_locale) {
  4336. this._locale = _locale;
  4337. }
  4338. /**
  4339. *
  4340. * @param value The number to be formatted as a percentage.
  4341. * @param digitsInfo Decimal representation options, specified by a string
  4342. * in the following format:<br>
  4343. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  4344. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  4345. * Default is `1`.
  4346. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  4347. * Default is `0`.
  4348. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  4349. * Default is `0`.
  4350. * @param locale A locale code for the locale format rules to use.
  4351. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  4352. * See [Setting your app locale](guide/i18n/locale-id).
  4353. */
  4354. transform(value, digitsInfo, locale) {
  4355. if (!isValue(value))
  4356. return null;
  4357. locale ||= this._locale;
  4358. try {
  4359. const num = strToNumber(value);
  4360. return formatPercent(num, locale, digitsInfo);
  4361. }
  4362. catch (error) {
  4363. throw invalidPipeArgumentError(PercentPipe, error.message);
  4364. }
  4365. }
  4366. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: PercentPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
  4367. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: PercentPipe, isStandalone: true, name: "percent" });
  4368. }
  4369. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: PercentPipe, decorators: [{
  4370. type: Pipe,
  4371. args: [{
  4372. name: 'percent',
  4373. }]
  4374. }], ctorParameters: () => [{ type: undefined, decorators: [{
  4375. type: Inject,
  4376. args: [LOCALE_ID]
  4377. }] }] });
  4378. /**
  4379. * @ngModule CommonModule
  4380. * @description
  4381. *
  4382. * Transforms a number to a currency string, formatted according to locale rules
  4383. * that determine group sizing and separator, decimal-point character,
  4384. * and other locale-specific configurations.
  4385. *
  4386. *
  4387. * @see {@link getCurrencySymbol}
  4388. * @see {@link formatCurrency}
  4389. *
  4390. * @usageNotes
  4391. * The following code shows how the pipe transforms numbers
  4392. * into text strings, according to various format specifications,
  4393. * where the caller's default locale is `en-US`.
  4394. *
  4395. * {@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}
  4396. *
  4397. * @publicApi
  4398. */
  4399. class CurrencyPipe {
  4400. _locale;
  4401. _defaultCurrencyCode;
  4402. constructor(_locale, _defaultCurrencyCode = 'USD') {
  4403. this._locale = _locale;
  4404. this._defaultCurrencyCode = _defaultCurrencyCode;
  4405. }
  4406. transform(value, currencyCode = this._defaultCurrencyCode, display = 'symbol', digitsInfo, locale) {
  4407. if (!isValue(value))
  4408. return null;
  4409. locale ||= this._locale;
  4410. if (typeof display === 'boolean') {
  4411. if ((typeof ngDevMode === 'undefined' || ngDevMode) && console && console.warn) {
  4412. 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".`);
  4413. }
  4414. display = display ? 'symbol' : 'code';
  4415. }
  4416. let currency = currencyCode || this._defaultCurrencyCode;
  4417. if (display !== 'code') {
  4418. if (display === 'symbol' || display === 'symbol-narrow') {
  4419. currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
  4420. }
  4421. else {
  4422. currency = display;
  4423. }
  4424. }
  4425. try {
  4426. const num = strToNumber(value);
  4427. return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
  4428. }
  4429. catch (error) {
  4430. throw invalidPipeArgumentError(CurrencyPipe, error.message);
  4431. }
  4432. }
  4433. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: CurrencyPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe });
  4434. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: "currency" });
  4435. }
  4436. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: CurrencyPipe, decorators: [{
  4437. type: Pipe,
  4438. args: [{
  4439. name: 'currency',
  4440. }]
  4441. }], ctorParameters: () => [{ type: undefined, decorators: [{
  4442. type: Inject,
  4443. args: [LOCALE_ID]
  4444. }] }, { type: undefined, decorators: [{
  4445. type: Inject,
  4446. args: [DEFAULT_CURRENCY_CODE]
  4447. }] }] });
  4448. function isValue(value) {
  4449. return !(value == null || value === '' || value !== value);
  4450. }
  4451. /**
  4452. * Transforms a string into a number (if needed).
  4453. */
  4454. function strToNumber(value) {
  4455. // Convert strings to numbers
  4456. if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
  4457. return Number(value);
  4458. }
  4459. if (typeof value !== 'number') {
  4460. throw new Error(`${value} is not a number`);
  4461. }
  4462. return value;
  4463. }
  4464. /**
  4465. * @ngModule CommonModule
  4466. * @description
  4467. *
  4468. * Creates a new `Array` or `String` containing a subset (slice) of the elements.
  4469. *
  4470. * @usageNotes
  4471. *
  4472. * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
  4473. * and `String.prototype.slice()`.
  4474. *
  4475. * When operating on an `Array`, the returned `Array` is always a copy even when all
  4476. * the elements are being returned.
  4477. *
  4478. * When operating on a blank value, the pipe returns the blank value.
  4479. *
  4480. * ### List Example
  4481. *
  4482. * This `ngFor` example:
  4483. *
  4484. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
  4485. *
  4486. * produces the following:
  4487. *
  4488. * ```html
  4489. * <li>b</li>
  4490. * <li>c</li>
  4491. * ```
  4492. *
  4493. * ### String Examples
  4494. *
  4495. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
  4496. *
  4497. * @publicApi
  4498. */
  4499. class SlicePipe {
  4500. transform(value, start, end) {
  4501. if (value == null)
  4502. return null;
  4503. const supports = typeof value === 'string' || Array.isArray(value);
  4504. if (!supports) {
  4505. throw invalidPipeArgumentError(SlicePipe, value);
  4506. }
  4507. return value.slice(start, end);
  4508. }
  4509. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: SlicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  4510. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: SlicePipe, isStandalone: true, name: "slice", pure: false });
  4511. }
  4512. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: SlicePipe, decorators: [{
  4513. type: Pipe,
  4514. args: [{
  4515. name: 'slice',
  4516. pure: false,
  4517. }]
  4518. }] });
  4519. /**
  4520. * @module
  4521. * @description
  4522. * This module provides a set of common Pipes.
  4523. */
  4524. /**
  4525. * A collection of Angular pipes that are likely to be used in each and every application.
  4526. */
  4527. const COMMON_PIPES = [
  4528. AsyncPipe,
  4529. UpperCasePipe,
  4530. LowerCasePipe,
  4531. JsonPipe,
  4532. SlicePipe,
  4533. DecimalPipe,
  4534. PercentPipe,
  4535. TitleCasePipe,
  4536. CurrencyPipe,
  4537. DatePipe,
  4538. I18nPluralPipe,
  4539. I18nSelectPipe,
  4540. KeyValuePipe,
  4541. ];
  4542. // Note: This does not contain the location providers,
  4543. // as they need some platform specific implementations to work.
  4544. /**
  4545. * Exports all the basic Angular directives and pipes,
  4546. * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
  4547. * Re-exported by `BrowserModule`, which is included automatically in the root
  4548. * `AppModule` when you create a new app with the CLI `new` command.
  4549. *
  4550. * @publicApi
  4551. */
  4552. class CommonModule {
  4553. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: CommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  4554. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: CommonModule, imports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe], exports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe] });
  4555. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: CommonModule });
  4556. }
  4557. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: CommonModule, decorators: [{
  4558. type: NgModule,
  4559. args: [{
  4560. imports: [COMMON_DIRECTIVES, COMMON_PIPES],
  4561. exports: [COMMON_DIRECTIVES, COMMON_PIPES],
  4562. }]
  4563. }] });
  4564. export { AsyncPipe, CommonModule, CurrencyPipe, DATE_PIPE_DEFAULT_OPTIONS, DATE_PIPE_DEFAULT_TIMEZONE, DatePipe, DecimalPipe, FormStyle, FormatWidth, HashLocationStrategy, I18nPluralPipe, I18nSelectPipe, JsonPipe, KeyValuePipe, LowerCasePipe, NgClass, NgComponentOutlet, NgForOf, NgForOfContext, NgIf, NgIfContext, NgLocaleLocalization, NgLocalization, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NumberFormatStyle, NumberSymbol, PercentPipe, Plural, SlicePipe, TitleCasePipe, TranslationWidth, UpperCasePipe, WeekDay, formatCurrency, formatDate, formatNumber, formatPercent, getCurrencySymbol, getLocaleCurrencyCode, getLocaleCurrencyName, getLocaleCurrencySymbol, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleDayNames, getLocaleDayPeriods, getLocaleDirection, getLocaleEraNames, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocaleFirstDayOfWeek, getLocaleId, getLocaleMonthNames, getLocaleNumberFormat, getLocaleNumberSymbol, getLocalePluralCase, getLocaleTimeFormat, getLocaleWeekEndRange, getNumberOfCurrencyDigits };
  4565. //# sourceMappingURL=common_module-Dx7dWex5.mjs.map