{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } it = o[Symbol.iterator](); return it.next.bind(it); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nimport _babelRuntimeHelpersEsmExtends from \"@babel/runtime/helpers/esm/extends\";\nimport { NumberFormatter } from \"@internationalized/number\";\nimport { MessageDictionary, MessageFormatter } from \"@internationalized/message\";\nimport { useIsSSR } from \"@react-aria/ssr\";\nimport _react, { useEffect, useState, useContext, useCallback, useMemo } from \"react\";\nvar $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nvar $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\nfunction $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) {\n  if (Intl.Locale) {\n    var script = new Intl.Locale(locale).maximize().script;\n    return $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS.has(script);\n  }\n\n  var lang = locale.split('-')[0];\n  return $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS.has(lang);\n}\n\nfunction $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale() {\n  var locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';\n  return {\n    locale: locale,\n    direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'\n  };\n}\n\nvar $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();\nvar $e851d0b81d46abd5f971c8e95c27f1$var$listeners = new Set();\n\nfunction $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale() {\n  $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();\n\n  for (var _iterator = _createForOfIteratorHelperLoose($e851d0b81d46abd5f971c8e95c27f1$var$listeners), _step; !(_step = _iterator()).done;) {\n    var listener = _step.value;\n    listener($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);\n  }\n}\n\nfunction $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale() {\n  var isSSR = useIsSSR();\n\n  var _useState = useState($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale),\n      _useState2 = _slicedToArray(_useState, 2),\n      defaultLocale = _useState2[0],\n      setDefaultLocale = _useState2[1];\n\n  useEffect(function () {\n    if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {\n      window.addEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);\n    }\n\n    $e851d0b81d46abd5f971c8e95c27f1$var$listeners.add(setDefaultLocale);\n    return function () {\n      $e851d0b81d46abd5f971c8e95c27f1$var$listeners.delete(setDefaultLocale);\n\n      if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {\n        window.removeEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);\n      }\n    };\n  }, []);\n\n  if (isSSR) {\n    return {\n      locale: 'en-US',\n      direction: 'ltr'\n    };\n  }\n\n  return defaultLocale;\n}\n\nvar $cff8541df3b5c83067b2ab3ee0d20$var$I18nContext = _react.createContext(null);\n\nexport function I18nProvider(props) {\n  var locale = props.locale,\n      children = props.children;\n  var defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();\n  var value = locale ? {\n    locale: locale,\n    direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'\n  } : defaultLocale;\n  return _react.createElement($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext.Provider, {\n    value: value\n  }, children);\n}\nexport function useLocale() {\n  var defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();\n  var context = useContext($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext);\n  return context || defaultLocale;\n}\nvar $f58d206cee90f9c2bf3c03e4522c35$var$cache = new WeakMap();\n\nfunction $f58d206cee90f9c2bf3c03e4522c35$var$getCachedDictionary(strings) {\n  var dictionary = $f58d206cee90f9c2bf3c03e4522c35$var$cache.get(strings);\n\n  if (!dictionary) {\n    dictionary = new MessageDictionary(strings);\n    $f58d206cee90f9c2bf3c03e4522c35$var$cache.set(strings, dictionary);\n  }\n\n  return dictionary;\n}\n\nexport function useMessageFormatter(strings) {\n  var _useLocale = useLocale(),\n      locale = _useLocale.locale;\n\n  var dictionary = useMemo(function () {\n    return $f58d206cee90f9c2bf3c03e4522c35$var$getCachedDictionary(strings);\n  }, [strings]);\n  var formatter = useMemo(function () {\n    return new MessageFormatter(locale, dictionary);\n  }, [locale, dictionary]);\n  return useCallback(function (key, variables) {\n    return formatter.format(key, variables);\n  }, [formatter]);\n}\nvar $b0007c63a64054c318efb8b6cd0053f$var$formatterCache = new Map();\nexport function useDateFormatter(options) {\n  var _useLocale2 = useLocale(),\n      locale = _useLocale2.locale;\n\n  if (options != null && options.calendar && !locale.includes('-u-ca-')) {\n    locale += '-u-ca-' + options.calendar;\n  }\n\n  var cacheKey = locale + (options ? Object.entries(options).sort(function (a, b) {\n    return a[0] < b[0] ? -1 : 1;\n  }).join() : '');\n\n  if ($b0007c63a64054c318efb8b6cd0053f$var$formatterCache.has(cacheKey)) {\n    return $b0007c63a64054c318efb8b6cd0053f$var$formatterCache.get(cacheKey);\n  }\n\n  var formatter = new Intl.DateTimeFormat(locale, options);\n  $b0007c63a64054c318efb8b6cd0053f$var$formatterCache.set(cacheKey, formatter);\n  return formatter;\n}\nexport function useNumberFormatter(options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  var _useLocale3 = useLocale(),\n      locale = _useLocale3.locale;\n\n  return useMemo(function () {\n    return new NumberFormatter(locale, options);\n  }, [locale, options]);\n}\nvar $a4045a18d7252bf6de9312e613c4e$var$cache = new Map();\nexport function useCollator(options) {\n  var _useLocale4 = useLocale(),\n      locale = _useLocale4.locale;\n\n  var cacheKey = locale + (options ? Object.entries(options).sort(function (a, b) {\n    return a[0] < b[0] ? -1 : 1;\n  }).join() : '');\n\n  if ($a4045a18d7252bf6de9312e613c4e$var$cache.has(cacheKey)) {\n    return $a4045a18d7252bf6de9312e613c4e$var$cache.get(cacheKey);\n  }\n\n  var formatter = new Intl.Collator(locale, options);\n  $a4045a18d7252bf6de9312e613c4e$var$cache.set(cacheKey, formatter);\n  return formatter;\n}\nexport function useFilter(options) {\n  var collator = useCollator(_babelRuntimeHelpersEsmExtends({\n    usage: 'search'\n  }, options));\n  return {\n    startsWith: function startsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(0, substring.length), substring) === 0;\n    },\n    endsWith: function endsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(-substring.length), substring) === 0;\n    },\n    contains: function contains(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      var scan = 0;\n      var sliceLen = substring.length;\n\n      for (; scan + sliceLen <= string.length; scan++) {\n        var slice = string.slice(scan, scan + sliceLen);\n\n        if (collator.compare(substring, slice) === 0) {\n          return true;\n        }\n      }\n\n      return false;\n    }\n  };\n}","map":{"version":3,"sources":["packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/useMessageFormatter.ts","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.ts"],"names":["RTL_SCRIPTS","RTL_LANGS","Intl","script","lang","locale","navigator","direction","currentLocale","getDefaultLocale","listeners","listener","isSSR","useIsSSR","useState","useEffect","window","I18nContext","React","children","defaultLocale","value","context","useContext","cache","dictionary","useMemo","getCachedDictionary","formatter","useCallback","formatterCache","options","cacheKey","Object","a","b","collator","usage","startsWith","substring","string","endsWith","contains","scan","sliceLen","slice"],"mappings":";;;;;;;;;;;;;AAaA,IAAMA,6CAAW,GAAG,IAAA,GAAA,CAAQ,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAA5B,MAA4B,CAAR,CAApB;AACA,IAAMC,2CAAS,GAAG,IAAA,GAAA,CAAQ,CAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EAAA,KAAA,EAAA,KAAA,EAAA,KAAA,EAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EA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A,SAAAA,CAAZA,KAAYA,CAAZA;AACA,aAAOH,QAAQ,CAARA,OAAAA,CAAiBI,MAAM,CAANA,KAAAA,CAAa,CAACD,SAAS,CAAxCH,MAAiBI,CAAjBJ,EAAAA,SAAAA,MAAP,CAAA;AAnBG,KAAA;AAqBLM,IAAAA,QArBK,oBAqBG,MArBH,EAqBG,SArBH,EAqBuB;AAC1B,UAAIH,SAAS,CAATA,MAAAA,KAAJ,CAAA,EAA4B;AAC1B,eAAA,IAAA;AACD;;AAEDC,MAAAA,MAAM,GAAGA,MAAM,CAANA,SAAAA,CAATA,KAASA,CAATA;AACAD,MAAAA,SAAS,GAAGA,SAAS,CAATA,SAAAA,CAAZA,KAAYA,CAAZA;AAEA,UAAII,IAAI,GAAR,CAAA;AACA,UAAIC,QAAQ,GAAGL,SAAS,CAAxB,MAAA;;AACA,aAAOI,IAAI,GAAJA,QAAAA,IAAmBH,MAAM,CAAhC,MAAA,EAAyCG,IAAzC,EAAA,EAAiD;AAC/C,YAAIE,KAAK,GAAGL,MAAM,CAANA,KAAAA,CAAAA,IAAAA,EAAmBG,IAAI,GAAnC,QAAYH,CAAZ;;AACA,YAAIJ,QAAQ,CAARA,OAAAA,CAAAA,SAAAA,EAAAA,KAAAA,MAAJ,CAAA,EAA8C;AAC5C,iBAAA,IAAA;AACD;AACF;;AAED,aAAA,KAAA;AACD;AAvCI,GAAP;AAyCD","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n  // If the Intl.Locale API is available, use it to get the script for the locale.\n  // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n  // @ts-ignore\n  if (Intl.Locale) {\n    // @ts-ignore\n    let script = new Intl.Locale(locale).maximize().script;\n    return RTL_SCRIPTS.has(script);\n  }\n\n  // If not, just guess by the language (first part of the locale)\n  let lang = locale.split('-')[0];\n  return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n  /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n  locale: string,\n  /** The writing direction for the locale. */\n  direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n  // @ts-ignore\n  let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n  return {\n    locale,\n    direction: isRTL(locale) ? 'rtl' : 'ltr'\n  };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n  currentLocale = getDefaultLocale();\n  for (let listener of listeners) {\n    listener(currentLocale);\n  }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n  let isSSR = useIsSSR();\n  let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n  useEffect(() => {\n    if (listeners.size === 0) {\n      window.addEventListener('languagechange', updateLocale);\n    }\n\n    listeners.add(setDefaultLocale);\n\n    return () => {\n      listeners.delete(setDefaultLocale);\n      if (listeners.size === 0) {\n        window.removeEventListener('languagechange', updateLocale);\n      }\n    };\n  }, []);\n\n  // We cannot determine the browser's language on the server, so default to\n  // en-US. This will be updated after hydration on the client to the correct value.\n  if (isSSR) {\n    return {\n      locale: 'en-US',\n      direction: 'ltr'\n    };\n  }\n\n  return defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\ninterface ProviderProps {\n  /** Contents that should have the locale applied. */\n  children: ReactNode,\n  /** The locale to apply to the children. */\n  locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: ProviderProps) {\n  let {locale, children} = props;\n  let defaultLocale = useDefaultLocale();\n\n  let value: Locale = locale ? {\n    locale,\n    direction: isRTL(locale) ? 'rtl' : 'ltr'\n  } : defaultLocale;\n\n  return (\n    <I18nContext.Provider value={value}>\n      {children}\n    </I18nContext.Provider>\n  );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n  let defaultLocale = useDefaultLocale();\n  let context = useContext(I18nContext);\n  return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {LocalizedStrings, MessageDictionary, MessageFormatter} from '@internationalized/message';\nimport {useCallback, useMemo} from 'react';\nimport {useLocale} from './context';\n\ntype FormatMessage = (key: string, variables?: {[key: string]: any}) => string;\n\nconst cache = new WeakMap();\nfunction getCachedDictionary(strings: LocalizedStrings) {\n  let dictionary = cache.get(strings);\n  if (!dictionary) {\n    dictionary = new MessageDictionary(strings);\n    cache.set(strings, dictionary);\n  }\n\n  return dictionary;\n}\n\n/**\n * Handles formatting ICU Message strings to create localized strings for the current locale.\n * Automatically updates when the locale changes, and handles caching of messages for performance.\n * @param strings - A mapping of languages to strings by key.\n */\nexport function useMessageFormatter(strings: LocalizedStrings): FormatMessage {\n  let {locale} = useLocale();\n  let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n  let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);\n  return useCallback((key, variables) => formatter.format(key, variables), [formatter]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\ninterface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n  calendar?: string\n}\n\nlet formatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): Intl.DateTimeFormat {\n  let {locale} = useLocale();\n\n  // Polyfill the `calendar` option - not supported in Safari.\n  if (options?.calendar && !locale.includes('-u-ca-')) {\n    locale += '-u-ca-' + options.calendar;\n  }\n\n  let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n  if (formatterCache.has(cacheKey)) {\n    return formatterCache.get(cacheKey);\n  }\n\n  let formatter = new Intl.DateTimeFormat(locale, options);\n  formatterCache.set(cacheKey, formatter);\n  return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n  let {locale} = useLocale();\n  return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n  let {locale} = useLocale();\n\n  let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n  if (cache.has(cacheKey)) {\n    return cache.get(cacheKey);\n  }\n\n  let formatter = new Intl.Collator(locale, options);\n  cache.set(cacheKey, formatter);\n  return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCollator} from './useCollator';\n\ninterface Filter {\n  /** Returns whether a string starts with a given substring. */\n  startsWith(string: string, substring: string): boolean,\n  /** Returns whether a string ends with a given substring. */\n  endsWith(string: string, substring: string): boolean,\n  /** Returns whether a string contains a given substring. */\n  contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n  let collator = useCollator({\n    usage: 'search',\n    ...options\n  });\n\n  // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n  return {\n    startsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      // Normalize both strings so we can slice safely\n      // TODO: take into account the ignorePunctuation option as well...\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(0, substring.length), substring) === 0;\n    },\n    endsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(-substring.length), substring) === 0;\n    },\n    contains(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n\n      let scan = 0;\n      let sliceLen = substring.length;\n      for (; scan + sliceLen <= string.length; scan++) {\n        let slice = string.slice(scan, scan + sliceLen);\n        if (collator.compare(substring, slice) === 0) {\n          return true;\n        }\n      }\n\n      return false;\n    }\n  };\n}\n"]},"metadata":{},"sourceType":"module"}