@haiilo/catalyst 0.2.3 → 0.4.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 (241) hide show
  1. package/dist/catalyst/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  2. package/dist/catalyst/assets/fonts/DMSans-Bold.woff2 +0 -0
  3. package/dist/catalyst/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  4. package/dist/catalyst/assets/fonts/DMSans-Italic.woff2 +0 -0
  5. package/dist/catalyst/assets/fonts/DMSans-Medium.woff2 +0 -0
  6. package/dist/catalyst/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  7. package/dist/catalyst/assets/fonts/DMSans-Regular.woff2 +0 -0
  8. package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
  9. package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
  10. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
  11. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  12. package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
  13. package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
  14. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
  15. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  16. package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
  17. package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
  18. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
  19. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  20. package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
  21. package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
  22. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
  23. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  24. package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
  25. package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
  26. package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
  27. package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
  28. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
  29. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
  30. package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
  31. package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
  32. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
  33. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  34. package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
  35. package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
  36. package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
  37. package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
  38. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  39. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  40. package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
  41. package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
  42. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
  43. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  44. package/dist/catalyst/catalyst.css +1 -1959
  45. package/dist/catalyst/catalyst.esm.js +1 -131
  46. package/dist/catalyst/catalyst.esm.js.map +1 -1
  47. package/dist/catalyst/index.esm.js +1 -2
  48. package/dist/catalyst/index.esm.js.map +1 -1
  49. package/dist/catalyst/p-89a97b7b.entry.js +10 -0
  50. package/dist/catalyst/p-89a97b7b.entry.js.map +1 -0
  51. package/dist/catalyst/p-ed826597.js +2 -0
  52. package/dist/catalyst/p-ed826597.js.map +1 -0
  53. package/dist/catalyst/p-ef0a8ae9.js +2 -0
  54. package/dist/catalyst/p-ef0a8ae9.js.map +1 -0
  55. package/dist/catalyst/p-f151cb13.js +2 -0
  56. package/dist/catalyst/p-f151cb13.js.map +1 -0
  57. package/dist/cjs/app-globals-7f2b1f8e.js +173 -0
  58. package/dist/cjs/app-globals-7f2b1f8e.js.map +1 -0
  59. package/dist/cjs/cat-alert_9.cjs.entry.js +4557 -0
  60. package/dist/cjs/cat-alert_9.cjs.entry.js.map +1 -0
  61. package/dist/cjs/cat-icon-registry-850c538c.js +47 -0
  62. package/dist/cjs/cat-icon-registry-850c538c.js.map +1 -0
  63. package/dist/cjs/catalyst.cjs.js +24 -0
  64. package/dist/cjs/catalyst.cjs.js.map +1 -0
  65. package/dist/cjs/index-c0881ae0.js +1348 -0
  66. package/dist/cjs/index-c0881ae0.js.map +1 -0
  67. package/dist/cjs/index.cjs.js +11 -0
  68. package/dist/cjs/index.cjs.js.map +1 -0
  69. package/dist/cjs/loader.cjs.js +26 -0
  70. package/dist/cjs/loader.cjs.js.map +1 -0
  71. package/dist/collection/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  72. package/dist/collection/assets/fonts/DMSans-Bold.woff2 +0 -0
  73. package/dist/collection/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  74. package/dist/collection/assets/fonts/DMSans-Italic.woff2 +0 -0
  75. package/dist/collection/assets/fonts/DMSans-Medium.woff2 +0 -0
  76. package/dist/collection/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  77. package/dist/collection/assets/fonts/DMSans-Regular.woff2 +0 -0
  78. package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
  79. package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
  80. package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
  81. package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  82. package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
  83. package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
  84. package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
  85. package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  86. package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
  87. package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
  88. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
  89. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  90. package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
  91. package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
  92. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
  93. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  94. package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
  95. package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
  96. package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
  97. package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
  98. package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
  99. package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
  100. package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
  101. package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
  102. package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
  103. package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  104. package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
  105. package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
  106. package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
  107. package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
  108. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  109. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  110. package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
  111. package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
  112. package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
  113. package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  114. package/dist/collection/collection-manifest.json +21 -0
  115. package/dist/collection/components/cat-alert/cat-alert.css +57 -0
  116. package/dist/collection/components/cat-alert/cat-alert.js +50 -0
  117. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -0
  118. package/dist/collection/components/cat-badge/cat-badge.css +154 -0
  119. package/dist/collection/components/cat-badge/cat-badge.js +142 -0
  120. package/dist/collection/components/cat-badge/cat-badge.js.map +1 -0
  121. package/dist/collection/components/cat-button/cat-button.css +323 -0
  122. package/dist/collection/components/cat-button/cat-button.js +591 -0
  123. package/dist/collection/components/cat-button/cat-button.js.map +1 -0
  124. package/dist/collection/components/cat-icon/cat-icon-registry.js +42 -0
  125. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -0
  126. package/dist/collection/components/cat-icon/cat-icon.css +50 -0
  127. package/dist/collection/components/cat-icon/cat-icon.js +90 -0
  128. package/dist/collection/components/cat-icon/cat-icon.js.map +1 -0
  129. package/dist/collection/components/cat-menu/cat-menu.css +33 -0
  130. package/dist/collection/components/cat-menu/cat-menu.js +184 -0
  131. package/dist/collection/components/cat-menu/cat-menu.js.map +1 -0
  132. package/dist/collection/components/cat-scrollable/cat-scrollable.css +69 -0
  133. package/dist/collection/components/cat-scrollable/cat-scrollable.js +309 -0
  134. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -0
  135. package/dist/collection/components/cat-skeleton/cat-skeleton.css +177 -0
  136. package/dist/collection/components/cat-skeleton/cat-skeleton.js +131 -0
  137. package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +1 -0
  138. package/dist/collection/components/cat-spinner/cat-spinner.css +63 -0
  139. package/dist/collection/components/cat-spinner/cat-spinner.js +65 -0
  140. package/dist/collection/components/cat-spinner/cat-spinner.js.map +1 -0
  141. package/dist/collection/components/cat-tooltip/cat-tooltip.css +37 -0
  142. package/dist/collection/components/cat-tooltip/cat-tooltip.js +254 -0
  143. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -0
  144. package/dist/collection/index.cdn.js +21 -0
  145. package/dist/collection/index.js +2 -0
  146. package/dist/collection/index.js.map +1 -0
  147. package/dist/collection/init.js +9 -0
  148. package/dist/collection/init.js.map +1 -0
  149. package/dist/collection/utils/breakpoints.js +12 -0
  150. package/dist/collection/utils/breakpoints.js.map +1 -0
  151. package/dist/collection/utils/first-tabbable.js +6 -0
  152. package/dist/collection/utils/first-tabbable.js.map +1 -0
  153. package/dist/collection/utils/is-touch-screen.js +3 -0
  154. package/dist/collection/utils/is-touch-screen.js.map +1 -0
  155. package/dist/collection/utils/media-matcher.js +55 -0
  156. package/dist/collection/utils/media-matcher.js.map +1 -0
  157. package/dist/collection/utils/platform.js +50 -0
  158. package/dist/collection/utils/platform.js.map +1 -0
  159. package/dist/collection/utils/utils.js +4 -0
  160. package/dist/collection/utils/utils.js.map +1 -0
  161. package/dist/{catalyst/cat-alert.entry.js → components/cat-alert.js} +28 -8
  162. package/dist/components/cat-alert.js.map +1 -0
  163. package/dist/{catalyst/cat-badge.entry.js → components/cat-badge.js} +32 -8
  164. package/dist/components/cat-badge.js.map +1 -0
  165. package/dist/{catalyst/cat-button.entry.js → components/cat-button.js} +60 -41
  166. package/dist/components/cat-button.js.map +1 -0
  167. package/dist/components/cat-icon-registry.js +45 -0
  168. package/dist/components/cat-icon-registry.js.map +1 -0
  169. package/dist/components/cat-icon.js +8 -0
  170. package/dist/components/cat-icon.js.map +1 -0
  171. package/dist/{catalyst/cat-icon.entry.js → components/cat-icon2.js} +28 -9
  172. package/dist/components/cat-icon2.js.map +1 -0
  173. package/dist/components/cat-menu.js +870 -0
  174. package/dist/components/cat-menu.js.map +1 -0
  175. package/dist/components/cat-scrollable.js +1363 -0
  176. package/dist/components/cat-scrollable.js.map +1 -0
  177. package/dist/{catalyst/cat-skeleton.entry.js → components/cat-skeleton.js} +31 -8
  178. package/dist/components/cat-skeleton.js.map +1 -0
  179. package/dist/components/cat-spinner.js +8 -0
  180. package/dist/components/cat-spinner.js.map +1 -0
  181. package/dist/{catalyst/cat-spinner.entry.js → components/cat-spinner2.js} +26 -8
  182. package/dist/components/cat-spinner2.js.map +1 -0
  183. package/dist/components/{cat-input.d.ts → cat-tooltip.d.ts} +4 -4
  184. package/dist/components/cat-tooltip.js +154 -0
  185. package/dist/components/cat-tooltip.js.map +1 -0
  186. package/dist/components/first-tabbable.js +1495 -0
  187. package/dist/components/first-tabbable.js.map +1 -0
  188. package/dist/components/index.js +173 -0
  189. package/dist/components/index.js.map +1 -0
  190. package/dist/esm/app-globals-8af9b2cf.js +171 -0
  191. package/dist/esm/app-globals-8af9b2cf.js.map +1 -0
  192. package/dist/esm/cat-alert_9.entry.js +4545 -0
  193. package/dist/esm/cat-alert_9.entry.js.map +1 -0
  194. package/dist/{catalyst → esm}/cat-icon-registry-59da2e37.js +0 -0
  195. package/dist/{catalyst → esm}/cat-icon-registry-59da2e37.js.map +0 -0
  196. package/dist/esm/catalyst.js +22 -0
  197. package/dist/esm/catalyst.js.map +1 -0
  198. package/dist/esm/index-0ff35bca.js +1320 -0
  199. package/dist/esm/index-0ff35bca.js.map +1 -0
  200. package/dist/esm/index.js +3 -0
  201. package/dist/esm/index.js.map +1 -0
  202. package/dist/esm/loader.js +22 -0
  203. package/dist/esm/loader.js.map +1 -0
  204. package/dist/esm/polyfills/core-js.js +11 -0
  205. package/dist/esm/polyfills/css-shim.js +1 -0
  206. package/dist/esm/polyfills/dom.js +79 -0
  207. package/dist/esm/polyfills/es5-html-element.js +1 -0
  208. package/dist/esm/polyfills/index.js +34 -0
  209. package/dist/esm/polyfills/system.js +6 -0
  210. package/dist/index.cjs.js +1 -0
  211. package/dist/index.js +1 -0
  212. package/dist/types/components/cat-menu/cat-menu.d.ts +0 -1
  213. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +46 -0
  214. package/dist/types/components.d.ts +61 -0
  215. package/dist/types/index.d.ts +1 -0
  216. package/dist/types/utils/first-tabbable.d.ts +4 -0
  217. package/dist/types/utils/is-touch-screen.d.ts +2 -0
  218. package/package.json +12 -19
  219. package/dist/catalyst/app-globals-54573336.js +0 -718
  220. package/dist/catalyst/app-globals-54573336.js.map +0 -1
  221. package/dist/catalyst/cat-alert.entry.js.map +0 -1
  222. package/dist/catalyst/cat-badge.entry.js.map +0 -1
  223. package/dist/catalyst/cat-button.entry.js.map +0 -1
  224. package/dist/catalyst/cat-icon.entry.js.map +0 -1
  225. package/dist/catalyst/cat-input.entry.js +0 -55
  226. package/dist/catalyst/cat-input.entry.js.map +0 -1
  227. package/dist/catalyst/cat-menu.entry.js +0 -2986
  228. package/dist/catalyst/cat-menu.entry.js.map +0 -1
  229. package/dist/catalyst/cat-scrollable.entry.js +0 -4523
  230. package/dist/catalyst/cat-scrollable.entry.js.map +0 -1
  231. package/dist/catalyst/cat-skeleton.entry.js.map +0 -1
  232. package/dist/catalyst/cat-spinner.entry.js.map +0 -1
  233. package/dist/catalyst/css-shim-e6dd2538.js +0 -6
  234. package/dist/catalyst/css-shim-e6dd2538.js.map +0 -1
  235. package/dist/catalyst/dom-7fc649b0.js +0 -75
  236. package/dist/catalyst/dom-7fc649b0.js.map +0 -1
  237. package/dist/catalyst/index-2df805aa.js +0 -3059
  238. package/dist/catalyst/index-2df805aa.js.map +0 -1
  239. package/dist/catalyst/shadow-css-4d56fa31.js +0 -390
  240. package/dist/catalyst/shadow-css-4d56fa31.js.map +0 -1
  241. package/dist/types/components/cat-input/cat-input.d.ts +0 -70
@@ -0,0 +1,4557 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c0881ae0.js');
6
+ const catIconRegistry = require('./cat-icon-registry-850c538c.js');
7
+
8
+ const catAlertCss = ":host{display:block;margin-bottom:1rem}:host([hidden]){display:none}.cat-alert{font:inherit;color:rgb(var(--text));background-color:rgba(var(--bg), 0.1);box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);border-radius:0.25rem;padding:0.75rem 1rem;width:100%}::slotted(:last-child){margin-bottom:0 !important}.cat-alert-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.cat-alert-secondary{--bg:105, 118, 135;--text:0, 0, 0;--border:105, 118, 135}.cat-alert-success{--bg:0, 132, 88;--text:0, 132, 88;--border:0, 132, 88}.cat-alert-warning{--bg:255, 206, 128;--text:159, 97, 0;--border:159, 97, 0}.cat-alert-danger{--bg:217, 52, 13;--text:217, 52, 13;--border:217, 52, 13}";
9
+
10
+ const CatAlert = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ /**
14
+ * The color palette of the alert.
15
+ */
16
+ this.color = 'primary';
17
+ }
18
+ render() {
19
+ return (index.h("div", { part: "alert", class: {
20
+ 'cat-alert': true,
21
+ [`cat-alert-${this.color}`]: Boolean(this.color)
22
+ } }, index.h("slot", null)));
23
+ }
24
+ };
25
+ CatAlert.style = catAlertCss;
26
+
27
+ const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.cat-badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.cat-badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cat-badge-round{border-radius:10rem}.cat-badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.cat-badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.cat-badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.cat-badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.cat-badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.cat-badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.cat-badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.cat-badge-xs{height:0.75rem;min-width:0.75rem;font-size:0.75rem;padding:0 0.1875rem}.cat-badge-s{height:1rem;min-width:1rem;font-size:0.75rem;padding:0 0.25rem}.cat-badge-m{height:1.25rem;min-width:1.25rem;font-size:0.75rem;padding:0 0.3125rem}.cat-badge-l{height:1.5rem;min-width:1.5rem;font-size:0.875rem;padding:0 0.375rem}.cat-badge-xl{height:1.75rem;min-width:1.75rem;font-size:0.9375rem;padding:0 0.4375rem}.cat-badge-pulse.cat-badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.cat-badge-pulse.cat-badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
28
+
29
+ const CatBadge = class {
30
+ constructor(hostRef) {
31
+ index.registerInstance(this, hostRef);
32
+ /**
33
+ * The rendering style of the badge.
34
+ */
35
+ this.variant = 'filled';
36
+ /**
37
+ * The color palette of the badge.
38
+ */
39
+ this.color = 'primary';
40
+ /**
41
+ * The size of the badge.
42
+ */
43
+ this.size = 'm';
44
+ /**
45
+ * Use round badge edges.
46
+ */
47
+ this.round = false;
48
+ /**
49
+ * Draw attention to the badge with a subtle animation.
50
+ */
51
+ this.pulse = false;
52
+ }
53
+ render() {
54
+ return (index.h("span", { part: "badge", class: {
55
+ 'cat-badge': true,
56
+ 'cat-badge-round': this.round,
57
+ 'cat-badge-pulse': this.pulse,
58
+ [`cat-badge-${this.variant}`]: Boolean(this.variant),
59
+ [`cat-badge-${this.color}`]: Boolean(this.color),
60
+ [`cat-badge-${this.size}`]: Boolean(this.size)
61
+ } }, index.h("slot", null)));
62
+ }
63
+ };
64
+ CatBadge.style = catBadgeCss;
65
+
66
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
67
+
68
+ function createCommonjsModule(fn, basedir, module) {
69
+ return module = {
70
+ path: basedir,
71
+ exports: {},
72
+ require: function (path, base) {
73
+ return commonjsRequire();
74
+ }
75
+ }, fn(module, module.exports), module.exports;
76
+ }
77
+
78
+ function commonjsRequire () {
79
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
80
+ }
81
+
82
+ var loglevel = createCommonjsModule(function (module) {
83
+ /*
84
+ * loglevel - https://github.com/pimterry/loglevel
85
+ *
86
+ * Copyright (c) 2013 Tim Perry
87
+ * Licensed under the MIT license.
88
+ */
89
+ (function (root, definition) {
90
+ if (module.exports) {
91
+ module.exports = definition();
92
+ } else {
93
+ root.log = definition();
94
+ }
95
+ }(commonjsGlobal, function () {
96
+
97
+ // Slightly dubious tricks to cut down minimized file size
98
+ var noop = function() {};
99
+ var undefinedType = "undefined";
100
+ var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
101
+ /Trident\/|MSIE /.test(window.navigator.userAgent)
102
+ );
103
+
104
+ var logMethods = [
105
+ "trace",
106
+ "debug",
107
+ "info",
108
+ "warn",
109
+ "error"
110
+ ];
111
+
112
+ // Cross-browser bind equivalent that works at least back to IE6
113
+ function bindMethod(obj, methodName) {
114
+ var method = obj[methodName];
115
+ if (typeof method.bind === 'function') {
116
+ return method.bind(obj);
117
+ } else {
118
+ try {
119
+ return Function.prototype.bind.call(method, obj);
120
+ } catch (e) {
121
+ // Missing bind shim or IE8 + Modernizr, fallback to wrapping
122
+ return function() {
123
+ return Function.prototype.apply.apply(method, [obj, arguments]);
124
+ };
125
+ }
126
+ }
127
+ }
128
+
129
+ // Trace() doesn't print the message in IE, so for that case we need to wrap it
130
+ function traceForIE() {
131
+ if (console.log) {
132
+ if (console.log.apply) {
133
+ console.log.apply(console, arguments);
134
+ } else {
135
+ // In old IE, native console methods themselves don't have apply().
136
+ Function.prototype.apply.apply(console.log, [console, arguments]);
137
+ }
138
+ }
139
+ if (console.trace) console.trace();
140
+ }
141
+
142
+ // Build the best logging method possible for this env
143
+ // Wherever possible we want to bind, not wrap, to preserve stack traces
144
+ function realMethod(methodName) {
145
+ if (methodName === 'debug') {
146
+ methodName = 'log';
147
+ }
148
+
149
+ if (typeof console === undefinedType) {
150
+ return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
151
+ } else if (methodName === 'trace' && isIE) {
152
+ return traceForIE;
153
+ } else if (console[methodName] !== undefined) {
154
+ return bindMethod(console, methodName);
155
+ } else if (console.log !== undefined) {
156
+ return bindMethod(console, 'log');
157
+ } else {
158
+ return noop;
159
+ }
160
+ }
161
+
162
+ // These private functions always need `this` to be set properly
163
+
164
+ function replaceLoggingMethods(level, loggerName) {
165
+ /*jshint validthis:true */
166
+ for (var i = 0; i < logMethods.length; i++) {
167
+ var methodName = logMethods[i];
168
+ this[methodName] = (i < level) ?
169
+ noop :
170
+ this.methodFactory(methodName, level, loggerName);
171
+ }
172
+
173
+ // Define log.log as an alias for log.debug
174
+ this.log = this.debug;
175
+ }
176
+
177
+ // In old IE versions, the console isn't present until you first open it.
178
+ // We build realMethod() replacements here that regenerate logging methods
179
+ function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
180
+ return function () {
181
+ if (typeof console !== undefinedType) {
182
+ replaceLoggingMethods.call(this, level, loggerName);
183
+ this[methodName].apply(this, arguments);
184
+ }
185
+ };
186
+ }
187
+
188
+ // By default, we use closely bound real methods wherever possible, and
189
+ // otherwise we wait for a console to appear, and then try again.
190
+ function defaultMethodFactory(methodName, level, loggerName) {
191
+ /*jshint validthis:true */
192
+ return realMethod(methodName) ||
193
+ enableLoggingWhenConsoleArrives.apply(this, arguments);
194
+ }
195
+
196
+ function Logger(name, defaultLevel, factory) {
197
+ var self = this;
198
+ var currentLevel;
199
+ defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
200
+
201
+ var storageKey = "loglevel";
202
+ if (typeof name === "string") {
203
+ storageKey += ":" + name;
204
+ } else if (typeof name === "symbol") {
205
+ storageKey = undefined;
206
+ }
207
+
208
+ function persistLevelIfPossible(levelNum) {
209
+ var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
210
+
211
+ if (typeof window === undefinedType || !storageKey) return;
212
+
213
+ // Use localStorage if available
214
+ try {
215
+ window.localStorage[storageKey] = levelName;
216
+ return;
217
+ } catch (ignore) {}
218
+
219
+ // Use session cookie as fallback
220
+ try {
221
+ window.document.cookie =
222
+ encodeURIComponent(storageKey) + "=" + levelName + ";";
223
+ } catch (ignore) {}
224
+ }
225
+
226
+ function getPersistedLevel() {
227
+ var storedLevel;
228
+
229
+ if (typeof window === undefinedType || !storageKey) return;
230
+
231
+ try {
232
+ storedLevel = window.localStorage[storageKey];
233
+ } catch (ignore) {}
234
+
235
+ // Fallback to cookies if local storage gives us nothing
236
+ if (typeof storedLevel === undefinedType) {
237
+ try {
238
+ var cookie = window.document.cookie;
239
+ var location = cookie.indexOf(
240
+ encodeURIComponent(storageKey) + "=");
241
+ if (location !== -1) {
242
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
243
+ }
244
+ } catch (ignore) {}
245
+ }
246
+
247
+ // If the stored level is not valid, treat it as if nothing was stored.
248
+ if (self.levels[storedLevel] === undefined) {
249
+ storedLevel = undefined;
250
+ }
251
+
252
+ return storedLevel;
253
+ }
254
+
255
+ function clearPersistedLevel() {
256
+ if (typeof window === undefinedType || !storageKey) return;
257
+
258
+ // Use localStorage if available
259
+ try {
260
+ window.localStorage.removeItem(storageKey);
261
+ return;
262
+ } catch (ignore) {}
263
+
264
+ // Use session cookie as fallback
265
+ try {
266
+ window.document.cookie =
267
+ encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
268
+ } catch (ignore) {}
269
+ }
270
+
271
+ /*
272
+ *
273
+ * Public logger API - see https://github.com/pimterry/loglevel for details
274
+ *
275
+ */
276
+
277
+ self.name = name;
278
+
279
+ self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
280
+ "ERROR": 4, "SILENT": 5};
281
+
282
+ self.methodFactory = factory || defaultMethodFactory;
283
+
284
+ self.getLevel = function () {
285
+ return currentLevel;
286
+ };
287
+
288
+ self.setLevel = function (level, persist) {
289
+ if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
290
+ level = self.levels[level.toUpperCase()];
291
+ }
292
+ if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
293
+ currentLevel = level;
294
+ if (persist !== false) { // defaults to true
295
+ persistLevelIfPossible(level);
296
+ }
297
+ replaceLoggingMethods.call(self, level, name);
298
+ if (typeof console === undefinedType && level < self.levels.SILENT) {
299
+ return "No console available for logging";
300
+ }
301
+ } else {
302
+ throw "log.setLevel() called with invalid level: " + level;
303
+ }
304
+ };
305
+
306
+ self.setDefaultLevel = function (level) {
307
+ defaultLevel = level;
308
+ if (!getPersistedLevel()) {
309
+ self.setLevel(level, false);
310
+ }
311
+ };
312
+
313
+ self.resetLevel = function () {
314
+ self.setLevel(defaultLevel, false);
315
+ clearPersistedLevel();
316
+ };
317
+
318
+ self.enableAll = function(persist) {
319
+ self.setLevel(self.levels.TRACE, persist);
320
+ };
321
+
322
+ self.disableAll = function(persist) {
323
+ self.setLevel(self.levels.SILENT, persist);
324
+ };
325
+
326
+ // Initialize with the right level
327
+ var initialLevel = getPersistedLevel();
328
+ if (initialLevel == null) {
329
+ initialLevel = defaultLevel;
330
+ }
331
+ self.setLevel(initialLevel, false);
332
+ }
333
+
334
+ /*
335
+ *
336
+ * Top-level API
337
+ *
338
+ */
339
+
340
+ var defaultLogger = new Logger();
341
+
342
+ var _loggersByName = {};
343
+ defaultLogger.getLogger = function getLogger(name) {
344
+ if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
345
+ throw new TypeError("You must supply a name when creating a logger.");
346
+ }
347
+
348
+ var logger = _loggersByName[name];
349
+ if (!logger) {
350
+ logger = _loggersByName[name] = new Logger(
351
+ name, defaultLogger.getLevel(), defaultLogger.methodFactory);
352
+ }
353
+ return logger;
354
+ };
355
+
356
+ // Grab the current global log variable in case of overwrite
357
+ var _log = (typeof window !== undefinedType) ? window.log : undefined;
358
+ defaultLogger.noConflict = function() {
359
+ if (typeof window !== undefinedType &&
360
+ window.log === defaultLogger) {
361
+ window.log = _log;
362
+ }
363
+
364
+ return defaultLogger;
365
+ };
366
+
367
+ defaultLogger.getLoggers = function getLoggers() {
368
+ return _loggersByName;
369
+ };
370
+
371
+ // ES6 default export, for compatibility
372
+ defaultLogger['default'] = defaultLogger;
373
+
374
+ return defaultLogger;
375
+ }));
376
+ });
377
+
378
+ const _breakpoints = ['xs', 's', 'm', 'l', 'xl'];
379
+ const Breakpoints = {
380
+ xs: '(max-width: 539.98px)',
381
+ s: '(max-width: 767.98px)',
382
+ m: '(max-width: 991.98px)',
383
+ l: '(max-width: 1199.98px)',
384
+ xl: '(max-width: 1399.98px)'
385
+ };
386
+ function isBreakpoint(value) {
387
+ return typeof value === 'string' && _breakpoints.includes(value);
388
+ }
389
+
390
+ // https://github.com/angular/components/blob/master/src/cdk/platform/platform.ts
391
+ // Whether the current platform supports the V8 Break Iterator. The V8 check
392
+ // is necessary to detect all Blink based browsers.
393
+ let hasV8BreakIterator;
394
+ // We need a try/catch around the reference to `Intl`, because accessing it in some cases can
395
+ // cause IE to throw. These cases are tied to particular versions of Windows and can happen if
396
+ // the consumer is providing a polyfilled `Map`. See:
397
+ // https://github.com/Microsoft/ChakraCore/issues/3189
398
+ // https://github.com/angular/components/issues/15687
399
+ try {
400
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
401
+ hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator;
402
+ }
403
+ catch (_a) {
404
+ hasV8BreakIterator = false;
405
+ }
406
+ class Platform {
407
+ constructor() {
408
+ /** Whether the current browser is Microsoft Edge. */
409
+ this.EDGE = /(edge)/i.test(navigator.userAgent);
410
+ /** Whether the current rendering engine is Microsoft Trident. */
411
+ this.TRIDENT = /(msie|trident)/i.test(navigator.userAgent);
412
+ // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
413
+ /** Whether the current rendering engine is Blink. */
414
+ this.BLINK =
415
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
416
+ !!(window.chrome || hasV8BreakIterator) && typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT;
417
+ // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
418
+ // ensure that Webkit runs standalone and is not used as another engine's base.
419
+ /** Whether the current rendering engine is WebKit. */
420
+ this.WEBKIT = /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
421
+ /** Whether the current platform is Apple iOS. */
422
+ this.IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
423
+ // It's difficult to detect the plain Gecko engine, because most of the browsers identify
424
+ // them self as Gecko-like browsers and modify the userAgent's according to that.
425
+ // Since we only cover one explicit Firefox case, we can simply check for Firefox
426
+ // instead of having an unstable check for Gecko.
427
+ /** Whether the current browser is Firefox. */
428
+ this.FIREFOX = /(firefox|minefield)/i.test(navigator.userAgent);
429
+ /** Whether the current platform is Android. */
430
+ // Trident on mobile adds the android platform to the userAgent to trick detections.
431
+ this.ANDROID = /android/i.test(navigator.userAgent) && !this.TRIDENT;
432
+ // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
433
+ // this and just place the Safari keyword in the userAgent. To be more safe about Safari every
434
+ // Safari browser should also use Webkit as its layout engine.
435
+ /** Whether the current browser is Safari. */
436
+ this.SAFARI = /safari/i.test(navigator.userAgent) && this.WEBKIT;
437
+ }
438
+ }
439
+
440
+ // https://github.com/angular/components/blob/master/src/cdk/layout/media-matcher.ts
441
+ /** Global registry for all dynamically-created, injected media queries. */
442
+ const mediaQueriesForWebkitCompatibility = new Set();
443
+ /** Style tag that holds all of the dynamically-created media queries. */
444
+ let mediaQueryStyleNode;
445
+ /** A utility for calling matchMedia queries. */
446
+ class MediaMatcher {
447
+ constructor() {
448
+ this._platform = new Platform();
449
+ this._matchMedia = window.matchMedia.bind(window);
450
+ }
451
+ /**
452
+ * Evaluates the given media query and returns the native MediaQueryList from which results
453
+ * can be retrieved.
454
+ * Confirms the layout engine will trigger for the selector query provided and returns the
455
+ * MediaQueryList for the query provided.
456
+ */
457
+ matchMedia(query) {
458
+ if (this._platform.WEBKIT || this._platform.BLINK) {
459
+ createEmptyStyleRule(query);
460
+ }
461
+ return this._matchMedia(query);
462
+ }
463
+ }
464
+ /**
465
+ * Creates an empty stylesheet that is used to work around browser inconsistencies related to
466
+ * `matchMedia`. At the time of writing, it handles the following cases:
467
+ * 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`
468
+ * to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.
469
+ * 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules
470
+ * inside the `@media` match existing elements on the page. We work around it by having one rule
471
+ * targeting the `body`. See https://github.com/angular/components/issues/23546.
472
+ */
473
+ function createEmptyStyleRule(query) {
474
+ if (mediaQueriesForWebkitCompatibility.has(query)) {
475
+ return;
476
+ }
477
+ try {
478
+ if (!mediaQueryStyleNode) {
479
+ mediaQueryStyleNode = document.createElement('style');
480
+ mediaQueryStyleNode.setAttribute('type', 'text/css');
481
+ document.head.appendChild(mediaQueryStyleNode);
482
+ }
483
+ if (mediaQueryStyleNode.sheet) {
484
+ mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);
485
+ mediaQueriesForWebkitCompatibility.add(query);
486
+ }
487
+ }
488
+ catch (e) {
489
+ loglevel.error(e);
490
+ }
491
+ }
492
+
493
+ const catButtonCss = ":host{display:inline-block;max-width:100%;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.cat-button{font:inherit;display:flex;align-items:center;justify-content:center;border:none;border-radius:0.25rem;text-decoration:none;width:100%;box-sizing:border-box;cursor:pointer;transition:color 0.13s linear, border-color 0.13s linear, background-color 0.13s linear, box-shadow 0.13s linear}.cat-button:focus-visible{outline:2px solid #0071ff;outline-offset:1px}.cat-button-ellipsed .cat-button-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cat-button-disabled{cursor:not-allowed;opacity:0.65;filter:grayscale(100%)}.cat-button-round{border-radius:10rem}.cat-button-loading{cursor:default}.cat-button-loading cat-spinner{position:absolute}.cat-button-loading>*:not(cat-spinner){visibility:hidden}.cat-button-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.cat-button-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--base), 0.2);color:rgb(var(--text))}.cat-button-outlined:hover:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.05)}.cat-button-outlined:active:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.1)}.cat-button-text{background-color:transparent;color:rgb(var(--text));text-decoration:none}.cat-button-text:hover:not(.cat-button-disabled):not(.cat-button-loading){text-decoration:underline}.cat-button-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--base:var(--cat-primary-text, 32, 127, 138)}.cat-button-primary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-hover, 28, 112, 122);--fill:var(--cat-primary-fill-hover, 255, 255, 255);--text:var(--cat-primary-text-hover, 28, 112, 122)}.cat-button-primary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-active, 25, 101, 110);--fill:var(--cat-primary-fill-active, 255, 255, 255);--text:var(--cat-primary-text-active, 25, 101, 110)}.cat-button-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--base:105, 118, 135}.cat-button-secondary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-secondary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--base:0, 132, 88}.cat-button-success:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 117, 78;--fill:255, 255, 255;--text:0, 117, 78}.cat-button-success:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 105, 70;--fill:255, 255, 255;--text:0, 105, 70}.cat-button-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--base:159, 97, 0}.cat-button-warning:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 214, 148;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-warning:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 222, 168;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--base:217, 52, 13}.cat-button-danger:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:194, 46, 11;--fill:255, 255, 255;--text:194, 46, 11}.cat-button-danger:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:174, 42, 10;--fill:255, 255, 255;--text:174, 42, 10}.cat-button-xs{min-width:1.5rem;padding:0.25rem 0.25rem;font-size:0.875rem;line-height:1rem}.cat-button-xs .cat-button-prefix{margin-right:0.25rem}.cat-button-xs .cat-button-suffix{margin-left:0.25rem}.cat-button-xs.cat-button-icon{width:1.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xs{padding-left:1rem;padding-right:1rem}.cat-button-s{min-width:2rem;padding:0.375rem 0.5rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-s .cat-button-prefix{margin-right:0.25rem}.cat-button-s .cat-button-suffix{margin-left:0.25rem}.cat-button-s cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-s.cat-button-icon{width:2rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-s{padding-left:1rem;padding-right:1rem}.cat-button-m{min-width:2.5rem;padding:0.625rem 0.75rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-m .cat-button-prefix{margin-right:0.25rem}.cat-button-m .cat-button-suffix{margin-left:0.25rem}.cat-button-m cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-m.cat-button-icon{width:2.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-m{padding-left:1rem;padding-right:1rem}.cat-button-l{min-width:3rem;padding:0.875rem 1rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-l .cat-button-prefix{margin-right:0.25rem}.cat-button-l .cat-button-suffix{margin-left:0.25rem}.cat-button-l cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-l.cat-button-icon{width:3rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-l{padding-left:1rem;padding-right:1rem}.cat-button-xl{min-width:3.5rem;padding:1rem 1.25rem;font-size:1.125rem;line-height:1.5rem}.cat-button-xl .cat-button-prefix{margin-right:0.25rem}.cat-button-xl .cat-button-suffix{margin-left:0.25rem}.cat-button-xl.cat-button-icon{width:3.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xl{padding-left:1rem;padding-right:1rem}:host-context(nav){width:100%}:host-context(nav) .cat-button{box-shadow:none;border-radius:0}:host-context(nav) .cat-button:focus-visible{outline-offset:-2px}:host-context(nav) .cat-button-content{text-align:left}:host([hidden]){display:none}:host(.cat-text-left) .cat-button{justify-content:left}:host(.cat-text-right) .cat-button{justify-content:right}";
494
+
495
+ const CatButton = class {
496
+ constructor(hostRef) {
497
+ index.registerInstance(this, hostRef);
498
+ this.catClick = index.createEvent(this, "catClick", 7);
499
+ this.catFocus = index.createEvent(this, "catFocus", 7);
500
+ this.catBlur = index.createEvent(this, "catBlur", 7);
501
+ this._iconOnly = true;
502
+ /**
503
+ * The rendering style of the button.
504
+ */
505
+ this.variant = 'outlined';
506
+ /**
507
+ * The color palette of the button.
508
+ */
509
+ this.color = 'secondary';
510
+ /**
511
+ * The size of the button.
512
+ */
513
+ this.size = 'm';
514
+ /**
515
+ * Specifies that the button should be disabled. A disabled button is unusable
516
+ * and un-clickable. Corresponds with the native HTML disabled attribute.
517
+ */
518
+ this.disabled = false;
519
+ /**
520
+ * Displays the button in a loading state with a spinner. Just like a disabled
521
+ * button, an inactive button is unusable and un-clickable. However, it
522
+ * retains the current focus state.
523
+ */
524
+ this.loading = false;
525
+ /**
526
+ * Allows the button to submit a form.
527
+ */
528
+ this.submit = false;
529
+ /**
530
+ * Ellipse overflowing button content.
531
+ */
532
+ this.ellipsed = true;
533
+ /**
534
+ * Use round button edges.
535
+ */
536
+ this.round = false;
537
+ /**
538
+ * Hide the actual button content and only display the icon.
539
+ */
540
+ this.iconOnly = false;
541
+ /**
542
+ * Display the icon as a suffix.
543
+ */
544
+ this.iconSuffix = false;
545
+ }
546
+ onIconOnlyChanged(value) {
547
+ var _a, _b;
548
+ // teardown
549
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
550
+ (_a = this.mediaQueryList) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this.mediaQueryListener);
551
+ this.mediaQueryList = undefined;
552
+ this.mediaQueryListener = undefined;
553
+ // setup
554
+ if (isBreakpoint(value)) {
555
+ (_b = this.mediaMatcher) !== null && _b !== void 0 ? _b : (this.mediaMatcher = new MediaMatcher());
556
+ this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);
557
+ this.mediaQueryListener = (event) => (this._iconOnly = event.matches);
558
+ this.mediaQueryList.addEventListener('change', this.mediaQueryListener);
559
+ this._iconOnly = this.mediaQueryList.matches;
560
+ }
561
+ else {
562
+ this._iconOnly = value;
563
+ }
564
+ }
565
+ componentWillLoad() {
566
+ this.onIconOnlyChanged(this.iconOnly);
567
+ }
568
+ componentWillRender() {
569
+ if (this.isIconButton && !this.a11yLabel) {
570
+ loglevel.warn('[A11y] Missing ARIA label on icon button', this);
571
+ }
572
+ }
573
+ haltDisabledEvents(event) {
574
+ if (this.disabled || this.loading) {
575
+ event.preventDefault();
576
+ event.stopImmediatePropagation();
577
+ }
578
+ }
579
+ /**
580
+ * Sets focus on the button. Use this method instead of `button.focus()`.
581
+ *
582
+ * @param options An optional object providing options to control aspects of
583
+ * the focusing process.
584
+ */
585
+ async setFocus(options) {
586
+ this.button.focus(options);
587
+ }
588
+ render() {
589
+ var _a;
590
+ if (this.url) {
591
+ return (index.h("a", { ref: el => (this.button = el), href: this.disabled ? undefined : this.url, target: this.urlTarget, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
592
+ 'cat-button': true,
593
+ 'cat-button-icon': this.isIconButton,
594
+ 'cat-button-round': this.round,
595
+ 'cat-button-loading': this.loading,
596
+ 'cat-button-disabled': this.disabled,
597
+ 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
598
+ [`cat-button-${this.variant}`]: Boolean(this.variant),
599
+ [`cat-button-${this.color}`]: Boolean(this.color),
600
+ [`cat-button-${this.size}`]: Boolean(this.size)
601
+ }, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
602
+ }
603
+ else {
604
+ return (index.h("button", { ref: el => (this.button = el), type: this.submit ? 'submit' : 'button', name: this.name, value: this.value, disabled: this.disabled, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
605
+ 'cat-button': true,
606
+ 'cat-button-icon': this.isIconButton,
607
+ 'cat-button-round': (_a = this.round) !== null && _a !== void 0 ? _a : this.isIconButton,
608
+ 'cat-button-loading': this.loading,
609
+ 'cat-button-disabled': this.disabled,
610
+ 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
611
+ [`cat-button-${this.variant}`]: Boolean(this.variant),
612
+ [`cat-button-${this.color}`]: Boolean(this.color),
613
+ [`cat-button-${this.size}`]: Boolean(this.size)
614
+ }, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
615
+ }
616
+ }
617
+ get iconSize() {
618
+ switch (this.size) {
619
+ case 'xs':
620
+ return 's';
621
+ default:
622
+ return 'l';
623
+ }
624
+ }
625
+ get spinnerSize() {
626
+ switch (this.size) {
627
+ case 'xs':
628
+ return 'xs';
629
+ default:
630
+ return 'm';
631
+ }
632
+ }
633
+ get isIconButton() {
634
+ return Boolean(this.icon) && this._iconOnly;
635
+ }
636
+ get hasPrefixIcon() {
637
+ return Boolean(this.icon) && !this._iconOnly && !this.iconSuffix;
638
+ }
639
+ get hasSuffixIcon() {
640
+ return Boolean(this.icon) && !this._iconOnly && this.iconSuffix;
641
+ }
642
+ get content() {
643
+ return [
644
+ this.hasPrefixIcon ? (index.h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-prefix", part: "prefix" })) : null,
645
+ this.isIconButton ? (index.h("cat-icon", { icon: this.icon, size: this.iconSize })) : (index.h("span", { class: "cat-button-content", part: "content" }, index.h("slot", null))),
646
+ this.hasSuffixIcon ? (index.h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-suffix", part: "suffix" })) : null,
647
+ this.loading ? index.h("cat-spinner", { size: this.spinnerSize }) : null
648
+ ];
649
+ }
650
+ onClick(event) {
651
+ this.catClick.emit(event);
652
+ }
653
+ onFocus(event) {
654
+ this.catFocus.emit(event);
655
+ }
656
+ onBlur(event) {
657
+ this.catBlur.emit(event);
658
+ }
659
+ static get watchers() { return {
660
+ "iconOnly": ["onIconOnlyChanged"]
661
+ }; }
662
+ };
663
+ CatButton.style = catButtonCss;
664
+
665
+ const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}span{display:inline-flex}svg{fill:currentColor;stroke:none;transform-origin:center center;width:1em;height:1em}.cat-icon-xs svg{font-size:0.75rem}.cat-icon-s svg{font-size:1rem}.cat-icon-m svg{font-size:1.25rem}.cat-icon-l svg{font-size:1.5rem}.cat-icon-xl svg{font-size:1.75rem}";
666
+
667
+ const CatIcon = class {
668
+ constructor(hostRef) {
669
+ index.registerInstance(this, hostRef);
670
+ this.iconRegistry = catIconRegistry.CatIconRegistry.getInstance();
671
+ /**
672
+ * The name of the icon.
673
+ */
674
+ this.icon = '';
675
+ /**
676
+ * The size of the icon.
677
+ */
678
+ this.size = 'm';
679
+ }
680
+ render() {
681
+ return (index.h("span", { innerHTML: this.iconRegistry.getIcon(this.icon), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
682
+ [`cat-icon-${this.size}`]: this.size !== 'inline'
683
+ } }));
684
+ }
685
+ };
686
+ CatIcon.style = catIconCss;
687
+
688
+ function getSide(placement) {
689
+ return placement.split('-')[0];
690
+ }
691
+
692
+ function getAlignment(placement) {
693
+ return placement.split('-')[1];
694
+ }
695
+
696
+ function getMainAxisFromPlacement(placement) {
697
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
698
+ }
699
+
700
+ function getLengthFromAxis(axis) {
701
+ return axis === 'y' ? 'height' : 'width';
702
+ }
703
+
704
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
705
+ let {
706
+ reference,
707
+ floating
708
+ } = _ref;
709
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
710
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
711
+ const mainAxis = getMainAxisFromPlacement(placement);
712
+ const length = getLengthFromAxis(mainAxis);
713
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
714
+ const side = getSide(placement);
715
+ const isVertical = mainAxis === 'x';
716
+ let coords;
717
+
718
+ switch (side) {
719
+ case 'top':
720
+ coords = {
721
+ x: commonX,
722
+ y: reference.y - floating.height
723
+ };
724
+ break;
725
+
726
+ case 'bottom':
727
+ coords = {
728
+ x: commonX,
729
+ y: reference.y + reference.height
730
+ };
731
+ break;
732
+
733
+ case 'right':
734
+ coords = {
735
+ x: reference.x + reference.width,
736
+ y: commonY
737
+ };
738
+ break;
739
+
740
+ case 'left':
741
+ coords = {
742
+ x: reference.x - floating.width,
743
+ y: commonY
744
+ };
745
+ break;
746
+
747
+ default:
748
+ coords = {
749
+ x: reference.x,
750
+ y: reference.y
751
+ };
752
+ }
753
+
754
+ switch (getAlignment(placement)) {
755
+ case 'start':
756
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
757
+ break;
758
+
759
+ case 'end':
760
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
761
+ break;
762
+ }
763
+
764
+ return coords;
765
+ }
766
+
767
+ /**
768
+ * Computes the `x` and `y` coordinates that will place the floating element
769
+ * next to a reference element when it is given a certain positioning strategy.
770
+ *
771
+ * This export does not have any `platform` interface logic. You will need to
772
+ * write one for the platform you are using Floating UI with.
773
+ */
774
+
775
+ const computePosition$1 = async (reference, floating, config) => {
776
+ const {
777
+ placement = 'bottom',
778
+ strategy = 'absolute',
779
+ middleware = [],
780
+ platform
781
+ } = config;
782
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
783
+
784
+ let rects = await platform.getElementRects({
785
+ reference,
786
+ floating,
787
+ strategy
788
+ });
789
+ let {
790
+ x,
791
+ y
792
+ } = computeCoordsFromPlacement(rects, placement, rtl);
793
+ let statefulPlacement = placement;
794
+ let middlewareData = {};
795
+
796
+ for (let i = 0; i < middleware.length; i++) {
797
+
798
+ const {
799
+ name,
800
+ fn
801
+ } = middleware[i];
802
+ const {
803
+ x: nextX,
804
+ y: nextY,
805
+ data,
806
+ reset
807
+ } = await fn({
808
+ x,
809
+ y,
810
+ initialPlacement: placement,
811
+ placement: statefulPlacement,
812
+ strategy,
813
+ middlewareData,
814
+ rects,
815
+ platform,
816
+ elements: {
817
+ reference,
818
+ floating
819
+ }
820
+ });
821
+ x = nextX != null ? nextX : x;
822
+ y = nextY != null ? nextY : y;
823
+ middlewareData = { ...middlewareData,
824
+ [name]: { ...middlewareData[name],
825
+ ...data
826
+ }
827
+ };
828
+
829
+ if (reset) {
830
+ if (typeof reset === 'object') {
831
+ if (reset.placement) {
832
+ statefulPlacement = reset.placement;
833
+ }
834
+
835
+ if (reset.rects) {
836
+ rects = reset.rects === true ? await platform.getElementRects({
837
+ reference,
838
+ floating,
839
+ strategy
840
+ }) : reset.rects;
841
+ }
842
+
843
+ ({
844
+ x,
845
+ y
846
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
847
+ }
848
+
849
+ i = -1;
850
+ continue;
851
+ }
852
+ }
853
+
854
+ return {
855
+ x,
856
+ y,
857
+ placement: statefulPlacement,
858
+ strategy,
859
+ middlewareData
860
+ };
861
+ };
862
+
863
+ function expandPaddingObject(padding) {
864
+ return {
865
+ top: 0,
866
+ right: 0,
867
+ bottom: 0,
868
+ left: 0,
869
+ ...padding
870
+ };
871
+ }
872
+
873
+ function getSideObjectFromPadding(padding) {
874
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
875
+ top: padding,
876
+ right: padding,
877
+ bottom: padding,
878
+ left: padding
879
+ };
880
+ }
881
+
882
+ function rectToClientRect(rect) {
883
+ return { ...rect,
884
+ top: rect.y,
885
+ left: rect.x,
886
+ right: rect.x + rect.width,
887
+ bottom: rect.y + rect.height
888
+ };
889
+ }
890
+
891
+ /**
892
+ * Resolves with an object of overflow side offsets that determine how much the
893
+ * element is overflowing a given clipping boundary.
894
+ * - positive = overflowing the boundary by that number of pixels
895
+ * - negative = how many pixels left before it will overflow
896
+ * - 0 = lies flush with the boundary
897
+ * @see https://floating-ui.com/docs/detectOverflow
898
+ */
899
+ async function detectOverflow(middlewareArguments, options) {
900
+ var _await$platform$isEle;
901
+
902
+ if (options === void 0) {
903
+ options = {};
904
+ }
905
+
906
+ const {
907
+ x,
908
+ y,
909
+ platform,
910
+ rects,
911
+ elements,
912
+ strategy
913
+ } = middlewareArguments;
914
+ const {
915
+ boundary = 'clippingAncestors',
916
+ rootBoundary = 'viewport',
917
+ elementContext = 'floating',
918
+ altBoundary = false,
919
+ padding = 0
920
+ } = options;
921
+ const paddingObject = getSideObjectFromPadding(padding);
922
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
923
+ const element = elements[altBoundary ? altContext : elementContext];
924
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
925
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
926
+ boundary,
927
+ rootBoundary,
928
+ strategy
929
+ }));
930
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
931
+ rect: elementContext === 'floating' ? { ...rects.floating,
932
+ x,
933
+ y
934
+ } : rects.reference,
935
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
936
+ strategy
937
+ }) : rects[elementContext]); // positive = overflowing the clipping rect
938
+ // 0 or negative = within the clipping rect
939
+
940
+ return {
941
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
942
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
943
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
944
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
945
+ };
946
+ }
947
+
948
+ const hash$1 = {
949
+ left: 'right',
950
+ right: 'left',
951
+ bottom: 'top',
952
+ top: 'bottom'
953
+ };
954
+ function getOppositePlacement(placement) {
955
+ return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
956
+ }
957
+
958
+ function getAlignmentSides(placement, rects, rtl) {
959
+ if (rtl === void 0) {
960
+ rtl = false;
961
+ }
962
+
963
+ const alignment = getAlignment(placement);
964
+ const mainAxis = getMainAxisFromPlacement(placement);
965
+ const length = getLengthFromAxis(mainAxis);
966
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
967
+
968
+ if (rects.reference[length] > rects.floating[length]) {
969
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
970
+ }
971
+
972
+ return {
973
+ main: mainAlignmentSide,
974
+ cross: getOppositePlacement(mainAlignmentSide)
975
+ };
976
+ }
977
+
978
+ const hash = {
979
+ start: 'end',
980
+ end: 'start'
981
+ };
982
+ function getOppositeAlignmentPlacement(placement) {
983
+ return placement.replace(/start|end/g, matched => hash[matched]);
984
+ }
985
+
986
+ function getExpandedPlacements(placement) {
987
+ const oppositePlacement = getOppositePlacement(placement);
988
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
989
+ }
990
+
991
+ /**
992
+ * Changes the placement of the floating element to one that will fit if the
993
+ * initially specified `placement` does not.
994
+ * @see https://floating-ui.com/docs/flip
995
+ */
996
+ const flip = function (options) {
997
+ if (options === void 0) {
998
+ options = {};
999
+ }
1000
+
1001
+ return {
1002
+ name: 'flip',
1003
+ options,
1004
+
1005
+ async fn(middlewareArguments) {
1006
+ var _middlewareData$flip;
1007
+
1008
+ const {
1009
+ placement,
1010
+ middlewareData,
1011
+ rects,
1012
+ initialPlacement,
1013
+ platform,
1014
+ elements
1015
+ } = middlewareArguments;
1016
+ const {
1017
+ mainAxis: checkMainAxis = true,
1018
+ crossAxis: checkCrossAxis = true,
1019
+ fallbackPlacements: specifiedFallbackPlacements,
1020
+ fallbackStrategy = 'bestFit',
1021
+ flipAlignment = true,
1022
+ ...detectOverflowOptions
1023
+ } = options;
1024
+ const side = getSide(placement);
1025
+ const isBasePlacement = side === initialPlacement;
1026
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1027
+ const placements = [initialPlacement, ...fallbackPlacements];
1028
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
1029
+ const overflows = [];
1030
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1031
+
1032
+ if (checkMainAxis) {
1033
+ overflows.push(overflow[side]);
1034
+ }
1035
+
1036
+ if (checkCrossAxis) {
1037
+ const {
1038
+ main,
1039
+ cross
1040
+ } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1041
+ overflows.push(overflow[main], overflow[cross]);
1042
+ }
1043
+
1044
+ overflowsData = [...overflowsData, {
1045
+ placement,
1046
+ overflows
1047
+ }]; // One or more sides is overflowing
1048
+
1049
+ if (!overflows.every(side => side <= 0)) {
1050
+ var _middlewareData$flip$, _middlewareData$flip2;
1051
+
1052
+ const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
1053
+ const nextPlacement = placements[nextIndex];
1054
+
1055
+ if (nextPlacement) {
1056
+ // Try next placement and re-run the lifecycle
1057
+ return {
1058
+ data: {
1059
+ index: nextIndex,
1060
+ overflows: overflowsData
1061
+ },
1062
+ reset: {
1063
+ placement: nextPlacement
1064
+ }
1065
+ };
1066
+ }
1067
+
1068
+ let resetPlacement = 'bottom';
1069
+
1070
+ switch (fallbackStrategy) {
1071
+ case 'bestFit':
1072
+ {
1073
+ var _overflowsData$map$so;
1074
+
1075
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
1076
+
1077
+ if (placement) {
1078
+ resetPlacement = placement;
1079
+ }
1080
+
1081
+ break;
1082
+ }
1083
+
1084
+ case 'initialPlacement':
1085
+ resetPlacement = initialPlacement;
1086
+ break;
1087
+ }
1088
+
1089
+ if (placement !== resetPlacement) {
1090
+ return {
1091
+ reset: {
1092
+ placement: resetPlacement
1093
+ }
1094
+ };
1095
+ }
1096
+ }
1097
+
1098
+ return {};
1099
+ }
1100
+
1101
+ };
1102
+ };
1103
+
1104
+ function convertValueToCoords(placement, rects, value, rtl) {
1105
+ if (rtl === void 0) {
1106
+ rtl = false;
1107
+ }
1108
+
1109
+ const side = getSide(placement);
1110
+ const alignment = getAlignment(placement);
1111
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
1112
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1113
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1114
+ const rawValue = typeof value === 'function' ? value({ ...rects,
1115
+ placement
1116
+ }) : value; // eslint-disable-next-line prefer-const
1117
+
1118
+ let {
1119
+ mainAxis,
1120
+ crossAxis,
1121
+ alignmentAxis
1122
+ } = typeof rawValue === 'number' ? {
1123
+ mainAxis: rawValue,
1124
+ crossAxis: 0,
1125
+ alignmentAxis: null
1126
+ } : {
1127
+ mainAxis: 0,
1128
+ crossAxis: 0,
1129
+ alignmentAxis: null,
1130
+ ...rawValue
1131
+ };
1132
+
1133
+ if (alignment && typeof alignmentAxis === 'number') {
1134
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1135
+ }
1136
+
1137
+ return isVertical ? {
1138
+ x: crossAxis * crossAxisMulti,
1139
+ y: mainAxis * mainAxisMulti
1140
+ } : {
1141
+ x: mainAxis * mainAxisMulti,
1142
+ y: crossAxis * crossAxisMulti
1143
+ };
1144
+ }
1145
+ /**
1146
+ * Displaces the floating element from its reference element.
1147
+ * @see https://floating-ui.com/docs/offset
1148
+ */
1149
+
1150
+ const offset = function (value) {
1151
+ if (value === void 0) {
1152
+ value = 0;
1153
+ }
1154
+
1155
+ return {
1156
+ name: 'offset',
1157
+ options: value,
1158
+
1159
+ async fn(middlewareArguments) {
1160
+ const {
1161
+ x,
1162
+ y,
1163
+ placement,
1164
+ rects,
1165
+ platform,
1166
+ elements
1167
+ } = middlewareArguments;
1168
+ const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1169
+ return {
1170
+ x: x + diffCoords.x,
1171
+ y: y + diffCoords.y,
1172
+ data: diffCoords
1173
+ };
1174
+ }
1175
+
1176
+ };
1177
+ };
1178
+
1179
+ function isWindow(value) {
1180
+ return (value == null ? void 0 : value.toString()) === '[object Window]';
1181
+ }
1182
+ function getWindow(node) {
1183
+ if (node == null) {
1184
+ return window;
1185
+ }
1186
+
1187
+ if (!isWindow(node)) {
1188
+ const ownerDocument = node.ownerDocument;
1189
+ return ownerDocument ? ownerDocument.defaultView || window : window;
1190
+ }
1191
+
1192
+ return node;
1193
+ }
1194
+
1195
+ function getComputedStyle$1(element) {
1196
+ return getWindow(element).getComputedStyle(element);
1197
+ }
1198
+
1199
+ function getNodeName(node) {
1200
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
1201
+ }
1202
+
1203
+ function isHTMLElement(value) {
1204
+ return value instanceof getWindow(value).HTMLElement;
1205
+ }
1206
+ function isElement(value) {
1207
+ return value instanceof getWindow(value).Element;
1208
+ }
1209
+ function isNode(value) {
1210
+ return value instanceof getWindow(value).Node;
1211
+ }
1212
+ function isShadowRoot(node) {
1213
+ const OwnElement = getWindow(node).ShadowRoot;
1214
+ return node instanceof OwnElement || node instanceof ShadowRoot;
1215
+ }
1216
+ function isOverflowElement(element) {
1217
+ // Firefox wants us to check `-x` and `-y` variations as well
1218
+ const {
1219
+ overflow,
1220
+ overflowX,
1221
+ overflowY
1222
+ } = getComputedStyle$1(element);
1223
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1224
+ }
1225
+ function isTableElement(element) {
1226
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1227
+ }
1228
+ function isContainingBlock(element) {
1229
+ // TODO: Try and use feature detection here instead
1230
+ const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
1231
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1232
+ // create a containing block.
1233
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1234
+
1235
+ return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
1236
+ }
1237
+ function isLayoutViewport() {
1238
+ // Not Safari
1239
+ return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent); // Feature detection for this fails in various ways
1240
+ // • Always-visible scrollbar or not
1241
+ // • Width of <html>, etc.
1242
+ // const vV = win.visualViewport;
1243
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
1244
+ }
1245
+
1246
+ const min = Math.min;
1247
+ const max = Math.max;
1248
+ const round = Math.round;
1249
+
1250
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1251
+ if (includeScale === void 0) {
1252
+ includeScale = false;
1253
+ }
1254
+
1255
+ if (isFixedStrategy === void 0) {
1256
+ isFixedStrategy = false;
1257
+ }
1258
+
1259
+ const clientRect = element.getBoundingClientRect();
1260
+ let scaleX = 1;
1261
+ let scaleY = 1;
1262
+
1263
+ if (includeScale && isHTMLElement(element)) {
1264
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1265
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1266
+ }
1267
+
1268
+ const win = isElement(element) ? getWindow(element) : window;
1269
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1270
+ const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
1271
+ const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
1272
+ const width = clientRect.width / scaleX;
1273
+ const height = clientRect.height / scaleY;
1274
+ return {
1275
+ width,
1276
+ height,
1277
+ top: y,
1278
+ right: x + width,
1279
+ bottom: y + height,
1280
+ left: x,
1281
+ x,
1282
+ y
1283
+ };
1284
+ }
1285
+
1286
+ function getDocumentElement(node) {
1287
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1288
+ }
1289
+
1290
+ function getNodeScroll(element) {
1291
+ if (isWindow(element)) {
1292
+ return {
1293
+ scrollLeft: element.pageXOffset,
1294
+ scrollTop: element.pageYOffset
1295
+ };
1296
+ }
1297
+
1298
+ return {
1299
+ scrollLeft: element.scrollLeft,
1300
+ scrollTop: element.scrollTop
1301
+ };
1302
+ }
1303
+
1304
+ function getWindowScrollBarX(element) {
1305
+ // If <html> has a CSS width greater than the viewport, then this will be
1306
+ // incorrect for RTL.
1307
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1308
+ }
1309
+
1310
+ function isScaled(element) {
1311
+ const rect = getBoundingClientRect(element);
1312
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1313
+ }
1314
+
1315
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1316
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1317
+ const documentElement = getDocumentElement(offsetParent);
1318
+ const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
1319
+ let scroll = {
1320
+ scrollLeft: 0,
1321
+ scrollTop: 0
1322
+ };
1323
+ const offsets = {
1324
+ x: 0,
1325
+ y: 0
1326
+ };
1327
+
1328
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1329
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1330
+ scroll = getNodeScroll(offsetParent);
1331
+ }
1332
+
1333
+ if (isHTMLElement(offsetParent)) {
1334
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1335
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1336
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1337
+ } else if (documentElement) {
1338
+ offsets.x = getWindowScrollBarX(documentElement);
1339
+ }
1340
+ }
1341
+
1342
+ return {
1343
+ x: rect.left + scroll.scrollLeft - offsets.x,
1344
+ y: rect.top + scroll.scrollTop - offsets.y,
1345
+ width: rect.width,
1346
+ height: rect.height
1347
+ };
1348
+ }
1349
+
1350
+ function getParentNode(node) {
1351
+ if (getNodeName(node) === 'html') {
1352
+ return node;
1353
+ }
1354
+
1355
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1356
+ // @ts-ignore
1357
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1358
+ node.parentNode || ( // DOM Element detected
1359
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1360
+ getDocumentElement(node) // fallback
1361
+
1362
+ );
1363
+ }
1364
+
1365
+ function getTrueOffsetParent(element) {
1366
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1367
+ return null;
1368
+ }
1369
+
1370
+ return element.offsetParent;
1371
+ }
1372
+
1373
+ function getContainingBlock(element) {
1374
+ let currentNode = getParentNode(element);
1375
+
1376
+ if (isShadowRoot(currentNode)) {
1377
+ currentNode = currentNode.host;
1378
+ }
1379
+
1380
+ while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
1381
+ if (isContainingBlock(currentNode)) {
1382
+ return currentNode;
1383
+ } else {
1384
+ currentNode = currentNode.parentNode;
1385
+ }
1386
+ }
1387
+
1388
+ return null;
1389
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1390
+ // such as table ancestors and cross browser bugs.
1391
+
1392
+
1393
+ function getOffsetParent(element) {
1394
+ const window = getWindow(element);
1395
+ let offsetParent = getTrueOffsetParent(element);
1396
+
1397
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1398
+ offsetParent = getTrueOffsetParent(offsetParent);
1399
+ }
1400
+
1401
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1402
+ return window;
1403
+ }
1404
+
1405
+ return offsetParent || getContainingBlock(element) || window;
1406
+ }
1407
+
1408
+ function getDimensions(element) {
1409
+ if (isHTMLElement(element)) {
1410
+ return {
1411
+ width: element.offsetWidth,
1412
+ height: element.offsetHeight
1413
+ };
1414
+ }
1415
+
1416
+ const rect = getBoundingClientRect(element);
1417
+ return {
1418
+ width: rect.width,
1419
+ height: rect.height
1420
+ };
1421
+ }
1422
+
1423
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1424
+ let {
1425
+ rect,
1426
+ offsetParent,
1427
+ strategy
1428
+ } = _ref;
1429
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1430
+ const documentElement = getDocumentElement(offsetParent);
1431
+
1432
+ if (offsetParent === documentElement) {
1433
+ return rect;
1434
+ }
1435
+
1436
+ let scroll = {
1437
+ scrollLeft: 0,
1438
+ scrollTop: 0
1439
+ };
1440
+ const offsets = {
1441
+ x: 0,
1442
+ y: 0
1443
+ };
1444
+
1445
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1446
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1447
+ scroll = getNodeScroll(offsetParent);
1448
+ }
1449
+
1450
+ if (isHTMLElement(offsetParent)) {
1451
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1452
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1453
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1454
+ } // This doesn't appear to be need to be negated.
1455
+ // else if (documentElement) {
1456
+ // offsets.x = getWindowScrollBarX(documentElement);
1457
+ // }
1458
+
1459
+ }
1460
+
1461
+ return { ...rect,
1462
+ x: rect.x - scroll.scrollLeft + offsets.x,
1463
+ y: rect.y - scroll.scrollTop + offsets.y
1464
+ };
1465
+ }
1466
+
1467
+ function getViewportRect(element, strategy) {
1468
+ const win = getWindow(element);
1469
+ const html = getDocumentElement(element);
1470
+ const visualViewport = win.visualViewport;
1471
+ let width = html.clientWidth;
1472
+ let height = html.clientHeight;
1473
+ let x = 0;
1474
+ let y = 0;
1475
+
1476
+ if (visualViewport) {
1477
+ width = visualViewport.width;
1478
+ height = visualViewport.height;
1479
+ const layoutViewport = isLayoutViewport();
1480
+
1481
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1482
+ x = visualViewport.offsetLeft;
1483
+ y = visualViewport.offsetTop;
1484
+ }
1485
+ }
1486
+
1487
+ return {
1488
+ width,
1489
+ height,
1490
+ x,
1491
+ y
1492
+ };
1493
+ }
1494
+
1495
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1496
+
1497
+ function getDocumentRect(element) {
1498
+ var _element$ownerDocumen;
1499
+
1500
+ const html = getDocumentElement(element);
1501
+ const scroll = getNodeScroll(element);
1502
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1503
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1504
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1505
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1506
+ const y = -scroll.scrollTop;
1507
+
1508
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1509
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1510
+ }
1511
+
1512
+ return {
1513
+ width,
1514
+ height,
1515
+ x,
1516
+ y
1517
+ };
1518
+ }
1519
+
1520
+ function getNearestOverflowAncestor(node) {
1521
+ const parentNode = getParentNode(node);
1522
+
1523
+ if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1524
+ // @ts-ignore assume body is always available
1525
+ return node.ownerDocument.body;
1526
+ }
1527
+
1528
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1529
+ return parentNode;
1530
+ }
1531
+
1532
+ return getNearestOverflowAncestor(parentNode);
1533
+ }
1534
+
1535
+ function getOverflowAncestors(node, list) {
1536
+ var _node$ownerDocument;
1537
+
1538
+ if (list === void 0) {
1539
+ list = [];
1540
+ }
1541
+
1542
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1543
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1544
+ const win = getWindow(scrollableAncestor);
1545
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1546
+ const updatedList = list.concat(target);
1547
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1548
+ updatedList.concat(getOverflowAncestors(getParentNode(target)));
1549
+ }
1550
+
1551
+ function contains(parent, child) {
1552
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1553
+
1554
+ if (parent.contains(child)) {
1555
+ return true;
1556
+ } // then fallback to custom implementation with Shadow DOM support
1557
+ else if (rootNode && isShadowRoot(rootNode)) {
1558
+ let next = child;
1559
+
1560
+ do {
1561
+ // use `===` replace node.isSameNode()
1562
+ if (next && parent === next) {
1563
+ return true;
1564
+ } // @ts-ignore: need a better way to handle this...
1565
+
1566
+
1567
+ next = next.parentNode || next.host;
1568
+ } while (next);
1569
+ }
1570
+
1571
+ return false;
1572
+ }
1573
+
1574
+ function getInnerBoundingClientRect(element, strategy) {
1575
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1576
+ const top = clientRect.top + element.clientTop;
1577
+ const left = clientRect.left + element.clientLeft;
1578
+ return {
1579
+ top,
1580
+ left,
1581
+ x: left,
1582
+ y: top,
1583
+ right: left + element.clientWidth,
1584
+ bottom: top + element.clientHeight,
1585
+ width: element.clientWidth,
1586
+ height: element.clientHeight
1587
+ };
1588
+ }
1589
+
1590
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1591
+ if (clippingParent === 'viewport') {
1592
+ return rectToClientRect(getViewportRect(element, strategy));
1593
+ }
1594
+
1595
+ if (isElement(clippingParent)) {
1596
+ return getInnerBoundingClientRect(clippingParent, strategy);
1597
+ }
1598
+
1599
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1600
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1601
+ // clipping (or hiding) overflowing elements with a position different from
1602
+ // `initial`
1603
+
1604
+
1605
+ function getClippingAncestors(element) {
1606
+ const clippingAncestors = getOverflowAncestors(element);
1607
+ const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1608
+ const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1609
+
1610
+ if (!isElement(clipperElement)) {
1611
+ return [];
1612
+ } // @ts-ignore isElement check ensures we return Array<Element>
1613
+
1614
+
1615
+ return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1616
+ } // Gets the maximum area that the element is visible in due to any number of
1617
+ // clipping ancestors
1618
+
1619
+
1620
+ function getClippingRect(_ref) {
1621
+ let {
1622
+ element,
1623
+ boundary,
1624
+ rootBoundary,
1625
+ strategy
1626
+ } = _ref;
1627
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1628
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1629
+ const firstClippingAncestor = clippingAncestors[0];
1630
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1631
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1632
+ accRect.top = max(rect.top, accRect.top);
1633
+ accRect.right = min(rect.right, accRect.right);
1634
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1635
+ accRect.left = max(rect.left, accRect.left);
1636
+ return accRect;
1637
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1638
+ return {
1639
+ width: clippingRect.right - clippingRect.left,
1640
+ height: clippingRect.bottom - clippingRect.top,
1641
+ x: clippingRect.left,
1642
+ y: clippingRect.top
1643
+ };
1644
+ }
1645
+
1646
+ const platform = {
1647
+ getClippingRect,
1648
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1649
+ isElement,
1650
+ getDimensions,
1651
+ getOffsetParent,
1652
+ getDocumentElement,
1653
+ getElementRects: _ref => {
1654
+ let {
1655
+ reference,
1656
+ floating,
1657
+ strategy
1658
+ } = _ref;
1659
+ return {
1660
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1661
+ floating: { ...getDimensions(floating),
1662
+ x: 0,
1663
+ y: 0
1664
+ }
1665
+ };
1666
+ },
1667
+ getClientRects: element => Array.from(element.getClientRects()),
1668
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1669
+ };
1670
+
1671
+ /**
1672
+ * Automatically updates the position of the floating element when necessary.
1673
+ * @see https://floating-ui.com/docs/autoUpdate
1674
+ */
1675
+ function autoUpdate(reference, floating, update, options) {
1676
+ if (options === void 0) {
1677
+ options = {};
1678
+ }
1679
+
1680
+ const {
1681
+ ancestorScroll: _ancestorScroll = true,
1682
+ ancestorResize: _ancestorResize = true,
1683
+ elementResize: _elementResize = true,
1684
+ animationFrame = false
1685
+ } = options;
1686
+ let cleanedUp = false;
1687
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1688
+ const ancestorResize = _ancestorResize && !animationFrame;
1689
+ const elementResize = _elementResize && !animationFrame;
1690
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1691
+ ancestors.forEach(ancestor => {
1692
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1693
+ passive: true
1694
+ });
1695
+ ancestorResize && ancestor.addEventListener('resize', update);
1696
+ });
1697
+ let observer = null;
1698
+
1699
+ if (elementResize) {
1700
+ observer = new ResizeObserver(update);
1701
+ isElement(reference) && observer.observe(reference);
1702
+ observer.observe(floating);
1703
+ }
1704
+
1705
+ let frameId;
1706
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1707
+
1708
+ if (animationFrame) {
1709
+ frameLoop();
1710
+ }
1711
+
1712
+ function frameLoop() {
1713
+ if (cleanedUp) {
1714
+ return;
1715
+ }
1716
+
1717
+ const nextRefRect = getBoundingClientRect(reference);
1718
+
1719
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1720
+ update();
1721
+ }
1722
+
1723
+ prevRefRect = nextRefRect;
1724
+ frameId = requestAnimationFrame(frameLoop);
1725
+ }
1726
+
1727
+ return () => {
1728
+ var _observer;
1729
+
1730
+ cleanedUp = true;
1731
+ ancestors.forEach(ancestor => {
1732
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1733
+ ancestorResize && ancestor.removeEventListener('resize', update);
1734
+ });
1735
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1736
+ observer = null;
1737
+
1738
+ if (animationFrame) {
1739
+ cancelAnimationFrame(frameId);
1740
+ }
1741
+ };
1742
+ }
1743
+
1744
+ /**
1745
+ * Computes the `x` and `y` coordinates that will place the floating element
1746
+ * next to a reference element when it is given a certain CSS positioning
1747
+ * strategy.
1748
+ */
1749
+
1750
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1751
+ platform,
1752
+ ...options
1753
+ });
1754
+
1755
+ /*!
1756
+ * tabbable 5.3.1
1757
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
1758
+ */
1759
+ var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]:not(slot)', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])', 'details>summary:first-of-type', 'details'];
1760
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
1761
+ var NoElement = typeof Element === 'undefined';
1762
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1763
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
1764
+ return element.getRootNode();
1765
+ } : function (element) {
1766
+ return element.ownerDocument;
1767
+ };
1768
+ /**
1769
+ * @param {Element} el container to check in
1770
+ * @param {boolean} includeContainer add container to check
1771
+ * @param {(node: Element) => boolean} filter filter candidates
1772
+ * @returns {Element[]}
1773
+ */
1774
+
1775
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
1776
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
1777
+
1778
+ if (includeContainer && matches.call(el, candidateSelector)) {
1779
+ candidates.unshift(el);
1780
+ }
1781
+
1782
+ candidates = candidates.filter(filter);
1783
+ return candidates;
1784
+ };
1785
+ /**
1786
+ * @callback GetShadowRoot
1787
+ * @param {Element} element to check for shadow root
1788
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
1789
+ */
1790
+
1791
+ /**
1792
+ * @typedef {Object} CandidatesScope
1793
+ * @property {Element} scope contains inner candidates
1794
+ * @property {Element[]} candidates
1795
+ */
1796
+
1797
+ /**
1798
+ * @typedef {Object} IterativeOptions
1799
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
1800
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
1801
+ * or a boolean stating if it has an undisclosed shadow root
1802
+ * @property {(node: Element) => boolean} filter filter candidates
1803
+ * @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list
1804
+ */
1805
+
1806
+ /**
1807
+ * @param {Element[]} elements list of element containers to match candidates from
1808
+ * @param {boolean} includeContainer add container list to check
1809
+ * @param {IterativeOptions} options
1810
+ * @returns {Array.<Element|CandidatesScope>}
1811
+ */
1812
+
1813
+
1814
+ var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
1815
+ var candidates = [];
1816
+ var elementsToCheck = Array.from(elements);
1817
+
1818
+ while (elementsToCheck.length) {
1819
+ var element = elementsToCheck.shift();
1820
+
1821
+ if (element.tagName === 'SLOT') {
1822
+ // add shadow dom slot scope (slot itself cannot be focusable)
1823
+ var assigned = element.assignedElements();
1824
+ var content = assigned.length ? assigned : element.children;
1825
+ var nestedCandidates = getCandidatesIteratively(content, true, options);
1826
+
1827
+ if (options.flatten) {
1828
+ candidates.push.apply(candidates, nestedCandidates);
1829
+ } else {
1830
+ candidates.push({
1831
+ scope: element,
1832
+ candidates: nestedCandidates
1833
+ });
1834
+ }
1835
+ } else {
1836
+ // check candidate element
1837
+ var validCandidate = matches.call(element, candidateSelector);
1838
+
1839
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
1840
+ candidates.push(element);
1841
+ } // iterate over shadow content if possible
1842
+
1843
+
1844
+ var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
1845
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
1846
+
1847
+ if (shadowRoot) {
1848
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
1849
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
1850
+ // child candidates found because they're likely slotted elements (elements that are
1851
+ // children of the web component element (which has the shadow), in the light dom, but
1852
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
1853
+ // _after_ we return from this recursive call
1854
+ var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
1855
+
1856
+ if (options.flatten) {
1857
+ candidates.push.apply(candidates, _nestedCandidates);
1858
+ } else {
1859
+ candidates.push({
1860
+ scope: element,
1861
+ candidates: _nestedCandidates
1862
+ });
1863
+ }
1864
+ } else {
1865
+ // there's not shadow so just dig into the element's (light dom) children
1866
+ // __without__ giving the element special scope treatment
1867
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
1868
+ }
1869
+ }
1870
+ }
1871
+
1872
+ return candidates;
1873
+ };
1874
+
1875
+ var getTabindex = function getTabindex(node, isScope) {
1876
+ if (node.tabIndex < 0) {
1877
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
1878
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
1879
+ // yet they are still part of the regular tab order; in FF, they get a default
1880
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
1881
+ // order, consider their tab index to be 0.
1882
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
1883
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
1884
+ //
1885
+ // isScope is positive for custom element with shadow root or slot that by default
1886
+ // have tabIndex -1, but need to be sorted by document order in order for their
1887
+ // content to be inserted in the correct position
1888
+ if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
1889
+ return 0;
1890
+ }
1891
+ }
1892
+
1893
+ return node.tabIndex;
1894
+ };
1895
+
1896
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
1897
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
1898
+ };
1899
+
1900
+ var isInput = function isInput(node) {
1901
+ return node.tagName === 'INPUT';
1902
+ };
1903
+
1904
+ var isHiddenInput = function isHiddenInput(node) {
1905
+ return isInput(node) && node.type === 'hidden';
1906
+ };
1907
+
1908
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
1909
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
1910
+ return child.tagName === 'SUMMARY';
1911
+ });
1912
+ return r;
1913
+ };
1914
+
1915
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
1916
+ for (var i = 0; i < nodes.length; i++) {
1917
+ if (nodes[i].checked && nodes[i].form === form) {
1918
+ return nodes[i];
1919
+ }
1920
+ }
1921
+ };
1922
+
1923
+ var isTabbableRadio = function isTabbableRadio(node) {
1924
+ if (!node.name) {
1925
+ return true;
1926
+ }
1927
+
1928
+ var radioScope = node.form || getRootNode(node);
1929
+
1930
+ var queryRadios = function queryRadios(name) {
1931
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
1932
+ };
1933
+
1934
+ var radioSet;
1935
+
1936
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
1937
+ radioSet = queryRadios(window.CSS.escape(node.name));
1938
+ } else {
1939
+ try {
1940
+ radioSet = queryRadios(node.name);
1941
+ } catch (err) {
1942
+ // eslint-disable-next-line no-console
1943
+ console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
1944
+ return false;
1945
+ }
1946
+ }
1947
+
1948
+ var checked = getCheckedRadio(radioSet, node.form);
1949
+ return !checked || checked === node;
1950
+ };
1951
+
1952
+ var isRadio = function isRadio(node) {
1953
+ return isInput(node) && node.type === 'radio';
1954
+ };
1955
+
1956
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
1957
+ return isRadio(node) && !isTabbableRadio(node);
1958
+ };
1959
+
1960
+ var isZeroArea = function isZeroArea(node) {
1961
+ var _node$getBoundingClie = node.getBoundingClientRect(),
1962
+ width = _node$getBoundingClie.width,
1963
+ height = _node$getBoundingClie.height;
1964
+
1965
+ return width === 0 && height === 0;
1966
+ };
1967
+
1968
+ var isHidden = function isHidden(node, _ref) {
1969
+ var displayCheck = _ref.displayCheck,
1970
+ getShadowRoot = _ref.getShadowRoot;
1971
+
1972
+ if (getComputedStyle(node).visibility === 'hidden') {
1973
+ return true;
1974
+ }
1975
+
1976
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
1977
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
1978
+
1979
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
1980
+ return true;
1981
+ }
1982
+
1983
+ if (!displayCheck || displayCheck === 'full') {
1984
+ if (typeof getShadowRoot === 'function') {
1985
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
1986
+ // 'non-zero-area' fallback
1987
+ var originalNode = node;
1988
+
1989
+ while (node) {
1990
+ var parentElement = node.parentElement;
1991
+ var rootNode = getRootNode(node);
1992
+
1993
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
1994
+ ) {
1995
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
1996
+ // fall back to a non-zero-area test
1997
+ return isZeroArea(node);
1998
+ } else if (node.assignedSlot) {
1999
+ // iterate up slot
2000
+ node = node.assignedSlot;
2001
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
2002
+ // cross shadow boundary
2003
+ node = rootNode.host;
2004
+ } else {
2005
+ // iterate up normal dom
2006
+ node = parentElement;
2007
+ }
2008
+ }
2009
+
2010
+ node = originalNode;
2011
+ } // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
2012
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
2013
+ // it might be a falsy value, which means shadow DOM support is disabled
2014
+ // didn't find it sitting in an undisclosed shadow (or shadows are disabled) so now we
2015
+ // can just test to see if it would normally be visible or not
2016
+ // this works wherever the node is: if there's at least one client rect, it's
2017
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
2018
+ // node itself is hidden in place of its contents; and there's no need to search
2019
+ // up the hierarchy either
2020
+
2021
+
2022
+ return !node.getClientRects().length;
2023
+ } else if (displayCheck === 'non-zero-area') {
2024
+ return isZeroArea(node);
2025
+ }
2026
+
2027
+ return false;
2028
+ }; // form fields (nested) inside a disabled fieldset are not focusable/tabbable
2029
+ // unless they are in the _first_ <legend> element of the top-most disabled
2030
+ // fieldset
2031
+
2032
+
2033
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
2034
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
2035
+ var parentNode = node.parentElement; // check if `node` is contained in a disabled <fieldset>
2036
+
2037
+ while (parentNode) {
2038
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
2039
+ // look for the first <legend> among the children of the disabled <fieldset>
2040
+ for (var i = 0; i < parentNode.children.length; i++) {
2041
+ var child = parentNode.children.item(i); // when the first <legend> (in document order) is found
2042
+
2043
+ if (child.tagName === 'LEGEND') {
2044
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
2045
+ // return whether `node` is a descendant of its first <legend>
2046
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
2047
+ }
2048
+ } // the disabled <fieldset> containing `node` has no <legend>
2049
+
2050
+
2051
+ return true;
2052
+ }
2053
+
2054
+ parentNode = parentNode.parentElement;
2055
+ }
2056
+ } // else, node's tabbable/focusable state should not be affected by a fieldset's
2057
+ // enabled/disabled state
2058
+
2059
+
2060
+ return false;
2061
+ };
2062
+
2063
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
2064
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
2065
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
2066
+ return false;
2067
+ }
2068
+
2069
+ return true;
2070
+ };
2071
+
2072
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
2073
+ if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
2074
+ return false;
2075
+ }
2076
+
2077
+ return true;
2078
+ };
2079
+ /**
2080
+ * @param {Array.<Element|CandidatesScope>} candidates
2081
+ * @returns Element[]
2082
+ */
2083
+
2084
+
2085
+ var sortByOrder = function sortByOrder(candidates) {
2086
+ var regularTabbables = [];
2087
+ var orderedTabbables = [];
2088
+ candidates.forEach(function (item, i) {
2089
+ var isScope = !!item.scope;
2090
+ var element = isScope ? item.scope : item;
2091
+ var candidateTabindex = getTabindex(element, isScope);
2092
+ var elements = isScope ? sortByOrder(item.candidates) : element;
2093
+
2094
+ if (candidateTabindex === 0) {
2095
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
2096
+ } else {
2097
+ orderedTabbables.push({
2098
+ documentOrder: i,
2099
+ tabIndex: candidateTabindex,
2100
+ item: item,
2101
+ isScope: isScope,
2102
+ content: elements
2103
+ });
2104
+ }
2105
+ });
2106
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
2107
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
2108
+ return acc;
2109
+ }, []).concat(regularTabbables);
2110
+ };
2111
+
2112
+ var tabbable = function tabbable(el, options) {
2113
+ options = options || {};
2114
+ var candidates;
2115
+
2116
+ if (options.getShadowRoot) {
2117
+ candidates = getCandidatesIteratively([el], options.includeContainer, {
2118
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
2119
+ flatten: false,
2120
+ getShadowRoot: options.getShadowRoot
2121
+ });
2122
+ } else {
2123
+ candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
2124
+ }
2125
+
2126
+ return sortByOrder(candidates);
2127
+ };
2128
+
2129
+ var focusable = function focusable(el, options) {
2130
+ options = options || {};
2131
+ var candidates;
2132
+
2133
+ if (options.getShadowRoot) {
2134
+ candidates = getCandidatesIteratively([el], options.includeContainer, {
2135
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
2136
+ flatten: true,
2137
+ getShadowRoot: options.getShadowRoot
2138
+ });
2139
+ } else {
2140
+ candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
2141
+ }
2142
+
2143
+ return candidates;
2144
+ };
2145
+
2146
+ var isTabbable = function isTabbable(node, options) {
2147
+ options = options || {};
2148
+
2149
+ if (!node) {
2150
+ throw new Error('No node provided');
2151
+ }
2152
+
2153
+ if (matches.call(node, candidateSelector) === false) {
2154
+ return false;
2155
+ }
2156
+
2157
+ return isNodeMatchingSelectorTabbable(options, node);
2158
+ };
2159
+
2160
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
2161
+
2162
+ var isFocusable = function isFocusable(node, options) {
2163
+ options = options || {};
2164
+
2165
+ if (!node) {
2166
+ throw new Error('No node provided');
2167
+ }
2168
+
2169
+ if (matches.call(node, focusableCandidateSelector) === false) {
2170
+ return false;
2171
+ }
2172
+
2173
+ return isNodeMatchingSelectorFocusable(options, node);
2174
+ };
2175
+
2176
+ /*!
2177
+ * focus-trap 6.8.1
2178
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
2179
+ */
2180
+
2181
+ function ownKeys(object, enumerableOnly) {
2182
+ var keys = Object.keys(object);
2183
+
2184
+ if (Object.getOwnPropertySymbols) {
2185
+ var symbols = Object.getOwnPropertySymbols(object);
2186
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
2187
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2188
+ })), keys.push.apply(keys, symbols);
2189
+ }
2190
+
2191
+ return keys;
2192
+ }
2193
+
2194
+ function _objectSpread2(target) {
2195
+ for (var i = 1; i < arguments.length; i++) {
2196
+ var source = null != arguments[i] ? arguments[i] : {};
2197
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
2198
+ _defineProperty(target, key, source[key]);
2199
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
2200
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2201
+ });
2202
+ }
2203
+
2204
+ return target;
2205
+ }
2206
+
2207
+ function _defineProperty(obj, key, value) {
2208
+ if (key in obj) {
2209
+ Object.defineProperty(obj, key, {
2210
+ value: value,
2211
+ enumerable: true,
2212
+ configurable: true,
2213
+ writable: true
2214
+ });
2215
+ } else {
2216
+ obj[key] = value;
2217
+ }
2218
+
2219
+ return obj;
2220
+ }
2221
+
2222
+ var activeFocusTraps = function () {
2223
+ var trapQueue = [];
2224
+ return {
2225
+ activateTrap: function activateTrap(trap) {
2226
+ if (trapQueue.length > 0) {
2227
+ var activeTrap = trapQueue[trapQueue.length - 1];
2228
+
2229
+ if (activeTrap !== trap) {
2230
+ activeTrap.pause();
2231
+ }
2232
+ }
2233
+
2234
+ var trapIndex = trapQueue.indexOf(trap);
2235
+
2236
+ if (trapIndex === -1) {
2237
+ trapQueue.push(trap);
2238
+ } else {
2239
+ // move this existing trap to the front of the queue
2240
+ trapQueue.splice(trapIndex, 1);
2241
+ trapQueue.push(trap);
2242
+ }
2243
+ },
2244
+ deactivateTrap: function deactivateTrap(trap) {
2245
+ var trapIndex = trapQueue.indexOf(trap);
2246
+
2247
+ if (trapIndex !== -1) {
2248
+ trapQueue.splice(trapIndex, 1);
2249
+ }
2250
+
2251
+ if (trapQueue.length > 0) {
2252
+ trapQueue[trapQueue.length - 1].unpause();
2253
+ }
2254
+ }
2255
+ };
2256
+ }();
2257
+
2258
+ var isSelectableInput = function isSelectableInput(node) {
2259
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
2260
+ };
2261
+
2262
+ var isEscapeEvent = function isEscapeEvent(e) {
2263
+ return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
2264
+ };
2265
+
2266
+ var isTabEvent = function isTabEvent(e) {
2267
+ return e.key === 'Tab' || e.keyCode === 9;
2268
+ };
2269
+
2270
+ var delay = function delay(fn) {
2271
+ return setTimeout(fn, 0);
2272
+ }; // Array.find/findIndex() are not supported on IE; this replicates enough
2273
+ // of Array.findIndex() for our needs
2274
+
2275
+
2276
+ var findIndex = function findIndex(arr, fn) {
2277
+ var idx = -1;
2278
+ arr.every(function (value, i) {
2279
+ if (fn(value)) {
2280
+ idx = i;
2281
+ return false; // break
2282
+ }
2283
+
2284
+ return true; // next
2285
+ });
2286
+ return idx;
2287
+ };
2288
+ /**
2289
+ * Get an option's value when it could be a plain value, or a handler that provides
2290
+ * the value.
2291
+ * @param {*} value Option's value to check.
2292
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
2293
+ * @returns {*} The `value`, or the handler's returned value.
2294
+ */
2295
+
2296
+
2297
+ var valueOrHandler = function valueOrHandler(value) {
2298
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2299
+ params[_key - 1] = arguments[_key];
2300
+ }
2301
+
2302
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
2303
+ };
2304
+
2305
+ var getActualTarget = function getActualTarget(event) {
2306
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
2307
+ // shadow host. However, event.target.composedPath() will be an array of
2308
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
2309
+ // outer-most (the host HTML document). If we have access to composedPath(),
2310
+ // then use its first element; otherwise, fall back to event.target (and
2311
+ // this only works for an _open_ shadow DOM; otherwise,
2312
+ // composedPath()[0] === event.target always).
2313
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
2314
+ };
2315
+
2316
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
2317
+ // SSR: a live trap shouldn't be created in this type of environment so this
2318
+ // should be safe code to execute if the `document` option isn't specified
2319
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
2320
+
2321
+ var config = _objectSpread2({
2322
+ returnFocusOnDeactivate: true,
2323
+ escapeDeactivates: true,
2324
+ delayInitialFocus: true
2325
+ }, userOptions);
2326
+
2327
+ var state = {
2328
+ // containers given to createFocusTrap()
2329
+ // @type {Array<HTMLElement>}
2330
+ containers: [],
2331
+ // list of objects identifying tabbable nodes in `containers` in the trap
2332
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
2333
+ // is active, but the trap should never get to a state where there isn't at least one group
2334
+ // with at least one tabbable node in it (that would lead to an error condition that would
2335
+ // result in an error being thrown)
2336
+ // @type {Array<{
2337
+ // container: HTMLElement,
2338
+ // tabbableNodes: Array<HTMLElement>, // empty if none
2339
+ // focusableNodes: Array<HTMLElement>, // empty if none
2340
+ // firstTabbableNode: HTMLElement|null,
2341
+ // lastTabbableNode: HTMLElement|null,
2342
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
2343
+ // }>}
2344
+ containerGroups: [],
2345
+ // same order/length as `containers` list
2346
+ // references to objects in `containerGroups`, but only those that actually have
2347
+ // tabbable nodes in them
2348
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
2349
+ // the same length
2350
+ tabbableGroups: [],
2351
+ nodeFocusedBeforeActivation: null,
2352
+ mostRecentlyFocusedNode: null,
2353
+ active: false,
2354
+ paused: false,
2355
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
2356
+ // has been delayed during activation
2357
+ delayInitialFocusTimer: undefined
2358
+ };
2359
+ var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
2360
+
2361
+ /**
2362
+ * Gets a configuration option value.
2363
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
2364
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
2365
+ * @param {string} optionName Name of the option whose value is sought.
2366
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
2367
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
2368
+ */
2369
+
2370
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
2371
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
2372
+ };
2373
+ /**
2374
+ * Finds the index of the container that contains the element.
2375
+ * @param {HTMLElement} element
2376
+ * @returns {number} Index of the container in either `state.containers` or
2377
+ * `state.containerGroups` (the order/length of these lists are the same); -1
2378
+ * if the element isn't found.
2379
+ */
2380
+
2381
+
2382
+ var findContainerIndex = function findContainerIndex(element) {
2383
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
2384
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
2385
+ // and we still need to find the element in there
2386
+ return state.containerGroups.findIndex(function (_ref) {
2387
+ var container = _ref.container,
2388
+ tabbableNodes = _ref.tabbableNodes;
2389
+ return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
2390
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
2391
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
2392
+ // look inside web components even if open)
2393
+ tabbableNodes.find(function (node) {
2394
+ return node === element;
2395
+ });
2396
+ });
2397
+ };
2398
+ /**
2399
+ * Gets the node for the given option, which is expected to be an option that
2400
+ * can be either a DOM node, a string that is a selector to get a node, `false`
2401
+ * (if a node is explicitly NOT given), or a function that returns any of these
2402
+ * values.
2403
+ * @param {string} optionName
2404
+ * @returns {undefined | false | HTMLElement | SVGElement} Returns
2405
+ * `undefined` if the option is not specified; `false` if the option
2406
+ * resolved to `false` (node explicitly not given); otherwise, the resolved
2407
+ * DOM node.
2408
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
2409
+ * resolve to a node.
2410
+ */
2411
+
2412
+
2413
+ var getNodeForOption = function getNodeForOption(optionName) {
2414
+ var optionValue = config[optionName];
2415
+
2416
+ if (typeof optionValue === 'function') {
2417
+ for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2418
+ params[_key2 - 1] = arguments[_key2];
2419
+ }
2420
+
2421
+ optionValue = optionValue.apply(void 0, params);
2422
+ }
2423
+
2424
+ if (!optionValue) {
2425
+ if (optionValue === undefined || optionValue === false) {
2426
+ return optionValue;
2427
+ } // else, empty string (invalid), null (invalid), 0 (invalid)
2428
+
2429
+
2430
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
2431
+ }
2432
+
2433
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
2434
+
2435
+ if (typeof optionValue === 'string') {
2436
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
2437
+
2438
+ if (!node) {
2439
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
2440
+ }
2441
+ }
2442
+
2443
+ return node;
2444
+ };
2445
+
2446
+ var getInitialFocusNode = function getInitialFocusNode() {
2447
+ var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
2448
+
2449
+ if (node === false) {
2450
+ return false;
2451
+ }
2452
+
2453
+ if (node === undefined) {
2454
+ // option not specified: use fallback options
2455
+ if (findContainerIndex(doc.activeElement) >= 0) {
2456
+ node = doc.activeElement;
2457
+ } else {
2458
+ var firstTabbableGroup = state.tabbableGroups[0];
2459
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
2460
+
2461
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
2462
+ }
2463
+ }
2464
+
2465
+ if (!node) {
2466
+ throw new Error('Your focus-trap needs to have at least one focusable element');
2467
+ }
2468
+
2469
+ return node;
2470
+ };
2471
+
2472
+ var updateTabbableNodes = function updateTabbableNodes() {
2473
+ state.containerGroups = state.containers.map(function (container) {
2474
+ var tabbableNodes = tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
2475
+ // are a superset of tabbable nodes
2476
+
2477
+ var focusableNodes = focusable(container, config.tabbableOptions);
2478
+ return {
2479
+ container: container,
2480
+ tabbableNodes: tabbableNodes,
2481
+ focusableNodes: focusableNodes,
2482
+ firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
2483
+ lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
2484
+
2485
+ /**
2486
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
2487
+ * in this container, if any.
2488
+ * @param {HTMLElement} node
2489
+ * @param {boolean} [forward] True if going in forward tab order; false if going
2490
+ * in reverse.
2491
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
2492
+ */
2493
+ nextTabbableNode: function nextTabbableNode(node) {
2494
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2495
+ // NOTE: If tabindex is positive (in order to manipulate the tab order separate
2496
+ // from the DOM order), this __will not work__ because the list of focusableNodes,
2497
+ // while it contains tabbable nodes, does not sort its nodes in any order other
2498
+ // than DOM order, because it can't: Where would you place focusable (but not
2499
+ // tabbable) nodes in that order? They have no order, because they aren't tabbale...
2500
+ // Support for positive tabindex is already broken and hard to manage (possibly
2501
+ // not supportable, TBD), so this isn't going to make things worse than they
2502
+ // already are, and at least makes things better for the majority of cases where
2503
+ // tabindex is either 0/unset or negative.
2504
+ // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
2505
+ var nodeIdx = focusableNodes.findIndex(function (n) {
2506
+ return n === node;
2507
+ });
2508
+
2509
+ if (nodeIdx < 0) {
2510
+ return undefined;
2511
+ }
2512
+
2513
+ if (forward) {
2514
+ return focusableNodes.slice(nodeIdx + 1).find(function (n) {
2515
+ return isTabbable(n, config.tabbableOptions);
2516
+ });
2517
+ }
2518
+
2519
+ return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
2520
+ return isTabbable(n, config.tabbableOptions);
2521
+ });
2522
+ }
2523
+ };
2524
+ });
2525
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
2526
+ return group.tabbableNodes.length > 0;
2527
+ }); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
2528
+
2529
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
2530
+ ) {
2531
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
2532
+ }
2533
+ };
2534
+
2535
+ var tryFocus = function tryFocus(node) {
2536
+ if (node === false) {
2537
+ return;
2538
+ }
2539
+
2540
+ if (node === doc.activeElement) {
2541
+ return;
2542
+ }
2543
+
2544
+ if (!node || !node.focus) {
2545
+ tryFocus(getInitialFocusNode());
2546
+ return;
2547
+ }
2548
+
2549
+ node.focus({
2550
+ preventScroll: !!config.preventScroll
2551
+ });
2552
+ state.mostRecentlyFocusedNode = node;
2553
+
2554
+ if (isSelectableInput(node)) {
2555
+ node.select();
2556
+ }
2557
+ };
2558
+
2559
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
2560
+ var node = getNodeForOption('setReturnFocus', previousActiveElement);
2561
+ return node ? node : node === false ? false : previousActiveElement;
2562
+ }; // This needs to be done on mousedown and touchstart instead of click
2563
+ // so that it precedes the focus event.
2564
+
2565
+
2566
+ var checkPointerDown = function checkPointerDown(e) {
2567
+ var target = getActualTarget(e);
2568
+
2569
+ if (findContainerIndex(target) >= 0) {
2570
+ // allow the click since it ocurred inside the trap
2571
+ return;
2572
+ }
2573
+
2574
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2575
+ // immediately deactivate the trap
2576
+ trap.deactivate({
2577
+ // if, on deactivation, we should return focus to the node originally-focused
2578
+ // when the trap was activated (or the configured `setReturnFocus` node),
2579
+ // then assume it's also OK to return focus to the outside node that was
2580
+ // just clicked, causing deactivation, as long as that node is focusable;
2581
+ // if it isn't focusable, then return focus to the original node focused
2582
+ // on activation (or the configured `setReturnFocus` node)
2583
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
2584
+ // which will result in the outside click setting focus to the node
2585
+ // that was clicked, whether it's focusable or not; by setting
2586
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
2587
+ // on activation (or the configured `setReturnFocus` node)
2588
+ returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
2589
+ });
2590
+ return;
2591
+ } // This is needed for mobile devices.
2592
+ // (If we'll only let `click` events through,
2593
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
2594
+
2595
+
2596
+ if (valueOrHandler(config.allowOutsideClick, e)) {
2597
+ // allow the click outside the trap to take place
2598
+ return;
2599
+ } // otherwise, prevent the click
2600
+
2601
+
2602
+ e.preventDefault();
2603
+ }; // In case focus escapes the trap for some strange reason, pull it back in.
2604
+
2605
+
2606
+ var checkFocusIn = function checkFocusIn(e) {
2607
+ var target = getActualTarget(e);
2608
+ var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
2609
+
2610
+ if (targetContained || target instanceof Document) {
2611
+ if (targetContained) {
2612
+ state.mostRecentlyFocusedNode = target;
2613
+ }
2614
+ } else {
2615
+ // escaped! pull it back in to where it just left
2616
+ e.stopImmediatePropagation();
2617
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
2618
+ }
2619
+ }; // Hijack Tab events on the first and last focusable nodes of the trap,
2620
+ // in order to prevent focus from escaping. If it escapes for even a
2621
+ // moment it can end up scrolling the page and causing confusion so we
2622
+ // kind of need to capture the action at the keydown phase.
2623
+
2624
+
2625
+ var checkTab = function checkTab(e) {
2626
+ var target = getActualTarget(e);
2627
+ updateTabbableNodes();
2628
+ var destinationNode = null;
2629
+
2630
+ if (state.tabbableGroups.length > 0) {
2631
+ // make sure the target is actually contained in a group
2632
+ // NOTE: the target may also be the container itself if it's focusable
2633
+ // with tabIndex='-1' and was given initial focus
2634
+ var containerIndex = findContainerIndex(target);
2635
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
2636
+
2637
+ if (containerIndex < 0) {
2638
+ // target not found in any group: quite possible focus has escaped the trap,
2639
+ // so bring it back in to...
2640
+ if (e.shiftKey) {
2641
+ // ...the last node in the last group
2642
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
2643
+ } else {
2644
+ // ...the first node in the first group
2645
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
2646
+ }
2647
+ } else if (e.shiftKey) {
2648
+ // REVERSE
2649
+ // is the target the first tabbable node in a group?
2650
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
2651
+ var firstTabbableNode = _ref2.firstTabbableNode;
2652
+ return target === firstTabbableNode;
2653
+ });
2654
+
2655
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
2656
+ // an exception case where the target is either the container itself, or
2657
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
2658
+ // and user clicked on it or node was programmatically given focus)
2659
+ // and is not followed by any other tabbable node, in which
2660
+ // case, we should handle shift+tab as if focus were on the container's
2661
+ // first tabbable node, and go to the last tabbable node of the LAST group
2662
+ startOfGroupIndex = containerIndex;
2663
+ }
2664
+
2665
+ if (startOfGroupIndex >= 0) {
2666
+ // YES: then shift+tab should go to the last tabbable node in the
2667
+ // previous group (and wrap around to the last tabbable node of
2668
+ // the LAST group if it's the first tabbable node of the FIRST group)
2669
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
2670
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
2671
+ destinationNode = destinationGroup.lastTabbableNode;
2672
+ }
2673
+ } else {
2674
+ // FORWARD
2675
+ // is the target the last tabbable node in a group?
2676
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
2677
+ var lastTabbableNode = _ref3.lastTabbableNode;
2678
+ return target === lastTabbableNode;
2679
+ });
2680
+
2681
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
2682
+ // an exception case where the target is the container itself, or
2683
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
2684
+ // and user clicked on it or node was programmatically given focus)
2685
+ // and is not followed by any other tabbable node, in which
2686
+ // case, we should handle tab as if focus were on the container's
2687
+ // last tabbable node, and go to the first tabbable node of the FIRST group
2688
+ lastOfGroupIndex = containerIndex;
2689
+ }
2690
+
2691
+ if (lastOfGroupIndex >= 0) {
2692
+ // YES: then tab should go to the first tabbable node in the next
2693
+ // group (and wrap around to the first tabbable node of the FIRST
2694
+ // group if it's the last tabbable node of the LAST group)
2695
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
2696
+
2697
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
2698
+ destinationNode = _destinationGroup.firstTabbableNode;
2699
+ }
2700
+ }
2701
+ } else {
2702
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
2703
+ destinationNode = getNodeForOption('fallbackFocus');
2704
+ }
2705
+
2706
+ if (destinationNode) {
2707
+ e.preventDefault();
2708
+ tryFocus(destinationNode);
2709
+ } // else, let the browser take care of [shift+]tab and move the focus
2710
+
2711
+ };
2712
+
2713
+ var checkKey = function checkKey(e) {
2714
+ if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
2715
+ e.preventDefault();
2716
+ trap.deactivate();
2717
+ return;
2718
+ }
2719
+
2720
+ if (isTabEvent(e)) {
2721
+ checkTab(e);
2722
+ return;
2723
+ }
2724
+ };
2725
+
2726
+ var checkClick = function checkClick(e) {
2727
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2728
+ return;
2729
+ }
2730
+
2731
+ var target = getActualTarget(e);
2732
+
2733
+ if (findContainerIndex(target) >= 0) {
2734
+ return;
2735
+ }
2736
+
2737
+ if (valueOrHandler(config.allowOutsideClick, e)) {
2738
+ return;
2739
+ }
2740
+
2741
+ e.preventDefault();
2742
+ e.stopImmediatePropagation();
2743
+ }; //
2744
+ // EVENT LISTENERS
2745
+ //
2746
+
2747
+
2748
+ var addListeners = function addListeners() {
2749
+ if (!state.active) {
2750
+ return;
2751
+ } // There can be only one listening focus trap at a time
2752
+
2753
+
2754
+ activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
2755
+ // that caused the focus trap activation.
2756
+
2757
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
2758
+ tryFocus(getInitialFocusNode());
2759
+ }) : tryFocus(getInitialFocusNode());
2760
+ doc.addEventListener('focusin', checkFocusIn, true);
2761
+ doc.addEventListener('mousedown', checkPointerDown, {
2762
+ capture: true,
2763
+ passive: false
2764
+ });
2765
+ doc.addEventListener('touchstart', checkPointerDown, {
2766
+ capture: true,
2767
+ passive: false
2768
+ });
2769
+ doc.addEventListener('click', checkClick, {
2770
+ capture: true,
2771
+ passive: false
2772
+ });
2773
+ doc.addEventListener('keydown', checkKey, {
2774
+ capture: true,
2775
+ passive: false
2776
+ });
2777
+ return trap;
2778
+ };
2779
+
2780
+ var removeListeners = function removeListeners() {
2781
+ if (!state.active) {
2782
+ return;
2783
+ }
2784
+
2785
+ doc.removeEventListener('focusin', checkFocusIn, true);
2786
+ doc.removeEventListener('mousedown', checkPointerDown, true);
2787
+ doc.removeEventListener('touchstart', checkPointerDown, true);
2788
+ doc.removeEventListener('click', checkClick, true);
2789
+ doc.removeEventListener('keydown', checkKey, true);
2790
+ return trap;
2791
+ }; //
2792
+ // TRAP DEFINITION
2793
+ //
2794
+
2795
+
2796
+ trap = {
2797
+ activate: function activate(activateOptions) {
2798
+ if (state.active) {
2799
+ return this;
2800
+ }
2801
+
2802
+ var onActivate = getOption(activateOptions, 'onActivate');
2803
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
2804
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
2805
+
2806
+ if (!checkCanFocusTrap) {
2807
+ updateTabbableNodes();
2808
+ }
2809
+
2810
+ state.active = true;
2811
+ state.paused = false;
2812
+ state.nodeFocusedBeforeActivation = doc.activeElement;
2813
+
2814
+ if (onActivate) {
2815
+ onActivate();
2816
+ }
2817
+
2818
+ var finishActivation = function finishActivation() {
2819
+ if (checkCanFocusTrap) {
2820
+ updateTabbableNodes();
2821
+ }
2822
+
2823
+ addListeners();
2824
+
2825
+ if (onPostActivate) {
2826
+ onPostActivate();
2827
+ }
2828
+ };
2829
+
2830
+ if (checkCanFocusTrap) {
2831
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
2832
+ return this;
2833
+ }
2834
+
2835
+ finishActivation();
2836
+ return this;
2837
+ },
2838
+ deactivate: function deactivate(deactivateOptions) {
2839
+ if (!state.active) {
2840
+ return this;
2841
+ }
2842
+
2843
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
2844
+
2845
+ state.delayInitialFocusTimer = undefined;
2846
+ removeListeners();
2847
+ state.active = false;
2848
+ state.paused = false;
2849
+ activeFocusTraps.deactivateTrap(trap);
2850
+ var onDeactivate = getOption(deactivateOptions, 'onDeactivate');
2851
+ var onPostDeactivate = getOption(deactivateOptions, 'onPostDeactivate');
2852
+ var checkCanReturnFocus = getOption(deactivateOptions, 'checkCanReturnFocus');
2853
+
2854
+ if (onDeactivate) {
2855
+ onDeactivate();
2856
+ }
2857
+
2858
+ var returnFocus = getOption(deactivateOptions, 'returnFocus', 'returnFocusOnDeactivate');
2859
+
2860
+ var finishDeactivation = function finishDeactivation() {
2861
+ delay(function () {
2862
+ if (returnFocus) {
2863
+ tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
2864
+ }
2865
+
2866
+ if (onPostDeactivate) {
2867
+ onPostDeactivate();
2868
+ }
2869
+ });
2870
+ };
2871
+
2872
+ if (returnFocus && checkCanReturnFocus) {
2873
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
2874
+ return this;
2875
+ }
2876
+
2877
+ finishDeactivation();
2878
+ return this;
2879
+ },
2880
+ pause: function pause() {
2881
+ if (state.paused || !state.active) {
2882
+ return this;
2883
+ }
2884
+
2885
+ state.paused = true;
2886
+ removeListeners();
2887
+ return this;
2888
+ },
2889
+ unpause: function unpause() {
2890
+ if (!state.paused || !state.active) {
2891
+ return this;
2892
+ }
2893
+
2894
+ state.paused = false;
2895
+ updateTabbableNodes();
2896
+ addListeners();
2897
+ return this;
2898
+ },
2899
+ updateContainerElements: function updateContainerElements(containerElements) {
2900
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
2901
+ state.containers = elementsAsArray.map(function (element) {
2902
+ return typeof element === 'string' ? doc.querySelector(element) : element;
2903
+ });
2904
+
2905
+ if (state.active) {
2906
+ updateTabbableNodes();
2907
+ }
2908
+
2909
+ return this;
2910
+ }
2911
+ }; // initialize container elements
2912
+
2913
+ trap.updateContainerElements(elements);
2914
+ return trap;
2915
+ };
2916
+
2917
+ const firstTabbable = (container) => {
2918
+ return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
2919
+ };
2920
+
2921
+ const catMenuCss = ":host{display:inline-block}:host([hidden]){display:none}.content{padding-top:0.5rem;padding-bottom:0.5rem;position:absolute;background:white;display:none;overflow:auto;-webkit-overflow-scrolling:touch;min-width:8rem;max-width:16rem;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem}";
2922
+
2923
+ let nextUniqueId$1 = 0;
2924
+ const CatMenu = class {
2925
+ constructor(hostRef) {
2926
+ index.registerInstance(this, hostRef);
2927
+ this.catOpen = index.createEvent(this, "catOpen", 7);
2928
+ this.catClose = index.createEvent(this, "catClose", 7);
2929
+ this.id = nextUniqueId$1++;
2930
+ /**
2931
+ * The placement of the menu.
2932
+ */
2933
+ this.placement = 'bottom-start';
2934
+ }
2935
+ clickHandler(event) {
2936
+ var _a;
2937
+ // hide menu on button click
2938
+ if (this.content && event.composedPath().includes(this.content)) {
2939
+ (_a = this.trap) === null || _a === void 0 ? void 0 : _a.deactivate();
2940
+ this.hide();
2941
+ }
2942
+ }
2943
+ componentDidLoad() {
2944
+ var _a, _b, _c, _d, _e;
2945
+ this.trigger = firstTabbable(this.triggerSlot);
2946
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
2947
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
2948
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
2949
+ (_d = this.content) === null || _d === void 0 ? void 0 : _d.setAttribute('id', this.contentId);
2950
+ if (this.trigger && this.content) {
2951
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => this.show());
2952
+ autoUpdate(this.trigger, this.content, () => this.update());
2953
+ }
2954
+ this.keyListener = event => {
2955
+ if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
2956
+ const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
2957
+ const activeElement = firstTabbable(document.activeElement);
2958
+ const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
2959
+ const activeOff = event.key === 'ArrowDown' ? 1 : -1;
2960
+ const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
2961
+ targetElements[targetIdx].focus();
2962
+ event.preventDefault();
2963
+ }
2964
+ };
2965
+ document.addEventListener('keydown', this.keyListener);
2966
+ }
2967
+ disconnectedCallback() {
2968
+ if (this.keyListener) {
2969
+ document.removeEventListener('keydown', this.keyListener);
2970
+ }
2971
+ }
2972
+ render() {
2973
+ return (index.h(index.Host, null, index.h("slot", { name: "trigger", ref: el => (this.triggerSlot = el) }), index.h("div", { class: "content", ref: el => (this.content = el) }, index.h("slot", { name: "content" }))));
2974
+ }
2975
+ get contentId() {
2976
+ return `cat-menu-${this.id}`;
2977
+ }
2978
+ show() {
2979
+ var _a;
2980
+ if (this.content) {
2981
+ this.content.style.display = 'block';
2982
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
2983
+ this.catOpen.emit();
2984
+ this.trap = this.trap
2985
+ ? this.trap.updateContainerElements(this.content)
2986
+ : createFocusTrap(this.content, {
2987
+ tabbableOptions: {
2988
+ getShadowRoot: true
2989
+ },
2990
+ allowOutsideClick: true,
2991
+ clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),
2992
+ onPostDeactivate: () => this.hide()
2993
+ });
2994
+ this.trap.activate();
2995
+ }
2996
+ }
2997
+ hide() {
2998
+ var _a;
2999
+ if (this.content) {
3000
+ this.content.style.display = '';
3001
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
3002
+ this.catClose.emit();
3003
+ }
3004
+ }
3005
+ update() {
3006
+ if (this.trigger && this.content) {
3007
+ computePosition(this.trigger, this.content, {
3008
+ placement: this.placement,
3009
+ middleware: [offset(CatMenu.OFFSET), flip()]
3010
+ }).then(({ x, y }) => {
3011
+ if (this.content) {
3012
+ Object.assign(this.content.style, {
3013
+ left: `${x}px`,
3014
+ top: `${y}px`
3015
+ });
3016
+ }
3017
+ });
3018
+ }
3019
+ }
3020
+ };
3021
+ CatMenu.OFFSET = 4;
3022
+ CatMenu.style = catMenuCss;
3023
+
3024
+ function isFunction(value) {
3025
+ return typeof value === 'function';
3026
+ }
3027
+
3028
+ function createErrorClass(createImpl) {
3029
+ const _super = (instance) => {
3030
+ Error.call(instance);
3031
+ instance.stack = new Error().stack;
3032
+ };
3033
+ const ctorFunc = createImpl(_super);
3034
+ ctorFunc.prototype = Object.create(Error.prototype);
3035
+ ctorFunc.prototype.constructor = ctorFunc;
3036
+ return ctorFunc;
3037
+ }
3038
+
3039
+ const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
3040
+ _super(this);
3041
+ this.message = errors
3042
+ ? `${errors.length} errors occurred during unsubscription:
3043
+ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
3044
+ : '';
3045
+ this.name = 'UnsubscriptionError';
3046
+ this.errors = errors;
3047
+ });
3048
+
3049
+ function arrRemove(arr, item) {
3050
+ if (arr) {
3051
+ const index = arr.indexOf(item);
3052
+ 0 <= index && arr.splice(index, 1);
3053
+ }
3054
+ }
3055
+
3056
+ class Subscription {
3057
+ constructor(initialTeardown) {
3058
+ this.initialTeardown = initialTeardown;
3059
+ this.closed = false;
3060
+ this._parentage = null;
3061
+ this._finalizers = null;
3062
+ }
3063
+ unsubscribe() {
3064
+ let errors;
3065
+ if (!this.closed) {
3066
+ this.closed = true;
3067
+ const { _parentage } = this;
3068
+ if (_parentage) {
3069
+ this._parentage = null;
3070
+ if (Array.isArray(_parentage)) {
3071
+ for (const parent of _parentage) {
3072
+ parent.remove(this);
3073
+ }
3074
+ }
3075
+ else {
3076
+ _parentage.remove(this);
3077
+ }
3078
+ }
3079
+ const { initialTeardown: initialFinalizer } = this;
3080
+ if (isFunction(initialFinalizer)) {
3081
+ try {
3082
+ initialFinalizer();
3083
+ }
3084
+ catch (e) {
3085
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
3086
+ }
3087
+ }
3088
+ const { _finalizers } = this;
3089
+ if (_finalizers) {
3090
+ this._finalizers = null;
3091
+ for (const finalizer of _finalizers) {
3092
+ try {
3093
+ execFinalizer(finalizer);
3094
+ }
3095
+ catch (err) {
3096
+ errors = errors !== null && errors !== void 0 ? errors : [];
3097
+ if (err instanceof UnsubscriptionError) {
3098
+ errors = [...errors, ...err.errors];
3099
+ }
3100
+ else {
3101
+ errors.push(err);
3102
+ }
3103
+ }
3104
+ }
3105
+ }
3106
+ if (errors) {
3107
+ throw new UnsubscriptionError(errors);
3108
+ }
3109
+ }
3110
+ }
3111
+ add(teardown) {
3112
+ var _a;
3113
+ if (teardown && teardown !== this) {
3114
+ if (this.closed) {
3115
+ execFinalizer(teardown);
3116
+ }
3117
+ else {
3118
+ if (teardown instanceof Subscription) {
3119
+ if (teardown.closed || teardown._hasParent(this)) {
3120
+ return;
3121
+ }
3122
+ teardown._addParent(this);
3123
+ }
3124
+ (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
3125
+ }
3126
+ }
3127
+ }
3128
+ _hasParent(parent) {
3129
+ const { _parentage } = this;
3130
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
3131
+ }
3132
+ _addParent(parent) {
3133
+ const { _parentage } = this;
3134
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
3135
+ }
3136
+ _removeParent(parent) {
3137
+ const { _parentage } = this;
3138
+ if (_parentage === parent) {
3139
+ this._parentage = null;
3140
+ }
3141
+ else if (Array.isArray(_parentage)) {
3142
+ arrRemove(_parentage, parent);
3143
+ }
3144
+ }
3145
+ remove(teardown) {
3146
+ const { _finalizers } = this;
3147
+ _finalizers && arrRemove(_finalizers, teardown);
3148
+ if (teardown instanceof Subscription) {
3149
+ teardown._removeParent(this);
3150
+ }
3151
+ }
3152
+ }
3153
+ Subscription.EMPTY = (() => {
3154
+ const empty = new Subscription();
3155
+ empty.closed = true;
3156
+ return empty;
3157
+ })();
3158
+ const EMPTY_SUBSCRIPTION = Subscription.EMPTY;
3159
+ function isSubscription(value) {
3160
+ return (value instanceof Subscription ||
3161
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
3162
+ }
3163
+ function execFinalizer(finalizer) {
3164
+ if (isFunction(finalizer)) {
3165
+ finalizer();
3166
+ }
3167
+ else {
3168
+ finalizer.unsubscribe();
3169
+ }
3170
+ }
3171
+
3172
+ const config = {
3173
+ onUnhandledError: null,
3174
+ onStoppedNotification: null,
3175
+ Promise: undefined,
3176
+ useDeprecatedSynchronousErrorHandling: false,
3177
+ useDeprecatedNextContext: false,
3178
+ };
3179
+
3180
+ const timeoutProvider = {
3181
+ setTimeout(handler, timeout, ...args) {
3182
+ const { delegate } = timeoutProvider;
3183
+ if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
3184
+ return delegate.setTimeout(handler, timeout, ...args);
3185
+ }
3186
+ return setTimeout(handler, timeout, ...args);
3187
+ },
3188
+ clearTimeout(handle) {
3189
+ const { delegate } = timeoutProvider;
3190
+ return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
3191
+ },
3192
+ delegate: undefined,
3193
+ };
3194
+
3195
+ function reportUnhandledError(err) {
3196
+ timeoutProvider.setTimeout(() => {
3197
+ const { onUnhandledError } = config;
3198
+ if (onUnhandledError) {
3199
+ onUnhandledError(err);
3200
+ }
3201
+ else {
3202
+ throw err;
3203
+ }
3204
+ });
3205
+ }
3206
+
3207
+ function noop() { }
3208
+
3209
+ const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();
3210
+ function errorNotification(error) {
3211
+ return createNotification('E', undefined, error);
3212
+ }
3213
+ function nextNotification(value) {
3214
+ return createNotification('N', value, undefined);
3215
+ }
3216
+ function createNotification(kind, value, error) {
3217
+ return {
3218
+ kind,
3219
+ value,
3220
+ error,
3221
+ };
3222
+ }
3223
+
3224
+ function errorContext(cb) {
3225
+ {
3226
+ cb();
3227
+ }
3228
+ }
3229
+
3230
+ class Subscriber extends Subscription {
3231
+ constructor(destination) {
3232
+ super();
3233
+ this.isStopped = false;
3234
+ if (destination) {
3235
+ this.destination = destination;
3236
+ if (isSubscription(destination)) {
3237
+ destination.add(this);
3238
+ }
3239
+ }
3240
+ else {
3241
+ this.destination = EMPTY_OBSERVER;
3242
+ }
3243
+ }
3244
+ static create(next, error, complete) {
3245
+ return new SafeSubscriber(next, error, complete);
3246
+ }
3247
+ next(value) {
3248
+ if (this.isStopped) {
3249
+ handleStoppedNotification(nextNotification(value), this);
3250
+ }
3251
+ else {
3252
+ this._next(value);
3253
+ }
3254
+ }
3255
+ error(err) {
3256
+ if (this.isStopped) {
3257
+ handleStoppedNotification(errorNotification(err), this);
3258
+ }
3259
+ else {
3260
+ this.isStopped = true;
3261
+ this._error(err);
3262
+ }
3263
+ }
3264
+ complete() {
3265
+ if (this.isStopped) {
3266
+ handleStoppedNotification(COMPLETE_NOTIFICATION, this);
3267
+ }
3268
+ else {
3269
+ this.isStopped = true;
3270
+ this._complete();
3271
+ }
3272
+ }
3273
+ unsubscribe() {
3274
+ if (!this.closed) {
3275
+ this.isStopped = true;
3276
+ super.unsubscribe();
3277
+ this.destination = null;
3278
+ }
3279
+ }
3280
+ _next(value) {
3281
+ this.destination.next(value);
3282
+ }
3283
+ _error(err) {
3284
+ try {
3285
+ this.destination.error(err);
3286
+ }
3287
+ finally {
3288
+ this.unsubscribe();
3289
+ }
3290
+ }
3291
+ _complete() {
3292
+ try {
3293
+ this.destination.complete();
3294
+ }
3295
+ finally {
3296
+ this.unsubscribe();
3297
+ }
3298
+ }
3299
+ }
3300
+ const _bind = Function.prototype.bind;
3301
+ function bind(fn, thisArg) {
3302
+ return _bind.call(fn, thisArg);
3303
+ }
3304
+ class ConsumerObserver {
3305
+ constructor(partialObserver) {
3306
+ this.partialObserver = partialObserver;
3307
+ }
3308
+ next(value) {
3309
+ const { partialObserver } = this;
3310
+ if (partialObserver.next) {
3311
+ try {
3312
+ partialObserver.next(value);
3313
+ }
3314
+ catch (error) {
3315
+ handleUnhandledError(error);
3316
+ }
3317
+ }
3318
+ }
3319
+ error(err) {
3320
+ const { partialObserver } = this;
3321
+ if (partialObserver.error) {
3322
+ try {
3323
+ partialObserver.error(err);
3324
+ }
3325
+ catch (error) {
3326
+ handleUnhandledError(error);
3327
+ }
3328
+ }
3329
+ else {
3330
+ handleUnhandledError(err);
3331
+ }
3332
+ }
3333
+ complete() {
3334
+ const { partialObserver } = this;
3335
+ if (partialObserver.complete) {
3336
+ try {
3337
+ partialObserver.complete();
3338
+ }
3339
+ catch (error) {
3340
+ handleUnhandledError(error);
3341
+ }
3342
+ }
3343
+ }
3344
+ }
3345
+ class SafeSubscriber extends Subscriber {
3346
+ constructor(observerOrNext, error, complete) {
3347
+ super();
3348
+ let partialObserver;
3349
+ if (isFunction(observerOrNext) || !observerOrNext) {
3350
+ partialObserver = {
3351
+ next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
3352
+ error: error !== null && error !== void 0 ? error : undefined,
3353
+ complete: complete !== null && complete !== void 0 ? complete : undefined,
3354
+ };
3355
+ }
3356
+ else {
3357
+ let context;
3358
+ if (this && config.useDeprecatedNextContext) {
3359
+ context = Object.create(observerOrNext);
3360
+ context.unsubscribe = () => this.unsubscribe();
3361
+ partialObserver = {
3362
+ next: observerOrNext.next && bind(observerOrNext.next, context),
3363
+ error: observerOrNext.error && bind(observerOrNext.error, context),
3364
+ complete: observerOrNext.complete && bind(observerOrNext.complete, context),
3365
+ };
3366
+ }
3367
+ else {
3368
+ partialObserver = observerOrNext;
3369
+ }
3370
+ }
3371
+ this.destination = new ConsumerObserver(partialObserver);
3372
+ }
3373
+ }
3374
+ function handleUnhandledError(error) {
3375
+ {
3376
+ reportUnhandledError(error);
3377
+ }
3378
+ }
3379
+ function defaultErrorHandler(err) {
3380
+ throw err;
3381
+ }
3382
+ function handleStoppedNotification(notification, subscriber) {
3383
+ const { onStoppedNotification } = config;
3384
+ onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
3385
+ }
3386
+ const EMPTY_OBSERVER = {
3387
+ closed: true,
3388
+ next: noop,
3389
+ error: defaultErrorHandler,
3390
+ complete: noop,
3391
+ };
3392
+
3393
+ const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();
3394
+
3395
+ function identity(x) {
3396
+ return x;
3397
+ }
3398
+
3399
+ function pipeFromArray(fns) {
3400
+ if (fns.length === 0) {
3401
+ return identity;
3402
+ }
3403
+ if (fns.length === 1) {
3404
+ return fns[0];
3405
+ }
3406
+ return function piped(input) {
3407
+ return fns.reduce((prev, fn) => fn(prev), input);
3408
+ };
3409
+ }
3410
+
3411
+ class Observable {
3412
+ constructor(subscribe) {
3413
+ if (subscribe) {
3414
+ this._subscribe = subscribe;
3415
+ }
3416
+ }
3417
+ lift(operator) {
3418
+ const observable = new Observable();
3419
+ observable.source = this;
3420
+ observable.operator = operator;
3421
+ return observable;
3422
+ }
3423
+ subscribe(observerOrNext, error, complete) {
3424
+ const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
3425
+ errorContext(() => {
3426
+ const { operator, source } = this;
3427
+ subscriber.add(operator
3428
+ ?
3429
+ operator.call(subscriber, source)
3430
+ : source
3431
+ ?
3432
+ this._subscribe(subscriber)
3433
+ :
3434
+ this._trySubscribe(subscriber));
3435
+ });
3436
+ return subscriber;
3437
+ }
3438
+ _trySubscribe(sink) {
3439
+ try {
3440
+ return this._subscribe(sink);
3441
+ }
3442
+ catch (err) {
3443
+ sink.error(err);
3444
+ }
3445
+ }
3446
+ forEach(next, promiseCtor) {
3447
+ promiseCtor = getPromiseCtor(promiseCtor);
3448
+ return new promiseCtor((resolve, reject) => {
3449
+ const subscriber = new SafeSubscriber({
3450
+ next: (value) => {
3451
+ try {
3452
+ next(value);
3453
+ }
3454
+ catch (err) {
3455
+ reject(err);
3456
+ subscriber.unsubscribe();
3457
+ }
3458
+ },
3459
+ error: reject,
3460
+ complete: resolve,
3461
+ });
3462
+ this.subscribe(subscriber);
3463
+ });
3464
+ }
3465
+ _subscribe(subscriber) {
3466
+ var _a;
3467
+ return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
3468
+ }
3469
+ [observable]() {
3470
+ return this;
3471
+ }
3472
+ pipe(...operations) {
3473
+ return pipeFromArray(operations)(this);
3474
+ }
3475
+ toPromise(promiseCtor) {
3476
+ promiseCtor = getPromiseCtor(promiseCtor);
3477
+ return new promiseCtor((resolve, reject) => {
3478
+ let value;
3479
+ this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));
3480
+ });
3481
+ }
3482
+ }
3483
+ Observable.create = (subscribe) => {
3484
+ return new Observable(subscribe);
3485
+ };
3486
+ function getPromiseCtor(promiseCtor) {
3487
+ var _a;
3488
+ return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
3489
+ }
3490
+ function isObserver(value) {
3491
+ return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
3492
+ }
3493
+ function isSubscriber(value) {
3494
+ return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
3495
+ }
3496
+
3497
+ function hasLift(source) {
3498
+ return isFunction(source === null || source === void 0 ? void 0 : source.lift);
3499
+ }
3500
+ function operate(init) {
3501
+ return (source) => {
3502
+ if (hasLift(source)) {
3503
+ return source.lift(function (liftedSource) {
3504
+ try {
3505
+ return init(liftedSource, this);
3506
+ }
3507
+ catch (err) {
3508
+ this.error(err);
3509
+ }
3510
+ });
3511
+ }
3512
+ throw new TypeError('Unable to lift unknown Observable type');
3513
+ };
3514
+ }
3515
+
3516
+ function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
3517
+ return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
3518
+ }
3519
+ class OperatorSubscriber extends Subscriber {
3520
+ constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
3521
+ super(destination);
3522
+ this.onFinalize = onFinalize;
3523
+ this.shouldUnsubscribe = shouldUnsubscribe;
3524
+ this._next = onNext
3525
+ ? function (value) {
3526
+ try {
3527
+ onNext(value);
3528
+ }
3529
+ catch (err) {
3530
+ destination.error(err);
3531
+ }
3532
+ }
3533
+ : super._next;
3534
+ this._error = onError
3535
+ ? function (err) {
3536
+ try {
3537
+ onError(err);
3538
+ }
3539
+ catch (err) {
3540
+ destination.error(err);
3541
+ }
3542
+ finally {
3543
+ this.unsubscribe();
3544
+ }
3545
+ }
3546
+ : super._error;
3547
+ this._complete = onComplete
3548
+ ? function () {
3549
+ try {
3550
+ onComplete();
3551
+ }
3552
+ catch (err) {
3553
+ destination.error(err);
3554
+ }
3555
+ finally {
3556
+ this.unsubscribe();
3557
+ }
3558
+ }
3559
+ : super._complete;
3560
+ }
3561
+ unsubscribe() {
3562
+ var _a;
3563
+ if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
3564
+ const { closed } = this;
3565
+ super.unsubscribe();
3566
+ !closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
3567
+ }
3568
+ }
3569
+ }
3570
+
3571
+ const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
3572
+ _super(this);
3573
+ this.name = 'ObjectUnsubscribedError';
3574
+ this.message = 'object unsubscribed';
3575
+ });
3576
+
3577
+ class Subject extends Observable {
3578
+ constructor() {
3579
+ super();
3580
+ this.closed = false;
3581
+ this.currentObservers = null;
3582
+ this.observers = [];
3583
+ this.isStopped = false;
3584
+ this.hasError = false;
3585
+ this.thrownError = null;
3586
+ }
3587
+ lift(operator) {
3588
+ const subject = new AnonymousSubject(this, this);
3589
+ subject.operator = operator;
3590
+ return subject;
3591
+ }
3592
+ _throwIfClosed() {
3593
+ if (this.closed) {
3594
+ throw new ObjectUnsubscribedError();
3595
+ }
3596
+ }
3597
+ next(value) {
3598
+ errorContext(() => {
3599
+ this._throwIfClosed();
3600
+ if (!this.isStopped) {
3601
+ if (!this.currentObservers) {
3602
+ this.currentObservers = Array.from(this.observers);
3603
+ }
3604
+ for (const observer of this.currentObservers) {
3605
+ observer.next(value);
3606
+ }
3607
+ }
3608
+ });
3609
+ }
3610
+ error(err) {
3611
+ errorContext(() => {
3612
+ this._throwIfClosed();
3613
+ if (!this.isStopped) {
3614
+ this.hasError = this.isStopped = true;
3615
+ this.thrownError = err;
3616
+ const { observers } = this;
3617
+ while (observers.length) {
3618
+ observers.shift().error(err);
3619
+ }
3620
+ }
3621
+ });
3622
+ }
3623
+ complete() {
3624
+ errorContext(() => {
3625
+ this._throwIfClosed();
3626
+ if (!this.isStopped) {
3627
+ this.isStopped = true;
3628
+ const { observers } = this;
3629
+ while (observers.length) {
3630
+ observers.shift().complete();
3631
+ }
3632
+ }
3633
+ });
3634
+ }
3635
+ unsubscribe() {
3636
+ this.isStopped = this.closed = true;
3637
+ this.observers = this.currentObservers = null;
3638
+ }
3639
+ get observed() {
3640
+ var _a;
3641
+ return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
3642
+ }
3643
+ _trySubscribe(subscriber) {
3644
+ this._throwIfClosed();
3645
+ return super._trySubscribe(subscriber);
3646
+ }
3647
+ _subscribe(subscriber) {
3648
+ this._throwIfClosed();
3649
+ this._checkFinalizedStatuses(subscriber);
3650
+ return this._innerSubscribe(subscriber);
3651
+ }
3652
+ _innerSubscribe(subscriber) {
3653
+ const { hasError, isStopped, observers } = this;
3654
+ if (hasError || isStopped) {
3655
+ return EMPTY_SUBSCRIPTION;
3656
+ }
3657
+ this.currentObservers = null;
3658
+ observers.push(subscriber);
3659
+ return new Subscription(() => {
3660
+ this.currentObservers = null;
3661
+ arrRemove(observers, subscriber);
3662
+ });
3663
+ }
3664
+ _checkFinalizedStatuses(subscriber) {
3665
+ const { hasError, thrownError, isStopped } = this;
3666
+ if (hasError) {
3667
+ subscriber.error(thrownError);
3668
+ }
3669
+ else if (isStopped) {
3670
+ subscriber.complete();
3671
+ }
3672
+ }
3673
+ asObservable() {
3674
+ const observable = new Observable();
3675
+ observable.source = this;
3676
+ return observable;
3677
+ }
3678
+ }
3679
+ Subject.create = (destination, source) => {
3680
+ return new AnonymousSubject(destination, source);
3681
+ };
3682
+ class AnonymousSubject extends Subject {
3683
+ constructor(destination, source) {
3684
+ super();
3685
+ this.destination = destination;
3686
+ this.source = source;
3687
+ }
3688
+ next(value) {
3689
+ var _a, _b;
3690
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
3691
+ }
3692
+ error(err) {
3693
+ var _a, _b;
3694
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
3695
+ }
3696
+ complete() {
3697
+ var _a, _b;
3698
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
3699
+ }
3700
+ _subscribe(subscriber) {
3701
+ var _a, _b;
3702
+ return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
3703
+ }
3704
+ }
3705
+
3706
+ const EMPTY = new Observable((subscriber) => subscriber.complete());
3707
+
3708
+ function isScheduler(value) {
3709
+ return value && isFunction(value.schedule);
3710
+ }
3711
+
3712
+ function last(arr) {
3713
+ return arr[arr.length - 1];
3714
+ }
3715
+ function popScheduler(args) {
3716
+ return isScheduler(last(args)) ? args.pop() : undefined;
3717
+ }
3718
+ function popNumber(args, defaultValue) {
3719
+ return typeof last(args) === 'number' ? args.pop() : defaultValue;
3720
+ }
3721
+
3722
+ /******************************************************************************
3723
+ Copyright (c) Microsoft Corporation.
3724
+
3725
+ Permission to use, copy, modify, and/or distribute this software for any
3726
+ purpose with or without fee is hereby granted.
3727
+
3728
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3729
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3730
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3731
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3732
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3733
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3734
+ PERFORMANCE OF THIS SOFTWARE.
3735
+ ***************************************************************************** */
3736
+
3737
+ function __awaiter(thisArg, _arguments, P, generator) {
3738
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3739
+ return new (P || (P = Promise))(function (resolve, reject) {
3740
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3741
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3742
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3743
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3744
+ });
3745
+ }
3746
+
3747
+ function __values(o) {
3748
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3749
+ if (m) return m.call(o);
3750
+ if (o && typeof o.length === "number") return {
3751
+ next: function () {
3752
+ if (o && i >= o.length) o = void 0;
3753
+ return { value: o && o[i++], done: !o };
3754
+ }
3755
+ };
3756
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3757
+ }
3758
+
3759
+ function __await(v) {
3760
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
3761
+ }
3762
+
3763
+ function __asyncGenerator(thisArg, _arguments, generator) {
3764
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3765
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
3766
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
3767
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
3768
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
3769
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
3770
+ function fulfill(value) { resume("next", value); }
3771
+ function reject(value) { resume("throw", value); }
3772
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
3773
+ }
3774
+
3775
+ function __asyncValues(o) {
3776
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3777
+ var m = o[Symbol.asyncIterator], i;
3778
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
3779
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
3780
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
3781
+ }
3782
+
3783
+ const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');
3784
+
3785
+ function isPromise(value) {
3786
+ return isFunction(value === null || value === void 0 ? void 0 : value.then);
3787
+ }
3788
+
3789
+ function isInteropObservable(input) {
3790
+ return isFunction(input[observable]);
3791
+ }
3792
+
3793
+ function isAsyncIterable(obj) {
3794
+ return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
3795
+ }
3796
+
3797
+ function createInvalidObservableTypeError(input) {
3798
+ return new TypeError(`You provided ${input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`);
3799
+ }
3800
+
3801
+ function getSymbolIterator() {
3802
+ if (typeof Symbol !== 'function' || !Symbol.iterator) {
3803
+ return '@@iterator';
3804
+ }
3805
+ return Symbol.iterator;
3806
+ }
3807
+ const iterator = getSymbolIterator();
3808
+
3809
+ function isIterable(input) {
3810
+ return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
3811
+ }
3812
+
3813
+ function readableStreamLikeToAsyncGenerator(readableStream) {
3814
+ return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {
3815
+ const reader = readableStream.getReader();
3816
+ try {
3817
+ while (true) {
3818
+ const { value, done } = yield __await(reader.read());
3819
+ if (done) {
3820
+ return yield __await(void 0);
3821
+ }
3822
+ yield yield __await(value);
3823
+ }
3824
+ }
3825
+ finally {
3826
+ reader.releaseLock();
3827
+ }
3828
+ });
3829
+ }
3830
+ function isReadableStreamLike(obj) {
3831
+ return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
3832
+ }
3833
+
3834
+ function innerFrom(input) {
3835
+ if (input instanceof Observable) {
3836
+ return input;
3837
+ }
3838
+ if (input != null) {
3839
+ if (isInteropObservable(input)) {
3840
+ return fromInteropObservable(input);
3841
+ }
3842
+ if (isArrayLike(input)) {
3843
+ return fromArrayLike(input);
3844
+ }
3845
+ if (isPromise(input)) {
3846
+ return fromPromise(input);
3847
+ }
3848
+ if (isAsyncIterable(input)) {
3849
+ return fromAsyncIterable(input);
3850
+ }
3851
+ if (isIterable(input)) {
3852
+ return fromIterable(input);
3853
+ }
3854
+ if (isReadableStreamLike(input)) {
3855
+ return fromReadableStreamLike(input);
3856
+ }
3857
+ }
3858
+ throw createInvalidObservableTypeError(input);
3859
+ }
3860
+ function fromInteropObservable(obj) {
3861
+ return new Observable((subscriber) => {
3862
+ const obs = obj[observable]();
3863
+ if (isFunction(obs.subscribe)) {
3864
+ return obs.subscribe(subscriber);
3865
+ }
3866
+ throw new TypeError('Provided object does not correctly implement Symbol.observable');
3867
+ });
3868
+ }
3869
+ function fromArrayLike(array) {
3870
+ return new Observable((subscriber) => {
3871
+ for (let i = 0; i < array.length && !subscriber.closed; i++) {
3872
+ subscriber.next(array[i]);
3873
+ }
3874
+ subscriber.complete();
3875
+ });
3876
+ }
3877
+ function fromPromise(promise) {
3878
+ return new Observable((subscriber) => {
3879
+ promise
3880
+ .then((value) => {
3881
+ if (!subscriber.closed) {
3882
+ subscriber.next(value);
3883
+ subscriber.complete();
3884
+ }
3885
+ }, (err) => subscriber.error(err))
3886
+ .then(null, reportUnhandledError);
3887
+ });
3888
+ }
3889
+ function fromIterable(iterable) {
3890
+ return new Observable((subscriber) => {
3891
+ for (const value of iterable) {
3892
+ subscriber.next(value);
3893
+ if (subscriber.closed) {
3894
+ return;
3895
+ }
3896
+ }
3897
+ subscriber.complete();
3898
+ });
3899
+ }
3900
+ function fromAsyncIterable(asyncIterable) {
3901
+ return new Observable((subscriber) => {
3902
+ process(asyncIterable, subscriber).catch((err) => subscriber.error(err));
3903
+ });
3904
+ }
3905
+ function fromReadableStreamLike(readableStream) {
3906
+ return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
3907
+ }
3908
+ function process(asyncIterable, subscriber) {
3909
+ var asyncIterable_1, asyncIterable_1_1;
3910
+ var e_1, _a;
3911
+ return __awaiter(this, void 0, void 0, function* () {
3912
+ try {
3913
+ for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {
3914
+ const value = asyncIterable_1_1.value;
3915
+ subscriber.next(value);
3916
+ if (subscriber.closed) {
3917
+ return;
3918
+ }
3919
+ }
3920
+ }
3921
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3922
+ finally {
3923
+ try {
3924
+ if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);
3925
+ }
3926
+ finally { if (e_1) throw e_1.error; }
3927
+ }
3928
+ subscriber.complete();
3929
+ });
3930
+ }
3931
+
3932
+ function executeSchedule(parentSubscription, scheduler, work, delay = 0, repeat = false) {
3933
+ const scheduleSubscription = scheduler.schedule(function () {
3934
+ work();
3935
+ if (repeat) {
3936
+ parentSubscription.add(this.schedule(null, delay));
3937
+ }
3938
+ else {
3939
+ this.unsubscribe();
3940
+ }
3941
+ }, delay);
3942
+ parentSubscription.add(scheduleSubscription);
3943
+ if (!repeat) {
3944
+ return scheduleSubscription;
3945
+ }
3946
+ }
3947
+
3948
+ function observeOn(scheduler, delay = 0) {
3949
+ return operate((source, subscriber) => {
3950
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay), () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay), (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)));
3951
+ });
3952
+ }
3953
+
3954
+ function subscribeOn(scheduler, delay = 0) {
3955
+ return operate((source, subscriber) => {
3956
+ subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));
3957
+ });
3958
+ }
3959
+
3960
+ function scheduleObservable(input, scheduler) {
3961
+ return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
3962
+ }
3963
+
3964
+ function schedulePromise(input, scheduler) {
3965
+ return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
3966
+ }
3967
+
3968
+ function scheduleArray(input, scheduler) {
3969
+ return new Observable((subscriber) => {
3970
+ let i = 0;
3971
+ return scheduler.schedule(function () {
3972
+ if (i === input.length) {
3973
+ subscriber.complete();
3974
+ }
3975
+ else {
3976
+ subscriber.next(input[i++]);
3977
+ if (!subscriber.closed) {
3978
+ this.schedule();
3979
+ }
3980
+ }
3981
+ });
3982
+ });
3983
+ }
3984
+
3985
+ function scheduleIterable(input, scheduler) {
3986
+ return new Observable((subscriber) => {
3987
+ let iterator$1;
3988
+ executeSchedule(subscriber, scheduler, () => {
3989
+ iterator$1 = input[iterator]();
3990
+ executeSchedule(subscriber, scheduler, () => {
3991
+ let value;
3992
+ let done;
3993
+ try {
3994
+ ({ value, done } = iterator$1.next());
3995
+ }
3996
+ catch (err) {
3997
+ subscriber.error(err);
3998
+ return;
3999
+ }
4000
+ if (done) {
4001
+ subscriber.complete();
4002
+ }
4003
+ else {
4004
+ subscriber.next(value);
4005
+ }
4006
+ }, 0, true);
4007
+ });
4008
+ return () => isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return();
4009
+ });
4010
+ }
4011
+
4012
+ function scheduleAsyncIterable(input, scheduler) {
4013
+ if (!input) {
4014
+ throw new Error('Iterable cannot be null');
4015
+ }
4016
+ return new Observable((subscriber) => {
4017
+ executeSchedule(subscriber, scheduler, () => {
4018
+ const iterator = input[Symbol.asyncIterator]();
4019
+ executeSchedule(subscriber, scheduler, () => {
4020
+ iterator.next().then((result) => {
4021
+ if (result.done) {
4022
+ subscriber.complete();
4023
+ }
4024
+ else {
4025
+ subscriber.next(result.value);
4026
+ }
4027
+ });
4028
+ }, 0, true);
4029
+ });
4030
+ });
4031
+ }
4032
+
4033
+ function scheduleReadableStreamLike(input, scheduler) {
4034
+ return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
4035
+ }
4036
+
4037
+ function scheduled(input, scheduler) {
4038
+ if (input != null) {
4039
+ if (isInteropObservable(input)) {
4040
+ return scheduleObservable(input, scheduler);
4041
+ }
4042
+ if (isArrayLike(input)) {
4043
+ return scheduleArray(input, scheduler);
4044
+ }
4045
+ if (isPromise(input)) {
4046
+ return schedulePromise(input, scheduler);
4047
+ }
4048
+ if (isAsyncIterable(input)) {
4049
+ return scheduleAsyncIterable(input, scheduler);
4050
+ }
4051
+ if (isIterable(input)) {
4052
+ return scheduleIterable(input, scheduler);
4053
+ }
4054
+ if (isReadableStreamLike(input)) {
4055
+ return scheduleReadableStreamLike(input, scheduler);
4056
+ }
4057
+ }
4058
+ throw createInvalidObservableTypeError(input);
4059
+ }
4060
+
4061
+ function from(input, scheduler) {
4062
+ return scheduler ? scheduled(input, scheduler) : innerFrom(input);
4063
+ }
4064
+
4065
+ function map(project, thisArg) {
4066
+ return operate((source, subscriber) => {
4067
+ let index = 0;
4068
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => {
4069
+ subscriber.next(project.call(thisArg, value, index++));
4070
+ }));
4071
+ });
4072
+ }
4073
+
4074
+ const { isArray } = Array;
4075
+ function callOrApply(fn, args) {
4076
+ return isArray(args) ? fn(...args) : fn(args);
4077
+ }
4078
+ function mapOneOrManyArgs(fn) {
4079
+ return map(args => callOrApply(fn, args));
4080
+ }
4081
+
4082
+ function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
4083
+ const buffer = [];
4084
+ let active = 0;
4085
+ let index = 0;
4086
+ let isComplete = false;
4087
+ const checkComplete = () => {
4088
+ if (isComplete && !buffer.length && !active) {
4089
+ subscriber.complete();
4090
+ }
4091
+ };
4092
+ const outerNext = (value) => (active < concurrent ? doInnerSub(value) : buffer.push(value));
4093
+ const doInnerSub = (value) => {
4094
+ expand && subscriber.next(value);
4095
+ active++;
4096
+ let innerComplete = false;
4097
+ innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {
4098
+ onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
4099
+ if (expand) {
4100
+ outerNext(innerValue);
4101
+ }
4102
+ else {
4103
+ subscriber.next(innerValue);
4104
+ }
4105
+ }, () => {
4106
+ innerComplete = true;
4107
+ }, undefined, () => {
4108
+ if (innerComplete) {
4109
+ try {
4110
+ active--;
4111
+ while (buffer.length && active < concurrent) {
4112
+ const bufferedValue = buffer.shift();
4113
+ if (innerSubScheduler) {
4114
+ executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));
4115
+ }
4116
+ else {
4117
+ doInnerSub(bufferedValue);
4118
+ }
4119
+ }
4120
+ checkComplete();
4121
+ }
4122
+ catch (err) {
4123
+ subscriber.error(err);
4124
+ }
4125
+ }
4126
+ }));
4127
+ };
4128
+ source.subscribe(createOperatorSubscriber(subscriber, outerNext, () => {
4129
+ isComplete = true;
4130
+ checkComplete();
4131
+ }));
4132
+ return () => {
4133
+ additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
4134
+ };
4135
+ }
4136
+
4137
+ function mergeMap(project, resultSelector, concurrent = Infinity) {
4138
+ if (isFunction(resultSelector)) {
4139
+ return mergeMap((a, i) => map((b, ii) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);
4140
+ }
4141
+ else if (typeof resultSelector === 'number') {
4142
+ concurrent = resultSelector;
4143
+ }
4144
+ return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));
4145
+ }
4146
+
4147
+ function mergeAll(concurrent = Infinity) {
4148
+ return mergeMap(identity, concurrent);
4149
+ }
4150
+
4151
+ const nodeEventEmitterMethods = ['addListener', 'removeListener'];
4152
+ const eventTargetMethods = ['addEventListener', 'removeEventListener'];
4153
+ const jqueryMethods = ['on', 'off'];
4154
+ function fromEvent(target, eventName, options, resultSelector) {
4155
+ if (isFunction(options)) {
4156
+ resultSelector = options;
4157
+ options = undefined;
4158
+ }
4159
+ if (resultSelector) {
4160
+ return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
4161
+ }
4162
+ const [add, remove] = isEventTarget(target)
4163
+ ? eventTargetMethods.map((methodName) => (handler) => target[methodName](eventName, handler, options))
4164
+ :
4165
+ isNodeStyleEventEmitter(target)
4166
+ ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName))
4167
+ : isJQueryStyleEventEmitter(target)
4168
+ ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName))
4169
+ : [];
4170
+ if (!add) {
4171
+ if (isArrayLike(target)) {
4172
+ return mergeMap((subTarget) => fromEvent(subTarget, eventName, options))(innerFrom(target));
4173
+ }
4174
+ }
4175
+ if (!add) {
4176
+ throw new TypeError('Invalid event target');
4177
+ }
4178
+ return new Observable((subscriber) => {
4179
+ const handler = (...args) => subscriber.next(1 < args.length ? args : args[0]);
4180
+ add(handler);
4181
+ return () => remove(handler);
4182
+ });
4183
+ }
4184
+ function toCommonHandlerRegistry(target, eventName) {
4185
+ return (methodName) => (handler) => target[methodName](eventName, handler);
4186
+ }
4187
+ function isNodeStyleEventEmitter(target) {
4188
+ return isFunction(target.addListener) && isFunction(target.removeListener);
4189
+ }
4190
+ function isJQueryStyleEventEmitter(target) {
4191
+ return isFunction(target.on) && isFunction(target.off);
4192
+ }
4193
+ function isEventTarget(target) {
4194
+ return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
4195
+ }
4196
+
4197
+ function merge(...args) {
4198
+ const scheduler = popScheduler(args);
4199
+ const concurrent = popNumber(args, Infinity);
4200
+ const sources = args;
4201
+ return !sources.length
4202
+ ?
4203
+ EMPTY
4204
+ : sources.length === 1
4205
+ ?
4206
+ innerFrom(sources[0])
4207
+ :
4208
+ mergeAll(concurrent)(from(sources, scheduler));
4209
+ }
4210
+
4211
+ function filter(predicate, thisArg) {
4212
+ return operate((source, subscriber) => {
4213
+ let index = 0;
4214
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value)));
4215
+ });
4216
+ }
4217
+
4218
+ function distinctUntilChanged(comparator, keySelector = identity) {
4219
+ comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
4220
+ return operate((source, subscriber) => {
4221
+ let previousKey;
4222
+ let first = true;
4223
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => {
4224
+ const currentKey = keySelector(value);
4225
+ if (first || !comparator(previousKey, currentKey)) {
4226
+ first = false;
4227
+ previousKey = currentKey;
4228
+ subscriber.next(value);
4229
+ }
4230
+ }));
4231
+ });
4232
+ }
4233
+ function defaultCompare(a, b) {
4234
+ return a === b;
4235
+ }
4236
+
4237
+ function takeUntil(notifier) {
4238
+ return operate((source, subscriber) => {
4239
+ innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
4240
+ !subscriber.closed && source.subscribe(subscriber);
4241
+ });
4242
+ }
4243
+
4244
+ const catScrollableCss = ":host{overflow:hidden;position:relative;display:flex}:host([hidden]){display:none}.shadow-bottom,.shadow-right,.shadow-left,.shadow-top{position:absolute;transition:box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1)}.shadow-top{z-index:2;width:100%;top:0}.shadow-left{z-index:4;height:100%;left:0}.shadow-right{z-index:4;height:100%;right:0}.shadow-bottom{z-index:2;width:100%;bottom:0}.scrollable-wrapper{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none}.scrollable-wrapper.cat-scrollable-top .shadow-top,.scrollable-wrapper.cat-scrollable-bottom .shadow-bottom,.scrollable-wrapper.cat-scrollable-left .shadow-left,.scrollable-wrapper.cat-scrollable-right .shadow-right{box-shadow:0 0 4px 1px rgba(16, 29, 48, 0.2)}.scrollable-content{overflow:hidden;white-space:nowrap}.scrollable-content.scroll-x{overflow-x:auto}.scrollable-content.scroll-y{overflow-y:auto}.scrollable-content.no-overscroll{overscroll-behavior:contain}";
4245
+
4246
+ const CatScrollable = class {
4247
+ constructor(hostRef) {
4248
+ index.registerInstance(this, hostRef);
4249
+ this.scrolledTop = index.createEvent(this, "scrolledTop", 7);
4250
+ this.scrolledLeft = index.createEvent(this, "scrolledLeft", 7);
4251
+ this.scrolledRight = index.createEvent(this, "scrolledRight", 7);
4252
+ this.scrolledBottom = index.createEvent(this, "scrolledBottom", 7);
4253
+ this.init = new Subject();
4254
+ this.destroyed = new Subject();
4255
+ /** Flags to enable/disable scroll shadowX. */
4256
+ this.shadowX = true;
4257
+ /** Flags to enable/disable scroll shadowY. */
4258
+ this.shadowY = true;
4259
+ /** Flags to enable/disable overflowX. */
4260
+ this.overflowX = true;
4261
+ /** Flags to enable/disable overflowY. */
4262
+ this.overflowY = true;
4263
+ /** Flag to enable/disable overscroll behavior. */
4264
+ this.overscroll = true;
4265
+ /**
4266
+ * Flag to fire an initial event after content initialization.
4267
+ */
4268
+ this.scrolledInit = true;
4269
+ /**
4270
+ * Buffer to be used to calculate the scroll distance.
4271
+ */
4272
+ this.scrolledBuffer = 0;
4273
+ }
4274
+ componentDidRender() {
4275
+ if (this.scrollElement) {
4276
+ this.scrolled = fromEvent(this.scrollElement, 'scroll').pipe(takeUntil(this.destroyed));
4277
+ }
4278
+ this.attachEmitter('left', this.scrolledLeft, this.scrolledBuffer);
4279
+ this.attachEmitter('right', this.scrolledRight, this.scrolledBuffer);
4280
+ this.attachEmitter('bottom', this.scrolledBottom, this.scrolledBuffer);
4281
+ this.attachEmitter('top', this.scrolledTop, this.scrolledBuffer);
4282
+ merge(this.init, this.scrolled)
4283
+ .pipe(map(() => ({
4284
+ top: this.getScrollOffset('top') > 0,
4285
+ left: this.getScrollOffset('left') > 0,
4286
+ right: this.getScrollOffset('right') > 0,
4287
+ bottom: this.getScrollOffset('bottom') > 0
4288
+ })), distinctUntilChanged(), takeUntil(this.destroyed))
4289
+ .subscribe(({ top, left, right, bottom }) => {
4290
+ this.toggleClass('cat-scrollable-top', top);
4291
+ this.toggleClass('cat-scrollable-left', left);
4292
+ this.toggleClass('cat-scrollable-right', right);
4293
+ this.toggleClass('cat-scrollable-bottom', bottom);
4294
+ });
4295
+ }
4296
+ componentDidLoad() {
4297
+ if (this.scrolledInit) {
4298
+ this.init.next();
4299
+ }
4300
+ }
4301
+ disconnectedCallback() {
4302
+ this.init.complete();
4303
+ this.destroyed.next();
4304
+ this.destroyed.complete();
4305
+ }
4306
+ render() {
4307
+ return [
4308
+ index.h("div", { class: "scrollable-wrapper", ref: el => (this.scrollWrapperElement = el) }, this.shadowY && index.h("div", { class: "shadow-top" }), this.shadowX && index.h("div", { class: "shadow-left" }), this.shadowX && index.h("div", { class: "shadow-right" }), this.shadowY && index.h("div", { class: "shadow-bottom" })),
4309
+ index.h("div", { ref: el => (this.scrollElement = el), class: {
4310
+ 'scrollable-content': true,
4311
+ 'scroll-x': this.overflowX,
4312
+ 'scroll-y': this.overflowY,
4313
+ 'no-overscroll': !this.overscroll
4314
+ } }, index.h("slot", null))
4315
+ ];
4316
+ }
4317
+ attachEmitter(from, emitter, buffer) {
4318
+ merge(this.init, this.scrolled)
4319
+ .pipe(map(() => this.getScrollOffset(from)))
4320
+ .pipe(map(offset => offset <= buffer))
4321
+ .pipe(distinctUntilChanged())
4322
+ .pipe(filter(isLower => isLower))
4323
+ .pipe(takeUntil(this.destroyed))
4324
+ .subscribe(() => emitter.emit());
4325
+ }
4326
+ getScrollOffset(from) {
4327
+ if (this.scrollElement) {
4328
+ switch (from) {
4329
+ case 'top':
4330
+ return this.scrollElement.scrollTop;
4331
+ case 'left':
4332
+ return this.scrollElement.scrollLeft;
4333
+ case 'right':
4334
+ return this.scrollElement.scrollWidth - this.scrollElement.clientWidth - this.scrollElement.scrollLeft;
4335
+ case 'bottom':
4336
+ return this.scrollElement.scrollHeight - this.scrollElement.clientHeight - this.scrollElement.scrollTop;
4337
+ default:
4338
+ return 0;
4339
+ }
4340
+ }
4341
+ return 0;
4342
+ }
4343
+ toggleClass(name, value) {
4344
+ var _a, _b;
4345
+ if (value) {
4346
+ (_a = this.scrollWrapperElement) === null || _a === void 0 ? void 0 : _a.classList.add(name);
4347
+ }
4348
+ else {
4349
+ (_b = this.scrollWrapperElement) === null || _b === void 0 ? void 0 : _b.classList.remove(name);
4350
+ }
4351
+ }
4352
+ get el() { return index.getElement(this); }
4353
+ };
4354
+ CatScrollable.style = catScrollableCss;
4355
+
4356
+ const catSkeletonCss = ":host{display:flex;flex-direction:column;position:relative;--background:#ebecf0;--highlight:#d7dbe0;--speed:2s}:host([variant=square]),:host([variant=circle]){display:inline-flex}:host([hidden]){display:none}:host([variant=head]){margin-bottom:0.5rem}:host([variant=body]){margin-bottom:1rem}.cat-skeleton{display:block;border-radius:0.25rem;background:var(--background)}.cat-skeleton-circle{border-radius:10rem}.cat-skeleton-xs.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 1.5rem)}.cat-skeleton-xs.cat-skeleton-square,.cat-skeleton-xs.cat-skeleton-circle{width:var(--width, 1.5rem);height:var(--height, 1.5rem)}.cat-skeleton-xs.cat-skeleton-head,.cat-skeleton-xs.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-xs.cat-skeleton-head{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.cat-skeleton-xs.cat-skeleton-body{height:calc(0.75rem - 4px);margin:calc((1rem - 0.75rem + 4px) * 0.5) 0}.cat-skeleton-s.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2rem)}.cat-skeleton-s.cat-skeleton-square,.cat-skeleton-s.cat-skeleton-circle{width:var(--width, 2rem);height:var(--height, 2rem)}.cat-skeleton-s.cat-skeleton-head,.cat-skeleton-s.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-s.cat-skeleton-head{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.cat-skeleton-s.cat-skeleton-body{height:calc(0.875rem - 4px);margin:calc((1rem - 0.875rem + 4px) * 0.5) 0}.cat-skeleton-m.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2.5rem)}.cat-skeleton-m.cat-skeleton-square,.cat-skeleton-m.cat-skeleton-circle{width:var(--width, 2.5rem);height:var(--height, 2.5rem)}.cat-skeleton-m.cat-skeleton-head,.cat-skeleton-m.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-m.cat-skeleton-head{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.cat-skeleton-m.cat-skeleton-body{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.cat-skeleton-l.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3rem)}.cat-skeleton-l.cat-skeleton-square,.cat-skeleton-l.cat-skeleton-circle{width:var(--width, 3rem);height:var(--height, 3rem)}.cat-skeleton-l.cat-skeleton-head,.cat-skeleton-l.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-l.cat-skeleton-head{height:calc(1.5rem - 4px);margin:calc((1.75rem - 1.5rem + 4px) * 0.5) 0}.cat-skeleton-l.cat-skeleton-body{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.cat-skeleton-xl.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3.5rem)}.cat-skeleton-xl.cat-skeleton-square,.cat-skeleton-xl.cat-skeleton-circle{width:var(--width, 3.5rem);height:var(--height, 3.5rem)}.cat-skeleton-xl.cat-skeleton-head,.cat-skeleton-xl.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-xl.cat-skeleton-head{height:calc(1.75rem - 4px);margin:calc((2rem - 1.75rem + 4px) * 0.5) 0}.cat-skeleton-xl.cat-skeleton-body{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.cat-skeleton-sheen{background:linear-gradient(90deg, var(--background) 33%, var(--highlight) 50%, var(--background) 66%) var(--background);background-size:300% 100%;animation:sheen var(--speed) ease-in-out infinite}.cat-skeleton-pulse{position:relative;overflow:hidden}.cat-skeleton-pulse::before{content:\"\";display:block;position:absolute;width:100%;height:100%;background-color:var(--highlight);animation:var(--speed) ease-in-out 0.5s infinite normal none running pulse;opacity:0}@keyframes sheen{0%{background-position:right}}@keyframes pulse{50%{opacity:1}}";
4357
+
4358
+ const CatSkeleton = class {
4359
+ constructor(hostRef) {
4360
+ index.registerInstance(this, hostRef);
4361
+ /**
4362
+ * The animation style of the skeleton.
4363
+ */
4364
+ this.effect = 'sheen';
4365
+ /**
4366
+ * The rendering style of the skeleton.
4367
+ */
4368
+ this.variant = 'rectangle';
4369
+ /**
4370
+ * The size of the skeleton. If the variant is set to "head", the size values
4371
+ * "xs" to "xl" translate to the head levels `h1` to `h5`.
4372
+ */
4373
+ this.size = 'm';
4374
+ }
4375
+ render() {
4376
+ return (index.h(index.Host, null, Array.from(Array(this.count)).map(() => (index.h("div", { style: this.style, class: {
4377
+ 'cat-skeleton': true,
4378
+ [`cat-skeleton-${this.effect}`]: Boolean(this.effect),
4379
+ [`cat-skeleton-${this.variant}`]: Boolean(this.variant),
4380
+ [`cat-skeleton-${this.size}`]: Boolean(this.size)
4381
+ } })))));
4382
+ }
4383
+ get count() {
4384
+ switch (this.variant) {
4385
+ case 'head':
4386
+ return Math.max(1, this.lines || 1);
4387
+ case 'body':
4388
+ return Math.max(1, this.lines || 3);
4389
+ default:
4390
+ return 1;
4391
+ }
4392
+ }
4393
+ get style() {
4394
+ return this.variant === 'head' || this.variant === 'body'
4395
+ ? {
4396
+ '--line-width': `${this.random(50, 100)}%`
4397
+ }
4398
+ : undefined;
4399
+ }
4400
+ random(min, max) {
4401
+ return Math.floor(Math.random() * (max - min + 1) + min);
4402
+ }
4403
+ };
4404
+ CatSkeleton.style = catSkeletonCss;
4405
+
4406
+ const catSpinnerCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host[hidden]{display:none}span{display:inline-flex}svg{fill:none;stroke:currentColor;stroke-dasharray:135px;stroke-dashoffset:95px;stroke-linecap:round;stroke-width:5px;transform-origin:center center;animation:cat-spinner 0.75s cubic-bezier(0.4, 0.15, 0.6, 0.85) infinite;width:1em;height:1em}.cat-spinner-xs svg{font-size:0.75rem}.cat-spinner-s svg{font-size:1rem}.cat-spinner-m svg{font-size:1.25rem}.cat-spinner-l svg{font-size:1.5rem}.cat-spinner-xl svg{font-size:1.75rem}@keyframes cat-spinner{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";
4407
+
4408
+ const CatSpinner = class {
4409
+ constructor(hostRef) {
4410
+ index.registerInstance(this, hostRef);
4411
+ /**
4412
+ * The size of the spinner.
4413
+ */
4414
+ this.size = 'm';
4415
+ }
4416
+ render() {
4417
+ return (index.h("span", { "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', class: {
4418
+ [`cat-spinner-${this.size}`]: this.size !== 'inline'
4419
+ } }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48" }, index.h("circle", { cx: "24", cy: "24", r: "21.5" }))));
4420
+ }
4421
+ };
4422
+ CatSpinner.style = catSpinnerCss;
4423
+
4424
+ const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
4425
+
4426
+ const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;padding:0.25rem;background-color:rgba(0, 0, 0, 0.7);border-radius:0.125rem;color:white;white-space:nowrap;transition:0.13s linear;visibility:hidden;opacity:0}.tooltip-show{opacity:1;visibility:visible}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
4427
+
4428
+ let nextUniqueId = 0;
4429
+ const CatTooltip = class {
4430
+ constructor(hostRef) {
4431
+ index.registerInstance(this, hostRef);
4432
+ this.id = `cat-tooltip-${nextUniqueId++}`;
4433
+ /**
4434
+ * The content of the tooltip.
4435
+ */
4436
+ this.content = '';
4437
+ /**
4438
+ * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,
4439
+ * and invisible. Corresponds with the native HTML disabled attribute.
4440
+ */
4441
+ this.disabled = false;
4442
+ /**
4443
+ * The placement of the tooltip.
4444
+ */
4445
+ this.placement = 'top';
4446
+ /**
4447
+ * The delay time for showing tooltip in ms.
4448
+ */
4449
+ this.showDelay = 1000;
4450
+ /**
4451
+ * The delay time for hiding tooltip in ms.
4452
+ */
4453
+ this.hideDelay = 0;
4454
+ /**
4455
+ * The duration of tap to show the tooltip.
4456
+ */
4457
+ this.longTouchDuration = 1000;
4458
+ }
4459
+ handleKeyDown({ key }) {
4460
+ key === 'Escape' && this.hideListener();
4461
+ }
4462
+ componentDidLoad() {
4463
+ var _a, _b, _c, _d, _e, _f, _g;
4464
+ this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;
4465
+ if (!this.isTabbable) {
4466
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
4467
+ }
4468
+ if (this.trigger && this.tooltip) {
4469
+ autoUpdate(this.trigger, this.tooltip, () => this.update());
4470
+ }
4471
+ if (isTouchDevice) {
4472
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.addEventListener('touchstart', this.touchStartListener.bind(this));
4473
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('touchend', this.touchEndListener.bind(this));
4474
+ }
4475
+ else {
4476
+ (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('focusin', this.showListener.bind(this));
4477
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('focusout', this.hideListener.bind(this));
4478
+ (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseenter', this.showListener.bind(this));
4479
+ (_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('mouseleave', this.hideListener.bind(this));
4480
+ }
4481
+ }
4482
+ disconnectedCallback() {
4483
+ var _a, _b, _c, _d, _e, _f;
4484
+ if (isTouchDevice) {
4485
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('touchstart', this.touchStartListener.bind(this));
4486
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('touchend', this.touchEndListener.bind(this));
4487
+ }
4488
+ else {
4489
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseenter', this.showListener.bind(this));
4490
+ (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseleave', this.hideListener.bind(this));
4491
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.removeEventListener('focusin', this.showListener.bind(this));
4492
+ (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.removeEventListener('focusout', this.hideListener.bind(this));
4493
+ }
4494
+ }
4495
+ render() {
4496
+ return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
4497
+ }
4498
+ get isTabbable() {
4499
+ return firstTabbable(this.trigger);
4500
+ }
4501
+ update() {
4502
+ if (this.trigger && this.tooltip) {
4503
+ computePosition(this.trigger, this.tooltip, {
4504
+ placement: this.placement,
4505
+ middleware: [offset(CatTooltip.OFFSET), flip()]
4506
+ }).then(({ x, y }) => {
4507
+ if (this.tooltip) {
4508
+ Object.assign(this.tooltip.style, {
4509
+ left: `${Math.max(0, x)}px`,
4510
+ top: `${y}px`
4511
+ });
4512
+ }
4513
+ });
4514
+ }
4515
+ }
4516
+ showListener() {
4517
+ window.clearTimeout(this.hideTimeout);
4518
+ this.showTimeout = window.setTimeout(() => {
4519
+ var _a, _b;
4520
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.focus();
4521
+ (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.add('tooltip-show');
4522
+ }, this.showDelay);
4523
+ }
4524
+ hideListener() {
4525
+ window.clearTimeout(this.showTimeout);
4526
+ this.hideTimeout = window.setTimeout(() => {
4527
+ var _a, _b;
4528
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.blur();
4529
+ (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.remove('tooltip-show');
4530
+ }, this.hideDelay);
4531
+ }
4532
+ touchStartListener() {
4533
+ this.touchTimeout = window.setTimeout(() => {
4534
+ var _a;
4535
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
4536
+ }, this.longTouchDuration);
4537
+ }
4538
+ touchEndListener() {
4539
+ var _a;
4540
+ window.clearTimeout(this.touchTimeout);
4541
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
4542
+ }
4543
+ };
4544
+ CatTooltip.OFFSET = 4;
4545
+ CatTooltip.style = catTooltipCss;
4546
+
4547
+ exports.cat_alert = CatAlert;
4548
+ exports.cat_badge = CatBadge;
4549
+ exports.cat_button = CatButton;
4550
+ exports.cat_icon = CatIcon;
4551
+ exports.cat_menu = CatMenu;
4552
+ exports.cat_scrollable = CatScrollable;
4553
+ exports.cat_skeleton = CatSkeleton;
4554
+ exports.cat_spinner = CatSpinner;
4555
+ exports.cat_tooltip = CatTooltip;
4556
+
4557
+ //# sourceMappingURL=cat-alert_9.cjs.entry.js.map