{"version":3,"file":"ngxtension-intl.mjs","sources":["../../../../libs/ngxtension/intl/src/display-names.pipe.ts","../../../../libs/ngxtension/intl/src/list-format.pipe.ts","../../../../libs/ngxtension/intl/src/plural-rules.pipe.ts","../../../../libs/ngxtension/intl/src/relative-time-format.pipe.ts","../../../../libs/ngxtension/intl/src/supportedValuesOf.pipe.ts","../../../../libs/ngxtension/intl/src/ngxtension-intl.ts"],"sourcesContent":["import {\n\tinject,\n\tLOCALE_ID,\n\tPipe,\n\ttype PipeTransform,\n\ttype Provider,\n} from '@angular/core';\nimport { createInjectionToken } from 'ngxtension/create-injection-token';\n\ntype DisplayNamesOptions = Omit<Intl.DisplayNamesOptions, 'type'>;\n\n/**\n * @internal\n */\nconst defaultOptions: DisplayNamesOptions = {\n\tstyle: 'short',\n\tlocaleMatcher: 'lookup',\n\tfallback: 'code',\n};\n\n/**\n * @internal\n */\nconst [injectFn, provideFn] = createInjectionToken(() => defaultOptions);\n\n/**\n * Provides a way to inject the options for the DisplayNamesPipe.\n *\n * @param options The options to use for the DisplayNamesPipe.\n * @returns The provider for the DisplayNamesPipe.\n */\nexport function provideDisplayNamesOptions(\n\toptions: Partial<DisplayNamesOptions>,\n): Provider {\n\treturn provideFn({ ...defaultOptions, ...options });\n}\n\n/**\n * This pipe is a wrapper around the [Intl.DisplayNames](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames) API.\n *\n * @returns The display name of the code or the code as it is in case of errors.\n */\n@Pipe({\n\tname: 'displayNames',\n\tstandalone: true,\n})\nexport class DisplayNamesPipe implements PipeTransform {\n\treadonly defaultOptions = injectFn();\n\treadonly locale = inject(LOCALE_ID);\n\n\t/**\n\t * Displays the name of the given code in the given locale.\n\t *\n\t * @param code The code to transform.\n\t * @param type DisplayNamesType to use.\n\t * @param style Optional. The formatting style to use. Defaults to \"short\".\n\t * @param locale Optional. The locale to use for the transformation. Defaults to LOCALE_ID.\n\t * @returns The name of the given code in the given locale or the code itself if the name could not be found.\n\t */\n\ttransform(\n\t\tcode: string,\n\t\ttype: Intl.DisplayNamesType,\n\t\tstyle?: Intl.DisplayNamesOptions['style'],\n\t\tlocale?: string | string[],\n\t): ReturnType<Intl.DisplayNames['of']> {\n\t\ttry {\n\t\t\treturn new Intl.DisplayNames(locale || this.locale, {\n\t\t\t\t...this.defaultOptions,\n\t\t\t\ttype,\n\t\t\t\t...(style ? { style } : {}),\n\t\t\t}).of(code);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\treturn code;\n\t\t}\n\t}\n}\n","import {\n\tinject,\n\tLOCALE_ID,\n\tPipe,\n\ttype PipeTransform,\n\ttype Provider,\n} from '@angular/core';\nimport { createInjectionToken } from 'ngxtension/create-injection-token';\n\n/**\n * @internal\n */\nconst defaultOptions: Intl.ListFormatOptions = {\n\tstyle: 'long',\n\ttype: 'conjunction',\n};\n\n/**\n * @internal\n */\nconst [injectFn, provideFn] = createInjectionToken(() => defaultOptions);\n\n/**\n * Provides a way to inject the options for the ListFormatPipe.\n *\n * @param options The options to use for the ListFormatPipe.\n * @returns The provider for the ListFormatPipe.\n */\nexport function provideListFormatOptions(\n\toptions: Partial<Intl.ListFormatOptions>,\n): Provider {\n\treturn provideFn({ ...defaultOptions, ...options });\n}\n\n/**\n * This pipe is a wrapper around the [Intl.ListFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) API.\n *\n * @returns The formatted list of values or the list as string in case of errors.\n */\n@Pipe({\n\tname: 'listFormat',\n\tstandalone: true,\n})\nexport class ListFormatPipe implements PipeTransform {\n\treadonly defaultOptions = injectFn();\n\treadonly locale = inject(LOCALE_ID);\n\n\t/**\n\t * Transforms the list of values into a formatted string.\n\t *\n\t * @param value The list of values to format.\n\t * @param style Optional. The formatting style to use. Defaults to \"long\".\n\t * @param locale Optional. The locale to use for the transformation. Defaults to LOCALE_ID.\n\t * @returns The formatted list of values or the list as string in case of errors.\n\t */\n\ttransform(\n\t\tvalue: Iterable<string>,\n\t\tstyle?: Intl.ListFormatOptions['style'],\n\t\tlocale?: string | string[],\n\t): string {\n\t\ttry {\n\t\t\treturn new Intl.ListFormat(locale || this.locale, {\n\t\t\t\t...this.defaultOptions,\n\t\t\t\t...(style ? { style } : {}),\n\t\t\t}).format(Array.from(value));\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\treturn Array.from(value).join(', ');\n\t\t}\n\t}\n}\n","import {\n\tinject,\n\tLOCALE_ID,\n\tPipe,\n\ttype PipeTransform,\n\ttype Provider,\n} from '@angular/core';\nimport { createInjectionToken } from 'ngxtension/create-injection-token';\n\n/**\n * @internal\n */\nconst defaultOptions: Intl.PluralRulesOptions = {\n\tlocaleMatcher: 'best fit', // other values: \"lookup\",\n\ttype: 'cardinal', // other values: \"ordinal\"\n};\n\n/**\n * @internal\n */\nconst [injectFn, provideFn] = createInjectionToken(() => defaultOptions);\n\n/**\n * Provides a way to inject the options for the PluralRules.\n *\n * @param options The options to use for the PluralRules.\n * @returns The provider for the PluralRules.\n */\nexport function providePluralRulesOptions(\n\toptions: Partial<Intl.PluralRulesOptions>,\n): Provider {\n\treturn provideFn({ ...defaultOptions, ...options });\n}\n\n/**\n * This pipe is a wrapper around the [Intl.PluralRules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules) API.\n * It takes a value and returns the plural category for that value.\n *\n * @returns The plural category for the value or the value as string in case of errors.\n */\n@Pipe({\n\tname: 'pluralRules',\n\tstandalone: true,\n})\nexport class PluralRulesPipe implements PipeTransform {\n\treadonly defaultOptions = injectFn();\n\treadonly locale = inject(LOCALE_ID);\n\n\t/**\n\t * Transforms the value into a plural category.\n\t *\n\t * @param value The value to transform.\n\t * @param locale Optional, the locale to use for the formatting.\n\t * @returns The plural category for the value or the value as string in case of errors.\n\t */\n\ttransform(\n\t\tvalue: number,\n\t\tlocale?: string,\n\t): ReturnType<Intl.PluralRules['select']> | string {\n\t\ttry {\n\t\t\treturn new Intl.PluralRules(\n\t\t\t\tlocale || this.locale,\n\t\t\t\tthis.defaultOptions,\n\t\t\t).select(value);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\treturn String(value);\n\t\t}\n\t}\n}\n","import {\n\tinject,\n\tLOCALE_ID,\n\tPipe,\n\ttype PipeTransform,\n\ttype Provider,\n} from '@angular/core';\nimport { createInjectionToken } from 'ngxtension/create-injection-token';\n\n/**\n * @internal\n */\nconst defaultOptions: Intl.RelativeTimeFormatOptions = {\n\tlocaleMatcher: 'best fit', // other values: \"lookup\"\n\tnumeric: 'always', // other values: \"auto\"\n\tstyle: 'long', // other values: \"short\" or \"narrow\"\n};\n\n/**\n * @internal\n */\nconst [injectFn, provideFn] = createInjectionToken(() => defaultOptions);\n\n/**\n * Provides a way to inject the options for the RelativeTimeFormatPipe.\n * @param options The options to use for the RelativeTimeFormatPipe.\n *\n * @returns The provider for the RelativeTimeFormatPipe.\n */\nexport function provideRelativeTimeFormatOptions(\n\toptions: Partial<Intl.RelativeTimeFormatOptions>,\n): Provider {\n\treturn provideFn({ ...defaultOptions, ...options });\n}\n\n/**\n * This pipe is a wrapper around the [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat) API.\n *\n * @returns The relative time format of the value or the value as it is in case of errors.\n */\n@Pipe({\n\tname: 'relativeTimeFormat',\n\tstandalone: true,\n})\nexport class RelativeTimeFormatPipe implements PipeTransform {\n\treadonly defaultOptions = injectFn();\n\treadonly locale = inject(LOCALE_ID);\n\n\t/**\n\t * Transforms the value into a relative time format.\n\t *\n\t * @param value The value to format.\n\t * @param unit The unit of the value.\n\t * @param style Optional, the formatting style to use.\n\t * @param locale Optional, the locale to use for the formatting.\n\t * @returns The relative time format of the value or the value as it is in case of errors.\n\t */\n\ttransform(\n\t\tvalue: number,\n\t\tunit: Intl.RelativeTimeFormatUnit,\n\t\tstyle?: Intl.RelativeTimeFormatOptions['style'],\n\t\tlocale?: string,\n\t): ReturnType<Intl.RelativeTimeFormat['format']> {\n\t\ttry {\n\t\t\treturn new Intl.RelativeTimeFormat(locale || this.locale, {\n\t\t\t\t...this.defaultOptions,\n\t\t\t\t...(style ? { style } : {}),\n\t\t\t}).format(value, unit);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\treturn value.toString();\n\t\t}\n\t}\n}\n","import { Pipe, type PipeTransform } from '@angular/core';\n\n/**\n * This pipe is a wrapper around the [Intl.supportedValuesOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf) method.\n *\n * @returns An array containing the supported calendar, collation, currency, numbering systems, or unit values supported by the implementation.\n */\n@Pipe({\n\tname: 'supportedValuesOf',\n\tstandalone: true,\n})\nexport class SupportedValuesOf implements PipeTransform {\n\t/**\n\t * Transforms a key into an array containing the supported calendar, collation, currency, numbering systems, or unit values supported by the implementation.\n\t *\n\t * @param key A key string indicating the category of values to be returned. This is one of: \"calendar\", \"collation\", \"currency\",\"numberingSystem\", \"timeZone\", \"unit\"\n\t * @returns An array containing the supported values for the key or an empty array if the input is invalid.\n\t */\n\ttransform(\n\t\tkey:\n\t\t\t| 'calendar'\n\t\t\t| 'collation'\n\t\t\t| 'currency'\n\t\t\t| 'numberingSystem'\n\t\t\t| 'timeZone'\n\t\t\t| 'unit',\n\t): string[] {\n\t\ttry {\n\t\t\treturn Intl.supportedValuesOf(key);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\treturn [];\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["defaultOptions","injectFn","provideFn"],"mappings":";;;;AAWA;;AAEG;AACH,MAAMA,gBAAc,GAAwB;AAC3C,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,aAAa,EAAE,QAAQ;AACvB,IAAA,QAAQ,EAAE,MAAM;CAChB,CAAC;AAEF;;AAEG;AACH,MAAM,CAACC,UAAQ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