genesys-spark-components 4.203.0 → 4.204.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (482) hide show
  1. package/dist/cjs/{get-valid-timezone-B5cZ0d-f.js → get-valid-timezone-Dr_-VXi7.js} +1 -1
  2. package/dist/cjs/gux-accordion.cjs.entry.js +1 -1
  3. package/dist/cjs/gux-action-button.cjs.entry.js +2 -2
  4. package/dist/cjs/gux-action-toast-legacy.cjs.entry.js +1 -1
  5. package/dist/cjs/gux-actionable-inline-alert-beta.cjs.entry.js +1 -1
  6. package/dist/cjs/gux-advanced-dropdown-legacy.cjs.entry.js +2 -2
  7. package/dist/cjs/gux-ai-powered-badge-beta.cjs.entry.js +2 -2
  8. package/dist/cjs/gux-all-row-select.cjs.entry.js +1 -1
  9. package/dist/cjs/gux-announce-beta.cjs.entry.js +1 -1
  10. package/dist/cjs/gux-avatar-beta.cjs.entry.js +2 -2
  11. package/dist/cjs/gux-avatar-change-photo-beta.cjs.entry.js +2 -2
  12. package/dist/cjs/gux-avatar-group-add-item-beta_3.cjs.entry.js +2 -2
  13. package/dist/cjs/gux-avatar-group-beta.cjs.entry.js +1 -1
  14. package/dist/cjs/gux-avatar-group-item-beta.cjs.entry.js +1 -1
  15. package/dist/cjs/gux-badge.cjs.entry.js +2 -2
  16. package/dist/cjs/gux-blank-state-beta.cjs.entry.js +1 -1
  17. package/dist/cjs/gux-blank-state.cjs.entry.js +1 -1
  18. package/dist/cjs/gux-breadcrumbs.cjs.entry.js +2 -2
  19. package/dist/cjs/gux-button-multi.cjs.entry.js +1 -1
  20. package/dist/cjs/gux-button-slot.cjs.entry.js +1 -1
  21. package/dist/cjs/gux-button_2.cjs.entry.js +1 -1
  22. package/dist/cjs/gux-calendar-beta.cjs.entry.js +1 -1
  23. package/dist/cjs/gux-calendar.cjs.entry.js +3 -3
  24. package/dist/cjs/gux-card.cjs.entry.js +1 -1
  25. package/dist/cjs/gux-cloud-logo-beta.cjs.entry.js +2 -2
  26. package/dist/cjs/gux-cloud-logomark-beta.cjs.entry.js +2 -2
  27. package/dist/cjs/gux-column-manager-item.cjs.entry.js +1 -1
  28. package/dist/cjs/gux-column-manager.cjs.entry.js +2 -2
  29. package/dist/cjs/gux-content-search.cjs.entry.js +2 -2
  30. package/dist/cjs/gux-context-menu.cjs.entry.js +2 -2
  31. package/dist/cjs/gux-copy-to-clipboard.cjs.entry.js +2 -2
  32. package/dist/cjs/gux-create-option.cjs.entry.js +1 -1
  33. package/dist/cjs/gux-date-beta.cjs.entry.js +3 -3
  34. package/dist/cjs/gux-date-time-beta.cjs.entry.js +3 -3
  35. package/dist/cjs/gux-datepicker.cjs.entry.js +15 -12
  36. package/dist/cjs/gux-day-beta.cjs.entry.js +1 -1
  37. package/dist/cjs/gux-disclosure-button-legacy.cjs.entry.js +2 -2
  38. package/dist/cjs/gux-dismiss-button.cjs.entry.js +2 -2
  39. package/dist/cjs/gux-dropdown-multi-tag.cjs.entry.js +1 -1
  40. package/dist/cjs/gux-dropdown-multi.cjs.entry.js +2 -2
  41. package/dist/cjs/gux-dropdown_3.cjs.entry.js +2 -2
  42. package/dist/cjs/gux-file-list-item.cjs.entry.js +2 -2
  43. package/dist/cjs/gux-flag-icon-beta.cjs.entry.js +2 -2
  44. package/dist/cjs/gux-flyout-menu.cjs.entry.js +2 -2
  45. package/dist/cjs/gux-form-field-checkbox-group-beta.cjs.entry.js +2 -2
  46. package/dist/cjs/gux-form-field-checkbox.cjs.entry.js +1 -1
  47. package/dist/cjs/gux-form-field-color.cjs.entry.js +1 -1
  48. package/dist/cjs/gux-form-field-dropdown.cjs.entry.js +2 -2
  49. package/dist/cjs/gux-form-field-file-beta.cjs.entry.js +2 -2
  50. package/dist/cjs/gux-form-field-file.cjs.entry.js +1 -1
  51. package/dist/cjs/gux-form-field-input-clear-button.cjs.entry.js +2 -2
  52. package/dist/cjs/gux-form-field-label-indicator.cjs.entry.js +2 -2
  53. package/dist/cjs/gux-form-field-number_2.cjs.entry.js +2 -2
  54. package/dist/cjs/gux-form-field-phone.cjs.entry.js +2 -2
  55. package/dist/cjs/gux-form-field-radio-group-beta.cjs.entry.js +2 -2
  56. package/dist/cjs/gux-form-field-radio.cjs.entry.js +1 -1
  57. package/dist/cjs/gux-form-field-range.cjs.entry.js +1 -1
  58. package/dist/cjs/gux-form-field-search.cjs.entry.js +1 -1
  59. package/dist/cjs/gux-form-field-select.cjs.entry.js +1 -1
  60. package/dist/cjs/gux-form-field-text-like.cjs.entry.js +2 -2
  61. package/dist/cjs/gux-form-field-textarea.cjs.entry.js +1 -1
  62. package/dist/cjs/gux-form-field-time-picker.cjs.entry.js +2 -2
  63. package/dist/cjs/gux-form-field-time-zone-picker.cjs.entry.js +2 -2
  64. package/dist/cjs/gux-form-footer.cjs.entry.js +1 -1
  65. package/dist/cjs/gux-icon-tooltip-beta.cjs.entry.js +1 -1
  66. package/dist/cjs/gux-icon.cjs.entry.js +2 -2
  67. package/dist/cjs/gux-illustration-beta.cjs.entry.js +1 -1
  68. package/dist/cjs/gux-inline-alert.cjs.entry.js +2 -2
  69. package/dist/cjs/gux-inline-dropdown-beta.cjs.entry.js +2 -2
  70. package/dist/cjs/gux-label-info-beta.cjs.entry.js +1 -1
  71. package/dist/cjs/gux-link-beta.cjs.entry.js +1 -1
  72. package/dist/cjs/gux-list.cjs.entry.js +1 -1
  73. package/dist/cjs/gux-listbox-multi.cjs.entry.js +2 -2
  74. package/dist/cjs/gux-loading-message.cjs.entry.js +1 -1
  75. package/dist/cjs/gux-logo-beta.cjs.entry.js +2 -2
  76. package/dist/cjs/gux-logomark-beta.cjs.entry.js +2 -2
  77. package/dist/cjs/gux-modal-legacy.cjs.entry.js +1 -1
  78. package/dist/cjs/gux-modal-side-panel-beta.cjs.entry.js +1 -1
  79. package/dist/cjs/gux-modal.cjs.entry.js +1 -1
  80. package/dist/cjs/gux-month-calendar.cjs.entry.js +1 -1
  81. package/dist/cjs/gux-month-picker-beta.cjs.entry.js +2 -2
  82. package/dist/cjs/gux-notification-toast-legacy.cjs.entry.js +1 -1
  83. package/dist/cjs/gux-option-multi.cjs.entry.js +1 -1
  84. package/dist/cjs/gux-page-loading-spinner.cjs.entry.js +1 -1
  85. package/dist/cjs/gux-pagination-buttons-legacy_3.cjs.entry.js +1 -1
  86. package/dist/cjs/gux-pagination-buttons_2.cjs.entry.js +1 -1
  87. package/dist/cjs/gux-pagination-cursor.cjs.entry.js +2 -2
  88. package/dist/cjs/gux-pagination-items-per-page.cjs.entry.js +1 -1
  89. package/dist/cjs/gux-pagination-legacy.cjs.entry.js +1 -1
  90. package/dist/cjs/gux-pagination.cjs.entry.js +1 -1
  91. package/dist/cjs/gux-phone-input-beta.cjs.entry.js +173 -171
  92. package/dist/cjs/gux-popover-beta.cjs.entry.js +1 -1
  93. package/dist/cjs/gux-popover-list-beta.cjs.entry.js +1 -1
  94. package/dist/cjs/gux-popover-list.cjs.entry.js +1 -1
  95. package/dist/cjs/gux-prompt-input-beta.cjs.entry.js +2 -2
  96. package/dist/cjs/gux-radial-loading.cjs.entry.js +2 -2
  97. package/dist/cjs/gux-radial-progress.cjs.entry.js +1 -1
  98. package/dist/cjs/gux-rating.cjs.entry.js +2 -2
  99. package/dist/cjs/gux-rich-highlight-list-item.cjs.entry.js +2 -2
  100. package/dist/cjs/gux-rich-style-list-item_3.cjs.entry.js +2 -2
  101. package/dist/cjs/gux-rich-text-editor-action-link.cjs.entry.js +2 -2
  102. package/dist/cjs/gux-rich-text-editor-action-rich-style.cjs.entry.js +2 -2
  103. package/dist/cjs/gux-rich-text-editor-action-text-highlight.cjs.entry.js +2 -2
  104. package/dist/cjs/gux-rich-text-editor-action.cjs.entry.js +2 -2
  105. package/dist/cjs/gux-rich-text-editor-beta.cjs.entry.js +2 -2
  106. package/dist/cjs/gux-rich-text-editor-list.cjs.entry.js +1 -1
  107. package/dist/cjs/gux-row-select.cjs.entry.js +1 -1
  108. package/dist/cjs/gux-screen-reader-beta.cjs.entry.js +1 -1
  109. package/dist/cjs/gux-segmented-control-beta.cjs.entry.js +1 -1
  110. package/dist/cjs/gux-select-all.cjs.entry.js +1 -1
  111. package/dist/cjs/gux-selector-card-beta.cjs.entry.js +1 -1
  112. package/dist/cjs/gux-selector-cards-beta.cjs.entry.js +1 -1
  113. package/dist/cjs/gux-side-panel-beta.cjs.entry.js +1 -1
  114. package/dist/cjs/gux-side-panel-header.cjs.entry.js +1 -1
  115. package/dist/cjs/gux-side-panel-heading.cjs.entry.js +1 -1
  116. package/dist/cjs/gux-simple-toast-legacy.cjs.entry.js +1 -1
  117. package/dist/cjs/gux-skip-navigation-list.cjs.entry.js +2 -2
  118. package/dist/cjs/gux-sort-control.cjs.entry.js +2 -2
  119. package/dist/cjs/gux-status-indicator-beta.cjs.entry.js +1 -1
  120. package/dist/cjs/gux-step-title.cjs.entry.js +1 -1
  121. package/dist/cjs/gux-step.cjs.entry.js +1 -1
  122. package/dist/cjs/gux-stepper-beta.cjs.entry.js +1 -1
  123. package/dist/cjs/gux-switch-legacy.cjs.entry.js +1 -1
  124. package/dist/cjs/gux-tab-advanced-list.cjs.entry.js +1 -1
  125. package/dist/cjs/gux-tab-advanced.cjs.entry.js +1 -1
  126. package/dist/cjs/gux-tab-list.cjs.entry.js +1 -1
  127. package/dist/cjs/gux-table-select-menu.cjs.entry.js +1 -1
  128. package/dist/cjs/gux-table-toolbar-action.cjs.entry.js +2 -2
  129. package/dist/cjs/gux-table-toolbar-custom-action.cjs.entry.js +1 -1
  130. package/dist/cjs/gux-table-toolbar-menu-button.cjs.entry.js +2 -2
  131. package/dist/cjs/gux-table-toolbar.cjs.entry.js +1 -1
  132. package/dist/cjs/gux-table.cjs.entry.js +2 -2
  133. package/dist/cjs/gux-tabs-advanced.cjs.entry.js +1 -1
  134. package/dist/cjs/gux-tabs.cjs.entry.js +1 -1
  135. package/dist/cjs/gux-tag.cjs.entry.js +2 -2
  136. package/dist/cjs/gux-text-highlight.cjs.entry.js +1 -1
  137. package/dist/cjs/gux-time-beta.cjs.entry.js +3 -3
  138. package/dist/cjs/gux-time-picker.cjs.entry.js +2 -2
  139. package/dist/cjs/gux-time-zone-beta.cjs.entry.js +2 -2
  140. package/dist/cjs/gux-time-zone-picker-beta.cjs.entry.js +2 -2
  141. package/dist/cjs/gux-toast.cjs.entry.js +1 -1
  142. package/dist/cjs/gux-toggle.cjs.entry.js +2 -2
  143. package/dist/cjs/gux-tooltip-base-beta_2.cjs.entry.js +1 -1
  144. package/dist/cjs/gux-tooltip-pointer-beta.cjs.entry.js +1 -1
  145. package/dist/cjs/gux-tooltip_2.cjs.entry.js +1 -1
  146. package/dist/cjs/gux-tree-beta.cjs.entry.js +1 -1
  147. package/dist/cjs/gux-tree-multi-beta.cjs.entry.js +1 -1
  148. package/dist/cjs/index-DRg53_B7.js +3372 -0
  149. package/dist/cjs/{iso-dates-B-hZmvim.js → iso-dates-BOFf_iIt.js} +3 -0
  150. package/dist/cjs/{usage-GrpazmBt.js → usage-D4P0WJ6v.js} +1 -1
  151. package/dist/collection/components/beta/gux-calendar-beta/tests/tests.service.playwright.js +1 -1
  152. package/dist/collection/components/stable/gux-datepicker/gux-datepicker.js +12 -9
  153. package/dist/collection/components/stable/gux-icon/gux-icon.css +1 -2
  154. package/dist/collection/utils/date/iso-dates.js +3 -0
  155. package/dist/esm/{get-valid-timezone-rh51yAZx.js → get-valid-timezone-DIdb7fir.js} +1 -1
  156. package/dist/esm/gux-accordion.entry.js +1 -1
  157. package/dist/esm/gux-action-button.entry.js +2 -2
  158. package/dist/esm/gux-action-toast-legacy.entry.js +1 -1
  159. package/dist/esm/gux-actionable-inline-alert-beta.entry.js +1 -1
  160. package/dist/esm/gux-advanced-dropdown-legacy.entry.js +2 -2
  161. package/dist/esm/gux-ai-powered-badge-beta.entry.js +2 -2
  162. package/dist/esm/gux-all-row-select.entry.js +1 -1
  163. package/dist/esm/gux-announce-beta.entry.js +1 -1
  164. package/dist/esm/gux-avatar-beta.entry.js +2 -2
  165. package/dist/esm/gux-avatar-change-photo-beta.entry.js +2 -2
  166. package/dist/esm/gux-avatar-group-add-item-beta_3.entry.js +2 -2
  167. package/dist/esm/gux-avatar-group-beta.entry.js +1 -1
  168. package/dist/esm/gux-avatar-group-item-beta.entry.js +1 -1
  169. package/dist/esm/gux-badge.entry.js +2 -2
  170. package/dist/esm/gux-blank-state-beta.entry.js +1 -1
  171. package/dist/esm/gux-blank-state.entry.js +1 -1
  172. package/dist/esm/gux-breadcrumbs.entry.js +2 -2
  173. package/dist/esm/gux-button-multi.entry.js +1 -1
  174. package/dist/esm/gux-button-slot.entry.js +1 -1
  175. package/dist/esm/gux-button_2.entry.js +1 -1
  176. package/dist/esm/gux-calendar-beta.entry.js +1 -1
  177. package/dist/esm/gux-calendar.entry.js +3 -3
  178. package/dist/esm/gux-card.entry.js +1 -1
  179. package/dist/esm/gux-cloud-logo-beta.entry.js +2 -2
  180. package/dist/esm/gux-cloud-logomark-beta.entry.js +2 -2
  181. package/dist/esm/gux-column-manager-item.entry.js +1 -1
  182. package/dist/esm/gux-column-manager.entry.js +2 -2
  183. package/dist/esm/gux-content-search.entry.js +2 -2
  184. package/dist/esm/gux-context-menu.entry.js +2 -2
  185. package/dist/esm/gux-copy-to-clipboard.entry.js +2 -2
  186. package/dist/esm/gux-create-option.entry.js +1 -1
  187. package/dist/esm/gux-date-beta.entry.js +3 -3
  188. package/dist/esm/gux-date-time-beta.entry.js +3 -3
  189. package/dist/esm/gux-datepicker.entry.js +15 -12
  190. package/dist/esm/gux-day-beta.entry.js +1 -1
  191. package/dist/esm/gux-disclosure-button-legacy.entry.js +2 -2
  192. package/dist/esm/gux-dismiss-button.entry.js +2 -2
  193. package/dist/esm/gux-dropdown-multi-tag.entry.js +1 -1
  194. package/dist/esm/gux-dropdown-multi.entry.js +2 -2
  195. package/dist/esm/gux-dropdown_3.entry.js +2 -2
  196. package/dist/esm/gux-file-list-item.entry.js +2 -2
  197. package/dist/esm/gux-flag-icon-beta.entry.js +2 -2
  198. package/dist/esm/gux-flyout-menu.entry.js +2 -2
  199. package/dist/esm/gux-form-field-checkbox-group-beta.entry.js +2 -2
  200. package/dist/esm/gux-form-field-checkbox.entry.js +1 -1
  201. package/dist/esm/gux-form-field-color.entry.js +1 -1
  202. package/dist/esm/gux-form-field-dropdown.entry.js +2 -2
  203. package/dist/esm/gux-form-field-file-beta.entry.js +2 -2
  204. package/dist/esm/gux-form-field-file.entry.js +1 -1
  205. package/dist/esm/gux-form-field-input-clear-button.entry.js +2 -2
  206. package/dist/esm/gux-form-field-label-indicator.entry.js +2 -2
  207. package/dist/esm/gux-form-field-number_2.entry.js +2 -2
  208. package/dist/esm/gux-form-field-phone.entry.js +2 -2
  209. package/dist/esm/gux-form-field-radio-group-beta.entry.js +2 -2
  210. package/dist/esm/gux-form-field-radio.entry.js +1 -1
  211. package/dist/esm/gux-form-field-range.entry.js +1 -1
  212. package/dist/esm/gux-form-field-search.entry.js +1 -1
  213. package/dist/esm/gux-form-field-select.entry.js +1 -1
  214. package/dist/esm/gux-form-field-text-like.entry.js +2 -2
  215. package/dist/esm/gux-form-field-textarea.entry.js +1 -1
  216. package/dist/esm/gux-form-field-time-picker.entry.js +2 -2
  217. package/dist/esm/gux-form-field-time-zone-picker.entry.js +2 -2
  218. package/dist/esm/gux-form-footer.entry.js +1 -1
  219. package/dist/esm/gux-icon-tooltip-beta.entry.js +1 -1
  220. package/dist/esm/gux-icon.entry.js +2 -2
  221. package/dist/esm/gux-illustration-beta.entry.js +1 -1
  222. package/dist/esm/gux-inline-alert.entry.js +2 -2
  223. package/dist/esm/gux-inline-dropdown-beta.entry.js +2 -2
  224. package/dist/esm/gux-label-info-beta.entry.js +1 -1
  225. package/dist/esm/gux-link-beta.entry.js +1 -1
  226. package/dist/esm/gux-list.entry.js +1 -1
  227. package/dist/esm/gux-listbox-multi.entry.js +2 -2
  228. package/dist/esm/gux-loading-message.entry.js +1 -1
  229. package/dist/esm/gux-logo-beta.entry.js +2 -2
  230. package/dist/esm/gux-logomark-beta.entry.js +2 -2
  231. package/dist/esm/gux-modal-legacy.entry.js +1 -1
  232. package/dist/esm/gux-modal-side-panel-beta.entry.js +1 -1
  233. package/dist/esm/gux-modal.entry.js +1 -1
  234. package/dist/esm/gux-month-calendar.entry.js +1 -1
  235. package/dist/esm/gux-month-picker-beta.entry.js +2 -2
  236. package/dist/esm/gux-notification-toast-legacy.entry.js +1 -1
  237. package/dist/esm/gux-option-multi.entry.js +1 -1
  238. package/dist/esm/gux-page-loading-spinner.entry.js +1 -1
  239. package/dist/esm/gux-pagination-buttons-legacy_3.entry.js +1 -1
  240. package/dist/esm/gux-pagination-buttons_2.entry.js +1 -1
  241. package/dist/esm/gux-pagination-cursor.entry.js +2 -2
  242. package/dist/esm/gux-pagination-items-per-page.entry.js +1 -1
  243. package/dist/esm/gux-pagination-legacy.entry.js +1 -1
  244. package/dist/esm/gux-pagination.entry.js +1 -1
  245. package/dist/esm/gux-phone-input-beta.entry.js +173 -171
  246. package/dist/esm/gux-popover-beta.entry.js +1 -1
  247. package/dist/esm/gux-popover-list-beta.entry.js +1 -1
  248. package/dist/esm/gux-popover-list.entry.js +1 -1
  249. package/dist/esm/gux-prompt-input-beta.entry.js +2 -2
  250. package/dist/esm/gux-radial-loading.entry.js +2 -2
  251. package/dist/esm/gux-radial-progress.entry.js +1 -1
  252. package/dist/esm/gux-rating.entry.js +2 -2
  253. package/dist/esm/gux-rich-highlight-list-item.entry.js +2 -2
  254. package/dist/esm/gux-rich-style-list-item_3.entry.js +2 -2
  255. package/dist/esm/gux-rich-text-editor-action-link.entry.js +2 -2
  256. package/dist/esm/gux-rich-text-editor-action-rich-style.entry.js +2 -2
  257. package/dist/esm/gux-rich-text-editor-action-text-highlight.entry.js +2 -2
  258. package/dist/esm/gux-rich-text-editor-action.entry.js +2 -2
  259. package/dist/esm/gux-rich-text-editor-beta.entry.js +2 -2
  260. package/dist/esm/gux-rich-text-editor-list.entry.js +1 -1
  261. package/dist/esm/gux-row-select.entry.js +1 -1
  262. package/dist/esm/gux-screen-reader-beta.entry.js +1 -1
  263. package/dist/esm/gux-segmented-control-beta.entry.js +1 -1
  264. package/dist/esm/gux-select-all.entry.js +1 -1
  265. package/dist/esm/gux-selector-card-beta.entry.js +1 -1
  266. package/dist/esm/gux-selector-cards-beta.entry.js +1 -1
  267. package/dist/esm/gux-side-panel-beta.entry.js +1 -1
  268. package/dist/esm/gux-side-panel-header.entry.js +1 -1
  269. package/dist/esm/gux-side-panel-heading.entry.js +1 -1
  270. package/dist/esm/gux-simple-toast-legacy.entry.js +1 -1
  271. package/dist/esm/gux-skip-navigation-list.entry.js +2 -2
  272. package/dist/esm/gux-sort-control.entry.js +2 -2
  273. package/dist/esm/gux-status-indicator-beta.entry.js +1 -1
  274. package/dist/esm/gux-step-title.entry.js +1 -1
  275. package/dist/esm/gux-step.entry.js +1 -1
  276. package/dist/esm/gux-stepper-beta.entry.js +1 -1
  277. package/dist/esm/gux-switch-legacy.entry.js +1 -1
  278. package/dist/esm/gux-tab-advanced-list.entry.js +1 -1
  279. package/dist/esm/gux-tab-advanced.entry.js +1 -1
  280. package/dist/esm/gux-tab-list.entry.js +1 -1
  281. package/dist/esm/gux-table-select-menu.entry.js +1 -1
  282. package/dist/esm/gux-table-toolbar-action.entry.js +2 -2
  283. package/dist/esm/gux-table-toolbar-custom-action.entry.js +1 -1
  284. package/dist/esm/gux-table-toolbar-menu-button.entry.js +2 -2
  285. package/dist/esm/gux-table-toolbar.entry.js +1 -1
  286. package/dist/esm/gux-table.entry.js +2 -2
  287. package/dist/esm/gux-tabs-advanced.entry.js +1 -1
  288. package/dist/esm/gux-tabs.entry.js +1 -1
  289. package/dist/esm/gux-tag.entry.js +2 -2
  290. package/dist/esm/gux-text-highlight.entry.js +1 -1
  291. package/dist/esm/gux-time-beta.entry.js +3 -3
  292. package/dist/esm/gux-time-picker.entry.js +2 -2
  293. package/dist/esm/gux-time-zone-beta.entry.js +2 -2
  294. package/dist/esm/gux-time-zone-picker-beta.entry.js +2 -2
  295. package/dist/esm/gux-toast.entry.js +1 -1
  296. package/dist/esm/gux-toggle.entry.js +2 -2
  297. package/dist/esm/gux-tooltip-base-beta_2.entry.js +1 -1
  298. package/dist/esm/gux-tooltip-pointer-beta.entry.js +1 -1
  299. package/dist/esm/gux-tooltip_2.entry.js +1 -1
  300. package/dist/esm/gux-tree-beta.entry.js +1 -1
  301. package/dist/esm/gux-tree-multi-beta.entry.js +1 -1
  302. package/dist/esm/index-ChoMleW_.js +3366 -0
  303. package/dist/esm/{iso-dates-aKaDsw_5.js → iso-dates-BFybQmZw.js} +3 -0
  304. package/dist/esm/{usage-CYZSsQYc.js → usage-BJX1jP8P.js} +1 -1
  305. package/dist/genesys-webcomponents/genesys-webcomponents.esm.js +1 -1
  306. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.ar.json +1 -1
  307. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.da.json +1 -1
  308. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.es-es.json +1 -1
  309. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.es.json +1 -1
  310. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.fi.json +1 -1
  311. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.ja.json +1 -1
  312. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.ko.json +1 -1
  313. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.nl.json +1 -1
  314. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.pt-br.json +1 -1
  315. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.ru.json +1 -1
  316. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.sv.json +1 -1
  317. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.th.json +1 -1
  318. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.uk.json +1 -1
  319. package/dist/genesys-webcomponents/i18n/genesys-webcomponents.i18n.zh-cn.json +1 -1
  320. package/dist/genesys-webcomponents/{p-eda82225.entry.js → p-00b6b549.entry.js} +1 -1
  321. package/dist/genesys-webcomponents/{p-8595df72.entry.js → p-015756d9.entry.js} +1 -1
  322. package/dist/genesys-webcomponents/{p-d8d1b6db.entry.js → p-029ceda7.entry.js} +1 -1
  323. package/dist/genesys-webcomponents/{p-8f29fb00.entry.js → p-02cdb13e.entry.js} +1 -1
  324. package/dist/genesys-webcomponents/{p-e24b725f.entry.js → p-05157b56.entry.js} +1 -1
  325. package/dist/genesys-webcomponents/{p-931b24c4.entry.js → p-052c800a.entry.js} +1 -1
  326. package/dist/genesys-webcomponents/p-087ec88e.entry.js +1 -0
  327. package/dist/genesys-webcomponents/{p-ddd7362d.entry.js → p-09220774.entry.js} +1 -1
  328. package/dist/genesys-webcomponents/p-0a094594.entry.js +1 -0
  329. package/dist/genesys-webcomponents/{p-01acdf70.entry.js → p-0fb11edf.entry.js} +1 -1
  330. package/dist/genesys-webcomponents/{p-4c966844.entry.js → p-13c99e2f.entry.js} +1 -1
  331. package/dist/genesys-webcomponents/{p-66c9b0d0.entry.js → p-15ca8693.entry.js} +1 -1
  332. package/dist/genesys-webcomponents/{p-fe5a1f14.entry.js → p-17014484.entry.js} +1 -1
  333. package/dist/genesys-webcomponents/{p-17a45dbe.entry.js → p-1814ba1a.entry.js} +1 -1
  334. package/dist/genesys-webcomponents/{p-150dda1b.entry.js → p-18e166ec.entry.js} +1 -1
  335. package/dist/genesys-webcomponents/{p-32991d30.entry.js → p-1bf6a162.entry.js} +1 -1
  336. package/dist/genesys-webcomponents/{p-e4208622.entry.js → p-1c01fba6.entry.js} +1 -1
  337. package/dist/genesys-webcomponents/{p-3de4faad.entry.js → p-1faaddc6.entry.js} +1 -1
  338. package/dist/genesys-webcomponents/{p-16940c56.entry.js → p-208a7b8c.entry.js} +1 -1
  339. package/dist/genesys-webcomponents/{p-1cd43bcd.entry.js → p-24a8060c.entry.js} +1 -1
  340. package/dist/genesys-webcomponents/{p-8b1ec4b4.entry.js → p-24da0e5e.entry.js} +1 -1
  341. package/dist/genesys-webcomponents/{p-592f2225.entry.js → p-24fec568.entry.js} +1 -1
  342. package/dist/genesys-webcomponents/{p-f9e43e59.entry.js → p-2596e74c.entry.js} +1 -1
  343. package/dist/genesys-webcomponents/{p-55bb8071.entry.js → p-29801d89.entry.js} +1 -1
  344. package/dist/genesys-webcomponents/{p-67f7bdf0.entry.js → p-2a1e81bc.entry.js} +1 -1
  345. package/dist/genesys-webcomponents/{p-b9d36907.entry.js → p-2d219353.entry.js} +1 -1
  346. package/dist/genesys-webcomponents/{p-4b1a4e58.entry.js → p-305f1f65.entry.js} +1 -1
  347. package/dist/genesys-webcomponents/{p-d057a751.entry.js → p-308b7568.entry.js} +1 -1
  348. package/dist/genesys-webcomponents/{p-2a801ea9.entry.js → p-3098f337.entry.js} +1 -1
  349. package/dist/genesys-webcomponents/{p-77265307.entry.js → p-30d43160.entry.js} +1 -1
  350. package/dist/genesys-webcomponents/{p-dcd1882b.entry.js → p-3142356f.entry.js} +1 -1
  351. package/dist/genesys-webcomponents/{p-ed4d78bc.entry.js → p-323abf43.entry.js} +1 -1
  352. package/dist/genesys-webcomponents/{p-801d79b5.entry.js → p-33ecf7bd.entry.js} +1 -1
  353. package/dist/genesys-webcomponents/{p-67ffdd06.entry.js → p-35acfa86.entry.js} +1 -1
  354. package/dist/genesys-webcomponents/{p-11a4a6ef.entry.js → p-36996781.entry.js} +1 -1
  355. package/dist/genesys-webcomponents/{p-4f62813b.entry.js → p-38d44fd2.entry.js} +1 -1
  356. package/dist/genesys-webcomponents/{p-99299d25.entry.js → p-395329cf.entry.js} +1 -1
  357. package/dist/genesys-webcomponents/{p-83014c33.entry.js → p-3a826875.entry.js} +1 -1
  358. package/dist/genesys-webcomponents/{p-40068451.entry.js → p-3ab52659.entry.js} +1 -1
  359. package/dist/genesys-webcomponents/{p-573cb83a.entry.js → p-3d638b05.entry.js} +1 -1
  360. package/dist/genesys-webcomponents/p-3e37ff1f.entry.js +1 -0
  361. package/dist/genesys-webcomponents/{p-ae7b7bda.entry.js → p-3f6e1f1c.entry.js} +1 -1
  362. package/dist/genesys-webcomponents/{p-00531df5.entry.js → p-3fdf0607.entry.js} +1 -1
  363. package/dist/genesys-webcomponents/{p-e2a8084e.entry.js → p-45656682.entry.js} +1 -1
  364. package/dist/genesys-webcomponents/{p-ed78de36.entry.js → p-471bfa55.entry.js} +1 -1
  365. package/dist/genesys-webcomponents/{p-8aeb2c01.entry.js → p-476b2052.entry.js} +1 -1
  366. package/dist/genesys-webcomponents/{p-ac558ad8.entry.js → p-47f84787.entry.js} +1 -1
  367. package/dist/genesys-webcomponents/{p-8a533da1.entry.js → p-4ce8fbc8.entry.js} +1 -1
  368. package/dist/genesys-webcomponents/{p-84c99152.entry.js → p-4d202156.entry.js} +1 -1
  369. package/dist/genesys-webcomponents/{p-f44e0aaf.entry.js → p-52541fce.entry.js} +1 -1
  370. package/dist/genesys-webcomponents/{p-7e122f43.entry.js → p-532f5101.entry.js} +1 -1
  371. package/dist/genesys-webcomponents/{p-a8fb48d5.entry.js → p-538798e4.entry.js} +1 -1
  372. package/dist/genesys-webcomponents/{p-d771bfca.entry.js → p-54c664c9.entry.js} +1 -1
  373. package/dist/genesys-webcomponents/{p-7ef51b7d.entry.js → p-5932e0c1.entry.js} +1 -1
  374. package/dist/genesys-webcomponents/{p-a69cce2b.entry.js → p-5965a868.entry.js} +1 -1
  375. package/dist/genesys-webcomponents/{p-56c66f0d.entry.js → p-5ac20467.entry.js} +1 -1
  376. package/dist/genesys-webcomponents/{p-9cce8f5a.entry.js → p-5f544839.entry.js} +1 -1
  377. package/dist/genesys-webcomponents/{p-85c4cd01.entry.js → p-674c7d0c.entry.js} +1 -1
  378. package/dist/genesys-webcomponents/{p-0f0d8d5d.entry.js → p-69412348.entry.js} +1 -1
  379. package/dist/genesys-webcomponents/{p-6ff72393.entry.js → p-6bdceed9.entry.js} +1 -1
  380. package/dist/genesys-webcomponents/{p-9a79b58d.entry.js → p-6cca4881.entry.js} +1 -1
  381. package/dist/genesys-webcomponents/{p-71a63e54.entry.js → p-6fa72a72.entry.js} +1 -1
  382. package/dist/genesys-webcomponents/{p-2e742607.entry.js → p-6fe0db93.entry.js} +1 -1
  383. package/dist/genesys-webcomponents/{p-bab515b9.entry.js → p-70fb9b3c.entry.js} +1 -1
  384. package/dist/genesys-webcomponents/{p-d1a7f402.entry.js → p-71a9054c.entry.js} +1 -1
  385. package/dist/genesys-webcomponents/{p-dfe507e8.entry.js → p-72b6fa90.entry.js} +1 -1
  386. package/dist/genesys-webcomponents/{p-7df39689.entry.js → p-74d74b0a.entry.js} +1 -1
  387. package/dist/genesys-webcomponents/{p-48926e3d.entry.js → p-751d9ed3.entry.js} +2 -2
  388. package/dist/genesys-webcomponents/{p-a7c37eab.entry.js → p-7537d923.entry.js} +1 -1
  389. package/dist/genesys-webcomponents/{p-f0478e6e.entry.js → p-75aa126c.entry.js} +1 -1
  390. package/dist/genesys-webcomponents/{p-23d2d73b.entry.js → p-82bd4b31.entry.js} +1 -1
  391. package/dist/genesys-webcomponents/{p-10f9ef52.entry.js → p-84d1c531.entry.js} +1 -1
  392. package/dist/genesys-webcomponents/{p-7ccc09fb.entry.js → p-86d8a706.entry.js} +1 -1
  393. package/dist/genesys-webcomponents/{p-58f9da5c.entry.js → p-87717cac.entry.js} +1 -1
  394. package/dist/genesys-webcomponents/{p-e1e30fcb.entry.js → p-879ee390.entry.js} +1 -1
  395. package/dist/genesys-webcomponents/{p-24b6f102.entry.js → p-87f84d44.entry.js} +1 -1
  396. package/dist/genesys-webcomponents/{p-e321e392.entry.js → p-89e226e8.entry.js} +1 -1
  397. package/dist/genesys-webcomponents/{p-e67865a1.entry.js → p-8aae6e1b.entry.js} +1 -1
  398. package/dist/genesys-webcomponents/{p-19ae0df0.entry.js → p-8cd048c5.entry.js} +1 -1
  399. package/dist/genesys-webcomponents/{p-40e8150c.entry.js → p-8d6fe6e1.entry.js} +1 -1
  400. package/dist/genesys-webcomponents/{p-9f9e1e6f.entry.js → p-8edabc20.entry.js} +1 -1
  401. package/dist/genesys-webcomponents/{p-cf9a2833.entry.js → p-93249f0f.entry.js} +1 -1
  402. package/dist/genesys-webcomponents/{p-bafe648a.entry.js → p-95c9469b.entry.js} +1 -1
  403. package/dist/genesys-webcomponents/{p-913ab88b.entry.js → p-9744bbcd.entry.js} +1 -1
  404. package/dist/genesys-webcomponents/{p-64bdfffa.entry.js → p-98109a06.entry.js} +1 -1
  405. package/dist/genesys-webcomponents/{p-2c0169ec.entry.js → p-9867f5b0.entry.js} +1 -1
  406. package/dist/genesys-webcomponents/p-9a8cf271.entry.js +1 -0
  407. package/dist/genesys-webcomponents/{p-37a4d70d.entry.js → p-9cfa2e74.entry.js} +1 -1
  408. package/dist/genesys-webcomponents/{p-f9fa3200.entry.js → p-9d76b7d4.entry.js} +1 -1
  409. package/dist/genesys-webcomponents/{p-8afc5a3d.entry.js → p-9e7d3ee9.entry.js} +1 -1
  410. package/dist/genesys-webcomponents/{p-603bcd25.entry.js → p-9eee14c9.entry.js} +1 -1
  411. package/dist/genesys-webcomponents/{p-554dbbe1.entry.js → p-9f43092a.entry.js} +1 -1
  412. package/dist/genesys-webcomponents/p-BFybQmZw.js +1 -0
  413. package/dist/genesys-webcomponents/{p-CYZSsQYc.js → p-BJX1jP8P.js} +1 -1
  414. package/dist/genesys-webcomponents/{p-BvsD2Jrx.js → p-C1OLX65e.js} +1 -1
  415. package/dist/genesys-webcomponents/p-DyLWs74h.js +1 -0
  416. package/dist/genesys-webcomponents/{p-9dbbdaa6.entry.js → p-a1f4ee28.entry.js} +1 -1
  417. package/dist/genesys-webcomponents/{p-6ac8394d.entry.js → p-a3b6a5f4.entry.js} +1 -1
  418. package/dist/genesys-webcomponents/p-a3e570b0.entry.js +1 -0
  419. package/dist/genesys-webcomponents/{p-1db598fc.entry.js → p-a4788c1d.entry.js} +1 -1
  420. package/dist/genesys-webcomponents/{p-8653db1a.entry.js → p-a5385c5f.entry.js} +1 -1
  421. package/dist/genesys-webcomponents/{p-77528c82.entry.js → p-a65b14f2.entry.js} +1 -1
  422. package/dist/genesys-webcomponents/{p-8ac99306.entry.js → p-a9e0a048.entry.js} +1 -1
  423. package/dist/genesys-webcomponents/{p-77fa550d.entry.js → p-ab0bd3aa.entry.js} +1 -1
  424. package/dist/genesys-webcomponents/{p-4b496a5e.entry.js → p-ac82162e.entry.js} +1 -1
  425. package/dist/genesys-webcomponents/{p-36e360c1.entry.js → p-b20b9779.entry.js} +1 -1
  426. package/dist/genesys-webcomponents/{p-13b0d7d1.entry.js → p-b25eb49f.entry.js} +1 -1
  427. package/dist/genesys-webcomponents/{p-ed33d483.entry.js → p-b4b76262.entry.js} +1 -1
  428. package/dist/genesys-webcomponents/{p-25b01b19.entry.js → p-b5fb334b.entry.js} +1 -1
  429. package/dist/genesys-webcomponents/{p-a8a46b95.entry.js → p-b749688d.entry.js} +1 -1
  430. package/dist/genesys-webcomponents/{p-8b620273.entry.js → p-b77918a0.entry.js} +1 -1
  431. package/dist/genesys-webcomponents/{p-d1b6b001.entry.js → p-b77b650c.entry.js} +1 -1
  432. package/dist/genesys-webcomponents/{p-a5a8e89a.entry.js → p-ba41e5d2.entry.js} +1 -1
  433. package/dist/genesys-webcomponents/{p-4a5d7c92.entry.js → p-bd35bf72.entry.js} +1 -1
  434. package/dist/genesys-webcomponents/{p-f0dfc482.entry.js → p-c07ab9eb.entry.js} +1 -1
  435. package/dist/genesys-webcomponents/{p-40bdc6cf.entry.js → p-c083c960.entry.js} +1 -1
  436. package/dist/genesys-webcomponents/{p-5edbab02.entry.js → p-c0a79e8d.entry.js} +1 -1
  437. package/dist/genesys-webcomponents/{p-40e67591.entry.js → p-c4896269.entry.js} +1 -1
  438. package/dist/genesys-webcomponents/{p-f9ba7265.entry.js → p-c60a0743.entry.js} +1 -1
  439. package/dist/genesys-webcomponents/{p-7e943541.entry.js → p-c629b283.entry.js} +1 -1
  440. package/dist/genesys-webcomponents/{p-56367f4c.entry.js → p-c91c7adc.entry.js} +1 -1
  441. package/dist/genesys-webcomponents/{p-edbe4ba0.entry.js → p-ca3bfaac.entry.js} +1 -1
  442. package/dist/genesys-webcomponents/{p-b463bdd3.entry.js → p-cb31dea7.entry.js} +1 -1
  443. package/dist/genesys-webcomponents/{p-2cc4e28d.entry.js → p-d5de16e1.entry.js} +1 -1
  444. package/dist/genesys-webcomponents/{p-ad9a18c7.entry.js → p-d868dbb5.entry.js} +1 -1
  445. package/dist/genesys-webcomponents/{p-dad46386.entry.js → p-d87799ad.entry.js} +1 -1
  446. package/dist/genesys-webcomponents/{p-500841cb.entry.js → p-d97c6402.entry.js} +1 -1
  447. package/dist/genesys-webcomponents/{p-0ac44e50.entry.js → p-da89d324.entry.js} +1 -1
  448. package/dist/genesys-webcomponents/{p-e908936f.entry.js → p-db52a0eb.entry.js} +1 -1
  449. package/dist/genesys-webcomponents/{p-f38d7610.entry.js → p-defa1a7d.entry.js} +1 -1
  450. package/dist/genesys-webcomponents/{p-f66adf01.entry.js → p-e0696252.entry.js} +1 -1
  451. package/dist/genesys-webcomponents/{p-485629ba.entry.js → p-e2c1853d.entry.js} +1 -1
  452. package/dist/genesys-webcomponents/{p-9e7fe47a.entry.js → p-e52833b2.entry.js} +1 -1
  453. package/dist/genesys-webcomponents/{p-984cbfe9.entry.js → p-e6a0b0a6.entry.js} +1 -1
  454. package/dist/genesys-webcomponents/{p-dd7741ca.entry.js → p-e9a2985b.entry.js} +1 -1
  455. package/dist/genesys-webcomponents/{p-b78c93da.entry.js → p-f15957e2.entry.js} +1 -1
  456. package/dist/genesys-webcomponents/{p-29222289.entry.js → p-f2bb6dac.entry.js} +1 -1
  457. package/dist/genesys-webcomponents/{p-81ddab63.entry.js → p-f475a40b.entry.js} +1 -1
  458. package/dist/genesys-webcomponents/{p-4fc4f932.entry.js → p-f4b919f5.entry.js} +1 -1
  459. package/dist/genesys-webcomponents/{p-4af7ac28.entry.js → p-f52f163b.entry.js} +1 -1
  460. package/dist/genesys-webcomponents/{p-d7aa420d.entry.js → p-f7e612aa.entry.js} +1 -1
  461. package/dist/genesys-webcomponents/{p-86a3bdd6.entry.js → p-f9d537a3.entry.js} +1 -1
  462. package/dist/genesys-webcomponents/{p-b091152c.entry.js → p-fa6bd708.entry.js} +1 -1
  463. package/dist/genesys-webcomponents/{p-feedb61e.entry.js → p-faaf93da.entry.js} +1 -1
  464. package/dist/genesys-webcomponents/{p-4e05cb3a.entry.js → p-fbbce3cb.entry.js} +1 -1
  465. package/dist/genesys-webcomponents/{p-e2fc68a6.entry.js → p-fbed7ee9.entry.js} +1 -1
  466. package/dist/genesys-webcomponents/{p-5155b824.entry.js → p-fd44ee1b.entry.js} +1 -1
  467. package/dist/genesys-webcomponents/{p-4f402fad.entry.js → p-fd7a9f36.entry.js} +1 -1
  468. package/dist/genesys-webcomponents/{p-b1fb20d7.entry.js → p-fde2d393.entry.js} +1 -1
  469. package/dist/genesys-webcomponents/{p-a658bc21.entry.js → p-fe915258.entry.js} +1 -1
  470. package/dist/stencil-wrapper.js +1 -1
  471. package/dist/types/components/stable/gux-datepicker/gux-datepicker.d.ts +1 -0
  472. package/dist/types/stencil-wrapper.d.ts +1 -1
  473. package/package.json +5 -5
  474. package/dist/cjs/index-D7ufkS4M.js +0 -4194
  475. package/dist/esm/index-HMDSHwTB.js +0 -4188
  476. package/dist/genesys-webcomponents/p-08aa9a17.entry.js +0 -1
  477. package/dist/genesys-webcomponents/p-0f9b2e05.entry.js +0 -1
  478. package/dist/genesys-webcomponents/p-11c7b49a.entry.js +0 -1
  479. package/dist/genesys-webcomponents/p-DnzIYzsz.js +0 -1
  480. package/dist/genesys-webcomponents/p-aKaDsw_5.js +0 -1
  481. package/dist/genesys-webcomponents/p-d061b1f4.entry.js +0 -1
  482. package/dist/genesys-webcomponents/p-deb3b990.entry.js +0 -1
@@ -1,4194 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-WrzJncgo.js');
4
- var getClosestElement = require('./get-closest-element-CfyZl7i7.js');
5
-
6
- /******************************************************************************
7
- Copyright (c) Microsoft Corporation.
8
-
9
- Permission to use, copy, modify, and/or distribute this software for any
10
- purpose with or without fee is hereby granted.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
- PERFORMANCE OF THIS SOFTWARE.
19
- ***************************************************************************** */
20
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
-
22
- var extendStatics = function(d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
26
- return extendStatics(d, b);
27
- };
28
-
29
- function __extends(d, b) {
30
- if (typeof b !== "function" && b !== null)
31
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
32
- extendStatics(d, b);
33
- function __() { this.constructor = d; }
34
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35
- }
36
-
37
- var __assign = function() {
38
- __assign = Object.assign || function __assign(t) {
39
- for (var s, i = 1, n = arguments.length; i < n; i++) {
40
- s = arguments[i];
41
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
42
- }
43
- return t;
44
- };
45
- return __assign.apply(this, arguments);
46
- };
47
-
48
- function __rest(s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- }
59
-
60
- function __spreadArray(to, from, pack) {
61
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62
- if (ar || !(i in from)) {
63
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
64
- ar[i] = from[i];
65
- }
66
- }
67
- return to.concat(ar || Array.prototype.slice.call(from));
68
- }
69
-
70
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
71
- var e = new Error(message);
72
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
73
- };
74
-
75
- //
76
- // Main
77
- //
78
- function memoize(fn, options) {
79
- var cache = options && options.cache ? options.cache : cacheDefault;
80
- var serializer = options && options.serializer ? options.serializer : serializerDefault;
81
- var strategy = options && options.strategy ? options.strategy : strategyDefault;
82
- return strategy(fn, {
83
- cache: cache,
84
- serializer: serializer,
85
- });
86
- }
87
- //
88
- // Strategy
89
- //
90
- function isPrimitive(value) {
91
- return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs
92
- }
93
- function monadic(fn, cache, serializer, arg) {
94
- var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
95
- var computedValue = cache.get(cacheKey);
96
- if (typeof computedValue === 'undefined') {
97
- computedValue = fn.call(this, arg);
98
- cache.set(cacheKey, computedValue);
99
- }
100
- return computedValue;
101
- }
102
- function variadic(fn, cache, serializer) {
103
- var args = Array.prototype.slice.call(arguments, 3);
104
- var cacheKey = serializer(args);
105
- var computedValue = cache.get(cacheKey);
106
- if (typeof computedValue === 'undefined') {
107
- computedValue = fn.apply(this, args);
108
- cache.set(cacheKey, computedValue);
109
- }
110
- return computedValue;
111
- }
112
- function assemble(fn, context, strategy, cache, serialize) {
113
- return strategy.bind(context, fn, cache, serialize);
114
- }
115
- function strategyDefault(fn, options) {
116
- var strategy = fn.length === 1 ? monadic : variadic;
117
- return assemble(fn, this, strategy, options.cache.create(), options.serializer);
118
- }
119
- function strategyVariadic(fn, options) {
120
- return assemble(fn, this, variadic, options.cache.create(), options.serializer);
121
- }
122
- //
123
- // Serializer
124
- //
125
- var serializerDefault = function () {
126
- return JSON.stringify(arguments);
127
- };
128
- //
129
- // Cache
130
- //
131
- var ObjectWithoutPrototypeCache = /** @class */ (function () {
132
- function ObjectWithoutPrototypeCache() {
133
- this.cache = Object.create(null);
134
- }
135
- ObjectWithoutPrototypeCache.prototype.get = function (key) {
136
- return this.cache[key];
137
- };
138
- ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
139
- this.cache[key] = value;
140
- };
141
- return ObjectWithoutPrototypeCache;
142
- }());
143
- var cacheDefault = {
144
- create: function create() {
145
- return new ObjectWithoutPrototypeCache();
146
- },
147
- };
148
- var strategies = {
149
- variadic: strategyVariadic};
150
-
151
- var ErrorKind;
152
- (function (ErrorKind) {
153
- /** Argument is unclosed (e.g. `{0`) */
154
- ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
155
- /** Argument is empty (e.g. `{}`). */
156
- ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
157
- /** Argument is malformed (e.g. `{foo!}``) */
158
- ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
159
- /** Expect an argument type (e.g. `{foo,}`) */
160
- ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
161
- /** Unsupported argument type (e.g. `{foo,foo}`) */
162
- ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
163
- /** Expect an argument style (e.g. `{foo, number, }`) */
164
- ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
165
- /** The number skeleton is invalid. */
166
- ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
167
- /** The date time skeleton is invalid. */
168
- ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
169
- /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
170
- ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
171
- /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
172
- ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
173
- /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
174
- ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
175
- /** Missing select argument options (e.g. `{foo, select}`) */
176
- ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
177
- /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
178
- ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
179
- /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
180
- ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
181
- /** Expecting a selector in `select` argument (e.g `{foo, select}`) */
182
- ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
183
- /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
184
- ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
185
- /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
186
- ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
187
- /**
188
- * Expecting a message fragment after the `plural` or `selectordinal` selector
189
- * (e.g. `{foo, plural, one}`)
190
- */
191
- ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
192
- /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
193
- ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
194
- /**
195
- * Duplicate selectors in `plural` or `selectordinal` argument.
196
- * (e.g. {foo, plural, one {#} one {#}})
197
- */
198
- ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
199
- /** Duplicate selectors in `select` argument.
200
- * (e.g. {foo, select, apple {apple} apple {apple}})
201
- */
202
- ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
203
- /** Plural or select argument option must have `other` clause. */
204
- ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
205
- /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
206
- ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
207
- /** The tag name is invalid. (e.g. `<123>foo</123>`) */
208
- ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
209
- /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
210
- ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
211
- /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
212
- ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
213
- })(ErrorKind || (ErrorKind = {}));
214
-
215
- var TYPE;
216
- (function (TYPE) {
217
- /**
218
- * Raw text
219
- */
220
- TYPE[TYPE["literal"] = 0] = "literal";
221
- /**
222
- * Variable w/o any format, e.g `var` in `this is a {var}`
223
- */
224
- TYPE[TYPE["argument"] = 1] = "argument";
225
- /**
226
- * Variable w/ number format
227
- */
228
- TYPE[TYPE["number"] = 2] = "number";
229
- /**
230
- * Variable w/ date format
231
- */
232
- TYPE[TYPE["date"] = 3] = "date";
233
- /**
234
- * Variable w/ time format
235
- */
236
- TYPE[TYPE["time"] = 4] = "time";
237
- /**
238
- * Variable w/ select format
239
- */
240
- TYPE[TYPE["select"] = 5] = "select";
241
- /**
242
- * Variable w/ plural format
243
- */
244
- TYPE[TYPE["plural"] = 6] = "plural";
245
- /**
246
- * Only possible within plural argument.
247
- * This is the `#` symbol that will be substituted with the count.
248
- */
249
- TYPE[TYPE["pound"] = 7] = "pound";
250
- /**
251
- * XML-like tag
252
- */
253
- TYPE[TYPE["tag"] = 8] = "tag";
254
- })(TYPE || (TYPE = {}));
255
- var SKELETON_TYPE;
256
- (function (SKELETON_TYPE) {
257
- SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
258
- SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
259
- })(SKELETON_TYPE || (SKELETON_TYPE = {}));
260
- /**
261
- * Type Guards
262
- */
263
- function isLiteralElement(el) {
264
- return el.type === TYPE.literal;
265
- }
266
- function isArgumentElement(el) {
267
- return el.type === TYPE.argument;
268
- }
269
- function isNumberElement(el) {
270
- return el.type === TYPE.number;
271
- }
272
- function isDateElement(el) {
273
- return el.type === TYPE.date;
274
- }
275
- function isTimeElement(el) {
276
- return el.type === TYPE.time;
277
- }
278
- function isSelectElement(el) {
279
- return el.type === TYPE.select;
280
- }
281
- function isPluralElement(el) {
282
- return el.type === TYPE.plural;
283
- }
284
- function isPoundElement(el) {
285
- return el.type === TYPE.pound;
286
- }
287
- function isTagElement(el) {
288
- return el.type === TYPE.tag;
289
- }
290
- function isNumberSkeleton(el) {
291
- return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
292
- }
293
- function isDateTimeSkeleton(el) {
294
- return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
295
- }
296
-
297
- // @generated from regex-gen.ts
298
- var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
299
-
300
- /**
301
- * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
302
- * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
303
- * with some tweaks
304
- */
305
- var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
306
- /**
307
- * Parse Date time skeleton into Intl.DateTimeFormatOptions
308
- * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
309
- * @public
310
- * @param skeleton skeleton string
311
- */
312
- function parseDateTimeSkeleton(skeleton) {
313
- var result = {};
314
- skeleton.replace(DATE_TIME_REGEX, function (match) {
315
- var len = match.length;
316
- switch (match[0]) {
317
- // Era
318
- case 'G':
319
- result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
320
- break;
321
- // Year
322
- case 'y':
323
- result.year = len === 2 ? '2-digit' : 'numeric';
324
- break;
325
- case 'Y':
326
- case 'u':
327
- case 'U':
328
- case 'r':
329
- throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
330
- // Quarter
331
- case 'q':
332
- case 'Q':
333
- throw new RangeError('`q/Q` (quarter) patterns are not supported');
334
- // Month
335
- case 'M':
336
- case 'L':
337
- result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
338
- break;
339
- // Week
340
- case 'w':
341
- case 'W':
342
- throw new RangeError('`w/W` (week) patterns are not supported');
343
- case 'd':
344
- result.day = ['numeric', '2-digit'][len - 1];
345
- break;
346
- case 'D':
347
- case 'F':
348
- case 'g':
349
- throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
350
- // Weekday
351
- case 'E':
352
- result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
353
- break;
354
- case 'e':
355
- if (len < 4) {
356
- throw new RangeError('`e..eee` (weekday) patterns are not supported');
357
- }
358
- result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
359
- break;
360
- case 'c':
361
- if (len < 4) {
362
- throw new RangeError('`c..ccc` (weekday) patterns are not supported');
363
- }
364
- result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
365
- break;
366
- // Period
367
- case 'a': // AM, PM
368
- result.hour12 = true;
369
- break;
370
- case 'b': // am, pm, noon, midnight
371
- case 'B': // flexible day periods
372
- throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
373
- // Hour
374
- case 'h':
375
- result.hourCycle = 'h12';
376
- result.hour = ['numeric', '2-digit'][len - 1];
377
- break;
378
- case 'H':
379
- result.hourCycle = 'h23';
380
- result.hour = ['numeric', '2-digit'][len - 1];
381
- break;
382
- case 'K':
383
- result.hourCycle = 'h11';
384
- result.hour = ['numeric', '2-digit'][len - 1];
385
- break;
386
- case 'k':
387
- result.hourCycle = 'h24';
388
- result.hour = ['numeric', '2-digit'][len - 1];
389
- break;
390
- case 'j':
391
- case 'J':
392
- case 'C':
393
- throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
394
- // Minute
395
- case 'm':
396
- result.minute = ['numeric', '2-digit'][len - 1];
397
- break;
398
- // Second
399
- case 's':
400
- result.second = ['numeric', '2-digit'][len - 1];
401
- break;
402
- case 'S':
403
- case 'A':
404
- throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');
405
- // Zone
406
- case 'z': // 1..3, 4: specific non-location format
407
- result.timeZoneName = len < 4 ? 'short' : 'long';
408
- break;
409
- case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
410
- case 'O': // 1, 4: milliseconds in day short, long
411
- case 'v': // 1, 4: generic non-location format
412
- case 'V': // 1, 2, 3, 4: time zone ID or city
413
- case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
414
- case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
415
- throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');
416
- }
417
- return '';
418
- });
419
- return result;
420
- }
421
-
422
- // @generated from regex-gen.ts
423
- var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
424
-
425
- function parseNumberSkeletonFromString(skeleton) {
426
- if (skeleton.length === 0) {
427
- throw new Error('Number skeleton cannot be empty');
428
- }
429
- // Parse the skeleton
430
- var stringTokens = skeleton
431
- .split(WHITE_SPACE_REGEX)
432
- .filter(function (x) { return x.length > 0; });
433
- var tokens = [];
434
- for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
435
- var stringToken = stringTokens_1[_i];
436
- var stemAndOptions = stringToken.split('/');
437
- if (stemAndOptions.length === 0) {
438
- throw new Error('Invalid number skeleton');
439
- }
440
- var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
441
- for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
442
- var option = options_1[_a];
443
- if (option.length === 0) {
444
- throw new Error('Invalid number skeleton');
445
- }
446
- }
447
- tokens.push({ stem: stem, options: options });
448
- }
449
- return tokens;
450
- }
451
- function icuUnitToEcma(unit) {
452
- return unit.replace(/^(.*?)-/, '');
453
- }
454
- var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
455
- var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
456
- var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
457
- var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
458
- function parseSignificantPrecision(str) {
459
- var result = {};
460
- if (str[str.length - 1] === 'r') {
461
- result.roundingPriority = 'morePrecision';
462
- }
463
- else if (str[str.length - 1] === 's') {
464
- result.roundingPriority = 'lessPrecision';
465
- }
466
- str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
467
- // @@@ case
468
- if (typeof g2 !== 'string') {
469
- result.minimumSignificantDigits = g1.length;
470
- result.maximumSignificantDigits = g1.length;
471
- }
472
- // @@@+ case
473
- else if (g2 === '+') {
474
- result.minimumSignificantDigits = g1.length;
475
- }
476
- // .### case
477
- else if (g1[0] === '#') {
478
- result.maximumSignificantDigits = g1.length;
479
- }
480
- // .@@## or .@@@ case
481
- else {
482
- result.minimumSignificantDigits = g1.length;
483
- result.maximumSignificantDigits =
484
- g1.length + (typeof g2 === 'string' ? g2.length : 0);
485
- }
486
- return '';
487
- });
488
- return result;
489
- }
490
- function parseSign(str) {
491
- switch (str) {
492
- case 'sign-auto':
493
- return {
494
- signDisplay: 'auto',
495
- };
496
- case 'sign-accounting':
497
- case '()':
498
- return {
499
- currencySign: 'accounting',
500
- };
501
- case 'sign-always':
502
- case '+!':
503
- return {
504
- signDisplay: 'always',
505
- };
506
- case 'sign-accounting-always':
507
- case '()!':
508
- return {
509
- signDisplay: 'always',
510
- currencySign: 'accounting',
511
- };
512
- case 'sign-except-zero':
513
- case '+?':
514
- return {
515
- signDisplay: 'exceptZero',
516
- };
517
- case 'sign-accounting-except-zero':
518
- case '()?':
519
- return {
520
- signDisplay: 'exceptZero',
521
- currencySign: 'accounting',
522
- };
523
- case 'sign-never':
524
- case '+_':
525
- return {
526
- signDisplay: 'never',
527
- };
528
- }
529
- }
530
- function parseConciseScientificAndEngineeringStem(stem) {
531
- // Engineering
532
- var result;
533
- if (stem[0] === 'E' && stem[1] === 'E') {
534
- result = {
535
- notation: 'engineering',
536
- };
537
- stem = stem.slice(2);
538
- }
539
- else if (stem[0] === 'E') {
540
- result = {
541
- notation: 'scientific',
542
- };
543
- stem = stem.slice(1);
544
- }
545
- if (result) {
546
- var signDisplay = stem.slice(0, 2);
547
- if (signDisplay === '+!') {
548
- result.signDisplay = 'always';
549
- stem = stem.slice(2);
550
- }
551
- else if (signDisplay === '+?') {
552
- result.signDisplay = 'exceptZero';
553
- stem = stem.slice(2);
554
- }
555
- if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
556
- throw new Error('Malformed concise eng/scientific notation');
557
- }
558
- result.minimumIntegerDigits = stem.length;
559
- }
560
- return result;
561
- }
562
- function parseNotationOptions(opt) {
563
- var result = {};
564
- var signOpts = parseSign(opt);
565
- if (signOpts) {
566
- return signOpts;
567
- }
568
- return result;
569
- }
570
- /**
571
- * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
572
- */
573
- function parseNumberSkeleton(tokens) {
574
- var result = {};
575
- for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
576
- var token = tokens_1[_i];
577
- switch (token.stem) {
578
- case 'percent':
579
- case '%':
580
- result.style = 'percent';
581
- continue;
582
- case '%x100':
583
- result.style = 'percent';
584
- result.scale = 100;
585
- continue;
586
- case 'currency':
587
- result.style = 'currency';
588
- result.currency = token.options[0];
589
- continue;
590
- case 'group-off':
591
- case ',_':
592
- result.useGrouping = false;
593
- continue;
594
- case 'precision-integer':
595
- case '.':
596
- result.maximumFractionDigits = 0;
597
- continue;
598
- case 'measure-unit':
599
- case 'unit':
600
- result.style = 'unit';
601
- result.unit = icuUnitToEcma(token.options[0]);
602
- continue;
603
- case 'compact-short':
604
- case 'K':
605
- result.notation = 'compact';
606
- result.compactDisplay = 'short';
607
- continue;
608
- case 'compact-long':
609
- case 'KK':
610
- result.notation = 'compact';
611
- result.compactDisplay = 'long';
612
- continue;
613
- case 'scientific':
614
- result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
615
- continue;
616
- case 'engineering':
617
- result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
618
- continue;
619
- case 'notation-simple':
620
- result.notation = 'standard';
621
- continue;
622
- // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
623
- case 'unit-width-narrow':
624
- result.currencyDisplay = 'narrowSymbol';
625
- result.unitDisplay = 'narrow';
626
- continue;
627
- case 'unit-width-short':
628
- result.currencyDisplay = 'code';
629
- result.unitDisplay = 'short';
630
- continue;
631
- case 'unit-width-full-name':
632
- result.currencyDisplay = 'name';
633
- result.unitDisplay = 'long';
634
- continue;
635
- case 'unit-width-iso-code':
636
- result.currencyDisplay = 'symbol';
637
- continue;
638
- case 'scale':
639
- result.scale = parseFloat(token.options[0]);
640
- continue;
641
- case 'rounding-mode-floor':
642
- result.roundingMode = 'floor';
643
- continue;
644
- case 'rounding-mode-ceiling':
645
- result.roundingMode = 'ceil';
646
- continue;
647
- case 'rounding-mode-down':
648
- result.roundingMode = 'trunc';
649
- continue;
650
- case 'rounding-mode-up':
651
- result.roundingMode = 'expand';
652
- continue;
653
- case 'rounding-mode-half-even':
654
- result.roundingMode = 'halfEven';
655
- continue;
656
- case 'rounding-mode-half-down':
657
- result.roundingMode = 'halfTrunc';
658
- continue;
659
- case 'rounding-mode-half-up':
660
- result.roundingMode = 'halfExpand';
661
- continue;
662
- // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
663
- case 'integer-width':
664
- if (token.options.length > 1) {
665
- throw new RangeError('integer-width stems only accept a single optional option');
666
- }
667
- token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {
668
- if (g1) {
669
- result.minimumIntegerDigits = g2.length;
670
- }
671
- else if (g3 && g4) {
672
- throw new Error('We currently do not support maximum integer digits');
673
- }
674
- else if (g5) {
675
- throw new Error('We currently do not support exact integer digits');
676
- }
677
- return '';
678
- });
679
- continue;
680
- }
681
- // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
682
- if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
683
- result.minimumIntegerDigits = token.stem.length;
684
- continue;
685
- }
686
- if (FRACTION_PRECISION_REGEX.test(token.stem)) {
687
- // Precision
688
- // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
689
- // precision-integer case
690
- if (token.options.length > 1) {
691
- throw new RangeError('Fraction-precision stems only accept a single optional option');
692
- }
693
- token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
694
- // .000* case (before ICU67 it was .000+)
695
- if (g2 === '*') {
696
- result.minimumFractionDigits = g1.length;
697
- }
698
- // .### case
699
- else if (g3 && g3[0] === '#') {
700
- result.maximumFractionDigits = g3.length;
701
- }
702
- // .00## case
703
- else if (g4 && g5) {
704
- result.minimumFractionDigits = g4.length;
705
- result.maximumFractionDigits = g4.length + g5.length;
706
- }
707
- else {
708
- result.minimumFractionDigits = g1.length;
709
- result.maximumFractionDigits = g1.length;
710
- }
711
- return '';
712
- });
713
- var opt = token.options[0];
714
- // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#trailing-zero-display
715
- if (opt === 'w') {
716
- result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' });
717
- }
718
- else if (opt) {
719
- result = __assign(__assign({}, result), parseSignificantPrecision(opt));
720
- }
721
- continue;
722
- }
723
- // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision
724
- if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
725
- result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
726
- continue;
727
- }
728
- var signOpts = parseSign(token.stem);
729
- if (signOpts) {
730
- result = __assign(__assign({}, result), signOpts);
731
- }
732
- var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
733
- if (conciseScientificAndEngineeringOpts) {
734
- result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
735
- }
736
- }
737
- return result;
738
- }
739
-
740
- // @generated from time-data-gen.ts
741
- // prettier-ignore
742
- var timeData = {
743
- "001": [
744
- "H",
745
- "h"
746
- ],
747
- "419": [
748
- "h",
749
- "H",
750
- "hB",
751
- "hb"
752
- ],
753
- "AC": [
754
- "H",
755
- "h",
756
- "hb",
757
- "hB"
758
- ],
759
- "AD": [
760
- "H",
761
- "hB"
762
- ],
763
- "AE": [
764
- "h",
765
- "hB",
766
- "hb",
767
- "H"
768
- ],
769
- "AF": [
770
- "H",
771
- "hb",
772
- "hB",
773
- "h"
774
- ],
775
- "AG": [
776
- "h",
777
- "hb",
778
- "H",
779
- "hB"
780
- ],
781
- "AI": [
782
- "H",
783
- "h",
784
- "hb",
785
- "hB"
786
- ],
787
- "AL": [
788
- "h",
789
- "H",
790
- "hB"
791
- ],
792
- "AM": [
793
- "H",
794
- "hB"
795
- ],
796
- "AO": [
797
- "H",
798
- "hB"
799
- ],
800
- "AR": [
801
- "h",
802
- "H",
803
- "hB",
804
- "hb"
805
- ],
806
- "AS": [
807
- "h",
808
- "H"
809
- ],
810
- "AT": [
811
- "H",
812
- "hB"
813
- ],
814
- "AU": [
815
- "h",
816
- "hb",
817
- "H",
818
- "hB"
819
- ],
820
- "AW": [
821
- "H",
822
- "hB"
823
- ],
824
- "AX": [
825
- "H"
826
- ],
827
- "AZ": [
828
- "H",
829
- "hB",
830
- "h"
831
- ],
832
- "BA": [
833
- "H",
834
- "hB",
835
- "h"
836
- ],
837
- "BB": [
838
- "h",
839
- "hb",
840
- "H",
841
- "hB"
842
- ],
843
- "BD": [
844
- "h",
845
- "hB",
846
- "H"
847
- ],
848
- "BE": [
849
- "H",
850
- "hB"
851
- ],
852
- "BF": [
853
- "H",
854
- "hB"
855
- ],
856
- "BG": [
857
- "H",
858
- "hB",
859
- "h"
860
- ],
861
- "BH": [
862
- "h",
863
- "hB",
864
- "hb",
865
- "H"
866
- ],
867
- "BI": [
868
- "H",
869
- "h"
870
- ],
871
- "BJ": [
872
- "H",
873
- "hB"
874
- ],
875
- "BL": [
876
- "H",
877
- "hB"
878
- ],
879
- "BM": [
880
- "h",
881
- "hb",
882
- "H",
883
- "hB"
884
- ],
885
- "BN": [
886
- "hb",
887
- "hB",
888
- "h",
889
- "H"
890
- ],
891
- "BO": [
892
- "h",
893
- "H",
894
- "hB",
895
- "hb"
896
- ],
897
- "BQ": [
898
- "H"
899
- ],
900
- "BR": [
901
- "H",
902
- "hB"
903
- ],
904
- "BS": [
905
- "h",
906
- "hb",
907
- "H",
908
- "hB"
909
- ],
910
- "BT": [
911
- "h",
912
- "H"
913
- ],
914
- "BW": [
915
- "H",
916
- "h",
917
- "hb",
918
- "hB"
919
- ],
920
- "BY": [
921
- "H",
922
- "h"
923
- ],
924
- "BZ": [
925
- "H",
926
- "h",
927
- "hb",
928
- "hB"
929
- ],
930
- "CA": [
931
- "h",
932
- "hb",
933
- "H",
934
- "hB"
935
- ],
936
- "CC": [
937
- "H",
938
- "h",
939
- "hb",
940
- "hB"
941
- ],
942
- "CD": [
943
- "hB",
944
- "H"
945
- ],
946
- "CF": [
947
- "H",
948
- "h",
949
- "hB"
950
- ],
951
- "CG": [
952
- "H",
953
- "hB"
954
- ],
955
- "CH": [
956
- "H",
957
- "hB",
958
- "h"
959
- ],
960
- "CI": [
961
- "H",
962
- "hB"
963
- ],
964
- "CK": [
965
- "H",
966
- "h",
967
- "hb",
968
- "hB"
969
- ],
970
- "CL": [
971
- "h",
972
- "H",
973
- "hB",
974
- "hb"
975
- ],
976
- "CM": [
977
- "H",
978
- "h",
979
- "hB"
980
- ],
981
- "CN": [
982
- "H",
983
- "hB",
984
- "hb",
985
- "h"
986
- ],
987
- "CO": [
988
- "h",
989
- "H",
990
- "hB",
991
- "hb"
992
- ],
993
- "CP": [
994
- "H"
995
- ],
996
- "CR": [
997
- "h",
998
- "H",
999
- "hB",
1000
- "hb"
1001
- ],
1002
- "CU": [
1003
- "h",
1004
- "H",
1005
- "hB",
1006
- "hb"
1007
- ],
1008
- "CV": [
1009
- "H",
1010
- "hB"
1011
- ],
1012
- "CW": [
1013
- "H",
1014
- "hB"
1015
- ],
1016
- "CX": [
1017
- "H",
1018
- "h",
1019
- "hb",
1020
- "hB"
1021
- ],
1022
- "CY": [
1023
- "h",
1024
- "H",
1025
- "hb",
1026
- "hB"
1027
- ],
1028
- "CZ": [
1029
- "H"
1030
- ],
1031
- "DE": [
1032
- "H",
1033
- "hB"
1034
- ],
1035
- "DG": [
1036
- "H",
1037
- "h",
1038
- "hb",
1039
- "hB"
1040
- ],
1041
- "DJ": [
1042
- "h",
1043
- "H"
1044
- ],
1045
- "DK": [
1046
- "H"
1047
- ],
1048
- "DM": [
1049
- "h",
1050
- "hb",
1051
- "H",
1052
- "hB"
1053
- ],
1054
- "DO": [
1055
- "h",
1056
- "H",
1057
- "hB",
1058
- "hb"
1059
- ],
1060
- "DZ": [
1061
- "h",
1062
- "hB",
1063
- "hb",
1064
- "H"
1065
- ],
1066
- "EA": [
1067
- "H",
1068
- "h",
1069
- "hB",
1070
- "hb"
1071
- ],
1072
- "EC": [
1073
- "h",
1074
- "H",
1075
- "hB",
1076
- "hb"
1077
- ],
1078
- "EE": [
1079
- "H",
1080
- "hB"
1081
- ],
1082
- "EG": [
1083
- "h",
1084
- "hB",
1085
- "hb",
1086
- "H"
1087
- ],
1088
- "EH": [
1089
- "h",
1090
- "hB",
1091
- "hb",
1092
- "H"
1093
- ],
1094
- "ER": [
1095
- "h",
1096
- "H"
1097
- ],
1098
- "ES": [
1099
- "H",
1100
- "hB",
1101
- "h",
1102
- "hb"
1103
- ],
1104
- "ET": [
1105
- "hB",
1106
- "hb",
1107
- "h",
1108
- "H"
1109
- ],
1110
- "FI": [
1111
- "H"
1112
- ],
1113
- "FJ": [
1114
- "h",
1115
- "hb",
1116
- "H",
1117
- "hB"
1118
- ],
1119
- "FK": [
1120
- "H",
1121
- "h",
1122
- "hb",
1123
- "hB"
1124
- ],
1125
- "FM": [
1126
- "h",
1127
- "hb",
1128
- "H",
1129
- "hB"
1130
- ],
1131
- "FO": [
1132
- "H",
1133
- "h"
1134
- ],
1135
- "FR": [
1136
- "H",
1137
- "hB"
1138
- ],
1139
- "GA": [
1140
- "H",
1141
- "hB"
1142
- ],
1143
- "GB": [
1144
- "H",
1145
- "h",
1146
- "hb",
1147
- "hB"
1148
- ],
1149
- "GD": [
1150
- "h",
1151
- "hb",
1152
- "H",
1153
- "hB"
1154
- ],
1155
- "GE": [
1156
- "H",
1157
- "hB",
1158
- "h"
1159
- ],
1160
- "GF": [
1161
- "H",
1162
- "hB"
1163
- ],
1164
- "GG": [
1165
- "H",
1166
- "h",
1167
- "hb",
1168
- "hB"
1169
- ],
1170
- "GH": [
1171
- "h",
1172
- "H"
1173
- ],
1174
- "GI": [
1175
- "H",
1176
- "h",
1177
- "hb",
1178
- "hB"
1179
- ],
1180
- "GL": [
1181
- "H",
1182
- "h"
1183
- ],
1184
- "GM": [
1185
- "h",
1186
- "hb",
1187
- "H",
1188
- "hB"
1189
- ],
1190
- "GN": [
1191
- "H",
1192
- "hB"
1193
- ],
1194
- "GP": [
1195
- "H",
1196
- "hB"
1197
- ],
1198
- "GQ": [
1199
- "H",
1200
- "hB",
1201
- "h",
1202
- "hb"
1203
- ],
1204
- "GR": [
1205
- "h",
1206
- "H",
1207
- "hb",
1208
- "hB"
1209
- ],
1210
- "GT": [
1211
- "h",
1212
- "H",
1213
- "hB",
1214
- "hb"
1215
- ],
1216
- "GU": [
1217
- "h",
1218
- "hb",
1219
- "H",
1220
- "hB"
1221
- ],
1222
- "GW": [
1223
- "H",
1224
- "hB"
1225
- ],
1226
- "GY": [
1227
- "h",
1228
- "hb",
1229
- "H",
1230
- "hB"
1231
- ],
1232
- "HK": [
1233
- "h",
1234
- "hB",
1235
- "hb",
1236
- "H"
1237
- ],
1238
- "HN": [
1239
- "h",
1240
- "H",
1241
- "hB",
1242
- "hb"
1243
- ],
1244
- "HR": [
1245
- "H",
1246
- "hB"
1247
- ],
1248
- "HU": [
1249
- "H",
1250
- "h"
1251
- ],
1252
- "IC": [
1253
- "H",
1254
- "h",
1255
- "hB",
1256
- "hb"
1257
- ],
1258
- "ID": [
1259
- "H"
1260
- ],
1261
- "IE": [
1262
- "H",
1263
- "h",
1264
- "hb",
1265
- "hB"
1266
- ],
1267
- "IL": [
1268
- "H",
1269
- "hB"
1270
- ],
1271
- "IM": [
1272
- "H",
1273
- "h",
1274
- "hb",
1275
- "hB"
1276
- ],
1277
- "IN": [
1278
- "h",
1279
- "H"
1280
- ],
1281
- "IO": [
1282
- "H",
1283
- "h",
1284
- "hb",
1285
- "hB"
1286
- ],
1287
- "IQ": [
1288
- "h",
1289
- "hB",
1290
- "hb",
1291
- "H"
1292
- ],
1293
- "IR": [
1294
- "hB",
1295
- "H"
1296
- ],
1297
- "IS": [
1298
- "H"
1299
- ],
1300
- "IT": [
1301
- "H",
1302
- "hB"
1303
- ],
1304
- "JE": [
1305
- "H",
1306
- "h",
1307
- "hb",
1308
- "hB"
1309
- ],
1310
- "JM": [
1311
- "h",
1312
- "hb",
1313
- "H",
1314
- "hB"
1315
- ],
1316
- "JO": [
1317
- "h",
1318
- "hB",
1319
- "hb",
1320
- "H"
1321
- ],
1322
- "JP": [
1323
- "H",
1324
- "K",
1325
- "h"
1326
- ],
1327
- "KE": [
1328
- "hB",
1329
- "hb",
1330
- "H",
1331
- "h"
1332
- ],
1333
- "KG": [
1334
- "H",
1335
- "h",
1336
- "hB",
1337
- "hb"
1338
- ],
1339
- "KH": [
1340
- "hB",
1341
- "h",
1342
- "H",
1343
- "hb"
1344
- ],
1345
- "KI": [
1346
- "h",
1347
- "hb",
1348
- "H",
1349
- "hB"
1350
- ],
1351
- "KM": [
1352
- "H",
1353
- "h",
1354
- "hB",
1355
- "hb"
1356
- ],
1357
- "KN": [
1358
- "h",
1359
- "hb",
1360
- "H",
1361
- "hB"
1362
- ],
1363
- "KP": [
1364
- "h",
1365
- "H",
1366
- "hB",
1367
- "hb"
1368
- ],
1369
- "KR": [
1370
- "h",
1371
- "H",
1372
- "hB",
1373
- "hb"
1374
- ],
1375
- "KW": [
1376
- "h",
1377
- "hB",
1378
- "hb",
1379
- "H"
1380
- ],
1381
- "KY": [
1382
- "h",
1383
- "hb",
1384
- "H",
1385
- "hB"
1386
- ],
1387
- "KZ": [
1388
- "H",
1389
- "hB"
1390
- ],
1391
- "LA": [
1392
- "H",
1393
- "hb",
1394
- "hB",
1395
- "h"
1396
- ],
1397
- "LB": [
1398
- "h",
1399
- "hB",
1400
- "hb",
1401
- "H"
1402
- ],
1403
- "LC": [
1404
- "h",
1405
- "hb",
1406
- "H",
1407
- "hB"
1408
- ],
1409
- "LI": [
1410
- "H",
1411
- "hB",
1412
- "h"
1413
- ],
1414
- "LK": [
1415
- "H",
1416
- "h",
1417
- "hB",
1418
- "hb"
1419
- ],
1420
- "LR": [
1421
- "h",
1422
- "hb",
1423
- "H",
1424
- "hB"
1425
- ],
1426
- "LS": [
1427
- "h",
1428
- "H"
1429
- ],
1430
- "LT": [
1431
- "H",
1432
- "h",
1433
- "hb",
1434
- "hB"
1435
- ],
1436
- "LU": [
1437
- "H",
1438
- "h",
1439
- "hB"
1440
- ],
1441
- "LV": [
1442
- "H",
1443
- "hB",
1444
- "hb",
1445
- "h"
1446
- ],
1447
- "LY": [
1448
- "h",
1449
- "hB",
1450
- "hb",
1451
- "H"
1452
- ],
1453
- "MA": [
1454
- "H",
1455
- "h",
1456
- "hB",
1457
- "hb"
1458
- ],
1459
- "MC": [
1460
- "H",
1461
- "hB"
1462
- ],
1463
- "MD": [
1464
- "H",
1465
- "hB"
1466
- ],
1467
- "ME": [
1468
- "H",
1469
- "hB",
1470
- "h"
1471
- ],
1472
- "MF": [
1473
- "H",
1474
- "hB"
1475
- ],
1476
- "MG": [
1477
- "H",
1478
- "h"
1479
- ],
1480
- "MH": [
1481
- "h",
1482
- "hb",
1483
- "H",
1484
- "hB"
1485
- ],
1486
- "MK": [
1487
- "H",
1488
- "h",
1489
- "hb",
1490
- "hB"
1491
- ],
1492
- "ML": [
1493
- "H"
1494
- ],
1495
- "MM": [
1496
- "hB",
1497
- "hb",
1498
- "H",
1499
- "h"
1500
- ],
1501
- "MN": [
1502
- "H",
1503
- "h",
1504
- "hb",
1505
- "hB"
1506
- ],
1507
- "MO": [
1508
- "h",
1509
- "hB",
1510
- "hb",
1511
- "H"
1512
- ],
1513
- "MP": [
1514
- "h",
1515
- "hb",
1516
- "H",
1517
- "hB"
1518
- ],
1519
- "MQ": [
1520
- "H",
1521
- "hB"
1522
- ],
1523
- "MR": [
1524
- "h",
1525
- "hB",
1526
- "hb",
1527
- "H"
1528
- ],
1529
- "MS": [
1530
- "H",
1531
- "h",
1532
- "hb",
1533
- "hB"
1534
- ],
1535
- "MT": [
1536
- "H",
1537
- "h"
1538
- ],
1539
- "MU": [
1540
- "H",
1541
- "h"
1542
- ],
1543
- "MV": [
1544
- "H",
1545
- "h"
1546
- ],
1547
- "MW": [
1548
- "h",
1549
- "hb",
1550
- "H",
1551
- "hB"
1552
- ],
1553
- "MX": [
1554
- "h",
1555
- "H",
1556
- "hB",
1557
- "hb"
1558
- ],
1559
- "MY": [
1560
- "hb",
1561
- "hB",
1562
- "h",
1563
- "H"
1564
- ],
1565
- "MZ": [
1566
- "H",
1567
- "hB"
1568
- ],
1569
- "NA": [
1570
- "h",
1571
- "H",
1572
- "hB",
1573
- "hb"
1574
- ],
1575
- "NC": [
1576
- "H",
1577
- "hB"
1578
- ],
1579
- "NE": [
1580
- "H"
1581
- ],
1582
- "NF": [
1583
- "H",
1584
- "h",
1585
- "hb",
1586
- "hB"
1587
- ],
1588
- "NG": [
1589
- "H",
1590
- "h",
1591
- "hb",
1592
- "hB"
1593
- ],
1594
- "NI": [
1595
- "h",
1596
- "H",
1597
- "hB",
1598
- "hb"
1599
- ],
1600
- "NL": [
1601
- "H",
1602
- "hB"
1603
- ],
1604
- "NO": [
1605
- "H",
1606
- "h"
1607
- ],
1608
- "NP": [
1609
- "H",
1610
- "h",
1611
- "hB"
1612
- ],
1613
- "NR": [
1614
- "H",
1615
- "h",
1616
- "hb",
1617
- "hB"
1618
- ],
1619
- "NU": [
1620
- "H",
1621
- "h",
1622
- "hb",
1623
- "hB"
1624
- ],
1625
- "NZ": [
1626
- "h",
1627
- "hb",
1628
- "H",
1629
- "hB"
1630
- ],
1631
- "OM": [
1632
- "h",
1633
- "hB",
1634
- "hb",
1635
- "H"
1636
- ],
1637
- "PA": [
1638
- "h",
1639
- "H",
1640
- "hB",
1641
- "hb"
1642
- ],
1643
- "PE": [
1644
- "h",
1645
- "H",
1646
- "hB",
1647
- "hb"
1648
- ],
1649
- "PF": [
1650
- "H",
1651
- "h",
1652
- "hB"
1653
- ],
1654
- "PG": [
1655
- "h",
1656
- "H"
1657
- ],
1658
- "PH": [
1659
- "h",
1660
- "hB",
1661
- "hb",
1662
- "H"
1663
- ],
1664
- "PK": [
1665
- "h",
1666
- "hB",
1667
- "H"
1668
- ],
1669
- "PL": [
1670
- "H",
1671
- "h"
1672
- ],
1673
- "PM": [
1674
- "H",
1675
- "hB"
1676
- ],
1677
- "PN": [
1678
- "H",
1679
- "h",
1680
- "hb",
1681
- "hB"
1682
- ],
1683
- "PR": [
1684
- "h",
1685
- "H",
1686
- "hB",
1687
- "hb"
1688
- ],
1689
- "PS": [
1690
- "h",
1691
- "hB",
1692
- "hb",
1693
- "H"
1694
- ],
1695
- "PT": [
1696
- "H",
1697
- "hB"
1698
- ],
1699
- "PW": [
1700
- "h",
1701
- "H"
1702
- ],
1703
- "PY": [
1704
- "h",
1705
- "H",
1706
- "hB",
1707
- "hb"
1708
- ],
1709
- "QA": [
1710
- "h",
1711
- "hB",
1712
- "hb",
1713
- "H"
1714
- ],
1715
- "RE": [
1716
- "H",
1717
- "hB"
1718
- ],
1719
- "RO": [
1720
- "H",
1721
- "hB"
1722
- ],
1723
- "RS": [
1724
- "H",
1725
- "hB",
1726
- "h"
1727
- ],
1728
- "RU": [
1729
- "H"
1730
- ],
1731
- "RW": [
1732
- "H",
1733
- "h"
1734
- ],
1735
- "SA": [
1736
- "h",
1737
- "hB",
1738
- "hb",
1739
- "H"
1740
- ],
1741
- "SB": [
1742
- "h",
1743
- "hb",
1744
- "H",
1745
- "hB"
1746
- ],
1747
- "SC": [
1748
- "H",
1749
- "h",
1750
- "hB"
1751
- ],
1752
- "SD": [
1753
- "h",
1754
- "hB",
1755
- "hb",
1756
- "H"
1757
- ],
1758
- "SE": [
1759
- "H"
1760
- ],
1761
- "SG": [
1762
- "h",
1763
- "hb",
1764
- "H",
1765
- "hB"
1766
- ],
1767
- "SH": [
1768
- "H",
1769
- "h",
1770
- "hb",
1771
- "hB"
1772
- ],
1773
- "SI": [
1774
- "H",
1775
- "hB"
1776
- ],
1777
- "SJ": [
1778
- "H"
1779
- ],
1780
- "SK": [
1781
- "H"
1782
- ],
1783
- "SL": [
1784
- "h",
1785
- "hb",
1786
- "H",
1787
- "hB"
1788
- ],
1789
- "SM": [
1790
- "H",
1791
- "h",
1792
- "hB"
1793
- ],
1794
- "SN": [
1795
- "H",
1796
- "h",
1797
- "hB"
1798
- ],
1799
- "SO": [
1800
- "h",
1801
- "H"
1802
- ],
1803
- "SR": [
1804
- "H",
1805
- "hB"
1806
- ],
1807
- "SS": [
1808
- "h",
1809
- "hb",
1810
- "H",
1811
- "hB"
1812
- ],
1813
- "ST": [
1814
- "H",
1815
- "hB"
1816
- ],
1817
- "SV": [
1818
- "h",
1819
- "H",
1820
- "hB",
1821
- "hb"
1822
- ],
1823
- "SX": [
1824
- "H",
1825
- "h",
1826
- "hb",
1827
- "hB"
1828
- ],
1829
- "SY": [
1830
- "h",
1831
- "hB",
1832
- "hb",
1833
- "H"
1834
- ],
1835
- "SZ": [
1836
- "h",
1837
- "hb",
1838
- "H",
1839
- "hB"
1840
- ],
1841
- "TA": [
1842
- "H",
1843
- "h",
1844
- "hb",
1845
- "hB"
1846
- ],
1847
- "TC": [
1848
- "h",
1849
- "hb",
1850
- "H",
1851
- "hB"
1852
- ],
1853
- "TD": [
1854
- "h",
1855
- "H",
1856
- "hB"
1857
- ],
1858
- "TF": [
1859
- "H",
1860
- "h",
1861
- "hB"
1862
- ],
1863
- "TG": [
1864
- "H",
1865
- "hB"
1866
- ],
1867
- "TH": [
1868
- "H",
1869
- "h"
1870
- ],
1871
- "TJ": [
1872
- "H",
1873
- "h"
1874
- ],
1875
- "TL": [
1876
- "H",
1877
- "hB",
1878
- "hb",
1879
- "h"
1880
- ],
1881
- "TM": [
1882
- "H",
1883
- "h"
1884
- ],
1885
- "TN": [
1886
- "h",
1887
- "hB",
1888
- "hb",
1889
- "H"
1890
- ],
1891
- "TO": [
1892
- "h",
1893
- "H"
1894
- ],
1895
- "TR": [
1896
- "H",
1897
- "hB"
1898
- ],
1899
- "TT": [
1900
- "h",
1901
- "hb",
1902
- "H",
1903
- "hB"
1904
- ],
1905
- "TW": [
1906
- "hB",
1907
- "hb",
1908
- "h",
1909
- "H"
1910
- ],
1911
- "TZ": [
1912
- "hB",
1913
- "hb",
1914
- "H",
1915
- "h"
1916
- ],
1917
- "UA": [
1918
- "H",
1919
- "hB",
1920
- "h"
1921
- ],
1922
- "UG": [
1923
- "hB",
1924
- "hb",
1925
- "H",
1926
- "h"
1927
- ],
1928
- "UM": [
1929
- "h",
1930
- "hb",
1931
- "H",
1932
- "hB"
1933
- ],
1934
- "US": [
1935
- "h",
1936
- "hb",
1937
- "H",
1938
- "hB"
1939
- ],
1940
- "UY": [
1941
- "h",
1942
- "H",
1943
- "hB",
1944
- "hb"
1945
- ],
1946
- "UZ": [
1947
- "H",
1948
- "hB",
1949
- "h"
1950
- ],
1951
- "VA": [
1952
- "H",
1953
- "h",
1954
- "hB"
1955
- ],
1956
- "VC": [
1957
- "h",
1958
- "hb",
1959
- "H",
1960
- "hB"
1961
- ],
1962
- "VE": [
1963
- "h",
1964
- "H",
1965
- "hB",
1966
- "hb"
1967
- ],
1968
- "VG": [
1969
- "h",
1970
- "hb",
1971
- "H",
1972
- "hB"
1973
- ],
1974
- "VI": [
1975
- "h",
1976
- "hb",
1977
- "H",
1978
- "hB"
1979
- ],
1980
- "VN": [
1981
- "H",
1982
- "h"
1983
- ],
1984
- "VU": [
1985
- "h",
1986
- "H"
1987
- ],
1988
- "WF": [
1989
- "H",
1990
- "hB"
1991
- ],
1992
- "WS": [
1993
- "h",
1994
- "H"
1995
- ],
1996
- "XK": [
1997
- "H",
1998
- "hB",
1999
- "h"
2000
- ],
2001
- "YE": [
2002
- "h",
2003
- "hB",
2004
- "hb",
2005
- "H"
2006
- ],
2007
- "YT": [
2008
- "H",
2009
- "hB"
2010
- ],
2011
- "ZA": [
2012
- "H",
2013
- "h",
2014
- "hb",
2015
- "hB"
2016
- ],
2017
- "ZM": [
2018
- "h",
2019
- "hb",
2020
- "H",
2021
- "hB"
2022
- ],
2023
- "ZW": [
2024
- "H",
2025
- "h"
2026
- ],
2027
- "af-ZA": [
2028
- "H",
2029
- "h",
2030
- "hB",
2031
- "hb"
2032
- ],
2033
- "ar-001": [
2034
- "h",
2035
- "hB",
2036
- "hb",
2037
- "H"
2038
- ],
2039
- "ca-ES": [
2040
- "H",
2041
- "h",
2042
- "hB"
2043
- ],
2044
- "en-001": [
2045
- "h",
2046
- "hb",
2047
- "H",
2048
- "hB"
2049
- ],
2050
- "en-HK": [
2051
- "h",
2052
- "hb",
2053
- "H",
2054
- "hB"
2055
- ],
2056
- "en-IL": [
2057
- "H",
2058
- "h",
2059
- "hb",
2060
- "hB"
2061
- ],
2062
- "en-MY": [
2063
- "h",
2064
- "hb",
2065
- "H",
2066
- "hB"
2067
- ],
2068
- "es-BR": [
2069
- "H",
2070
- "h",
2071
- "hB",
2072
- "hb"
2073
- ],
2074
- "es-ES": [
2075
- "H",
2076
- "h",
2077
- "hB",
2078
- "hb"
2079
- ],
2080
- "es-GQ": [
2081
- "H",
2082
- "h",
2083
- "hB",
2084
- "hb"
2085
- ],
2086
- "fr-CA": [
2087
- "H",
2088
- "h",
2089
- "hB"
2090
- ],
2091
- "gl-ES": [
2092
- "H",
2093
- "h",
2094
- "hB"
2095
- ],
2096
- "gu-IN": [
2097
- "hB",
2098
- "hb",
2099
- "h",
2100
- "H"
2101
- ],
2102
- "hi-IN": [
2103
- "hB",
2104
- "h",
2105
- "H"
2106
- ],
2107
- "it-CH": [
2108
- "H",
2109
- "h",
2110
- "hB"
2111
- ],
2112
- "it-IT": [
2113
- "H",
2114
- "h",
2115
- "hB"
2116
- ],
2117
- "kn-IN": [
2118
- "hB",
2119
- "h",
2120
- "H"
2121
- ],
2122
- "ml-IN": [
2123
- "hB",
2124
- "h",
2125
- "H"
2126
- ],
2127
- "mr-IN": [
2128
- "hB",
2129
- "hb",
2130
- "h",
2131
- "H"
2132
- ],
2133
- "pa-IN": [
2134
- "hB",
2135
- "hb",
2136
- "h",
2137
- "H"
2138
- ],
2139
- "ta-IN": [
2140
- "hB",
2141
- "h",
2142
- "hb",
2143
- "H"
2144
- ],
2145
- "te-IN": [
2146
- "hB",
2147
- "h",
2148
- "H"
2149
- ],
2150
- "zu-ZA": [
2151
- "H",
2152
- "hB",
2153
- "hb",
2154
- "h"
2155
- ]
2156
- };
2157
-
2158
- /**
2159
- * Returns the best matching date time pattern if a date time skeleton
2160
- * pattern is provided with a locale. Follows the Unicode specification:
2161
- * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
2162
- * @param skeleton date time skeleton pattern that possibly includes j, J or C
2163
- * @param locale
2164
- */
2165
- function getBestPattern(skeleton, locale) {
2166
- var skeletonCopy = '';
2167
- for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
2168
- var patternChar = skeleton.charAt(patternPos);
2169
- if (patternChar === 'j') {
2170
- var extraLength = 0;
2171
- while (patternPos + 1 < skeleton.length &&
2172
- skeleton.charAt(patternPos + 1) === patternChar) {
2173
- extraLength++;
2174
- patternPos++;
2175
- }
2176
- var hourLen = 1 + (extraLength & 1);
2177
- var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
2178
- var dayPeriodChar = 'a';
2179
- var hourChar = getDefaultHourSymbolFromLocale(locale);
2180
- if (hourChar == 'H' || hourChar == 'k') {
2181
- dayPeriodLen = 0;
2182
- }
2183
- while (dayPeriodLen-- > 0) {
2184
- skeletonCopy += dayPeriodChar;
2185
- }
2186
- while (hourLen-- > 0) {
2187
- skeletonCopy = hourChar + skeletonCopy;
2188
- }
2189
- }
2190
- else if (patternChar === 'J') {
2191
- skeletonCopy += 'H';
2192
- }
2193
- else {
2194
- skeletonCopy += patternChar;
2195
- }
2196
- }
2197
- return skeletonCopy;
2198
- }
2199
- /**
2200
- * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
2201
- * of the given `locale` to the corresponding time pattern.
2202
- * @param locale
2203
- */
2204
- function getDefaultHourSymbolFromLocale(locale) {
2205
- var hourCycle = locale.hourCycle;
2206
- if (hourCycle === undefined &&
2207
- // @ts-ignore hourCycle(s) is not identified yet
2208
- locale.hourCycles &&
2209
- // @ts-ignore
2210
- locale.hourCycles.length) {
2211
- // @ts-ignore
2212
- hourCycle = locale.hourCycles[0];
2213
- }
2214
- if (hourCycle) {
2215
- switch (hourCycle) {
2216
- case 'h24':
2217
- return 'k';
2218
- case 'h23':
2219
- return 'H';
2220
- case 'h12':
2221
- return 'h';
2222
- case 'h11':
2223
- return 'K';
2224
- default:
2225
- throw new Error('Invalid hourCycle');
2226
- }
2227
- }
2228
- // TODO: Once hourCycle is fully supported remove the following with data generation
2229
- var languageTag = locale.language;
2230
- var regionTag;
2231
- if (languageTag !== 'root') {
2232
- regionTag = locale.maximize().region;
2233
- }
2234
- var hourCycles = timeData[regionTag || ''] ||
2235
- timeData[languageTag || ''] ||
2236
- timeData["".concat(languageTag, "-001")] ||
2237
- timeData['001'];
2238
- return hourCycles[0];
2239
- }
2240
-
2241
- var _a;
2242
- var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
2243
- var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
2244
- function createLocation(start, end) {
2245
- return { start: start, end: end };
2246
- }
2247
- // #region Ponyfills
2248
- // Consolidate these variables up top for easier toggling during debugging
2249
- var hasNativeStartsWith = !!String.prototype.startsWith && '_a'.startsWith('a', 1);
2250
- var hasNativeFromCodePoint = !!String.fromCodePoint;
2251
- var hasNativeFromEntries = !!Object.fromEntries;
2252
- var hasNativeCodePointAt = !!String.prototype.codePointAt;
2253
- var hasTrimStart = !!String.prototype.trimStart;
2254
- var hasTrimEnd = !!String.prototype.trimEnd;
2255
- var hasNativeIsSafeInteger = !!Number.isSafeInteger;
2256
- var isSafeInteger = hasNativeIsSafeInteger
2257
- ? Number.isSafeInteger
2258
- : function (n) {
2259
- return (typeof n === 'number' &&
2260
- isFinite(n) &&
2261
- Math.floor(n) === n &&
2262
- Math.abs(n) <= 0x1fffffffffffff);
2263
- };
2264
- // IE11 does not support y and u.
2265
- var REGEX_SUPPORTS_U_AND_Y = true;
2266
- try {
2267
- var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2268
- /**
2269
- * legacy Edge or Xbox One browser
2270
- * Unicode flag support: supported
2271
- * Pattern_Syntax support: not supported
2272
- * See https://github.com/formatjs/formatjs/issues/2822
2273
- */
2274
- REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
2275
- }
2276
- catch (_) {
2277
- REGEX_SUPPORTS_U_AND_Y = false;
2278
- }
2279
- var startsWith = hasNativeStartsWith
2280
- ? // Native
2281
- function startsWith(s, search, position) {
2282
- return s.startsWith(search, position);
2283
- }
2284
- : // For IE11
2285
- function startsWith(s, search, position) {
2286
- return s.slice(position, position + search.length) === search;
2287
- };
2288
- var fromCodePoint = hasNativeFromCodePoint
2289
- ? String.fromCodePoint
2290
- : // IE11
2291
- function fromCodePoint() {
2292
- var codePoints = [];
2293
- for (var _i = 0; _i < arguments.length; _i++) {
2294
- codePoints[_i] = arguments[_i];
2295
- }
2296
- var elements = '';
2297
- var length = codePoints.length;
2298
- var i = 0;
2299
- var code;
2300
- while (length > i) {
2301
- code = codePoints[i++];
2302
- if (code > 0x10ffff)
2303
- throw RangeError(code + ' is not a valid code point');
2304
- elements +=
2305
- code < 0x10000
2306
- ? String.fromCharCode(code)
2307
- : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
2308
- }
2309
- return elements;
2310
- };
2311
- var fromEntries =
2312
- // native
2313
- hasNativeFromEntries
2314
- ? Object.fromEntries
2315
- : // Ponyfill
2316
- function fromEntries(entries) {
2317
- var obj = {};
2318
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
2319
- var _a = entries_1[_i], k = _a[0], v = _a[1];
2320
- obj[k] = v;
2321
- }
2322
- return obj;
2323
- };
2324
- var codePointAt = hasNativeCodePointAt
2325
- ? // Native
2326
- function codePointAt(s, index) {
2327
- return s.codePointAt(index);
2328
- }
2329
- : // IE 11
2330
- function codePointAt(s, index) {
2331
- var size = s.length;
2332
- if (index < 0 || index >= size) {
2333
- return undefined;
2334
- }
2335
- var first = s.charCodeAt(index);
2336
- var second;
2337
- return first < 0xd800 ||
2338
- first > 0xdbff ||
2339
- index + 1 === size ||
2340
- (second = s.charCodeAt(index + 1)) < 0xdc00 ||
2341
- second > 0xdfff
2342
- ? first
2343
- : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
2344
- };
2345
- var trimStart = hasTrimStart
2346
- ? // Native
2347
- function trimStart(s) {
2348
- return s.trimStart();
2349
- }
2350
- : // Ponyfill
2351
- function trimStart(s) {
2352
- return s.replace(SPACE_SEPARATOR_START_REGEX, '');
2353
- };
2354
- var trimEnd = hasTrimEnd
2355
- ? // Native
2356
- function trimEnd(s) {
2357
- return s.trimEnd();
2358
- }
2359
- : // Ponyfill
2360
- function trimEnd(s) {
2361
- return s.replace(SPACE_SEPARATOR_END_REGEX, '');
2362
- };
2363
- // Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
2364
- function RE(s, flag) {
2365
- return new RegExp(s, flag);
2366
- }
2367
- // #endregion
2368
- var matchIdentifierAtIndex;
2369
- if (REGEX_SUPPORTS_U_AND_Y) {
2370
- // Native
2371
- var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2372
- matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2373
- var _a;
2374
- IDENTIFIER_PREFIX_RE_1.lastIndex = index;
2375
- var match = IDENTIFIER_PREFIX_RE_1.exec(s);
2376
- return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
2377
- };
2378
- }
2379
- else {
2380
- // IE11
2381
- matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2382
- var match = [];
2383
- while (true) {
2384
- var c = codePointAt(s, index);
2385
- if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
2386
- break;
2387
- }
2388
- match.push(c);
2389
- index += c >= 0x10000 ? 2 : 1;
2390
- }
2391
- return fromCodePoint.apply(void 0, match);
2392
- };
2393
- }
2394
- var Parser = /** @class */ (function () {
2395
- function Parser(message, options) {
2396
- if (options === void 0) { options = {}; }
2397
- this.message = message;
2398
- this.position = { offset: 0, line: 1, column: 1 };
2399
- this.ignoreTag = !!options.ignoreTag;
2400
- this.locale = options.locale;
2401
- this.requiresOtherClause = !!options.requiresOtherClause;
2402
- this.shouldParseSkeletons = !!options.shouldParseSkeletons;
2403
- }
2404
- Parser.prototype.parse = function () {
2405
- if (this.offset() !== 0) {
2406
- throw Error('parser can only be used once');
2407
- }
2408
- return this.parseMessage(0, '', false);
2409
- };
2410
- Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
2411
- var elements = [];
2412
- while (!this.isEOF()) {
2413
- var char = this.char();
2414
- if (char === 123 /* `{` */) {
2415
- var result = this.parseArgument(nestingLevel, expectingCloseTag);
2416
- if (result.err) {
2417
- return result;
2418
- }
2419
- elements.push(result.val);
2420
- }
2421
- else if (char === 125 /* `}` */ && nestingLevel > 0) {
2422
- break;
2423
- }
2424
- else if (char === 35 /* `#` */ &&
2425
- (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
2426
- var position = this.clonePosition();
2427
- this.bump();
2428
- elements.push({
2429
- type: TYPE.pound,
2430
- location: createLocation(position, this.clonePosition()),
2431
- });
2432
- }
2433
- else if (char === 60 /* `<` */ &&
2434
- !this.ignoreTag &&
2435
- this.peek() === 47 // char code for '/'
2436
- ) {
2437
- if (expectingCloseTag) {
2438
- break;
2439
- }
2440
- else {
2441
- return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
2442
- }
2443
- }
2444
- else if (char === 60 /* `<` */ &&
2445
- !this.ignoreTag &&
2446
- _isAlpha(this.peek() || 0)) {
2447
- var result = this.parseTag(nestingLevel, parentArgType);
2448
- if (result.err) {
2449
- return result;
2450
- }
2451
- elements.push(result.val);
2452
- }
2453
- else {
2454
- var result = this.parseLiteral(nestingLevel, parentArgType);
2455
- if (result.err) {
2456
- return result;
2457
- }
2458
- elements.push(result.val);
2459
- }
2460
- }
2461
- return { val: elements, err: null };
2462
- };
2463
- /**
2464
- * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
2465
- * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
2466
- * are accepted:
2467
- *
2468
- * ```
2469
- * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
2470
- * tagName ::= [a-z] (PENChar)*
2471
- * PENChar ::=
2472
- * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
2473
- * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
2474
- * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
2475
- * ```
2476
- *
2477
- * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
2478
- * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
2479
- * since other tag-based engines like React allow it
2480
- */
2481
- Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
2482
- var startPosition = this.clonePosition();
2483
- this.bump(); // `<`
2484
- var tagName = this.parseTagName();
2485
- this.bumpSpace();
2486
- if (this.bumpIf('/>')) {
2487
- // Self closing tag
2488
- return {
2489
- val: {
2490
- type: TYPE.literal,
2491
- value: "<".concat(tagName, "/>"),
2492
- location: createLocation(startPosition, this.clonePosition()),
2493
- },
2494
- err: null,
2495
- };
2496
- }
2497
- else if (this.bumpIf('>')) {
2498
- var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
2499
- if (childrenResult.err) {
2500
- return childrenResult;
2501
- }
2502
- var children = childrenResult.val;
2503
- // Expecting a close tag
2504
- var endTagStartPosition = this.clonePosition();
2505
- if (this.bumpIf('</')) {
2506
- if (this.isEOF() || !_isAlpha(this.char())) {
2507
- return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2508
- }
2509
- var closingTagNameStartPosition = this.clonePosition();
2510
- var closingTagName = this.parseTagName();
2511
- if (tagName !== closingTagName) {
2512
- return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
2513
- }
2514
- this.bumpSpace();
2515
- if (!this.bumpIf('>')) {
2516
- return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2517
- }
2518
- return {
2519
- val: {
2520
- type: TYPE.tag,
2521
- value: tagName,
2522
- children: children,
2523
- location: createLocation(startPosition, this.clonePosition()),
2524
- },
2525
- err: null,
2526
- };
2527
- }
2528
- else {
2529
- return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
2530
- }
2531
- }
2532
- else {
2533
- return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
2534
- }
2535
- };
2536
- /**
2537
- * This method assumes that the caller has peeked ahead for the first tag character.
2538
- */
2539
- Parser.prototype.parseTagName = function () {
2540
- var startOffset = this.offset();
2541
- this.bump(); // the first tag name character
2542
- while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
2543
- this.bump();
2544
- }
2545
- return this.message.slice(startOffset, this.offset());
2546
- };
2547
- Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
2548
- var start = this.clonePosition();
2549
- var value = '';
2550
- while (true) {
2551
- var parseQuoteResult = this.tryParseQuote(parentArgType);
2552
- if (parseQuoteResult) {
2553
- value += parseQuoteResult;
2554
- continue;
2555
- }
2556
- var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
2557
- if (parseUnquotedResult) {
2558
- value += parseUnquotedResult;
2559
- continue;
2560
- }
2561
- var parseLeftAngleResult = this.tryParseLeftAngleBracket();
2562
- if (parseLeftAngleResult) {
2563
- value += parseLeftAngleResult;
2564
- continue;
2565
- }
2566
- break;
2567
- }
2568
- var location = createLocation(start, this.clonePosition());
2569
- return {
2570
- val: { type: TYPE.literal, value: value, location: location },
2571
- err: null,
2572
- };
2573
- };
2574
- Parser.prototype.tryParseLeftAngleBracket = function () {
2575
- if (!this.isEOF() &&
2576
- this.char() === 60 /* `<` */ &&
2577
- (this.ignoreTag ||
2578
- // If at the opening tag or closing tag position, bail.
2579
- !_isAlphaOrSlash(this.peek() || 0))) {
2580
- this.bump(); // `<`
2581
- return '<';
2582
- }
2583
- return null;
2584
- };
2585
- /**
2586
- * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
2587
- * a character that requires quoting (that is, "only where needed"), and works the same in
2588
- * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
2589
- */
2590
- Parser.prototype.tryParseQuote = function (parentArgType) {
2591
- if (this.isEOF() || this.char() !== 39 /* `'` */) {
2592
- return null;
2593
- }
2594
- // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2595
- // Check if is valid escaped character
2596
- switch (this.peek()) {
2597
- case 39 /* `'` */:
2598
- // double quote, should return as a single quote.
2599
- this.bump();
2600
- this.bump();
2601
- return "'";
2602
- // '{', '<', '>', '}'
2603
- case 123:
2604
- case 60:
2605
- case 62:
2606
- case 125:
2607
- break;
2608
- case 35: // '#'
2609
- if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
2610
- break;
2611
- }
2612
- return null;
2613
- default:
2614
- return null;
2615
- }
2616
- this.bump(); // apostrophe
2617
- var codePoints = [this.char()]; // escaped char
2618
- this.bump();
2619
- // read chars until the optional closing apostrophe is found
2620
- while (!this.isEOF()) {
2621
- var ch = this.char();
2622
- if (ch === 39 /* `'` */) {
2623
- if (this.peek() === 39 /* `'` */) {
2624
- codePoints.push(39);
2625
- // Bump one more time because we need to skip 2 characters.
2626
- this.bump();
2627
- }
2628
- else {
2629
- // Optional closing apostrophe.
2630
- this.bump();
2631
- break;
2632
- }
2633
- }
2634
- else {
2635
- codePoints.push(ch);
2636
- }
2637
- this.bump();
2638
- }
2639
- return fromCodePoint.apply(void 0, codePoints);
2640
- };
2641
- Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
2642
- if (this.isEOF()) {
2643
- return null;
2644
- }
2645
- var ch = this.char();
2646
- if (ch === 60 /* `<` */ ||
2647
- ch === 123 /* `{` */ ||
2648
- (ch === 35 /* `#` */ &&
2649
- (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
2650
- (ch === 125 /* `}` */ && nestingLevel > 0)) {
2651
- return null;
2652
- }
2653
- else {
2654
- this.bump();
2655
- return fromCodePoint(ch);
2656
- }
2657
- };
2658
- Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
2659
- var openingBracePosition = this.clonePosition();
2660
- this.bump(); // `{`
2661
- this.bumpSpace();
2662
- if (this.isEOF()) {
2663
- return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2664
- }
2665
- if (this.char() === 125 /* `}` */) {
2666
- this.bump();
2667
- return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2668
- }
2669
- // argument name
2670
- var value = this.parseIdentifierIfPossible().value;
2671
- if (!value) {
2672
- return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2673
- }
2674
- this.bumpSpace();
2675
- if (this.isEOF()) {
2676
- return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2677
- }
2678
- switch (this.char()) {
2679
- // Simple argument: `{name}`
2680
- case 125 /* `}` */: {
2681
- this.bump(); // `}`
2682
- return {
2683
- val: {
2684
- type: TYPE.argument,
2685
- // value does not include the opening and closing braces.
2686
- value: value,
2687
- location: createLocation(openingBracePosition, this.clonePosition()),
2688
- },
2689
- err: null,
2690
- };
2691
- }
2692
- // Argument with options: `{name, format, ...}`
2693
- case 44 /* `,` */: {
2694
- this.bump(); // `,`
2695
- this.bumpSpace();
2696
- if (this.isEOF()) {
2697
- return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2698
- }
2699
- return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
2700
- }
2701
- default:
2702
- return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2703
- }
2704
- };
2705
- /**
2706
- * Advance the parser until the end of the identifier, if it is currently on
2707
- * an identifier character. Return an empty string otherwise.
2708
- */
2709
- Parser.prototype.parseIdentifierIfPossible = function () {
2710
- var startingPosition = this.clonePosition();
2711
- var startOffset = this.offset();
2712
- var value = matchIdentifierAtIndex(this.message, startOffset);
2713
- var endOffset = startOffset + value.length;
2714
- this.bumpTo(endOffset);
2715
- var endPosition = this.clonePosition();
2716
- var location = createLocation(startingPosition, endPosition);
2717
- return { value: value, location: location };
2718
- };
2719
- Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
2720
- var _a;
2721
- // Parse this range:
2722
- // {name, type, style}
2723
- // ^---^
2724
- var typeStartPosition = this.clonePosition();
2725
- var argType = this.parseIdentifierIfPossible().value;
2726
- var typeEndPosition = this.clonePosition();
2727
- switch (argType) {
2728
- case '':
2729
- // Expecting a style string number, date, time, plural, selectordinal, or select.
2730
- return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
2731
- case 'number':
2732
- case 'date':
2733
- case 'time': {
2734
- // Parse this range:
2735
- // {name, number, style}
2736
- // ^-------^
2737
- this.bumpSpace();
2738
- var styleAndLocation = null;
2739
- if (this.bumpIf(',')) {
2740
- this.bumpSpace();
2741
- var styleStartPosition = this.clonePosition();
2742
- var result = this.parseSimpleArgStyleIfPossible();
2743
- if (result.err) {
2744
- return result;
2745
- }
2746
- var style = trimEnd(result.val);
2747
- if (style.length === 0) {
2748
- return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
2749
- }
2750
- var styleLocation = createLocation(styleStartPosition, this.clonePosition());
2751
- styleAndLocation = { style: style, styleLocation: styleLocation };
2752
- }
2753
- var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
2754
- if (argCloseResult.err) {
2755
- return argCloseResult;
2756
- }
2757
- var location_1 = createLocation(openingBracePosition, this.clonePosition());
2758
- // Extract style or skeleton
2759
- if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
2760
- // Skeleton starts with `::`.
2761
- var skeleton = trimStart(styleAndLocation.style.slice(2));
2762
- if (argType === 'number') {
2763
- var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
2764
- if (result.err) {
2765
- return result;
2766
- }
2767
- return {
2768
- val: { type: TYPE.number, value: value, location: location_1, style: result.val },
2769
- err: null,
2770
- };
2771
- }
2772
- else {
2773
- if (skeleton.length === 0) {
2774
- return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
2775
- }
2776
- var dateTimePattern = skeleton;
2777
- // Get "best match" pattern only if locale is passed, if not, let it
2778
- // pass as-is where `parseDateTimeSkeleton()` will throw an error
2779
- // for unsupported patterns.
2780
- if (this.locale) {
2781
- dateTimePattern = getBestPattern(skeleton, this.locale);
2782
- }
2783
- var style = {
2784
- type: SKELETON_TYPE.dateTime,
2785
- pattern: dateTimePattern,
2786
- location: styleAndLocation.styleLocation,
2787
- parsedOptions: this.shouldParseSkeletons
2788
- ? parseDateTimeSkeleton(dateTimePattern)
2789
- : {},
2790
- };
2791
- var type = argType === 'date' ? TYPE.date : TYPE.time;
2792
- return {
2793
- val: { type: type, value: value, location: location_1, style: style },
2794
- err: null,
2795
- };
2796
- }
2797
- }
2798
- // Regular style or no style.
2799
- return {
2800
- val: {
2801
- type: argType === 'number'
2802
- ? TYPE.number
2803
- : argType === 'date'
2804
- ? TYPE.date
2805
- : TYPE.time,
2806
- value: value,
2807
- location: location_1,
2808
- style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
2809
- },
2810
- err: null,
2811
- };
2812
- }
2813
- case 'plural':
2814
- case 'selectordinal':
2815
- case 'select': {
2816
- // Parse this range:
2817
- // {name, plural, options}
2818
- // ^---------^
2819
- var typeEndPosition_1 = this.clonePosition();
2820
- this.bumpSpace();
2821
- if (!this.bumpIf(',')) {
2822
- return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
2823
- }
2824
- this.bumpSpace();
2825
- // Parse offset:
2826
- // {name, plural, offset:1, options}
2827
- // ^-----^
2828
- //
2829
- // or the first option:
2830
- //
2831
- // {name, plural, one {...} other {...}}
2832
- // ^--^
2833
- var identifierAndLocation = this.parseIdentifierIfPossible();
2834
- var pluralOffset = 0;
2835
- if (argType !== 'select' && identifierAndLocation.value === 'offset') {
2836
- if (!this.bumpIf(':')) {
2837
- return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
2838
- }
2839
- this.bumpSpace();
2840
- var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
2841
- if (result.err) {
2842
- return result;
2843
- }
2844
- // Parse another identifier for option parsing
2845
- this.bumpSpace();
2846
- identifierAndLocation = this.parseIdentifierIfPossible();
2847
- pluralOffset = result.val;
2848
- }
2849
- var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
2850
- if (optionsResult.err) {
2851
- return optionsResult;
2852
- }
2853
- var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
2854
- if (argCloseResult.err) {
2855
- return argCloseResult;
2856
- }
2857
- var location_2 = createLocation(openingBracePosition, this.clonePosition());
2858
- if (argType === 'select') {
2859
- return {
2860
- val: {
2861
- type: TYPE.select,
2862
- value: value,
2863
- options: fromEntries(optionsResult.val),
2864
- location: location_2,
2865
- },
2866
- err: null,
2867
- };
2868
- }
2869
- else {
2870
- return {
2871
- val: {
2872
- type: TYPE.plural,
2873
- value: value,
2874
- options: fromEntries(optionsResult.val),
2875
- offset: pluralOffset,
2876
- pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
2877
- location: location_2,
2878
- },
2879
- err: null,
2880
- };
2881
- }
2882
- }
2883
- default:
2884
- return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
2885
- }
2886
- };
2887
- Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
2888
- // Parse: {value, number, ::currency/GBP }
2889
- //
2890
- if (this.isEOF() || this.char() !== 125 /* `}` */) {
2891
- return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2892
- }
2893
- this.bump(); // `}`
2894
- return { val: true, err: null };
2895
- };
2896
- /**
2897
- * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
2898
- */
2899
- Parser.prototype.parseSimpleArgStyleIfPossible = function () {
2900
- var nestedBraces = 0;
2901
- var startPosition = this.clonePosition();
2902
- while (!this.isEOF()) {
2903
- var ch = this.char();
2904
- switch (ch) {
2905
- case 39 /* `'` */: {
2906
- // Treat apostrophe as quoting but include it in the style part.
2907
- // Find the end of the quoted literal text.
2908
- this.bump();
2909
- var apostrophePosition = this.clonePosition();
2910
- if (!this.bumpUntil("'")) {
2911
- return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
2912
- }
2913
- this.bump();
2914
- break;
2915
- }
2916
- case 123 /* `{` */: {
2917
- nestedBraces += 1;
2918
- this.bump();
2919
- break;
2920
- }
2921
- case 125 /* `}` */: {
2922
- if (nestedBraces > 0) {
2923
- nestedBraces -= 1;
2924
- }
2925
- else {
2926
- return {
2927
- val: this.message.slice(startPosition.offset, this.offset()),
2928
- err: null,
2929
- };
2930
- }
2931
- break;
2932
- }
2933
- default:
2934
- this.bump();
2935
- break;
2936
- }
2937
- }
2938
- return {
2939
- val: this.message.slice(startPosition.offset, this.offset()),
2940
- err: null,
2941
- };
2942
- };
2943
- Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
2944
- var tokens = [];
2945
- try {
2946
- tokens = parseNumberSkeletonFromString(skeleton);
2947
- }
2948
- catch (e) {
2949
- return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
2950
- }
2951
- return {
2952
- val: {
2953
- type: SKELETON_TYPE.number,
2954
- tokens: tokens,
2955
- location: location,
2956
- parsedOptions: this.shouldParseSkeletons
2957
- ? parseNumberSkeleton(tokens)
2958
- : {},
2959
- },
2960
- err: null,
2961
- };
2962
- };
2963
- /**
2964
- * @param nesting_level The current nesting level of messages.
2965
- * This can be positive when parsing message fragment in select or plural argument options.
2966
- * @param parent_arg_type The parent argument's type.
2967
- * @param parsed_first_identifier If provided, this is the first identifier-like selector of
2968
- * the argument. It is a by-product of a previous parsing attempt.
2969
- * @param expecting_close_tag If true, this message is directly or indirectly nested inside
2970
- * between a pair of opening and closing tags. The nested message will not parse beyond
2971
- * the closing tag boundary.
2972
- */
2973
- Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
2974
- var _a;
2975
- var hasOtherClause = false;
2976
- var options = [];
2977
- var parsedSelectors = new Set();
2978
- var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
2979
- // Parse:
2980
- // one {one apple}
2981
- // ^--^
2982
- while (true) {
2983
- if (selector.length === 0) {
2984
- var startPosition = this.clonePosition();
2985
- if (parentArgType !== 'select' && this.bumpIf('=')) {
2986
- // Try parse `={number}` selector
2987
- var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
2988
- if (result.err) {
2989
- return result;
2990
- }
2991
- selectorLocation = createLocation(startPosition, this.clonePosition());
2992
- selector = this.message.slice(startPosition.offset, this.offset());
2993
- }
2994
- else {
2995
- break;
2996
- }
2997
- }
2998
- // Duplicate selector clauses
2999
- if (parsedSelectors.has(selector)) {
3000
- return this.error(parentArgType === 'select'
3001
- ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
3002
- : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
3003
- }
3004
- if (selector === 'other') {
3005
- hasOtherClause = true;
3006
- }
3007
- // Parse:
3008
- // one {one apple}
3009
- // ^----------^
3010
- this.bumpSpace();
3011
- var openingBracePosition = this.clonePosition();
3012
- if (!this.bumpIf('{')) {
3013
- return this.error(parentArgType === 'select'
3014
- ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
3015
- : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
3016
- }
3017
- var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
3018
- if (fragmentResult.err) {
3019
- return fragmentResult;
3020
- }
3021
- var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3022
- if (argCloseResult.err) {
3023
- return argCloseResult;
3024
- }
3025
- options.push([
3026
- selector,
3027
- {
3028
- value: fragmentResult.val,
3029
- location: createLocation(openingBracePosition, this.clonePosition()),
3030
- },
3031
- ]);
3032
- // Keep track of the existing selectors
3033
- parsedSelectors.add(selector);
3034
- // Prep next selector clause.
3035
- this.bumpSpace();
3036
- (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
3037
- }
3038
- if (options.length === 0) {
3039
- return this.error(parentArgType === 'select'
3040
- ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
3041
- : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
3042
- }
3043
- if (this.requiresOtherClause && !hasOtherClause) {
3044
- return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
3045
- }
3046
- return { val: options, err: null };
3047
- };
3048
- Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
3049
- var sign = 1;
3050
- var startingPosition = this.clonePosition();
3051
- if (this.bumpIf('+')) ;
3052
- else if (this.bumpIf('-')) {
3053
- sign = -1;
3054
- }
3055
- var hasDigits = false;
3056
- var decimal = 0;
3057
- while (!this.isEOF()) {
3058
- var ch = this.char();
3059
- if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
3060
- hasDigits = true;
3061
- decimal = decimal * 10 + (ch - 48);
3062
- this.bump();
3063
- }
3064
- else {
3065
- break;
3066
- }
3067
- }
3068
- var location = createLocation(startingPosition, this.clonePosition());
3069
- if (!hasDigits) {
3070
- return this.error(expectNumberError, location);
3071
- }
3072
- decimal *= sign;
3073
- if (!isSafeInteger(decimal)) {
3074
- return this.error(invalidNumberError, location);
3075
- }
3076
- return { val: decimal, err: null };
3077
- };
3078
- Parser.prototype.offset = function () {
3079
- return this.position.offset;
3080
- };
3081
- Parser.prototype.isEOF = function () {
3082
- return this.offset() === this.message.length;
3083
- };
3084
- Parser.prototype.clonePosition = function () {
3085
- // This is much faster than `Object.assign` or spread.
3086
- return {
3087
- offset: this.position.offset,
3088
- line: this.position.line,
3089
- column: this.position.column,
3090
- };
3091
- };
3092
- /**
3093
- * Return the code point at the current position of the parser.
3094
- * Throws if the index is out of bound.
3095
- */
3096
- Parser.prototype.char = function () {
3097
- var offset = this.position.offset;
3098
- if (offset >= this.message.length) {
3099
- throw Error('out of bound');
3100
- }
3101
- var code = codePointAt(this.message, offset);
3102
- if (code === undefined) {
3103
- throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
3104
- }
3105
- return code;
3106
- };
3107
- Parser.prototype.error = function (kind, location) {
3108
- return {
3109
- val: null,
3110
- err: {
3111
- kind: kind,
3112
- message: this.message,
3113
- location: location,
3114
- },
3115
- };
3116
- };
3117
- /** Bump the parser to the next UTF-16 code unit. */
3118
- Parser.prototype.bump = function () {
3119
- if (this.isEOF()) {
3120
- return;
3121
- }
3122
- var code = this.char();
3123
- if (code === 10 /* '\n' */) {
3124
- this.position.line += 1;
3125
- this.position.column = 1;
3126
- this.position.offset += 1;
3127
- }
3128
- else {
3129
- this.position.column += 1;
3130
- // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
3131
- this.position.offset += code < 0x10000 ? 1 : 2;
3132
- }
3133
- };
3134
- /**
3135
- * If the substring starting at the current position of the parser has
3136
- * the given prefix, then bump the parser to the character immediately
3137
- * following the prefix and return true. Otherwise, don't bump the parser
3138
- * and return false.
3139
- */
3140
- Parser.prototype.bumpIf = function (prefix) {
3141
- if (startsWith(this.message, prefix, this.offset())) {
3142
- for (var i = 0; i < prefix.length; i++) {
3143
- this.bump();
3144
- }
3145
- return true;
3146
- }
3147
- return false;
3148
- };
3149
- /**
3150
- * Bump the parser until the pattern character is found and return `true`.
3151
- * Otherwise bump to the end of the file and return `false`.
3152
- */
3153
- Parser.prototype.bumpUntil = function (pattern) {
3154
- var currentOffset = this.offset();
3155
- var index = this.message.indexOf(pattern, currentOffset);
3156
- if (index >= 0) {
3157
- this.bumpTo(index);
3158
- return true;
3159
- }
3160
- else {
3161
- this.bumpTo(this.message.length);
3162
- return false;
3163
- }
3164
- };
3165
- /**
3166
- * Bump the parser to the target offset.
3167
- * If target offset is beyond the end of the input, bump the parser to the end of the input.
3168
- */
3169
- Parser.prototype.bumpTo = function (targetOffset) {
3170
- if (this.offset() > targetOffset) {
3171
- throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
3172
- }
3173
- targetOffset = Math.min(targetOffset, this.message.length);
3174
- while (true) {
3175
- var offset = this.offset();
3176
- if (offset === targetOffset) {
3177
- break;
3178
- }
3179
- if (offset > targetOffset) {
3180
- throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
3181
- }
3182
- this.bump();
3183
- if (this.isEOF()) {
3184
- break;
3185
- }
3186
- }
3187
- };
3188
- /** advance the parser through all whitespace to the next non-whitespace code unit. */
3189
- Parser.prototype.bumpSpace = function () {
3190
- while (!this.isEOF() && _isWhiteSpace(this.char())) {
3191
- this.bump();
3192
- }
3193
- };
3194
- /**
3195
- * Peek at the *next* Unicode codepoint in the input without advancing the parser.
3196
- * If the input has been exhausted, then this returns null.
3197
- */
3198
- Parser.prototype.peek = function () {
3199
- if (this.isEOF()) {
3200
- return null;
3201
- }
3202
- var code = this.char();
3203
- var offset = this.offset();
3204
- var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
3205
- return nextCode !== null && nextCode !== void 0 ? nextCode : null;
3206
- };
3207
- return Parser;
3208
- }());
3209
- /**
3210
- * This check if codepoint is alphabet (lower & uppercase)
3211
- * @param codepoint
3212
- * @returns
3213
- */
3214
- function _isAlpha(codepoint) {
3215
- return ((codepoint >= 97 && codepoint <= 122) ||
3216
- (codepoint >= 65 && codepoint <= 90));
3217
- }
3218
- function _isAlphaOrSlash(codepoint) {
3219
- return _isAlpha(codepoint) || codepoint === 47; /* '/' */
3220
- }
3221
- /** See `parseTag` function docs. */
3222
- function _isPotentialElementNameChar(c) {
3223
- return (c === 45 /* '-' */ ||
3224
- c === 46 /* '.' */ ||
3225
- (c >= 48 && c <= 57) /* 0..9 */ ||
3226
- c === 95 /* '_' */ ||
3227
- (c >= 97 && c <= 122) /** a..z */ ||
3228
- (c >= 65 && c <= 90) /* A..Z */ ||
3229
- c == 0xb7 ||
3230
- (c >= 0xc0 && c <= 0xd6) ||
3231
- (c >= 0xd8 && c <= 0xf6) ||
3232
- (c >= 0xf8 && c <= 0x37d) ||
3233
- (c >= 0x37f && c <= 0x1fff) ||
3234
- (c >= 0x200c && c <= 0x200d) ||
3235
- (c >= 0x203f && c <= 0x2040) ||
3236
- (c >= 0x2070 && c <= 0x218f) ||
3237
- (c >= 0x2c00 && c <= 0x2fef) ||
3238
- (c >= 0x3001 && c <= 0xd7ff) ||
3239
- (c >= 0xf900 && c <= 0xfdcf) ||
3240
- (c >= 0xfdf0 && c <= 0xfffd) ||
3241
- (c >= 0x10000 && c <= 0xeffff));
3242
- }
3243
- /**
3244
- * Code point equivalent of regex `\p{White_Space}`.
3245
- * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3246
- */
3247
- function _isWhiteSpace(c) {
3248
- return ((c >= 0x0009 && c <= 0x000d) ||
3249
- c === 0x0020 ||
3250
- c === 0x0085 ||
3251
- (c >= 0x200e && c <= 0x200f) ||
3252
- c === 0x2028 ||
3253
- c === 0x2029);
3254
- }
3255
- /**
3256
- * Code point equivalent of regex `\p{Pattern_Syntax}`.
3257
- * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3258
- */
3259
- function _isPatternSyntax(c) {
3260
- return ((c >= 0x0021 && c <= 0x0023) ||
3261
- c === 0x0024 ||
3262
- (c >= 0x0025 && c <= 0x0027) ||
3263
- c === 0x0028 ||
3264
- c === 0x0029 ||
3265
- c === 0x002a ||
3266
- c === 0x002b ||
3267
- c === 0x002c ||
3268
- c === 0x002d ||
3269
- (c >= 0x002e && c <= 0x002f) ||
3270
- (c >= 0x003a && c <= 0x003b) ||
3271
- (c >= 0x003c && c <= 0x003e) ||
3272
- (c >= 0x003f && c <= 0x0040) ||
3273
- c === 0x005b ||
3274
- c === 0x005c ||
3275
- c === 0x005d ||
3276
- c === 0x005e ||
3277
- c === 0x0060 ||
3278
- c === 0x007b ||
3279
- c === 0x007c ||
3280
- c === 0x007d ||
3281
- c === 0x007e ||
3282
- c === 0x00a1 ||
3283
- (c >= 0x00a2 && c <= 0x00a5) ||
3284
- c === 0x00a6 ||
3285
- c === 0x00a7 ||
3286
- c === 0x00a9 ||
3287
- c === 0x00ab ||
3288
- c === 0x00ac ||
3289
- c === 0x00ae ||
3290
- c === 0x00b0 ||
3291
- c === 0x00b1 ||
3292
- c === 0x00b6 ||
3293
- c === 0x00bb ||
3294
- c === 0x00bf ||
3295
- c === 0x00d7 ||
3296
- c === 0x00f7 ||
3297
- (c >= 0x2010 && c <= 0x2015) ||
3298
- (c >= 0x2016 && c <= 0x2017) ||
3299
- c === 0x2018 ||
3300
- c === 0x2019 ||
3301
- c === 0x201a ||
3302
- (c >= 0x201b && c <= 0x201c) ||
3303
- c === 0x201d ||
3304
- c === 0x201e ||
3305
- c === 0x201f ||
3306
- (c >= 0x2020 && c <= 0x2027) ||
3307
- (c >= 0x2030 && c <= 0x2038) ||
3308
- c === 0x2039 ||
3309
- c === 0x203a ||
3310
- (c >= 0x203b && c <= 0x203e) ||
3311
- (c >= 0x2041 && c <= 0x2043) ||
3312
- c === 0x2044 ||
3313
- c === 0x2045 ||
3314
- c === 0x2046 ||
3315
- (c >= 0x2047 && c <= 0x2051) ||
3316
- c === 0x2052 ||
3317
- c === 0x2053 ||
3318
- (c >= 0x2055 && c <= 0x205e) ||
3319
- (c >= 0x2190 && c <= 0x2194) ||
3320
- (c >= 0x2195 && c <= 0x2199) ||
3321
- (c >= 0x219a && c <= 0x219b) ||
3322
- (c >= 0x219c && c <= 0x219f) ||
3323
- c === 0x21a0 ||
3324
- (c >= 0x21a1 && c <= 0x21a2) ||
3325
- c === 0x21a3 ||
3326
- (c >= 0x21a4 && c <= 0x21a5) ||
3327
- c === 0x21a6 ||
3328
- (c >= 0x21a7 && c <= 0x21ad) ||
3329
- c === 0x21ae ||
3330
- (c >= 0x21af && c <= 0x21cd) ||
3331
- (c >= 0x21ce && c <= 0x21cf) ||
3332
- (c >= 0x21d0 && c <= 0x21d1) ||
3333
- c === 0x21d2 ||
3334
- c === 0x21d3 ||
3335
- c === 0x21d4 ||
3336
- (c >= 0x21d5 && c <= 0x21f3) ||
3337
- (c >= 0x21f4 && c <= 0x22ff) ||
3338
- (c >= 0x2300 && c <= 0x2307) ||
3339
- c === 0x2308 ||
3340
- c === 0x2309 ||
3341
- c === 0x230a ||
3342
- c === 0x230b ||
3343
- (c >= 0x230c && c <= 0x231f) ||
3344
- (c >= 0x2320 && c <= 0x2321) ||
3345
- (c >= 0x2322 && c <= 0x2328) ||
3346
- c === 0x2329 ||
3347
- c === 0x232a ||
3348
- (c >= 0x232b && c <= 0x237b) ||
3349
- c === 0x237c ||
3350
- (c >= 0x237d && c <= 0x239a) ||
3351
- (c >= 0x239b && c <= 0x23b3) ||
3352
- (c >= 0x23b4 && c <= 0x23db) ||
3353
- (c >= 0x23dc && c <= 0x23e1) ||
3354
- (c >= 0x23e2 && c <= 0x2426) ||
3355
- (c >= 0x2427 && c <= 0x243f) ||
3356
- (c >= 0x2440 && c <= 0x244a) ||
3357
- (c >= 0x244b && c <= 0x245f) ||
3358
- (c >= 0x2500 && c <= 0x25b6) ||
3359
- c === 0x25b7 ||
3360
- (c >= 0x25b8 && c <= 0x25c0) ||
3361
- c === 0x25c1 ||
3362
- (c >= 0x25c2 && c <= 0x25f7) ||
3363
- (c >= 0x25f8 && c <= 0x25ff) ||
3364
- (c >= 0x2600 && c <= 0x266e) ||
3365
- c === 0x266f ||
3366
- (c >= 0x2670 && c <= 0x2767) ||
3367
- c === 0x2768 ||
3368
- c === 0x2769 ||
3369
- c === 0x276a ||
3370
- c === 0x276b ||
3371
- c === 0x276c ||
3372
- c === 0x276d ||
3373
- c === 0x276e ||
3374
- c === 0x276f ||
3375
- c === 0x2770 ||
3376
- c === 0x2771 ||
3377
- c === 0x2772 ||
3378
- c === 0x2773 ||
3379
- c === 0x2774 ||
3380
- c === 0x2775 ||
3381
- (c >= 0x2794 && c <= 0x27bf) ||
3382
- (c >= 0x27c0 && c <= 0x27c4) ||
3383
- c === 0x27c5 ||
3384
- c === 0x27c6 ||
3385
- (c >= 0x27c7 && c <= 0x27e5) ||
3386
- c === 0x27e6 ||
3387
- c === 0x27e7 ||
3388
- c === 0x27e8 ||
3389
- c === 0x27e9 ||
3390
- c === 0x27ea ||
3391
- c === 0x27eb ||
3392
- c === 0x27ec ||
3393
- c === 0x27ed ||
3394
- c === 0x27ee ||
3395
- c === 0x27ef ||
3396
- (c >= 0x27f0 && c <= 0x27ff) ||
3397
- (c >= 0x2800 && c <= 0x28ff) ||
3398
- (c >= 0x2900 && c <= 0x2982) ||
3399
- c === 0x2983 ||
3400
- c === 0x2984 ||
3401
- c === 0x2985 ||
3402
- c === 0x2986 ||
3403
- c === 0x2987 ||
3404
- c === 0x2988 ||
3405
- c === 0x2989 ||
3406
- c === 0x298a ||
3407
- c === 0x298b ||
3408
- c === 0x298c ||
3409
- c === 0x298d ||
3410
- c === 0x298e ||
3411
- c === 0x298f ||
3412
- c === 0x2990 ||
3413
- c === 0x2991 ||
3414
- c === 0x2992 ||
3415
- c === 0x2993 ||
3416
- c === 0x2994 ||
3417
- c === 0x2995 ||
3418
- c === 0x2996 ||
3419
- c === 0x2997 ||
3420
- c === 0x2998 ||
3421
- (c >= 0x2999 && c <= 0x29d7) ||
3422
- c === 0x29d8 ||
3423
- c === 0x29d9 ||
3424
- c === 0x29da ||
3425
- c === 0x29db ||
3426
- (c >= 0x29dc && c <= 0x29fb) ||
3427
- c === 0x29fc ||
3428
- c === 0x29fd ||
3429
- (c >= 0x29fe && c <= 0x2aff) ||
3430
- (c >= 0x2b00 && c <= 0x2b2f) ||
3431
- (c >= 0x2b30 && c <= 0x2b44) ||
3432
- (c >= 0x2b45 && c <= 0x2b46) ||
3433
- (c >= 0x2b47 && c <= 0x2b4c) ||
3434
- (c >= 0x2b4d && c <= 0x2b73) ||
3435
- (c >= 0x2b74 && c <= 0x2b75) ||
3436
- (c >= 0x2b76 && c <= 0x2b95) ||
3437
- c === 0x2b96 ||
3438
- (c >= 0x2b97 && c <= 0x2bff) ||
3439
- (c >= 0x2e00 && c <= 0x2e01) ||
3440
- c === 0x2e02 ||
3441
- c === 0x2e03 ||
3442
- c === 0x2e04 ||
3443
- c === 0x2e05 ||
3444
- (c >= 0x2e06 && c <= 0x2e08) ||
3445
- c === 0x2e09 ||
3446
- c === 0x2e0a ||
3447
- c === 0x2e0b ||
3448
- c === 0x2e0c ||
3449
- c === 0x2e0d ||
3450
- (c >= 0x2e0e && c <= 0x2e16) ||
3451
- c === 0x2e17 ||
3452
- (c >= 0x2e18 && c <= 0x2e19) ||
3453
- c === 0x2e1a ||
3454
- c === 0x2e1b ||
3455
- c === 0x2e1c ||
3456
- c === 0x2e1d ||
3457
- (c >= 0x2e1e && c <= 0x2e1f) ||
3458
- c === 0x2e20 ||
3459
- c === 0x2e21 ||
3460
- c === 0x2e22 ||
3461
- c === 0x2e23 ||
3462
- c === 0x2e24 ||
3463
- c === 0x2e25 ||
3464
- c === 0x2e26 ||
3465
- c === 0x2e27 ||
3466
- c === 0x2e28 ||
3467
- c === 0x2e29 ||
3468
- (c >= 0x2e2a && c <= 0x2e2e) ||
3469
- c === 0x2e2f ||
3470
- (c >= 0x2e30 && c <= 0x2e39) ||
3471
- (c >= 0x2e3a && c <= 0x2e3b) ||
3472
- (c >= 0x2e3c && c <= 0x2e3f) ||
3473
- c === 0x2e40 ||
3474
- c === 0x2e41 ||
3475
- c === 0x2e42 ||
3476
- (c >= 0x2e43 && c <= 0x2e4f) ||
3477
- (c >= 0x2e50 && c <= 0x2e51) ||
3478
- c === 0x2e52 ||
3479
- (c >= 0x2e53 && c <= 0x2e7f) ||
3480
- (c >= 0x3001 && c <= 0x3003) ||
3481
- c === 0x3008 ||
3482
- c === 0x3009 ||
3483
- c === 0x300a ||
3484
- c === 0x300b ||
3485
- c === 0x300c ||
3486
- c === 0x300d ||
3487
- c === 0x300e ||
3488
- c === 0x300f ||
3489
- c === 0x3010 ||
3490
- c === 0x3011 ||
3491
- (c >= 0x3012 && c <= 0x3013) ||
3492
- c === 0x3014 ||
3493
- c === 0x3015 ||
3494
- c === 0x3016 ||
3495
- c === 0x3017 ||
3496
- c === 0x3018 ||
3497
- c === 0x3019 ||
3498
- c === 0x301a ||
3499
- c === 0x301b ||
3500
- c === 0x301c ||
3501
- c === 0x301d ||
3502
- (c >= 0x301e && c <= 0x301f) ||
3503
- c === 0x3020 ||
3504
- c === 0x3030 ||
3505
- c === 0xfd3e ||
3506
- c === 0xfd3f ||
3507
- (c >= 0xfe45 && c <= 0xfe46));
3508
- }
3509
-
3510
- function pruneLocation(els) {
3511
- els.forEach(function (el) {
3512
- delete el.location;
3513
- if (isSelectElement(el) || isPluralElement(el)) {
3514
- for (var k in el.options) {
3515
- delete el.options[k].location;
3516
- pruneLocation(el.options[k].value);
3517
- }
3518
- }
3519
- else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
3520
- delete el.style.location;
3521
- }
3522
- else if ((isDateElement(el) || isTimeElement(el)) &&
3523
- isDateTimeSkeleton(el.style)) {
3524
- delete el.style.location;
3525
- }
3526
- else if (isTagElement(el)) {
3527
- pruneLocation(el.children);
3528
- }
3529
- });
3530
- }
3531
- function parse(message, opts) {
3532
- if (opts === void 0) { opts = {}; }
3533
- opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
3534
- var result = new Parser(message, opts).parse();
3535
- if (result.err) {
3536
- var error = SyntaxError(ErrorKind[result.err.kind]);
3537
- // @ts-expect-error Assign to error object
3538
- error.location = result.err.location;
3539
- // @ts-expect-error Assign to error object
3540
- error.originalMessage = result.err.message;
3541
- throw error;
3542
- }
3543
- if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
3544
- pruneLocation(result.val);
3545
- }
3546
- return result.val;
3547
- }
3548
-
3549
- var ErrorCode;
3550
- (function (ErrorCode) {
3551
- // When we have a placeholder but no value to format
3552
- ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
3553
- // When value supplied is invalid
3554
- ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
3555
- // When we need specific Intl API but it's not available
3556
- ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
3557
- })(ErrorCode || (ErrorCode = {}));
3558
- var FormatError = /** @class */ (function (_super) {
3559
- __extends(FormatError, _super);
3560
- function FormatError(msg, code, originalMessage) {
3561
- var _this = _super.call(this, msg) || this;
3562
- _this.code = code;
3563
- _this.originalMessage = originalMessage;
3564
- return _this;
3565
- }
3566
- FormatError.prototype.toString = function () {
3567
- return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
3568
- };
3569
- return FormatError;
3570
- }(Error));
3571
- var InvalidValueError = /** @class */ (function (_super) {
3572
- __extends(InvalidValueError, _super);
3573
- function InvalidValueError(variableId, value, options, originalMessage) {
3574
- return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
3575
- }
3576
- return InvalidValueError;
3577
- }(FormatError));
3578
- var InvalidValueTypeError = /** @class */ (function (_super) {
3579
- __extends(InvalidValueTypeError, _super);
3580
- function InvalidValueTypeError(value, type, originalMessage) {
3581
- return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
3582
- }
3583
- return InvalidValueTypeError;
3584
- }(FormatError));
3585
- var MissingValueError = /** @class */ (function (_super) {
3586
- __extends(MissingValueError, _super);
3587
- function MissingValueError(variableId, originalMessage) {
3588
- return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
3589
- }
3590
- return MissingValueError;
3591
- }(FormatError));
3592
-
3593
- var PART_TYPE;
3594
- (function (PART_TYPE) {
3595
- PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
3596
- PART_TYPE[PART_TYPE["object"] = 1] = "object";
3597
- })(PART_TYPE || (PART_TYPE = {}));
3598
- function mergeLiteral(parts) {
3599
- if (parts.length < 2) {
3600
- return parts;
3601
- }
3602
- return parts.reduce(function (all, part) {
3603
- var lastPart = all[all.length - 1];
3604
- if (!lastPart ||
3605
- lastPart.type !== PART_TYPE.literal ||
3606
- part.type !== PART_TYPE.literal) {
3607
- all.push(part);
3608
- }
3609
- else {
3610
- lastPart.value += part.value;
3611
- }
3612
- return all;
3613
- }, []);
3614
- }
3615
- function isFormatXMLElementFn(el) {
3616
- return typeof el === 'function';
3617
- }
3618
- // TODO(skeleton): add skeleton support
3619
- function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
3620
- // For debugging
3621
- originalMessage) {
3622
- // Hot path for straight simple msg translations
3623
- if (els.length === 1 && isLiteralElement(els[0])) {
3624
- return [
3625
- {
3626
- type: PART_TYPE.literal,
3627
- value: els[0].value,
3628
- },
3629
- ];
3630
- }
3631
- var result = [];
3632
- for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
3633
- var el = els_1[_i];
3634
- // Exit early for string parts.
3635
- if (isLiteralElement(el)) {
3636
- result.push({
3637
- type: PART_TYPE.literal,
3638
- value: el.value,
3639
- });
3640
- continue;
3641
- }
3642
- // TODO: should this part be literal type?
3643
- // Replace `#` in plural rules with the actual numeric value.
3644
- if (isPoundElement(el)) {
3645
- if (typeof currentPluralValue === 'number') {
3646
- result.push({
3647
- type: PART_TYPE.literal,
3648
- value: formatters.getNumberFormat(locales).format(currentPluralValue),
3649
- });
3650
- }
3651
- continue;
3652
- }
3653
- var varName = el.value;
3654
- // Enforce that all required values are provided by the caller.
3655
- if (!(values && varName in values)) {
3656
- throw new MissingValueError(varName, originalMessage);
3657
- }
3658
- var value = values[varName];
3659
- if (isArgumentElement(el)) {
3660
- if (!value || typeof value === 'string' || typeof value === 'number') {
3661
- value =
3662
- typeof value === 'string' || typeof value === 'number'
3663
- ? String(value)
3664
- : '';
3665
- }
3666
- result.push({
3667
- type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
3668
- value: value,
3669
- });
3670
- continue;
3671
- }
3672
- // Recursively format plural and select parts' option — which can be a
3673
- // nested pattern structure. The choosing of the option to use is
3674
- // abstracted-by and delegated-to the part helper object.
3675
- if (isDateElement(el)) {
3676
- var style = typeof el.style === 'string'
3677
- ? formats.date[el.style]
3678
- : isDateTimeSkeleton(el.style)
3679
- ? el.style.parsedOptions
3680
- : undefined;
3681
- result.push({
3682
- type: PART_TYPE.literal,
3683
- value: formatters
3684
- .getDateTimeFormat(locales, style)
3685
- .format(value),
3686
- });
3687
- continue;
3688
- }
3689
- if (isTimeElement(el)) {
3690
- var style = typeof el.style === 'string'
3691
- ? formats.time[el.style]
3692
- : isDateTimeSkeleton(el.style)
3693
- ? el.style.parsedOptions
3694
- : formats.time.medium;
3695
- result.push({
3696
- type: PART_TYPE.literal,
3697
- value: formatters
3698
- .getDateTimeFormat(locales, style)
3699
- .format(value),
3700
- });
3701
- continue;
3702
- }
3703
- if (isNumberElement(el)) {
3704
- var style = typeof el.style === 'string'
3705
- ? formats.number[el.style]
3706
- : isNumberSkeleton(el.style)
3707
- ? el.style.parsedOptions
3708
- : undefined;
3709
- if (style && style.scale) {
3710
- value =
3711
- value *
3712
- (style.scale || 1);
3713
- }
3714
- result.push({
3715
- type: PART_TYPE.literal,
3716
- value: formatters
3717
- .getNumberFormat(locales, style)
3718
- .format(value),
3719
- });
3720
- continue;
3721
- }
3722
- if (isTagElement(el)) {
3723
- var children = el.children, value_1 = el.value;
3724
- var formatFn = values[value_1];
3725
- if (!isFormatXMLElementFn(formatFn)) {
3726
- throw new InvalidValueTypeError(value_1, 'function', originalMessage);
3727
- }
3728
- var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
3729
- var chunks = formatFn(parts.map(function (p) { return p.value; }));
3730
- if (!Array.isArray(chunks)) {
3731
- chunks = [chunks];
3732
- }
3733
- result.push.apply(result, chunks.map(function (c) {
3734
- return {
3735
- type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
3736
- value: c,
3737
- };
3738
- }));
3739
- }
3740
- if (isSelectElement(el)) {
3741
- var opt = el.options[value] || el.options.other;
3742
- if (!opt) {
3743
- throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
3744
- }
3745
- result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
3746
- continue;
3747
- }
3748
- if (isPluralElement(el)) {
3749
- var opt = el.options["=".concat(value)];
3750
- if (!opt) {
3751
- if (!Intl.PluralRules) {
3752
- throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
3753
- }
3754
- var rule = formatters
3755
- .getPluralRules(locales, { type: el.pluralType })
3756
- .select(value - (el.offset || 0));
3757
- opt = el.options[rule] || el.options.other;
3758
- }
3759
- if (!opt) {
3760
- throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
3761
- }
3762
- result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
3763
- continue;
3764
- }
3765
- }
3766
- return mergeLiteral(result);
3767
- }
3768
-
3769
- /*
3770
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
3771
- Copyrights licensed under the New BSD License.
3772
- See the accompanying LICENSE file for terms.
3773
- */
3774
- // -- MessageFormat --------------------------------------------------------
3775
- function mergeConfig(c1, c2) {
3776
- if (!c2) {
3777
- return c1;
3778
- }
3779
- return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
3780
- all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
3781
- return all;
3782
- }, {}));
3783
- }
3784
- function mergeConfigs(defaultConfig, configs) {
3785
- if (!configs) {
3786
- return defaultConfig;
3787
- }
3788
- return Object.keys(defaultConfig).reduce(function (all, k) {
3789
- all[k] = mergeConfig(defaultConfig[k], configs[k]);
3790
- return all;
3791
- }, __assign({}, defaultConfig));
3792
- }
3793
- function createFastMemoizeCache(store) {
3794
- return {
3795
- create: function () {
3796
- return {
3797
- get: function (key) {
3798
- return store[key];
3799
- },
3800
- set: function (key, value) {
3801
- store[key] = value;
3802
- },
3803
- };
3804
- },
3805
- };
3806
- }
3807
- function createDefaultFormatters(cache) {
3808
- if (cache === void 0) { cache = {
3809
- number: {},
3810
- dateTime: {},
3811
- pluralRules: {},
3812
- }; }
3813
- return {
3814
- getNumberFormat: memoize(function () {
3815
- var _a;
3816
- var args = [];
3817
- for (var _i = 0; _i < arguments.length; _i++) {
3818
- args[_i] = arguments[_i];
3819
- }
3820
- return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
3821
- }, {
3822
- cache: createFastMemoizeCache(cache.number),
3823
- strategy: strategies.variadic,
3824
- }),
3825
- getDateTimeFormat: memoize(function () {
3826
- var _a;
3827
- var args = [];
3828
- for (var _i = 0; _i < arguments.length; _i++) {
3829
- args[_i] = arguments[_i];
3830
- }
3831
- return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
3832
- }, {
3833
- cache: createFastMemoizeCache(cache.dateTime),
3834
- strategy: strategies.variadic,
3835
- }),
3836
- getPluralRules: memoize(function () {
3837
- var _a;
3838
- var args = [];
3839
- for (var _i = 0; _i < arguments.length; _i++) {
3840
- args[_i] = arguments[_i];
3841
- }
3842
- return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
3843
- }, {
3844
- cache: createFastMemoizeCache(cache.pluralRules),
3845
- strategy: strategies.variadic,
3846
- }),
3847
- };
3848
- }
3849
- var IntlMessageFormat = /** @class */ (function () {
3850
- function IntlMessageFormat(message, locales, overrideFormats, opts) {
3851
- if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
3852
- var _this = this;
3853
- this.formatterCache = {
3854
- number: {},
3855
- dateTime: {},
3856
- pluralRules: {},
3857
- };
3858
- this.format = function (values) {
3859
- var parts = _this.formatToParts(values);
3860
- // Hot path for straight simple msg translations
3861
- if (parts.length === 1) {
3862
- return parts[0].value;
3863
- }
3864
- var result = parts.reduce(function (all, part) {
3865
- if (!all.length ||
3866
- part.type !== PART_TYPE.literal ||
3867
- typeof all[all.length - 1] !== 'string') {
3868
- all.push(part.value);
3869
- }
3870
- else {
3871
- all[all.length - 1] += part.value;
3872
- }
3873
- return all;
3874
- }, []);
3875
- if (result.length <= 1) {
3876
- return result[0] || '';
3877
- }
3878
- return result;
3879
- };
3880
- this.formatToParts = function (values) {
3881
- return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
3882
- };
3883
- this.resolvedOptions = function () {
3884
- var _a;
3885
- return ({
3886
- locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) ||
3887
- Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
3888
- });
3889
- };
3890
- this.getAst = function () { return _this.ast; };
3891
- // Defined first because it's used to build the format pattern.
3892
- this.locales = locales;
3893
- this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
3894
- if (typeof message === 'string') {
3895
- this.message = message;
3896
- if (!IntlMessageFormat.__parse) {
3897
- throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
3898
- }
3899
- var _a = opts || {}, parseOpts = __rest(_a, ["formatters"]);
3900
- // Parse string messages into an AST.
3901
- this.ast = IntlMessageFormat.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
3902
- }
3903
- else {
3904
- this.ast = message;
3905
- }
3906
- if (!Array.isArray(this.ast)) {
3907
- throw new TypeError('A message must be provided as a String or AST.');
3908
- }
3909
- // Creates a new object with the specified `formats` merged with the default
3910
- // formats.
3911
- this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
3912
- this.formatters =
3913
- (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
3914
- }
3915
- Object.defineProperty(IntlMessageFormat, "defaultLocale", {
3916
- get: function () {
3917
- if (!IntlMessageFormat.memoizedDefaultLocale) {
3918
- IntlMessageFormat.memoizedDefaultLocale =
3919
- new Intl.NumberFormat().resolvedOptions().locale;
3920
- }
3921
- return IntlMessageFormat.memoizedDefaultLocale;
3922
- },
3923
- enumerable: false,
3924
- configurable: true
3925
- });
3926
- IntlMessageFormat.memoizedDefaultLocale = null;
3927
- IntlMessageFormat.resolveLocale = function (locales) {
3928
- if (typeof Intl.Locale === 'undefined') {
3929
- return;
3930
- }
3931
- var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
3932
- if (supportedLocales.length > 0) {
3933
- return new Intl.Locale(supportedLocales[0]);
3934
- }
3935
- return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);
3936
- };
3937
- IntlMessageFormat.__parse = parse;
3938
- // Default format options used as the prototype of the `formats` provided to the
3939
- // constructor. These are used when constructing the internal Intl.NumberFormat
3940
- // and Intl.DateTimeFormat instances.
3941
- IntlMessageFormat.formats = {
3942
- number: {
3943
- integer: {
3944
- maximumFractionDigits: 0,
3945
- },
3946
- currency: {
3947
- style: 'currency',
3948
- },
3949
- percent: {
3950
- style: 'percent',
3951
- },
3952
- },
3953
- date: {
3954
- short: {
3955
- month: 'numeric',
3956
- day: 'numeric',
3957
- year: '2-digit',
3958
- },
3959
- medium: {
3960
- month: 'short',
3961
- day: 'numeric',
3962
- year: 'numeric',
3963
- },
3964
- long: {
3965
- month: 'long',
3966
- day: 'numeric',
3967
- year: 'numeric',
3968
- },
3969
- full: {
3970
- weekday: 'long',
3971
- month: 'long',
3972
- day: 'numeric',
3973
- year: 'numeric',
3974
- },
3975
- },
3976
- time: {
3977
- short: {
3978
- hour: 'numeric',
3979
- minute: 'numeric',
3980
- },
3981
- medium: {
3982
- hour: 'numeric',
3983
- minute: 'numeric',
3984
- second: 'numeric',
3985
- },
3986
- long: {
3987
- hour: 'numeric',
3988
- minute: 'numeric',
3989
- second: 'numeric',
3990
- timeZoneName: 'short',
3991
- },
3992
- full: {
3993
- hour: 'numeric',
3994
- minute: 'numeric',
3995
- second: 'numeric',
3996
- timeZoneName: 'short',
3997
- },
3998
- },
3999
- };
4000
- return IntlMessageFormat;
4001
- }());
4002
-
4003
- const resourceCache = {};
4004
- const determineFetchUrl = (locale = 'en') => index.getAssetPath(`i18n/genesys-webcomponents.i18n.${locale}.json`);
4005
- const fetchResources = async (componentName, locale) => {
4006
- if (!resourceCache[locale]) {
4007
- const url = determineFetchUrl(locale);
4008
- const response = await fetch(url);
4009
- const resources = await response.json();
4010
- resourceCache[locale] = resources;
4011
- }
4012
- return resourceCache[locale][componentName];
4013
- };
4014
-
4015
- var locales = [
4016
- "ar",
4017
- "cs",
4018
- "da",
4019
- "de",
4020
- "en",
4021
- "es-es",
4022
- "es",
4023
- "fi",
4024
- "fr-ca",
4025
- "fr",
4026
- "he",
4027
- "hi",
4028
- "it",
4029
- "ja",
4030
- "ko",
4031
- "nl",
4032
- "no",
4033
- "pl",
4034
- "pt-br",
4035
- "pt-pt",
4036
- "ru",
4037
- "sv",
4038
- "th",
4039
- "tr",
4040
- "uk",
4041
- "zh-cn",
4042
- "zh-tw"
4043
- ];
4044
-
4045
- const ar = 6;
4046
- const cs = 1;
4047
- const da = 1;
4048
- const de = 1;
4049
- const en = 0;
4050
- const es = 1;
4051
- const fi = 1;
4052
- const fr = 1;
4053
- const he = 0;
4054
- const hi = 0;
4055
- const it = 1;
4056
- const ja = 0;
4057
- const ko = 0;
4058
- const nl = 1;
4059
- const no = 1;
4060
- const pl = 1;
4061
- const ru = 1;
4062
- const sv = 1;
4063
- const th = 0;
4064
- const tr = 1;
4065
- const uk = 1;
4066
- var startOfWeekDataUntyped = {
4067
- ar: ar,
4068
- cs: cs,
4069
- da: da,
4070
- de: de,
4071
- en: en,
4072
- "es-es": 1,
4073
- es: es,
4074
- fi: fi,
4075
- "fr-ca": 0,
4076
- fr: fr,
4077
- he: he,
4078
- hi: hi,
4079
- it: it,
4080
- ja: ja,
4081
- ko: ko,
4082
- nl: nl,
4083
- no: no,
4084
- pl: pl,
4085
- "pt-br": 0,
4086
- "pt-pt": 0,
4087
- ru: ru,
4088
- sv: sv,
4089
- th: th,
4090
- tr: tr,
4091
- uk: uk,
4092
- "zh-cn": 1,
4093
- "zh-tw": 0
4094
- };
4095
-
4096
- const DEFAULT_LOCALE = 'en';
4097
- async function buildI18nForComponent(component, defaultResources, parentComponent) {
4098
- let resources = defaultResources;
4099
- let locale = 'en';
4100
- if (component !== undefined) {
4101
- locale = getDesiredLocale(component);
4102
- resources = await getComponentI18nResources(component, defaultResources, locale, parentComponent);
4103
- }
4104
- const intlFormats = Object.entries(resources).reduce((map, [key, val]) => {
4105
- map.set(key, new IntlMessageFormat(val, locale));
4106
- return map;
4107
- }, new Map());
4108
- const defaultFormats = Object.entries(defaultResources).reduce((map, [key, val]) => {
4109
- map.set(key, new IntlMessageFormat(val, DEFAULT_LOCALE));
4110
- return map;
4111
- }, new Map());
4112
- return (resourceKey, context) => {
4113
- var _a, _b;
4114
- let i18nString = (_a = intlFormats.get(resourceKey)) === null || _a === void 0 ? void 0 : _a.format(context);
4115
- if (!i18nString) {
4116
- i18nString = (_b = defaultFormats.get(resourceKey)) === null || _b === void 0 ? void 0 : _b.format(context);
4117
- console.warn(`No localized string available for "${resourceKey}-${i18nString}" for "${locale}" locale. Falling back to English translation.`);
4118
- }
4119
- return i18nString;
4120
- };
4121
- }
4122
- async function getComponentI18nResources(component, defaultResources, locale, parentComponent) {
4123
- const componentName = parentComponent ||
4124
- component.tagName.toLocaleLowerCase().replace(/-beta$/, '');
4125
- let resources;
4126
- if (component['i18n-resources']) {
4127
- resources = component['i18n-resources'];
4128
- }
4129
- else if (locale !== DEFAULT_LOCALE) {
4130
- try {
4131
- resources = await fetchResources(componentName, locale);
4132
- }
4133
- catch (_a) {
4134
- resources = null;
4135
- }
4136
- }
4137
- if (!resources) {
4138
- resources = defaultResources;
4139
- }
4140
- return resources;
4141
- }
4142
- function getDesiredLocale(element) {
4143
- const locale = findLocaleInDom(element);
4144
- const lang = locale.split(/[_-]/)[0];
4145
- if (locales.indexOf(locale) >= 0) {
4146
- return locale;
4147
- }
4148
- else if (locales.indexOf(lang) >= 0) {
4149
- return lang;
4150
- }
4151
- else {
4152
- return DEFAULT_LOCALE;
4153
- }
4154
- }
4155
- function findLocaleInDom(element) {
4156
- const closestElement = getClosestElement.getClosestElement('[lang]', element);
4157
- if (closestElement && closestElement.lang) {
4158
- return closestElement.lang.toLowerCase();
4159
- }
4160
- else {
4161
- return DEFAULT_LOCALE;
4162
- }
4163
- }
4164
- /**
4165
- * Get the 0-indexed first day of the week for a given locale, where 0 represents
4166
- * Sunday. This should be considered deprecated, as newer browser APIs use
4167
- * a different day-of-week indexing scheme, provided by `getFirstDayOfWeek`
4168
- * @param locale
4169
- * @returns A number representing the first day of the week where 0 is Sunday
4170
- */
4171
- function getStartOfWeek(locale = DEFAULT_LOCALE) {
4172
- const startOfWeekData = startOfWeekDataUntyped;
4173
- return (startOfWeekData[locale]
4174
- ? startOfWeekData[locale]
4175
- : startOfWeekData[DEFAULT_LOCALE]);
4176
- }
4177
- function getFirstDayOfWeek(locale = DEFAULT_LOCALE) {
4178
- // Eventually, we can hopefully convert all of this to:
4179
- // `new Locale(locale).getWeekInfo().firstDay`
4180
- // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
4181
- const legacyFirstDay = getStartOfWeek(locale);
4182
- // This looks crazy, but it's the following:
4183
- // - Shift legacy days "left" 1 place: `legacyFirstDay - 1`
4184
- // - Take a true mathematical modulo: `((n % d) + d) % d` (where d is 7)
4185
- // to get back to the correct range
4186
- // - Add 1 to make the list 1-indexed.
4187
- return (((((legacyFirstDay - 1) % 7) + 7) % 7) + 1);
4188
- }
4189
-
4190
- exports.buildI18nForComponent = buildI18nForComponent;
4191
- exports.getDesiredLocale = getDesiredLocale;
4192
- exports.getFirstDayOfWeek = getFirstDayOfWeek;
4193
- exports.getStartOfWeek = getStartOfWeek;
4194
- exports.locales = locales;