@govtechsg/sgds-web-component 3.0.0-rc.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/Masthead/index.js +2 -2
  2. package/README.md +2 -2
  3. package/base/button.js +1 -1
  4. package/base/card-element.d.ts +0 -3
  5. package/base/card-element.js +0 -3
  6. package/base/card-element.js.map +1 -1
  7. package/base/card.js +1 -1
  8. package/base/sgds-element2.js +1 -1
  9. package/components/Accordion/accordion-item.js +1 -1
  10. package/components/Accordion/accordion.js +1 -1
  11. package/components/Accordion/index.umd.js +137 -145
  12. package/components/Accordion/index.umd.js.map +1 -1
  13. package/components/Accordion/sgds-accordion-item.js +1 -5
  14. package/components/Accordion/sgds-accordion-item.js.map +1 -1
  15. package/components/Accordion/sgds-accordion.js +1 -6
  16. package/components/Accordion/sgds-accordion.js.map +1 -1
  17. package/components/Alert/alert.js +1 -1
  18. package/components/Alert/index.umd.js +3 -3
  19. package/components/Badge/badge.js +1 -1
  20. package/components/Badge/index.umd.js +3 -3
  21. package/components/Breadcrumb/breadcrumb-item.js +1 -1
  22. package/components/Breadcrumb/index.umd.js +19 -7
  23. package/components/Breadcrumb/index.umd.js.map +1 -1
  24. package/components/Button/button.js +1 -1
  25. package/components/Button/index.umd.js +3 -3
  26. package/components/Card/card.js +1 -1
  27. package/components/Card/index.umd.js +6 -9
  28. package/components/Card/index.umd.js.map +1 -1
  29. package/components/Card/sgds-card.d.ts +3 -3
  30. package/components/Card/sgds-card.js +3 -3
  31. package/components/Card/sgds-card.js.map +1 -1
  32. package/components/Checkbox/checkbox.js +1 -1
  33. package/components/Checkbox/index.umd.js +3 -3
  34. package/components/ComboBox/combo-box-item2.js +1 -1
  35. package/components/ComboBox/combo-box.js +1 -1
  36. package/components/ComboBox/index.umd.js +14 -9
  37. package/components/ComboBox/index.umd.js.map +1 -1
  38. package/components/ComboBox/sgds-combo-box.d.ts +6 -1
  39. package/components/ComboBox/sgds-combo-box.js +6 -1
  40. package/components/ComboBox/sgds-combo-box.js.map +1 -1
  41. package/components/Datepicker/datepicker-calendar2.js +1 -1
  42. package/components/Datepicker/datepicker.js +1 -1
  43. package/components/Datepicker/index.umd.js +9 -9
  44. package/components/DescriptionList/description-list-group.js +1 -1
  45. package/components/DescriptionList/description-list.js +1 -1
  46. package/components/DescriptionList/index.umd.js +18 -20
  47. package/components/DescriptionList/index.umd.js.map +1 -1
  48. package/components/DescriptionList/sgds-description-list-group.d.ts +1 -1
  49. package/components/DescriptionList/sgds-description-list-group.js +11 -11
  50. package/components/DescriptionList/sgds-description-list-group.js.map +1 -1
  51. package/components/DescriptionList/sgds-description-list.js +4 -6
  52. package/components/DescriptionList/sgds-description-list.js.map +1 -1
  53. package/components/Divider/divider.js +1 -1
  54. package/components/Divider/index.umd.js +2 -2
  55. package/components/Drawer/drawer.js +1 -1
  56. package/components/Drawer/index.umd.js +31 -136
  57. package/components/Drawer/index.umd.js.map +1 -1
  58. package/components/Drawer/sgds-drawer.d.ts +3 -32
  59. package/components/Drawer/sgds-drawer.js +16 -73
  60. package/components/Drawer/sgds-drawer.js.map +1 -1
  61. package/components/Dropdown/dropdown-item.js +1 -1
  62. package/components/Dropdown/dropdown-menu.js +1 -1
  63. package/components/Dropdown/index.umd.js +3 -3
  64. package/components/Dropdown/index.umd.js.map +1 -1
  65. package/components/Dropdown/sgds-dropdown-item.d.ts +2 -1
  66. package/components/Dropdown/sgds-dropdown-item.js.map +1 -1
  67. package/components/FileUpload/file-upload.js +1 -1
  68. package/components/FileUpload/index.umd.js +8 -8
  69. package/components/FileUpload/index.umd.js.map +1 -1
  70. package/components/FileUpload/sgds-file-upload.js +2 -2
  71. package/components/FileUpload/sgds-file-upload.js.map +1 -1
  72. package/components/Footer/footer-item.js +1 -1
  73. package/components/Footer/footer.js +1 -1
  74. package/components/Footer/index.umd.js +3 -3
  75. package/components/Icon/index.umd.js +1 -1
  76. package/components/IconButton/index.umd.js +2 -2
  77. package/components/IconList/index.umd.js +1 -1
  78. package/components/Input/index.umd.js +4 -4
  79. package/components/Input/input.js +1 -1
  80. package/components/Link/index.umd.js +15 -3
  81. package/components/Link/index.umd.js.map +1 -1
  82. package/components/Link/link.js +1 -1
  83. package/components/Link/sgds-link.d.ts +2 -1
  84. package/components/Link/sgds-link.js +13 -1
  85. package/components/Link/sgds-link.js.map +1 -1
  86. package/components/Mainnav/index.umd.js +74 -93
  87. package/components/Mainnav/index.umd.js.map +1 -1
  88. package/components/Mainnav/mainnav-dropdown.js +1 -1
  89. package/components/Mainnav/mainnav-item.js +1 -1
  90. package/components/Mainnav/mainnav.js +1 -1
  91. package/components/Mainnav/sgds-mainnav-dropdown.d.ts +1 -4
  92. package/components/Mainnav/sgds-mainnav-dropdown.js +24 -37
  93. package/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
  94. package/components/Mainnav/sgds-mainnav-item.d.ts +9 -2
  95. package/components/Mainnav/sgds-mainnav-item.js +58 -3
  96. package/components/Mainnav/sgds-mainnav-item.js.map +1 -1
  97. package/components/Mainnav/sgds-mainnav.js +7 -6
  98. package/components/Mainnav/sgds-mainnav.js.map +1 -1
  99. package/components/Masthead/index.umd.js +2 -2
  100. package/components/Masthead/masthead.js +1 -1
  101. package/components/Modal/index.umd.js +3 -3
  102. package/components/Modal/modal.js +1 -1
  103. package/components/Pagination/index.umd.js +4 -4
  104. package/components/Pagination/pagination.js +1 -1
  105. package/components/ProgressBar/index.umd.js +3 -3
  106. package/components/ProgressBar/index.umd.js.map +1 -1
  107. package/components/ProgressBar/progress-bar.js +1 -1
  108. package/components/ProgressBar/sgds-progress-bar.d.ts +1 -1
  109. package/components/ProgressBar/sgds-progress-bar.js +1 -1
  110. package/components/ProgressBar/sgds-progress-bar.js.map +1 -1
  111. package/components/QuantityToggle/index.umd.js +5 -10
  112. package/components/QuantityToggle/index.umd.js.map +1 -1
  113. package/components/QuantityToggle/sgds-quantity-toggle.d.ts +0 -2
  114. package/components/QuantityToggle/sgds-quantity-toggle.js +0 -5
  115. package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  116. package/components/Radio/index.umd.js +3 -3
  117. package/components/Radio/radio.js +1 -1
  118. package/components/Sidenav/index.umd.js +40 -44
  119. package/components/Sidenav/index.umd.js.map +1 -1
  120. package/components/Sidenav/sgds-sidenav-item.d.ts +14 -16
  121. package/components/Sidenav/sgds-sidenav-item.js +39 -43
  122. package/components/Sidenav/sgds-sidenav-item.js.map +1 -1
  123. package/components/Sidenav/sidenav-item.js +1 -1
  124. package/components/Sidenav/sidenav-link.js +1 -1
  125. package/components/Skeleton/index.umd.js +2 -2
  126. package/components/Skeleton/skeleton.js +1 -1
  127. package/components/Spinner/index.umd.js +2 -2
  128. package/components/Spinner/spinner.js +1 -1
  129. package/components/Stepper/index.umd.js +2 -2
  130. package/components/Stepper/stepper.js +1 -1
  131. package/components/Switch/index.umd.js +2 -2
  132. package/components/Switch/switch.js +1 -1
  133. package/components/Tab/index.umd.js +2 -2
  134. package/components/Tab/tab.js +1 -1
  135. package/components/Table/index.umd.js +63 -205
  136. package/components/Table/index.umd.js.map +1 -1
  137. package/components/Table/sgds-table.d.ts +12 -55
  138. package/components/Table/sgds-table.js +59 -201
  139. package/components/Table/sgds-table.js.map +1 -1
  140. package/components/Table/table.js +1 -1
  141. package/components/TableOfContents/index.d.ts +6 -0
  142. package/components/TableOfContents/index.js +4 -0
  143. package/components/TableOfContents/index.js.map +1 -0
  144. package/components/TableOfContents/index.umd.js +3995 -0
  145. package/components/TableOfContents/index.umd.js.map +1 -0
  146. package/components/TableOfContents/sgds-table-of-contents.d.ts +13 -0
  147. package/components/TableOfContents/sgds-table-of-contents.js +25 -0
  148. package/components/TableOfContents/sgds-table-of-contents.js.map +1 -0
  149. package/components/TableOfContents/table-of-contents.js +6 -0
  150. package/components/TableOfContents/table-of-contents.js.map +1 -0
  151. package/components/Textarea/index.umd.js +3 -3
  152. package/components/Textarea/textarea.js +1 -1
  153. package/components/Toast/index.umd.js +3 -3
  154. package/components/Toast/toast.js +1 -1
  155. package/components/Tooltip/index.umd.js +2 -2
  156. package/components/Tooltip/tooltip.js +1 -1
  157. package/components/index.d.ts +1 -1
  158. package/components/index.js +1 -1
  159. package/components/index.umd.js +2694 -3016
  160. package/components/index.umd.js.map +1 -1
  161. package/css/grid.css +110 -0
  162. package/css/reboot.css +7 -7
  163. package/css/sgds.css +1 -0
  164. package/index.d.ts +1 -1
  165. package/index.js +1 -1
  166. package/index.umd.js +2949 -3271
  167. package/index.umd.js.map +1 -1
  168. package/internals/CloseButton/close-button.js +1 -1
  169. package/internals/OverflowMenu/overflow-menu.js +1 -1
  170. package/package.json +1 -1
  171. package/react/base/button.cjs.js +1 -1
  172. package/react/base/button.js +1 -1
  173. package/react/base/card-element.cjs.js +0 -3
  174. package/react/base/card-element.cjs.js.map +1 -1
  175. package/react/base/card-element.js +0 -3
  176. package/react/base/card-element.js.map +1 -1
  177. package/react/base/card.cjs.js +1 -1
  178. package/react/base/card.js +1 -1
  179. package/react/base/sgds-element.cjs2.js +1 -1
  180. package/react/base/sgds-element2.js +1 -1
  181. package/react/components/Accordion/accordion-item.cjs.js +1 -1
  182. package/react/components/Accordion/accordion-item.js +1 -1
  183. package/react/components/Accordion/accordion.cjs.js +1 -1
  184. package/react/components/Accordion/accordion.js +1 -1
  185. package/react/components/Accordion/sgds-accordion-item.cjs.js +1 -5
  186. package/react/components/Accordion/sgds-accordion-item.cjs.js.map +1 -1
  187. package/react/components/Accordion/sgds-accordion-item.js +1 -5
  188. package/react/components/Accordion/sgds-accordion-item.js.map +1 -1
  189. package/react/components/Accordion/sgds-accordion.cjs.js +1 -6
  190. package/react/components/Accordion/sgds-accordion.cjs.js.map +1 -1
  191. package/react/components/Accordion/sgds-accordion.js +1 -6
  192. package/react/components/Accordion/sgds-accordion.js.map +1 -1
  193. package/react/components/Alert/alert.cjs.js +1 -1
  194. package/react/components/Alert/alert.js +1 -1
  195. package/react/components/Badge/badge.cjs.js +1 -1
  196. package/react/components/Badge/badge.js +1 -1
  197. package/react/components/Breadcrumb/breadcrumb-item.cjs.js +1 -1
  198. package/react/components/Breadcrumb/breadcrumb-item.js +1 -1
  199. package/react/components/Button/button.cjs.js +1 -1
  200. package/react/components/Button/button.js +1 -1
  201. package/react/components/Card/card.cjs.js +1 -1
  202. package/react/components/Card/card.js +1 -1
  203. package/react/components/Card/sgds-card.cjs.js +3 -3
  204. package/react/components/Card/sgds-card.cjs.js.map +1 -1
  205. package/react/components/Card/sgds-card.js +3 -3
  206. package/react/components/Card/sgds-card.js.map +1 -1
  207. package/react/components/Checkbox/checkbox.cjs.js +1 -1
  208. package/react/components/Checkbox/checkbox.js +1 -1
  209. package/react/components/ComboBox/combo-box-item.cjs2.js +1 -1
  210. package/react/components/ComboBox/combo-box-item2.js +1 -1
  211. package/react/components/ComboBox/combo-box.cjs.js +1 -1
  212. package/react/components/ComboBox/combo-box.js +1 -1
  213. package/react/components/ComboBox/sgds-combo-box.cjs.js +6 -1
  214. package/react/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
  215. package/react/components/ComboBox/sgds-combo-box.js +6 -1
  216. package/react/components/ComboBox/sgds-combo-box.js.map +1 -1
  217. package/react/components/Datepicker/datepicker-calendar.cjs2.js +1 -1
  218. package/react/components/Datepicker/datepicker-calendar2.js +1 -1
  219. package/react/components/Datepicker/datepicker.cjs.js +1 -1
  220. package/react/components/Datepicker/datepicker.js +1 -1
  221. package/react/components/DescriptionList/description-list-group.cjs.js +1 -1
  222. package/react/components/DescriptionList/description-list-group.js +1 -1
  223. package/react/components/DescriptionList/description-list.cjs.js +1 -1
  224. package/react/components/DescriptionList/description-list.js +1 -1
  225. package/react/components/DescriptionList/sgds-description-list-group.cjs.js +11 -11
  226. package/react/components/DescriptionList/sgds-description-list-group.cjs.js.map +1 -1
  227. package/react/components/DescriptionList/sgds-description-list-group.js +11 -11
  228. package/react/components/DescriptionList/sgds-description-list-group.js.map +1 -1
  229. package/react/components/DescriptionList/sgds-description-list.cjs.js +4 -6
  230. package/react/components/DescriptionList/sgds-description-list.cjs.js.map +1 -1
  231. package/react/components/DescriptionList/sgds-description-list.js +4 -6
  232. package/react/components/DescriptionList/sgds-description-list.js.map +1 -1
  233. package/react/components/Divider/divider.cjs.js +1 -1
  234. package/react/components/Divider/divider.js +1 -1
  235. package/react/components/Drawer/drawer.cjs.js +1 -1
  236. package/react/components/Drawer/drawer.js +1 -1
  237. package/react/components/Drawer/sgds-drawer.cjs.js +15 -72
  238. package/react/components/Drawer/sgds-drawer.cjs.js.map +1 -1
  239. package/react/components/Drawer/sgds-drawer.js +16 -73
  240. package/react/components/Drawer/sgds-drawer.js.map +1 -1
  241. package/react/components/Dropdown/dropdown-item.cjs.js +1 -1
  242. package/react/components/Dropdown/dropdown-item.js +1 -1
  243. package/react/components/Dropdown/dropdown-menu.cjs.js +1 -1
  244. package/react/components/Dropdown/dropdown-menu.js +1 -1
  245. package/react/components/Dropdown/sgds-dropdown-item.cjs.js.map +1 -1
  246. package/react/components/Dropdown/sgds-dropdown-item.js.map +1 -1
  247. package/react/components/FileUpload/file-upload.cjs.js +1 -1
  248. package/react/components/FileUpload/file-upload.js +1 -1
  249. package/react/components/FileUpload/sgds-file-upload.cjs.js +2 -2
  250. package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
  251. package/react/components/FileUpload/sgds-file-upload.js +2 -2
  252. package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
  253. package/react/components/Footer/footer-item.cjs.js +1 -1
  254. package/react/components/Footer/footer-item.js +1 -1
  255. package/react/components/Footer/footer.cjs.js +1 -1
  256. package/react/components/Footer/footer.js +1 -1
  257. package/react/components/Input/input.cjs.js +1 -1
  258. package/react/components/Input/input.js +1 -1
  259. package/react/components/Link/link.cjs.js +1 -1
  260. package/react/components/Link/link.js +1 -1
  261. package/react/components/Link/sgds-link.cjs.js +13 -1
  262. package/react/components/Link/sgds-link.cjs.js.map +1 -1
  263. package/react/components/Link/sgds-link.js +13 -1
  264. package/react/components/Link/sgds-link.js.map +1 -1
  265. package/react/components/Mainnav/mainnav-dropdown.cjs.js +1 -1
  266. package/react/components/Mainnav/mainnav-dropdown.js +1 -1
  267. package/react/components/Mainnav/mainnav-item.cjs.js +1 -1
  268. package/react/components/Mainnav/mainnav-item.js +1 -1
  269. package/react/components/Mainnav/mainnav.cjs.js +1 -1
  270. package/react/components/Mainnav/mainnav.js +1 -1
  271. package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js +23 -36
  272. package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js.map +1 -1
  273. package/react/components/Mainnav/sgds-mainnav-dropdown.js +24 -37
  274. package/react/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
  275. package/react/components/Mainnav/sgds-mainnav-item.cjs.js +58 -3
  276. package/react/components/Mainnav/sgds-mainnav-item.cjs.js.map +1 -1
  277. package/react/components/Mainnav/sgds-mainnav-item.js +58 -3
  278. package/react/components/Mainnav/sgds-mainnav-item.js.map +1 -1
  279. package/react/components/Mainnav/sgds-mainnav.cjs.js +7 -6
  280. package/react/components/Mainnav/sgds-mainnav.cjs.js.map +1 -1
  281. package/react/components/Mainnav/sgds-mainnav.js +7 -6
  282. package/react/components/Mainnav/sgds-mainnav.js.map +1 -1
  283. package/react/components/Masthead/masthead.cjs.js +1 -1
  284. package/react/components/Masthead/masthead.js +1 -1
  285. package/react/components/Modal/modal.cjs.js +1 -1
  286. package/react/components/Modal/modal.js +1 -1
  287. package/react/components/Pagination/pagination.cjs.js +1 -1
  288. package/react/components/Pagination/pagination.js +1 -1
  289. package/react/components/ProgressBar/progress-bar.cjs.js +1 -1
  290. package/react/components/ProgressBar/progress-bar.js +1 -1
  291. package/react/components/ProgressBar/sgds-progress-bar.cjs.js +1 -1
  292. package/react/components/ProgressBar/sgds-progress-bar.cjs.js.map +1 -1
  293. package/react/components/ProgressBar/sgds-progress-bar.js +1 -1
  294. package/react/components/ProgressBar/sgds-progress-bar.js.map +1 -1
  295. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js +0 -5
  296. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
  297. package/react/components/QuantityToggle/sgds-quantity-toggle.js +0 -5
  298. package/react/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  299. package/react/components/Radio/radio.cjs.js +1 -1
  300. package/react/components/Radio/radio.js +1 -1
  301. package/react/components/Sidenav/sgds-sidenav-item.cjs.js +37 -41
  302. package/react/components/Sidenav/sgds-sidenav-item.cjs.js.map +1 -1
  303. package/react/components/Sidenav/sgds-sidenav-item.js +39 -43
  304. package/react/components/Sidenav/sgds-sidenav-item.js.map +1 -1
  305. package/react/components/Sidenav/sidenav-item.cjs.js +1 -1
  306. package/react/components/Sidenav/sidenav-item.js +1 -1
  307. package/react/components/Sidenav/sidenav-link.cjs.js +1 -1
  308. package/react/components/Sidenav/sidenav-link.js +1 -1
  309. package/react/components/Skeleton/skeleton.cjs.js +1 -1
  310. package/react/components/Skeleton/skeleton.js +1 -1
  311. package/react/components/Spinner/spinner.cjs.js +1 -1
  312. package/react/components/Spinner/spinner.js +1 -1
  313. package/react/components/Stepper/stepper.cjs.js +1 -1
  314. package/react/components/Stepper/stepper.js +1 -1
  315. package/react/components/Switch/switch.cjs.js +1 -1
  316. package/react/components/Switch/switch.js +1 -1
  317. package/react/components/Tab/tab.cjs.js +1 -1
  318. package/react/components/Tab/tab.js +1 -1
  319. package/react/components/Table/sgds-table.cjs.js +59 -201
  320. package/react/components/Table/sgds-table.cjs.js.map +1 -1
  321. package/react/components/Table/sgds-table.js +59 -201
  322. package/react/components/Table/sgds-table.js.map +1 -1
  323. package/react/components/Table/table.cjs.js +1 -1
  324. package/react/components/Table/table.js +1 -1
  325. package/react/components/TableOfContents/sgds-table-of-contents.cjs.js +31 -0
  326. package/react/components/TableOfContents/sgds-table-of-contents.cjs.js.map +1 -0
  327. package/react/components/TableOfContents/sgds-table-of-contents.js +26 -0
  328. package/react/components/TableOfContents/sgds-table-of-contents.js.map +1 -0
  329. package/react/components/TableOfContents/table-of-contents.cjs.js +11 -0
  330. package/react/components/TableOfContents/table-of-contents.cjs.js.map +1 -0
  331. package/react/components/TableOfContents/table-of-contents.js +7 -0
  332. package/react/components/TableOfContents/table-of-contents.js.map +1 -0
  333. package/react/components/Textarea/textarea.cjs.js +1 -1
  334. package/react/components/Textarea/textarea.js +1 -1
  335. package/react/components/Toast/toast.cjs.js +1 -1
  336. package/react/components/Toast/toast.js +1 -1
  337. package/react/components/Tooltip/tooltip.cjs.js +1 -1
  338. package/react/components/Tooltip/tooltip.js +1 -1
  339. package/react/index.cjs.js +94 -94
  340. package/react/index.d.ts +1 -1
  341. package/react/index.js +1 -1
  342. package/react/internals/CloseButton/close-button.cjs.js +1 -1
  343. package/react/internals/CloseButton/close-button.js +1 -1
  344. package/react/internals/OverflowMenu/overflow-menu.cjs.js +1 -1
  345. package/react/internals/OverflowMenu/overflow-menu.js +1 -1
  346. package/react/styles/feedback.cjs.js +1 -1
  347. package/react/styles/feedback.js +1 -1
  348. package/react/{action-card → table-of-contents}/index.cjs.js +5 -7
  349. package/react/table-of-contents/index.cjs.js.map +1 -0
  350. package/react/{action-card → table-of-contents}/index.js +5 -7
  351. package/react/table-of-contents/index.js.map +1 -0
  352. package/styles/feedback.js +1 -1
  353. package/themes/day.css +113 -105
  354. package/themes/night.css +117 -109
  355. package/themes/root.css +92 -85
  356. package/base/link-element.js +0 -55
  357. package/base/link-element.js.map +0 -1
  358. package/components/ActionCard/action-card.js +0 -6
  359. package/components/ActionCard/action-card.js.map +0 -1
  360. package/components/ActionCard/index.d.ts +0 -6
  361. package/components/ActionCard/index.js +0 -5
  362. package/components/ActionCard/index.js.map +0 -1
  363. package/components/ActionCard/index.umd.js +0 -5860
  364. package/components/ActionCard/index.umd.js.map +0 -1
  365. package/components/ActionCard/sgds-action-card.d.ts +0 -54
  366. package/components/ActionCard/sgds-action-card.js +0 -148
  367. package/components/ActionCard/sgds-action-card.js.map +0 -1
  368. package/react/action-card/index.cjs.js.map +0 -1
  369. package/react/action-card/index.js.map +0 -1
  370. package/react/base/link-element.cjs.js +0 -60
  371. package/react/base/link-element.cjs.js.map +0 -1
  372. package/react/base/link-element.js +0 -56
  373. package/react/base/link-element.js.map +0 -1
  374. package/react/components/ActionCard/action-card.cjs.js +0 -11
  375. package/react/components/ActionCard/action-card.cjs.js.map +0 -1
  376. package/react/components/ActionCard/action-card.js +0 -7
  377. package/react/components/ActionCard/action-card.js.map +0 -1
  378. package/react/components/ActionCard/sgds-action-card.cjs.js +0 -154
  379. package/react/components/ActionCard/sgds-action-card.cjs.js.map +0 -1
  380. package/react/components/ActionCard/sgds-action-card.js +0 -149
  381. package/react/components/ActionCard/sgds-action-card.js.map +0 -1
  382. /package/react/{action-card → table-of-contents}/index.d.ts +0 -0
@@ -0,0 +1,3995 @@
1
+ (function (factory) {
2
+ typeof define === 'function' && define.amd ? define(factory) :
3
+ factory();
4
+ })((function () { 'use strict';
5
+
6
+ /**
7
+ * @license
8
+ * Copyright 2019 Google LLC
9
+ * SPDX-License-Identifier: BSD-3-Clause
10
+ */
11
+ const NODE_MODE$1 = false;
12
+ // Allows minifiers to rename references to globalThis
13
+ const global$4 = globalThis;
14
+ /**
15
+ * Whether the current browser supports `adoptedStyleSheets`.
16
+ */
17
+ const supportsAdoptingStyleSheets$1 = global$4.ShadowRoot &&
18
+ (global$4.ShadyCSS === undefined || global$4.ShadyCSS.nativeShadow) &&
19
+ 'adoptedStyleSheets' in Document.prototype &&
20
+ 'replace' in CSSStyleSheet.prototype;
21
+ const constructionToken$1 = Symbol();
22
+ const cssTagCache$1 = new WeakMap();
23
+ /**
24
+ * A container for a string of CSS text, that may be used to create a CSSStyleSheet.
25
+ *
26
+ * CSSResult is the return value of `css`-tagged template literals and
27
+ * `unsafeCSS()`. In order to ensure that CSSResults are only created via the
28
+ * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
29
+ */
30
+ class CSSResult$1 {
31
+ constructor(cssText, strings, safeToken) {
32
+ // This property needs to remain unminified.
33
+ this['_$cssResult$'] = true;
34
+ if (safeToken !== constructionToken$1) {
35
+ throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
36
+ }
37
+ this.cssText = cssText;
38
+ this._strings = strings;
39
+ }
40
+ // This is a getter so that it's lazy. In practice, this means stylesheets
41
+ // are not created until the first element instance is made.
42
+ get styleSheet() {
43
+ // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is
44
+ // constructable.
45
+ let styleSheet = this._styleSheet;
46
+ const strings = this._strings;
47
+ if (supportsAdoptingStyleSheets$1 && styleSheet === undefined) {
48
+ const cacheable = strings !== undefined && strings.length === 1;
49
+ if (cacheable) {
50
+ styleSheet = cssTagCache$1.get(strings);
51
+ }
52
+ if (styleSheet === undefined) {
53
+ (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
54
+ if (cacheable) {
55
+ cssTagCache$1.set(strings, styleSheet);
56
+ }
57
+ }
58
+ }
59
+ return styleSheet;
60
+ }
61
+ toString() {
62
+ return this.cssText;
63
+ }
64
+ }
65
+ /**
66
+ * Wrap a value for interpolation in a {@linkcode css} tagged template literal.
67
+ *
68
+ * This is unsafe because untrusted CSS text can be used to phone home
69
+ * or exfiltrate data to an attacker controlled site. Take care to only use
70
+ * this with trusted input.
71
+ */
72
+ const unsafeCSS$1 = (value) => new CSSResult$1(typeof value === 'string' ? value : String(value), undefined, constructionToken$1);
73
+ /**
74
+ * Applies the given styles to a `shadowRoot`. When Shadow DOM is
75
+ * available but `adoptedStyleSheets` is not, styles are appended to the
76
+ * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
77
+ * Note, when shimming is used, any styles that are subsequently placed into
78
+ * the shadowRoot should be placed *before* any shimmed adopted styles. This
79
+ * will match spec behavior that gives adopted sheets precedence over styles in
80
+ * shadowRoot.
81
+ */
82
+ const adoptStyles$1 = (renderRoot, styles) => {
83
+ if (supportsAdoptingStyleSheets$1) {
84
+ renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
85
+ }
86
+ else {
87
+ for (const s of styles) {
88
+ const style = document.createElement('style');
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
+ const nonce = global$4['litNonce'];
91
+ if (nonce !== undefined) {
92
+ style.setAttribute('nonce', nonce);
93
+ }
94
+ style.textContent = s.cssText;
95
+ renderRoot.appendChild(style);
96
+ }
97
+ }
98
+ };
99
+ const cssResultFromStyleSheet$1 = (sheet) => {
100
+ let cssText = '';
101
+ for (const rule of sheet.cssRules) {
102
+ cssText += rule.cssText;
103
+ }
104
+ return unsafeCSS$1(cssText);
105
+ };
106
+ const getCompatibleStyle$1 = supportsAdoptingStyleSheets$1 ||
107
+ (NODE_MODE$1 )
108
+ ? (s) => s
109
+ : (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet$1(s) : s;
110
+
111
+ /**
112
+ * @license
113
+ * Copyright 2017 Google LLC
114
+ * SPDX-License-Identifier: BSD-3-Clause
115
+ */
116
+ // TODO (justinfagnani): Add `hasOwn` here when we ship ES2022
117
+ const { is: is$1, defineProperty: defineProperty$1, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getOwnPropertySymbols: getOwnPropertySymbols$1, getPrototypeOf: getPrototypeOf$1, } = Object;
118
+ // Lets a minifier replace globalThis references with a minified name
119
+ const global$3 = globalThis;
120
+ let issueWarning$3;
121
+ const trustedTypes$2 = global$3
122
+ .trustedTypes;
123
+ // Temporary workaround for https://crbug.com/993268
124
+ // Currently, any attribute starting with "on" is considered to be a
125
+ // TrustedScript source. Such boolean attributes must be set to the equivalent
126
+ // trusted emptyScript value.
127
+ const emptyStringForBooleanAttribute$1 = trustedTypes$2
128
+ ? trustedTypes$2.emptyScript
129
+ : '';
130
+ const polyfillSupport$3 = global$3.reactiveElementPolyfillSupportDevMode
131
+ ;
132
+ {
133
+ // Ensure warnings are issued only 1x, even if multiple versions of Lit
134
+ // are loaded.
135
+ const issuedWarnings = (global$3.litIssuedWarnings ??=
136
+ new Set());
137
+ // Issue a warning, if we haven't already.
138
+ issueWarning$3 = (code, warning) => {
139
+ warning += ` See https://lit.dev/msg/${code} for more information.`;
140
+ if (!issuedWarnings.has(warning)) {
141
+ console.warn(warning);
142
+ issuedWarnings.add(warning);
143
+ }
144
+ };
145
+ issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
146
+ // Issue polyfill support warning.
147
+ if (global$3.ShadyDOM?.inUse && polyfillSupport$3 === undefined) {
148
+ issueWarning$3('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
149
+ `the \`polyfill-support\` module has not been loaded.`);
150
+ }
151
+ }
152
+ /**
153
+ * Useful for visualizing and logging insights into what the Lit template system is doing.
154
+ *
155
+ * Compiled out of prod mode builds.
156
+ */
157
+ const debugLogEvent$2 = (event) => {
158
+ const shouldEmit = global$3
159
+ .emitLitDebugLogEvents;
160
+ if (!shouldEmit) {
161
+ return;
162
+ }
163
+ global$3.dispatchEvent(new CustomEvent('lit-debug', {
164
+ detail: event,
165
+ }));
166
+ }
167
+ ;
168
+ /*
169
+ * When using Closure Compiler, JSCompiler_renameProperty(property, object) is
170
+ * replaced at compile time by the munged name for object[property]. We cannot
171
+ * alias this function, so we have to use a small shim that has the same
172
+ * behavior when not compiling.
173
+ */
174
+ /*@__INLINE__*/
175
+ const JSCompiler_renameProperty$2 = (prop, _obj) => prop;
176
+ const defaultConverter$1 = {
177
+ toAttribute(value, type) {
178
+ switch (type) {
179
+ case Boolean:
180
+ value = value ? emptyStringForBooleanAttribute$1 : null;
181
+ break;
182
+ case Object:
183
+ case Array:
184
+ // if the value is `null` or `undefined` pass this through
185
+ // to allow removing/no change behavior.
186
+ value = value == null ? value : JSON.stringify(value);
187
+ break;
188
+ }
189
+ return value;
190
+ },
191
+ fromAttribute(value, type) {
192
+ let fromValue = value;
193
+ switch (type) {
194
+ case Boolean:
195
+ fromValue = value !== null;
196
+ break;
197
+ case Number:
198
+ fromValue = value === null ? null : Number(value);
199
+ break;
200
+ case Object:
201
+ case Array:
202
+ // Do *not* generate exception when invalid JSON is set as elements
203
+ // don't normally complain on being mis-configured.
204
+ // TODO(sorvell): Do generate exception in *dev mode*.
205
+ try {
206
+ // Assert to adhere to Bazel's "must type assert JSON parse" rule.
207
+ fromValue = JSON.parse(value);
208
+ }
209
+ catch (e) {
210
+ fromValue = null;
211
+ }
212
+ break;
213
+ }
214
+ return fromValue;
215
+ },
216
+ };
217
+ /**
218
+ * Change function that returns true if `value` is different from `oldValue`.
219
+ * This method is used as the default for a property's `hasChanged` function.
220
+ */
221
+ const notEqual$1 = (value, old) => !is$1(value, old);
222
+ const defaultPropertyDeclaration$1 = {
223
+ attribute: true,
224
+ type: String,
225
+ converter: defaultConverter$1,
226
+ reflect: false,
227
+ hasChanged: notEqual$1,
228
+ };
229
+ // Ensure metadata is enabled. TypeScript does not polyfill
230
+ // Symbol.metadata, so we must ensure that it exists.
231
+ Symbol.metadata ??= Symbol('metadata');
232
+ // Map from a class's metadata object to property options
233
+ // Note that we must use nullish-coalescing assignment so that we only use one
234
+ // map even if we load multiple version of this module.
235
+ global$3.litPropertyMetadata ??= new WeakMap();
236
+ /**
237
+ * Base element class which manages element properties and attributes. When
238
+ * properties change, the `update` method is asynchronously called. This method
239
+ * should be supplied by subclasses to render updates as desired.
240
+ * @noInheritDoc
241
+ */
242
+ class ReactiveElement$1
243
+ // In the Node build, this `extends` clause will be substituted with
244
+ // `(globalThis.HTMLElement ?? HTMLElement)`.
245
+ //
246
+ // This way, we will first prefer any global `HTMLElement` polyfill that the
247
+ // user has assigned, and then fall back to the `HTMLElement` shim which has
248
+ // been imported (see note at the top of this file about how this import is
249
+ // generated by Rollup). Note that the `HTMLElement` variable has been
250
+ // shadowed by this import, so it no longer refers to the global.
251
+ extends HTMLElement {
252
+ /**
253
+ * Adds an initializer function to the class that is called during instance
254
+ * construction.
255
+ *
256
+ * This is useful for code that runs against a `ReactiveElement`
257
+ * subclass, such as a decorator, that needs to do work for each
258
+ * instance, such as setting up a `ReactiveController`.
259
+ *
260
+ * ```ts
261
+ * const myDecorator = (target: typeof ReactiveElement, key: string) => {
262
+ * target.addInitializer((instance: ReactiveElement) => {
263
+ * // This is run during construction of the element
264
+ * new MyController(instance);
265
+ * });
266
+ * }
267
+ * ```
268
+ *
269
+ * Decorating a field will then cause each instance to run an initializer
270
+ * that adds a controller:
271
+ *
272
+ * ```ts
273
+ * class MyElement extends LitElement {
274
+ * @myDecorator foo;
275
+ * }
276
+ * ```
277
+ *
278
+ * Initializers are stored per-constructor. Adding an initializer to a
279
+ * subclass does not add it to a superclass. Since initializers are run in
280
+ * constructors, initializers will run in order of the class hierarchy,
281
+ * starting with superclasses and progressing to the instance's class.
282
+ *
283
+ * @nocollapse
284
+ */
285
+ static addInitializer(initializer) {
286
+ this.__prepare();
287
+ (this._initializers ??= []).push(initializer);
288
+ }
289
+ /**
290
+ * Returns a list of attributes corresponding to the registered properties.
291
+ * @nocollapse
292
+ * @category attributes
293
+ */
294
+ static get observedAttributes() {
295
+ // Ensure we've created all properties
296
+ this.finalize();
297
+ // this.__attributeToPropertyMap is only undefined after finalize() in
298
+ // ReactiveElement itself. ReactiveElement.observedAttributes is only
299
+ // accessed with ReactiveElement as the receiver when a subclass or mixin
300
+ // calls super.observedAttributes
301
+ return (this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]);
302
+ }
303
+ /**
304
+ * Creates a property accessor on the element prototype if one does not exist
305
+ * and stores a {@linkcode PropertyDeclaration} for the property with the
306
+ * given options. The property setter calls the property's `hasChanged`
307
+ * property option or uses a strict identity check to determine whether or not
308
+ * to request an update.
309
+ *
310
+ * This method may be overridden to customize properties; however,
311
+ * when doing so, it's important to call `super.createProperty` to ensure
312
+ * the property is setup correctly. This method calls
313
+ * `getPropertyDescriptor` internally to get a descriptor to install.
314
+ * To customize what properties do when they are get or set, override
315
+ * `getPropertyDescriptor`. To customize the options for a property,
316
+ * implement `createProperty` like this:
317
+ *
318
+ * ```ts
319
+ * static createProperty(name, options) {
320
+ * options = Object.assign(options, {myOption: true});
321
+ * super.createProperty(name, options);
322
+ * }
323
+ * ```
324
+ *
325
+ * @nocollapse
326
+ * @category properties
327
+ */
328
+ static createProperty(name, options = defaultPropertyDeclaration$1) {
329
+ // If this is a state property, force the attribute to false.
330
+ if (options.state) {
331
+ options.attribute = false;
332
+ }
333
+ this.__prepare();
334
+ this.elementProperties.set(name, options);
335
+ if (!options.noAccessor) {
336
+ const key = // Use Symbol.for in dev mode to make it easier to maintain state
337
+ // when doing HMR.
338
+ Symbol.for(`${String(name)} (@property() cache)`)
339
+ ;
340
+ const descriptor = this.getPropertyDescriptor(name, key, options);
341
+ if (descriptor !== undefined) {
342
+ defineProperty$1(this.prototype, name, descriptor);
343
+ }
344
+ }
345
+ }
346
+ /**
347
+ * Returns a property descriptor to be defined on the given named property.
348
+ * If no descriptor is returned, the property will not become an accessor.
349
+ * For example,
350
+ *
351
+ * ```ts
352
+ * class MyElement extends LitElement {
353
+ * static getPropertyDescriptor(name, key, options) {
354
+ * const defaultDescriptor =
355
+ * super.getPropertyDescriptor(name, key, options);
356
+ * const setter = defaultDescriptor.set;
357
+ * return {
358
+ * get: defaultDescriptor.get,
359
+ * set(value) {
360
+ * setter.call(this, value);
361
+ * // custom action.
362
+ * },
363
+ * configurable: true,
364
+ * enumerable: true
365
+ * }
366
+ * }
367
+ * }
368
+ * ```
369
+ *
370
+ * @nocollapse
371
+ * @category properties
372
+ */
373
+ static getPropertyDescriptor(name, key, options) {
374
+ const { get, set } = getOwnPropertyDescriptor$1(this.prototype, name) ?? {
375
+ get() {
376
+ return this[key];
377
+ },
378
+ set(v) {
379
+ this[key] = v;
380
+ },
381
+ };
382
+ if (get == null) {
383
+ if ('value' in (getOwnPropertyDescriptor$1(this.prototype, name) ?? {})) {
384
+ throw new Error(`Field ${JSON.stringify(String(name))} on ` +
385
+ `${this.name} was declared as a reactive property ` +
386
+ `but it's actually declared as a value on the prototype. ` +
387
+ `Usually this is due to using @property or @state on a method.`);
388
+ }
389
+ issueWarning$3('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
390
+ `${this.name} was declared as a reactive property ` +
391
+ `but it does not have a getter. This will be an error in a ` +
392
+ `future version of Lit.`);
393
+ }
394
+ return {
395
+ get() {
396
+ return get?.call(this);
397
+ },
398
+ set(value) {
399
+ const oldValue = get?.call(this);
400
+ set.call(this, value);
401
+ this.requestUpdate(name, oldValue, options);
402
+ },
403
+ configurable: true,
404
+ enumerable: true,
405
+ };
406
+ }
407
+ /**
408
+ * Returns the property options associated with the given property.
409
+ * These options are defined with a `PropertyDeclaration` via the `properties`
410
+ * object or the `@property` decorator and are registered in
411
+ * `createProperty(...)`.
412
+ *
413
+ * Note, this method should be considered "final" and not overridden. To
414
+ * customize the options for a given property, override
415
+ * {@linkcode createProperty}.
416
+ *
417
+ * @nocollapse
418
+ * @final
419
+ * @category properties
420
+ */
421
+ static getPropertyOptions(name) {
422
+ return this.elementProperties.get(name) ?? defaultPropertyDeclaration$1;
423
+ }
424
+ /**
425
+ * Initializes static own properties of the class used in bookkeeping
426
+ * for element properties, initializers, etc.
427
+ *
428
+ * Can be called multiple times by code that needs to ensure these
429
+ * properties exist before using them.
430
+ *
431
+ * This method ensures the superclass is finalized so that inherited
432
+ * property metadata can be copied down.
433
+ * @nocollapse
434
+ */
435
+ static __prepare() {
436
+ if (this.hasOwnProperty(JSCompiler_renameProperty$2('elementProperties'))) {
437
+ // Already prepared
438
+ return;
439
+ }
440
+ // Finalize any superclasses
441
+ const superCtor = getPrototypeOf$1(this);
442
+ superCtor.finalize();
443
+ // Create own set of initializers for this class if any exist on the
444
+ // superclass and copy them down. Note, for a small perf boost, avoid
445
+ // creating initializers unless needed.
446
+ if (superCtor._initializers !== undefined) {
447
+ this._initializers = [...superCtor._initializers];
448
+ }
449
+ // Initialize elementProperties from the superclass
450
+ this.elementProperties = new Map(superCtor.elementProperties);
451
+ }
452
+ /**
453
+ * Finishes setting up the class so that it's ready to be registered
454
+ * as a custom element and instantiated.
455
+ *
456
+ * This method is called by the ReactiveElement.observedAttributes getter.
457
+ * If you override the observedAttributes getter, you must either call
458
+ * super.observedAttributes to trigger finalization, or call finalize()
459
+ * yourself.
460
+ *
461
+ * @nocollapse
462
+ */
463
+ static finalize() {
464
+ if (this.hasOwnProperty(JSCompiler_renameProperty$2('finalized'))) {
465
+ return;
466
+ }
467
+ this.finalized = true;
468
+ this.__prepare();
469
+ // Create properties from the static properties block:
470
+ if (this.hasOwnProperty(JSCompiler_renameProperty$2('properties'))) {
471
+ const props = this.properties;
472
+ const propKeys = [
473
+ ...getOwnPropertyNames$1(props),
474
+ ...getOwnPropertySymbols$1(props),
475
+ ];
476
+ for (const p of propKeys) {
477
+ this.createProperty(p, props[p]);
478
+ }
479
+ }
480
+ // Create properties from standard decorator metadata:
481
+ const metadata = this[Symbol.metadata];
482
+ if (metadata !== null) {
483
+ const properties = litPropertyMetadata.get(metadata);
484
+ if (properties !== undefined) {
485
+ for (const [p, options] of properties) {
486
+ this.elementProperties.set(p, options);
487
+ }
488
+ }
489
+ }
490
+ // Create the attribute-to-property map
491
+ this.__attributeToPropertyMap = new Map();
492
+ for (const [p, options] of this.elementProperties) {
493
+ const attr = this.__attributeNameForProperty(p, options);
494
+ if (attr !== undefined) {
495
+ this.__attributeToPropertyMap.set(attr, p);
496
+ }
497
+ }
498
+ this.elementStyles = this.finalizeStyles(this.styles);
499
+ {
500
+ if (this.hasOwnProperty('createProperty')) {
501
+ issueWarning$3('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
502
+ 'The override will not be called with standard decorators');
503
+ }
504
+ if (this.hasOwnProperty('getPropertyDescriptor')) {
505
+ issueWarning$3('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
506
+ 'The override will not be called with standard decorators');
507
+ }
508
+ }
509
+ }
510
+ /**
511
+ * Takes the styles the user supplied via the `static styles` property and
512
+ * returns the array of styles to apply to the element.
513
+ * Override this method to integrate into a style management system.
514
+ *
515
+ * Styles are deduplicated preserving the _last_ instance in the list. This
516
+ * is a performance optimization to avoid duplicated styles that can occur
517
+ * especially when composing via subclassing. The last item is kept to try
518
+ * to preserve the cascade order with the assumption that it's most important
519
+ * that last added styles override previous styles.
520
+ *
521
+ * @nocollapse
522
+ * @category styles
523
+ */
524
+ static finalizeStyles(styles) {
525
+ const elementStyles = [];
526
+ if (Array.isArray(styles)) {
527
+ // Dedupe the flattened array in reverse order to preserve the last items.
528
+ // Casting to Array<unknown> works around TS error that
529
+ // appears to come from trying to flatten a type CSSResultArray.
530
+ const set = new Set(styles.flat(Infinity).reverse());
531
+ // Then preserve original order by adding the set items in reverse order.
532
+ for (const s of set) {
533
+ elementStyles.unshift(getCompatibleStyle$1(s));
534
+ }
535
+ }
536
+ else if (styles !== undefined) {
537
+ elementStyles.push(getCompatibleStyle$1(styles));
538
+ }
539
+ return elementStyles;
540
+ }
541
+ /**
542
+ * Returns the property name for the given attribute `name`.
543
+ * @nocollapse
544
+ */
545
+ static __attributeNameForProperty(name, options) {
546
+ const attribute = options.attribute;
547
+ return attribute === false
548
+ ? undefined
549
+ : typeof attribute === 'string'
550
+ ? attribute
551
+ : typeof name === 'string'
552
+ ? name.toLowerCase()
553
+ : undefined;
554
+ }
555
+ constructor() {
556
+ super();
557
+ this.__instanceProperties = undefined;
558
+ /**
559
+ * True if there is a pending update as a result of calling `requestUpdate()`.
560
+ * Should only be read.
561
+ * @category updates
562
+ */
563
+ this.isUpdatePending = false;
564
+ /**
565
+ * Is set to `true` after the first update. The element code cannot assume
566
+ * that `renderRoot` exists before the element `hasUpdated`.
567
+ * @category updates
568
+ */
569
+ this.hasUpdated = false;
570
+ /**
571
+ * Name of currently reflecting property
572
+ */
573
+ this.__reflectingProperty = null;
574
+ this.__initialize();
575
+ }
576
+ /**
577
+ * Internal only override point for customizing work done when elements
578
+ * are constructed.
579
+ */
580
+ __initialize() {
581
+ this.__updatePromise = new Promise((res) => (this.enableUpdating = res));
582
+ this._$changedProperties = new Map();
583
+ // This enqueues a microtask that ust run before the first update, so it
584
+ // must be called before requestUpdate()
585
+ this.__saveInstanceProperties();
586
+ // ensures first update will be caught by an early access of
587
+ // `updateComplete`
588
+ this.requestUpdate();
589
+ this.constructor._initializers?.forEach((i) => i(this));
590
+ }
591
+ /**
592
+ * Registers a `ReactiveController` to participate in the element's reactive
593
+ * update cycle. The element automatically calls into any registered
594
+ * controllers during its lifecycle callbacks.
595
+ *
596
+ * If the element is connected when `addController()` is called, the
597
+ * controller's `hostConnected()` callback will be immediately called.
598
+ * @category controllers
599
+ */
600
+ addController(controller) {
601
+ (this.__controllers ??= new Set()).add(controller);
602
+ // If a controller is added after the element has been connected,
603
+ // call hostConnected. Note, re-using existence of `renderRoot` here
604
+ // (which is set in connectedCallback) to avoid the need to track a
605
+ // first connected state.
606
+ if (this.renderRoot !== undefined && this.isConnected) {
607
+ controller.hostConnected?.();
608
+ }
609
+ }
610
+ /**
611
+ * Removes a `ReactiveController` from the element.
612
+ * @category controllers
613
+ */
614
+ removeController(controller) {
615
+ this.__controllers?.delete(controller);
616
+ }
617
+ /**
618
+ * Fixes any properties set on the instance before upgrade time.
619
+ * Otherwise these would shadow the accessor and break these properties.
620
+ * The properties are stored in a Map which is played back after the
621
+ * constructor runs. Note, on very old versions of Safari (<=9) or Chrome
622
+ * (<=41), properties created for native platform properties like (`id` or
623
+ * `name`) may not have default values set in the element constructor. On
624
+ * these browsers native properties appear on instances and therefore their
625
+ * default value will overwrite any element default (e.g. if the element sets
626
+ * this.id = 'id' in the constructor, the 'id' will become '' since this is
627
+ * the native platform default).
628
+ */
629
+ __saveInstanceProperties() {
630
+ const instanceProperties = new Map();
631
+ const elementProperties = this.constructor
632
+ .elementProperties;
633
+ for (const p of elementProperties.keys()) {
634
+ if (this.hasOwnProperty(p)) {
635
+ instanceProperties.set(p, this[p]);
636
+ delete this[p];
637
+ }
638
+ }
639
+ if (instanceProperties.size > 0) {
640
+ this.__instanceProperties = instanceProperties;
641
+ }
642
+ }
643
+ /**
644
+ * Returns the node into which the element should render and by default
645
+ * creates and returns an open shadowRoot. Implement to customize where the
646
+ * element's DOM is rendered. For example, to render into the element's
647
+ * childNodes, return `this`.
648
+ *
649
+ * @return Returns a node into which to render.
650
+ * @category rendering
651
+ */
652
+ createRenderRoot() {
653
+ const renderRoot = this.shadowRoot ??
654
+ this.attachShadow(this.constructor.shadowRootOptions);
655
+ adoptStyles$1(renderRoot, this.constructor.elementStyles);
656
+ return renderRoot;
657
+ }
658
+ /**
659
+ * On first connection, creates the element's renderRoot, sets up
660
+ * element styling, and enables updating.
661
+ * @category lifecycle
662
+ */
663
+ connectedCallback() {
664
+ // Create renderRoot before controllers `hostConnected`
665
+ this.renderRoot ??=
666
+ this.createRenderRoot();
667
+ this.enableUpdating(true);
668
+ this.__controllers?.forEach((c) => c.hostConnected?.());
669
+ }
670
+ /**
671
+ * Note, this method should be considered final and not overridden. It is
672
+ * overridden on the element instance with a function that triggers the first
673
+ * update.
674
+ * @category updates
675
+ */
676
+ enableUpdating(_requestedUpdate) { }
677
+ /**
678
+ * Allows for `super.disconnectedCallback()` in extensions while
679
+ * reserving the possibility of making non-breaking feature additions
680
+ * when disconnecting at some point in the future.
681
+ * @category lifecycle
682
+ */
683
+ disconnectedCallback() {
684
+ this.__controllers?.forEach((c) => c.hostDisconnected?.());
685
+ }
686
+ /**
687
+ * Synchronizes property values when attributes change.
688
+ *
689
+ * Specifically, when an attribute is set, the corresponding property is set.
690
+ * You should rarely need to implement this callback. If this method is
691
+ * overridden, `super.attributeChangedCallback(name, _old, value)` must be
692
+ * called.
693
+ *
694
+ * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)
695
+ * on MDN for more information about the `attributeChangedCallback`.
696
+ * @category attributes
697
+ */
698
+ attributeChangedCallback(name, _old, value) {
699
+ this._$attributeToProperty(name, value);
700
+ }
701
+ __propertyToAttribute(name, value) {
702
+ const elemProperties = this.constructor.elementProperties;
703
+ const options = elemProperties.get(name);
704
+ const attr = this.constructor.__attributeNameForProperty(name, options);
705
+ if (attr !== undefined && options.reflect === true) {
706
+ const converter = options.converter?.toAttribute !==
707
+ undefined
708
+ ? options.converter
709
+ : defaultConverter$1;
710
+ const attrValue = converter.toAttribute(value, options.type);
711
+ if (this.constructor.enabledWarnings.includes('migration') &&
712
+ attrValue === undefined) {
713
+ issueWarning$3('undefined-attribute-value', `The attribute value for the ${name} property is ` +
714
+ `undefined on element ${this.localName}. The attribute will be ` +
715
+ `removed, but in the previous version of \`ReactiveElement\`, ` +
716
+ `the attribute would not have changed.`);
717
+ }
718
+ // Track if the property is being reflected to avoid
719
+ // setting the property again via `attributeChangedCallback`. Note:
720
+ // 1. this takes advantage of the fact that the callback is synchronous.
721
+ // 2. will behave incorrectly if multiple attributes are in the reaction
722
+ // stack at time of calling. However, since we process attributes
723
+ // in `update` this should not be possible (or an extreme corner case
724
+ // that we'd like to discover).
725
+ // mark state reflecting
726
+ this.__reflectingProperty = name;
727
+ if (attrValue == null) {
728
+ this.removeAttribute(attr);
729
+ }
730
+ else {
731
+ this.setAttribute(attr, attrValue);
732
+ }
733
+ // mark state not reflecting
734
+ this.__reflectingProperty = null;
735
+ }
736
+ }
737
+ /** @internal */
738
+ _$attributeToProperty(name, value) {
739
+ const ctor = this.constructor;
740
+ // Note, hint this as an `AttributeMap` so closure clearly understands
741
+ // the type; it has issues with tracking types through statics
742
+ const propName = ctor.__attributeToPropertyMap.get(name);
743
+ // Use tracking info to avoid reflecting a property value to an attribute
744
+ // if it was just set because the attribute changed.
745
+ if (propName !== undefined && this.__reflectingProperty !== propName) {
746
+ const options = ctor.getPropertyOptions(propName);
747
+ const converter = typeof options.converter === 'function'
748
+ ? { fromAttribute: options.converter }
749
+ : options.converter?.fromAttribute !== undefined
750
+ ? options.converter
751
+ : defaultConverter$1;
752
+ // mark state reflecting
753
+ this.__reflectingProperty = propName;
754
+ this[propName] = converter.fromAttribute(value, options.type
755
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
756
+ );
757
+ // mark state not reflecting
758
+ this.__reflectingProperty = null;
759
+ }
760
+ }
761
+ /**
762
+ * Requests an update which is processed asynchronously. This should be called
763
+ * when an element should update based on some state not triggered by setting
764
+ * a reactive property. In this case, pass no arguments. It should also be
765
+ * called when manually implementing a property setter. In this case, pass the
766
+ * property `name` and `oldValue` to ensure that any configured property
767
+ * options are honored.
768
+ *
769
+ * @param name name of requesting property
770
+ * @param oldValue old value of requesting property
771
+ * @param options property options to use instead of the previously
772
+ * configured options
773
+ * @category updates
774
+ */
775
+ requestUpdate(name, oldValue, options) {
776
+ // If we have a property key, perform property update steps.
777
+ if (name !== undefined) {
778
+ if (name instanceof Event) {
779
+ issueWarning$3(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
780
+ }
781
+ options ??= this.constructor.getPropertyOptions(name);
782
+ const hasChanged = options.hasChanged ?? notEqual$1;
783
+ const newValue = this[name];
784
+ if (hasChanged(newValue, oldValue)) {
785
+ this._$changeProperty(name, oldValue, options);
786
+ }
787
+ else {
788
+ // Abort the request if the property should not be considered changed.
789
+ return;
790
+ }
791
+ }
792
+ if (this.isUpdatePending === false) {
793
+ this.__updatePromise = this.__enqueueUpdate();
794
+ }
795
+ }
796
+ /**
797
+ * @internal
798
+ */
799
+ _$changeProperty(name, oldValue, options) {
800
+ // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(
801
+ // vs just Map.set()
802
+ if (!this._$changedProperties.has(name)) {
803
+ this._$changedProperties.set(name, oldValue);
804
+ }
805
+ // Add to reflecting properties set.
806
+ // Note, it's important that every change has a chance to add the
807
+ // property to `__reflectingProperties`. This ensures setting
808
+ // attribute + property reflects correctly.
809
+ if (options.reflect === true && this.__reflectingProperty !== name) {
810
+ (this.__reflectingProperties ??= new Set()).add(name);
811
+ }
812
+ }
813
+ /**
814
+ * Sets up the element to asynchronously update.
815
+ */
816
+ async __enqueueUpdate() {
817
+ this.isUpdatePending = true;
818
+ try {
819
+ // Ensure any previous update has resolved before updating.
820
+ // This `await` also ensures that property changes are batched.
821
+ await this.__updatePromise;
822
+ }
823
+ catch (e) {
824
+ // Refire any previous errors async so they do not disrupt the update
825
+ // cycle. Errors are refired so developers have a chance to observe
826
+ // them, and this can be done by implementing
827
+ // `window.onunhandledrejection`.
828
+ Promise.reject(e);
829
+ }
830
+ const result = this.scheduleUpdate();
831
+ // If `scheduleUpdate` returns a Promise, we await it. This is done to
832
+ // enable coordinating updates with a scheduler. Note, the result is
833
+ // checked to avoid delaying an additional microtask unless we need to.
834
+ if (result != null) {
835
+ await result;
836
+ }
837
+ return !this.isUpdatePending;
838
+ }
839
+ /**
840
+ * Schedules an element update. You can override this method to change the
841
+ * timing of updates by returning a Promise. The update will await the
842
+ * returned Promise, and you should resolve the Promise to allow the update
843
+ * to proceed. If this method is overridden, `super.scheduleUpdate()`
844
+ * must be called.
845
+ *
846
+ * For instance, to schedule updates to occur just before the next frame:
847
+ *
848
+ * ```ts
849
+ * override protected async scheduleUpdate(): Promise<unknown> {
850
+ * await new Promise((resolve) => requestAnimationFrame(() => resolve()));
851
+ * super.scheduleUpdate();
852
+ * }
853
+ * ```
854
+ * @category updates
855
+ */
856
+ scheduleUpdate() {
857
+ const result = this.performUpdate();
858
+ if (this.constructor.enabledWarnings.includes('async-perform-update') &&
859
+ typeof result?.then ===
860
+ 'function') {
861
+ issueWarning$3('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
862
+ `This behavior is deprecated and will be removed in a future ` +
863
+ `version of ReactiveElement.`);
864
+ }
865
+ return result;
866
+ }
867
+ /**
868
+ * Performs an element update. Note, if an exception is thrown during the
869
+ * update, `firstUpdated` and `updated` will not be called.
870
+ *
871
+ * Call `performUpdate()` to immediately process a pending update. This should
872
+ * generally not be needed, but it can be done in rare cases when you need to
873
+ * update synchronously.
874
+ *
875
+ * @category updates
876
+ */
877
+ performUpdate() {
878
+ // Abort any update if one is not pending when this is called.
879
+ // This can happen if `performUpdate` is called early to "flush"
880
+ // the update.
881
+ if (!this.isUpdatePending) {
882
+ return;
883
+ }
884
+ debugLogEvent$2?.({ kind: 'update' });
885
+ if (!this.hasUpdated) {
886
+ // Create renderRoot before first update. This occurs in `connectedCallback`
887
+ // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.
888
+ this.renderRoot ??=
889
+ this.createRenderRoot();
890
+ {
891
+ // Produce warning if any reactive properties on the prototype are
892
+ // shadowed by class fields. Instance fields set before upgrade are
893
+ // deleted by this point, so any own property is caused by class field
894
+ // initialization in the constructor.
895
+ const ctor = this.constructor;
896
+ const shadowedProperties = [...ctor.elementProperties.keys()].filter((p) => this.hasOwnProperty(p) && p in getPrototypeOf$1(this));
897
+ if (shadowedProperties.length) {
898
+ throw new Error(`The following properties on element ${this.localName} will not ` +
899
+ `trigger updates as expected because they are set using class ` +
900
+ `fields: ${shadowedProperties.join(', ')}. ` +
901
+ `Native class fields and some compiled output will overwrite ` +
902
+ `accessors used for detecting changes. See ` +
903
+ `https://lit.dev/msg/class-field-shadowing ` +
904
+ `for more information.`);
905
+ }
906
+ }
907
+ // Mixin instance properties once, if they exist.
908
+ if (this.__instanceProperties) {
909
+ // TODO (justinfagnani): should we use the stored value? Could a new value
910
+ // have been set since we stored the own property value?
911
+ for (const [p, value] of this.__instanceProperties) {
912
+ this[p] = value;
913
+ }
914
+ this.__instanceProperties = undefined;
915
+ }
916
+ // Trigger initial value reflection and populate the initial
917
+ // changedProperties map, but only for the case of experimental
918
+ // decorators on accessors, which will not have already populated the
919
+ // changedProperties map. We can't know if these accessors had
920
+ // initializers, so we just set them anyway - a difference from
921
+ // experimental decorators on fields and standard decorators on
922
+ // auto-accessors.
923
+ // For context why experimentalDecorators with auto accessors are handled
924
+ // specifically also see:
925
+ // https://github.com/lit/lit/pull/4183#issuecomment-1711959635
926
+ const elementProperties = this.constructor
927
+ .elementProperties;
928
+ if (elementProperties.size > 0) {
929
+ for (const [p, options] of elementProperties) {
930
+ if (options.wrapped === true &&
931
+ !this._$changedProperties.has(p) &&
932
+ this[p] !== undefined) {
933
+ this._$changeProperty(p, this[p], options);
934
+ }
935
+ }
936
+ }
937
+ }
938
+ let shouldUpdate = false;
939
+ const changedProperties = this._$changedProperties;
940
+ try {
941
+ shouldUpdate = this.shouldUpdate(changedProperties);
942
+ if (shouldUpdate) {
943
+ this.willUpdate(changedProperties);
944
+ this.__controllers?.forEach((c) => c.hostUpdate?.());
945
+ this.update(changedProperties);
946
+ }
947
+ else {
948
+ this.__markUpdated();
949
+ }
950
+ }
951
+ catch (e) {
952
+ // Prevent `firstUpdated` and `updated` from running when there's an
953
+ // update exception.
954
+ shouldUpdate = false;
955
+ // Ensure element can accept additional updates after an exception.
956
+ this.__markUpdated();
957
+ throw e;
958
+ }
959
+ // The update is no longer considered pending and further updates are now allowed.
960
+ if (shouldUpdate) {
961
+ this._$didUpdate(changedProperties);
962
+ }
963
+ }
964
+ /**
965
+ * Invoked before `update()` to compute values needed during the update.
966
+ *
967
+ * Implement `willUpdate` to compute property values that depend on other
968
+ * properties and are used in the rest of the update process.
969
+ *
970
+ * ```ts
971
+ * willUpdate(changedProperties) {
972
+ * // only need to check changed properties for an expensive computation.
973
+ * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {
974
+ * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
975
+ * }
976
+ * }
977
+ *
978
+ * render() {
979
+ * return html`SHA: ${this.sha}`;
980
+ * }
981
+ * ```
982
+ *
983
+ * @category updates
984
+ */
985
+ willUpdate(_changedProperties) { }
986
+ // Note, this is an override point for polyfill-support.
987
+ // @internal
988
+ _$didUpdate(changedProperties) {
989
+ this.__controllers?.forEach((c) => c.hostUpdated?.());
990
+ if (!this.hasUpdated) {
991
+ this.hasUpdated = true;
992
+ this.firstUpdated(changedProperties);
993
+ }
994
+ this.updated(changedProperties);
995
+ if (this.isUpdatePending &&
996
+ this.constructor.enabledWarnings.includes('change-in-update')) {
997
+ issueWarning$3('change-in-update', `Element ${this.localName} scheduled an update ` +
998
+ `(generally because a property was set) ` +
999
+ `after an update completed, causing a new update to be scheduled. ` +
1000
+ `This is inefficient and should be avoided unless the next update ` +
1001
+ `can only be scheduled as a side effect of the previous update.`);
1002
+ }
1003
+ }
1004
+ __markUpdated() {
1005
+ this._$changedProperties = new Map();
1006
+ this.isUpdatePending = false;
1007
+ }
1008
+ /**
1009
+ * Returns a Promise that resolves when the element has completed updating.
1010
+ * The Promise value is a boolean that is `true` if the element completed the
1011
+ * update without triggering another update. The Promise result is `false` if
1012
+ * a property was set inside `updated()`. If the Promise is rejected, an
1013
+ * exception was thrown during the update.
1014
+ *
1015
+ * To await additional asynchronous work, override the `getUpdateComplete`
1016
+ * method. For example, it is sometimes useful to await a rendered element
1017
+ * before fulfilling this Promise. To do this, first await
1018
+ * `super.getUpdateComplete()`, then any subsequent state.
1019
+ *
1020
+ * @return A promise of a boolean that resolves to true if the update completed
1021
+ * without triggering another update.
1022
+ * @category updates
1023
+ */
1024
+ get updateComplete() {
1025
+ return this.getUpdateComplete();
1026
+ }
1027
+ /**
1028
+ * Override point for the `updateComplete` promise.
1029
+ *
1030
+ * It is not safe to override the `updateComplete` getter directly due to a
1031
+ * limitation in TypeScript which means it is not possible to call a
1032
+ * superclass getter (e.g. `super.updateComplete.then(...)`) when the target
1033
+ * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
1034
+ * This method should be overridden instead. For example:
1035
+ *
1036
+ * ```ts
1037
+ * class MyElement extends LitElement {
1038
+ * override async getUpdateComplete() {
1039
+ * const result = await super.getUpdateComplete();
1040
+ * await this._myChild.updateComplete;
1041
+ * return result;
1042
+ * }
1043
+ * }
1044
+ * ```
1045
+ *
1046
+ * @return A promise of a boolean that resolves to true if the update completed
1047
+ * without triggering another update.
1048
+ * @category updates
1049
+ */
1050
+ getUpdateComplete() {
1051
+ return this.__updatePromise;
1052
+ }
1053
+ /**
1054
+ * Controls whether or not `update()` should be called when the element requests
1055
+ * an update. By default, this method always returns `true`, but this can be
1056
+ * customized to control when to update.
1057
+ *
1058
+ * @param _changedProperties Map of changed properties with old values
1059
+ * @category updates
1060
+ */
1061
+ shouldUpdate(_changedProperties) {
1062
+ return true;
1063
+ }
1064
+ /**
1065
+ * Updates the element. This method reflects property values to attributes.
1066
+ * It can be overridden to render and keep updated element DOM.
1067
+ * Setting properties inside this method will *not* trigger
1068
+ * another update.
1069
+ *
1070
+ * @param _changedProperties Map of changed properties with old values
1071
+ * @category updates
1072
+ */
1073
+ update(_changedProperties) {
1074
+ // The forEach() expression will only run when when __reflectingProperties is
1075
+ // defined, and it returns undefined, setting __reflectingProperties to
1076
+ // undefined
1077
+ this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) => this.__propertyToAttribute(p, this[p]));
1078
+ this.__markUpdated();
1079
+ }
1080
+ /**
1081
+ * Invoked whenever the element is updated. Implement to perform
1082
+ * post-updating tasks via DOM APIs, for example, focusing an element.
1083
+ *
1084
+ * Setting properties inside this method will trigger the element to update
1085
+ * again after this update cycle completes.
1086
+ *
1087
+ * @param _changedProperties Map of changed properties with old values
1088
+ * @category updates
1089
+ */
1090
+ updated(_changedProperties) { }
1091
+ /**
1092
+ * Invoked when the element is first updated. Implement to perform one time
1093
+ * work on the element after update.
1094
+ *
1095
+ * ```ts
1096
+ * firstUpdated() {
1097
+ * this.renderRoot.getElementById('my-text-area').focus();
1098
+ * }
1099
+ * ```
1100
+ *
1101
+ * Setting properties inside this method will trigger the element to update
1102
+ * again after this update cycle completes.
1103
+ *
1104
+ * @param _changedProperties Map of changed properties with old values
1105
+ * @category updates
1106
+ */
1107
+ firstUpdated(_changedProperties) { }
1108
+ }
1109
+ /**
1110
+ * Memoized list of all element styles.
1111
+ * Created lazily on user subclasses when finalizing the class.
1112
+ * @nocollapse
1113
+ * @category styles
1114
+ */
1115
+ ReactiveElement$1.elementStyles = [];
1116
+ /**
1117
+ * Options used when calling `attachShadow`. Set this property to customize
1118
+ * the options for the shadowRoot; for example, to create a closed
1119
+ * shadowRoot: `{mode: 'closed'}`.
1120
+ *
1121
+ * Note, these options are used in `createRenderRoot`. If this method
1122
+ * is customized, options should be respected if possible.
1123
+ * @nocollapse
1124
+ * @category rendering
1125
+ */
1126
+ ReactiveElement$1.shadowRootOptions = { mode: 'open' };
1127
+ // Assigned here to work around a jscompiler bug with static fields
1128
+ // when compiling to ES5.
1129
+ // https://github.com/google/closure-compiler/issues/3177
1130
+ ReactiveElement$1[JSCompiler_renameProperty$2('elementProperties')] = new Map();
1131
+ ReactiveElement$1[JSCompiler_renameProperty$2('finalized')] = new Map();
1132
+ // Apply polyfills if available
1133
+ polyfillSupport$3?.({ ReactiveElement: ReactiveElement$1 });
1134
+ // Dev mode warnings...
1135
+ {
1136
+ // Default warning set.
1137
+ ReactiveElement$1.enabledWarnings = [
1138
+ 'change-in-update',
1139
+ 'async-perform-update',
1140
+ ];
1141
+ const ensureOwnWarnings = function (ctor) {
1142
+ if (!ctor.hasOwnProperty(JSCompiler_renameProperty$2('enabledWarnings'))) {
1143
+ ctor.enabledWarnings = ctor.enabledWarnings.slice();
1144
+ }
1145
+ };
1146
+ ReactiveElement$1.enableWarning = function (warning) {
1147
+ ensureOwnWarnings(this);
1148
+ if (!this.enabledWarnings.includes(warning)) {
1149
+ this.enabledWarnings.push(warning);
1150
+ }
1151
+ };
1152
+ ReactiveElement$1.disableWarning = function (warning) {
1153
+ ensureOwnWarnings(this);
1154
+ const i = this.enabledWarnings.indexOf(warning);
1155
+ if (i >= 0) {
1156
+ this.enabledWarnings.splice(i, 1);
1157
+ }
1158
+ };
1159
+ }
1160
+ // IMPORTANT: do not change the property name or the assignment expression.
1161
+ // This line will be used in regexes to search for ReactiveElement usage.
1162
+ (global$3.reactiveElementVersions ??= []).push('2.0.4');
1163
+ if (global$3.reactiveElementVersions.length > 1) {
1164
+ issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
1165
+ `is not recommended.`);
1166
+ }
1167
+
1168
+ /**
1169
+ * @license
1170
+ * Copyright 2017 Google LLC
1171
+ * SPDX-License-Identifier: BSD-3-Clause
1172
+ */
1173
+ // Allows minifiers to rename references to globalThis
1174
+ const global$2 = globalThis;
1175
+ /**
1176
+ * Useful for visualizing and logging insights into what the Lit template system is doing.
1177
+ *
1178
+ * Compiled out of prod mode builds.
1179
+ */
1180
+ const debugLogEvent$1 = (event) => {
1181
+ const shouldEmit = global$2
1182
+ .emitLitDebugLogEvents;
1183
+ if (!shouldEmit) {
1184
+ return;
1185
+ }
1186
+ global$2.dispatchEvent(new CustomEvent('lit-debug', {
1187
+ detail: event,
1188
+ }));
1189
+ }
1190
+ ;
1191
+ // Used for connecting beginRender and endRender events when there are nested
1192
+ // renders when errors are thrown preventing an endRender event from being
1193
+ // called.
1194
+ let debugLogRenderId = 0;
1195
+ let issueWarning$2;
1196
+ {
1197
+ global$2.litIssuedWarnings ??= new Set();
1198
+ // Issue a warning, if we haven't already.
1199
+ issueWarning$2 = (code, warning) => {
1200
+ warning += code
1201
+ ? ` See https://lit.dev/msg/${code} for more information.`
1202
+ : '';
1203
+ if (!global$2.litIssuedWarnings.has(warning)) {
1204
+ console.warn(warning);
1205
+ global$2.litIssuedWarnings.add(warning);
1206
+ }
1207
+ };
1208
+ issueWarning$2('dev-mode', `Lit is in dev mode. Not recommended for production!`);
1209
+ }
1210
+ const wrap = global$2.ShadyDOM?.inUse &&
1211
+ global$2.ShadyDOM?.noPatch === true
1212
+ ? global$2.ShadyDOM.wrap
1213
+ : (node) => node;
1214
+ const trustedTypes$1 = global$2.trustedTypes;
1215
+ /**
1216
+ * Our TrustedTypePolicy for HTML which is declared using the html template
1217
+ * tag function.
1218
+ *
1219
+ * That HTML is a developer-authored constant, and is parsed with innerHTML
1220
+ * before any untrusted expressions have been mixed in. Therefor it is
1221
+ * considered safe by construction.
1222
+ */
1223
+ const policy = trustedTypes$1
1224
+ ? trustedTypes$1.createPolicy('lit-html', {
1225
+ createHTML: (s) => s,
1226
+ })
1227
+ : undefined;
1228
+ const identityFunction = (value) => value;
1229
+ const noopSanitizer = (_node, _name, _type) => identityFunction;
1230
+ /** Sets the global sanitizer factory. */
1231
+ const setSanitizer = (newSanitizer) => {
1232
+ if (sanitizerFactoryInternal !== noopSanitizer) {
1233
+ throw new Error(`Attempted to overwrite existing lit-html security policy.` +
1234
+ ` setSanitizeDOMValueFactory should be called at most once.`);
1235
+ }
1236
+ sanitizerFactoryInternal = newSanitizer;
1237
+ };
1238
+ /**
1239
+ * Only used in internal tests, not a part of the public API.
1240
+ */
1241
+ const _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {
1242
+ sanitizerFactoryInternal = noopSanitizer;
1243
+ };
1244
+ const createSanitizer = (node, name, type) => {
1245
+ return sanitizerFactoryInternal(node, name, type);
1246
+ };
1247
+ // Added to an attribute name to mark the attribute as bound so we can find
1248
+ // it easily.
1249
+ const boundAttributeSuffix = '$lit$';
1250
+ // This marker is used in many syntactic positions in HTML, so it must be
1251
+ // a valid element name and attribute name. We don't support dynamic names (yet)
1252
+ // but this at least ensures that the parse tree is closer to the template
1253
+ // intention.
1254
+ const marker = `lit$${Math.random().toFixed(9).slice(2)}$`;
1255
+ // String used to tell if a comment is a marker comment
1256
+ const markerMatch = '?' + marker;
1257
+ // Text used to insert a comment marker node. We use processing instruction
1258
+ // syntax because it's slightly smaller, but parses as a comment node.
1259
+ const nodeMarker = `<${markerMatch}>`;
1260
+ const d = document;
1261
+ // Creates a dynamic marker. We never have to search for these in the DOM.
1262
+ const createMarker = () => d.createComment('');
1263
+ const isPrimitive = (value) => value === null || (typeof value != 'object' && typeof value != 'function');
1264
+ const isArray = Array.isArray;
1265
+ const isIterable = (value) => isArray(value) ||
1266
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1267
+ typeof value?.[Symbol.iterator] === 'function';
1268
+ const SPACE_CHAR = `[ \t\n\f\r]`;
1269
+ const ATTR_VALUE_CHAR = `[^ \t\n\f\r"'\`<>=]`;
1270
+ const NAME_CHAR = `[^\\s"'>=/]`;
1271
+ // These regexes represent the five parsing states that we care about in the
1272
+ // Template's HTML scanner. They match the *end* of the state they're named
1273
+ // after.
1274
+ // Depending on the match, we transition to a new state. If there's no match,
1275
+ // we stay in the same state.
1276
+ // Note that the regexes are stateful. We utilize lastIndex and sync it
1277
+ // across the multiple regexes used. In addition to the five regexes below
1278
+ // we also dynamically create a regex to find the matching end tags for raw
1279
+ // text elements.
1280
+ /**
1281
+ * End of text is: `<` followed by:
1282
+ * (comment start) or (tag) or (dynamic tag binding)
1283
+ */
1284
+ const textEndRegex = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
1285
+ const COMMENT_START = 1;
1286
+ const TAG_NAME = 2;
1287
+ const DYNAMIC_TAG_NAME = 3;
1288
+ const commentEndRegex = /-->/g;
1289
+ /**
1290
+ * Comments not started with <!--, like </{, can be ended by a single `>`
1291
+ */
1292
+ const comment2EndRegex = />/g;
1293
+ /**
1294
+ * The tagEnd regex matches the end of the "inside an opening" tag syntax
1295
+ * position. It either matches a `>`, an attribute-like sequence, or the end
1296
+ * of the string after a space (attribute-name position ending).
1297
+ *
1298
+ * See attributes in the HTML spec:
1299
+ * https://www.w3.org/TR/html5/syntax.html#elements-attributes
1300
+ *
1301
+ * " \t\n\f\r" are HTML space characters:
1302
+ * https://infra.spec.whatwg.org/#ascii-whitespace
1303
+ *
1304
+ * So an attribute is:
1305
+ * * The name: any character except a whitespace character, ("), ('), ">",
1306
+ * "=", or "/". Note: this is different from the HTML spec which also excludes control characters.
1307
+ * * Followed by zero or more space characters
1308
+ * * Followed by "="
1309
+ * * Followed by zero or more space characters
1310
+ * * Followed by:
1311
+ * * Any character except space, ('), ("), "<", ">", "=", (`), or
1312
+ * * (") then any non-("), or
1313
+ * * (') then any non-(')
1314
+ */
1315
+ const tagEndRegex = new RegExp(`>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|("|')|))|$)`, 'g');
1316
+ const ENTIRE_MATCH = 0;
1317
+ const ATTRIBUTE_NAME = 1;
1318
+ const SPACES_AND_EQUALS = 2;
1319
+ const QUOTE_CHAR = 3;
1320
+ const singleQuoteAttrEndRegex = /'/g;
1321
+ const doubleQuoteAttrEndRegex = /"/g;
1322
+ /**
1323
+ * Matches the raw text elements.
1324
+ *
1325
+ * Comments are not parsed within raw text elements, so we need to search their
1326
+ * text content for marker strings.
1327
+ */
1328
+ const rawTextElement = /^(?:script|style|textarea|title)$/i;
1329
+ /** TemplateResult types */
1330
+ const HTML_RESULT = 1;
1331
+ const SVG_RESULT = 2;
1332
+ const MATHML_RESULT = 3;
1333
+ // TemplatePart types
1334
+ // IMPORTANT: these must match the values in PartType
1335
+ const ATTRIBUTE_PART = 1;
1336
+ const CHILD_PART = 2;
1337
+ const PROPERTY_PART = 3;
1338
+ const BOOLEAN_ATTRIBUTE_PART = 4;
1339
+ const EVENT_PART = 5;
1340
+ const ELEMENT_PART = 6;
1341
+ const COMMENT_PART = 7;
1342
+ /**
1343
+ * Generates a template literal tag function that returns a TemplateResult with
1344
+ * the given result type.
1345
+ */
1346
+ const tag = (type) => (strings, ...values) => {
1347
+ // Warn against templates octal escape sequences
1348
+ // We do this here rather than in render so that the warning is closer to the
1349
+ // template definition.
1350
+ if (strings.some((s) => s === undefined)) {
1351
+ console.warn('Some template strings are undefined.\n' +
1352
+ 'This is probably caused by illegal octal escape sequences.');
1353
+ }
1354
+ {
1355
+ // Import static-html.js results in a circular dependency which g3 doesn't
1356
+ // handle. Instead we know that static values must have the field
1357
+ // `_$litStatic$`.
1358
+ if (values.some((val) => val?.['_$litStatic$'])) {
1359
+ issueWarning$2('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\n` +
1360
+ `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);
1361
+ }
1362
+ }
1363
+ return {
1364
+ // This property needs to remain unminified.
1365
+ ['_$litType$']: type,
1366
+ strings,
1367
+ values,
1368
+ };
1369
+ };
1370
+ /**
1371
+ * Interprets a template literal as an HTML template that can efficiently
1372
+ * render to and update a container.
1373
+ *
1374
+ * ```ts
1375
+ * const header = (title: string) => html`<h1>${title}</h1>`;
1376
+ * ```
1377
+ *
1378
+ * The `html` tag returns a description of the DOM to render as a value. It is
1379
+ * lazy, meaning no work is done until the template is rendered. When rendering,
1380
+ * if a template comes from the same expression as a previously rendered result,
1381
+ * it's efficiently updated instead of replaced.
1382
+ */
1383
+ const html = tag(HTML_RESULT);
1384
+ /**
1385
+ * A sentinel value that signals that a value was handled by a directive and
1386
+ * should not be written to the DOM.
1387
+ */
1388
+ const noChange = Symbol.for('lit-noChange');
1389
+ /**
1390
+ * A sentinel value that signals a ChildPart to fully clear its content.
1391
+ *
1392
+ * ```ts
1393
+ * const button = html`${
1394
+ * user.isAdmin
1395
+ * ? html`<button>DELETE</button>`
1396
+ * : nothing
1397
+ * }`;
1398
+ * ```
1399
+ *
1400
+ * Prefer using `nothing` over other falsy values as it provides a consistent
1401
+ * behavior between various expression binding contexts.
1402
+ *
1403
+ * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the
1404
+ * same and render no nodes. In attribute expressions, `nothing` _removes_ the
1405
+ * attribute, while `undefined` and `null` will render an empty string. In
1406
+ * property expressions `nothing` becomes `undefined`.
1407
+ */
1408
+ const nothing = Symbol.for('lit-nothing');
1409
+ /**
1410
+ * The cache of prepared templates, keyed by the tagged TemplateStringsArray
1411
+ * and _not_ accounting for the specific template tag used. This means that
1412
+ * template tags cannot be dynamic - they must statically be one of html, svg,
1413
+ * or attr. This restriction simplifies the cache lookup, which is on the hot
1414
+ * path for rendering.
1415
+ */
1416
+ const templateCache = new WeakMap();
1417
+ const walker = d.createTreeWalker(d, 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */);
1418
+ let sanitizerFactoryInternal = noopSanitizer;
1419
+ function trustFromTemplateString(tsa, stringFromTSA) {
1420
+ // A security check to prevent spoofing of Lit template results.
1421
+ // In the future, we may be able to replace this with Array.isTemplateObject,
1422
+ // though we might need to make that check inside of the html and svg
1423
+ // functions, because precompiled templates don't come in as
1424
+ // TemplateStringArray objects.
1425
+ if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {
1426
+ let message = 'invalid template strings array';
1427
+ {
1428
+ message = `
1429
+ Internal Error: expected template strings to be an array
1430
+ with a 'raw' field. Faking a template strings array by
1431
+ calling html or svg like an ordinary function is effectively
1432
+ the same as calling unsafeHtml and can lead to major security
1433
+ issues, e.g. opening your code up to XSS attacks.
1434
+ If you're using the html or svg tagged template functions normally
1435
+ and still seeing this error, please file a bug at
1436
+ https://github.com/lit/lit/issues/new?template=bug_report.md
1437
+ and include information about your build tooling, if any.
1438
+ `
1439
+ .trim()
1440
+ .replace(/\n */g, '\n');
1441
+ }
1442
+ throw new Error(message);
1443
+ }
1444
+ return policy !== undefined
1445
+ ? policy.createHTML(stringFromTSA)
1446
+ : stringFromTSA;
1447
+ }
1448
+ /**
1449
+ * Returns an HTML string for the given TemplateStringsArray and result type
1450
+ * (HTML or SVG), along with the case-sensitive bound attribute names in
1451
+ * template order. The HTML contains comment markers denoting the `ChildPart`s
1452
+ * and suffixes on bound attributes denoting the `AttributeParts`.
1453
+ *
1454
+ * @param strings template strings array
1455
+ * @param type HTML or SVG
1456
+ * @return Array containing `[html, attrNames]` (array returned for terseness,
1457
+ * to avoid object fields since this code is shared with non-minified SSR
1458
+ * code)
1459
+ */
1460
+ const getTemplateHtml = (strings, type) => {
1461
+ // Insert makers into the template HTML to represent the position of
1462
+ // bindings. The following code scans the template strings to determine the
1463
+ // syntactic position of the bindings. They can be in text position, where
1464
+ // we insert an HTML comment, attribute value position, where we insert a
1465
+ // sentinel string and re-write the attribute name, or inside a tag where
1466
+ // we insert the sentinel string.
1467
+ const l = strings.length - 1;
1468
+ // Stores the case-sensitive bound attribute names in the order of their
1469
+ // parts. ElementParts are also reflected in this array as undefined
1470
+ // rather than a string, to disambiguate from attribute bindings.
1471
+ const attrNames = [];
1472
+ let html = type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';
1473
+ // When we're inside a raw text tag (not it's text content), the regex
1474
+ // will still be tagRegex so we can find attributes, but will switch to
1475
+ // this regex when the tag ends.
1476
+ let rawTextEndRegex;
1477
+ // The current parsing state, represented as a reference to one of the
1478
+ // regexes
1479
+ let regex = textEndRegex;
1480
+ for (let i = 0; i < l; i++) {
1481
+ const s = strings[i];
1482
+ // The index of the end of the last attribute name. When this is
1483
+ // positive at end of a string, it means we're in an attribute value
1484
+ // position and need to rewrite the attribute name.
1485
+ // We also use a special value of -2 to indicate that we encountered
1486
+ // the end of a string in attribute name position.
1487
+ let attrNameEndIndex = -1;
1488
+ let attrName;
1489
+ let lastIndex = 0;
1490
+ let match;
1491
+ // The conditions in this loop handle the current parse state, and the
1492
+ // assignments to the `regex` variable are the state transitions.
1493
+ while (lastIndex < s.length) {
1494
+ // Make sure we start searching from where we previously left off
1495
+ regex.lastIndex = lastIndex;
1496
+ match = regex.exec(s);
1497
+ if (match === null) {
1498
+ break;
1499
+ }
1500
+ lastIndex = regex.lastIndex;
1501
+ if (regex === textEndRegex) {
1502
+ if (match[COMMENT_START] === '!--') {
1503
+ regex = commentEndRegex;
1504
+ }
1505
+ else if (match[COMMENT_START] !== undefined) {
1506
+ // We started a weird comment, like </{
1507
+ regex = comment2EndRegex;
1508
+ }
1509
+ else if (match[TAG_NAME] !== undefined) {
1510
+ if (rawTextElement.test(match[TAG_NAME])) {
1511
+ // Record if we encounter a raw-text element. We'll switch to
1512
+ // this regex at the end of the tag.
1513
+ rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');
1514
+ }
1515
+ regex = tagEndRegex;
1516
+ }
1517
+ else if (match[DYNAMIC_TAG_NAME] !== undefined) {
1518
+ {
1519
+ throw new Error('Bindings in tag names are not supported. Please use static templates instead. ' +
1520
+ 'See https://lit.dev/docs/templates/expressions/#static-expressions');
1521
+ }
1522
+ }
1523
+ }
1524
+ else if (regex === tagEndRegex) {
1525
+ if (match[ENTIRE_MATCH] === '>') {
1526
+ // End of a tag. If we had started a raw-text element, use that
1527
+ // regex
1528
+ regex = rawTextEndRegex ?? textEndRegex;
1529
+ // We may be ending an unquoted attribute value, so make sure we
1530
+ // clear any pending attrNameEndIndex
1531
+ attrNameEndIndex = -1;
1532
+ }
1533
+ else if (match[ATTRIBUTE_NAME] === undefined) {
1534
+ // Attribute name position
1535
+ attrNameEndIndex = -2;
1536
+ }
1537
+ else {
1538
+ attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;
1539
+ attrName = match[ATTRIBUTE_NAME];
1540
+ regex =
1541
+ match[QUOTE_CHAR] === undefined
1542
+ ? tagEndRegex
1543
+ : match[QUOTE_CHAR] === '"'
1544
+ ? doubleQuoteAttrEndRegex
1545
+ : singleQuoteAttrEndRegex;
1546
+ }
1547
+ }
1548
+ else if (regex === doubleQuoteAttrEndRegex ||
1549
+ regex === singleQuoteAttrEndRegex) {
1550
+ regex = tagEndRegex;
1551
+ }
1552
+ else if (regex === commentEndRegex || regex === comment2EndRegex) {
1553
+ regex = textEndRegex;
1554
+ }
1555
+ else {
1556
+ // Not one of the five state regexes, so it must be the dynamically
1557
+ // created raw text regex and we're at the close of that element.
1558
+ regex = tagEndRegex;
1559
+ rawTextEndRegex = undefined;
1560
+ }
1561
+ }
1562
+ {
1563
+ // If we have a attrNameEndIndex, which indicates that we should
1564
+ // rewrite the attribute name, assert that we're in a valid attribute
1565
+ // position - either in a tag, or a quoted attribute value.
1566
+ console.assert(attrNameEndIndex === -1 ||
1567
+ regex === tagEndRegex ||
1568
+ regex === singleQuoteAttrEndRegex ||
1569
+ regex === doubleQuoteAttrEndRegex, 'unexpected parse state B');
1570
+ }
1571
+ // We have four cases:
1572
+ // 1. We're in text position, and not in a raw text element
1573
+ // (regex === textEndRegex): insert a comment marker.
1574
+ // 2. We have a non-negative attrNameEndIndex which means we need to
1575
+ // rewrite the attribute name to add a bound attribute suffix.
1576
+ // 3. We're at the non-first binding in a multi-binding attribute, use a
1577
+ // plain marker.
1578
+ // 4. We're somewhere else inside the tag. If we're in attribute name
1579
+ // position (attrNameEndIndex === -2), add a sequential suffix to
1580
+ // generate a unique attribute name.
1581
+ // Detect a binding next to self-closing tag end and insert a space to
1582
+ // separate the marker from the tag end:
1583
+ const end = regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';
1584
+ html +=
1585
+ regex === textEndRegex
1586
+ ? s + nodeMarker
1587
+ : attrNameEndIndex >= 0
1588
+ ? (attrNames.push(attrName),
1589
+ s.slice(0, attrNameEndIndex) +
1590
+ boundAttributeSuffix +
1591
+ s.slice(attrNameEndIndex)) +
1592
+ marker +
1593
+ end
1594
+ : s + marker + (attrNameEndIndex === -2 ? i : end);
1595
+ }
1596
+ const htmlResult = html +
1597
+ (strings[l] || '<?>') +
1598
+ (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');
1599
+ // Returned as an array for terseness
1600
+ return [trustFromTemplateString(strings, htmlResult), attrNames];
1601
+ };
1602
+ class Template {
1603
+ constructor(
1604
+ // This property needs to remain unminified.
1605
+ { strings, ['_$litType$']: type }, options) {
1606
+ this.parts = [];
1607
+ let node;
1608
+ let nodeIndex = 0;
1609
+ let attrNameIndex = 0;
1610
+ const partCount = strings.length - 1;
1611
+ const parts = this.parts;
1612
+ // Create template element
1613
+ const [html, attrNames] = getTemplateHtml(strings, type);
1614
+ this.el = Template.createElement(html, options);
1615
+ walker.currentNode = this.el.content;
1616
+ // Re-parent SVG or MathML nodes into template root
1617
+ if (type === SVG_RESULT || type === MATHML_RESULT) {
1618
+ const wrapper = this.el.content.firstChild;
1619
+ wrapper.replaceWith(...wrapper.childNodes);
1620
+ }
1621
+ // Walk the template to find binding markers and create TemplateParts
1622
+ while ((node = walker.nextNode()) !== null && parts.length < partCount) {
1623
+ if (node.nodeType === 1) {
1624
+ {
1625
+ const tag = node.localName;
1626
+ // Warn if `textarea` includes an expression and throw if `template`
1627
+ // does since these are not supported. We do this by checking
1628
+ // innerHTML for anything that looks like a marker. This catches
1629
+ // cases like bindings in textarea there markers turn into text nodes.
1630
+ if (/^(?:textarea|template)$/i.test(tag) &&
1631
+ node.innerHTML.includes(marker)) {
1632
+ const m = `Expressions are not supported inside \`${tag}\` ` +
1633
+ `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +
1634
+ `information.`;
1635
+ if (tag === 'template') {
1636
+ throw new Error(m);
1637
+ }
1638
+ else
1639
+ issueWarning$2('', m);
1640
+ }
1641
+ }
1642
+ // TODO (justinfagnani): for attempted dynamic tag names, we don't
1643
+ // increment the bindingIndex, and it'll be off by 1 in the element
1644
+ // and off by two after it.
1645
+ if (node.hasAttributes()) {
1646
+ for (const name of node.getAttributeNames()) {
1647
+ if (name.endsWith(boundAttributeSuffix)) {
1648
+ const realName = attrNames[attrNameIndex++];
1649
+ const value = node.getAttribute(name);
1650
+ const statics = value.split(marker);
1651
+ const m = /([.?@])?(.*)/.exec(realName);
1652
+ parts.push({
1653
+ type: ATTRIBUTE_PART,
1654
+ index: nodeIndex,
1655
+ name: m[2],
1656
+ strings: statics,
1657
+ ctor: m[1] === '.'
1658
+ ? PropertyPart
1659
+ : m[1] === '?'
1660
+ ? BooleanAttributePart
1661
+ : m[1] === '@'
1662
+ ? EventPart
1663
+ : AttributePart,
1664
+ });
1665
+ node.removeAttribute(name);
1666
+ }
1667
+ else if (name.startsWith(marker)) {
1668
+ parts.push({
1669
+ type: ELEMENT_PART,
1670
+ index: nodeIndex,
1671
+ });
1672
+ node.removeAttribute(name);
1673
+ }
1674
+ }
1675
+ }
1676
+ // TODO (justinfagnani): benchmark the regex against testing for each
1677
+ // of the 3 raw text element names.
1678
+ if (rawTextElement.test(node.tagName)) {
1679
+ // For raw text elements we need to split the text content on
1680
+ // markers, create a Text node for each segment, and create
1681
+ // a TemplatePart for each marker.
1682
+ const strings = node.textContent.split(marker);
1683
+ const lastIndex = strings.length - 1;
1684
+ if (lastIndex > 0) {
1685
+ node.textContent = trustedTypes$1
1686
+ ? trustedTypes$1.emptyScript
1687
+ : '';
1688
+ // Generate a new text node for each literal section
1689
+ // These nodes are also used as the markers for node parts
1690
+ // We can't use empty text nodes as markers because they're
1691
+ // normalized when cloning in IE (could simplify when
1692
+ // IE is no longer supported)
1693
+ for (let i = 0; i < lastIndex; i++) {
1694
+ node.append(strings[i], createMarker());
1695
+ // Walk past the marker node we just added
1696
+ walker.nextNode();
1697
+ parts.push({ type: CHILD_PART, index: ++nodeIndex });
1698
+ }
1699
+ // Note because this marker is added after the walker's current
1700
+ // node, it will be walked to in the outer loop (and ignored), so
1701
+ // we don't need to adjust nodeIndex here
1702
+ node.append(strings[lastIndex], createMarker());
1703
+ }
1704
+ }
1705
+ }
1706
+ else if (node.nodeType === 8) {
1707
+ const data = node.data;
1708
+ if (data === markerMatch) {
1709
+ parts.push({ type: CHILD_PART, index: nodeIndex });
1710
+ }
1711
+ else {
1712
+ let i = -1;
1713
+ while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
1714
+ // Comment node has a binding marker inside, make an inactive part
1715
+ // The binding won't work, but subsequent bindings will
1716
+ parts.push({ type: COMMENT_PART, index: nodeIndex });
1717
+ // Move to the end of the match
1718
+ i += marker.length - 1;
1719
+ }
1720
+ }
1721
+ }
1722
+ nodeIndex++;
1723
+ }
1724
+ {
1725
+ // If there was a duplicate attribute on a tag, then when the tag is
1726
+ // parsed into an element the attribute gets de-duplicated. We can detect
1727
+ // this mismatch if we haven't precisely consumed every attribute name
1728
+ // when preparing the template. This works because `attrNames` is built
1729
+ // from the template string and `attrNameIndex` comes from processing the
1730
+ // resulting DOM.
1731
+ if (attrNames.length !== attrNameIndex) {
1732
+ throw new Error(`Detected duplicate attribute bindings. This occurs if your template ` +
1733
+ `has duplicate attributes on an element tag. For example ` +
1734
+ `"<input ?disabled=\${true} ?disabled=\${false}>" contains a ` +
1735
+ `duplicate "disabled" attribute. The error was detected in ` +
1736
+ `the following template: \n` +
1737
+ '`' +
1738
+ strings.join('${...}') +
1739
+ '`');
1740
+ }
1741
+ }
1742
+ // We could set walker.currentNode to another node here to prevent a memory
1743
+ // leak, but every time we prepare a template, we immediately render it
1744
+ // and re-use the walker in new TemplateInstance._clone().
1745
+ debugLogEvent$1 &&
1746
+ debugLogEvent$1({
1747
+ kind: 'template prep',
1748
+ template: this,
1749
+ clonableTemplate: this.el,
1750
+ parts: this.parts,
1751
+ strings,
1752
+ });
1753
+ }
1754
+ // Overridden via `litHtmlPolyfillSupport` to provide platform support.
1755
+ /** @nocollapse */
1756
+ static createElement(html, _options) {
1757
+ const el = d.createElement('template');
1758
+ el.innerHTML = html;
1759
+ return el;
1760
+ }
1761
+ }
1762
+ function resolveDirective(part, value, parent = part, attributeIndex) {
1763
+ // Bail early if the value is explicitly noChange. Note, this means any
1764
+ // nested directive is still attached and is not run.
1765
+ if (value === noChange) {
1766
+ return value;
1767
+ }
1768
+ let currentDirective = attributeIndex !== undefined
1769
+ ? parent.__directives?.[attributeIndex]
1770
+ : parent.__directive;
1771
+ const nextDirectiveConstructor = isPrimitive(value)
1772
+ ? undefined
1773
+ : // This property needs to remain unminified.
1774
+ value['_$litDirective$'];
1775
+ if (currentDirective?.constructor !== nextDirectiveConstructor) {
1776
+ // This property needs to remain unminified.
1777
+ currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);
1778
+ if (nextDirectiveConstructor === undefined) {
1779
+ currentDirective = undefined;
1780
+ }
1781
+ else {
1782
+ currentDirective = new nextDirectiveConstructor(part);
1783
+ currentDirective._$initialize(part, parent, attributeIndex);
1784
+ }
1785
+ if (attributeIndex !== undefined) {
1786
+ (parent.__directives ??= [])[attributeIndex] =
1787
+ currentDirective;
1788
+ }
1789
+ else {
1790
+ parent.__directive = currentDirective;
1791
+ }
1792
+ }
1793
+ if (currentDirective !== undefined) {
1794
+ value = resolveDirective(part, currentDirective._$resolve(part, value.values), currentDirective, attributeIndex);
1795
+ }
1796
+ return value;
1797
+ }
1798
+ /**
1799
+ * An updateable instance of a Template. Holds references to the Parts used to
1800
+ * update the template instance.
1801
+ */
1802
+ class TemplateInstance {
1803
+ constructor(template, parent) {
1804
+ this._$parts = [];
1805
+ /** @internal */
1806
+ this._$disconnectableChildren = undefined;
1807
+ this._$template = template;
1808
+ this._$parent = parent;
1809
+ }
1810
+ // Called by ChildPart parentNode getter
1811
+ get parentNode() {
1812
+ return this._$parent.parentNode;
1813
+ }
1814
+ // See comment in Disconnectable interface for why this is a getter
1815
+ get _$isConnected() {
1816
+ return this._$parent._$isConnected;
1817
+ }
1818
+ // This method is separate from the constructor because we need to return a
1819
+ // DocumentFragment and we don't want to hold onto it with an instance field.
1820
+ _clone(options) {
1821
+ const { el: { content }, parts: parts, } = this._$template;
1822
+ const fragment = (options?.creationScope ?? d).importNode(content, true);
1823
+ walker.currentNode = fragment;
1824
+ let node = walker.nextNode();
1825
+ let nodeIndex = 0;
1826
+ let partIndex = 0;
1827
+ let templatePart = parts[0];
1828
+ while (templatePart !== undefined) {
1829
+ if (nodeIndex === templatePart.index) {
1830
+ let part;
1831
+ if (templatePart.type === CHILD_PART) {
1832
+ part = new ChildPart(node, node.nextSibling, this, options);
1833
+ }
1834
+ else if (templatePart.type === ATTRIBUTE_PART) {
1835
+ part = new templatePart.ctor(node, templatePart.name, templatePart.strings, this, options);
1836
+ }
1837
+ else if (templatePart.type === ELEMENT_PART) {
1838
+ part = new ElementPart(node, this, options);
1839
+ }
1840
+ this._$parts.push(part);
1841
+ templatePart = parts[++partIndex];
1842
+ }
1843
+ if (nodeIndex !== templatePart?.index) {
1844
+ node = walker.nextNode();
1845
+ nodeIndex++;
1846
+ }
1847
+ }
1848
+ // We need to set the currentNode away from the cloned tree so that we
1849
+ // don't hold onto the tree even if the tree is detached and should be
1850
+ // freed.
1851
+ walker.currentNode = d;
1852
+ return fragment;
1853
+ }
1854
+ _update(values) {
1855
+ let i = 0;
1856
+ for (const part of this._$parts) {
1857
+ if (part !== undefined) {
1858
+ debugLogEvent$1 &&
1859
+ debugLogEvent$1({
1860
+ kind: 'set part',
1861
+ part,
1862
+ value: values[i],
1863
+ valueIndex: i,
1864
+ values,
1865
+ templateInstance: this,
1866
+ });
1867
+ if (part.strings !== undefined) {
1868
+ part._$setValue(values, part, i);
1869
+ // The number of values the part consumes is part.strings.length - 1
1870
+ // since values are in between template spans. We increment i by 1
1871
+ // later in the loop, so increment it by part.strings.length - 2 here
1872
+ i += part.strings.length - 2;
1873
+ }
1874
+ else {
1875
+ part._$setValue(values[i]);
1876
+ }
1877
+ }
1878
+ i++;
1879
+ }
1880
+ }
1881
+ }
1882
+ class ChildPart {
1883
+ // See comment in Disconnectable interface for why this is a getter
1884
+ get _$isConnected() {
1885
+ // ChildParts that are not at the root should always be created with a
1886
+ // parent; only RootChildNode's won't, so they return the local isConnected
1887
+ // state
1888
+ return this._$parent?._$isConnected ?? this.__isConnected;
1889
+ }
1890
+ constructor(startNode, endNode, parent, options) {
1891
+ this.type = CHILD_PART;
1892
+ this._$committedValue = nothing;
1893
+ // The following fields will be patched onto ChildParts when required by
1894
+ // AsyncDirective
1895
+ /** @internal */
1896
+ this._$disconnectableChildren = undefined;
1897
+ this._$startNode = startNode;
1898
+ this._$endNode = endNode;
1899
+ this._$parent = parent;
1900
+ this.options = options;
1901
+ // Note __isConnected is only ever accessed on RootParts (i.e. when there is
1902
+ // no _$parent); the value on a non-root-part is "don't care", but checking
1903
+ // for parent would be more code
1904
+ this.__isConnected = options?.isConnected ?? true;
1905
+ {
1906
+ // Explicitly initialize for consistent class shape.
1907
+ this._textSanitizer = undefined;
1908
+ }
1909
+ }
1910
+ /**
1911
+ * The parent node into which the part renders its content.
1912
+ *
1913
+ * A ChildPart's content consists of a range of adjacent child nodes of
1914
+ * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and
1915
+ * `.endNode`).
1916
+ *
1917
+ * - If both `.startNode` and `.endNode` are non-null, then the part's content
1918
+ * consists of all siblings between `.startNode` and `.endNode`, exclusively.
1919
+ *
1920
+ * - If `.startNode` is non-null but `.endNode` is null, then the part's
1921
+ * content consists of all siblings following `.startNode`, up to and
1922
+ * including the last child of `.parentNode`. If `.endNode` is non-null, then
1923
+ * `.startNode` will always be non-null.
1924
+ *
1925
+ * - If both `.endNode` and `.startNode` are null, then the part's content
1926
+ * consists of all child nodes of `.parentNode`.
1927
+ */
1928
+ get parentNode() {
1929
+ let parentNode = wrap(this._$startNode).parentNode;
1930
+ const parent = this._$parent;
1931
+ if (parent !== undefined &&
1932
+ parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */) {
1933
+ // If the parentNode is a DocumentFragment, it may be because the DOM is
1934
+ // still in the cloned fragment during initial render; if so, get the real
1935
+ // parentNode the part will be committed into by asking the parent.
1936
+ parentNode = parent.parentNode;
1937
+ }
1938
+ return parentNode;
1939
+ }
1940
+ /**
1941
+ * The part's leading marker node, if any. See `.parentNode` for more
1942
+ * information.
1943
+ */
1944
+ get startNode() {
1945
+ return this._$startNode;
1946
+ }
1947
+ /**
1948
+ * The part's trailing marker node, if any. See `.parentNode` for more
1949
+ * information.
1950
+ */
1951
+ get endNode() {
1952
+ return this._$endNode;
1953
+ }
1954
+ _$setValue(value, directiveParent = this) {
1955
+ if (this.parentNode === null) {
1956
+ throw new Error(`This \`ChildPart\` has no \`parentNode\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \`innerHTML\` or \`textContent\` can do this.`);
1957
+ }
1958
+ value = resolveDirective(this, value, directiveParent);
1959
+ if (isPrimitive(value)) {
1960
+ // Non-rendering child values. It's important that these do not render
1961
+ // empty text nodes to avoid issues with preventing default <slot>
1962
+ // fallback content.
1963
+ if (value === nothing || value == null || value === '') {
1964
+ if (this._$committedValue !== nothing) {
1965
+ debugLogEvent$1 &&
1966
+ debugLogEvent$1({
1967
+ kind: 'commit nothing to child',
1968
+ start: this._$startNode,
1969
+ end: this._$endNode,
1970
+ parent: this._$parent,
1971
+ options: this.options,
1972
+ });
1973
+ this._$clear();
1974
+ }
1975
+ this._$committedValue = nothing;
1976
+ }
1977
+ else if (value !== this._$committedValue && value !== noChange) {
1978
+ this._commitText(value);
1979
+ }
1980
+ // This property needs to remain unminified.
1981
+ }
1982
+ else if (value['_$litType$'] !== undefined) {
1983
+ this._commitTemplateResult(value);
1984
+ }
1985
+ else if (value.nodeType !== undefined) {
1986
+ if (this.options?.host === value) {
1987
+ this._commitText(`[probable mistake: rendered a template's host in itself ` +
1988
+ `(commonly caused by writing \${this} in a template]`);
1989
+ console.warn(`Attempted to render the template host`, value, `inside itself. This is almost always a mistake, and in dev mode `, `we render some warning text. In production however, we'll `, `render it, which will usually result in an error, and sometimes `, `in the element disappearing from the DOM.`);
1990
+ return;
1991
+ }
1992
+ this._commitNode(value);
1993
+ }
1994
+ else if (isIterable(value)) {
1995
+ this._commitIterable(value);
1996
+ }
1997
+ else {
1998
+ // Fallback, will render the string representation
1999
+ this._commitText(value);
2000
+ }
2001
+ }
2002
+ _insert(node) {
2003
+ return wrap(wrap(this._$startNode).parentNode).insertBefore(node, this._$endNode);
2004
+ }
2005
+ _commitNode(value) {
2006
+ if (this._$committedValue !== value) {
2007
+ this._$clear();
2008
+ if (sanitizerFactoryInternal !== noopSanitizer) {
2009
+ const parentNodeName = this._$startNode.parentNode?.nodeName;
2010
+ if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {
2011
+ let message = 'Forbidden';
2012
+ {
2013
+ if (parentNodeName === 'STYLE') {
2014
+ message =
2015
+ `Lit does not support binding inside style nodes. ` +
2016
+ `This is a security risk, as style injection attacks can ` +
2017
+ `exfiltrate data and spoof UIs. ` +
2018
+ `Consider instead using css\`...\` literals ` +
2019
+ `to compose styles, and do dynamic styling with ` +
2020
+ `css custom properties, ::parts, <slot>s, ` +
2021
+ `and by mutating the DOM rather than stylesheets.`;
2022
+ }
2023
+ else {
2024
+ message =
2025
+ `Lit does not support binding inside script nodes. ` +
2026
+ `This is a security risk, as it could allow arbitrary ` +
2027
+ `code execution.`;
2028
+ }
2029
+ }
2030
+ throw new Error(message);
2031
+ }
2032
+ }
2033
+ debugLogEvent$1 &&
2034
+ debugLogEvent$1({
2035
+ kind: 'commit node',
2036
+ start: this._$startNode,
2037
+ parent: this._$parent,
2038
+ value: value,
2039
+ options: this.options,
2040
+ });
2041
+ this._$committedValue = this._insert(value);
2042
+ }
2043
+ }
2044
+ _commitText(value) {
2045
+ // If the committed value is a primitive it means we called _commitText on
2046
+ // the previous render, and we know that this._$startNode.nextSibling is a
2047
+ // Text node. We can now just replace the text content (.data) of the node.
2048
+ if (this._$committedValue !== nothing &&
2049
+ isPrimitive(this._$committedValue)) {
2050
+ const node = wrap(this._$startNode).nextSibling;
2051
+ {
2052
+ if (this._textSanitizer === undefined) {
2053
+ this._textSanitizer = createSanitizer(node, 'data', 'property');
2054
+ }
2055
+ value = this._textSanitizer(value);
2056
+ }
2057
+ debugLogEvent$1 &&
2058
+ debugLogEvent$1({
2059
+ kind: 'commit text',
2060
+ node,
2061
+ value,
2062
+ options: this.options,
2063
+ });
2064
+ node.data = value;
2065
+ }
2066
+ else {
2067
+ {
2068
+ const textNode = d.createTextNode('');
2069
+ this._commitNode(textNode);
2070
+ // When setting text content, for security purposes it matters a lot
2071
+ // what the parent is. For example, <style> and <script> need to be
2072
+ // handled with care, while <span> does not. So first we need to put a
2073
+ // text node into the document, then we can sanitize its content.
2074
+ if (this._textSanitizer === undefined) {
2075
+ this._textSanitizer = createSanitizer(textNode, 'data', 'property');
2076
+ }
2077
+ value = this._textSanitizer(value);
2078
+ debugLogEvent$1 &&
2079
+ debugLogEvent$1({
2080
+ kind: 'commit text',
2081
+ node: textNode,
2082
+ value,
2083
+ options: this.options,
2084
+ });
2085
+ textNode.data = value;
2086
+ }
2087
+ }
2088
+ this._$committedValue = value;
2089
+ }
2090
+ _commitTemplateResult(result) {
2091
+ // This property needs to remain unminified.
2092
+ const { values, ['_$litType$']: type } = result;
2093
+ // If $litType$ is a number, result is a plain TemplateResult and we get
2094
+ // the template from the template cache. If not, result is a
2095
+ // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need
2096
+ // to create the <template> element the first time we see it.
2097
+ const template = typeof type === 'number'
2098
+ ? this._$getTemplate(result)
2099
+ : (type.el === undefined &&
2100
+ (type.el = Template.createElement(trustFromTemplateString(type.h, type.h[0]), this.options)),
2101
+ type);
2102
+ if (this._$committedValue?._$template === template) {
2103
+ debugLogEvent$1 &&
2104
+ debugLogEvent$1({
2105
+ kind: 'template updating',
2106
+ template,
2107
+ instance: this._$committedValue,
2108
+ parts: this._$committedValue._$parts,
2109
+ options: this.options,
2110
+ values,
2111
+ });
2112
+ this._$committedValue._update(values);
2113
+ }
2114
+ else {
2115
+ const instance = new TemplateInstance(template, this);
2116
+ const fragment = instance._clone(this.options);
2117
+ debugLogEvent$1 &&
2118
+ debugLogEvent$1({
2119
+ kind: 'template instantiated',
2120
+ template,
2121
+ instance,
2122
+ parts: instance._$parts,
2123
+ options: this.options,
2124
+ fragment,
2125
+ values,
2126
+ });
2127
+ instance._update(values);
2128
+ debugLogEvent$1 &&
2129
+ debugLogEvent$1({
2130
+ kind: 'template instantiated and updated',
2131
+ template,
2132
+ instance,
2133
+ parts: instance._$parts,
2134
+ options: this.options,
2135
+ fragment,
2136
+ values,
2137
+ });
2138
+ this._commitNode(fragment);
2139
+ this._$committedValue = instance;
2140
+ }
2141
+ }
2142
+ // Overridden via `litHtmlPolyfillSupport` to provide platform support.
2143
+ /** @internal */
2144
+ _$getTemplate(result) {
2145
+ let template = templateCache.get(result.strings);
2146
+ if (template === undefined) {
2147
+ templateCache.set(result.strings, (template = new Template(result)));
2148
+ }
2149
+ return template;
2150
+ }
2151
+ _commitIterable(value) {
2152
+ // For an Iterable, we create a new InstancePart per item, then set its
2153
+ // value to the item. This is a little bit of overhead for every item in
2154
+ // an Iterable, but it lets us recurse easily and efficiently update Arrays
2155
+ // of TemplateResults that will be commonly returned from expressions like:
2156
+ // array.map((i) => html`${i}`), by reusing existing TemplateInstances.
2157
+ // If value is an array, then the previous render was of an
2158
+ // iterable and value will contain the ChildParts from the previous
2159
+ // render. If value is not an array, clear this part and make a new
2160
+ // array for ChildParts.
2161
+ if (!isArray(this._$committedValue)) {
2162
+ this._$committedValue = [];
2163
+ this._$clear();
2164
+ }
2165
+ // Lets us keep track of how many items we stamped so we can clear leftover
2166
+ // items from a previous render
2167
+ const itemParts = this._$committedValue;
2168
+ let partIndex = 0;
2169
+ let itemPart;
2170
+ for (const item of value) {
2171
+ if (partIndex === itemParts.length) {
2172
+ // If no existing part, create a new one
2173
+ // TODO (justinfagnani): test perf impact of always creating two parts
2174
+ // instead of sharing parts between nodes
2175
+ // https://github.com/lit/lit/issues/1266
2176
+ itemParts.push((itemPart = new ChildPart(this._insert(createMarker()), this._insert(createMarker()), this, this.options)));
2177
+ }
2178
+ else {
2179
+ // Reuse an existing part
2180
+ itemPart = itemParts[partIndex];
2181
+ }
2182
+ itemPart._$setValue(item);
2183
+ partIndex++;
2184
+ }
2185
+ if (partIndex < itemParts.length) {
2186
+ // itemParts always have end nodes
2187
+ this._$clear(itemPart && wrap(itemPart._$endNode).nextSibling, partIndex);
2188
+ // Truncate the parts array so _value reflects the current state
2189
+ itemParts.length = partIndex;
2190
+ }
2191
+ }
2192
+ /**
2193
+ * Removes the nodes contained within this Part from the DOM.
2194
+ *
2195
+ * @param start Start node to clear from, for clearing a subset of the part's
2196
+ * DOM (used when truncating iterables)
2197
+ * @param from When `start` is specified, the index within the iterable from
2198
+ * which ChildParts are being removed, used for disconnecting directives in
2199
+ * those Parts.
2200
+ *
2201
+ * @internal
2202
+ */
2203
+ _$clear(start = wrap(this._$startNode).nextSibling, from) {
2204
+ this._$notifyConnectionChanged?.(false, true, from);
2205
+ while (start && start !== this._$endNode) {
2206
+ const n = wrap(start).nextSibling;
2207
+ wrap(start).remove();
2208
+ start = n;
2209
+ }
2210
+ }
2211
+ /**
2212
+ * Implementation of RootPart's `isConnected`. Note that this method
2213
+ * should only be called on `RootPart`s (the `ChildPart` returned from a
2214
+ * top-level `render()` call). It has no effect on non-root ChildParts.
2215
+ * @param isConnected Whether to set
2216
+ * @internal
2217
+ */
2218
+ setConnected(isConnected) {
2219
+ if (this._$parent === undefined) {
2220
+ this.__isConnected = isConnected;
2221
+ this._$notifyConnectionChanged?.(isConnected);
2222
+ }
2223
+ else {
2224
+ throw new Error('part.setConnected() may only be called on a ' +
2225
+ 'RootPart returned from render().');
2226
+ }
2227
+ }
2228
+ }
2229
+ class AttributePart {
2230
+ get tagName() {
2231
+ return this.element.tagName;
2232
+ }
2233
+ // See comment in Disconnectable interface for why this is a getter
2234
+ get _$isConnected() {
2235
+ return this._$parent._$isConnected;
2236
+ }
2237
+ constructor(element, name, strings, parent, options) {
2238
+ this.type = ATTRIBUTE_PART;
2239
+ /** @internal */
2240
+ this._$committedValue = nothing;
2241
+ /** @internal */
2242
+ this._$disconnectableChildren = undefined;
2243
+ this.element = element;
2244
+ this.name = name;
2245
+ this._$parent = parent;
2246
+ this.options = options;
2247
+ if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {
2248
+ this._$committedValue = new Array(strings.length - 1).fill(new String());
2249
+ this.strings = strings;
2250
+ }
2251
+ else {
2252
+ this._$committedValue = nothing;
2253
+ }
2254
+ {
2255
+ this._sanitizer = undefined;
2256
+ }
2257
+ }
2258
+ /**
2259
+ * Sets the value of this part by resolving the value from possibly multiple
2260
+ * values and static strings and committing it to the DOM.
2261
+ * If this part is single-valued, `this._strings` will be undefined, and the
2262
+ * method will be called with a single value argument. If this part is
2263
+ * multi-value, `this._strings` will be defined, and the method is called
2264
+ * with the value array of the part's owning TemplateInstance, and an offset
2265
+ * into the value array from which the values should be read.
2266
+ * This method is overloaded this way to eliminate short-lived array slices
2267
+ * of the template instance values, and allow a fast-path for single-valued
2268
+ * parts.
2269
+ *
2270
+ * @param value The part value, or an array of values for multi-valued parts
2271
+ * @param valueIndex the index to start reading values from. `undefined` for
2272
+ * single-valued parts
2273
+ * @param noCommit causes the part to not commit its value to the DOM. Used
2274
+ * in hydration to prime attribute parts with their first-rendered value,
2275
+ * but not set the attribute, and in SSR to no-op the DOM operation and
2276
+ * capture the value for serialization.
2277
+ *
2278
+ * @internal
2279
+ */
2280
+ _$setValue(value, directiveParent = this, valueIndex, noCommit) {
2281
+ const strings = this.strings;
2282
+ // Whether any of the values has changed, for dirty-checking
2283
+ let change = false;
2284
+ if (strings === undefined) {
2285
+ // Single-value binding case
2286
+ value = resolveDirective(this, value, directiveParent, 0);
2287
+ change =
2288
+ !isPrimitive(value) ||
2289
+ (value !== this._$committedValue && value !== noChange);
2290
+ if (change) {
2291
+ this._$committedValue = value;
2292
+ }
2293
+ }
2294
+ else {
2295
+ // Interpolation case
2296
+ const values = value;
2297
+ value = strings[0];
2298
+ let i, v;
2299
+ for (i = 0; i < strings.length - 1; i++) {
2300
+ v = resolveDirective(this, values[valueIndex + i], directiveParent, i);
2301
+ if (v === noChange) {
2302
+ // If the user-provided value is `noChange`, use the previous value
2303
+ v = this._$committedValue[i];
2304
+ }
2305
+ change ||=
2306
+ !isPrimitive(v) || v !== this._$committedValue[i];
2307
+ if (v === nothing) {
2308
+ value = nothing;
2309
+ }
2310
+ else if (value !== nothing) {
2311
+ value += (v ?? '') + strings[i + 1];
2312
+ }
2313
+ // We always record each value, even if one is `nothing`, for future
2314
+ // change detection.
2315
+ this._$committedValue[i] = v;
2316
+ }
2317
+ }
2318
+ if (change && !noCommit) {
2319
+ this._commitValue(value);
2320
+ }
2321
+ }
2322
+ /** @internal */
2323
+ _commitValue(value) {
2324
+ if (value === nothing) {
2325
+ wrap(this.element).removeAttribute(this.name);
2326
+ }
2327
+ else {
2328
+ {
2329
+ if (this._sanitizer === undefined) {
2330
+ this._sanitizer = sanitizerFactoryInternal(this.element, this.name, 'attribute');
2331
+ }
2332
+ value = this._sanitizer(value ?? '');
2333
+ }
2334
+ debugLogEvent$1 &&
2335
+ debugLogEvent$1({
2336
+ kind: 'commit attribute',
2337
+ element: this.element,
2338
+ name: this.name,
2339
+ value,
2340
+ options: this.options,
2341
+ });
2342
+ wrap(this.element).setAttribute(this.name, (value ?? ''));
2343
+ }
2344
+ }
2345
+ }
2346
+ class PropertyPart extends AttributePart {
2347
+ constructor() {
2348
+ super(...arguments);
2349
+ this.type = PROPERTY_PART;
2350
+ }
2351
+ /** @internal */
2352
+ _commitValue(value) {
2353
+ {
2354
+ if (this._sanitizer === undefined) {
2355
+ this._sanitizer = sanitizerFactoryInternal(this.element, this.name, 'property');
2356
+ }
2357
+ value = this._sanitizer(value);
2358
+ }
2359
+ debugLogEvent$1 &&
2360
+ debugLogEvent$1({
2361
+ kind: 'commit property',
2362
+ element: this.element,
2363
+ name: this.name,
2364
+ value,
2365
+ options: this.options,
2366
+ });
2367
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2368
+ this.element[this.name] = value === nothing ? undefined : value;
2369
+ }
2370
+ }
2371
+ class BooleanAttributePart extends AttributePart {
2372
+ constructor() {
2373
+ super(...arguments);
2374
+ this.type = BOOLEAN_ATTRIBUTE_PART;
2375
+ }
2376
+ /** @internal */
2377
+ _commitValue(value) {
2378
+ debugLogEvent$1 &&
2379
+ debugLogEvent$1({
2380
+ kind: 'commit boolean attribute',
2381
+ element: this.element,
2382
+ name: this.name,
2383
+ value: !!(value && value !== nothing),
2384
+ options: this.options,
2385
+ });
2386
+ wrap(this.element).toggleAttribute(this.name, !!value && value !== nothing);
2387
+ }
2388
+ }
2389
+ class EventPart extends AttributePart {
2390
+ constructor(element, name, strings, parent, options) {
2391
+ super(element, name, strings, parent, options);
2392
+ this.type = EVENT_PART;
2393
+ if (this.strings !== undefined) {
2394
+ throw new Error(`A \`<${element.localName}>\` has a \`@${name}=...\` listener with ` +
2395
+ 'invalid content. Event listeners in templates must have exactly ' +
2396
+ 'one expression and no surrounding text.');
2397
+ }
2398
+ }
2399
+ // EventPart does not use the base _$setValue/_resolveValue implementation
2400
+ // since the dirty checking is more complex
2401
+ /** @internal */
2402
+ _$setValue(newListener, directiveParent = this) {
2403
+ newListener =
2404
+ resolveDirective(this, newListener, directiveParent, 0) ?? nothing;
2405
+ if (newListener === noChange) {
2406
+ return;
2407
+ }
2408
+ const oldListener = this._$committedValue;
2409
+ // If the new value is nothing or any options change we have to remove the
2410
+ // part as a listener.
2411
+ const shouldRemoveListener = (newListener === nothing && oldListener !== nothing) ||
2412
+ newListener.capture !==
2413
+ oldListener.capture ||
2414
+ newListener.once !==
2415
+ oldListener.once ||
2416
+ newListener.passive !==
2417
+ oldListener.passive;
2418
+ // If the new value is not nothing and we removed the listener, we have
2419
+ // to add the part as a listener.
2420
+ const shouldAddListener = newListener !== nothing &&
2421
+ (oldListener === nothing || shouldRemoveListener);
2422
+ debugLogEvent$1 &&
2423
+ debugLogEvent$1({
2424
+ kind: 'commit event listener',
2425
+ element: this.element,
2426
+ name: this.name,
2427
+ value: newListener,
2428
+ options: this.options,
2429
+ removeListener: shouldRemoveListener,
2430
+ addListener: shouldAddListener,
2431
+ oldListener,
2432
+ });
2433
+ if (shouldRemoveListener) {
2434
+ this.element.removeEventListener(this.name, this, oldListener);
2435
+ }
2436
+ if (shouldAddListener) {
2437
+ // Beware: IE11 and Chrome 41 don't like using the listener as the
2438
+ // options object. Figure out how to deal w/ this in IE11 - maybe
2439
+ // patch addEventListener?
2440
+ this.element.addEventListener(this.name, this, newListener);
2441
+ }
2442
+ this._$committedValue = newListener;
2443
+ }
2444
+ handleEvent(event) {
2445
+ if (typeof this._$committedValue === 'function') {
2446
+ this._$committedValue.call(this.options?.host ?? this.element, event);
2447
+ }
2448
+ else {
2449
+ this._$committedValue.handleEvent(event);
2450
+ }
2451
+ }
2452
+ }
2453
+ class ElementPart {
2454
+ constructor(element, parent, options) {
2455
+ this.element = element;
2456
+ this.type = ELEMENT_PART;
2457
+ /** @internal */
2458
+ this._$disconnectableChildren = undefined;
2459
+ this._$parent = parent;
2460
+ this.options = options;
2461
+ }
2462
+ // See comment in Disconnectable interface for why this is a getter
2463
+ get _$isConnected() {
2464
+ return this._$parent._$isConnected;
2465
+ }
2466
+ _$setValue(value) {
2467
+ debugLogEvent$1 &&
2468
+ debugLogEvent$1({
2469
+ kind: 'commit to element binding',
2470
+ element: this.element,
2471
+ value,
2472
+ options: this.options,
2473
+ });
2474
+ resolveDirective(this, value);
2475
+ }
2476
+ }
2477
+ // Apply polyfills if available
2478
+ const polyfillSupport$2 = global$2.litHtmlPolyfillSupportDevMode
2479
+ ;
2480
+ polyfillSupport$2?.(Template, ChildPart);
2481
+ // IMPORTANT: do not change the property name or the assignment expression.
2482
+ // This line will be used in regexes to search for lit-html usage.
2483
+ (global$2.litHtmlVersions ??= []).push('3.2.0');
2484
+ if (global$2.litHtmlVersions.length > 1) {
2485
+ issueWarning$2('multiple-versions', `Multiple versions of Lit loaded. ` +
2486
+ `Loading multiple versions is not recommended.`);
2487
+ }
2488
+ /**
2489
+ * Renders a value, usually a lit-html TemplateResult, to the container.
2490
+ *
2491
+ * This example renders the text "Hello, Zoe!" inside a paragraph tag, appending
2492
+ * it to the container `document.body`.
2493
+ *
2494
+ * ```js
2495
+ * import {html, render} from 'lit';
2496
+ *
2497
+ * const name = "Zoe";
2498
+ * render(html`<p>Hello, ${name}!</p>`, document.body);
2499
+ * ```
2500
+ *
2501
+ * @param value Any [renderable
2502
+ * value](https://lit.dev/docs/templates/expressions/#child-expressions),
2503
+ * typically a {@linkcode TemplateResult} created by evaluating a template tag
2504
+ * like {@linkcode html} or {@linkcode svg}.
2505
+ * @param container A DOM container to render to. The first render will append
2506
+ * the rendered value to the container, and subsequent renders will
2507
+ * efficiently update the rendered value if the same result type was
2508
+ * previously rendered there.
2509
+ * @param options See {@linkcode RenderOptions} for options documentation.
2510
+ * @see
2511
+ * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}
2512
+ */
2513
+ const render = (value, container, options) => {
2514
+ if (container == null) {
2515
+ // Give a clearer error message than
2516
+ // Uncaught TypeError: Cannot read properties of null (reading
2517
+ // '_$litPart$')
2518
+ // which reads like an internal Lit error.
2519
+ throw new TypeError(`The container to render into may not be ${container}`);
2520
+ }
2521
+ const renderId = debugLogRenderId++ ;
2522
+ const partOwnerNode = options?.renderBefore ?? container;
2523
+ // This property needs to remain unminified.
2524
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2525
+ let part = partOwnerNode['_$litPart$'];
2526
+ debugLogEvent$1 &&
2527
+ debugLogEvent$1({
2528
+ kind: 'begin render',
2529
+ id: renderId,
2530
+ value,
2531
+ container,
2532
+ options,
2533
+ part,
2534
+ });
2535
+ if (part === undefined) {
2536
+ const endNode = options?.renderBefore ?? null;
2537
+ // This property needs to remain unminified.
2538
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2539
+ partOwnerNode['_$litPart$'] = part = new ChildPart(container.insertBefore(createMarker(), endNode), endNode, undefined, options ?? {});
2540
+ }
2541
+ part._$setValue(value);
2542
+ debugLogEvent$1 &&
2543
+ debugLogEvent$1({
2544
+ kind: 'end render',
2545
+ id: renderId,
2546
+ value,
2547
+ container,
2548
+ options,
2549
+ part,
2550
+ });
2551
+ return part;
2552
+ };
2553
+ {
2554
+ render.setSanitizer = setSanitizer;
2555
+ render.createSanitizer = createSanitizer;
2556
+ {
2557
+ render._testOnlyClearSanitizerFactoryDoNotCallOrElse =
2558
+ _testOnlyClearSanitizerFactoryDoNotCallOrElse;
2559
+ }
2560
+ }
2561
+
2562
+ /**
2563
+ * @license
2564
+ * Copyright 2019 Google LLC
2565
+ * SPDX-License-Identifier: BSD-3-Clause
2566
+ */
2567
+ const NODE_MODE = false;
2568
+ // Allows minifiers to rename references to globalThis
2569
+ const global$1 = globalThis;
2570
+ /**
2571
+ * Whether the current browser supports `adoptedStyleSheets`.
2572
+ */
2573
+ const supportsAdoptingStyleSheets = global$1.ShadowRoot &&
2574
+ (global$1.ShadyCSS === undefined || global$1.ShadyCSS.nativeShadow) &&
2575
+ 'adoptedStyleSheets' in Document.prototype &&
2576
+ 'replace' in CSSStyleSheet.prototype;
2577
+ const constructionToken = Symbol();
2578
+ const cssTagCache = new WeakMap();
2579
+ /**
2580
+ * A container for a string of CSS text, that may be used to create a CSSStyleSheet.
2581
+ *
2582
+ * CSSResult is the return value of `css`-tagged template literals and
2583
+ * `unsafeCSS()`. In order to ensure that CSSResults are only created via the
2584
+ * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
2585
+ */
2586
+ class CSSResult {
2587
+ constructor(cssText, strings, safeToken) {
2588
+ // This property needs to remain unminified.
2589
+ this['_$cssResult$'] = true;
2590
+ if (safeToken !== constructionToken) {
2591
+ throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
2592
+ }
2593
+ this.cssText = cssText;
2594
+ this._strings = strings;
2595
+ }
2596
+ // This is a getter so that it's lazy. In practice, this means stylesheets
2597
+ // are not created until the first element instance is made.
2598
+ get styleSheet() {
2599
+ // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is
2600
+ // constructable.
2601
+ let styleSheet = this._styleSheet;
2602
+ const strings = this._strings;
2603
+ if (supportsAdoptingStyleSheets && styleSheet === undefined) {
2604
+ const cacheable = strings !== undefined && strings.length === 1;
2605
+ if (cacheable) {
2606
+ styleSheet = cssTagCache.get(strings);
2607
+ }
2608
+ if (styleSheet === undefined) {
2609
+ (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
2610
+ if (cacheable) {
2611
+ cssTagCache.set(strings, styleSheet);
2612
+ }
2613
+ }
2614
+ }
2615
+ return styleSheet;
2616
+ }
2617
+ toString() {
2618
+ return this.cssText;
2619
+ }
2620
+ }
2621
+ const textFromCSSResult = (value) => {
2622
+ // This property needs to remain unminified.
2623
+ if (value['_$cssResult$'] === true) {
2624
+ return value.cssText;
2625
+ }
2626
+ else if (typeof value === 'number') {
2627
+ return value;
2628
+ }
2629
+ else {
2630
+ throw new Error(`Value passed to 'css' function must be a 'css' function result: ` +
2631
+ `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +
2632
+ `to ensure page security.`);
2633
+ }
2634
+ };
2635
+ /**
2636
+ * Wrap a value for interpolation in a {@linkcode css} tagged template literal.
2637
+ *
2638
+ * This is unsafe because untrusted CSS text can be used to phone home
2639
+ * or exfiltrate data to an attacker controlled site. Take care to only use
2640
+ * this with trusted input.
2641
+ */
2642
+ const unsafeCSS = (value) => new CSSResult(typeof value === 'string' ? value : String(value), undefined, constructionToken);
2643
+ /**
2644
+ * A template literal tag which can be used with LitElement's
2645
+ * {@linkcode LitElement.styles} property to set element styles.
2646
+ *
2647
+ * For security reasons, only literal string values and number may be used in
2648
+ * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}
2649
+ * may be used inside an expression.
2650
+ */
2651
+ const css = (strings, ...values) => {
2652
+ const cssText = strings.length === 1
2653
+ ? strings[0]
2654
+ : values.reduce((acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1], strings[0]);
2655
+ return new CSSResult(cssText, strings, constructionToken);
2656
+ };
2657
+ /**
2658
+ * Applies the given styles to a `shadowRoot`. When Shadow DOM is
2659
+ * available but `adoptedStyleSheets` is not, styles are appended to the
2660
+ * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
2661
+ * Note, when shimming is used, any styles that are subsequently placed into
2662
+ * the shadowRoot should be placed *before* any shimmed adopted styles. This
2663
+ * will match spec behavior that gives adopted sheets precedence over styles in
2664
+ * shadowRoot.
2665
+ */
2666
+ const adoptStyles = (renderRoot, styles) => {
2667
+ if (supportsAdoptingStyleSheets) {
2668
+ renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
2669
+ }
2670
+ else {
2671
+ for (const s of styles) {
2672
+ const style = document.createElement('style');
2673
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2674
+ const nonce = global$1['litNonce'];
2675
+ if (nonce !== undefined) {
2676
+ style.setAttribute('nonce', nonce);
2677
+ }
2678
+ style.textContent = s.cssText;
2679
+ renderRoot.appendChild(style);
2680
+ }
2681
+ }
2682
+ };
2683
+ const cssResultFromStyleSheet = (sheet) => {
2684
+ let cssText = '';
2685
+ for (const rule of sheet.cssRules) {
2686
+ cssText += rule.cssText;
2687
+ }
2688
+ return unsafeCSS(cssText);
2689
+ };
2690
+ const getCompatibleStyle = supportsAdoptingStyleSheets ||
2691
+ (NODE_MODE )
2692
+ ? (s) => s
2693
+ : (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
2694
+
2695
+ /**
2696
+ * @license
2697
+ * Copyright 2017 Google LLC
2698
+ * SPDX-License-Identifier: BSD-3-Clause
2699
+ */
2700
+ // TODO (justinfagnani): Add `hasOwn` here when we ship ES2022
2701
+ const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
2702
+ // Lets a minifier replace globalThis references with a minified name
2703
+ const global = globalThis;
2704
+ let issueWarning$1;
2705
+ const trustedTypes = global
2706
+ .trustedTypes;
2707
+ // Temporary workaround for https://crbug.com/993268
2708
+ // Currently, any attribute starting with "on" is considered to be a
2709
+ // TrustedScript source. Such boolean attributes must be set to the equivalent
2710
+ // trusted emptyScript value.
2711
+ const emptyStringForBooleanAttribute = trustedTypes
2712
+ ? trustedTypes.emptyScript
2713
+ : '';
2714
+ const polyfillSupport$1 = global.reactiveElementPolyfillSupportDevMode
2715
+ ;
2716
+ {
2717
+ // Ensure warnings are issued only 1x, even if multiple versions of Lit
2718
+ // are loaded.
2719
+ const issuedWarnings = (global.litIssuedWarnings ??=
2720
+ new Set());
2721
+ // Issue a warning, if we haven't already.
2722
+ issueWarning$1 = (code, warning) => {
2723
+ warning += ` See https://lit.dev/msg/${code} for more information.`;
2724
+ if (!issuedWarnings.has(warning)) {
2725
+ console.warn(warning);
2726
+ issuedWarnings.add(warning);
2727
+ }
2728
+ };
2729
+ issueWarning$1('dev-mode', `Lit is in dev mode. Not recommended for production!`);
2730
+ // Issue polyfill support warning.
2731
+ if (global.ShadyDOM?.inUse && polyfillSupport$1 === undefined) {
2732
+ issueWarning$1('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
2733
+ `the \`polyfill-support\` module has not been loaded.`);
2734
+ }
2735
+ }
2736
+ /**
2737
+ * Useful for visualizing and logging insights into what the Lit template system is doing.
2738
+ *
2739
+ * Compiled out of prod mode builds.
2740
+ */
2741
+ const debugLogEvent = (event) => {
2742
+ const shouldEmit = global
2743
+ .emitLitDebugLogEvents;
2744
+ if (!shouldEmit) {
2745
+ return;
2746
+ }
2747
+ global.dispatchEvent(new CustomEvent('lit-debug', {
2748
+ detail: event,
2749
+ }));
2750
+ }
2751
+ ;
2752
+ /*
2753
+ * When using Closure Compiler, JSCompiler_renameProperty(property, object) is
2754
+ * replaced at compile time by the munged name for object[property]. We cannot
2755
+ * alias this function, so we have to use a small shim that has the same
2756
+ * behavior when not compiling.
2757
+ */
2758
+ /*@__INLINE__*/
2759
+ const JSCompiler_renameProperty$1 = (prop, _obj) => prop;
2760
+ const defaultConverter = {
2761
+ toAttribute(value, type) {
2762
+ switch (type) {
2763
+ case Boolean:
2764
+ value = value ? emptyStringForBooleanAttribute : null;
2765
+ break;
2766
+ case Object:
2767
+ case Array:
2768
+ // if the value is `null` or `undefined` pass this through
2769
+ // to allow removing/no change behavior.
2770
+ value = value == null ? value : JSON.stringify(value);
2771
+ break;
2772
+ }
2773
+ return value;
2774
+ },
2775
+ fromAttribute(value, type) {
2776
+ let fromValue = value;
2777
+ switch (type) {
2778
+ case Boolean:
2779
+ fromValue = value !== null;
2780
+ break;
2781
+ case Number:
2782
+ fromValue = value === null ? null : Number(value);
2783
+ break;
2784
+ case Object:
2785
+ case Array:
2786
+ // Do *not* generate exception when invalid JSON is set as elements
2787
+ // don't normally complain on being mis-configured.
2788
+ // TODO(sorvell): Do generate exception in *dev mode*.
2789
+ try {
2790
+ // Assert to adhere to Bazel's "must type assert JSON parse" rule.
2791
+ fromValue = JSON.parse(value);
2792
+ }
2793
+ catch (e) {
2794
+ fromValue = null;
2795
+ }
2796
+ break;
2797
+ }
2798
+ return fromValue;
2799
+ },
2800
+ };
2801
+ /**
2802
+ * Change function that returns true if `value` is different from `oldValue`.
2803
+ * This method is used as the default for a property's `hasChanged` function.
2804
+ */
2805
+ const notEqual = (value, old) => !is(value, old);
2806
+ const defaultPropertyDeclaration = {
2807
+ attribute: true,
2808
+ type: String,
2809
+ converter: defaultConverter,
2810
+ reflect: false,
2811
+ hasChanged: notEqual,
2812
+ };
2813
+ // Ensure metadata is enabled. TypeScript does not polyfill
2814
+ // Symbol.metadata, so we must ensure that it exists.
2815
+ Symbol.metadata ??= Symbol('metadata');
2816
+ // Map from a class's metadata object to property options
2817
+ // Note that we must use nullish-coalescing assignment so that we only use one
2818
+ // map even if we load multiple version of this module.
2819
+ global.litPropertyMetadata ??= new WeakMap();
2820
+ /**
2821
+ * Base element class which manages element properties and attributes. When
2822
+ * properties change, the `update` method is asynchronously called. This method
2823
+ * should be supplied by subclasses to render updates as desired.
2824
+ * @noInheritDoc
2825
+ */
2826
+ class ReactiveElement
2827
+ // In the Node build, this `extends` clause will be substituted with
2828
+ // `(globalThis.HTMLElement ?? HTMLElement)`.
2829
+ //
2830
+ // This way, we will first prefer any global `HTMLElement` polyfill that the
2831
+ // user has assigned, and then fall back to the `HTMLElement` shim which has
2832
+ // been imported (see note at the top of this file about how this import is
2833
+ // generated by Rollup). Note that the `HTMLElement` variable has been
2834
+ // shadowed by this import, so it no longer refers to the global.
2835
+ extends HTMLElement {
2836
+ /**
2837
+ * Adds an initializer function to the class that is called during instance
2838
+ * construction.
2839
+ *
2840
+ * This is useful for code that runs against a `ReactiveElement`
2841
+ * subclass, such as a decorator, that needs to do work for each
2842
+ * instance, such as setting up a `ReactiveController`.
2843
+ *
2844
+ * ```ts
2845
+ * const myDecorator = (target: typeof ReactiveElement, key: string) => {
2846
+ * target.addInitializer((instance: ReactiveElement) => {
2847
+ * // This is run during construction of the element
2848
+ * new MyController(instance);
2849
+ * });
2850
+ * }
2851
+ * ```
2852
+ *
2853
+ * Decorating a field will then cause each instance to run an initializer
2854
+ * that adds a controller:
2855
+ *
2856
+ * ```ts
2857
+ * class MyElement extends LitElement {
2858
+ * @myDecorator foo;
2859
+ * }
2860
+ * ```
2861
+ *
2862
+ * Initializers are stored per-constructor. Adding an initializer to a
2863
+ * subclass does not add it to a superclass. Since initializers are run in
2864
+ * constructors, initializers will run in order of the class hierarchy,
2865
+ * starting with superclasses and progressing to the instance's class.
2866
+ *
2867
+ * @nocollapse
2868
+ */
2869
+ static addInitializer(initializer) {
2870
+ this.__prepare();
2871
+ (this._initializers ??= []).push(initializer);
2872
+ }
2873
+ /**
2874
+ * Returns a list of attributes corresponding to the registered properties.
2875
+ * @nocollapse
2876
+ * @category attributes
2877
+ */
2878
+ static get observedAttributes() {
2879
+ // Ensure we've created all properties
2880
+ this.finalize();
2881
+ // this.__attributeToPropertyMap is only undefined after finalize() in
2882
+ // ReactiveElement itself. ReactiveElement.observedAttributes is only
2883
+ // accessed with ReactiveElement as the receiver when a subclass or mixin
2884
+ // calls super.observedAttributes
2885
+ return (this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]);
2886
+ }
2887
+ /**
2888
+ * Creates a property accessor on the element prototype if one does not exist
2889
+ * and stores a {@linkcode PropertyDeclaration} for the property with the
2890
+ * given options. The property setter calls the property's `hasChanged`
2891
+ * property option or uses a strict identity check to determine whether or not
2892
+ * to request an update.
2893
+ *
2894
+ * This method may be overridden to customize properties; however,
2895
+ * when doing so, it's important to call `super.createProperty` to ensure
2896
+ * the property is setup correctly. This method calls
2897
+ * `getPropertyDescriptor` internally to get a descriptor to install.
2898
+ * To customize what properties do when they are get or set, override
2899
+ * `getPropertyDescriptor`. To customize the options for a property,
2900
+ * implement `createProperty` like this:
2901
+ *
2902
+ * ```ts
2903
+ * static createProperty(name, options) {
2904
+ * options = Object.assign(options, {myOption: true});
2905
+ * super.createProperty(name, options);
2906
+ * }
2907
+ * ```
2908
+ *
2909
+ * @nocollapse
2910
+ * @category properties
2911
+ */
2912
+ static createProperty(name, options = defaultPropertyDeclaration) {
2913
+ // If this is a state property, force the attribute to false.
2914
+ if (options.state) {
2915
+ options.attribute = false;
2916
+ }
2917
+ this.__prepare();
2918
+ this.elementProperties.set(name, options);
2919
+ if (!options.noAccessor) {
2920
+ const key = // Use Symbol.for in dev mode to make it easier to maintain state
2921
+ // when doing HMR.
2922
+ Symbol.for(`${String(name)} (@property() cache)`)
2923
+ ;
2924
+ const descriptor = this.getPropertyDescriptor(name, key, options);
2925
+ if (descriptor !== undefined) {
2926
+ defineProperty(this.prototype, name, descriptor);
2927
+ }
2928
+ }
2929
+ }
2930
+ /**
2931
+ * Returns a property descriptor to be defined on the given named property.
2932
+ * If no descriptor is returned, the property will not become an accessor.
2933
+ * For example,
2934
+ *
2935
+ * ```ts
2936
+ * class MyElement extends LitElement {
2937
+ * static getPropertyDescriptor(name, key, options) {
2938
+ * const defaultDescriptor =
2939
+ * super.getPropertyDescriptor(name, key, options);
2940
+ * const setter = defaultDescriptor.set;
2941
+ * return {
2942
+ * get: defaultDescriptor.get,
2943
+ * set(value) {
2944
+ * setter.call(this, value);
2945
+ * // custom action.
2946
+ * },
2947
+ * configurable: true,
2948
+ * enumerable: true
2949
+ * }
2950
+ * }
2951
+ * }
2952
+ * ```
2953
+ *
2954
+ * @nocollapse
2955
+ * @category properties
2956
+ */
2957
+ static getPropertyDescriptor(name, key, options) {
2958
+ const { get, set } = getOwnPropertyDescriptor(this.prototype, name) ?? {
2959
+ get() {
2960
+ return this[key];
2961
+ },
2962
+ set(v) {
2963
+ this[key] = v;
2964
+ },
2965
+ };
2966
+ if (get == null) {
2967
+ if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {
2968
+ throw new Error(`Field ${JSON.stringify(String(name))} on ` +
2969
+ `${this.name} was declared as a reactive property ` +
2970
+ `but it's actually declared as a value on the prototype. ` +
2971
+ `Usually this is due to using @property or @state on a method.`);
2972
+ }
2973
+ issueWarning$1('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
2974
+ `${this.name} was declared as a reactive property ` +
2975
+ `but it does not have a getter. This will be an error in a ` +
2976
+ `future version of Lit.`);
2977
+ }
2978
+ return {
2979
+ get() {
2980
+ return get?.call(this);
2981
+ },
2982
+ set(value) {
2983
+ const oldValue = get?.call(this);
2984
+ set.call(this, value);
2985
+ this.requestUpdate(name, oldValue, options);
2986
+ },
2987
+ configurable: true,
2988
+ enumerable: true,
2989
+ };
2990
+ }
2991
+ /**
2992
+ * Returns the property options associated with the given property.
2993
+ * These options are defined with a `PropertyDeclaration` via the `properties`
2994
+ * object or the `@property` decorator and are registered in
2995
+ * `createProperty(...)`.
2996
+ *
2997
+ * Note, this method should be considered "final" and not overridden. To
2998
+ * customize the options for a given property, override
2999
+ * {@linkcode createProperty}.
3000
+ *
3001
+ * @nocollapse
3002
+ * @final
3003
+ * @category properties
3004
+ */
3005
+ static getPropertyOptions(name) {
3006
+ return this.elementProperties.get(name) ?? defaultPropertyDeclaration;
3007
+ }
3008
+ /**
3009
+ * Initializes static own properties of the class used in bookkeeping
3010
+ * for element properties, initializers, etc.
3011
+ *
3012
+ * Can be called multiple times by code that needs to ensure these
3013
+ * properties exist before using them.
3014
+ *
3015
+ * This method ensures the superclass is finalized so that inherited
3016
+ * property metadata can be copied down.
3017
+ * @nocollapse
3018
+ */
3019
+ static __prepare() {
3020
+ if (this.hasOwnProperty(JSCompiler_renameProperty$1('elementProperties'))) {
3021
+ // Already prepared
3022
+ return;
3023
+ }
3024
+ // Finalize any superclasses
3025
+ const superCtor = getPrototypeOf(this);
3026
+ superCtor.finalize();
3027
+ // Create own set of initializers for this class if any exist on the
3028
+ // superclass and copy them down. Note, for a small perf boost, avoid
3029
+ // creating initializers unless needed.
3030
+ if (superCtor._initializers !== undefined) {
3031
+ this._initializers = [...superCtor._initializers];
3032
+ }
3033
+ // Initialize elementProperties from the superclass
3034
+ this.elementProperties = new Map(superCtor.elementProperties);
3035
+ }
3036
+ /**
3037
+ * Finishes setting up the class so that it's ready to be registered
3038
+ * as a custom element and instantiated.
3039
+ *
3040
+ * This method is called by the ReactiveElement.observedAttributes getter.
3041
+ * If you override the observedAttributes getter, you must either call
3042
+ * super.observedAttributes to trigger finalization, or call finalize()
3043
+ * yourself.
3044
+ *
3045
+ * @nocollapse
3046
+ */
3047
+ static finalize() {
3048
+ if (this.hasOwnProperty(JSCompiler_renameProperty$1('finalized'))) {
3049
+ return;
3050
+ }
3051
+ this.finalized = true;
3052
+ this.__prepare();
3053
+ // Create properties from the static properties block:
3054
+ if (this.hasOwnProperty(JSCompiler_renameProperty$1('properties'))) {
3055
+ const props = this.properties;
3056
+ const propKeys = [
3057
+ ...getOwnPropertyNames(props),
3058
+ ...getOwnPropertySymbols(props),
3059
+ ];
3060
+ for (const p of propKeys) {
3061
+ this.createProperty(p, props[p]);
3062
+ }
3063
+ }
3064
+ // Create properties from standard decorator metadata:
3065
+ const metadata = this[Symbol.metadata];
3066
+ if (metadata !== null) {
3067
+ const properties = litPropertyMetadata.get(metadata);
3068
+ if (properties !== undefined) {
3069
+ for (const [p, options] of properties) {
3070
+ this.elementProperties.set(p, options);
3071
+ }
3072
+ }
3073
+ }
3074
+ // Create the attribute-to-property map
3075
+ this.__attributeToPropertyMap = new Map();
3076
+ for (const [p, options] of this.elementProperties) {
3077
+ const attr = this.__attributeNameForProperty(p, options);
3078
+ if (attr !== undefined) {
3079
+ this.__attributeToPropertyMap.set(attr, p);
3080
+ }
3081
+ }
3082
+ this.elementStyles = this.finalizeStyles(this.styles);
3083
+ {
3084
+ if (this.hasOwnProperty('createProperty')) {
3085
+ issueWarning$1('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
3086
+ 'The override will not be called with standard decorators');
3087
+ }
3088
+ if (this.hasOwnProperty('getPropertyDescriptor')) {
3089
+ issueWarning$1('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
3090
+ 'The override will not be called with standard decorators');
3091
+ }
3092
+ }
3093
+ }
3094
+ /**
3095
+ * Takes the styles the user supplied via the `static styles` property and
3096
+ * returns the array of styles to apply to the element.
3097
+ * Override this method to integrate into a style management system.
3098
+ *
3099
+ * Styles are deduplicated preserving the _last_ instance in the list. This
3100
+ * is a performance optimization to avoid duplicated styles that can occur
3101
+ * especially when composing via subclassing. The last item is kept to try
3102
+ * to preserve the cascade order with the assumption that it's most important
3103
+ * that last added styles override previous styles.
3104
+ *
3105
+ * @nocollapse
3106
+ * @category styles
3107
+ */
3108
+ static finalizeStyles(styles) {
3109
+ const elementStyles = [];
3110
+ if (Array.isArray(styles)) {
3111
+ // Dedupe the flattened array in reverse order to preserve the last items.
3112
+ // Casting to Array<unknown> works around TS error that
3113
+ // appears to come from trying to flatten a type CSSResultArray.
3114
+ const set = new Set(styles.flat(Infinity).reverse());
3115
+ // Then preserve original order by adding the set items in reverse order.
3116
+ for (const s of set) {
3117
+ elementStyles.unshift(getCompatibleStyle(s));
3118
+ }
3119
+ }
3120
+ else if (styles !== undefined) {
3121
+ elementStyles.push(getCompatibleStyle(styles));
3122
+ }
3123
+ return elementStyles;
3124
+ }
3125
+ /**
3126
+ * Returns the property name for the given attribute `name`.
3127
+ * @nocollapse
3128
+ */
3129
+ static __attributeNameForProperty(name, options) {
3130
+ const attribute = options.attribute;
3131
+ return attribute === false
3132
+ ? undefined
3133
+ : typeof attribute === 'string'
3134
+ ? attribute
3135
+ : typeof name === 'string'
3136
+ ? name.toLowerCase()
3137
+ : undefined;
3138
+ }
3139
+ constructor() {
3140
+ super();
3141
+ this.__instanceProperties = undefined;
3142
+ /**
3143
+ * True if there is a pending update as a result of calling `requestUpdate()`.
3144
+ * Should only be read.
3145
+ * @category updates
3146
+ */
3147
+ this.isUpdatePending = false;
3148
+ /**
3149
+ * Is set to `true` after the first update. The element code cannot assume
3150
+ * that `renderRoot` exists before the element `hasUpdated`.
3151
+ * @category updates
3152
+ */
3153
+ this.hasUpdated = false;
3154
+ /**
3155
+ * Name of currently reflecting property
3156
+ */
3157
+ this.__reflectingProperty = null;
3158
+ this.__initialize();
3159
+ }
3160
+ /**
3161
+ * Internal only override point for customizing work done when elements
3162
+ * are constructed.
3163
+ */
3164
+ __initialize() {
3165
+ this.__updatePromise = new Promise((res) => (this.enableUpdating = res));
3166
+ this._$changedProperties = new Map();
3167
+ // This enqueues a microtask that ust run before the first update, so it
3168
+ // must be called before requestUpdate()
3169
+ this.__saveInstanceProperties();
3170
+ // ensures first update will be caught by an early access of
3171
+ // `updateComplete`
3172
+ this.requestUpdate();
3173
+ this.constructor._initializers?.forEach((i) => i(this));
3174
+ }
3175
+ /**
3176
+ * Registers a `ReactiveController` to participate in the element's reactive
3177
+ * update cycle. The element automatically calls into any registered
3178
+ * controllers during its lifecycle callbacks.
3179
+ *
3180
+ * If the element is connected when `addController()` is called, the
3181
+ * controller's `hostConnected()` callback will be immediately called.
3182
+ * @category controllers
3183
+ */
3184
+ addController(controller) {
3185
+ (this.__controllers ??= new Set()).add(controller);
3186
+ // If a controller is added after the element has been connected,
3187
+ // call hostConnected. Note, re-using existence of `renderRoot` here
3188
+ // (which is set in connectedCallback) to avoid the need to track a
3189
+ // first connected state.
3190
+ if (this.renderRoot !== undefined && this.isConnected) {
3191
+ controller.hostConnected?.();
3192
+ }
3193
+ }
3194
+ /**
3195
+ * Removes a `ReactiveController` from the element.
3196
+ * @category controllers
3197
+ */
3198
+ removeController(controller) {
3199
+ this.__controllers?.delete(controller);
3200
+ }
3201
+ /**
3202
+ * Fixes any properties set on the instance before upgrade time.
3203
+ * Otherwise these would shadow the accessor and break these properties.
3204
+ * The properties are stored in a Map which is played back after the
3205
+ * constructor runs. Note, on very old versions of Safari (<=9) or Chrome
3206
+ * (<=41), properties created for native platform properties like (`id` or
3207
+ * `name`) may not have default values set in the element constructor. On
3208
+ * these browsers native properties appear on instances and therefore their
3209
+ * default value will overwrite any element default (e.g. if the element sets
3210
+ * this.id = 'id' in the constructor, the 'id' will become '' since this is
3211
+ * the native platform default).
3212
+ */
3213
+ __saveInstanceProperties() {
3214
+ const instanceProperties = new Map();
3215
+ const elementProperties = this.constructor
3216
+ .elementProperties;
3217
+ for (const p of elementProperties.keys()) {
3218
+ if (this.hasOwnProperty(p)) {
3219
+ instanceProperties.set(p, this[p]);
3220
+ delete this[p];
3221
+ }
3222
+ }
3223
+ if (instanceProperties.size > 0) {
3224
+ this.__instanceProperties = instanceProperties;
3225
+ }
3226
+ }
3227
+ /**
3228
+ * Returns the node into which the element should render and by default
3229
+ * creates and returns an open shadowRoot. Implement to customize where the
3230
+ * element's DOM is rendered. For example, to render into the element's
3231
+ * childNodes, return `this`.
3232
+ *
3233
+ * @return Returns a node into which to render.
3234
+ * @category rendering
3235
+ */
3236
+ createRenderRoot() {
3237
+ const renderRoot = this.shadowRoot ??
3238
+ this.attachShadow(this.constructor.shadowRootOptions);
3239
+ adoptStyles(renderRoot, this.constructor.elementStyles);
3240
+ return renderRoot;
3241
+ }
3242
+ /**
3243
+ * On first connection, creates the element's renderRoot, sets up
3244
+ * element styling, and enables updating.
3245
+ * @category lifecycle
3246
+ */
3247
+ connectedCallback() {
3248
+ // Create renderRoot before controllers `hostConnected`
3249
+ this.renderRoot ??=
3250
+ this.createRenderRoot();
3251
+ this.enableUpdating(true);
3252
+ this.__controllers?.forEach((c) => c.hostConnected?.());
3253
+ }
3254
+ /**
3255
+ * Note, this method should be considered final and not overridden. It is
3256
+ * overridden on the element instance with a function that triggers the first
3257
+ * update.
3258
+ * @category updates
3259
+ */
3260
+ enableUpdating(_requestedUpdate) { }
3261
+ /**
3262
+ * Allows for `super.disconnectedCallback()` in extensions while
3263
+ * reserving the possibility of making non-breaking feature additions
3264
+ * when disconnecting at some point in the future.
3265
+ * @category lifecycle
3266
+ */
3267
+ disconnectedCallback() {
3268
+ this.__controllers?.forEach((c) => c.hostDisconnected?.());
3269
+ }
3270
+ /**
3271
+ * Synchronizes property values when attributes change.
3272
+ *
3273
+ * Specifically, when an attribute is set, the corresponding property is set.
3274
+ * You should rarely need to implement this callback. If this method is
3275
+ * overridden, `super.attributeChangedCallback(name, _old, value)` must be
3276
+ * called.
3277
+ *
3278
+ * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)
3279
+ * on MDN for more information about the `attributeChangedCallback`.
3280
+ * @category attributes
3281
+ */
3282
+ attributeChangedCallback(name, _old, value) {
3283
+ this._$attributeToProperty(name, value);
3284
+ }
3285
+ __propertyToAttribute(name, value) {
3286
+ const elemProperties = this.constructor.elementProperties;
3287
+ const options = elemProperties.get(name);
3288
+ const attr = this.constructor.__attributeNameForProperty(name, options);
3289
+ if (attr !== undefined && options.reflect === true) {
3290
+ const converter = options.converter?.toAttribute !==
3291
+ undefined
3292
+ ? options.converter
3293
+ : defaultConverter;
3294
+ const attrValue = converter.toAttribute(value, options.type);
3295
+ if (this.constructor.enabledWarnings.includes('migration') &&
3296
+ attrValue === undefined) {
3297
+ issueWarning$1('undefined-attribute-value', `The attribute value for the ${name} property is ` +
3298
+ `undefined on element ${this.localName}. The attribute will be ` +
3299
+ `removed, but in the previous version of \`ReactiveElement\`, ` +
3300
+ `the attribute would not have changed.`);
3301
+ }
3302
+ // Track if the property is being reflected to avoid
3303
+ // setting the property again via `attributeChangedCallback`. Note:
3304
+ // 1. this takes advantage of the fact that the callback is synchronous.
3305
+ // 2. will behave incorrectly if multiple attributes are in the reaction
3306
+ // stack at time of calling. However, since we process attributes
3307
+ // in `update` this should not be possible (or an extreme corner case
3308
+ // that we'd like to discover).
3309
+ // mark state reflecting
3310
+ this.__reflectingProperty = name;
3311
+ if (attrValue == null) {
3312
+ this.removeAttribute(attr);
3313
+ }
3314
+ else {
3315
+ this.setAttribute(attr, attrValue);
3316
+ }
3317
+ // mark state not reflecting
3318
+ this.__reflectingProperty = null;
3319
+ }
3320
+ }
3321
+ /** @internal */
3322
+ _$attributeToProperty(name, value) {
3323
+ const ctor = this.constructor;
3324
+ // Note, hint this as an `AttributeMap` so closure clearly understands
3325
+ // the type; it has issues with tracking types through statics
3326
+ const propName = ctor.__attributeToPropertyMap.get(name);
3327
+ // Use tracking info to avoid reflecting a property value to an attribute
3328
+ // if it was just set because the attribute changed.
3329
+ if (propName !== undefined && this.__reflectingProperty !== propName) {
3330
+ const options = ctor.getPropertyOptions(propName);
3331
+ const converter = typeof options.converter === 'function'
3332
+ ? { fromAttribute: options.converter }
3333
+ : options.converter?.fromAttribute !== undefined
3334
+ ? options.converter
3335
+ : defaultConverter;
3336
+ // mark state reflecting
3337
+ this.__reflectingProperty = propName;
3338
+ this[propName] = converter.fromAttribute(value, options.type
3339
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3340
+ );
3341
+ // mark state not reflecting
3342
+ this.__reflectingProperty = null;
3343
+ }
3344
+ }
3345
+ /**
3346
+ * Requests an update which is processed asynchronously. This should be called
3347
+ * when an element should update based on some state not triggered by setting
3348
+ * a reactive property. In this case, pass no arguments. It should also be
3349
+ * called when manually implementing a property setter. In this case, pass the
3350
+ * property `name` and `oldValue` to ensure that any configured property
3351
+ * options are honored.
3352
+ *
3353
+ * @param name name of requesting property
3354
+ * @param oldValue old value of requesting property
3355
+ * @param options property options to use instead of the previously
3356
+ * configured options
3357
+ * @category updates
3358
+ */
3359
+ requestUpdate(name, oldValue, options) {
3360
+ // If we have a property key, perform property update steps.
3361
+ if (name !== undefined) {
3362
+ if (name instanceof Event) {
3363
+ issueWarning$1(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
3364
+ }
3365
+ options ??= this.constructor.getPropertyOptions(name);
3366
+ const hasChanged = options.hasChanged ?? notEqual;
3367
+ const newValue = this[name];
3368
+ if (hasChanged(newValue, oldValue)) {
3369
+ this._$changeProperty(name, oldValue, options);
3370
+ }
3371
+ else {
3372
+ // Abort the request if the property should not be considered changed.
3373
+ return;
3374
+ }
3375
+ }
3376
+ if (this.isUpdatePending === false) {
3377
+ this.__updatePromise = this.__enqueueUpdate();
3378
+ }
3379
+ }
3380
+ /**
3381
+ * @internal
3382
+ */
3383
+ _$changeProperty(name, oldValue, options) {
3384
+ // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(
3385
+ // vs just Map.set()
3386
+ if (!this._$changedProperties.has(name)) {
3387
+ this._$changedProperties.set(name, oldValue);
3388
+ }
3389
+ // Add to reflecting properties set.
3390
+ // Note, it's important that every change has a chance to add the
3391
+ // property to `__reflectingProperties`. This ensures setting
3392
+ // attribute + property reflects correctly.
3393
+ if (options.reflect === true && this.__reflectingProperty !== name) {
3394
+ (this.__reflectingProperties ??= new Set()).add(name);
3395
+ }
3396
+ }
3397
+ /**
3398
+ * Sets up the element to asynchronously update.
3399
+ */
3400
+ async __enqueueUpdate() {
3401
+ this.isUpdatePending = true;
3402
+ try {
3403
+ // Ensure any previous update has resolved before updating.
3404
+ // This `await` also ensures that property changes are batched.
3405
+ await this.__updatePromise;
3406
+ }
3407
+ catch (e) {
3408
+ // Refire any previous errors async so they do not disrupt the update
3409
+ // cycle. Errors are refired so developers have a chance to observe
3410
+ // them, and this can be done by implementing
3411
+ // `window.onunhandledrejection`.
3412
+ Promise.reject(e);
3413
+ }
3414
+ const result = this.scheduleUpdate();
3415
+ // If `scheduleUpdate` returns a Promise, we await it. This is done to
3416
+ // enable coordinating updates with a scheduler. Note, the result is
3417
+ // checked to avoid delaying an additional microtask unless we need to.
3418
+ if (result != null) {
3419
+ await result;
3420
+ }
3421
+ return !this.isUpdatePending;
3422
+ }
3423
+ /**
3424
+ * Schedules an element update. You can override this method to change the
3425
+ * timing of updates by returning a Promise. The update will await the
3426
+ * returned Promise, and you should resolve the Promise to allow the update
3427
+ * to proceed. If this method is overridden, `super.scheduleUpdate()`
3428
+ * must be called.
3429
+ *
3430
+ * For instance, to schedule updates to occur just before the next frame:
3431
+ *
3432
+ * ```ts
3433
+ * override protected async scheduleUpdate(): Promise<unknown> {
3434
+ * await new Promise((resolve) => requestAnimationFrame(() => resolve()));
3435
+ * super.scheduleUpdate();
3436
+ * }
3437
+ * ```
3438
+ * @category updates
3439
+ */
3440
+ scheduleUpdate() {
3441
+ const result = this.performUpdate();
3442
+ if (this.constructor.enabledWarnings.includes('async-perform-update') &&
3443
+ typeof result?.then ===
3444
+ 'function') {
3445
+ issueWarning$1('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
3446
+ `This behavior is deprecated and will be removed in a future ` +
3447
+ `version of ReactiveElement.`);
3448
+ }
3449
+ return result;
3450
+ }
3451
+ /**
3452
+ * Performs an element update. Note, if an exception is thrown during the
3453
+ * update, `firstUpdated` and `updated` will not be called.
3454
+ *
3455
+ * Call `performUpdate()` to immediately process a pending update. This should
3456
+ * generally not be needed, but it can be done in rare cases when you need to
3457
+ * update synchronously.
3458
+ *
3459
+ * @category updates
3460
+ */
3461
+ performUpdate() {
3462
+ // Abort any update if one is not pending when this is called.
3463
+ // This can happen if `performUpdate` is called early to "flush"
3464
+ // the update.
3465
+ if (!this.isUpdatePending) {
3466
+ return;
3467
+ }
3468
+ debugLogEvent?.({ kind: 'update' });
3469
+ if (!this.hasUpdated) {
3470
+ // Create renderRoot before first update. This occurs in `connectedCallback`
3471
+ // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.
3472
+ this.renderRoot ??=
3473
+ this.createRenderRoot();
3474
+ {
3475
+ // Produce warning if any reactive properties on the prototype are
3476
+ // shadowed by class fields. Instance fields set before upgrade are
3477
+ // deleted by this point, so any own property is caused by class field
3478
+ // initialization in the constructor.
3479
+ const ctor = this.constructor;
3480
+ const shadowedProperties = [...ctor.elementProperties.keys()].filter((p) => this.hasOwnProperty(p) && p in getPrototypeOf(this));
3481
+ if (shadowedProperties.length) {
3482
+ throw new Error(`The following properties on element ${this.localName} will not ` +
3483
+ `trigger updates as expected because they are set using class ` +
3484
+ `fields: ${shadowedProperties.join(', ')}. ` +
3485
+ `Native class fields and some compiled output will overwrite ` +
3486
+ `accessors used for detecting changes. See ` +
3487
+ `https://lit.dev/msg/class-field-shadowing ` +
3488
+ `for more information.`);
3489
+ }
3490
+ }
3491
+ // Mixin instance properties once, if they exist.
3492
+ if (this.__instanceProperties) {
3493
+ // TODO (justinfagnani): should we use the stored value? Could a new value
3494
+ // have been set since we stored the own property value?
3495
+ for (const [p, value] of this.__instanceProperties) {
3496
+ this[p] = value;
3497
+ }
3498
+ this.__instanceProperties = undefined;
3499
+ }
3500
+ // Trigger initial value reflection and populate the initial
3501
+ // changedProperties map, but only for the case of experimental
3502
+ // decorators on accessors, which will not have already populated the
3503
+ // changedProperties map. We can't know if these accessors had
3504
+ // initializers, so we just set them anyway - a difference from
3505
+ // experimental decorators on fields and standard decorators on
3506
+ // auto-accessors.
3507
+ // For context why experimentalDecorators with auto accessors are handled
3508
+ // specifically also see:
3509
+ // https://github.com/lit/lit/pull/4183#issuecomment-1711959635
3510
+ const elementProperties = this.constructor
3511
+ .elementProperties;
3512
+ if (elementProperties.size > 0) {
3513
+ for (const [p, options] of elementProperties) {
3514
+ if (options.wrapped === true &&
3515
+ !this._$changedProperties.has(p) &&
3516
+ this[p] !== undefined) {
3517
+ this._$changeProperty(p, this[p], options);
3518
+ }
3519
+ }
3520
+ }
3521
+ }
3522
+ let shouldUpdate = false;
3523
+ const changedProperties = this._$changedProperties;
3524
+ try {
3525
+ shouldUpdate = this.shouldUpdate(changedProperties);
3526
+ if (shouldUpdate) {
3527
+ this.willUpdate(changedProperties);
3528
+ this.__controllers?.forEach((c) => c.hostUpdate?.());
3529
+ this.update(changedProperties);
3530
+ }
3531
+ else {
3532
+ this.__markUpdated();
3533
+ }
3534
+ }
3535
+ catch (e) {
3536
+ // Prevent `firstUpdated` and `updated` from running when there's an
3537
+ // update exception.
3538
+ shouldUpdate = false;
3539
+ // Ensure element can accept additional updates after an exception.
3540
+ this.__markUpdated();
3541
+ throw e;
3542
+ }
3543
+ // The update is no longer considered pending and further updates are now allowed.
3544
+ if (shouldUpdate) {
3545
+ this._$didUpdate(changedProperties);
3546
+ }
3547
+ }
3548
+ /**
3549
+ * Invoked before `update()` to compute values needed during the update.
3550
+ *
3551
+ * Implement `willUpdate` to compute property values that depend on other
3552
+ * properties and are used in the rest of the update process.
3553
+ *
3554
+ * ```ts
3555
+ * willUpdate(changedProperties) {
3556
+ * // only need to check changed properties for an expensive computation.
3557
+ * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {
3558
+ * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
3559
+ * }
3560
+ * }
3561
+ *
3562
+ * render() {
3563
+ * return html`SHA: ${this.sha}`;
3564
+ * }
3565
+ * ```
3566
+ *
3567
+ * @category updates
3568
+ */
3569
+ willUpdate(_changedProperties) { }
3570
+ // Note, this is an override point for polyfill-support.
3571
+ // @internal
3572
+ _$didUpdate(changedProperties) {
3573
+ this.__controllers?.forEach((c) => c.hostUpdated?.());
3574
+ if (!this.hasUpdated) {
3575
+ this.hasUpdated = true;
3576
+ this.firstUpdated(changedProperties);
3577
+ }
3578
+ this.updated(changedProperties);
3579
+ if (this.isUpdatePending &&
3580
+ this.constructor.enabledWarnings.includes('change-in-update')) {
3581
+ issueWarning$1('change-in-update', `Element ${this.localName} scheduled an update ` +
3582
+ `(generally because a property was set) ` +
3583
+ `after an update completed, causing a new update to be scheduled. ` +
3584
+ `This is inefficient and should be avoided unless the next update ` +
3585
+ `can only be scheduled as a side effect of the previous update.`);
3586
+ }
3587
+ }
3588
+ __markUpdated() {
3589
+ this._$changedProperties = new Map();
3590
+ this.isUpdatePending = false;
3591
+ }
3592
+ /**
3593
+ * Returns a Promise that resolves when the element has completed updating.
3594
+ * The Promise value is a boolean that is `true` if the element completed the
3595
+ * update without triggering another update. The Promise result is `false` if
3596
+ * a property was set inside `updated()`. If the Promise is rejected, an
3597
+ * exception was thrown during the update.
3598
+ *
3599
+ * To await additional asynchronous work, override the `getUpdateComplete`
3600
+ * method. For example, it is sometimes useful to await a rendered element
3601
+ * before fulfilling this Promise. To do this, first await
3602
+ * `super.getUpdateComplete()`, then any subsequent state.
3603
+ *
3604
+ * @return A promise of a boolean that resolves to true if the update completed
3605
+ * without triggering another update.
3606
+ * @category updates
3607
+ */
3608
+ get updateComplete() {
3609
+ return this.getUpdateComplete();
3610
+ }
3611
+ /**
3612
+ * Override point for the `updateComplete` promise.
3613
+ *
3614
+ * It is not safe to override the `updateComplete` getter directly due to a
3615
+ * limitation in TypeScript which means it is not possible to call a
3616
+ * superclass getter (e.g. `super.updateComplete.then(...)`) when the target
3617
+ * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
3618
+ * This method should be overridden instead. For example:
3619
+ *
3620
+ * ```ts
3621
+ * class MyElement extends LitElement {
3622
+ * override async getUpdateComplete() {
3623
+ * const result = await super.getUpdateComplete();
3624
+ * await this._myChild.updateComplete;
3625
+ * return result;
3626
+ * }
3627
+ * }
3628
+ * ```
3629
+ *
3630
+ * @return A promise of a boolean that resolves to true if the update completed
3631
+ * without triggering another update.
3632
+ * @category updates
3633
+ */
3634
+ getUpdateComplete() {
3635
+ return this.__updatePromise;
3636
+ }
3637
+ /**
3638
+ * Controls whether or not `update()` should be called when the element requests
3639
+ * an update. By default, this method always returns `true`, but this can be
3640
+ * customized to control when to update.
3641
+ *
3642
+ * @param _changedProperties Map of changed properties with old values
3643
+ * @category updates
3644
+ */
3645
+ shouldUpdate(_changedProperties) {
3646
+ return true;
3647
+ }
3648
+ /**
3649
+ * Updates the element. This method reflects property values to attributes.
3650
+ * It can be overridden to render and keep updated element DOM.
3651
+ * Setting properties inside this method will *not* trigger
3652
+ * another update.
3653
+ *
3654
+ * @param _changedProperties Map of changed properties with old values
3655
+ * @category updates
3656
+ */
3657
+ update(_changedProperties) {
3658
+ // The forEach() expression will only run when when __reflectingProperties is
3659
+ // defined, and it returns undefined, setting __reflectingProperties to
3660
+ // undefined
3661
+ this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) => this.__propertyToAttribute(p, this[p]));
3662
+ this.__markUpdated();
3663
+ }
3664
+ /**
3665
+ * Invoked whenever the element is updated. Implement to perform
3666
+ * post-updating tasks via DOM APIs, for example, focusing an element.
3667
+ *
3668
+ * Setting properties inside this method will trigger the element to update
3669
+ * again after this update cycle completes.
3670
+ *
3671
+ * @param _changedProperties Map of changed properties with old values
3672
+ * @category updates
3673
+ */
3674
+ updated(_changedProperties) { }
3675
+ /**
3676
+ * Invoked when the element is first updated. Implement to perform one time
3677
+ * work on the element after update.
3678
+ *
3679
+ * ```ts
3680
+ * firstUpdated() {
3681
+ * this.renderRoot.getElementById('my-text-area').focus();
3682
+ * }
3683
+ * ```
3684
+ *
3685
+ * Setting properties inside this method will trigger the element to update
3686
+ * again after this update cycle completes.
3687
+ *
3688
+ * @param _changedProperties Map of changed properties with old values
3689
+ * @category updates
3690
+ */
3691
+ firstUpdated(_changedProperties) { }
3692
+ }
3693
+ /**
3694
+ * Memoized list of all element styles.
3695
+ * Created lazily on user subclasses when finalizing the class.
3696
+ * @nocollapse
3697
+ * @category styles
3698
+ */
3699
+ ReactiveElement.elementStyles = [];
3700
+ /**
3701
+ * Options used when calling `attachShadow`. Set this property to customize
3702
+ * the options for the shadowRoot; for example, to create a closed
3703
+ * shadowRoot: `{mode: 'closed'}`.
3704
+ *
3705
+ * Note, these options are used in `createRenderRoot`. If this method
3706
+ * is customized, options should be respected if possible.
3707
+ * @nocollapse
3708
+ * @category rendering
3709
+ */
3710
+ ReactiveElement.shadowRootOptions = { mode: 'open' };
3711
+ // Assigned here to work around a jscompiler bug with static fields
3712
+ // when compiling to ES5.
3713
+ // https://github.com/google/closure-compiler/issues/3177
3714
+ ReactiveElement[JSCompiler_renameProperty$1('elementProperties')] = new Map();
3715
+ ReactiveElement[JSCompiler_renameProperty$1('finalized')] = new Map();
3716
+ // Apply polyfills if available
3717
+ polyfillSupport$1?.({ ReactiveElement });
3718
+ // Dev mode warnings...
3719
+ {
3720
+ // Default warning set.
3721
+ ReactiveElement.enabledWarnings = [
3722
+ 'change-in-update',
3723
+ 'async-perform-update',
3724
+ ];
3725
+ const ensureOwnWarnings = function (ctor) {
3726
+ if (!ctor.hasOwnProperty(JSCompiler_renameProperty$1('enabledWarnings'))) {
3727
+ ctor.enabledWarnings = ctor.enabledWarnings.slice();
3728
+ }
3729
+ };
3730
+ ReactiveElement.enableWarning = function (warning) {
3731
+ ensureOwnWarnings(this);
3732
+ if (!this.enabledWarnings.includes(warning)) {
3733
+ this.enabledWarnings.push(warning);
3734
+ }
3735
+ };
3736
+ ReactiveElement.disableWarning = function (warning) {
3737
+ ensureOwnWarnings(this);
3738
+ const i = this.enabledWarnings.indexOf(warning);
3739
+ if (i >= 0) {
3740
+ this.enabledWarnings.splice(i, 1);
3741
+ }
3742
+ };
3743
+ }
3744
+ // IMPORTANT: do not change the property name or the assignment expression.
3745
+ // This line will be used in regexes to search for ReactiveElement usage.
3746
+ (global.reactiveElementVersions ??= []).push('2.0.4');
3747
+ if (global.reactiveElementVersions.length > 1) {
3748
+ issueWarning$1('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3749
+ `is not recommended.`);
3750
+ }
3751
+
3752
+ /**
3753
+ * @license
3754
+ * Copyright 2017 Google LLC
3755
+ * SPDX-License-Identifier: BSD-3-Clause
3756
+ */
3757
+ /*
3758
+ * When using Closure Compiler, JSCompiler_renameProperty(property, object) is
3759
+ * replaced at compile time by the munged name for object[property]. We cannot
3760
+ * alias this function, so we have to use a small shim that has the same
3761
+ * behavior when not compiling.
3762
+ */
3763
+ /*@__INLINE__*/
3764
+ const JSCompiler_renameProperty = (prop, _obj) => prop;
3765
+ let issueWarning;
3766
+ {
3767
+ // Ensure warnings are issued only 1x, even if multiple versions of Lit
3768
+ // are loaded.
3769
+ const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
3770
+ // Issue a warning, if we haven't already.
3771
+ issueWarning = (code, warning) => {
3772
+ warning += ` See https://lit.dev/msg/${code} for more information.`;
3773
+ if (!issuedWarnings.has(warning)) {
3774
+ console.warn(warning);
3775
+ issuedWarnings.add(warning);
3776
+ }
3777
+ };
3778
+ }
3779
+ /**
3780
+ * Base element class that manages element properties and attributes, and
3781
+ * renders a lit-html template.
3782
+ *
3783
+ * To define a component, subclass `LitElement` and implement a
3784
+ * `render` method to provide the component's template. Define properties
3785
+ * using the {@linkcode LitElement.properties properties} property or the
3786
+ * {@linkcode property} decorator.
3787
+ */
3788
+ class LitElement extends ReactiveElement {
3789
+ constructor() {
3790
+ super(...arguments);
3791
+ /**
3792
+ * @category rendering
3793
+ */
3794
+ this.renderOptions = { host: this };
3795
+ this.__childPart = undefined;
3796
+ }
3797
+ /**
3798
+ * @category rendering
3799
+ */
3800
+ createRenderRoot() {
3801
+ const renderRoot = super.createRenderRoot();
3802
+ // When adoptedStyleSheets are shimmed, they are inserted into the
3803
+ // shadowRoot by createRenderRoot. Adjust the renderBefore node so that
3804
+ // any styles in Lit content render before adoptedStyleSheets. This is
3805
+ // important so that adoptedStyleSheets have precedence over styles in
3806
+ // the shadowRoot.
3807
+ this.renderOptions.renderBefore ??= renderRoot.firstChild;
3808
+ return renderRoot;
3809
+ }
3810
+ /**
3811
+ * Updates the element. This method reflects property values to attributes
3812
+ * and calls `render` to render DOM via lit-html. Setting properties inside
3813
+ * this method will *not* trigger another update.
3814
+ * @param changedProperties Map of changed properties with old values
3815
+ * @category updates
3816
+ */
3817
+ update(changedProperties) {
3818
+ // Setting properties in `render` should not trigger an update. Since
3819
+ // updates are allowed after super.update, it's important to call `render`
3820
+ // before that.
3821
+ const value = this.render();
3822
+ if (!this.hasUpdated) {
3823
+ this.renderOptions.isConnected = this.isConnected;
3824
+ }
3825
+ super.update(changedProperties);
3826
+ this.__childPart = render(value, this.renderRoot, this.renderOptions);
3827
+ }
3828
+ /**
3829
+ * Invoked when the component is added to the document's DOM.
3830
+ *
3831
+ * In `connectedCallback()` you should setup tasks that should only occur when
3832
+ * the element is connected to the document. The most common of these is
3833
+ * adding event listeners to nodes external to the element, like a keydown
3834
+ * event handler added to the window.
3835
+ *
3836
+ * ```ts
3837
+ * connectedCallback() {
3838
+ * super.connectedCallback();
3839
+ * addEventListener('keydown', this._handleKeydown);
3840
+ * }
3841
+ * ```
3842
+ *
3843
+ * Typically, anything done in `connectedCallback()` should be undone when the
3844
+ * element is disconnected, in `disconnectedCallback()`.
3845
+ *
3846
+ * @category lifecycle
3847
+ */
3848
+ connectedCallback() {
3849
+ super.connectedCallback();
3850
+ this.__childPart?.setConnected(true);
3851
+ }
3852
+ /**
3853
+ * Invoked when the component is removed from the document's DOM.
3854
+ *
3855
+ * This callback is the main signal to the element that it may no longer be
3856
+ * used. `disconnectedCallback()` should ensure that nothing is holding a
3857
+ * reference to the element (such as event listeners added to nodes external
3858
+ * to the element), so that it is free to be garbage collected.
3859
+ *
3860
+ * ```ts
3861
+ * disconnectedCallback() {
3862
+ * super.disconnectedCallback();
3863
+ * window.removeEventListener('keydown', this._handleKeydown);
3864
+ * }
3865
+ * ```
3866
+ *
3867
+ * An element may be re-connected after being disconnected.
3868
+ *
3869
+ * @category lifecycle
3870
+ */
3871
+ disconnectedCallback() {
3872
+ super.disconnectedCallback();
3873
+ this.__childPart?.setConnected(false);
3874
+ }
3875
+ /**
3876
+ * Invoked on each update to perform rendering tasks. This method may return
3877
+ * any value renderable by lit-html's `ChildPart` - typically a
3878
+ * `TemplateResult`. Setting properties inside this method will *not* trigger
3879
+ * the element to update.
3880
+ * @category rendering
3881
+ */
3882
+ render() {
3883
+ return noChange;
3884
+ }
3885
+ }
3886
+ // This property needs to remain unminified.
3887
+ LitElement['_$litElement$'] = true;
3888
+ /**
3889
+ * Ensure this class is marked as `finalized` as an optimization ensuring
3890
+ * it will not needlessly try to `finalize`.
3891
+ *
3892
+ * Note this property name is a string to prevent breaking Closure JS Compiler
3893
+ * optimizations. See @lit/reactive-element for more information.
3894
+ */
3895
+ LitElement[JSCompiler_renameProperty('finalized')] = true;
3896
+ // Install hydration if available
3897
+ globalThis.litElementHydrateSupport?.({ LitElement });
3898
+ // Apply polyfills if available
3899
+ const polyfillSupport = globalThis.litElementPolyfillSupportDevMode
3900
+ ;
3901
+ polyfillSupport?.({ LitElement });
3902
+ // IMPORTANT: do not change the property name or the assignment expression.
3903
+ // This line will be used in regexes to search for LitElement usage.
3904
+ (globalThis.litElementVersions ??= []).push('4.1.0');
3905
+ if (globalThis.litElementVersions.length > 1) {
3906
+ issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3907
+ `is not recommended.`);
3908
+ }
3909
+
3910
+ var css_248z$1 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color-default);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-body);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}a[target=_blank]{align-items:center;display:flex;gap:var(--sgds-gap-2-xs)}::slotted(a[target=_blank]):after,a[target=_blank]:after{background-color:currentColor;content:"/";display:inline-block;-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.274 3.9H9.3a.6.6 0 0 1 0 1.2c-.85 0-1.451 0-1.922.039-.463.038-.745.11-.968.223A2.4 2.4 0 0 0 5.361 6.41c-.113.223-.184.505-.222.968-.039.47-.04 1.072-.04 1.922v5.4c0 .85.001 1.451.04 1.922.038.463.11.745.222.968a2.4 2.4 0 0 0 1.05 1.048c.222.114.504.185.967.223.47.038 1.072.039 1.922.039h5.4c.85 0 1.451 0 1.921-.039.464-.038.746-.11.969-.223a2.4 2.4 0 0 0 1.048-1.048c.113-.223.185-.505.223-.968.038-.47.039-1.072.039-1.922a.6.6 0 1 1 1.2 0v.026c0 .818 0 1.469-.043 1.993-.044.538-.136.996-.35 1.415a3.6 3.6 0 0 1-1.573 1.574c-.42.213-.878.305-1.415.35-.525.042-1.175.042-1.993.042H9.274c-.818 0-1.469 0-1.993-.043-.538-.044-.996-.136-1.415-.35a3.6 3.6 0 0 1-1.574-1.573c-.213-.42-.305-.877-.35-1.415-.042-.524-.042-1.175-.042-1.993V9.274c0-.818 0-1.468.043-1.993.044-.538.136-.996.35-1.415a3.6 3.6 0 0 1 1.573-1.574c.42-.213.877-.305 1.415-.35C7.805 3.9 8.456 3.9 9.274 3.9Zm3.626.6a.6.6 0 0 1 .6-.6h6a.6.6 0 0 1 .6.6v6a.6.6 0 1 1-1.2 0V5.949l-5.976 5.975a.6.6 0 0 1-.848-.848L18.05 5.1H13.5a.6.6 0 0 1-.6-.6Z' fill='%230E0E0E'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.274 3.9H9.3a.6.6 0 0 1 0 1.2c-.85 0-1.451 0-1.922.039-.463.038-.745.11-.968.223A2.4 2.4 0 0 0 5.361 6.41c-.113.223-.184.505-.222.968-.039.47-.04 1.072-.04 1.922v5.4c0 .85.001 1.451.04 1.922.038.463.11.745.222.968a2.4 2.4 0 0 0 1.05 1.048c.222.114.504.185.967.223.47.038 1.072.039 1.922.039h5.4c.85 0 1.451 0 1.921-.039.464-.038.746-.11.969-.223a2.4 2.4 0 0 0 1.048-1.048c.113-.223.185-.505.223-.968.038-.47.039-1.072.039-1.922a.6.6 0 1 1 1.2 0v.026c0 .818 0 1.469-.043 1.993-.044.538-.136.996-.35 1.415a3.6 3.6 0 0 1-1.573 1.574c-.42.213-.878.305-1.415.35-.525.042-1.175.042-1.993.042H9.274c-.818 0-1.469 0-1.993-.043-.538-.044-.996-.136-1.415-.35a3.6 3.6 0 0 1-1.574-1.573c-.213-.42-.305-.877-.35-1.415-.042-.524-.042-1.175-.042-1.993V9.274c0-.818 0-1.468.043-1.993.044-.538.136-.996.35-1.415a3.6 3.6 0 0 1 1.573-1.574c.42-.213.877-.305 1.415-.35C7.805 3.9 8.456 3.9 9.274 3.9Zm3.626.6a.6.6 0 0 1 .6-.6h6a.6.6 0 0 1 .6.6v6a.6.6 0 1 1-1.2 0V5.949l-5.976 5.975a.6.6 0 0 1-.848-.848L18.05 5.1H13.5a.6.6 0 0 1-.6-.6Z' fill='%230E0E0E'/%3E%3C/svg%3E");-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;padding:0 .45em}::slotted(svg){vertical-align:middle}}`;
3911
+
3912
+ /**
3913
+ * @cssprop --sgds-{stateColor} - State colors in hexadecimal value
3914
+ * @cssprop --sgds-{stateColor}-rgb - State colors in rgb value
3915
+ * @cssprop --sgds-{stateColor}-{weights} - State colors with different weightage in hexadecimal value
3916
+ * @cssprop --sgds-gray-{weights} - State colors with different weightage in hexadecimal value
3917
+ * @cssprop --overlay-background-color - The drawer and modal component overlay background color
3918
+ * @cssprop --zindex-modal - The drawer and modal component z-index value
3919
+ */
3920
+ class SgdsElement extends LitElement {
3921
+ /** Emits a custom event with more convenient defaults. */
3922
+ emit(name, options) {
3923
+ const event = new CustomEvent(name, Object.assign({ bubbles: true, cancelable: false, composed: true, detail: {} }, options));
3924
+ this.dispatchEvent(event);
3925
+ return event;
3926
+ }
3927
+ static define(name, elementConstructor = this, options = {}) {
3928
+ const currentlyRegisteredConstructor = customElements.get(name);
3929
+ if (!currentlyRegisteredConstructor) {
3930
+ // We try to register as the actual class first. If for some reason that fails, we fall back to anonymous classes.
3931
+ // customElements can only have 1 class of the same "object id" per registry, so that is why the try {} catch {} exists.
3932
+ // Some tools like Jest Snapshots and if you import the constructor and call `new SgdsButton()` they will fail with
3933
+ // the anonymous class version.
3934
+ try {
3935
+ customElements.define(name, elementConstructor, options);
3936
+ }
3937
+ catch (_err) {
3938
+ customElements.define(name, class extends elementConstructor {
3939
+ }, options);
3940
+ }
3941
+ return;
3942
+ }
3943
+ // let newVersion = ' (unknown version)';
3944
+ // let existingVersion = newVersion;
3945
+ // if ('version' in elementConstructor && elementConstructor.version) {
3946
+ // newVersion = ' v' + elementConstructor.version;
3947
+ // }
3948
+ // if ('version' in currentlyRegisteredConstructor && currentlyRegisteredConstructor.version) {
3949
+ // existingVersion = ' v' + currentlyRegisteredConstructor.version;
3950
+ // }
3951
+ // // Need to make sure we're not working with null or empty strings before doing version comparisons.
3952
+ // if (newVersion && existingVersion && newVersion === existingVersion) {
3953
+ // // If versions match, we don't need to warn anyone. Carry on.
3954
+ // return;
3955
+ // }
3956
+ // console.warn(
3957
+ // `Attempted to register <${name}>${newVersion}, but <${name}>${existingVersion} has already been registered.`
3958
+ // );
3959
+ }
3960
+ constructor() {
3961
+ super();
3962
+ Object.entries(this.constructor.dependencies).forEach(([name, component]) => {
3963
+ this.constructor.define(name, component);
3964
+ });
3965
+ }
3966
+ }
3967
+ SgdsElement.styles = [css_248z$1];
3968
+ /** @internal */
3969
+ SgdsElement.dependencies = {};
3970
+
3971
+ var css_248z = css`.container{display:flex;flex-direction:column;gap:var(--sgds-gap-xl)}slot:not([name])::slotted(*){--sgds-font-size-5:var(--sgds-font-size-4);--sgds-font-size-6:var(--sgds-font-size-4);--sgds-margin-2-xs:var(--sgds-margin-none);--sgds-font-weight-bold:var(--sgds-font-weight-semibold);font-size:var(--sgds-font-size-4);font-weight:var(--sgds-font-weight-bold,var(--sgds-font-weight-semibold));margin-bottom:var(--sgds-margin-2-xs,var(--sgds-margin-none))}.contents{display:flex;flex-direction:column;gap:var(--sgds-gap-md);list-style:none;margin:var(--sgds-margin-none);padding:var(--sgds-padding-none)}slot[name=contents]::slotted(li){--sgds-margin-3-xs:var(--sgds-margin-none);margin-top:var(--sgds-margin-3-xs,var(--sgds-margin-none))}`;
3972
+
3973
+ /**
3974
+ *
3975
+ * @summary Tables of contents provide a page overview and direct access to specific sections.
3976
+ *
3977
+ * @slot default - The slot for the header
3978
+ * @slot contents - The slot for the contents
3979
+ */
3980
+ class SgdsTableOfContents extends SgdsElement {
3981
+ render() {
3982
+ return html `<div class="container">
3983
+ <slot></slot>
3984
+ <ul class="contents">
3985
+ <slot name="contents"></slot>
3986
+ </ul>
3987
+ </div> `;
3988
+ }
3989
+ }
3990
+ SgdsTableOfContents.styles = [...SgdsElement.styles, css_248z];
3991
+
3992
+ customElements.define("sgds-table-of-contents", SgdsTableOfContents);
3993
+
3994
+ }));
3995
+ //# sourceMappingURL=index.umd.js.map