@dta-au/civictheme-twig 1.13.1

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 (667) hide show
  1. package/assets/backgrounds/civictheme_background_1.png +0 -0
  2. package/assets/backgrounds/civictheme_background_2.png +0 -0
  3. package/assets/backgrounds/civictheme_background_3.png +0 -0
  4. package/assets/backgrounds/civictheme_background_4.png +0 -0
  5. package/assets/backgrounds/civictheme_background_5.png +0 -0
  6. package/assets/backgrounds/civictheme_background_6.png +0 -0
  7. package/assets/backgrounds/civictheme_background_7.png +0 -0
  8. package/assets/fonts/.gitkeep +0 -0
  9. package/assets/icons/account.svg +3 -0
  10. package/assets/icons/approve.svg +3 -0
  11. package/assets/icons/bars.svg +3 -0
  12. package/assets/icons/bullet.svg +3 -0
  13. package/assets/icons/calendar-1.svg +3 -0
  14. package/assets/icons/calendar-2.svg +3 -0
  15. package/assets/icons/call.svg +3 -0
  16. package/assets/icons/cancel.svg +3 -0
  17. package/assets/icons/checked.svg +4 -0
  18. package/assets/icons/close-outline.svg +3 -0
  19. package/assets/icons/close.svg +3 -0
  20. package/assets/icons/document.svg +4 -0
  21. package/assets/icons/down-arrow-1.svg +3 -0
  22. package/assets/icons/down-arrow-2.svg +3 -0
  23. package/assets/icons/download-file.svg +3 -0
  24. package/assets/icons/download.svg +3 -0
  25. package/assets/icons/exclamation-mark-1.svg +3 -0
  26. package/assets/icons/exclamation-mark-2.svg +3 -0
  27. package/assets/icons/exclamation-mark-3.svg +3 -0
  28. package/assets/icons/eye.svg +3 -0
  29. package/assets/icons/facebook.svg +3 -0
  30. package/assets/icons/help.svg +3 -0
  31. package/assets/icons/image.svg +5 -0
  32. package/assets/icons/information-mark.svg +3 -0
  33. package/assets/icons/instagram.svg +3 -0
  34. package/assets/icons/layer.svg +4 -0
  35. package/assets/icons/layers.svg +4 -0
  36. package/assets/icons/left-arrow-outline.svg +3 -0
  37. package/assets/icons/left-arrow.svg +3 -0
  38. package/assets/icons/linkedin.svg +3 -0
  39. package/assets/icons/lock-file.svg +4 -0
  40. package/assets/icons/lock-gallery.svg +4 -0
  41. package/assets/icons/magnifier.svg +3 -0
  42. package/assets/icons/map.svg +3 -0
  43. package/assets/icons/megaphone.svg +3 -0
  44. package/assets/icons/message.svg +3 -0
  45. package/assets/icons/mobile.svg +4 -0
  46. package/assets/icons/mortarboard.svg +3 -0
  47. package/assets/icons/newspaper.svg +3 -0
  48. package/assets/icons/open-source.svg +3 -0
  49. package/assets/icons/pdf-file.svg +4 -0
  50. package/assets/icons/progress.svg +3 -0
  51. package/assets/icons/right-arrow-1.svg +3 -0
  52. package/assets/icons/right-arrow-2.svg +3 -0
  53. package/assets/icons/select-box.svg +4 -0
  54. package/assets/icons/share.svg +3 -0
  55. package/assets/icons/square.svg +3 -0
  56. package/assets/icons/to-do.svg +3 -0
  57. package/assets/icons/twitter.svg +3 -0
  58. package/assets/icons/up-arrow.svg +3 -0
  59. package/assets/icons/upper-arrow.svg +3 -0
  60. package/assets/icons/upper-right-arrow.svg +3 -0
  61. package/assets/icons/users.svg +4 -0
  62. package/assets/icons/watch.svg +3 -0
  63. package/assets/icons/water-drop.svg +4 -0
  64. package/assets/icons/web.svg +4 -0
  65. package/assets/icons/word-file.svg +4 -0
  66. package/assets/icons/x.svg +3 -0
  67. package/assets/icons/youtube.svg +3 -0
  68. package/assets/logos/logo_custom_light_desktop_civictheme.svg +32 -0
  69. package/assets/logos/logo_custom_light_mobile_civictheme.svg +32 -0
  70. package/assets/logos/logo_primary_dark_desktop.png +0 -0
  71. package/assets/logos/logo_primary_dark_mobile.png +0 -0
  72. package/assets/logos/logo_primary_light_desktop.png +0 -0
  73. package/assets/logos/logo_primary_light_mobile.png +0 -0
  74. package/assets/logos/logo_secondary_dark_desktop.png +0 -0
  75. package/assets/logos/logo_secondary_dark_mobile.png +0 -0
  76. package/assets/logos/logo_secondary_light_desktop.png +0 -0
  77. package/assets/logos/logo_secondary_light_mobile.png +0 -0
  78. package/components/00-base/_variables.base.scss +482 -0
  79. package/components/00-base/_variables.components.scss +1315 -0
  80. package/components/00-base/about-civictheme/about-civictheme.stories.js +37 -0
  81. package/components/00-base/about-civictheme/about-civictheme.stories.scss +37 -0
  82. package/components/00-base/about-civictheme/about-civictheme.stories.twig +219 -0
  83. package/components/00-base/background/background.scss +12 -0
  84. package/components/00-base/background/background.stories.js +33 -0
  85. package/components/00-base/background/background.stories.scss +16 -0
  86. package/components/00-base/background/background.stories.twig +6 -0
  87. package/components/00-base/background/background.utils.js +23 -0
  88. package/components/00-base/collapsible/collapsible.js +452 -0
  89. package/components/00-base/collapsible/collapsible.scss +80 -0
  90. package/components/00-base/collapsible/collapsible.stories.js +17 -0
  91. package/components/00-base/collapsible/collapsible.stories.scss +38 -0
  92. package/components/00-base/collapsible/collapsible.stories.twig +497 -0
  93. package/components/00-base/collapsible/collapsible.test.js +186 -0
  94. package/components/00-base/colors/colors.stories.js +142 -0
  95. package/components/00-base/colors/colors.stories.scss +78 -0
  96. package/components/00-base/colors/colors.stories.twig +42 -0
  97. package/components/00-base/datetime/__snapshots__/datetime.test.js.snap +114 -0
  98. package/components/00-base/datetime/datetime.stories.js +47 -0
  99. package/components/00-base/datetime/datetime.test.js +75 -0
  100. package/components/00-base/datetime/datetime.twig +24 -0
  101. package/components/00-base/debug/_index.scss +24 -0
  102. package/components/00-base/elevation/elevation.stories.js +14 -0
  103. package/components/00-base/elevation/elevation.stories.scss +21 -0
  104. package/components/00-base/elevation/elevation.stories.twig +8 -0
  105. package/components/00-base/flex/_index.scss +37 -0
  106. package/components/00-base/flyout/flyout.js +207 -0
  107. package/components/00-base/flyout/flyout.scss +47 -0
  108. package/components/00-base/flyout/flyout.stories.js +34 -0
  109. package/components/00-base/flyout/flyout.stories.scss +38 -0
  110. package/components/00-base/flyout/flyout.stories.twig +101 -0
  111. package/components/00-base/fonts/_index.scss +15 -0
  112. package/components/00-base/fonts/fonts.stories.js +40 -0
  113. package/components/00-base/fonts/fonts.stories.scss +28 -0
  114. package/components/00-base/fonts/fonts.stories.twig +15 -0
  115. package/components/00-base/grid/__snapshots__/grid.test.js.snap +2113 -0
  116. package/components/00-base/grid/grid.scss +164 -0
  117. package/components/00-base/grid/grid.stories.js +570 -0
  118. package/components/00-base/grid/grid.stories.scss +184 -0
  119. package/components/00-base/grid/grid.test.js +386 -0
  120. package/components/00-base/grid/grid.twig +96 -0
  121. package/components/00-base/icon/__snapshots__/icon.test.js.snap +76 -0
  122. package/components/00-base/icon/icon.scss +21 -0
  123. package/components/00-base/icon/icon.stories.js +46 -0
  124. package/components/00-base/icon/icon.test.js +53 -0
  125. package/components/00-base/icon/icon.twig +35 -0
  126. package/components/00-base/icon/icon.utils.js +35 -0
  127. package/components/00-base/item-list/__snapshots__/item-list.test.js.snap +255 -0
  128. package/components/00-base/item-list/item-list.scss +66 -0
  129. package/components/00-base/item-list/item-list.stories.js +49 -0
  130. package/components/00-base/item-list/item-list.test.js +96 -0
  131. package/components/00-base/item-list/item-list.twig +35 -0
  132. package/components/00-base/layout/__snapshots__/layout.test.js.snap +520 -0
  133. package/components/00-base/layout/layout.js +97 -0
  134. package/components/00-base/layout/layout.scss +329 -0
  135. package/components/00-base/layout/layout.stories.data.js +22 -0
  136. package/components/00-base/layout/layout.stories.js +120 -0
  137. package/components/00-base/layout/layout.stories.scss +55 -0
  138. package/components/00-base/layout/layout.test.js +166 -0
  139. package/components/00-base/layout/layout.twig +115 -0
  140. package/components/00-base/menu/__snapshots__/menu.test.js.snap +1028 -0
  141. package/components/00-base/menu/menu.stories.js +107 -0
  142. package/components/00-base/menu/menu.stories.scss +11 -0
  143. package/components/00-base/menu/menu.test.js +231 -0
  144. package/components/00-base/menu/menu.twig +133 -0
  145. package/components/00-base/mixins/_background.scss +11 -0
  146. package/components/00-base/mixins/_breakpoint.scss +75 -0
  147. package/components/00-base/mixins/_button.scss +312 -0
  148. package/components/00-base/mixins/_color.scss +137 -0
  149. package/components/00-base/mixins/_component.scss +39 -0
  150. package/components/00-base/mixins/_content-link.scss +58 -0
  151. package/components/00-base/mixins/_content.scss +369 -0
  152. package/components/00-base/mixins/_cssgrid.scss +106 -0
  153. package/components/00-base/mixins/_debug.scss +29 -0
  154. package/components/00-base/mixins/_deprecations.scss +21 -0
  155. package/components/00-base/mixins/_disabled.scss +11 -0
  156. package/components/00-base/mixins/_elevation.scss +37 -0
  157. package/components/00-base/mixins/_font.scss +140 -0
  158. package/components/00-base/mixins/_form.scss +30 -0
  159. package/components/00-base/mixins/_generator.scss +35 -0
  160. package/components/00-base/mixins/_grid.scss +223 -0
  161. package/components/00-base/mixins/_highlight.scss +84 -0
  162. package/components/00-base/mixins/_icon.scss +118 -0
  163. package/components/00-base/mixins/_image.scss +149 -0
  164. package/components/00-base/mixins/_index.scss +25 -0
  165. package/components/00-base/mixins/_link.scss +163 -0
  166. package/components/00-base/mixins/_map.scss +90 -0
  167. package/components/00-base/mixins/_message.scss +11 -0
  168. package/components/00-base/mixins/_outline.scss +32 -0
  169. package/components/00-base/mixins/_particle.scss +40 -0
  170. package/components/00-base/mixins/_print.scss +26 -0
  171. package/components/00-base/mixins/_rem.scss +20 -0
  172. package/components/00-base/mixins/_reset.scss +85 -0
  173. package/components/00-base/mixins/_spacing.scss +57 -0
  174. package/components/00-base/mixins/_string.scss +76 -0
  175. package/components/00-base/mixins/_table.scss +254 -0
  176. package/components/00-base/mixins/_typography.scss +193 -0
  177. package/components/00-base/mixins/_visibility.scss +27 -0
  178. package/components/00-base/platform/platform.js +27 -0
  179. package/components/00-base/responsive/responsive.js +186 -0
  180. package/components/00-base/responsive/responsive.stories.js +17 -0
  181. package/components/00-base/responsive/responsive.stories.twig +121 -0
  182. package/components/00-base/scrollspy/scrollspy.js +36 -0
  183. package/components/00-base/scrollspy/scrollspy.scss +11 -0
  184. package/components/00-base/scrollspy/scrollspy.stories.js +18 -0
  185. package/components/00-base/scrollspy/scrollspy.stories.scss +51 -0
  186. package/components/00-base/scrollspy/scrollspy.stories.twig +9 -0
  187. package/components/00-base/skip-to-target/skip-to-target.js +27 -0
  188. package/components/00-base/spacing/spacing.scss +29 -0
  189. package/components/00-base/spacing/spacing.stories.js +16 -0
  190. package/components/00-base/spacing/spacing.stories.scss +51 -0
  191. package/components/00-base/spacing/spacing.stories.twig +64 -0
  192. package/components/00-base/storybook/storybook.container.utils.stories.scss +105 -0
  193. package/components/00-base/storybook/storybook.docs.utils.js +37 -0
  194. package/components/00-base/storybook/storybook.docs.utils.stories.scss +70 -0
  195. package/components/00-base/storybook/storybook.generators.utils.js +19 -0
  196. package/components/00-base/storybook/storybook.layout.utils.stories.scss +90 -0
  197. package/components/00-base/storybook/storybook.placeholder.utils.stories.scss +75 -0
  198. package/components/00-base/storybook/storybook.stories.scss +8 -0
  199. package/components/00-base/text-icon/text-icon.scss +9 -0
  200. package/components/00-base/text-icon/text-icon.stories.js +57 -0
  201. package/components/00-base/text-icon/text-icon.twig +81 -0
  202. package/components/00-base/typography/typography.scss +81 -0
  203. package/components/00-base/typography/typography.stories.js +17 -0
  204. package/components/00-base/typography/typography.stories.twig +228 -0
  205. package/components/00-base/variables.scss +41 -0
  206. package/components/00-base/visibility/_index.scss +42 -0
  207. package/components/00-base/welcome/welcome.stories.js +37 -0
  208. package/components/00-base/welcome/welcome.stories.scss +30 -0
  209. package/components/00-base/welcome/welcome.stories.twig +41 -0
  210. package/components/01-atoms/button/__snapshots__/button.test.js.snap +205 -0
  211. package/components/01-atoms/button/button.js +127 -0
  212. package/components/01-atoms/button/button.scss +82 -0
  213. package/components/01-atoms/button/button.stories.js +86 -0
  214. package/components/01-atoms/button/button.test.js +103 -0
  215. package/components/01-atoms/button/button.twig +82 -0
  216. package/components/01-atoms/checkbox/__snapshots__/checkbox.test.js.snap +65 -0
  217. package/components/01-atoms/checkbox/checkbox.scss +176 -0
  218. package/components/01-atoms/checkbox/checkbox.stories.js +63 -0
  219. package/components/01-atoms/checkbox/checkbox.test.js +67 -0
  220. package/components/01-atoms/checkbox/checkbox.twig +47 -0
  221. package/components/01-atoms/chip/__snapshots__/chip.test.js.snap +90 -0
  222. package/components/01-atoms/chip/chip.event.stories.js +25 -0
  223. package/components/01-atoms/chip/chip.js +104 -0
  224. package/components/01-atoms/chip/chip.scss +144 -0
  225. package/components/01-atoms/chip/chip.stories.js +74 -0
  226. package/components/01-atoms/chip/chip.test.js +53 -0
  227. package/components/01-atoms/chip/chip.twig +73 -0
  228. package/components/01-atoms/content-link/__snapshots__/content-link.test.js.snap +91 -0
  229. package/components/01-atoms/content-link/content-link.scss +16 -0
  230. package/components/01-atoms/content-link/content-link.stories.js +50 -0
  231. package/components/01-atoms/content-link/content-link.test.js +50 -0
  232. package/components/01-atoms/content-link/content-link.twig +40 -0
  233. package/components/01-atoms/field-description/__snapshots__/field-description.test.js.snap +49 -0
  234. package/components/01-atoms/field-description/field-description.scss +24 -0
  235. package/components/01-atoms/field-description/field-description.stories.js +41 -0
  236. package/components/01-atoms/field-description/field-description.test.js +51 -0
  237. package/components/01-atoms/field-description/field-description.twig +24 -0
  238. package/components/01-atoms/field-message/__snapshots__/field-message.test.js.snap +142 -0
  239. package/components/01-atoms/field-message/field-message.scss +108 -0
  240. package/components/01-atoms/field-message/field-message.stories.js +41 -0
  241. package/components/01-atoms/field-message/field-message.test.js +64 -0
  242. package/components/01-atoms/field-message/field-message.twig +37 -0
  243. package/components/01-atoms/fieldset/__snapshots__/fieldset.test.js.snap +358 -0
  244. package/components/01-atoms/fieldset/fieldset.scss +44 -0
  245. package/components/01-atoms/fieldset/fieldset.stories.js +79 -0
  246. package/components/01-atoms/fieldset/fieldset.test.js +102 -0
  247. package/components/01-atoms/fieldset/fieldset.twig +91 -0
  248. package/components/01-atoms/heading/__snapshots__/heading.test.js.snap +43 -0
  249. package/components/01-atoms/heading/heading.scss +13 -0
  250. package/components/01-atoms/heading/heading.stories.js +41 -0
  251. package/components/01-atoms/heading/heading.test.js +42 -0
  252. package/components/01-atoms/heading/heading.twig +24 -0
  253. package/components/01-atoms/iframe/__snapshots__/iframe.test.js.snap +34 -0
  254. package/components/01-atoms/iframe/iframe.scss +29 -0
  255. package/components/01-atoms/iframe/iframe.stories.js +53 -0
  256. package/components/01-atoms/iframe/iframe.test.js +37 -0
  257. package/components/01-atoms/iframe/iframe.twig +29 -0
  258. package/components/01-atoms/image/__snapshots__/image.test.js.snap +45 -0
  259. package/components/01-atoms/image/image.stories.js +48 -0
  260. package/components/01-atoms/image/image.test.js +45 -0
  261. package/components/01-atoms/image/image.twig +31 -0
  262. package/components/01-atoms/input/__snapshots__/input.test.js.snap +64 -0
  263. package/components/01-atoms/input/input.scss +112 -0
  264. package/components/01-atoms/input/input.stories.js +81 -0
  265. package/components/01-atoms/input/input.test.js +71 -0
  266. package/components/01-atoms/input/input.twig +38 -0
  267. package/components/01-atoms/label/__snapshots__/label.test.js.snap +69 -0
  268. package/components/01-atoms/label/label.scss +34 -0
  269. package/components/01-atoms/label/label.stories.js +65 -0
  270. package/components/01-atoms/label/label.test.js +76 -0
  271. package/components/01-atoms/label/label.twig +35 -0
  272. package/components/01-atoms/link/__snapshots__/link.test.js.snap +138 -0
  273. package/components/01-atoms/link/link.scss +53 -0
  274. package/components/01-atoms/link/link.stories.js +82 -0
  275. package/components/01-atoms/link/link.test.js +84 -0
  276. package/components/01-atoms/link/link.twig +62 -0
  277. package/components/01-atoms/paragraph/__snapshots__/paragraph.test.js.snap +36 -0
  278. package/components/01-atoms/paragraph/paragraph.scss +31 -0
  279. package/components/01-atoms/paragraph/paragraph.stories.js +45 -0
  280. package/components/01-atoms/paragraph/paragraph.test.js +40 -0
  281. package/components/01-atoms/paragraph/paragraph.twig +25 -0
  282. package/components/01-atoms/popover/__snapshots__/popover.test.js.snap +129 -0
  283. package/components/01-atoms/popover/popover.scss +44 -0
  284. package/components/01-atoms/popover/popover.stories.js +52 -0
  285. package/components/01-atoms/popover/popover.test.js +57 -0
  286. package/components/01-atoms/popover/popover.twig +69 -0
  287. package/components/01-atoms/radio/__snapshots__/radio.test.js.snap +83 -0
  288. package/components/01-atoms/radio/radio.scss +176 -0
  289. package/components/01-atoms/radio/radio.stories.js +64 -0
  290. package/components/01-atoms/radio/radio.test.js +76 -0
  291. package/components/01-atoms/radio/radio.twig +47 -0
  292. package/components/01-atoms/select/__snapshots__/select.test.js.snap +165 -0
  293. package/components/01-atoms/select/select.scss +105 -0
  294. package/components/01-atoms/select/select.stories.js +81 -0
  295. package/components/01-atoms/select/select.test.js +117 -0
  296. package/components/01-atoms/select/select.twig +63 -0
  297. package/components/01-atoms/table/__snapshots__/table.test.js.snap +206 -0
  298. package/components/01-atoms/table/table.js +79 -0
  299. package/components/01-atoms/table/table.scss +18 -0
  300. package/components/01-atoms/table/table.stories.js +129 -0
  301. package/components/01-atoms/table/table.test.js +60 -0
  302. package/components/01-atoms/table/table.twig +104 -0
  303. package/components/01-atoms/tag/__snapshots__/tag.test.js.snap +97 -0
  304. package/components/01-atoms/tag/tag.scss +63 -0
  305. package/components/01-atoms/tag/tag.stories.js +55 -0
  306. package/components/01-atoms/tag/tag.test.js +49 -0
  307. package/components/01-atoms/tag/tag.twig +74 -0
  308. package/components/01-atoms/textarea/__snapshots__/textarea.test.js.snap +64 -0
  309. package/components/01-atoms/textarea/textarea.scss +72 -0
  310. package/components/01-atoms/textarea/textarea.stories.js +64 -0
  311. package/components/01-atoms/textarea/textarea.test.js +68 -0
  312. package/components/01-atoms/textarea/textarea.twig +37 -0
  313. package/components/01-atoms/textfield/__snapshots__/textfield.test.js.snap +63 -0
  314. package/components/01-atoms/textfield/textfield.scss +70 -0
  315. package/components/01-atoms/textfield/textfield.stories.js +60 -0
  316. package/components/01-atoms/textfield/textfield.test.js +64 -0
  317. package/components/01-atoms/textfield/textfield.twig +37 -0
  318. package/components/01-atoms/video/__snapshots__/video.test.js.snap +75 -0
  319. package/components/01-atoms/video/video.stories.js +69 -0
  320. package/components/01-atoms/video/video.test.js +57 -0
  321. package/components/01-atoms/video/video.twig +59 -0
  322. package/components/02-molecules/accordion/__snapshots__/accordion.test.js.snap +651 -0
  323. package/components/02-molecules/accordion/accordion.scss +109 -0
  324. package/components/02-molecules/accordion/accordion.stories.js +73 -0
  325. package/components/02-molecules/accordion/accordion.test.js +84 -0
  326. package/components/02-molecules/accordion/accordion.twig +86 -0
  327. package/components/02-molecules/attachment/__snapshots__/attachment.test.js.snap +694 -0
  328. package/components/02-molecules/attachment/attachment.scss +54 -0
  329. package/components/02-molecules/attachment/attachment.stories.js +125 -0
  330. package/components/02-molecules/attachment/attachment.test.js +84 -0
  331. package/components/02-molecules/attachment/attachment.twig +139 -0
  332. package/components/02-molecules/back-to-top/__snapshots__/back-to-top.test.js.snap +172 -0
  333. package/components/02-molecules/back-to-top/back-to-top.scss +39 -0
  334. package/components/02-molecules/back-to-top/back-to-top.stories.js +26 -0
  335. package/components/02-molecules/back-to-top/back-to-top.stories.scss +20 -0
  336. package/components/02-molecules/back-to-top/back-to-top.stories.twig +6 -0
  337. package/components/02-molecules/back-to-top/back-to-top.test.js +31 -0
  338. package/components/02-molecules/back-to-top/back-to-top.twig +32 -0
  339. package/components/02-molecules/basic-content/__snapshots__/basic-content.test.js.snap +110 -0
  340. package/components/02-molecules/basic-content/basic-content.scss +39 -0
  341. package/components/02-molecules/basic-content/basic-content.stories.data.js +157 -0
  342. package/components/02-molecules/basic-content/basic-content.stories.js +56 -0
  343. package/components/02-molecules/basic-content/basic-content.test.js +59 -0
  344. package/components/02-molecules/basic-content/basic-content.twig +42 -0
  345. package/components/02-molecules/breadcrumb/__snapshots__/breadcrumb.test.js.snap +553 -0
  346. package/components/02-molecules/breadcrumb/breadcrumb.scss +23 -0
  347. package/components/02-molecules/breadcrumb/breadcrumb.stories.js +53 -0
  348. package/components/02-molecules/breadcrumb/breadcrumb.test.js +82 -0
  349. package/components/02-molecules/breadcrumb/breadcrumb.twig +85 -0
  350. package/components/02-molecules/callout/__snapshots__/callout.test.js.snap +384 -0
  351. package/components/02-molecules/callout/callout.scss +35 -0
  352. package/components/02-molecules/callout/callout.stories.js +70 -0
  353. package/components/02-molecules/callout/callout.test.js +73 -0
  354. package/components/02-molecules/callout/callout.twig +108 -0
  355. package/components/02-molecules/event-card/__snapshots__/event-card.test.js.snap +382 -0
  356. package/components/02-molecules/event-card/event-card.scss +153 -0
  357. package/components/02-molecules/event-card/event-card.stories.data.js +31 -0
  358. package/components/02-molecules/event-card/event-card.stories.js +68 -0
  359. package/components/02-molecules/event-card/event-card.test.js +74 -0
  360. package/components/02-molecules/event-card/event-card.twig +195 -0
  361. package/components/02-molecules/fast-fact-card/__snapshots__/fast-fact-card.test.js.snap +186 -0
  362. package/components/02-molecules/fast-fact-card/fast-fact-card.scss +104 -0
  363. package/components/02-molecules/fast-fact-card/fast-fact-card.stories.data.js +18 -0
  364. package/components/02-molecules/fast-fact-card/fast-fact-card.stories.js +44 -0
  365. package/components/02-molecules/fast-fact-card/fast-fact-card.test.js +90 -0
  366. package/components/02-molecules/fast-fact-card/fast-fact-card.twig +74 -0
  367. package/components/02-molecules/field/__snapshots__/field.test.js.snap +1526 -0
  368. package/components/02-molecules/field/field.scss +92 -0
  369. package/components/02-molecules/field/field.stories.data.js +52 -0
  370. package/components/02-molecules/field/field.stories.js +117 -0
  371. package/components/02-molecules/field/field.test.js +530 -0
  372. package/components/02-molecules/field/field.twig +206 -0
  373. package/components/02-molecules/figure/__snapshots__/figure.test.js.snap +104 -0
  374. package/components/02-molecules/figure/figure.scss +27 -0
  375. package/components/02-molecules/figure/figure.stories.js +52 -0
  376. package/components/02-molecules/figure/figure.test.js +60 -0
  377. package/components/02-molecules/figure/figure.twig +43 -0
  378. package/components/02-molecules/group-filter/__snapshots__/group-filter.test.js.snap +1466 -0
  379. package/components/02-molecules/group-filter/group-filter.js +33 -0
  380. package/components/02-molecules/group-filter/group-filter.scss +111 -0
  381. package/components/02-molecules/group-filter/group-filter.stories.data.js +83 -0
  382. package/components/02-molecules/group-filter/group-filter.stories.js +81 -0
  383. package/components/02-molecules/group-filter/group-filter.test.js +104 -0
  384. package/components/02-molecules/group-filter/group-filter.twig +192 -0
  385. package/components/02-molecules/inline-filter/inline-filter.scss +58 -0
  386. package/components/02-molecules/inline-filter/inline-filter.stories.data.js +24 -0
  387. package/components/02-molecules/inline-filter/inline-filter.stories.js +52 -0
  388. package/components/02-molecules/inline-filter/inline-filter.twig +48 -0
  389. package/components/02-molecules/logo/__snapshots__/logo.test.js.snap +191 -0
  390. package/components/02-molecules/logo/logo.scss +60 -0
  391. package/components/02-molecules/logo/logo.stories.data.js +34 -0
  392. package/components/02-molecules/logo/logo.stories.js +56 -0
  393. package/components/02-molecules/logo/logo.test.js +111 -0
  394. package/components/02-molecules/logo/logo.twig +71 -0
  395. package/components/02-molecules/logo/logo.utils.js +57 -0
  396. package/components/02-molecules/map/__snapshots__/map.test.js.snap +310 -0
  397. package/components/02-molecules/map/map.scss +35 -0
  398. package/components/02-molecules/map/map.stories.js +65 -0
  399. package/components/02-molecules/map/map.test.js +78 -0
  400. package/components/02-molecules/map/map.twig +86 -0
  401. package/components/02-molecules/navigation-card/__snapshots__/navigation-card.test.js.snap +507 -0
  402. package/components/02-molecules/navigation-card/navigation-card.scss +164 -0
  403. package/components/02-molecules/navigation-card/navigation-card.stories.data.js +26 -0
  404. package/components/02-molecules/navigation-card/navigation-card.stories.js +64 -0
  405. package/components/02-molecules/navigation-card/navigation-card.test.js +146 -0
  406. package/components/02-molecules/navigation-card/navigation-card.twig +165 -0
  407. package/components/02-molecules/next-step/__snapshots__/next-step.test.js.snap +331 -0
  408. package/components/02-molecules/next-step/next-step.scss +46 -0
  409. package/components/02-molecules/next-step/next-step.stories.js +61 -0
  410. package/components/02-molecules/next-step/next-step.test.js +74 -0
  411. package/components/02-molecules/next-step/next-step.twig +104 -0
  412. package/components/02-molecules/pagination/__snapshots__/pagination.test.js.snap +863 -0
  413. package/components/02-molecules/pagination/pagination.scss +103 -0
  414. package/components/02-molecules/pagination/pagination.stories.data.js +55 -0
  415. package/components/02-molecules/pagination/pagination.stories.js +56 -0
  416. package/components/02-molecules/pagination/pagination.test.js +121 -0
  417. package/components/02-molecules/pagination/pagination.twig +177 -0
  418. package/components/02-molecules/promo-card/__snapshots__/promo-card.test.js.snap +407 -0
  419. package/components/02-molecules/promo-card/promo-card.scss +149 -0
  420. package/components/02-molecules/promo-card/promo-card.stories.data.js +32 -0
  421. package/components/02-molecules/promo-card/promo-card.stories.js +62 -0
  422. package/components/02-molecules/promo-card/promo-card.test.js +98 -0
  423. package/components/02-molecules/promo-card/promo-card.twig +198 -0
  424. package/components/02-molecules/publication-card/__snapshots__/publication-card.test.js.snap +342 -0
  425. package/components/02-molecules/publication-card/publication-card.scss +148 -0
  426. package/components/02-molecules/publication-card/publication-card.stories.js +83 -0
  427. package/components/02-molecules/publication-card/publication-card.test.js +113 -0
  428. package/components/02-molecules/publication-card/publication-card.twig +162 -0
  429. package/components/02-molecules/search/__snapshots__/search.test.js.snap +161 -0
  430. package/components/02-molecules/search/search.scss +74 -0
  431. package/components/02-molecules/search/search.stories.js +40 -0
  432. package/components/02-molecules/search/search.test.js +58 -0
  433. package/components/02-molecules/search/search.twig +33 -0
  434. package/components/02-molecules/service-card/__snapshots__/service-card.test.js.snap +324 -0
  435. package/components/02-molecules/service-card/service-card.scss +42 -0
  436. package/components/02-molecules/service-card/service-card.stories.js +65 -0
  437. package/components/02-molecules/service-card/service-card.test.js +91 -0
  438. package/components/02-molecules/service-card/service-card.twig +89 -0
  439. package/components/02-molecules/single-filter/__snapshots__/single-filter.test.js.snap +694 -0
  440. package/components/02-molecules/single-filter/single-filter.js +33 -0
  441. package/components/02-molecules/single-filter/single-filter.scss +70 -0
  442. package/components/02-molecules/single-filter/single-filter.stories.data.js +35 -0
  443. package/components/02-molecules/single-filter/single-filter.stories.js +53 -0
  444. package/components/02-molecules/single-filter/single-filter.test.js +102 -0
  445. package/components/02-molecules/single-filter/single-filter.twig +139 -0
  446. package/components/02-molecules/snippet/__snapshots__/snippet.test.js.snap +367 -0
  447. package/components/02-molecules/snippet/snippet.scss +60 -0
  448. package/components/02-molecules/snippet/snippet.stories.data.js +20 -0
  449. package/components/02-molecules/snippet/snippet.stories.js +50 -0
  450. package/components/02-molecules/snippet/snippet.test.js +108 -0
  451. package/components/02-molecules/snippet/snippet.twig +109 -0
  452. package/components/02-molecules/social-links/__snapshots__/social-links.test.js.snap +311 -0
  453. package/components/02-molecules/social-links/social-links.scss +23 -0
  454. package/components/02-molecules/social-links/social-links.stories.js +77 -0
  455. package/components/02-molecules/social-links/social-links.test.js +82 -0
  456. package/components/02-molecules/social-links/social-links.twig +58 -0
  457. package/components/02-molecules/subject-card/__snapshots__/subject-card.test.js.snap +219 -0
  458. package/components/02-molecules/subject-card/subject-card.scss +112 -0
  459. package/components/02-molecules/subject-card/subject-card.stories.js +58 -0
  460. package/components/02-molecules/subject-card/subject-card.test.js +102 -0
  461. package/components/02-molecules/subject-card/subject-card.twig +81 -0
  462. package/components/02-molecules/table-of-contents/table-of-contents.js +152 -0
  463. package/components/02-molecules/table-of-contents/table-of-contents.scss +115 -0
  464. package/components/02-molecules/table-of-contents/table-of-contents.stories.js +88 -0
  465. package/components/02-molecules/table-of-contents/table-of-contents.twig +63 -0
  466. package/components/02-molecules/tabs/__snapshots__/tabs.test.js.snap +346 -0
  467. package/components/02-molecules/tabs/tabs.js +75 -0
  468. package/components/02-molecules/tabs/tabs.scss +66 -0
  469. package/components/02-molecules/tabs/tabs.stories.js +80 -0
  470. package/components/02-molecules/tabs/tabs.test.js +75 -0
  471. package/components/02-molecules/tabs/tabs.twig +81 -0
  472. package/components/02-molecules/tag-list/__snapshots__/tag-list.test.js.snap +255 -0
  473. package/components/02-molecules/tag-list/tag-list.stories.js +53 -0
  474. package/components/02-molecules/tag-list/tag-list.test.js +64 -0
  475. package/components/02-molecules/tag-list/tag-list.twig +68 -0
  476. package/components/02-molecules/tooltip/__snapshots__/tooltip.test.js.snap +321 -0
  477. package/components/02-molecules/tooltip/tooltip.js +143 -0
  478. package/components/02-molecules/tooltip/tooltip.scss +165 -0
  479. package/components/02-molecules/tooltip/tooltip.stories.js +59 -0
  480. package/components/02-molecules/tooltip/tooltip.test.js +59 -0
  481. package/components/02-molecules/tooltip/tooltip.twig +48 -0
  482. package/components/02-molecules/video-player/__snapshots__/video-player.test.js.snap +244 -0
  483. package/components/02-molecules/video-player/video-player.scss +75 -0
  484. package/components/02-molecules/video-player/video-player.stories.js +180 -0
  485. package/components/02-molecules/video-player/video-player.test.js +81 -0
  486. package/components/02-molecules/video-player/video-player.twig +130 -0
  487. package/components/03-organisms/alert/__snapshots__/alert.test.js.snap +356 -0
  488. package/components/03-organisms/alert/alert.js +268 -0
  489. package/components/03-organisms/alert/alert.scss +90 -0
  490. package/components/03-organisms/alert/alert.stories.js +104 -0
  491. package/components/03-organisms/alert/alert.test.js +59 -0
  492. package/components/03-organisms/alert/alert.twig +76 -0
  493. package/components/03-organisms/banner/__snapshots__/banner.test.js.snap +621 -0
  494. package/components/03-organisms/banner/banner.scss +118 -0
  495. package/components/03-organisms/banner/banner.stories.data.js +88 -0
  496. package/components/03-organisms/banner/banner.stories.js +87 -0
  497. package/components/03-organisms/banner/banner.test.js +94 -0
  498. package/components/03-organisms/banner/banner.twig +218 -0
  499. package/components/03-organisms/campaign/__snapshots__/campaign.test.js.snap +489 -0
  500. package/components/03-organisms/campaign/campaign.scss +64 -0
  501. package/components/03-organisms/campaign/campaign.stories.js +92 -0
  502. package/components/03-organisms/campaign/campaign.test.js +81 -0
  503. package/components/03-organisms/campaign/campaign.twig +152 -0
  504. package/components/03-organisms/footer/__snapshots__/footer.test.js.snap +354 -0
  505. package/components/03-organisms/footer/footer.scss +114 -0
  506. package/components/03-organisms/footer/footer.stories.data.js +42 -0
  507. package/components/03-organisms/footer/footer.stories.js +75 -0
  508. package/components/03-organisms/footer/footer.test.js +85 -0
  509. package/components/03-organisms/footer/footer.twig +157 -0
  510. package/components/03-organisms/header/__snapshots__/header.test.js.snap +411 -0
  511. package/components/03-organisms/header/header.scss +59 -0
  512. package/components/03-organisms/header/header.stories.data.js +132 -0
  513. package/components/03-organisms/header/header.stories.js +78 -0
  514. package/components/03-organisms/header/header.test.js +72 -0
  515. package/components/03-organisms/header/header.twig +141 -0
  516. package/components/03-organisms/list/__snapshots__/list.test.js.snap +454 -0
  517. package/components/03-organisms/list/list.scss +83 -0
  518. package/components/03-organisms/list/list.stories.data.js +98 -0
  519. package/components/03-organisms/list/list.stories.js +223 -0
  520. package/components/03-organisms/list/list.test.js +93 -0
  521. package/components/03-organisms/list/list.twig +263 -0
  522. package/components/03-organisms/message/__snapshots__/message.test.js.snap +517 -0
  523. package/components/03-organisms/message/message.scss +69 -0
  524. package/components/03-organisms/message/message.stories.js +58 -0
  525. package/components/03-organisms/message/message.test.js +158 -0
  526. package/components/03-organisms/message/message.twig +69 -0
  527. package/components/03-organisms/mobile-navigation/__snapshots__/mobile-navigation.test.js.snap +928 -0
  528. package/components/03-organisms/mobile-navigation/mobile-navigation-close.twig +31 -0
  529. package/components/03-organisms/mobile-navigation/mobile-navigation-menu.twig +138 -0
  530. package/components/03-organisms/mobile-navigation/mobile-navigation-trigger.twig +28 -0
  531. package/components/03-organisms/mobile-navigation/mobile-navigation.scss +236 -0
  532. package/components/03-organisms/mobile-navigation/mobile-navigation.stories.js +123 -0
  533. package/components/03-organisms/mobile-navigation/mobile-navigation.stories.scss +21 -0
  534. package/components/03-organisms/mobile-navigation/mobile-navigation.test.js +143 -0
  535. package/components/03-organisms/mobile-navigation/mobile-navigation.twig +86 -0
  536. package/components/03-organisms/navigation/__snapshots__/navigation.test.js.snap +561 -0
  537. package/components/03-organisms/navigation/navigation.scss +433 -0
  538. package/components/03-organisms/navigation/navigation.stories.data.js +60 -0
  539. package/components/03-organisms/navigation/navigation.stories.js +58 -0
  540. package/components/03-organisms/navigation/navigation.test.js +122 -0
  541. package/components/03-organisms/navigation/navigation.twig +106 -0
  542. package/components/03-organisms/promo/__snapshots__/promo.test.js.snap +415 -0
  543. package/components/03-organisms/promo/promo.scss +65 -0
  544. package/components/03-organisms/promo/promo.stories.js +70 -0
  545. package/components/03-organisms/promo/promo.test.js +125 -0
  546. package/components/03-organisms/promo/promo.twig +113 -0
  547. package/components/03-organisms/side-navigation/__snapshots__/side-navigation.test.js.snap +393 -0
  548. package/components/03-organisms/side-navigation/side-navigation.scss +215 -0
  549. package/components/03-organisms/side-navigation/side-navigation.stories.data.js +54 -0
  550. package/components/03-organisms/side-navigation/side-navigation.stories.js +39 -0
  551. package/components/03-organisms/side-navigation/side-navigation.test.js +87 -0
  552. package/components/03-organisms/side-navigation/side-navigation.twig +54 -0
  553. package/components/03-organisms/skip-link/__snapshots__/skip-link.test.js.snap +94 -0
  554. package/components/03-organisms/skip-link/skip-link.scss +28 -0
  555. package/components/03-organisms/skip-link/skip-link.stories.js +42 -0
  556. package/components/03-organisms/skip-link/skip-link.test.js +48 -0
  557. package/components/03-organisms/skip-link/skip-link.twig +31 -0
  558. package/components/03-organisms/slider/__snapshots__/slide.test.js.snap +265 -0
  559. package/components/03-organisms/slider/__snapshots__/slider.test.js.snap +638 -0
  560. package/components/03-organisms/slider/slide.test.js +55 -0
  561. package/components/03-organisms/slider/slide.twig +168 -0
  562. package/components/03-organisms/slider/slider.js +159 -0
  563. package/components/03-organisms/slider/slider.scss +158 -0
  564. package/components/03-organisms/slider/slider.stories.js +90 -0
  565. package/components/03-organisms/slider/slider.test.js +84 -0
  566. package/components/03-organisms/slider/slider.twig +116 -0
  567. package/components/03-organisms/webform/__snapshots__/webform.test.js.snap +145 -0
  568. package/components/03-organisms/webform/webform.js +36 -0
  569. package/components/03-organisms/webform/webform.scss +17 -0
  570. package/components/03-organisms/webform/webform.stories.js +45 -0
  571. package/components/03-organisms/webform/webform.test.js +63 -0
  572. package/components/03-organisms/webform/webform.twig +33 -0
  573. package/components/04-templates/event/.gitkeep +0 -0
  574. package/components/04-templates/page/__snapshots__/page.test.js.snap +1503 -0
  575. package/components/04-templates/page/page.scss +11 -0
  576. package/components/04-templates/page/page.stories.data.js +166 -0
  577. package/components/04-templates/page/page.stories.js +163 -0
  578. package/components/04-templates/page/page.test.js +170 -0
  579. package/components/04-templates/page/page.twig +138 -0
  580. package/components/style.css_variables.scss +129 -0
  581. package/components/style.scss +13 -0
  582. package/components/style.stories.scss +15 -0
  583. package/components/variables.base.scss +33 -0
  584. package/components/variables.components.scss +6 -0
  585. package/dist/assets/backgrounds/civictheme_background_1.png +0 -0
  586. package/dist/assets/backgrounds/civictheme_background_2.png +0 -0
  587. package/dist/assets/backgrounds/civictheme_background_3.png +0 -0
  588. package/dist/assets/backgrounds/civictheme_background_4.png +0 -0
  589. package/dist/assets/backgrounds/civictheme_background_5.png +0 -0
  590. package/dist/assets/backgrounds/civictheme_background_6.png +0 -0
  591. package/dist/assets/backgrounds/civictheme_background_7.png +0 -0
  592. package/dist/assets/icons/account.svg +3 -0
  593. package/dist/assets/icons/approve.svg +3 -0
  594. package/dist/assets/icons/bars.svg +3 -0
  595. package/dist/assets/icons/bullet.svg +3 -0
  596. package/dist/assets/icons/calendar-1.svg +3 -0
  597. package/dist/assets/icons/calendar-2.svg +3 -0
  598. package/dist/assets/icons/call.svg +3 -0
  599. package/dist/assets/icons/cancel.svg +3 -0
  600. package/dist/assets/icons/checked.svg +4 -0
  601. package/dist/assets/icons/close-outline.svg +3 -0
  602. package/dist/assets/icons/close.svg +3 -0
  603. package/dist/assets/icons/document.svg +4 -0
  604. package/dist/assets/icons/down-arrow-1.svg +3 -0
  605. package/dist/assets/icons/down-arrow-2.svg +3 -0
  606. package/dist/assets/icons/download-file.svg +3 -0
  607. package/dist/assets/icons/download.svg +3 -0
  608. package/dist/assets/icons/exclamation-mark-1.svg +3 -0
  609. package/dist/assets/icons/exclamation-mark-2.svg +3 -0
  610. package/dist/assets/icons/exclamation-mark-3.svg +3 -0
  611. package/dist/assets/icons/eye.svg +3 -0
  612. package/dist/assets/icons/facebook.svg +3 -0
  613. package/dist/assets/icons/help.svg +3 -0
  614. package/dist/assets/icons/image.svg +5 -0
  615. package/dist/assets/icons/information-mark.svg +3 -0
  616. package/dist/assets/icons/instagram.svg +3 -0
  617. package/dist/assets/icons/layer.svg +4 -0
  618. package/dist/assets/icons/layers.svg +4 -0
  619. package/dist/assets/icons/left-arrow-outline.svg +3 -0
  620. package/dist/assets/icons/left-arrow.svg +3 -0
  621. package/dist/assets/icons/linkedin.svg +3 -0
  622. package/dist/assets/icons/lock-file.svg +4 -0
  623. package/dist/assets/icons/lock-gallery.svg +4 -0
  624. package/dist/assets/icons/magnifier.svg +3 -0
  625. package/dist/assets/icons/map.svg +3 -0
  626. package/dist/assets/icons/megaphone.svg +3 -0
  627. package/dist/assets/icons/message.svg +3 -0
  628. package/dist/assets/icons/mobile.svg +4 -0
  629. package/dist/assets/icons/mortarboard.svg +3 -0
  630. package/dist/assets/icons/newspaper.svg +3 -0
  631. package/dist/assets/icons/open-source.svg +3 -0
  632. package/dist/assets/icons/pdf-file.svg +4 -0
  633. package/dist/assets/icons/progress.svg +3 -0
  634. package/dist/assets/icons/right-arrow-1.svg +3 -0
  635. package/dist/assets/icons/right-arrow-2.svg +3 -0
  636. package/dist/assets/icons/select-box.svg +4 -0
  637. package/dist/assets/icons/share.svg +3 -0
  638. package/dist/assets/icons/square.svg +3 -0
  639. package/dist/assets/icons/to-do.svg +3 -0
  640. package/dist/assets/icons/twitter.svg +3 -0
  641. package/dist/assets/icons/up-arrow.svg +3 -0
  642. package/dist/assets/icons/upper-arrow.svg +3 -0
  643. package/dist/assets/icons/upper-right-arrow.svg +3 -0
  644. package/dist/assets/icons/users.svg +4 -0
  645. package/dist/assets/icons/watch.svg +3 -0
  646. package/dist/assets/icons/water-drop.svg +4 -0
  647. package/dist/assets/icons/web.svg +4 -0
  648. package/dist/assets/icons/word-file.svg +4 -0
  649. package/dist/assets/icons/x.svg +3 -0
  650. package/dist/assets/icons/youtube.svg +3 -0
  651. package/dist/assets/logos/logo_custom_light_desktop_civictheme.svg +32 -0
  652. package/dist/assets/logos/logo_custom_light_mobile_civictheme.svg +32 -0
  653. package/dist/assets/logos/logo_primary_dark_desktop.png +0 -0
  654. package/dist/assets/logos/logo_primary_dark_mobile.png +0 -0
  655. package/dist/assets/logos/logo_primary_light_desktop.png +0 -0
  656. package/dist/assets/logos/logo_primary_light_mobile.png +0 -0
  657. package/dist/assets/logos/logo_secondary_dark_desktop.png +0 -0
  658. package/dist/assets/logos/logo_secondary_dark_mobile.png +0 -0
  659. package/dist/assets/logos/logo_secondary_light_desktop.png +0 -0
  660. package/dist/assets/logos/logo_secondary_light_mobile.png +0 -0
  661. package/dist/civictheme.css +12303 -0
  662. package/dist/civictheme.stories.css +2807 -0
  663. package/dist/civictheme.storybook.css +12303 -0
  664. package/dist/civictheme.storybook.js +4122 -0
  665. package/dist/civictheme.variables.css +1148 -0
  666. package/dist/constants.json +1562 -0
  667. package/package.json +80 -0
@@ -0,0 +1,4122 @@
1
+ // phpcs:ignoreFile
2
+ /**
3
+ * @popperjs/core v2.11.8 - MIT License
4
+ */
5
+
6
+ (function (global, factory) {
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
8
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Popper = {}));
10
+ }(this, (function (exports) { 'use strict';
11
+
12
+ function getWindow(node) {
13
+ if (node == null) {
14
+ return window;
15
+ }
16
+
17
+ if (node.toString() !== '[object Window]') {
18
+ var ownerDocument = node.ownerDocument;
19
+ return ownerDocument ? ownerDocument.defaultView || window : window;
20
+ }
21
+
22
+ return node;
23
+ }
24
+
25
+ function isElement(node) {
26
+ var OwnElement = getWindow(node).Element;
27
+ return node instanceof OwnElement || node instanceof Element;
28
+ }
29
+
30
+ function isHTMLElement(node) {
31
+ var OwnElement = getWindow(node).HTMLElement;
32
+ return node instanceof OwnElement || node instanceof HTMLElement;
33
+ }
34
+
35
+ function isShadowRoot(node) {
36
+ // IE 11 has no ShadowRoot
37
+ if (typeof ShadowRoot === 'undefined') {
38
+ return false;
39
+ }
40
+
41
+ var OwnElement = getWindow(node).ShadowRoot;
42
+ return node instanceof OwnElement || node instanceof ShadowRoot;
43
+ }
44
+
45
+ var max = Math.max;
46
+ var min = Math.min;
47
+ var round = Math.round;
48
+
49
+ function getUAString() {
50
+ var uaData = navigator.userAgentData;
51
+
52
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
53
+ return uaData.brands.map(function (item) {
54
+ return item.brand + "/" + item.version;
55
+ }).join(' ');
56
+ }
57
+
58
+ return navigator.userAgent;
59
+ }
60
+
61
+ function isLayoutViewport() {
62
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
63
+ }
64
+
65
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
66
+ if (includeScale === void 0) {
67
+ includeScale = false;
68
+ }
69
+
70
+ if (isFixedStrategy === void 0) {
71
+ isFixedStrategy = false;
72
+ }
73
+
74
+ var clientRect = element.getBoundingClientRect();
75
+ var scaleX = 1;
76
+ var scaleY = 1;
77
+
78
+ if (includeScale && isHTMLElement(element)) {
79
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
80
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
81
+ }
82
+
83
+ var _ref = isElement(element) ? getWindow(element) : window,
84
+ visualViewport = _ref.visualViewport;
85
+
86
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
87
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
88
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
89
+ var width = clientRect.width / scaleX;
90
+ var height = clientRect.height / scaleY;
91
+ return {
92
+ width: width,
93
+ height: height,
94
+ top: y,
95
+ right: x + width,
96
+ bottom: y + height,
97
+ left: x,
98
+ x: x,
99
+ y: y
100
+ };
101
+ }
102
+
103
+ function getWindowScroll(node) {
104
+ var win = getWindow(node);
105
+ var scrollLeft = win.pageXOffset;
106
+ var scrollTop = win.pageYOffset;
107
+ return {
108
+ scrollLeft: scrollLeft,
109
+ scrollTop: scrollTop
110
+ };
111
+ }
112
+
113
+ function getHTMLElementScroll(element) {
114
+ return {
115
+ scrollLeft: element.scrollLeft,
116
+ scrollTop: element.scrollTop
117
+ };
118
+ }
119
+
120
+ function getNodeScroll(node) {
121
+ if (node === getWindow(node) || !isHTMLElement(node)) {
122
+ return getWindowScroll(node);
123
+ } else {
124
+ return getHTMLElementScroll(node);
125
+ }
126
+ }
127
+
128
+ function getNodeName(element) {
129
+ return element ? (element.nodeName || '').toLowerCase() : null;
130
+ }
131
+
132
+ function getDocumentElement(element) {
133
+ // $FlowFixMe[incompatible-return]: assume body is always available
134
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
135
+ element.document) || window.document).documentElement;
136
+ }
137
+
138
+ function getWindowScrollBarX(element) {
139
+ // If <html> has a CSS width greater than the viewport, then this will be
140
+ // incorrect for RTL.
141
+ // Popper 1 is broken in this case and never had a bug report so let's assume
142
+ // it's not an issue. I don't think anyone ever specifies width on <html>
143
+ // anyway.
144
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
145
+ // this (e.g. Edge 2019, IE11, Safari)
146
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
147
+ }
148
+
149
+ function getComputedStyle(element) {
150
+ return getWindow(element).getComputedStyle(element);
151
+ }
152
+
153
+ function isScrollParent(element) {
154
+ // Firefox wants us to check `-x` and `-y` variations as well
155
+ var _getComputedStyle = getComputedStyle(element),
156
+ overflow = _getComputedStyle.overflow,
157
+ overflowX = _getComputedStyle.overflowX,
158
+ overflowY = _getComputedStyle.overflowY;
159
+
160
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
161
+ }
162
+
163
+ function isElementScaled(element) {
164
+ var rect = element.getBoundingClientRect();
165
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
166
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
167
+ return scaleX !== 1 || scaleY !== 1;
168
+ } // Returns the composite rect of an element relative to its offsetParent.
169
+ // Composite means it takes into account transforms as well as layout.
170
+
171
+
172
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
173
+ if (isFixed === void 0) {
174
+ isFixed = false;
175
+ }
176
+
177
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
178
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
179
+ var documentElement = getDocumentElement(offsetParent);
180
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
181
+ var scroll = {
182
+ scrollLeft: 0,
183
+ scrollTop: 0
184
+ };
185
+ var offsets = {
186
+ x: 0,
187
+ y: 0
188
+ };
189
+
190
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
191
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
192
+ isScrollParent(documentElement)) {
193
+ scroll = getNodeScroll(offsetParent);
194
+ }
195
+
196
+ if (isHTMLElement(offsetParent)) {
197
+ offsets = getBoundingClientRect(offsetParent, true);
198
+ offsets.x += offsetParent.clientLeft;
199
+ offsets.y += offsetParent.clientTop;
200
+ } else if (documentElement) {
201
+ offsets.x = getWindowScrollBarX(documentElement);
202
+ }
203
+ }
204
+
205
+ return {
206
+ x: rect.left + scroll.scrollLeft - offsets.x,
207
+ y: rect.top + scroll.scrollTop - offsets.y,
208
+ width: rect.width,
209
+ height: rect.height
210
+ };
211
+ }
212
+
213
+ // means it doesn't take into account transforms.
214
+
215
+ function getLayoutRect(element) {
216
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
217
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
218
+
219
+ var width = element.offsetWidth;
220
+ var height = element.offsetHeight;
221
+
222
+ if (Math.abs(clientRect.width - width) <= 1) {
223
+ width = clientRect.width;
224
+ }
225
+
226
+ if (Math.abs(clientRect.height - height) <= 1) {
227
+ height = clientRect.height;
228
+ }
229
+
230
+ return {
231
+ x: element.offsetLeft,
232
+ y: element.offsetTop,
233
+ width: width,
234
+ height: height
235
+ };
236
+ }
237
+
238
+ function getParentNode(element) {
239
+ if (getNodeName(element) === 'html') {
240
+ return element;
241
+ }
242
+
243
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
244
+ // $FlowFixMe[incompatible-return]
245
+ // $FlowFixMe[prop-missing]
246
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
247
+ element.parentNode || ( // DOM Element detected
248
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
249
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
250
+ getDocumentElement(element) // fallback
251
+
252
+ );
253
+ }
254
+
255
+ function getScrollParent(node) {
256
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
257
+ // $FlowFixMe[incompatible-return]: assume body is always available
258
+ return node.ownerDocument.body;
259
+ }
260
+
261
+ if (isHTMLElement(node) && isScrollParent(node)) {
262
+ return node;
263
+ }
264
+
265
+ return getScrollParent(getParentNode(node));
266
+ }
267
+
268
+ /*
269
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
270
+ until we get to the top window object. This list is what we attach scroll listeners
271
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
272
+ reference element's position.
273
+ */
274
+
275
+ function listScrollParents(element, list) {
276
+ var _element$ownerDocumen;
277
+
278
+ if (list === void 0) {
279
+ list = [];
280
+ }
281
+
282
+ var scrollParent = getScrollParent(element);
283
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
284
+ var win = getWindow(scrollParent);
285
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
286
+ var updatedList = list.concat(target);
287
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
288
+ updatedList.concat(listScrollParents(getParentNode(target)));
289
+ }
290
+
291
+ function isTableElement(element) {
292
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
293
+ }
294
+
295
+ function getTrueOffsetParent(element) {
296
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
297
+ getComputedStyle(element).position === 'fixed') {
298
+ return null;
299
+ }
300
+
301
+ return element.offsetParent;
302
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
303
+ // return the containing block
304
+
305
+
306
+ function getContainingBlock(element) {
307
+ var isFirefox = /firefox/i.test(getUAString());
308
+ var isIE = /Trident/i.test(getUAString());
309
+
310
+ if (isIE && isHTMLElement(element)) {
311
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
312
+ var elementCss = getComputedStyle(element);
313
+
314
+ if (elementCss.position === 'fixed') {
315
+ return null;
316
+ }
317
+ }
318
+
319
+ var currentNode = getParentNode(element);
320
+
321
+ if (isShadowRoot(currentNode)) {
322
+ currentNode = currentNode.host;
323
+ }
324
+
325
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
326
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
327
+ // create a containing block.
328
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
329
+
330
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
331
+ return currentNode;
332
+ } else {
333
+ currentNode = currentNode.parentNode;
334
+ }
335
+ }
336
+
337
+ return null;
338
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
339
+ // such as table ancestors and cross browser bugs.
340
+
341
+
342
+ function getOffsetParent(element) {
343
+ var window = getWindow(element);
344
+ var offsetParent = getTrueOffsetParent(element);
345
+
346
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
347
+ offsetParent = getTrueOffsetParent(offsetParent);
348
+ }
349
+
350
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
351
+ return window;
352
+ }
353
+
354
+ return offsetParent || getContainingBlock(element) || window;
355
+ }
356
+
357
+ var top = 'top';
358
+ var bottom = 'bottom';
359
+ var right = 'right';
360
+ var left = 'left';
361
+ var auto = 'auto';
362
+ var basePlacements = [top, bottom, right, left];
363
+ var start = 'start';
364
+ var end = 'end';
365
+ var clippingParents = 'clippingParents';
366
+ var viewport = 'viewport';
367
+ var popper = 'popper';
368
+ var reference = 'reference';
369
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
370
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
371
+ }, []);
372
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
373
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
374
+ }, []); // modifiers that need to read the DOM
375
+
376
+ var beforeRead = 'beforeRead';
377
+ var read = 'read';
378
+ var afterRead = 'afterRead'; // pure-logic modifiers
379
+
380
+ var beforeMain = 'beforeMain';
381
+ var main = 'main';
382
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
383
+
384
+ var beforeWrite = 'beforeWrite';
385
+ var write = 'write';
386
+ var afterWrite = 'afterWrite';
387
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
388
+
389
+ function order(modifiers) {
390
+ var map = new Map();
391
+ var visited = new Set();
392
+ var result = [];
393
+ modifiers.forEach(function (modifier) {
394
+ map.set(modifier.name, modifier);
395
+ }); // On visiting object, check for its dependencies and visit them recursively
396
+
397
+ function sort(modifier) {
398
+ visited.add(modifier.name);
399
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
400
+ requires.forEach(function (dep) {
401
+ if (!visited.has(dep)) {
402
+ var depModifier = map.get(dep);
403
+
404
+ if (depModifier) {
405
+ sort(depModifier);
406
+ }
407
+ }
408
+ });
409
+ result.push(modifier);
410
+ }
411
+
412
+ modifiers.forEach(function (modifier) {
413
+ if (!visited.has(modifier.name)) {
414
+ // check for visited object
415
+ sort(modifier);
416
+ }
417
+ });
418
+ return result;
419
+ }
420
+
421
+ function orderModifiers(modifiers) {
422
+ // order based on dependencies
423
+ var orderedModifiers = order(modifiers); // order based on phase
424
+
425
+ return modifierPhases.reduce(function (acc, phase) {
426
+ return acc.concat(orderedModifiers.filter(function (modifier) {
427
+ return modifier.phase === phase;
428
+ }));
429
+ }, []);
430
+ }
431
+
432
+ function debounce(fn) {
433
+ var pending;
434
+ return function () {
435
+ if (!pending) {
436
+ pending = new Promise(function (resolve) {
437
+ Promise.resolve().then(function () {
438
+ pending = undefined;
439
+ resolve(fn());
440
+ });
441
+ });
442
+ }
443
+
444
+ return pending;
445
+ };
446
+ }
447
+
448
+ function mergeByName(modifiers) {
449
+ var merged = modifiers.reduce(function (merged, current) {
450
+ var existing = merged[current.name];
451
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
452
+ options: Object.assign({}, existing.options, current.options),
453
+ data: Object.assign({}, existing.data, current.data)
454
+ }) : current;
455
+ return merged;
456
+ }, {}); // IE11 does not support Object.values
457
+
458
+ return Object.keys(merged).map(function (key) {
459
+ return merged[key];
460
+ });
461
+ }
462
+
463
+ function getViewportRect(element, strategy) {
464
+ var win = getWindow(element);
465
+ var html = getDocumentElement(element);
466
+ var visualViewport = win.visualViewport;
467
+ var width = html.clientWidth;
468
+ var height = html.clientHeight;
469
+ var x = 0;
470
+ var y = 0;
471
+
472
+ if (visualViewport) {
473
+ width = visualViewport.width;
474
+ height = visualViewport.height;
475
+ var layoutViewport = isLayoutViewport();
476
+
477
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
478
+ x = visualViewport.offsetLeft;
479
+ y = visualViewport.offsetTop;
480
+ }
481
+ }
482
+
483
+ return {
484
+ width: width,
485
+ height: height,
486
+ x: x + getWindowScrollBarX(element),
487
+ y: y
488
+ };
489
+ }
490
+
491
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
492
+
493
+ function getDocumentRect(element) {
494
+ var _element$ownerDocumen;
495
+
496
+ var html = getDocumentElement(element);
497
+ var winScroll = getWindowScroll(element);
498
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
499
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
500
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
501
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
502
+ var y = -winScroll.scrollTop;
503
+
504
+ if (getComputedStyle(body || html).direction === 'rtl') {
505
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
506
+ }
507
+
508
+ return {
509
+ width: width,
510
+ height: height,
511
+ x: x,
512
+ y: y
513
+ };
514
+ }
515
+
516
+ function contains(parent, child) {
517
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
518
+
519
+ if (parent.contains(child)) {
520
+ return true;
521
+ } // then fallback to custom implementation with Shadow DOM support
522
+ else if (rootNode && isShadowRoot(rootNode)) {
523
+ var next = child;
524
+
525
+ do {
526
+ if (next && parent.isSameNode(next)) {
527
+ return true;
528
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
529
+
530
+
531
+ next = next.parentNode || next.host;
532
+ } while (next);
533
+ } // Give up, the result is false
534
+
535
+
536
+ return false;
537
+ }
538
+
539
+ function rectToClientRect(rect) {
540
+ return Object.assign({}, rect, {
541
+ left: rect.x,
542
+ top: rect.y,
543
+ right: rect.x + rect.width,
544
+ bottom: rect.y + rect.height
545
+ });
546
+ }
547
+
548
+ function getInnerBoundingClientRect(element, strategy) {
549
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
550
+ rect.top = rect.top + element.clientTop;
551
+ rect.left = rect.left + element.clientLeft;
552
+ rect.bottom = rect.top + element.clientHeight;
553
+ rect.right = rect.left + element.clientWidth;
554
+ rect.width = element.clientWidth;
555
+ rect.height = element.clientHeight;
556
+ rect.x = rect.left;
557
+ rect.y = rect.top;
558
+ return rect;
559
+ }
560
+
561
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
562
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
563
+ } // A "clipping parent" is an overflowable container with the characteristic of
564
+ // clipping (or hiding) overflowing elements with a position different from
565
+ // `initial`
566
+
567
+
568
+ function getClippingParents(element) {
569
+ var clippingParents = listScrollParents(getParentNode(element));
570
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
571
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
572
+
573
+ if (!isElement(clipperElement)) {
574
+ return [];
575
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
576
+
577
+
578
+ return clippingParents.filter(function (clippingParent) {
579
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
580
+ });
581
+ } // Gets the maximum area that the element is visible in due to any number of
582
+ // clipping parents
583
+
584
+
585
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
586
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
587
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
588
+ var firstClippingParent = clippingParents[0];
589
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
590
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
591
+ accRect.top = max(rect.top, accRect.top);
592
+ accRect.right = min(rect.right, accRect.right);
593
+ accRect.bottom = min(rect.bottom, accRect.bottom);
594
+ accRect.left = max(rect.left, accRect.left);
595
+ return accRect;
596
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
597
+ clippingRect.width = clippingRect.right - clippingRect.left;
598
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
599
+ clippingRect.x = clippingRect.left;
600
+ clippingRect.y = clippingRect.top;
601
+ return clippingRect;
602
+ }
603
+
604
+ function getBasePlacement(placement) {
605
+ return placement.split('-')[0];
606
+ }
607
+
608
+ function getVariation(placement) {
609
+ return placement.split('-')[1];
610
+ }
611
+
612
+ function getMainAxisFromPlacement(placement) {
613
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
614
+ }
615
+
616
+ function computeOffsets(_ref) {
617
+ var reference = _ref.reference,
618
+ element = _ref.element,
619
+ placement = _ref.placement;
620
+ var basePlacement = placement ? getBasePlacement(placement) : null;
621
+ var variation = placement ? getVariation(placement) : null;
622
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
623
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
624
+ var offsets;
625
+
626
+ switch (basePlacement) {
627
+ case top:
628
+ offsets = {
629
+ x: commonX,
630
+ y: reference.y - element.height
631
+ };
632
+ break;
633
+
634
+ case bottom:
635
+ offsets = {
636
+ x: commonX,
637
+ y: reference.y + reference.height
638
+ };
639
+ break;
640
+
641
+ case right:
642
+ offsets = {
643
+ x: reference.x + reference.width,
644
+ y: commonY
645
+ };
646
+ break;
647
+
648
+ case left:
649
+ offsets = {
650
+ x: reference.x - element.width,
651
+ y: commonY
652
+ };
653
+ break;
654
+
655
+ default:
656
+ offsets = {
657
+ x: reference.x,
658
+ y: reference.y
659
+ };
660
+ }
661
+
662
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
663
+
664
+ if (mainAxis != null) {
665
+ var len = mainAxis === 'y' ? 'height' : 'width';
666
+
667
+ switch (variation) {
668
+ case start:
669
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
670
+ break;
671
+
672
+ case end:
673
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
674
+ break;
675
+ }
676
+ }
677
+
678
+ return offsets;
679
+ }
680
+
681
+ function getFreshSideObject() {
682
+ return {
683
+ top: 0,
684
+ right: 0,
685
+ bottom: 0,
686
+ left: 0
687
+ };
688
+ }
689
+
690
+ function mergePaddingObject(paddingObject) {
691
+ return Object.assign({}, getFreshSideObject(), paddingObject);
692
+ }
693
+
694
+ function expandToHashMap(value, keys) {
695
+ return keys.reduce(function (hashMap, key) {
696
+ hashMap[key] = value;
697
+ return hashMap;
698
+ }, {});
699
+ }
700
+
701
+ function detectOverflow(state, options) {
702
+ if (options === void 0) {
703
+ options = {};
704
+ }
705
+
706
+ var _options = options,
707
+ _options$placement = _options.placement,
708
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
709
+ _options$strategy = _options.strategy,
710
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
711
+ _options$boundary = _options.boundary,
712
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
713
+ _options$rootBoundary = _options.rootBoundary,
714
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
715
+ _options$elementConte = _options.elementContext,
716
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
717
+ _options$altBoundary = _options.altBoundary,
718
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
719
+ _options$padding = _options.padding,
720
+ padding = _options$padding === void 0 ? 0 : _options$padding;
721
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
722
+ var altContext = elementContext === popper ? reference : popper;
723
+ var popperRect = state.rects.popper;
724
+ var element = state.elements[altBoundary ? altContext : elementContext];
725
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
726
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
727
+ var popperOffsets = computeOffsets({
728
+ reference: referenceClientRect,
729
+ element: popperRect,
730
+ strategy: 'absolute',
731
+ placement: placement
732
+ });
733
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
734
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
735
+ // 0 or negative = within the clipping rect
736
+
737
+ var overflowOffsets = {
738
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
739
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
740
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
741
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
742
+ };
743
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
744
+
745
+ if (elementContext === popper && offsetData) {
746
+ var offset = offsetData[placement];
747
+ Object.keys(overflowOffsets).forEach(function (key) {
748
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
749
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
750
+ overflowOffsets[key] += offset[axis] * multiply;
751
+ });
752
+ }
753
+
754
+ return overflowOffsets;
755
+ }
756
+
757
+ var DEFAULT_OPTIONS = {
758
+ placement: 'bottom',
759
+ modifiers: [],
760
+ strategy: 'absolute'
761
+ };
762
+
763
+ function areValidElements() {
764
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
765
+ args[_key] = arguments[_key];
766
+ }
767
+
768
+ return !args.some(function (element) {
769
+ return !(element && typeof element.getBoundingClientRect === 'function');
770
+ });
771
+ }
772
+
773
+ function popperGenerator(generatorOptions) {
774
+ if (generatorOptions === void 0) {
775
+ generatorOptions = {};
776
+ }
777
+
778
+ var _generatorOptions = generatorOptions,
779
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
780
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
781
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
782
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
783
+ return function createPopper(reference, popper, options) {
784
+ if (options === void 0) {
785
+ options = defaultOptions;
786
+ }
787
+
788
+ var state = {
789
+ placement: 'bottom',
790
+ orderedModifiers: [],
791
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
792
+ modifiersData: {},
793
+ elements: {
794
+ reference: reference,
795
+ popper: popper
796
+ },
797
+ attributes: {},
798
+ styles: {}
799
+ };
800
+ var effectCleanupFns = [];
801
+ var isDestroyed = false;
802
+ var instance = {
803
+ state: state,
804
+ setOptions: function setOptions(setOptionsAction) {
805
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
806
+ cleanupModifierEffects();
807
+ state.options = Object.assign({}, defaultOptions, state.options, options);
808
+ state.scrollParents = {
809
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
810
+ popper: listScrollParents(popper)
811
+ }; // Orders the modifiers based on their dependencies and `phase`
812
+ // properties
813
+
814
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
815
+
816
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
817
+ return m.enabled;
818
+ });
819
+ runModifierEffects();
820
+ return instance.update();
821
+ },
822
+ // Sync update – it will always be executed, even if not necessary. This
823
+ // is useful for low frequency updates where sync behavior simplifies the
824
+ // logic.
825
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
826
+ // prefer the async Popper#update method
827
+ forceUpdate: function forceUpdate() {
828
+ if (isDestroyed) {
829
+ return;
830
+ }
831
+
832
+ var _state$elements = state.elements,
833
+ reference = _state$elements.reference,
834
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
835
+ // anymore
836
+
837
+ if (!areValidElements(reference, popper)) {
838
+ return;
839
+ } // Store the reference and popper rects to be read by modifiers
840
+
841
+
842
+ state.rects = {
843
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
844
+ popper: getLayoutRect(popper)
845
+ }; // Modifiers have the ability to reset the current update cycle. The
846
+ // most common use case for this is the `flip` modifier changing the
847
+ // placement, which then needs to re-run all the modifiers, because the
848
+ // logic was previously ran for the previous placement and is therefore
849
+ // stale/incorrect
850
+
851
+ state.reset = false;
852
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
853
+ // is filled with the initial data specified by the modifier. This means
854
+ // it doesn't persist and is fresh on each update.
855
+ // To ensure persistent data, use `${name}#persistent`
856
+
857
+ state.orderedModifiers.forEach(function (modifier) {
858
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
859
+ });
860
+
861
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
862
+ if (state.reset === true) {
863
+ state.reset = false;
864
+ index = -1;
865
+ continue;
866
+ }
867
+
868
+ var _state$orderedModifie = state.orderedModifiers[index],
869
+ fn = _state$orderedModifie.fn,
870
+ _state$orderedModifie2 = _state$orderedModifie.options,
871
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
872
+ name = _state$orderedModifie.name;
873
+
874
+ if (typeof fn === 'function') {
875
+ state = fn({
876
+ state: state,
877
+ options: _options,
878
+ name: name,
879
+ instance: instance
880
+ }) || state;
881
+ }
882
+ }
883
+ },
884
+ // Async and optimistically optimized update – it will not be executed if
885
+ // not necessary (debounced to run at most once-per-tick)
886
+ update: debounce(function () {
887
+ return new Promise(function (resolve) {
888
+ instance.forceUpdate();
889
+ resolve(state);
890
+ });
891
+ }),
892
+ destroy: function destroy() {
893
+ cleanupModifierEffects();
894
+ isDestroyed = true;
895
+ }
896
+ };
897
+
898
+ if (!areValidElements(reference, popper)) {
899
+ return instance;
900
+ }
901
+
902
+ instance.setOptions(options).then(function (state) {
903
+ if (!isDestroyed && options.onFirstUpdate) {
904
+ options.onFirstUpdate(state);
905
+ }
906
+ }); // Modifiers have the ability to execute arbitrary code before the first
907
+ // update cycle runs. They will be executed in the same order as the update
908
+ // cycle. This is useful when a modifier adds some persistent data that
909
+ // other modifiers need to use, but the modifier is run after the dependent
910
+ // one.
911
+
912
+ function runModifierEffects() {
913
+ state.orderedModifiers.forEach(function (_ref) {
914
+ var name = _ref.name,
915
+ _ref$options = _ref.options,
916
+ options = _ref$options === void 0 ? {} : _ref$options,
917
+ effect = _ref.effect;
918
+
919
+ if (typeof effect === 'function') {
920
+ var cleanupFn = effect({
921
+ state: state,
922
+ name: name,
923
+ instance: instance,
924
+ options: options
925
+ });
926
+
927
+ var noopFn = function noopFn() {};
928
+
929
+ effectCleanupFns.push(cleanupFn || noopFn);
930
+ }
931
+ });
932
+ }
933
+
934
+ function cleanupModifierEffects() {
935
+ effectCleanupFns.forEach(function (fn) {
936
+ return fn();
937
+ });
938
+ effectCleanupFns = [];
939
+ }
940
+
941
+ return instance;
942
+ };
943
+ }
944
+
945
+ var passive = {
946
+ passive: true
947
+ };
948
+
949
+ function effect$2(_ref) {
950
+ var state = _ref.state,
951
+ instance = _ref.instance,
952
+ options = _ref.options;
953
+ var _options$scroll = options.scroll,
954
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
955
+ _options$resize = options.resize,
956
+ resize = _options$resize === void 0 ? true : _options$resize;
957
+ var window = getWindow(state.elements.popper);
958
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
959
+
960
+ if (scroll) {
961
+ scrollParents.forEach(function (scrollParent) {
962
+ scrollParent.addEventListener('scroll', instance.update, passive);
963
+ });
964
+ }
965
+
966
+ if (resize) {
967
+ window.addEventListener('resize', instance.update, passive);
968
+ }
969
+
970
+ return function () {
971
+ if (scroll) {
972
+ scrollParents.forEach(function (scrollParent) {
973
+ scrollParent.removeEventListener('scroll', instance.update, passive);
974
+ });
975
+ }
976
+
977
+ if (resize) {
978
+ window.removeEventListener('resize', instance.update, passive);
979
+ }
980
+ };
981
+ } // eslint-disable-next-line import/no-unused-modules
982
+
983
+
984
+ var eventListeners = {
985
+ name: 'eventListeners',
986
+ enabled: true,
987
+ phase: 'write',
988
+ fn: function fn() {},
989
+ effect: effect$2,
990
+ data: {}
991
+ };
992
+
993
+ function popperOffsets(_ref) {
994
+ var state = _ref.state,
995
+ name = _ref.name;
996
+ // Offsets are the actual position the popper needs to have to be
997
+ // properly positioned near its reference element
998
+ // This is the most basic placement, and will be adjusted by
999
+ // the modifiers in the next step
1000
+ state.modifiersData[name] = computeOffsets({
1001
+ reference: state.rects.reference,
1002
+ element: state.rects.popper,
1003
+ strategy: 'absolute',
1004
+ placement: state.placement
1005
+ });
1006
+ } // eslint-disable-next-line import/no-unused-modules
1007
+
1008
+
1009
+ var popperOffsets$1 = {
1010
+ name: 'popperOffsets',
1011
+ enabled: true,
1012
+ phase: 'read',
1013
+ fn: popperOffsets,
1014
+ data: {}
1015
+ };
1016
+
1017
+ var unsetSides = {
1018
+ top: 'auto',
1019
+ right: 'auto',
1020
+ bottom: 'auto',
1021
+ left: 'auto'
1022
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1023
+ // Zooming can change the DPR, but it seems to report a value that will
1024
+ // cleanly divide the values into the appropriate subpixels.
1025
+
1026
+ function roundOffsetsByDPR(_ref, win) {
1027
+ var x = _ref.x,
1028
+ y = _ref.y;
1029
+ var dpr = win.devicePixelRatio || 1;
1030
+ return {
1031
+ x: round(x * dpr) / dpr || 0,
1032
+ y: round(y * dpr) / dpr || 0
1033
+ };
1034
+ }
1035
+
1036
+ function mapToStyles(_ref2) {
1037
+ var _Object$assign2;
1038
+
1039
+ var popper = _ref2.popper,
1040
+ popperRect = _ref2.popperRect,
1041
+ placement = _ref2.placement,
1042
+ variation = _ref2.variation,
1043
+ offsets = _ref2.offsets,
1044
+ position = _ref2.position,
1045
+ gpuAcceleration = _ref2.gpuAcceleration,
1046
+ adaptive = _ref2.adaptive,
1047
+ roundOffsets = _ref2.roundOffsets,
1048
+ isFixed = _ref2.isFixed;
1049
+ var _offsets$x = offsets.x,
1050
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1051
+ _offsets$y = offsets.y,
1052
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1053
+
1054
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1055
+ x: x,
1056
+ y: y
1057
+ }) : {
1058
+ x: x,
1059
+ y: y
1060
+ };
1061
+
1062
+ x = _ref3.x;
1063
+ y = _ref3.y;
1064
+ var hasX = offsets.hasOwnProperty('x');
1065
+ var hasY = offsets.hasOwnProperty('y');
1066
+ var sideX = left;
1067
+ var sideY = top;
1068
+ var win = window;
1069
+
1070
+ if (adaptive) {
1071
+ var offsetParent = getOffsetParent(popper);
1072
+ var heightProp = 'clientHeight';
1073
+ var widthProp = 'clientWidth';
1074
+
1075
+ if (offsetParent === getWindow(popper)) {
1076
+ offsetParent = getDocumentElement(popper);
1077
+
1078
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1079
+ heightProp = 'scrollHeight';
1080
+ widthProp = 'scrollWidth';
1081
+ }
1082
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1083
+
1084
+
1085
+ offsetParent = offsetParent;
1086
+
1087
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1088
+ sideY = bottom;
1089
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1090
+ offsetParent[heightProp];
1091
+ y -= offsetY - popperRect.height;
1092
+ y *= gpuAcceleration ? 1 : -1;
1093
+ }
1094
+
1095
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1096
+ sideX = right;
1097
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1098
+ offsetParent[widthProp];
1099
+ x -= offsetX - popperRect.width;
1100
+ x *= gpuAcceleration ? 1 : -1;
1101
+ }
1102
+ }
1103
+
1104
+ var commonStyles = Object.assign({
1105
+ position: position
1106
+ }, adaptive && unsetSides);
1107
+
1108
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1109
+ x: x,
1110
+ y: y
1111
+ }, getWindow(popper)) : {
1112
+ x: x,
1113
+ y: y
1114
+ };
1115
+
1116
+ x = _ref4.x;
1117
+ y = _ref4.y;
1118
+
1119
+ if (gpuAcceleration) {
1120
+ var _Object$assign;
1121
+
1122
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1123
+ }
1124
+
1125
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1126
+ }
1127
+
1128
+ function computeStyles(_ref5) {
1129
+ var state = _ref5.state,
1130
+ options = _ref5.options;
1131
+ var _options$gpuAccelerat = options.gpuAcceleration,
1132
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1133
+ _options$adaptive = options.adaptive,
1134
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1135
+ _options$roundOffsets = options.roundOffsets,
1136
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1137
+ var commonStyles = {
1138
+ placement: getBasePlacement(state.placement),
1139
+ variation: getVariation(state.placement),
1140
+ popper: state.elements.popper,
1141
+ popperRect: state.rects.popper,
1142
+ gpuAcceleration: gpuAcceleration,
1143
+ isFixed: state.options.strategy === 'fixed'
1144
+ };
1145
+
1146
+ if (state.modifiersData.popperOffsets != null) {
1147
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1148
+ offsets: state.modifiersData.popperOffsets,
1149
+ position: state.options.strategy,
1150
+ adaptive: adaptive,
1151
+ roundOffsets: roundOffsets
1152
+ })));
1153
+ }
1154
+
1155
+ if (state.modifiersData.arrow != null) {
1156
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1157
+ offsets: state.modifiersData.arrow,
1158
+ position: 'absolute',
1159
+ adaptive: false,
1160
+ roundOffsets: roundOffsets
1161
+ })));
1162
+ }
1163
+
1164
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1165
+ 'data-popper-placement': state.placement
1166
+ });
1167
+ } // eslint-disable-next-line import/no-unused-modules
1168
+
1169
+
1170
+ var computeStyles$1 = {
1171
+ name: 'computeStyles',
1172
+ enabled: true,
1173
+ phase: 'beforeWrite',
1174
+ fn: computeStyles,
1175
+ data: {}
1176
+ };
1177
+
1178
+ // and applies them to the HTMLElements such as popper and arrow
1179
+
1180
+ function applyStyles(_ref) {
1181
+ var state = _ref.state;
1182
+ Object.keys(state.elements).forEach(function (name) {
1183
+ var style = state.styles[name] || {};
1184
+ var attributes = state.attributes[name] || {};
1185
+ var element = state.elements[name]; // arrow is optional + virtual elements
1186
+
1187
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1188
+ return;
1189
+ } // Flow doesn't support to extend this property, but it's the most
1190
+ // effective way to apply styles to an HTMLElement
1191
+ // $FlowFixMe[cannot-write]
1192
+
1193
+
1194
+ Object.assign(element.style, style);
1195
+ Object.keys(attributes).forEach(function (name) {
1196
+ var value = attributes[name];
1197
+
1198
+ if (value === false) {
1199
+ element.removeAttribute(name);
1200
+ } else {
1201
+ element.setAttribute(name, value === true ? '' : value);
1202
+ }
1203
+ });
1204
+ });
1205
+ }
1206
+
1207
+ function effect$1(_ref2) {
1208
+ var state = _ref2.state;
1209
+ var initialStyles = {
1210
+ popper: {
1211
+ position: state.options.strategy,
1212
+ left: '0',
1213
+ top: '0',
1214
+ margin: '0'
1215
+ },
1216
+ arrow: {
1217
+ position: 'absolute'
1218
+ },
1219
+ reference: {}
1220
+ };
1221
+ Object.assign(state.elements.popper.style, initialStyles.popper);
1222
+ state.styles = initialStyles;
1223
+
1224
+ if (state.elements.arrow) {
1225
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
1226
+ }
1227
+
1228
+ return function () {
1229
+ Object.keys(state.elements).forEach(function (name) {
1230
+ var element = state.elements[name];
1231
+ var attributes = state.attributes[name] || {};
1232
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
1233
+
1234
+ var style = styleProperties.reduce(function (style, property) {
1235
+ style[property] = '';
1236
+ return style;
1237
+ }, {}); // arrow is optional + virtual elements
1238
+
1239
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1240
+ return;
1241
+ }
1242
+
1243
+ Object.assign(element.style, style);
1244
+ Object.keys(attributes).forEach(function (attribute) {
1245
+ element.removeAttribute(attribute);
1246
+ });
1247
+ });
1248
+ };
1249
+ } // eslint-disable-next-line import/no-unused-modules
1250
+
1251
+
1252
+ var applyStyles$1 = {
1253
+ name: 'applyStyles',
1254
+ enabled: true,
1255
+ phase: 'write',
1256
+ fn: applyStyles,
1257
+ effect: effect$1,
1258
+ requires: ['computeStyles']
1259
+ };
1260
+
1261
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1262
+ var basePlacement = getBasePlacement(placement);
1263
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1264
+
1265
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1266
+ placement: placement
1267
+ })) : offset,
1268
+ skidding = _ref[0],
1269
+ distance = _ref[1];
1270
+
1271
+ skidding = skidding || 0;
1272
+ distance = (distance || 0) * invertDistance;
1273
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1274
+ x: distance,
1275
+ y: skidding
1276
+ } : {
1277
+ x: skidding,
1278
+ y: distance
1279
+ };
1280
+ }
1281
+
1282
+ function offset(_ref2) {
1283
+ var state = _ref2.state,
1284
+ options = _ref2.options,
1285
+ name = _ref2.name;
1286
+ var _options$offset = options.offset,
1287
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1288
+ var data = placements.reduce(function (acc, placement) {
1289
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1290
+ return acc;
1291
+ }, {});
1292
+ var _data$state$placement = data[state.placement],
1293
+ x = _data$state$placement.x,
1294
+ y = _data$state$placement.y;
1295
+
1296
+ if (state.modifiersData.popperOffsets != null) {
1297
+ state.modifiersData.popperOffsets.x += x;
1298
+ state.modifiersData.popperOffsets.y += y;
1299
+ }
1300
+
1301
+ state.modifiersData[name] = data;
1302
+ } // eslint-disable-next-line import/no-unused-modules
1303
+
1304
+
1305
+ var offset$1 = {
1306
+ name: 'offset',
1307
+ enabled: true,
1308
+ phase: 'main',
1309
+ requires: ['popperOffsets'],
1310
+ fn: offset
1311
+ };
1312
+
1313
+ var hash$1 = {
1314
+ left: 'right',
1315
+ right: 'left',
1316
+ bottom: 'top',
1317
+ top: 'bottom'
1318
+ };
1319
+ function getOppositePlacement(placement) {
1320
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
1321
+ return hash$1[matched];
1322
+ });
1323
+ }
1324
+
1325
+ var hash = {
1326
+ start: 'end',
1327
+ end: 'start'
1328
+ };
1329
+ function getOppositeVariationPlacement(placement) {
1330
+ return placement.replace(/start|end/g, function (matched) {
1331
+ return hash[matched];
1332
+ });
1333
+ }
1334
+
1335
+ function computeAutoPlacement(state, options) {
1336
+ if (options === void 0) {
1337
+ options = {};
1338
+ }
1339
+
1340
+ var _options = options,
1341
+ placement = _options.placement,
1342
+ boundary = _options.boundary,
1343
+ rootBoundary = _options.rootBoundary,
1344
+ padding = _options.padding,
1345
+ flipVariations = _options.flipVariations,
1346
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1347
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1348
+ var variation = getVariation(placement);
1349
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1350
+ return getVariation(placement) === variation;
1351
+ }) : basePlacements;
1352
+ var allowedPlacements = placements$1.filter(function (placement) {
1353
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1354
+ });
1355
+
1356
+ if (allowedPlacements.length === 0) {
1357
+ allowedPlacements = placements$1;
1358
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1359
+
1360
+
1361
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1362
+ acc[placement] = detectOverflow(state, {
1363
+ placement: placement,
1364
+ boundary: boundary,
1365
+ rootBoundary: rootBoundary,
1366
+ padding: padding
1367
+ })[getBasePlacement(placement)];
1368
+ return acc;
1369
+ }, {});
1370
+ return Object.keys(overflows).sort(function (a, b) {
1371
+ return overflows[a] - overflows[b];
1372
+ });
1373
+ }
1374
+
1375
+ function getExpandedFallbackPlacements(placement) {
1376
+ if (getBasePlacement(placement) === auto) {
1377
+ return [];
1378
+ }
1379
+
1380
+ var oppositePlacement = getOppositePlacement(placement);
1381
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1382
+ }
1383
+
1384
+ function flip(_ref) {
1385
+ var state = _ref.state,
1386
+ options = _ref.options,
1387
+ name = _ref.name;
1388
+
1389
+ if (state.modifiersData[name]._skip) {
1390
+ return;
1391
+ }
1392
+
1393
+ var _options$mainAxis = options.mainAxis,
1394
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1395
+ _options$altAxis = options.altAxis,
1396
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1397
+ specifiedFallbackPlacements = options.fallbackPlacements,
1398
+ padding = options.padding,
1399
+ boundary = options.boundary,
1400
+ rootBoundary = options.rootBoundary,
1401
+ altBoundary = options.altBoundary,
1402
+ _options$flipVariatio = options.flipVariations,
1403
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1404
+ allowedAutoPlacements = options.allowedAutoPlacements;
1405
+ var preferredPlacement = state.options.placement;
1406
+ var basePlacement = getBasePlacement(preferredPlacement);
1407
+ var isBasePlacement = basePlacement === preferredPlacement;
1408
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1409
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1410
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1411
+ placement: placement,
1412
+ boundary: boundary,
1413
+ rootBoundary: rootBoundary,
1414
+ padding: padding,
1415
+ flipVariations: flipVariations,
1416
+ allowedAutoPlacements: allowedAutoPlacements
1417
+ }) : placement);
1418
+ }, []);
1419
+ var referenceRect = state.rects.reference;
1420
+ var popperRect = state.rects.popper;
1421
+ var checksMap = new Map();
1422
+ var makeFallbackChecks = true;
1423
+ var firstFittingPlacement = placements[0];
1424
+
1425
+ for (var i = 0; i < placements.length; i++) {
1426
+ var placement = placements[i];
1427
+
1428
+ var _basePlacement = getBasePlacement(placement);
1429
+
1430
+ var isStartVariation = getVariation(placement) === start;
1431
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1432
+ var len = isVertical ? 'width' : 'height';
1433
+ var overflow = detectOverflow(state, {
1434
+ placement: placement,
1435
+ boundary: boundary,
1436
+ rootBoundary: rootBoundary,
1437
+ altBoundary: altBoundary,
1438
+ padding: padding
1439
+ });
1440
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1441
+
1442
+ if (referenceRect[len] > popperRect[len]) {
1443
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1444
+ }
1445
+
1446
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1447
+ var checks = [];
1448
+
1449
+ if (checkMainAxis) {
1450
+ checks.push(overflow[_basePlacement] <= 0);
1451
+ }
1452
+
1453
+ if (checkAltAxis) {
1454
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1455
+ }
1456
+
1457
+ if (checks.every(function (check) {
1458
+ return check;
1459
+ })) {
1460
+ firstFittingPlacement = placement;
1461
+ makeFallbackChecks = false;
1462
+ break;
1463
+ }
1464
+
1465
+ checksMap.set(placement, checks);
1466
+ }
1467
+
1468
+ if (makeFallbackChecks) {
1469
+ // `2` may be desired in some cases – research later
1470
+ var numberOfChecks = flipVariations ? 3 : 1;
1471
+
1472
+ var _loop = function _loop(_i) {
1473
+ var fittingPlacement = placements.find(function (placement) {
1474
+ var checks = checksMap.get(placement);
1475
+
1476
+ if (checks) {
1477
+ return checks.slice(0, _i).every(function (check) {
1478
+ return check;
1479
+ });
1480
+ }
1481
+ });
1482
+
1483
+ if (fittingPlacement) {
1484
+ firstFittingPlacement = fittingPlacement;
1485
+ return "break";
1486
+ }
1487
+ };
1488
+
1489
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1490
+ var _ret = _loop(_i);
1491
+
1492
+ if (_ret === "break") break;
1493
+ }
1494
+ }
1495
+
1496
+ if (state.placement !== firstFittingPlacement) {
1497
+ state.modifiersData[name]._skip = true;
1498
+ state.placement = firstFittingPlacement;
1499
+ state.reset = true;
1500
+ }
1501
+ } // eslint-disable-next-line import/no-unused-modules
1502
+
1503
+
1504
+ var flip$1 = {
1505
+ name: 'flip',
1506
+ enabled: true,
1507
+ phase: 'main',
1508
+ fn: flip,
1509
+ requiresIfExists: ['offset'],
1510
+ data: {
1511
+ _skip: false
1512
+ }
1513
+ };
1514
+
1515
+ function getAltAxis(axis) {
1516
+ return axis === 'x' ? 'y' : 'x';
1517
+ }
1518
+
1519
+ function within(min$1, value, max$1) {
1520
+ return max(min$1, min(value, max$1));
1521
+ }
1522
+ function withinMaxClamp(min, value, max) {
1523
+ var v = within(min, value, max);
1524
+ return v > max ? max : v;
1525
+ }
1526
+
1527
+ function preventOverflow(_ref) {
1528
+ var state = _ref.state,
1529
+ options = _ref.options,
1530
+ name = _ref.name;
1531
+ var _options$mainAxis = options.mainAxis,
1532
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1533
+ _options$altAxis = options.altAxis,
1534
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1535
+ boundary = options.boundary,
1536
+ rootBoundary = options.rootBoundary,
1537
+ altBoundary = options.altBoundary,
1538
+ padding = options.padding,
1539
+ _options$tether = options.tether,
1540
+ tether = _options$tether === void 0 ? true : _options$tether,
1541
+ _options$tetherOffset = options.tetherOffset,
1542
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1543
+ var overflow = detectOverflow(state, {
1544
+ boundary: boundary,
1545
+ rootBoundary: rootBoundary,
1546
+ padding: padding,
1547
+ altBoundary: altBoundary
1548
+ });
1549
+ var basePlacement = getBasePlacement(state.placement);
1550
+ var variation = getVariation(state.placement);
1551
+ var isBasePlacement = !variation;
1552
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1553
+ var altAxis = getAltAxis(mainAxis);
1554
+ var popperOffsets = state.modifiersData.popperOffsets;
1555
+ var referenceRect = state.rects.reference;
1556
+ var popperRect = state.rects.popper;
1557
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1558
+ placement: state.placement
1559
+ })) : tetherOffset;
1560
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1561
+ mainAxis: tetherOffsetValue,
1562
+ altAxis: tetherOffsetValue
1563
+ } : Object.assign({
1564
+ mainAxis: 0,
1565
+ altAxis: 0
1566
+ }, tetherOffsetValue);
1567
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1568
+ var data = {
1569
+ x: 0,
1570
+ y: 0
1571
+ };
1572
+
1573
+ if (!popperOffsets) {
1574
+ return;
1575
+ }
1576
+
1577
+ if (checkMainAxis) {
1578
+ var _offsetModifierState$;
1579
+
1580
+ var mainSide = mainAxis === 'y' ? top : left;
1581
+ var altSide = mainAxis === 'y' ? bottom : right;
1582
+ var len = mainAxis === 'y' ? 'height' : 'width';
1583
+ var offset = popperOffsets[mainAxis];
1584
+ var min$1 = offset + overflow[mainSide];
1585
+ var max$1 = offset - overflow[altSide];
1586
+ var additive = tether ? -popperRect[len] / 2 : 0;
1587
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1588
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1589
+ // outside the reference bounds
1590
+
1591
+ var arrowElement = state.elements.arrow;
1592
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1593
+ width: 0,
1594
+ height: 0
1595
+ };
1596
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1597
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1598
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1599
+ // to include its full size in the calculation. If the reference is small
1600
+ // and near the edge of a boundary, the popper can overflow even if the
1601
+ // reference is not overflowing as well (e.g. virtual elements with no
1602
+ // width or height)
1603
+
1604
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1605
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1606
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1607
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1608
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1609
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1610
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1611
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1612
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1613
+ popperOffsets[mainAxis] = preventedOffset;
1614
+ data[mainAxis] = preventedOffset - offset;
1615
+ }
1616
+
1617
+ if (checkAltAxis) {
1618
+ var _offsetModifierState$2;
1619
+
1620
+ var _mainSide = mainAxis === 'x' ? top : left;
1621
+
1622
+ var _altSide = mainAxis === 'x' ? bottom : right;
1623
+
1624
+ var _offset = popperOffsets[altAxis];
1625
+
1626
+ var _len = altAxis === 'y' ? 'height' : 'width';
1627
+
1628
+ var _min = _offset + overflow[_mainSide];
1629
+
1630
+ var _max = _offset - overflow[_altSide];
1631
+
1632
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1633
+
1634
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1635
+
1636
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1637
+
1638
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1639
+
1640
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1641
+
1642
+ popperOffsets[altAxis] = _preventedOffset;
1643
+ data[altAxis] = _preventedOffset - _offset;
1644
+ }
1645
+
1646
+ state.modifiersData[name] = data;
1647
+ } // eslint-disable-next-line import/no-unused-modules
1648
+
1649
+
1650
+ var preventOverflow$1 = {
1651
+ name: 'preventOverflow',
1652
+ enabled: true,
1653
+ phase: 'main',
1654
+ fn: preventOverflow,
1655
+ requiresIfExists: ['offset']
1656
+ };
1657
+
1658
+ var toPaddingObject = function toPaddingObject(padding, state) {
1659
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
1660
+ placement: state.placement
1661
+ })) : padding;
1662
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1663
+ };
1664
+
1665
+ function arrow(_ref) {
1666
+ var _state$modifiersData$;
1667
+
1668
+ var state = _ref.state,
1669
+ name = _ref.name,
1670
+ options = _ref.options;
1671
+ var arrowElement = state.elements.arrow;
1672
+ var popperOffsets = state.modifiersData.popperOffsets;
1673
+ var basePlacement = getBasePlacement(state.placement);
1674
+ var axis = getMainAxisFromPlacement(basePlacement);
1675
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
1676
+ var len = isVertical ? 'height' : 'width';
1677
+
1678
+ if (!arrowElement || !popperOffsets) {
1679
+ return;
1680
+ }
1681
+
1682
+ var paddingObject = toPaddingObject(options.padding, state);
1683
+ var arrowRect = getLayoutRect(arrowElement);
1684
+ var minProp = axis === 'y' ? top : left;
1685
+ var maxProp = axis === 'y' ? bottom : right;
1686
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1687
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1688
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1689
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1690
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1691
+ // outside of the popper bounds
1692
+
1693
+ var min = paddingObject[minProp];
1694
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1695
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1696
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1697
+
1698
+ var axisProp = axis;
1699
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1700
+ }
1701
+
1702
+ function effect(_ref2) {
1703
+ var state = _ref2.state,
1704
+ options = _ref2.options;
1705
+ var _options$element = options.element,
1706
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
1707
+
1708
+ if (arrowElement == null) {
1709
+ return;
1710
+ } // CSS selector
1711
+
1712
+
1713
+ if (typeof arrowElement === 'string') {
1714
+ arrowElement = state.elements.popper.querySelector(arrowElement);
1715
+
1716
+ if (!arrowElement) {
1717
+ return;
1718
+ }
1719
+ }
1720
+
1721
+ if (!contains(state.elements.popper, arrowElement)) {
1722
+ return;
1723
+ }
1724
+
1725
+ state.elements.arrow = arrowElement;
1726
+ } // eslint-disable-next-line import/no-unused-modules
1727
+
1728
+
1729
+ var arrow$1 = {
1730
+ name: 'arrow',
1731
+ enabled: true,
1732
+ phase: 'main',
1733
+ fn: arrow,
1734
+ effect: effect,
1735
+ requires: ['popperOffsets'],
1736
+ requiresIfExists: ['preventOverflow']
1737
+ };
1738
+
1739
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1740
+ if (preventedOffsets === void 0) {
1741
+ preventedOffsets = {
1742
+ x: 0,
1743
+ y: 0
1744
+ };
1745
+ }
1746
+
1747
+ return {
1748
+ top: overflow.top - rect.height - preventedOffsets.y,
1749
+ right: overflow.right - rect.width + preventedOffsets.x,
1750
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1751
+ left: overflow.left - rect.width - preventedOffsets.x
1752
+ };
1753
+ }
1754
+
1755
+ function isAnySideFullyClipped(overflow) {
1756
+ return [top, right, bottom, left].some(function (side) {
1757
+ return overflow[side] >= 0;
1758
+ });
1759
+ }
1760
+
1761
+ function hide(_ref) {
1762
+ var state = _ref.state,
1763
+ name = _ref.name;
1764
+ var referenceRect = state.rects.reference;
1765
+ var popperRect = state.rects.popper;
1766
+ var preventedOffsets = state.modifiersData.preventOverflow;
1767
+ var referenceOverflow = detectOverflow(state, {
1768
+ elementContext: 'reference'
1769
+ });
1770
+ var popperAltOverflow = detectOverflow(state, {
1771
+ altBoundary: true
1772
+ });
1773
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1774
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1775
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1776
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1777
+ state.modifiersData[name] = {
1778
+ referenceClippingOffsets: referenceClippingOffsets,
1779
+ popperEscapeOffsets: popperEscapeOffsets,
1780
+ isReferenceHidden: isReferenceHidden,
1781
+ hasPopperEscaped: hasPopperEscaped
1782
+ };
1783
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1784
+ 'data-popper-reference-hidden': isReferenceHidden,
1785
+ 'data-popper-escaped': hasPopperEscaped
1786
+ });
1787
+ } // eslint-disable-next-line import/no-unused-modules
1788
+
1789
+
1790
+ var hide$1 = {
1791
+ name: 'hide',
1792
+ enabled: true,
1793
+ phase: 'main',
1794
+ requiresIfExists: ['preventOverflow'],
1795
+ fn: hide
1796
+ };
1797
+
1798
+ var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
1799
+ var createPopper$1 = /*#__PURE__*/popperGenerator({
1800
+ defaultModifiers: defaultModifiers$1
1801
+ }); // eslint-disable-next-line import/no-unused-modules
1802
+
1803
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1804
+ var createPopper = /*#__PURE__*/popperGenerator({
1805
+ defaultModifiers: defaultModifiers
1806
+ }); // eslint-disable-next-line import/no-unused-modules
1807
+
1808
+ exports.applyStyles = applyStyles$1;
1809
+ exports.arrow = arrow$1;
1810
+ exports.computeStyles = computeStyles$1;
1811
+ exports.createPopper = createPopper;
1812
+ exports.createPopperLite = createPopper$1;
1813
+ exports.defaultModifiers = defaultModifiers;
1814
+ exports.detectOverflow = detectOverflow;
1815
+ exports.eventListeners = eventListeners;
1816
+ exports.flip = flip$1;
1817
+ exports.hide = hide$1;
1818
+ exports.offset = offset$1;
1819
+ exports.popperGenerator = popperGenerator;
1820
+ exports.popperOffsets = popperOffsets$1;
1821
+ exports.preventOverflow = preventOverflow$1;
1822
+
1823
+ Object.defineProperty(exports, '__esModule', { value: true });
1824
+
1825
+ })));
1826
+
1827
+
1828
+ document.addEventListener('DOMContentLoaded', () => {
1829
+ /**
1830
+ * CivicTheme Webform component.
1831
+ */
1832
+
1833
+ function CivicThemeWebform(el) {
1834
+ if (el.getAttribute('data-webform') === 'true' || this.el) {
1835
+ return;
1836
+ }
1837
+
1838
+ this.el = el;
1839
+
1840
+ // Check for form errors and scroll to error message if present.
1841
+ const fieldErrors = this.el.querySelectorAll('.ct-field-message--error');
1842
+ if (fieldErrors.length > 0) {
1843
+ const errorMessage = document.querySelector('.ct-message--error');
1844
+ if (errorMessage) {
1845
+ // Make error message focusable if it's not a link.
1846
+ if (!errorMessage.matches('a')) {
1847
+ errorMessage.setAttribute('tabindex', '-1');
1848
+ }
1849
+ errorMessage.focus();
1850
+ errorMessage.scrollIntoView({
1851
+ behavior: 'smooth',
1852
+ });
1853
+ }
1854
+ }
1855
+
1856
+ // Mark as initialized.
1857
+ this.el.setAttribute('data-webform', 'true');
1858
+ }
1859
+
1860
+ // Initialize CivicThemeWebform on every element.
1861
+ document.querySelectorAll('.ct-webform').forEach((webform) => {
1862
+
1863
+ new CivicThemeWebform(webform);
1864
+ });
1865
+
1866
+ });
1867
+ document.addEventListener('DOMContentLoaded', () => {
1868
+ /**
1869
+ * CivicTheme Slider component.
1870
+ */
1871
+
1872
+ function CivicThemeSlider(el) {
1873
+ if (el.getAttribute('data-slider') === 'true' || this.el) {
1874
+ return;
1875
+ }
1876
+
1877
+ this.el = el;
1878
+
1879
+ this.panel = this.el.querySelector('[data-slider-panel]');
1880
+ this.rail = this.el.querySelector('[data-slider-rail]');
1881
+ this.prev = this.el.querySelector('[data-slider-previous]');
1882
+ this.next = this.el.querySelector('[data-slider-next]');
1883
+ this.slides = this.el.querySelectorAll('[data-slider-slide]');
1884
+ this.progressIndicator = this.el.querySelector('[data-slider-progress]');
1885
+
1886
+ this.prev.addEventListener('click', this.previousClick.bind(this));
1887
+ this.next.addEventListener('click', this.nextClick.bind(this));
1888
+ window.addEventListener('resize', this.refresh.bind(this));
1889
+
1890
+ this.currentSlide = 0;
1891
+ this.totalSlides = this.slides.length;
1892
+ this.animationTimeout = null;
1893
+
1894
+ this.updateProgress();
1895
+ this.addSlideAriaAttributes();
1896
+ this.hideAllSlidesExceptCurrent();
1897
+
1898
+ this.refresh();
1899
+
1900
+ // Refresh slider on font-load.
1901
+ document.fonts.ready.then(() => {
1902
+ requestAnimationFrame(() => {
1903
+ this.refresh();
1904
+ });
1905
+ });
1906
+ }
1907
+
1908
+ CivicThemeSlider.prototype.refresh = function () {
1909
+ // Set slide width based on panel width.
1910
+ const panelWidth = window.getComputedStyle(this.panel).width;
1911
+ const panelWidthVal = parseFloat(panelWidth);
1912
+
1913
+ // Reset rail and panel height.
1914
+ this.rail.style.height = '';
1915
+ this.panel.style.height = '';
1916
+
1917
+ // Set the rail width.
1918
+ this.rail.style.width = `${this.totalSlides * panelWidthVal}px`;
1919
+
1920
+ // Reset slide heights.
1921
+ this.slides.forEach((slide) => {
1922
+ slide.style.height = null;
1923
+ slide.style.width = panelWidth;
1924
+ });
1925
+
1926
+ // Show all slides temporarily to calculate heights.
1927
+ this.slides.forEach((slide) => slide.removeAttribute('data-slider-slide-hidden'));
1928
+
1929
+ // Set slide position and find largest slide.
1930
+ let largestHeight = 0;
1931
+ this.slides.forEach((slide, idx) => {
1932
+ slide.style.left = `${idx * panelWidthVal}px`;
1933
+ const slideHeight = slide.offsetHeight;
1934
+ if (slideHeight > largestHeight) {
1935
+ largestHeight = slideHeight;
1936
+ }
1937
+ });
1938
+ const largestHeightPx = `${largestHeight}px`;
1939
+
1940
+ // Resize all slides to the largest slide.
1941
+ this.slides.forEach((slide) => {
1942
+ slide.style.height = largestHeightPx;
1943
+ });
1944
+
1945
+ this.hideAllSlidesExceptCurrent();
1946
+
1947
+ // Set heights based on largest slide height.
1948
+ this.rail.style.height = largestHeightPx;
1949
+ this.panel.style.height = largestHeightPx;
1950
+ };
1951
+
1952
+ CivicThemeSlider.prototype.enableSlideInteraction = function () {
1953
+ this.rail.querySelectorAll('a, button').forEach((link) => {
1954
+ link.removeAttribute('tabindex');
1955
+ });
1956
+ };
1957
+
1958
+ CivicThemeSlider.prototype.addSlideAriaAttributes = function () {
1959
+ this.slides.forEach((slide, idx) => {
1960
+ slide.setAttribute('aria-label', `Slide ${idx + 1} of ${this.totalSlides}`);
1961
+ });
1962
+ };
1963
+
1964
+ CivicThemeSlider.prototype.disableSlideInteraction = function () {
1965
+ this.rail.querySelectorAll('a, button').forEach((link) => {
1966
+ link.setAttribute('tabindex', '-1');
1967
+ });
1968
+ };
1969
+
1970
+ CivicThemeSlider.prototype.hideAllSlidesExceptCurrent = function () {
1971
+ this.slides.forEach((slide, idx) => {
1972
+ if (idx !== this.currentSlide) {
1973
+ slide.setAttribute('data-slider-slide-hidden', 'true');
1974
+ slide.setAttribute('inert', true);
1975
+ } else {
1976
+ slide.removeAttribute('data-slider-slide-hidden');
1977
+ slide.removeAttribute('inert');
1978
+ }
1979
+ });
1980
+ };
1981
+
1982
+ CivicThemeSlider.prototype.updateDisplaySlide = function () {
1983
+ const duration = parseFloat(window.getComputedStyle(this.rail).transitionDuration) * 1000;
1984
+
1985
+ this.disableSlideInteraction();
1986
+ this.slides.forEach((slide) => slide.removeAttribute('data-slider-slide-hidden'));
1987
+
1988
+ // Reset timer and wait for animation to complete.
1989
+ clearTimeout(this.animationTimeout);
1990
+ this.animationTimeout = setTimeout(() => {
1991
+ this.hideAllSlidesExceptCurrent();
1992
+ this.enableSlideInteraction();
1993
+ }, duration);
1994
+ };
1995
+
1996
+ CivicThemeSlider.prototype.previousClick = function () {
1997
+ // Go to last slide if current slide is the first slide.
1998
+ if (this.currentSlide === 0) {
1999
+ this.currentSlide = this.totalSlides - 1;
2000
+ } else {
2001
+ this.currentSlide--;
2002
+ }
2003
+ this.rail.style.left = `${this.currentSlide * -100}%`;
2004
+ this.updateProgress();
2005
+ this.updateDisplaySlide();
2006
+ };
2007
+
2008
+ CivicThemeSlider.prototype.nextClick = function () {
2009
+ // Go to first slide if current slide is the last slide.
2010
+ if (this.currentSlide === (this.totalSlides - 1)) {
2011
+ this.currentSlide = 0;
2012
+ } else {
2013
+ this.currentSlide++;
2014
+ }
2015
+ this.rail.style.left = `${this.currentSlide * -100}%`;
2016
+ this.updateProgress();
2017
+ this.updateDisplaySlide();
2018
+ };
2019
+
2020
+ CivicThemeSlider.prototype.updateProgress = function () {
2021
+ this.progressIndicator.innerHTML = `Slide ${this.currentSlide + 1} of ${this.totalSlides}`;
2022
+ };
2023
+
2024
+ document.querySelectorAll('[data-slider]').forEach((slider) => {
2025
+ new CivicThemeSlider(slider);
2026
+ });
2027
+
2028
+ });
2029
+ document.addEventListener('DOMContentLoaded', () => {
2030
+ /**
2031
+ * CivicTheme Alert component.
2032
+ */
2033
+
2034
+ function CivicThemeAlert(el) {
2035
+ // Use "data-alert"'s attribute value to identify if this
2036
+ // component was already initialised.
2037
+ if (el.getAttribute('data-alert') === 'true' || this.container) {
2038
+ return;
2039
+ }
2040
+
2041
+ this.container = el;
2042
+ this.endpoint = this.container.getAttribute('data-alert-endpoint');
2043
+ if (this.endpoint !== null) {
2044
+ this.getAll();
2045
+ }
2046
+
2047
+ // Mark as initialized.
2048
+ this.container.setAttribute('data-alert', 'true');
2049
+ }
2050
+
2051
+ /**
2052
+ * Gets alerts from endpoint.
2053
+ */
2054
+ CivicThemeAlert.prototype.getAll = function () {
2055
+ const { endpoint } = this;
2056
+ const request = new XMLHttpRequest();
2057
+ request.open('get', endpoint);
2058
+ request.onreadystatechange = () => {
2059
+ if (request.readyState === 4 && request.status === 200) {
2060
+ try {
2061
+ const response = JSON.parse(request.responseText);
2062
+ const html = this.filter(response);
2063
+ this.insert(html);
2064
+ } catch (e) {
2065
+ // Do nothing.
2066
+ }
2067
+ }
2068
+ };
2069
+ request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
2070
+ request.send();
2071
+ };
2072
+
2073
+ /**
2074
+ * Filters out alerts not to show ie dismissed, page-specific alerts.
2075
+ */
2076
+ CivicThemeAlert.prototype.filter = function (response) {
2077
+ let html = '';
2078
+
2079
+ if (response.length) {
2080
+ for (let i = 0; i < response.length; i++) {
2081
+ const item = response[i];
2082
+
2083
+ if (!this.isValidResponse(item)) {
2084
+ continue;
2085
+ }
2086
+
2087
+ // Skip the alert hidden by the user session.
2088
+ if (this.hasCookieValue(item.id, item.message)) {
2089
+ continue;
2090
+ }
2091
+
2092
+ // Skip the alert not matching visibility rules.
2093
+ if (!this.isVisible(item.visibility)) {
2094
+ continue;
2095
+ }
2096
+
2097
+ html += item.message;
2098
+ }
2099
+ }
2100
+
2101
+ return html;
2102
+ };
2103
+
2104
+ /**
2105
+ * Checks whether an alert is to be shown on a specified page.
2106
+ */
2107
+ CivicThemeAlert.prototype.isVisible = function (visibilityString) {
2108
+ if ((typeof visibilityString === 'undefined') || visibilityString === false || visibilityString === '') {
2109
+ return true;
2110
+ }
2111
+
2112
+ let pageVisibility = visibilityString.replace(/\*/g, '[^ ]*');
2113
+ // Replace '<front>' with "/".
2114
+ pageVisibility = pageVisibility.replace('<front>', '/');
2115
+ // Replace all occurrences of '/' with '\/'.
2116
+ // eslint-disable-next-line
2117
+ pageVisibility = pageVisibility.replace('/', '\/');
2118
+
2119
+ const pageVisibilityRules = pageVisibility.split(/\r?\n/);
2120
+ if (pageVisibilityRules.length !== 0) {
2121
+ const path = this.urlPath();
2122
+
2123
+ for (let r = 0, rlen = pageVisibilityRules.length; r < rlen; r++) {
2124
+ if (path === pageVisibilityRules[r]) {
2125
+ return true;
2126
+ }
2127
+
2128
+ if (pageVisibilityRules[r].indexOf('*') !== -1 && path.match(new RegExp(`^${pageVisibilityRules[r]}`))) {
2129
+ return true;
2130
+ }
2131
+ }
2132
+ return false;
2133
+ }
2134
+
2135
+ return true;
2136
+ };
2137
+
2138
+ /**
2139
+ * Check if response object is valid.
2140
+ */
2141
+ CivicThemeAlert.prototype.isValidResponse = function (item) {
2142
+ return typeof item === 'object' && 'id' in item && 'message' in item && 'visibility' in item;
2143
+ };
2144
+
2145
+ /**
2146
+ * Get the cookie name.
2147
+ */
2148
+ CivicThemeAlert.prototype.getCookieName = function () {
2149
+ return 'ct-alert-hide';
2150
+ };
2151
+
2152
+ /**
2153
+ * Check if cookie has value.
2154
+ */
2155
+ CivicThemeAlert.prototype.hasCookieValue = function (id, message) {
2156
+ const cookie = this.getCookie();
2157
+ return id in cookie && cookie[id] === this.hashString(this.removeHtml(message));
2158
+ };
2159
+
2160
+ /**
2161
+ * Sets an cookie value.
2162
+ */
2163
+ CivicThemeAlert.prototype.setCookieValue = function (id, message) {
2164
+ const cookie = this.getCookie();
2165
+ cookie[id] = this.hashString(this.removeHtml(message));
2166
+ this.setCookie(cookie);
2167
+ };
2168
+
2169
+ /**
2170
+ * Get cookie value.
2171
+ */
2172
+ CivicThemeAlert.prototype.getCookie = function () {
2173
+ let cookie = {};
2174
+
2175
+ const values = document.cookie.split(';').filter((item) => item.trim().startsWith(`${this.getCookieName()}=`));
2176
+ if (values.length !== 1) {
2177
+ return cookie;
2178
+ }
2179
+
2180
+ const stringValues = values[0].trim().replace(`${this.getCookieName()}=`, '');
2181
+ if (typeof stringValues !== 'string') {
2182
+ return cookie;
2183
+ }
2184
+
2185
+ try {
2186
+ cookie = JSON.parse(stringValues);
2187
+ } catch (e) {
2188
+ cookie = {};
2189
+ }
2190
+
2191
+ return cookie;
2192
+ };
2193
+
2194
+ /**
2195
+ * Set a cookie.
2196
+ */
2197
+ CivicThemeAlert.prototype.setCookie = function (value) {
2198
+ document.cookie = `${this.getCookieName()}=${JSON.stringify(value)}; SameSite=Strict; Path=/`;
2199
+ };
2200
+
2201
+ /**
2202
+ * Simple HTML remover.
2203
+ */
2204
+ CivicThemeAlert.prototype.removeHtml = function (string) {
2205
+ return string
2206
+ .replace(/(\r\n|\n|\r)/g, '')
2207
+ .replace(/\s/g, '')
2208
+ .replace(/(&nbsp;|<([^>]+)>)/ig, '')
2209
+ .trim();
2210
+ };
2211
+
2212
+ /**
2213
+ * Hash string.
2214
+ */
2215
+ CivicThemeAlert.prototype.hashString = function (string) {
2216
+ let hash = 0;
2217
+ let i;
2218
+ let
2219
+ chr;
2220
+ if (string.length === 0) return hash;
2221
+ for (i = 0; i < string.length; i++) {
2222
+ chr = string.charCodeAt(i);
2223
+ // eslint-disable-next-line no-bitwise
2224
+ hash = ((hash << 5) - hash) + chr;
2225
+ // eslint-disable-next-line no-bitwise
2226
+ hash |= 0;
2227
+ }
2228
+ return hash;
2229
+ };
2230
+
2231
+ /**
2232
+ * Insert alerts into container.
2233
+ */
2234
+ CivicThemeAlert.prototype.insert = function (html) {
2235
+ // Build the alert.
2236
+ this.container.insertAdjacentHTML('afterbegin', html);
2237
+ this.setDismissListeners();
2238
+ };
2239
+
2240
+ /**
2241
+ * Sets dismiss listeners to alerts.
2242
+ */
2243
+ CivicThemeAlert.prototype.setDismissListeners = function () {
2244
+ // Process the Close button of each alert.
2245
+ document
2246
+ .querySelectorAll('[data-alert-dismiss-trigger]')
2247
+ .forEach((el) => {
2248
+ el.addEventListener('click', (event) => {
2249
+ event.stopPropagation();
2250
+ const parent = this.getParentElement(event.currentTarget, '[data-component-name="ct-alert"]');
2251
+ this.dismiss(parent);
2252
+ });
2253
+ });
2254
+ };
2255
+
2256
+ /**
2257
+ * Dismisses an alert and adds cookie to dismiss for session.
2258
+ */
2259
+ CivicThemeAlert.prototype.dismiss = function (element) {
2260
+ if (element !== null) {
2261
+ const parent = this.getParentElement(element, '[data-component-name="ct-alerts"]');
2262
+ if (parent) {
2263
+ parent.removeChild(element);
2264
+ }
2265
+ const id = element.getAttribute('data-alert-id');
2266
+ if (id) {
2267
+ this.setCookieValue(id, element.outerHTML);
2268
+ }
2269
+ }
2270
+ };
2271
+
2272
+ /**
2273
+ * Get a parent element matching a selector.
2274
+ */
2275
+ CivicThemeAlert.prototype.getParentElement = function (element, selector) {
2276
+ while (element !== null && !element.matches(selector)) {
2277
+ element = element.parentNode;
2278
+ }
2279
+ return element;
2280
+ };
2281
+
2282
+ /**
2283
+ * Get current path from URL or data attribute.
2284
+ *
2285
+ * 'data-test-path' attribute is used for testing of this component within
2286
+ * Storybook.
2287
+ */
2288
+ CivicThemeAlert.prototype.urlPath = function () {
2289
+ return this.container.getAttribute('data-test-path') || window.location.pathname;
2290
+ };
2291
+
2292
+ /**
2293
+ * Initialise component.
2294
+ */
2295
+ document.querySelectorAll('[data-component-name="ct-alerts"]').forEach((el) => {
2296
+ new CivicThemeAlert(el);
2297
+ });
2298
+
2299
+ });
2300
+ document.addEventListener('DOMContentLoaded', () => {
2301
+ /**
2302
+ * CivicTheme Tooltip component.
2303
+ */
2304
+
2305
+ function CivicThemeTooltip(el) {
2306
+ if (el.getAttribute('data-tooltip') === 'true') {
2307
+ return;
2308
+ }
2309
+
2310
+ this.el = el;
2311
+ this.el.setAttribute('data-tooltip', 'true');
2312
+ this.button = this.el.querySelector('[data-tooltip-button]');
2313
+ this.content = this.el.querySelector('[data-tooltip-content]');
2314
+ this.arrow = this.el.querySelector('[data-tooltip-arrow]');
2315
+ this.close = this.el.querySelector('[data-tooltip-close]');
2316
+ this.position = 'auto';
2317
+
2318
+ if (this.button) {
2319
+ // Generate unique id for the tooltip content.
2320
+ let prefix = 'tooltip';
2321
+ do {
2322
+ prefix += Math.floor(Math.random() * 10000);
2323
+ } while (document.getElementById(prefix));
2324
+ this.content.setAttribute('id', prefix);
2325
+ this.button.setAttribute('aria-describedby', prefix);
2326
+
2327
+ this.position = this.button.getAttribute('data-tooltip-position') || 'auto';
2328
+ this.button.addEventListener('click', this.tooltipShow.bind(this));
2329
+ this.button.addEventListener('focusin', this.tooltipShow.bind(this));
2330
+ this.button.addEventListener('focusout', this.tooltipHide.bind(this));
2331
+ this.button.addEventListener('mouseenter', this.tooltipShow.bind(this));
2332
+ this.button.addEventListener('mouseleave', this.tooltipHide.bind(this));
2333
+ this.close.addEventListener('focusin', this.tooltipHide.bind(this));
2334
+ this.close.addEventListener('click', this.tooltipHide.bind(this));
2335
+ }
2336
+
2337
+ if (typeof Popper !== 'undefined') {
2338
+ // Pass the button, the tooltip, and some options, and Popper will do the
2339
+ // magic positioning for you:
2340
+ this.el.popper = window.Popper.createPopper(this.button, this.content, {
2341
+ placement: this.position,
2342
+ modifiers: [
2343
+ {
2344
+ name: 'arrow',
2345
+ options: {
2346
+ element: this.arrow,
2347
+ padding: 12,
2348
+ },
2349
+ },
2350
+ {
2351
+ name: 'offset',
2352
+ options: {
2353
+ offset: [0, 36],
2354
+ },
2355
+ },
2356
+ {
2357
+ name: 'flip',
2358
+ options: {
2359
+ fallbackPlacements: ['top', 'bottom'],
2360
+ },
2361
+ },
2362
+ ],
2363
+ });
2364
+ }
2365
+ }
2366
+
2367
+ /**
2368
+ * Show event handler.
2369
+ */
2370
+ CivicThemeTooltip.prototype.tooltipShow = function (e) {
2371
+ e.stopPropagation();
2372
+ e.preventDefault();
2373
+ e.stopImmediatePropagation();
2374
+
2375
+ const tooltip = this.findTooltip(e.target);
2376
+ if (tooltip) {
2377
+ tooltip.setAttribute('data-tooltip-visible', '');
2378
+ tooltip.popper.update();
2379
+ }
2380
+ };
2381
+
2382
+ /**
2383
+ * Hide event handler.
2384
+ */
2385
+ CivicThemeTooltip.prototype.tooltipHide = function (e) {
2386
+ e.stopPropagation();
2387
+ e.preventDefault();
2388
+ e.stopImmediatePropagation();
2389
+
2390
+ const tooltip = this.findTooltip(e.target);
2391
+ if (tooltip) {
2392
+ tooltip.removeAttribute('data-tooltip-visible');
2393
+ }
2394
+ };
2395
+
2396
+ /**
2397
+ * Find button element.
2398
+ */
2399
+ CivicThemeTooltip.prototype.findTooltip = function (el) {
2400
+ if (el.classList.contains('ct-tooltip')) {
2401
+ return el;
2402
+ }
2403
+ return el.closest('.ct-tooltip');
2404
+ };
2405
+
2406
+ /**
2407
+ * Destroy an instance.
2408
+ */
2409
+ CivicThemeTooltip.prototype.destroy = function (el) {
2410
+ if (el.getAttribute('data-tooltip') !== 'true' || !this.el) {
2411
+ return;
2412
+ }
2413
+
2414
+ const button = el.querySelector('[data-tooltip-button]');
2415
+ const content = el.querySelector('[data-tooltip-content]');
2416
+
2417
+ // Exit early if button or content were not found.
2418
+ if (!button || !content) {
2419
+ return;
2420
+ }
2421
+
2422
+ this.el = el;
2423
+ this.button = button;
2424
+ this.content = content;
2425
+
2426
+ // Remove any attached event listeners.
2427
+ // eslint-disable-next-line no-self-assign
2428
+ this.button.outerHTML = this.button.outerHTML;
2429
+
2430
+ // Mark as non-initialized.
2431
+ this.el.setAttribute('data-tooltip', '');
2432
+
2433
+ delete this.el;
2434
+ delete this.button;
2435
+ delete this.content;
2436
+ delete this.arrow;
2437
+ delete this.close;
2438
+ delete this.position;
2439
+ };
2440
+
2441
+ document.querySelectorAll('.ct-tooltip').forEach((el) => {
2442
+ new CivicThemeTooltip(el);
2443
+ });
2444
+
2445
+ });
2446
+ document.addEventListener('DOMContentLoaded', () => {
2447
+ /**
2448
+ * CivicTheme Tabs component.
2449
+ */
2450
+
2451
+ function CivicThemeTabs(el, selectedIndex) {
2452
+ if (!el) {
2453
+ return;
2454
+ }
2455
+
2456
+ this.el = el;
2457
+ this.links = this.el.querySelectorAll('[data-tabs-tab]');
2458
+ this.panels = this.el.querySelectorAll('[data-tabs-panel]');
2459
+
2460
+ if (this.links.length === 0
2461
+ || this.panels.length === 0
2462
+ || this.links.length !== this.panels.length
2463
+ ) {
2464
+ return;
2465
+ }
2466
+
2467
+ this.init(selectedIndex);
2468
+ }
2469
+
2470
+ CivicThemeTabs.prototype.init = function () {
2471
+ this.clickListener = this.clickEvent.bind(this);
2472
+
2473
+ let selected = 0;
2474
+ for (let i = 0; i < this.panels.length; i++) {
2475
+ this.links[i].addEventListener('click', this.clickListener, false);
2476
+
2477
+ if (this.panels[i].classList.contains('ct-tabs__panel--selected') && !selected) {
2478
+ selected = i;
2479
+ }
2480
+ }
2481
+
2482
+ this.links[selected].click();
2483
+ };
2484
+
2485
+ CivicThemeTabs.prototype.clickEvent = function (e) {
2486
+ e.preventDefault();
2487
+
2488
+ this.setSelected(e.currentTarget);
2489
+ };
2490
+
2491
+ CivicThemeTabs.prototype.setSelected = function (current) {
2492
+ for (let i = 0; i < this.panels.length; i++) {
2493
+ const currentLink = this.links[i];
2494
+ if (currentLink === current) {
2495
+ currentLink.classList.add('ct-tabs__tab--selected');
2496
+ currentLink.setAttribute('aria-selected', true);
2497
+ this.panels[i].classList.add('ct-tabs__panel--selected');
2498
+ this.panels[i].setAttribute('aria-hidden', false);
2499
+ } else {
2500
+ currentLink.classList.remove('ct-tabs__tab--selected');
2501
+ currentLink.setAttribute('aria-selected', false);
2502
+ this.panels[i].classList.remove('ct-tabs__panel--selected');
2503
+ this.panels[i].setAttribute('aria-hidden', true);
2504
+ }
2505
+ }
2506
+ };
2507
+
2508
+ CivicThemeTabs.prototype.destroy = function () {
2509
+ for (let i = 0; i < this.panels.length; i++) {
2510
+ this.links[i].removeAttribute('aria-selected');
2511
+ this.links[i].classList.remove('ct-tabs__tab--selected');
2512
+ this.links[i].removeEventListener('click', this.clickListener, false);
2513
+
2514
+ this.panels[i].removeAttribute('aria-hidden');
2515
+ this.panels[i].classList.remove('ct-tabs__panel--selected');
2516
+ }
2517
+ };
2518
+
2519
+ document.querySelectorAll('.ct-tabs').forEach((tabs) => {
2520
+ new CivicThemeTabs(tabs);
2521
+ });
2522
+
2523
+ });
2524
+ document.addEventListener('DOMContentLoaded', () => {
2525
+ /**
2526
+ * CivicTheme Table of Contents component.
2527
+ */
2528
+
2529
+ function CivicThemeTableOfContents(el) {
2530
+ // Check if current target is already initialised.
2531
+ if (el.hasAttribute('data-table-of-contents-initialised')) {
2532
+ return;
2533
+ }
2534
+
2535
+ // Get options from attributes.
2536
+ this.target = el;
2537
+ this.position = this.target.getAttribute('data-table-of-contents-position').trim();
2538
+ this.theme = this.target.hasAttribute('data-table-of-contents-theme') ? this.target.getAttribute('data-table-of-contents-theme').trim() : 'light';
2539
+ this.anchorSelector = this.target.hasAttribute('data-table-of-contents-anchor-selector') ? this.target.getAttribute('data-table-of-contents-anchor-selector').trim() : 'h2';
2540
+ this.anchorScopeSelector = this.target.hasAttribute('data-table-of-contents-anchor-scope-selector') ? this.target.getAttribute('data-table-of-contents-anchor-scope-selector').trim() : '.ct-basic-content';
2541
+ this.title = this.target.hasAttribute('data-table-of-contents-title') ? this.target.getAttribute('data-table-of-contents-title').trim() : '';
2542
+
2543
+ // Normalise attribute values.
2544
+ this.position = ['before', 'after', 'prepend', 'append'].indexOf(this.position.trim()) > 0 ? this.position : 'before';
2545
+ this.theme = this.theme === 'dark' ? 'dark' : 'light';
2546
+ this.anchorSelector = this.anchorSelector !== '' ? this.anchorSelector : 'h2';
2547
+ this.anchorScopeSelector = this.anchorScopeSelector !== '' ? this.anchorScopeSelector : '.ct-basic-content';
2548
+
2549
+ // Initialise component.
2550
+ this.init();
2551
+
2552
+ // Mark target as initialised.
2553
+ this.target.setAttribute('data-table-of-contents-initialised', 'true');
2554
+ }
2555
+
2556
+ CivicThemeTableOfContents.prototype.init = function () {
2557
+ let html = '';
2558
+
2559
+ const links = this.findLinks(this.anchorSelector, this.anchorScopeSelector);
2560
+
2561
+ if (!links.length) {
2562
+ return;
2563
+ }
2564
+
2565
+ if (this.title) {
2566
+ html += this.renderTitle(this.title);
2567
+ }
2568
+
2569
+ html += this.renderLinks(links);
2570
+
2571
+ html = this.renderContainer(html, this.theme, this.position);
2572
+
2573
+ this.place(this.target, this.position, html);
2574
+ };
2575
+
2576
+ CivicThemeTableOfContents.prototype.findLinks = function (anchorSelector, scopeSelector) {
2577
+ const links = [];
2578
+ const existingUrls = new Set(); // Track existing URLs.
2579
+
2580
+ // Find links within provided scope selector.
2581
+ document.querySelectorAll(scopeSelector).forEach((elScope) => {
2582
+ elScope.querySelectorAll(anchorSelector).forEach((elAnchor) => {
2583
+ // Skip headings marked to be excluded from TOC.
2584
+ if (elAnchor.hasAttribute('data-toc-exclude')) {
2585
+ return;
2586
+ }
2587
+
2588
+ // Respect existing ID.
2589
+ let anchorId = elAnchor.id || null;
2590
+ const anchorText = elAnchor.innerText;
2591
+
2592
+ // Ignore blank headings.
2593
+ if (anchorText.trim() === '') {
2594
+ return;
2595
+ }
2596
+
2597
+ // Generate new ID if no existing ID.
2598
+ if (!anchorId || anchorId.length === 0) {
2599
+ anchorId = this.makeAnchorId(anchorText);
2600
+ // Check if generated ID is already present on the page or links array.
2601
+ while (elScope.querySelectorAll(`#${anchorId}`).length || existingUrls.has(`#${anchorId}`)) {
2602
+ // Add random 3 character suffix.
2603
+ anchorId = `${anchorId}-${Math.random().toString(36).substring(2, 5)}`;
2604
+ }
2605
+ }
2606
+
2607
+ const url = `#${anchorId}`;
2608
+
2609
+ // Skip adding the link if the URL already exists.
2610
+ if (existingUrls.has(url)) {
2611
+ return;
2612
+ }
2613
+
2614
+ links.push({
2615
+ title: anchorText,
2616
+ url,
2617
+ });
2618
+
2619
+ // Update anchor with the id. This will "fix" any anchors with duplicated
2620
+ // IDs, which is not a valid HTML content.
2621
+ elAnchor.id = anchorId;
2622
+
2623
+ // Add the URL to the set of existing URLs.
2624
+ existingUrls.add(url);
2625
+ });
2626
+ });
2627
+
2628
+ return links;
2629
+ };
2630
+
2631
+ CivicThemeTableOfContents.prototype.renderTitle = function (title) {
2632
+ return `<h2 class="ct-table-of-contents__title">${title}</h2>`;
2633
+ };
2634
+
2635
+ CivicThemeTableOfContents.prototype.renderLinks = function (links) {
2636
+ let html = '';
2637
+
2638
+ html += `<ul class="ct-table-of-contents__links">`;
2639
+ for (const i in links) {
2640
+ html += `
2641
+ <li class="ct-table-of-contents__link-item">
2642
+ <a class="ct-table-of-contents__link" href="${links[i].url}">${links[i].title}</a>
2643
+ </li>
2644
+ `;
2645
+ }
2646
+ html += '</ul>';
2647
+
2648
+ return html;
2649
+ };
2650
+
2651
+ CivicThemeTableOfContents.prototype.renderContainer = function (html, theme, position) {
2652
+ return `<div class="ct-table-of-contents ct-theme-${theme} ct-table-of-contents--position-${position}">${html}</div>`;
2653
+ };
2654
+
2655
+ CivicThemeTableOfContents.prototype.place = function (el, position, html) {
2656
+ const positionMap = {
2657
+ before: 'beforebegin',
2658
+ after: 'afterend',
2659
+ prepend: 'afterbegin',
2660
+ append: 'beforeend',
2661
+ };
2662
+
2663
+ el.insertAdjacentHTML(positionMap[position], html);
2664
+ };
2665
+
2666
+ CivicThemeTableOfContents.prototype.makeAnchorId = function (str) {
2667
+ return str.toLowerCase()
2668
+ .replace(/(&\w+?;)/gim, ' ')
2669
+ .replace(/[_.~"<>%|'!*();:@&=+$,/?%#[\]{}\n`^\\]/gim, '')
2670
+ .replace(/(^\s+)|(\s+$)/gim, '')
2671
+ .replace(/\s+/gm, '-');
2672
+ };
2673
+
2674
+ document.querySelectorAll('[data-table-of-contents-position]').forEach((el) => {
2675
+ new CivicThemeTableOfContents(el);
2676
+ });
2677
+
2678
+ });
2679
+ document.addEventListener('DOMContentLoaded', () => {
2680
+ /**
2681
+ * CivicTheme Single Filter component.
2682
+ */
2683
+
2684
+ function CivicThemeSingleFilterComponent(el) {
2685
+ if (el.getAttribute('data-single-filter') === 'true') {
2686
+ return;
2687
+ }
2688
+
2689
+ this.el = el;
2690
+
2691
+ this.el.addEventListener('ct.single-filter.update', this.updateEvent.bind(this));
2692
+
2693
+ this.el.querySelectorAll('input, textarea, select, [type="checkbox"], [type="radio"]').forEach((input) => {
2694
+ input.addEventListener('change', () => {
2695
+ el.dispatchEvent(new CustomEvent('ct.single-filter.update', { detail: { parent: input.parentElement } }));
2696
+ });
2697
+ });
2698
+
2699
+ // Mark as initialized.
2700
+ this.el.setAttribute('data-single-filter', 'true');
2701
+ }
2702
+
2703
+ /**
2704
+ * Update event handler.
2705
+ */
2706
+ CivicThemeSingleFilterComponent.prototype.updateEvent = function (el) {
2707
+ el.detail.parent.setAttribute('aria-live', 'polite');
2708
+ };
2709
+
2710
+ document.querySelectorAll('.ct-single-filter').forEach((el) => {
2711
+ new CivicThemeSingleFilterComponent(el);
2712
+ });
2713
+
2714
+ });
2715
+ document.addEventListener('DOMContentLoaded', () => {
2716
+ /**
2717
+ * CivicTheme Group Filter component.
2718
+ */
2719
+
2720
+ function CivicThemeGroupFilterComponent(el) {
2721
+ if (this.el) {
2722
+ return;
2723
+ }
2724
+
2725
+ this.el = el;
2726
+
2727
+ this.el.addEventListener('ct.group-filter.update', this.update.bind(this));
2728
+
2729
+ if (!el.hasEventListener) {
2730
+ el.hasEventListener = true;
2731
+ el.querySelectorAll('input, textarea, select, [type="checkbox"], [type="radio"]').forEach((input) => {
2732
+ input.addEventListener('change', () => {
2733
+ el.dispatchEvent(new CustomEvent('ct.group-filter.update', { detail: { parent: input.parentElement } }));
2734
+ });
2735
+ });
2736
+ }
2737
+ }
2738
+
2739
+ /**
2740
+ * Update the instance.
2741
+ */
2742
+ CivicThemeGroupFilterComponent.prototype.update = function (el) {
2743
+ el.detail.parent.setAttribute('aria-live', 'polite');
2744
+ };
2745
+
2746
+ document.querySelectorAll('[data-group-filter-filters]').forEach((el) => {
2747
+ new CivicThemeGroupFilterComponent(el);
2748
+ });
2749
+
2750
+ });
2751
+ document.addEventListener('DOMContentLoaded', () => {
2752
+ /**
2753
+ * CivicTheme Table component.
2754
+ */
2755
+
2756
+ function CivicThemeTable(el) {
2757
+ if (!el) {
2758
+ return;
2759
+ }
2760
+
2761
+ this.el = el;
2762
+
2763
+ this.init();
2764
+ }
2765
+
2766
+
2767
+ CivicThemeTable.prototype.init = function () {
2768
+ if (this.el.getAttribute('data-table') === 'true') {
2769
+ return;
2770
+ }
2771
+
2772
+ this.addTitles();
2773
+
2774
+ // Check if the table has the class 'ct-table--data'
2775
+ if (this.el.classList.contains('ct-table--data')) {
2776
+ this.addWrapper();
2777
+ }
2778
+
2779
+ this.el.setAttribute('data-table', 'true');
2780
+ };
2781
+
2782
+ // Add data-title attributes to cells for display on mobile.
2783
+ // TODO: Add titles to cells in rows with row-scoped th cells.
2784
+ // CivicThemeTable.prototype.addRowScopedTitles.
2785
+ // TODO: Add titles to cells in columns with col-scoped th cells.
2786
+ // CivicThemeTable.prototype.addColScopedTitles.
2787
+ CivicThemeTable.prototype.addTitles = function () {
2788
+ this.addTheadColumnTitles();
2789
+ };
2790
+
2791
+ CivicThemeTable.prototype.addWrapper = function () {
2792
+ // Select the target element you want to wrap.
2793
+ const targetElement = this.el;
2794
+ // Create the wrapper element.
2795
+ const wrapper = document.createElement('div');
2796
+ wrapper.classList.add('ct-table--wrapper');
2797
+ // Add attributes to the wrapper
2798
+ wrapper.setAttribute('role', 'region');
2799
+ wrapper.setAttribute('tabindex', '0');
2800
+ // Insert the wrapper before the target element.
2801
+ targetElement.parentNode.insertBefore(wrapper, targetElement);
2802
+ // Move the target element inside the wrapper.
2803
+ wrapper.appendChild(targetElement);
2804
+ };
2805
+
2806
+
2807
+ CivicThemeTable.prototype.addTheadColumnTitles = function () {
2808
+ // Determine whether column titles can be added via thead.
2809
+ const theadRows = this.el.querySelectorAll('thead tr');
2810
+ const tbodyRows = this.el.querySelectorAll('tbody tr');
2811
+ if (!(theadRows.length && tbodyRows.length)) {
2812
+ return;
2813
+ }
2814
+ const theadRow = theadRows[0];
2815
+ const theadCells = theadRow.querySelectorAll('th, td');
2816
+
2817
+ tbodyRows.forEach((tbodyRow) => {
2818
+ const tbodyRowCells = tbodyRow.querySelectorAll('th, td');
2819
+ tbodyRowCells.forEach((tbodyRowCell, index) => {
2820
+ if (!tbodyRowCell.hasAttribute('data-title') && theadCells[index]) {
2821
+ tbodyRowCell.setAttribute('data-title', theadCells[index].textContent);
2822
+ }
2823
+ });
2824
+ });
2825
+ };
2826
+
2827
+ document.querySelectorAll('.ct-basic-content table, .ct-table').forEach((table) => {
2828
+
2829
+ new CivicThemeTable(table);
2830
+ });
2831
+
2832
+ });
2833
+ document.addEventListener('DOMContentLoaded', () => {
2834
+ /**
2835
+ * CivicTheme Chip component.
2836
+ */
2837
+
2838
+ function CivicThemeChip(el) {
2839
+ if (el.getAttribute('data-chip') === 'true') {
2840
+ return;
2841
+ }
2842
+
2843
+ this.el = el;
2844
+ this.groupParentSelector = el.getAttribute('data-chip-group-parent') || null;
2845
+
2846
+ this.el.addEventListener('change', this.changeEvent.bind(this));
2847
+ this.el.addEventListener('focusin', this.focusinEvent.bind(this));
2848
+ this.el.addEventListener('focusout', this.focusoutEvent.bind(this));
2849
+
2850
+ // Mark as initialized.
2851
+ this.el.setAttribute('data-chip', 'true');
2852
+ }
2853
+
2854
+ /**
2855
+ * Toggle the checked value.
2856
+ */
2857
+ CivicThemeChip.prototype.setChecked = function (input, isChecked) {
2858
+ const chip = this.findChip(input);
2859
+ if (chip && !chip.hasAttribute('disabled')) {
2860
+ if (isChecked) {
2861
+ input.setAttribute('checked', 'checked');
2862
+ chip.classList.add('active');
2863
+ } else {
2864
+ input.removeAttribute('checked');
2865
+ chip.classList.remove('active');
2866
+
2867
+ const dismissable = chip.hasAttribute('data-chip-dismiss');
2868
+ if (dismissable && !input.checked) {
2869
+ this.el.dispatchEvent(new CustomEvent('ct.chip.dismiss', { bubbles: true }));
2870
+ }
2871
+ }
2872
+ }
2873
+ };
2874
+
2875
+ /**
2876
+ * Focusin event handler.
2877
+ */
2878
+ CivicThemeChip.prototype.focusinEvent = function (e) {
2879
+ const chip = this.findChip(e.target);
2880
+ if (chip && !chip.hasAttribute('disabled')) {
2881
+ chip.classList.add('focus');
2882
+ }
2883
+ };
2884
+
2885
+ /**
2886
+ * Focusout event handler.
2887
+ */
2888
+ CivicThemeChip.prototype.focusoutEvent = function (e) {
2889
+ const chip = this.findChip(e.target);
2890
+ if (chip) {
2891
+ chip.classList.remove('focus');
2892
+ }
2893
+ };
2894
+
2895
+ /**
2896
+ * Change event handler.
2897
+ */
2898
+ CivicThemeChip.prototype.changeEvent = function (e) {
2899
+ const chip = this.findChip(e.target);
2900
+ if (!chip) {
2901
+ return;
2902
+ }
2903
+
2904
+ const input = chip.querySelector('input');
2905
+ if (!input) {
2906
+ return;
2907
+ }
2908
+
2909
+ // For radios, check current and uncheck others in this group.
2910
+ if (input.getAttribute('type') === 'radio') {
2911
+ const name = input.getAttribute('name');
2912
+ const chipContainer = (!!this.groupParentSelector && chip.closest(this.groupParentSelector)) || document;
2913
+ const radios = chipContainer.querySelectorAll(`input[type=radio][name="${name}"]`);
2914
+ radios.forEach((radio) => {
2915
+ if (radio !== input) {
2916
+ this.setChecked(radio, false);
2917
+ }
2918
+ });
2919
+ this.setChecked(input, true);
2920
+ } else {
2921
+ this.setChecked(input, input.checked);
2922
+ }
2923
+ };
2924
+
2925
+ /**
2926
+ * Find Chip element.
2927
+ */
2928
+ CivicThemeChip.prototype.findChip = function (el) {
2929
+ if (el.classList.contains('ct-chip')) {
2930
+ return el;
2931
+ }
2932
+ return el.closest('.ct-chip');
2933
+ };
2934
+
2935
+ document.querySelectorAll('.ct-chip').forEach((el) => {
2936
+ new CivicThemeChip(el);
2937
+ });
2938
+
2939
+ });
2940
+ document.addEventListener('DOMContentLoaded', () => {
2941
+ /**
2942
+ * CivicTheme Button component.
2943
+ */
2944
+
2945
+ function CivicThemeButton(el) {
2946
+ if (el.getAttribute('data-button') === 'true') {
2947
+ return;
2948
+ }
2949
+
2950
+ this.el = el;
2951
+ this.el.setAttribute('data-button', 'true');
2952
+ this.dismissButton = this.el.querySelector('[data-button-dismiss]');
2953
+ this.keyboardFocused = false;
2954
+
2955
+ this.el.addEventListener('click', this.clickEvent.bind(this));
2956
+ this.el.addEventListener('focusin', this.focusinEvent.bind(this));
2957
+ this.el.addEventListener('focusout', this.focusoutEvent.bind(this));
2958
+
2959
+ document.addEventListener('mousedown', this.mousedownEvent.bind(this));
2960
+ document.addEventListener('keydown', this.keydownEvent.bind(this));
2961
+
2962
+ if (this.dismissButton) {
2963
+ this.dismissButton.addEventListener('click', this.dismissClickEvent.bind(this));
2964
+ }
2965
+ }
2966
+
2967
+ /**
2968
+ * Click event handler.
2969
+ */
2970
+ CivicThemeButton.prototype.clickEvent = function (e) {
2971
+ if (/input/i.test(e.target.tagName)) {
2972
+ let isChecked = false;
2973
+ const input = e.target;
2974
+ if (input.getAttribute('type') === 'checkbox') {
2975
+ isChecked = input.getAttribute('checked');
2976
+ } else if (input.getAttribute('type') === 'radio') {
2977
+ // "Uncheck" all but current radio in this group.
2978
+ const name = input.getAttribute('name');
2979
+ const radios = document.querySelectorAll(`input[type=radio][name="${name}"]`);
2980
+ for (const i in radios) {
2981
+ if (Object.prototype.hasOwnProperty.call(radios, i) && radios[i] !== input) {
2982
+ this.setChecked(radios[i], false);
2983
+ }
2984
+ }
2985
+ } else {
2986
+ return;
2987
+ }
2988
+ this.setChecked(input, !isChecked);
2989
+ }
2990
+ };
2991
+
2992
+ /**
2993
+ * Keydown event handler.
2994
+ */
2995
+ CivicThemeButton.prototype.keydownEvent = function (e) {
2996
+ if (e.key && (e.key === 'Tab' || e.key.indexOf('Arrow') === 0)) {
2997
+ this.keyboardFocused = true;
2998
+ }
2999
+ };
3000
+
3001
+ /**
3002
+ * Keydown event handler.
3003
+ */
3004
+ CivicThemeButton.prototype.mousedownEvent = function () {
3005
+ this.keyboardFocused = false;
3006
+ };
3007
+
3008
+ /**
3009
+ * Set the checked value.
3010
+ */
3011
+ CivicThemeButton.prototype.setChecked = function (input, check) {
3012
+ const button = this.findButton(input);
3013
+ if (button && !button.hasAttribute('disabled')) {
3014
+ if (check) {
3015
+ input.setAttribute('checked', 'checked');
3016
+ button.classList.add('active');
3017
+ } else {
3018
+ input.removeAttribute('checked');
3019
+ button.classList.remove('active');
3020
+ }
3021
+ }
3022
+ };
3023
+
3024
+ /**
3025
+ * Focusin event handler.
3026
+ */
3027
+ CivicThemeButton.prototype.focusinEvent = function (e) {
3028
+ const button = this.findButton(e.target);
3029
+ if (button && !button.hasAttribute('disabled') && this.keyboardFocused) {
3030
+ button.classList.add('focus');
3031
+ }
3032
+ };
3033
+
3034
+ /**
3035
+ * Focusout event handler.
3036
+ */
3037
+ CivicThemeButton.prototype.focusoutEvent = function (e) {
3038
+ const button = this.findButton(e.target);
3039
+ if (button) {
3040
+ button.classList.remove('focus');
3041
+ }
3042
+ };
3043
+
3044
+ /**
3045
+ * Click event handler for dismiss button.
3046
+ */
3047
+ CivicThemeButton.prototype.dismissClickEvent = function (e) {
3048
+ const button = this.findButton(e.target);
3049
+ if (button) {
3050
+ button.remove();
3051
+ this.el.dispatchEvent(new CustomEvent('ct.button.dismiss', { bubbles: true }));
3052
+ }
3053
+ };
3054
+
3055
+ /**
3056
+ * Find button element.
3057
+ */
3058
+ CivicThemeButton.prototype.findButton = function (el) {
3059
+ if (el.classList.contains('ct-button')) {
3060
+ return el;
3061
+ }
3062
+ return el.closest('.ct-button');
3063
+ };
3064
+
3065
+ document.querySelectorAll('.ct-button').forEach((el) => {
3066
+ new CivicThemeButton(el);
3067
+ });
3068
+
3069
+ });
3070
+ document.addEventListener('DOMContentLoaded', () => {
3071
+ /**
3072
+ * @file
3073
+ * Skip to target utility.
3074
+ */
3075
+
3076
+ function CivicThemeSkipToTarget(el) {
3077
+ this.el = el;
3078
+ this.targetId = this.el.getAttribute('href');
3079
+
3080
+ if (this.targetId) {
3081
+ this.targetEl = document.querySelector(this.targetId);
3082
+
3083
+ this.el.addEventListener('click', (e) => {
3084
+ e.preventDefault();
3085
+ e.stopPropagation();
3086
+
3087
+ this.targetEl.setAttribute('tabindex', '1');
3088
+ this.targetEl.focus();
3089
+ this.targetEl.scrollIntoView(true);
3090
+ this.targetEl.setAttribute('tabindex', '-1');
3091
+ });
3092
+ }
3093
+ }
3094
+
3095
+ document.querySelectorAll('[data-skip-to-target]').forEach((el) => {
3096
+ new CivicThemeSkipToTarget(el);
3097
+ });
3098
+
3099
+ });
3100
+ document.addEventListener('DOMContentLoaded', () => {
3101
+ /**
3102
+ * @file
3103
+ * Scrollspy component.
3104
+ *
3105
+ * Adds '.ct-scrollspy-scrolled' class to an element whose
3106
+ * data-scrollspy-offset attribute's value is more than a vertical window
3107
+ * scroll.
3108
+ */
3109
+ function CivicThemeScrollspy(el) {
3110
+ if (el.getAttribute('data-scrollspy') === 'true' || this.el) {
3111
+ return;
3112
+ }
3113
+
3114
+ this.el = el;
3115
+ this.offset = this.el.hasAttribute('data-scrollspy-offset') ? this.el.getAttribute('data-scrollspy-offset') : null;
3116
+
3117
+ document.addEventListener('scroll', CivicThemeScrollspy.prototype.scrollEvent.bind(this));
3118
+
3119
+ // Mark as initialized.
3120
+ this.el.setAttribute('data-scrollspy', 'true');
3121
+ }
3122
+
3123
+ /**
3124
+ * Event handler for the scroll.
3125
+ */
3126
+ CivicThemeScrollspy.prototype.scrollEvent = function () {
3127
+ if (window.scrollY > this.offset) {
3128
+ this.el.classList.add('ct-scrollspy-scrolled');
3129
+ } else {
3130
+ this.el.classList.remove('ct-scrollspy-scrolled');
3131
+ }
3132
+ };
3133
+
3134
+ document.querySelectorAll('[data-scrollspy]').forEach((el) => {
3135
+ new CivicThemeScrollspy(el);
3136
+ });
3137
+
3138
+ });
3139
+ document.addEventListener('DOMContentLoaded', () => {
3140
+ /**
3141
+ * @file
3142
+ * Responsive component.
3143
+ *
3144
+ * Emits a 'ct-responsive' event on breakpoint change allowing
3145
+ * components to delay initialisation by providing 'data-responsive' attribute
3146
+ * with an operator and breakpoint name.
3147
+ *
3148
+ * For example: a component with `data-responsive=">=m"` attribute will
3149
+ * delay its initialisation to happen only when current screen size is equal
3150
+ * or more than medium ('m') breakpoint.
3151
+ */
3152
+ function CivicThemeResponsive() {
3153
+ const queries = this.getMediaQueries();
3154
+ for (const breakpoint in queries) {
3155
+ const query = queries[breakpoint];
3156
+ // Store matched media queries in global scope as this component is a
3157
+ // singleton.
3158
+ window.civicthemeResponsive = window.civicthemeResponsive || {};
3159
+ // Only proceed if this query was not processed previously.
3160
+ if (!(query in window.civicthemeResponsive)) {
3161
+ window.civicthemeResponsive[query] = window.matchMedia(query);
3162
+ // Support for Safari 13.
3163
+ const hasEventListener = (window.civicthemeResponsive[query].addEventListener !== undefined);
3164
+ if (hasEventListener) {
3165
+ window.civicthemeResponsive[query]
3166
+ .addEventListener('change', this.mediaQueryChange.bind(this, breakpoint));
3167
+ } else {
3168
+ window.civicthemeResponsive[query]
3169
+ .addListener(this.mediaQueryChange.bind(this, breakpoint));
3170
+ }
3171
+ }
3172
+ // Call event handler on init.
3173
+ this.mediaQueryChange(breakpoint, { matches: window.civicthemeResponsive[query].matches });
3174
+ }
3175
+ }
3176
+
3177
+ /**
3178
+ * Breakpoints map.
3179
+ */
3180
+ CivicThemeResponsive.prototype.breakpoints = {
3181
+ xxs: '0px',
3182
+ xs: '368px',
3183
+ s: '576px',
3184
+ m: '768px',
3185
+ l: '992px',
3186
+ xl: '1280px',
3187
+ xxl: '1440px',
3188
+ };
3189
+
3190
+ /**
3191
+ * Get an object of media queries.
3192
+ *
3193
+ * @return object
3194
+ * Keys are breakpoint names, and values a media queries.
3195
+ */
3196
+ CivicThemeResponsive.prototype.getMediaQueries = function () {
3197
+ const queries = {};
3198
+
3199
+ const firstBp = Object.keys(this.breakpoints)[0];
3200
+ let lastBp = firstBp;
3201
+ for (const breakpoint in this.breakpoints) {
3202
+ if (breakpoint === firstBp) {
3203
+ continue;
3204
+ }
3205
+ const min = this.breakpoints[lastBp];
3206
+ const max = `${Math.max(parseFloat(this.breakpoints[breakpoint]) - 0.02, 0)}px`;
3207
+ if (lastBp === firstBp) {
3208
+ queries[lastBp] = `screen and (max-width: ${max})`;
3209
+ } else {
3210
+ queries[lastBp] = `screen and (min-width: ${min}) and (max-width: ${max})`;
3211
+ }
3212
+ lastBp = breakpoint;
3213
+ }
3214
+ queries[lastBp] = `screen and (min-width: ${this.breakpoints[lastBp]})`;
3215
+
3216
+ return queries;
3217
+ };
3218
+
3219
+ /**
3220
+ * Event handler for the media query change event.
3221
+ *
3222
+ * @param {string} breakpoint
3223
+ * The breakpoint name for which this event was fired.
3224
+ * @param {Event} evt
3225
+ * The media query change event.
3226
+ */
3227
+ CivicThemeResponsive.prototype.mediaQueryChange = function (breakpoint, evt) {
3228
+ if (!evt.matches) {
3229
+ return;
3230
+ }
3231
+ // Fire a custom event that other components can subscribe to.
3232
+ window.dispatchEvent(new CustomEvent('ct-responsive', {
3233
+ bubbles: true,
3234
+ detail: {
3235
+ breakpoint,
3236
+ evaluate: CivicThemeResponsive.prototype.evaluate,
3237
+ },
3238
+ }));
3239
+ };
3240
+
3241
+ /**
3242
+ * Evaluate breakpoint expression and attach or detach component.
3243
+ *
3244
+ * @param {string} breakpointExpr
3245
+ * The breakpoint expression.
3246
+ * @param {object} func
3247
+ * Function or class constructor.
3248
+ * @param {object} el
3249
+ * Element to be passed to the constructor.
3250
+ *
3251
+ * @return {*}
3252
+ * Attached object or false if expression did not match.
3253
+ */
3254
+ CivicThemeResponsive.prototype.evaluate = function (breakpointExpr, func, el) {
3255
+ if (CivicThemeResponsive.prototype.matchExpr(breakpointExpr, this.breakpoint)) {
3256
+ // eslint-disable-next-line new-cap
3257
+ return new func(el);
3258
+ }
3259
+ if (typeof func.prototype.destroy !== 'undefined') {
3260
+ func.prototype.destroy(el);
3261
+ return true;
3262
+ }
3263
+ return false;
3264
+ };
3265
+
3266
+ /**
3267
+ * Match breakpoint expression to the passed breakpoint.
3268
+ *
3269
+ * Used by the listeners to decide when to respond to a query.
3270
+ *
3271
+ * @param {string} breakpointExpr
3272
+ * The breakpoint expression. E.g. '>=m', '<s' etc.
3273
+ * Supported operators are: <, >, =, >=, <=, <>. Defaults to '>='.
3274
+ * Breakpoint names are matched to the
3275
+ * CivicThemeResponsive.prototype.breakpoints.
3276
+ *
3277
+ * @param {string} breakpoint
3278
+ * Currently active breakpoint.
3279
+ *
3280
+ * @return {boolean}
3281
+ * True if expression matches current breakppint, false otherwise.
3282
+ */
3283
+ CivicThemeResponsive.prototype.matchExpr = function (breakpointExpr, breakpoint) {
3284
+ const names = Object.keys(CivicThemeResponsive.prototype.breakpoints);
3285
+ // Parse breakpoint expression into name and operator.
3286
+ const regex = `^(<|>|=|>=|<=|<>)?(${names.join('|')})$`;
3287
+ const matches = breakpointExpr.match(new RegExp(regex, 'i'));
3288
+
3289
+ // If not matched (malformed expression) or not exactly expected number of
3290
+ // matches - consider as a non-match.
3291
+ if (!matches || matches.length < 2 || matches.length > 3) {
3292
+ return false;
3293
+ }
3294
+
3295
+ // Can be with or without an operator, i.e. '>=m' or 'm'.
3296
+ const parsedOperator = matches[1] || '>=';
3297
+ const parsedBreakpoint = matches[2];
3298
+
3299
+ const compFunctions = {
3300
+ '>': (parsed, current) => names.indexOf(current) > names.indexOf(parsed),
3301
+ '>=': (parsed, current) => names.indexOf(current) >= names.indexOf(parsed),
3302
+ '<': (parsed, current) => names.indexOf(current) < names.indexOf(parsed),
3303
+ '<=': (parsed, current) => names.indexOf(current) <= names.indexOf(parsed),
3304
+ '<>': (parsed, current) => names.indexOf(current) !== names.indexOf(parsed),
3305
+ '=': (parsed, current) => names.indexOf(current) === names.indexOf(parsed),
3306
+ };
3307
+
3308
+ return compFunctions[parsedOperator](parsedBreakpoint, breakpoint);
3309
+ };
3310
+
3311
+ if (document.querySelectorAll('[data-responsive]').length) {
3312
+ // CivicThemeResponsive needs to run after all ct-responisve
3313
+ // event listeners have been added.
3314
+ // Delay the execution until after other components have been initialized.
3315
+ // Using setTimeout as an interim solution because:
3316
+ // - DOMContentLoad won't work on prod-site due to being double wrapped in a
3317
+ // DOMLoad event.
3318
+ // - window 'load' event won't work on storybook as it's not called per
3319
+ // component page change.
3320
+ setTimeout(() => {
3321
+ // Init if there is at least a single component with data-responsive
3322
+ // attribute on the page.
3323
+ new CivicThemeResponsive();
3324
+ }, 10);
3325
+ }
3326
+
3327
+ });
3328
+ document.addEventListener('DOMContentLoaded', () => {
3329
+ /**
3330
+ * @file
3331
+ * Platform utility.
3332
+ */
3333
+
3334
+ function CivicThemePlatform(el) {
3335
+ function iOS() {
3336
+ return [
3337
+ 'iPad Simulator',
3338
+ 'iPhone Simulator',
3339
+ 'iPod Simulator',
3340
+ 'iPad',
3341
+ 'iPhone',
3342
+ 'iPod',
3343
+ ].includes(navigator.platform)
3344
+ // iPad on iOS 13 detection
3345
+ || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
3346
+ }
3347
+
3348
+ if (iOS()) {
3349
+ el.dataset.platform = 'ios';
3350
+ }
3351
+ }
3352
+
3353
+ document.querySelectorAll('[data-platform]').forEach((el) => {
3354
+ new CivicThemePlatform(el);
3355
+ });
3356
+
3357
+ });
3358
+ document.addEventListener('DOMContentLoaded', () => {
3359
+ /**
3360
+ * CivicTheme Layout component.
3361
+ */
3362
+
3363
+ function CivicThemeLayout(el) {
3364
+ this.el = el;
3365
+ this.grid = el.querySelector(':scope > .ct-layout__inner');
3366
+ const gridStyle = getComputedStyle(this.grid);
3367
+
3368
+ if (gridStyle.gridTemplateRows === 'masonry' || this.grid.hasAttribute('data-masonry')) {
3369
+ return;
3370
+ }
3371
+
3372
+ this.grid.setAttribute('data-masonry', true);
3373
+
3374
+ this.stl = this.grid.querySelector(':scope > .ct-layout__sidebar_top_left');
3375
+ this.str = this.grid.querySelector(':scope > .ct-layout__sidebar_top_right');
3376
+ this.sbl = this.grid.querySelector(':scope > .ct-layout__sidebar_bottom_left');
3377
+ this.sbr = this.grid.querySelector(':scope > .ct-layout__sidebar_bottom_right');
3378
+
3379
+ // Only enable masonry if all 4 elements are present.
3380
+ if (this.stl && this.str && this.sbl && this.sbr) {
3381
+ // Prepare redraw variables.
3382
+ this.gap = parseFloat(gridStyle.gridRowGap);
3383
+ // Items include all children of the grid, not just the 4 sidebar regions.
3384
+ this.items = Array.from(this.grid.children);
3385
+ this.height = 0;
3386
+
3387
+ // Listen for redraw events.
3388
+ this.resizeObserver = new ResizeObserver(() => {
3389
+ requestAnimationFrame(() => {
3390
+ this.masonryRedraw();
3391
+ });
3392
+ });
3393
+
3394
+ // Observe all children of the grid items rather than the items themselves:
3395
+ // this allows us to detect changes in the height of the children rather
3396
+ // tnan of the grid items as their height will not change when children
3397
+ // combined heights is less than a single grid row height.
3398
+ this.items.forEach((item) => {
3399
+ Array.from(item.children).forEach((child) => {
3400
+ this.resizeObserver.observe(child);
3401
+ });
3402
+ });
3403
+
3404
+ this.masonryRedraw();
3405
+ }
3406
+ }
3407
+
3408
+ /**
3409
+ * Position element in relation to it's above element.
3410
+ */
3411
+ CivicThemeLayout.prototype.masonryPositionElement = function (el, aboveEl, gap) {
3412
+ const aboveChildIdx = aboveEl.children.length - 1;
3413
+ const aboveChild = (aboveChildIdx >= 0) ? aboveEl.children[aboveChildIdx] : null;
3414
+ const aboveBottom = aboveChild ? aboveChild.getBoundingClientRect().bottom : aboveEl.getBoundingClientRect().top;
3415
+ const currentTop = el.getBoundingClientRect().top;
3416
+ el.style.marginTop = `${aboveBottom + gap - currentTop}px`;
3417
+ };
3418
+
3419
+ /**
3420
+ * Reposition grid elements.
3421
+ */
3422
+ CivicThemeLayout.prototype.masonryRedraw = function () {
3423
+ // Calculate the new height of all children.
3424
+ //
3425
+ // Although masonry layout is applied only if the element has the
3426
+ // CSS variable --js-masonry-enabled set and we could have check for this
3427
+ // variable to preserve height reclaulation, this variable can be assigned
3428
+ // within a specific media query. Therefore, we need to calculate the height
3429
+ // in case --js-masonry-enabled is assigned to the element after the viewport
3430
+ // has been resized.
3431
+ const newHeight = this.items.reduce((totalHeight, item) => {
3432
+ const childrenHeight = Array.from(item.children).reduce((childTotal, child) => childTotal + child.getBoundingClientRect().height, 0);
3433
+ return totalHeight + childrenHeight;
3434
+ }, 0);
3435
+
3436
+ // Proceed only if the height has changed.
3437
+ if (newHeight !== this.height) {
3438
+ this.height = newHeight;
3439
+
3440
+ // Clear existing positioning.
3441
+ this.sbl.style.removeProperty('margin-top');
3442
+ this.sbr.style.removeProperty('margin-top');
3443
+
3444
+ // Set new position (if masonry css has been applied).
3445
+ if (getComputedStyle(this.grid).getPropertyValue('--js-masonry-enabled')) {
3446
+ this.masonryPositionElement(this.sbl, this.stl, this.gap);
3447
+ this.masonryPositionElement(this.sbr, this.str, this.gap);
3448
+ }
3449
+ }
3450
+ };
3451
+
3452
+ document.querySelectorAll('.ct-layout').forEach((layout) => {
3453
+
3454
+ new CivicThemeLayout(layout);
3455
+ });
3456
+
3457
+ });
3458
+ document.addEventListener('DOMContentLoaded', () => {
3459
+ /**
3460
+ * @file
3461
+ * Flyout component.
3462
+ *
3463
+ * Allows introducing "fly out" behaviour to a block-level HTML element on the
3464
+ * page by adding data attributes to elements. The component does not provide
3465
+ * any styles, except for z-index configuration and direction transformations.
3466
+ *
3467
+ * Also, provides a trigger to close a single (currently opened) panel and
3468
+ * another trigger to close all open panels.
3469
+ */
3470
+ function CivicThemeFlyout(el) {
3471
+ if (el.getAttribute('data-flyout') === 'true' || this.el) {
3472
+ return;
3473
+ }
3474
+
3475
+ // Find all open triggers.
3476
+ const openTriggers = document.querySelectorAll('[data-flyout-open-trigger]');
3477
+ if (!openTriggers.length) {
3478
+ return;
3479
+ }
3480
+
3481
+ // Find an open trigger.
3482
+ this.openTrigger = this.findOpenTrigger(openTriggers, el);
3483
+ if (!this.openTrigger) {
3484
+ return;
3485
+ }
3486
+
3487
+ this.el = el;
3488
+
3489
+ // Find "close trigger", but only search among triggers that are not a part
3490
+ // of descendant flyouts.
3491
+ this.closeTriggers = Array.from(this.el.querySelectorAll('[data-flyout-close-trigger]'));
3492
+ this.closeTriggers = this.closeTriggers.filter((item) => (item.closest('[data-flyout]') === this.el));
3493
+
3494
+ this.closeAllTriggers = Array.from(this.el.querySelectorAll('[data-flyout-close-all-trigger]'));
3495
+ this.closeAllTriggers = this.closeAllTriggers.filter((item) => (item.closest('[data-flyout]') === this.el));
3496
+ this.panel = this.el.querySelector('[data-flyout-panel]');
3497
+ this.el.expanded = this.el.hasAttribute('data-flyout-expanded');
3498
+ this.duration = this.el.hasAttribute('data-flyout-duration') ? parseInt(this.el.getAttribute('data-flyout-duration'), 10) : 500;
3499
+ this.focusTargets = this.el.hasAttribute('data-flyout-focus') ? this.el.getAttribute('data-flyout-focus').split(',').filter((i) => i) : [];
3500
+
3501
+ // Add event listener to element.
3502
+ if (this.openTrigger) {
3503
+ this.openTrigger.addEventListener('click', this.clickEvent.bind(this));
3504
+ this.openTrigger.expand = true;
3505
+ }
3506
+
3507
+ if (this.closeTriggers) {
3508
+ this.closeTriggers.forEach((trigger) => {
3509
+ trigger.addEventListener('click', this.clickEvent.bind(this));
3510
+ trigger.expand = false;
3511
+ });
3512
+ }
3513
+
3514
+ if (this.closeAllTriggers) {
3515
+ this.closeAllTriggers.forEach((trigger) => {
3516
+ trigger.addEventListener('click', this.closeAllTriggerClickEvent.bind(this));
3517
+ });
3518
+ }
3519
+
3520
+ document.addEventListener('keydown', (event) => {
3521
+ if (event.key === 'Tab') {
3522
+ const flyoutElements = document.querySelectorAll('[data-flyout]');
3523
+ flyoutElements.forEach((flyout) => {
3524
+ const focusableElements = flyout.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
3525
+ const firstFocusable = focusableElements[0];
3526
+ const lastFocusable = focusableElements[focusableElements.length - 1];
3527
+ if (document.activeElement === lastFocusable && !event.shiftKey) {
3528
+ event.preventDefault();
3529
+ firstFocusable.focus();
3530
+ } else if (document.activeElement === firstFocusable && event.shiftKey) {
3531
+ event.preventDefault();
3532
+ lastFocusable.focus();
3533
+ }
3534
+ });
3535
+ }
3536
+ });
3537
+
3538
+ // Mark as initialized.
3539
+ this.el.setAttribute('data-flyout', 'true');
3540
+ }
3541
+
3542
+ /**
3543
+ * Find open trigger for the given flyout among provided triggers.
3544
+ */
3545
+ CivicThemeFlyout.prototype.findOpenTrigger = function (triggers, el) {
3546
+ // Find a trigger for the current flyout.
3547
+ for (const i in triggers) {
3548
+ if (Object.prototype.hasOwnProperty.call(triggers, i)) {
3549
+ if (triggers[i].hasAttribute('data-flyout-target')) {
3550
+ const found = document.querySelector(triggers[i].getAttribute('data-flyout-target'));
3551
+ if (found === el) {
3552
+ return triggers[i];
3553
+ }
3554
+ } else if (triggers[i].nextElementSibling && triggers[i].nextElementSibling.hasAttribute('data-flyout')) {
3555
+ // Try to get from the next element.
3556
+ const found = triggers[i].nextElementSibling;
3557
+ if (found === el) {
3558
+ return triggers[i];
3559
+ }
3560
+ }
3561
+ }
3562
+ }
3563
+ return null;
3564
+ };
3565
+
3566
+ /**
3567
+ * Click event handler to toggle flyout state.
3568
+ */
3569
+ CivicThemeFlyout.prototype.clickEvent = function (e) {
3570
+ e.stopPropagation();
3571
+ if (e.target.hasAttribute('data-flyout-trigger-allow-default') !== true) {
3572
+ e.preventDefault();
3573
+ }
3574
+
3575
+ return e.currentTarget.expand ? this.expand() : this.collapse();
3576
+ };
3577
+
3578
+ /**
3579
+ * Event handler to close all flyout components.
3580
+ */
3581
+ CivicThemeFlyout.prototype.closeAllTriggerClickEvent = function (e) {
3582
+ e.stopPropagation();
3583
+ if (e.target.hasAttribute('data-flyout-trigger-allow-default') !== true) {
3584
+ e.preventDefault();
3585
+ }
3586
+
3587
+ // Collapse all panels.
3588
+ document.querySelectorAll('[data-flyout-expanded]').forEach((flyout) => {
3589
+ flyout.removeAttribute('data-flyout-expanded');
3590
+ });
3591
+ document.querySelectorAll('[data-flyout-panel]').forEach((panel) => {
3592
+ panel.setAttribute('aria-hidden', true);
3593
+ const duration = panel.parentNode.hasAttribute('data-flyout-duration') ? parseInt(panel.parentNode.getAttribute('data-flyout-duration'), 10) : 500;
3594
+ setTimeout(() => {
3595
+ panel.style.visibility = null;
3596
+ document.body.style.overflow = null;
3597
+ }, duration);
3598
+ });
3599
+ document.querySelectorAll('[data-flyout-open-trigger]').forEach((trigger) => {
3600
+ trigger.setAttribute('aria-expanded', false);
3601
+ });
3602
+
3603
+ if (this.focusTargets) {
3604
+ // Focus on the first trigger.
3605
+ setTimeout(() => {
3606
+ document.querySelector('[data-flyout-open-trigger]').focus();
3607
+ }, this.duration);
3608
+ }
3609
+ };
3610
+
3611
+ /**
3612
+ * Expand flyout.
3613
+ */
3614
+ CivicThemeFlyout.prototype.expand = function () {
3615
+ this.el.expanded = true;
3616
+ this.openTrigger.setAttribute('aria-expanded', true);
3617
+ this.panel.style.visibility = 'visible';
3618
+
3619
+ // Add required classes.
3620
+ this.el.setAttribute('data-flyout-expanded', true);
3621
+ this.panel.setAttribute('aria-hidden', false);
3622
+ document.body.style.overflow = 'hidden';
3623
+
3624
+ if (this.focusTargets) {
3625
+ // Focus on the first available target or close button.
3626
+ const focusTargets = [
3627
+ ...this.focusTargets,
3628
+ '[data-flyout-close-trigger]',
3629
+ '[data-flyout-close-all-trigger]',
3630
+ ];
3631
+
3632
+ for (let i = 0; i < focusTargets.length; i++) {
3633
+ let focusElements = Array.from(this.panel.querySelectorAll(focusTargets[i]));
3634
+ // Filter to only focus points found in this panel.
3635
+ focusElements = focusElements.filter((el) => (el.closest('[data-flyout-panel]') === this.panel));
3636
+ if (focusElements.length > 0) {
3637
+ setTimeout(() => focusElements[0].focus(), this.duration);
3638
+ break;
3639
+ }
3640
+ }
3641
+ }
3642
+ };
3643
+
3644
+ /**
3645
+ * Collapse flyout.
3646
+ */
3647
+ CivicThemeFlyout.prototype.collapse = function () {
3648
+ this.el.expanded = false;
3649
+ this.openTrigger.setAttribute('aria-expanded', false);
3650
+ this.el.removeAttribute('data-flyout-expanded');
3651
+ this.panel.setAttribute('aria-hidden', true);
3652
+ setTimeout(() => {
3653
+ this.panel.style.visibility = null;
3654
+ document.body.style.overflow = null;
3655
+ if (this.focusTargets) {
3656
+ this.openTrigger.focus();
3657
+ }
3658
+ }, this.duration);
3659
+ };
3660
+
3661
+ // Initialize CivicThemeFlyout on every element.
3662
+ document.querySelectorAll('[data-flyout]').forEach((flyout) => {
3663
+
3664
+ new CivicThemeFlyout(flyout);
3665
+ });
3666
+
3667
+ });
3668
+ document.addEventListener('DOMContentLoaded', () => {
3669
+ /**
3670
+ * @file
3671
+ * Collapsible component.
3672
+ *
3673
+ * Attaches to markup with 'data-collapsible' attribute.
3674
+ * Available attributes:
3675
+ * - data-collapsible-trigger - trigger for the collapsible. If not provided,
3676
+ * then the first descendant will be used.
3677
+ * - data-collapsible-panel - panel for the collapsible. If not provided,
3678
+ * then the second descendant will be used.
3679
+ * - data-collapsible-collapsed - indicate that a starting state is collapsed.
3680
+ * - data-collapsible-duration - duration in milliseconds. Defaults to 500.
3681
+ * - data-collapsible-group-enabled-breakpoint - enable grouping at breakpoint.
3682
+ * Needs 'data-responsive' attribute.
3683
+ */
3684
+ function CivicThemeCollapsible(el) {
3685
+ // Use "data-collapsible"'s attribute value to identify if this component was
3686
+ // already initialised.
3687
+ if (el.getAttribute('data-collapsible') === 'true' || this.el) {
3688
+ return;
3689
+ }
3690
+
3691
+ const trigger = this.getTrigger(el);
3692
+ const panel = this.getPanel(el);
3693
+
3694
+ // Exit early if trigger or panel were not found.
3695
+ if (!trigger || !panel) {
3696
+ return;
3697
+ }
3698
+
3699
+ this.el = el;
3700
+ this.trigger = trigger;
3701
+ this.panel = panel;
3702
+ this.collapsed = this.isCollapsed(el);
3703
+ this.duration = this.el.hasAttribute('data-collapsible-duration') ? this.el.getAttribute('data-collapsible-duration') : 500;
3704
+ this.group = this.el.hasAttribute('data-collapsible-group') ? this.el.getAttribute('data-collapsible-group') : null;
3705
+ this.icon = '<svg class="ct-icon" width="24" height="24" aria-hidden="true" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.6072 8.38619C18.3583 8.13884 18.0217 8 17.6709 8C17.32 8 16.9834 8.13884 16.7346 8.38619L11.9668 13.0876L7.26542 8.38619C7.01659 8.13884 6.67999 8 6.32913 8C5.97827 8 5.64167 8.13884 5.39284 8.38619C5.26836 8.50965 5.16956 8.65654 5.10214 8.81838C5.03471 8.98022 5 9.1538 5 9.32912C5 9.50445 5.03471 9.67803 5.10214 9.83987C5.16956 10.0017 5.26836 10.1486 5.39284 10.2721L11.0239 15.9031C11.1473 16.0276 11.2942 16.1264 11.4561 16.1938C11.6179 16.2612 11.7915 16.2959 11.9668 16.2959C12.1421 16.2959 12.3157 16.2612 12.4775 16.1938C12.6394 16.1264 12.7863 16.0276 12.9097 15.9031L18.6072 10.2721C18.7316 10.1486 18.8304 10.0017 18.8979 9.83987C18.9653 9.67803 19 9.50445 19 9.32912C19 9.1538 18.9653 8.98022 18.8979 8.81838C18.8304 8.65654 18.7316 8.50965 18.6072 8.38619Z" /></svg>';
3706
+ this.iconGroupEnabled = this.el.hasAttribute('data-collapsible-icon-group');
3707
+
3708
+ // Make sure that both trigger and a panel have required attributes set.
3709
+ this.trigger.setAttribute('data-collapsible-trigger', '');
3710
+ this.panel.setAttribute('data-collapsible-panel', '');
3711
+
3712
+ if (!this.panel.hasAttribute('data-collapsible-trigger-no-icon') && !this.trigger.querySelector('.ct-collapsible__icon')) {
3713
+ const iconEl = this.htmlToElement(this.icon);
3714
+ iconEl.classList.add('ct-collapsible__icon');
3715
+ // If multiple words - use last word and icon grouping.
3716
+ if (this.iconGroupEnabled) {
3717
+ const wrapText = (text) => `<span class="ct-text-icon__text">${text}</span>`;
3718
+ const text = this.trigger.innerText.trim();
3719
+ const lastWordIndex = text.lastIndexOf(' ');
3720
+ const lastWord = lastWordIndex >= 0 ? text.substring(lastWordIndex + 1) : text;
3721
+ const firstWords = lastWordIndex >= 0 ? text.substring(0, lastWordIndex + 1) : '';
3722
+ const iconGroupEl = this.htmlToElement(`<span class="ct-text-icon__group">${wrapText(lastWord)} </span>`);
3723
+ iconGroupEl.append(iconEl);
3724
+ this.trigger.innerHTML = wrapText(firstWords);
3725
+ this.trigger.append(iconGroupEl);
3726
+ } else {
3727
+ this.trigger.append(iconEl);
3728
+ }
3729
+ }
3730
+
3731
+ // Attach event listener.
3732
+ this.trigger.addEventListener('click', this.clickEvent.bind(this));
3733
+ this.trigger.addEventListener('keydown', this.keydownEvent.bind(this.trigger));
3734
+ this.trigger.addEventListener('focusout', this.focusoutEvent.bind(this));
3735
+ this.panel.addEventListener('click', (e) => e.stopPropagation());
3736
+ this.panel.addEventListener('focusout', this.focusoutEvent.bind(this));
3737
+
3738
+ // Set components to their collapsed / expanded state.
3739
+ if (this.collapsed) {
3740
+ this.setCollapsedState.call(this);
3741
+ } else {
3742
+ this.setExpandedState.call(this);
3743
+ }
3744
+
3745
+ this.el.addEventListener('ct.collapsible.collapse', (evt) => {
3746
+ // For some cases (like group collapse) - the animation should be disabled.
3747
+ const animate = (evt.detail && evt.detail.animate);
3748
+ const isCloseAllEvent = (evt.detail && evt.detail.closeAll);
3749
+ if ((isCloseAllEvent && this.isGroupsEnabled) || !isCloseAllEvent) {
3750
+ this.collapse(animate, evt);
3751
+ }
3752
+ });
3753
+
3754
+ this.el.addEventListener('ct.collapsible.expand', () => {
3755
+ this.expand(true);
3756
+ });
3757
+
3758
+ this.el.addEventListener('ct.collapsible.toggle', () => {
3759
+ if (this.isCollapsed(this.el)) {
3760
+ this.el.dispatchEvent(new CustomEvent('ct.collapsible.expand', { bubbles: true }));
3761
+ } else {
3762
+ this.el.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { animate: true } }));
3763
+ }
3764
+ });
3765
+
3766
+ // Attach global keydown event listener to allow closing all collapsibles.
3767
+ document.addEventListener('keydown', CivicThemeCollapsible.prototype.keydownEvent);
3768
+ document.addEventListener('click', CivicThemeCollapsible.prototype.collapseAllGroups);
3769
+
3770
+ // Responsive Collapsible Group.
3771
+ this.isGroupsEnabled = true;
3772
+ this.groupEnabledBreakpoint = this.el.getAttribute('data-collapsible-group-enabled-breakpoint');
3773
+ if (this.groupEnabledBreakpoint) {
3774
+ window.addEventListener('ct-responsive', (evt) => {
3775
+ const evaluationResult = evt.detail.evaluate(this.groupEnabledBreakpoint, () => {
3776
+ // Is within breakpoint.
3777
+ this.isGroupsEnabled = true;
3778
+ });
3779
+ if (evaluationResult === false) {
3780
+ // Not within breakpoint.
3781
+ this.isGroupsEnabled = false;
3782
+ }
3783
+ }, false);
3784
+ }
3785
+
3786
+ // Mark as initialized.
3787
+ this.el.setAttribute('data-collapsible', 'true');
3788
+ }
3789
+
3790
+ /**
3791
+ * Destroy an instance.
3792
+ */
3793
+ CivicThemeCollapsible.prototype.destroy = function (el) {
3794
+ if (el.getAttribute('data-collapsible') !== 'true' || !this.el) {
3795
+ return;
3796
+ }
3797
+ const trigger = el.querySelector('[data-collapsible-trigger]') || el.firstElementChild;
3798
+ const panel = el.querySelector('[data-collapsible-panel]') || el.firstElementChild.nextElementSibling;
3799
+
3800
+ // Exit early if trigger or panel were not found.
3801
+ if (!trigger || !panel) {
3802
+ return;
3803
+ }
3804
+
3805
+ this.el = el;
3806
+ this.trigger = trigger;
3807
+ this.panel = panel;
3808
+
3809
+ // Remove any attached event listeners.
3810
+ // eslint-disable-next-line no-self-assign
3811
+ this.trigger.outerHTML = this.trigger.outerHTML;
3812
+ // Remove inline overrides.
3813
+ this.panel.style.height = '';
3814
+ this.panel.style.overflow = '';
3815
+
3816
+ this.trigger.removeAttribute('aria-expanded');
3817
+ this.panel.removeAttribute('aria-hidden');
3818
+
3819
+ // Mark as non-initialized.
3820
+ this.el.setAttribute('data-collapsible', '');
3821
+
3822
+ delete this.el;
3823
+ delete this.trigger;
3824
+ delete this.panel;
3825
+ delete this.collapsed;
3826
+ delete this.duration;
3827
+ delete this.group;
3828
+ };
3829
+
3830
+ /**
3831
+ * Click event handler.
3832
+ */
3833
+ CivicThemeCollapsible.prototype.clickEvent = function (e) {
3834
+ e.stopPropagation();
3835
+ e.preventDefault();
3836
+ e.stopImmediatePropagation();
3837
+
3838
+ if (this.group) {
3839
+ this.closeGroup(this.group);
3840
+ }
3841
+
3842
+ if (this.collapsed) {
3843
+ this.el.dispatchEvent(new CustomEvent('ct.collapsible.expand', { bubbles: true }));
3844
+ } else {
3845
+ this.el.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { animate: true } }));
3846
+ }
3847
+ };
3848
+
3849
+ /**
3850
+ * Focusout event handler.
3851
+ */
3852
+ CivicThemeCollapsible.prototype.focusoutEvent = function (e) {
3853
+ // Close when trigger or panel leaves a focus, but only for grouped ones.
3854
+ if (
3855
+ e.relatedTarget
3856
+ && !this.panel.contains(e.relatedTarget)
3857
+ && !this.trigger.contains(e.relatedTarget)
3858
+ && this.group
3859
+ && this.isGroupsEnabled
3860
+ ) {
3861
+ e.target.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true }));
3862
+ }
3863
+ };
3864
+
3865
+ /**
3866
+ * React on pressed keys.
3867
+ */
3868
+ CivicThemeCollapsible.prototype.keydownEvent = function (e) {
3869
+ if (!/(32|27|37|38|39|40)/.test(e.which) || e.altKey || e.ctrlKey || e.metaKey || /input|textarea|select|object/i.test(e.target.tagName)) {
3870
+ return;
3871
+ }
3872
+
3873
+ e.stopPropagation();
3874
+
3875
+ // ESC.
3876
+ if (e.which === 27) {
3877
+ CivicThemeCollapsible.prototype.collapseAllGroups();
3878
+ return;
3879
+ }
3880
+
3881
+ if (this !== document) {
3882
+ if ((e.which === 38 || e.which === 40 || e.which === 32) && !e.shiftKey) {
3883
+ e.preventDefault();
3884
+ }
3885
+ // Up or Left.
3886
+ if ((e.which === 38 || e.which === 37) && !e.shiftKey) {
3887
+ this.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { animate: true, keydown: true } }));
3888
+ return;
3889
+ }
3890
+ // Down or Right.
3891
+ if ((e.which === 40 || e.which === 39) && !e.shiftKey) {
3892
+ this.dispatchEvent(new CustomEvent('ct.collapsible.expand', { bubbles: true }));
3893
+ }
3894
+
3895
+ // Space.
3896
+ if (e.which === 32) {
3897
+ e.target.click();
3898
+ }
3899
+ }
3900
+ };
3901
+
3902
+ /**
3903
+ * Close "other" instances in the group.
3904
+ */
3905
+ CivicThemeCollapsible.prototype.closeGroup = function (group) {
3906
+ if (this.isGroupsEnabled) {
3907
+ const currentEl = this.el;
3908
+ // eslint-disable-next-line prefer-template
3909
+ document.querySelectorAll('[data-collapsible-group=' + group + ']:not([data-collapsible-collapsed])').forEach((el) => {
3910
+ if (el !== currentEl) {
3911
+ el.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { closeGroup: true } }));
3912
+ }
3913
+ });
3914
+ }
3915
+ };
3916
+
3917
+ /**
3918
+ * Close all grouped instances on the page.
3919
+ */
3920
+ CivicThemeCollapsible.prototype.collapseAllGroups = function () {
3921
+ document.querySelectorAll('[data-collapsible-group]').forEach((el) => {
3922
+ el.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { closeAll: true } }));
3923
+ });
3924
+ };
3925
+
3926
+ /**
3927
+ * Set elements to their collapsed state.
3928
+ */
3929
+ CivicThemeCollapsible.prototype.setCollapsedState = function () {
3930
+ this.panel.style.transition = '';
3931
+ this.panel.style.overflow = 'hidden';
3932
+ this.panel.style.display = 'none';
3933
+ this.el.setAttribute('data-collapsible-collapsed', '');
3934
+ this.trigger.setAttribute('data-collapsible-trigger-collapsed', '');
3935
+ this.panel.setAttribute('aria-hidden', true);
3936
+ this.trigger.setAttribute('aria-expanded', false);
3937
+ this.collapsed = true;
3938
+ };
3939
+
3940
+ /**
3941
+ * Collapse panel.
3942
+ *
3943
+ * @param {boolean} animate
3944
+ * Flag to collapse with animation.
3945
+ */
3946
+ CivicThemeCollapsible.prototype.collapse = function (animate, evt) {
3947
+ const t = this;
3948
+
3949
+ if (this.isCollapsed(t.el)) {
3950
+ return;
3951
+ }
3952
+
3953
+ if (evt && evt.target) {
3954
+ if (evt.detail && evt.detail.keydown && !evt.detail.closeGroup) {
3955
+ if (evt.target.closest('[data-collapsible="true"]') !== t.el) {
3956
+ return;
3957
+ }
3958
+ } else if (evt.currentTarget !== t.el || evt.target !== t.el) {
3959
+ return;
3960
+ }
3961
+ }
3962
+
3963
+ const onTransitionEnd = function () {
3964
+ // Remove the event listener straight away.
3965
+
3966
+ t.panel.removeEventListener('transitionend', onTransitionEnd);
3967
+ // Remove progress state.
3968
+ t.el.removeAttribute('data-collapsible-collapsing');
3969
+ t.trigger.removeAttribute('data-collapsible-trigger-collapsing');
3970
+ // Set all required attributes.
3971
+ t.setCollapsedState.call(t);
3972
+ };
3973
+
3974
+ if (animate && t.duration > 0) {
3975
+ // Support already set transitions.
3976
+ const transition = t.panel.style.transition || `height ${t.duration}ms ease-out`;
3977
+ // Reset transition and set overflow before animation starts.
3978
+ t.panel.style.transition = '';
3979
+ t.panel.style.overflow = 'hidden';
3980
+ // Get height before animation starts.
3981
+ const h = t.panel.scrollHeight;
3982
+ requestAnimationFrame(() => {
3983
+ // Prepare for animation by setting initial values.
3984
+ t.panel.style.transition = transition;
3985
+ t.panel.style.height = `${h}px`;
3986
+ // Set progress state.
3987
+ t.el.setAttribute('data-collapsible-collapsing', '');
3988
+ t.trigger.setAttribute('data-collapsible-trigger-collapsing', '');
3989
+ requestAnimationFrame(() => {
3990
+ // Register an event listener to fire at the end of the transition.
3991
+ t.panel.addEventListener('transitionend', onTransitionEnd);
3992
+ // Finally, change the height, triggering the transition.
3993
+ t.panel.style.height = '0px';
3994
+ });
3995
+ });
3996
+ } else {
3997
+ // Store current transition before it will be reset.
3998
+ const transition = t.panel.style;
3999
+ t.setCollapsedState.call(t);
4000
+ // Restore transition.
4001
+ t.panel.style.transition = transition;
4002
+ }
4003
+ };
4004
+
4005
+ /**
4006
+ * Set elements to their expanded state.
4007
+ */
4008
+ CivicThemeCollapsible.prototype.setExpandedState = function () {
4009
+ this.panel.style.transition = '';
4010
+ this.panel.style.overflow = '';
4011
+ this.panel.style.height = '';
4012
+ this.panel.style.display = '';
4013
+ this.panel.setAttribute('aria-hidden', false);
4014
+ this.trigger.setAttribute('aria-expanded', true);
4015
+ this.el.removeAttribute('data-collapsible-collapsed');
4016
+ this.trigger.removeAttribute('data-collapsible-trigger-collapsed');
4017
+ this.collapsed = false;
4018
+ };
4019
+
4020
+ /**
4021
+ * Expand panel.
4022
+ *
4023
+ * @param {boolean} animate
4024
+ * Flag to expand with animation.
4025
+ */
4026
+ CivicThemeCollapsible.prototype.expand = function (animate) {
4027
+ const t = this;
4028
+
4029
+ if (!this.isCollapsed(t.el)) {
4030
+ return;
4031
+ }
4032
+
4033
+ const onTransitionEnd = function () {
4034
+ // Remove the event listener straight away.
4035
+
4036
+ t.panel.removeEventListener('transitionend', onTransitionEnd);
4037
+ // Set all required attributes.
4038
+ t.setExpandedState.call(t);
4039
+ // Remove progress state.
4040
+ t.el.removeAttribute('data-collapsible-collapsing');
4041
+ t.trigger.removeAttribute('data-collapsible-trigger-collapsing');
4042
+ };
4043
+
4044
+ if (animate && t.duration > 0) {
4045
+ // Get height before animation starts.
4046
+ t.panel.style.display = '';
4047
+ t.panel.style.height = '';
4048
+ const h = t.panel.scrollHeight;
4049
+
4050
+ // Set progress state.
4051
+ t.el.setAttribute('data-collapsible-collapsing', '');
4052
+ t.trigger.setAttribute('data-collapsible-trigger-collapsing', '');
4053
+ t.panel.style.height = '0px';
4054
+ requestAnimationFrame(() => {
4055
+ // Prepare for animation by setting initial values.
4056
+ t.panel.style.transition = t.panel.style.transition || `height ${t.duration}ms ease-out`;
4057
+
4058
+ requestAnimationFrame(() => {
4059
+ // Register an event listener to fire at the end of the transition.
4060
+ t.panel.addEventListener('transitionend', onTransitionEnd);
4061
+ // Finally, change the height, triggering the transition.
4062
+ t.panel.style.height = `${h}px`;
4063
+ });
4064
+ });
4065
+ } else {
4066
+ const transition = t.panel.style;
4067
+ t.setExpandedState.call(t);
4068
+ t.panel.style.transition = transition;
4069
+ }
4070
+ };
4071
+
4072
+ /**
4073
+ * Check if the collapsible is collapsed.
4074
+ */
4075
+ CivicThemeCollapsible.prototype.isCollapsed = function (el) {
4076
+ return el.hasAttribute('data-collapsible-collapsed');
4077
+ };
4078
+
4079
+ /**
4080
+ * Get trigger element.
4081
+ */
4082
+ CivicThemeCollapsible.prototype.getTrigger = function (el) {
4083
+ return el.querySelector('[data-collapsible-trigger]') || el.firstElementChild || null;
4084
+ };
4085
+
4086
+ /**
4087
+ * Get panel element.
4088
+ */
4089
+ CivicThemeCollapsible.prototype.getPanel = function (el) {
4090
+ let panelEl = el.querySelector('[data-collapsible-panel]');
4091
+ if (!panelEl) {
4092
+ const triggerEl = this.getTrigger(el);
4093
+ if (triggerEl) {
4094
+ panelEl = triggerEl.nextElementSibling;
4095
+ }
4096
+ }
4097
+ return panelEl;
4098
+ };
4099
+
4100
+ /**
4101
+ * Convert HTML to a DOM element.
4102
+ */
4103
+ CivicThemeCollapsible.prototype.htmlToElement = function (html) {
4104
+ const template = document.createElement('template');
4105
+ template.innerHTML = html.trim();
4106
+ return template.content.firstChild;
4107
+ };
4108
+
4109
+ document.querySelectorAll('[data-collapsible]').forEach((el) => {
4110
+ // Delay initialisation if should be responsive.
4111
+ const breakpointExpr = el.getAttribute('data-responsive');
4112
+ if (breakpointExpr) {
4113
+ window.addEventListener('ct-responsive', (evt) => {
4114
+ evt.detail.evaluate(breakpointExpr, CivicThemeCollapsible, el);
4115
+ }, false);
4116
+ return;
4117
+ }
4118
+
4119
+ new CivicThemeCollapsible(el);
4120
+ });
4121
+
4122
+ });