@prolibu-suite/cobalt-core 0.1.2 → 0.2.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 (555) hide show
  1. package/custom-elements.json +15359 -5571
  2. package/dist/cjs/co-accordion.cjs.entry.js +19 -4
  3. package/dist/cjs/co-app-shell.cjs.entry.js +1 -1
  4. package/dist/cjs/co-autocomplete.cjs.entry.js +51 -6
  5. package/dist/cjs/co-avatar.cjs.entry.js +40 -7
  6. package/dist/cjs/co-badge.cjs.entry.js +1 -1
  7. package/dist/cjs/co-button-group.cjs.entry.js +1 -1
  8. package/dist/cjs/co-button.cjs.entry.js +10 -5
  9. package/dist/cjs/co-calendar_3.cjs.entry.js +692 -0
  10. package/dist/cjs/co-card.cjs.entry.js +21 -4
  11. package/dist/cjs/co-checkbox-group.cjs.entry.js +7 -5
  12. package/dist/cjs/co-checkbox.cjs.entry.js +4 -4
  13. package/dist/cjs/co-chip.cjs.entry.js +3 -3
  14. package/dist/cjs/co-color-picker.cjs.entry.js +109 -0
  15. package/dist/cjs/co-column-picker.cjs.entry.js +443 -0
  16. package/dist/cjs/co-combobox.cjs.entry.js +51 -15
  17. package/dist/cjs/co-command-search.cjs.entry.js +14 -7
  18. package/dist/cjs/co-data-table-pagination.cjs.entry.js +5 -5
  19. package/dist/cjs/co-data-table.cjs.entry.js +17 -5
  20. package/dist/cjs/co-date-picker.cjs.entry.js +177 -0
  21. package/dist/cjs/co-date-range-picker.cjs.entry.js +378 -0
  22. package/dist/cjs/co-date-range.cjs.entry.js +13 -259
  23. package/dist/cjs/co-empty-state.cjs.entry.js +2 -2
  24. package/dist/cjs/co-fab.cjs.entry.js +3 -3
  25. package/dist/cjs/co-file-field.cjs.entry.js +498 -0
  26. package/dist/cjs/co-helper-text.cjs.entry.js +3 -3
  27. package/dist/cjs/co-icon-button.cjs.entry.js +4 -4
  28. package/dist/cjs/co-icon.cjs.entry.js +7 -4
  29. package/dist/cjs/co-input.cjs.entry.js +13 -8
  30. package/dist/cjs/co-json-field.cjs.entry.js +109 -0
  31. package/dist/cjs/co-lightbox.cjs.entry.js +344 -0
  32. package/dist/cjs/co-list-item.cjs.entry.js +14 -4
  33. package/dist/cjs/co-loader.cjs.entry.js +1 -1
  34. package/dist/cjs/co-menu-divider.cjs.entry.js +2 -2
  35. package/dist/cjs/co-menu-item.cjs.entry.js +1 -1
  36. package/dist/cjs/co-menu.cjs.entry.js +2 -2
  37. package/dist/cjs/co-modal.cjs.entry.js +13 -3
  38. package/dist/cjs/co-navbar.cjs.entry.js +4 -4
  39. package/dist/cjs/co-number-field.cjs.entry.js +47 -11
  40. package/dist/cjs/co-overlay.cjs.entry.js +2 -2
  41. package/dist/cjs/co-page-header.cjs.entry.js +2 -2
  42. package/dist/cjs/co-phone-field.cjs.entry.js +376 -0
  43. package/dist/cjs/co-popover.cjs.entry.js +4 -4
  44. package/dist/cjs/co-progress-bar.cjs.entry.js +3 -3
  45. package/dist/cjs/co-progress-circle.cjs.entry.js +38 -0
  46. package/dist/cjs/co-radio-group.cjs.entry.js +7 -5
  47. package/dist/cjs/co-radio.cjs.entry.js +4 -4
  48. package/dist/cjs/co-rating.cjs.entry.js +4 -4
  49. package/dist/cjs/co-ref-field.cjs.entry.js +191 -21
  50. package/dist/cjs/co-rich-text-editor.cjs.entry.js +235 -0
  51. package/dist/cjs/co-rich-text-toolbar.cjs.entry.js +184 -0
  52. package/dist/cjs/co-rich-text-viewer.cjs.entry.js +82 -0
  53. package/dist/cjs/co-row.cjs.entry.js +3 -3
  54. package/dist/cjs/co-select.cjs.entry.js +119 -18
  55. package/dist/cjs/co-separator.cjs.entry.js +2 -2
  56. package/dist/cjs/co-sidebar-nav.cjs.entry.js +30 -5
  57. package/dist/cjs/co-sidebar.cjs.entry.js +3 -3
  58. package/dist/cjs/co-slider.cjs.entry.js +3 -3
  59. package/dist/cjs/co-switch.cjs.entry.js +9 -6
  60. package/dist/cjs/co-tab-group.cjs.entry.js +2 -2
  61. package/dist/cjs/co-tab.cjs.entry.js +3 -3
  62. package/dist/cjs/co-tags-field.cjs.entry.js +205 -0
  63. package/dist/cjs/co-textarea.cjs.entry.js +92 -0
  64. package/dist/cjs/co-toast.cjs.entry.js +2 -2
  65. package/dist/cjs/co-toggle-button-group.cjs.entry.js +7 -4
  66. package/dist/cjs/co-toggle-button.cjs.entry.js +4 -4
  67. package/dist/cjs/co-tooltip.cjs.entry.js +12 -6
  68. package/dist/cjs/co-transfer-list.cjs.entry.js +20 -6
  69. package/dist/cjs/cobalt.cjs.js +2 -2
  70. package/dist/cjs/dateI18n-BdiNAl0_.js +106 -0
  71. package/dist/cjs/dates-D8D-aS5d.js +432 -0
  72. package/dist/cjs/index-CaEJnpZe.js +27213 -0
  73. package/dist/cjs/{index-BEovErzl.js → index-DoFnrUVH.js} +79 -11
  74. package/dist/cjs/loader.cjs.js +2 -2
  75. package/dist/cjs/normalizeText-B-v-XPKf.js +96 -0
  76. package/dist/cjs/overlayScroll-ifzDNeyb.js +25 -0
  77. package/dist/cjs/overlayscrollbars-BlBHo2Xx.js +2842 -0
  78. package/dist/cjs/{positioning-DozpXyBd.js → positioning-DwHW399W.js} +40 -25
  79. package/dist/cjs/requiredMark-DA6y-4rp.js +16 -0
  80. package/dist/cjs/sanitizer-CjHZAkOm.js +1883 -0
  81. package/dist/cobalt/cobalt.css +1 -1
  82. package/dist/cobalt/cobalt.esm.js +1 -1
  83. package/dist/cobalt/{p-1021f612.entry.js → p-01fc77c4.entry.js} +1 -1
  84. package/dist/cobalt/p-0a6d8061.entry.js +1 -0
  85. package/dist/cobalt/{p-ff6a647c.entry.js → p-0bf288cd.entry.js} +1 -1
  86. package/dist/cobalt/p-136bdbd2.entry.js +1 -0
  87. package/dist/cobalt/{p-1b7d6808.entry.js → p-15708d32.entry.js} +1 -1
  88. package/dist/cobalt/{p-cc93ab05.entry.js → p-1578b019.entry.js} +1 -1
  89. package/dist/cobalt/{p-1b5c723a.entry.js → p-1e0282b8.entry.js} +1 -1
  90. package/dist/cobalt/p-23d48581.entry.js +1 -0
  91. package/dist/cobalt/p-2718ff27.entry.js +1 -0
  92. package/dist/cobalt/p-273afd93.entry.js +1 -0
  93. package/dist/cobalt/{p-c9b0e73f.entry.js → p-2b4d8535.entry.js} +1 -1
  94. package/dist/cobalt/p-3190d715.entry.js +1 -0
  95. package/dist/cobalt/p-3f9b3fcb.entry.js +1 -0
  96. package/dist/cobalt/p-41228dce.entry.js +1 -0
  97. package/dist/cobalt/{p-5a13e3a0.entry.js → p-44672953.entry.js} +1 -1
  98. package/dist/cobalt/{p-4cf6d1f4.entry.js → p-522fcdb7.entry.js} +1 -1
  99. package/dist/cobalt/p-53ce9023.entry.js +1 -0
  100. package/dist/cobalt/{p-4d8ff00a.entry.js → p-54f26e95.entry.js} +1 -1
  101. package/dist/cobalt/p-5d01bd4d.entry.js +1 -0
  102. package/dist/cobalt/p-5e7141aa.entry.js +1 -0
  103. package/dist/cobalt/p-5f905739.entry.js +1 -0
  104. package/dist/cobalt/{p-fb047df8.entry.js → p-6404bd21.entry.js} +1 -1
  105. package/dist/cobalt/p-654bbc2a.entry.js +1 -0
  106. package/dist/cobalt/p-6678ac0a.entry.js +1 -0
  107. package/dist/cobalt/{p-e808916c.entry.js → p-66a912dd.entry.js} +1 -1
  108. package/dist/cobalt/p-6759ee1c.entry.js +1 -0
  109. package/dist/cobalt/p-69a40bfd.entry.js +1 -0
  110. package/dist/cobalt/p-6a6a62cb.entry.js +1 -0
  111. package/dist/cobalt/p-6d43b6cd.entry.js +1 -0
  112. package/dist/cobalt/p-759c3dd0.entry.js +1 -0
  113. package/dist/cobalt/p-782f729f.entry.js +1 -0
  114. package/dist/cobalt/{p-ebd1555e.entry.js → p-7ef766c6.entry.js} +1 -1
  115. package/dist/cobalt/p-7f818368.entry.js +1 -0
  116. package/dist/cobalt/p-83b89bf8.entry.js +1 -0
  117. package/dist/cobalt/p-88dc561a.entry.js +1 -0
  118. package/dist/cobalt/{p-4905b51d.entry.js → p-8c27aff7.entry.js} +1 -1
  119. package/dist/cobalt/{p-a7fa4484.entry.js → p-95d14878.entry.js} +1 -1
  120. package/dist/cobalt/{p-1d7da33f.entry.js → p-97c20011.entry.js} +1 -1
  121. package/dist/cobalt/p-996179f7.entry.js +1 -0
  122. package/dist/cobalt/p-9c533830.entry.js +1 -0
  123. package/dist/cobalt/p-9d89bf47.entry.js +1 -0
  124. package/dist/cobalt/p-BKmfyPZK.js +2 -0
  125. package/dist/cobalt/p-BchB6Hdr.js +1 -0
  126. package/dist/cobalt/p-C1DCLOEl.js +1 -0
  127. package/dist/cobalt/p-C2mZ7x_Y.js +1 -0
  128. package/dist/cobalt/p-CQY6Ul7q.js +1 -0
  129. package/dist/cobalt/p-CyYF8IJE.js +1 -0
  130. package/dist/cobalt/p-DcK0GGZC.js +2 -0
  131. package/dist/cobalt/p-DqyWGweA.js +1 -0
  132. package/dist/cobalt/p-Qqq8fysz.js +1 -0
  133. package/dist/cobalt/p-aa17c70b.entry.js +1 -0
  134. package/dist/cobalt/{p-416bb5ae.entry.js → p-aa63812a.entry.js} +1 -1
  135. package/dist/cobalt/p-ad4c1b41.entry.js +1 -0
  136. package/dist/cobalt/p-ae4d3207.entry.js +1 -0
  137. package/dist/cobalt/p-af64da37.entry.js +1 -0
  138. package/dist/cobalt/p-b758c2e6.entry.js +1 -0
  139. package/dist/cobalt/p-bb07da22.entry.js +1 -0
  140. package/dist/cobalt/p-beb9c11d.entry.js +1 -0
  141. package/dist/cobalt/p-c6a242e4.entry.js +1 -0
  142. package/dist/cobalt/p-c87285b6.entry.js +1 -0
  143. package/dist/cobalt/p-cd57e8b4.entry.js +1 -0
  144. package/dist/cobalt/{p-4ffba5a3.entry.js → p-ce3a535f.entry.js} +1 -1
  145. package/dist/cobalt/p-d17e1444.entry.js +1 -0
  146. package/dist/cobalt/p-d958566a.entry.js +1 -0
  147. package/dist/cobalt/p-dd873bf8.entry.js +1 -0
  148. package/dist/cobalt/p-def448e4.entry.js +1 -0
  149. package/dist/cobalt/p-e4de8865.entry.js +1 -0
  150. package/dist/cobalt/{p-3b2f7959.entry.js → p-e8b58332.entry.js} +1 -1
  151. package/dist/cobalt/p-eba0bf7f.entry.js +1 -0
  152. package/dist/cobalt/p-f0e8fa7d.entry.js +1 -0
  153. package/dist/cobalt/{p-e50c4c6f.entry.js → p-f2c5cb74.entry.js} +1 -1
  154. package/dist/cobalt/p-f8728b21.entry.js +1 -0
  155. package/dist/cobalt/{p-697df797.entry.js → p-f97ad9ad.entry.js} +1 -1
  156. package/dist/cobalt/p-fad3605d.entry.js +1 -0
  157. package/dist/cobalt/{p-319937c3.entry.js → p-fe9e85b6.entry.js} +1 -1
  158. package/dist/cobalt/p-ff2690e5.entry.js +1 -0
  159. package/dist/cobalt/p-ox7HzCZn.js +10 -0
  160. package/dist/collection/collection-manifest.json +17 -1
  161. package/dist/collection/components/co-accordion/co-accordion.css +19 -1
  162. package/dist/collection/components/co-accordion/co-accordion.js +46 -4
  163. package/dist/collection/components/co-autocomplete/co-autocomplete.css +725 -7
  164. package/dist/collection/components/co-autocomplete/co-autocomplete.js +88 -4
  165. package/dist/collection/components/co-avatar/co-avatar.css +7 -0
  166. package/dist/collection/components/co-avatar/co-avatar.js +35 -6
  167. package/dist/collection/components/co-button/co-button.css +8 -5
  168. package/dist/collection/components/co-button/co-button.js +46 -3
  169. package/dist/collection/components/co-calendar/co-calendar.css +236 -0
  170. package/dist/collection/components/co-calendar/co-calendar.js +728 -0
  171. package/dist/collection/components/co-card/co-card.css +28 -5
  172. package/dist/collection/components/co-card/co-card.js +47 -4
  173. package/dist/collection/components/co-checkbox/co-checkbox.js +3 -3
  174. package/dist/collection/components/co-checkbox-group/co-checkbox-group.css +26 -0
  175. package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +25 -3
  176. package/dist/collection/components/co-chip/co-chip.js +2 -2
  177. package/dist/collection/components/co-color-picker/co-color-picker.css +224 -0
  178. package/dist/collection/components/co-color-picker/co-color-picker.js +333 -0
  179. package/dist/collection/components/co-color-picker/presets.js +19 -0
  180. package/dist/collection/components/co-column-picker/co-column-picker.css +490 -0
  181. package/dist/collection/components/co-column-picker/co-column-picker.js +675 -0
  182. package/dist/collection/components/co-column-picker/column-picker-node.js +34 -0
  183. package/dist/collection/components/co-column-picker/utils/column-picker-tree.js +221 -0
  184. package/dist/collection/components/co-combobox/co-combobox.css +788 -21
  185. package/dist/collection/components/co-combobox/co-combobox.js +130 -15
  186. package/dist/collection/components/co-command-search/co-command-search.css +4 -0
  187. package/dist/collection/components/co-command-search/co-command-search.js +12 -5
  188. package/dist/collection/components/co-data-table/co-data-table.css +1 -1
  189. package/dist/collection/components/co-data-table/co-data-table.js +15 -3
  190. package/dist/collection/components/co-data-table-pagination/co-data-table-pagination.js +4 -4
  191. package/dist/collection/components/co-date-field/co-date-field.css +239 -0
  192. package/dist/collection/components/co-date-field/co-date-field.js +746 -0
  193. package/dist/collection/components/co-date-picker/co-date-picker.css +112 -0
  194. package/dist/collection/components/co-date-picker/co-date-picker.js +801 -0
  195. package/dist/collection/components/co-date-range/co-date-range.css +3 -254
  196. package/dist/collection/components/co-date-range/co-date-range.js +29 -433
  197. package/dist/collection/components/co-date-range-picker/co-date-range-picker.css +251 -0
  198. package/dist/collection/components/co-date-range-picker/co-date-range-picker.js +1142 -0
  199. package/dist/collection/components/co-drawer/co-drawer.css +19 -0
  200. package/dist/collection/components/co-drawer/co-drawer.js +46 -2
  201. package/dist/collection/components/co-empty-state/co-empty-state.js +1 -1
  202. package/dist/collection/components/co-fab/co-fab.js +2 -2
  203. package/dist/collection/components/co-file-field/co-file-field.css +389 -0
  204. package/dist/collection/components/co-file-field/co-file-field.js +841 -0
  205. package/dist/collection/components/co-file-field/co-file-field.utils.js +47 -0
  206. package/dist/collection/components/co-helper-text/co-helper-text.js +2 -2
  207. package/dist/collection/components/co-icon/co-icon.js +6 -3
  208. package/dist/collection/components/co-icon-button/co-icon-button.css +10 -0
  209. package/dist/collection/components/co-icon-button/co-icon-button.js +4 -4
  210. package/dist/collection/components/co-input/co-input.css +56 -10
  211. package/dist/collection/components/co-input/co-input.js +34 -9
  212. package/dist/collection/components/co-json-field/co-json-field.css +169 -0
  213. package/dist/collection/components/co-json-field/co-json-field.js +453 -0
  214. package/dist/collection/components/co-lightbox/co-lightbox.css +164 -0
  215. package/dist/collection/components/co-lightbox/co-lightbox.js +451 -0
  216. package/dist/collection/components/co-list-item/co-list-item.css +5 -0
  217. package/dist/collection/components/co-list-item/co-list-item.js +12 -2
  218. package/dist/collection/components/co-menu/co-menu.js +1 -1
  219. package/dist/collection/components/co-menu-divider/co-menu-divider.js +1 -1
  220. package/dist/collection/components/co-modal/co-modal.css +17 -3
  221. package/dist/collection/components/co-modal/co-modal.js +51 -1
  222. package/dist/collection/components/co-navbar/co-navbar.css +1 -1
  223. package/dist/collection/components/co-navbar/co-navbar.js +2 -2
  224. package/dist/collection/components/co-number-field/co-number-field.css +70 -0
  225. package/dist/collection/components/co-number-field/co-number-field.js +143 -13
  226. package/dist/collection/components/co-overlay/co-overlay.js +1 -1
  227. package/dist/collection/components/co-page-header/co-page-header.js +1 -1
  228. package/dist/collection/components/co-phone-field/co-phone-field.css +265 -0
  229. package/dist/collection/components/co-phone-field/co-phone-field.js +392 -0
  230. package/dist/collection/components/co-phone-field/dial-codes.js +208 -0
  231. package/dist/collection/components/co-popover/co-popover.js +2 -2
  232. package/dist/collection/components/co-progress-bar/co-progress-bar.js +2 -2
  233. package/dist/collection/components/co-progress-circle/co-progress-circle.css +50 -0
  234. package/dist/collection/components/co-progress-circle/co-progress-circle.js +148 -0
  235. package/dist/collection/components/co-radio/co-radio.js +3 -3
  236. package/dist/collection/components/co-radio-group/co-radio-group.css +26 -0
  237. package/dist/collection/components/co-radio-group/co-radio-group.js +25 -3
  238. package/dist/collection/components/co-rating/co-rating.js +3 -3
  239. package/dist/collection/components/co-ref-field/co-ref-field.css +816 -54
  240. package/dist/collection/components/co-ref-field/co-ref-field.js +0 -0
  241. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.css +238 -0
  242. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.js +868 -0
  243. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.css +55 -0
  244. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.js +289 -0
  245. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.css +78 -0
  246. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.js +232 -0
  247. package/dist/collection/components/co-row/co-row.js +2 -2
  248. package/dist/collection/components/co-select/co-select.css +845 -7
  249. package/dist/collection/components/co-select/co-select.js +240 -17
  250. package/dist/collection/components/co-separator/co-separator.js +1 -1
  251. package/dist/collection/components/co-sidebar/co-sidebar.js +2 -2
  252. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +29 -4
  253. package/dist/collection/components/co-slider/co-slider.js +2 -2
  254. package/dist/collection/components/co-switch/co-switch.css +17 -0
  255. package/dist/collection/components/co-switch/co-switch.js +27 -4
  256. package/dist/collection/components/co-tab/co-tab.js +2 -2
  257. package/dist/collection/components/co-tab-group/co-tab-group.js +1 -1
  258. package/dist/collection/components/co-tags-field/co-tags-field.css +272 -0
  259. package/dist/collection/components/co-tags-field/co-tags-field.js +590 -0
  260. package/dist/collection/components/co-textarea/co-textarea.css +261 -0
  261. package/dist/collection/components/co-textarea/co-textarea.js +484 -0
  262. package/dist/collection/components/co-toast/co-toast.js +1 -1
  263. package/dist/collection/components/co-toggle-button/co-toggle-button.css +6 -4
  264. package/dist/collection/components/co-toggle-button/co-toggle-button.js +2 -2
  265. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.css +16 -0
  266. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.js +25 -2
  267. package/dist/collection/components/co-tooltip/co-tooltip.css +16 -0
  268. package/dist/collection/components/co-tooltip/co-tooltip.js +9 -3
  269. package/dist/collection/components/co-transfer-list/co-transfer-list.css +683 -7
  270. package/dist/collection/components/co-transfer-list/co-transfer-list.js +17 -4
  271. package/dist/collection/utils/dateI18n.js +101 -0
  272. package/dist/collection/utils/fileI18n.js +76 -0
  273. package/dist/collection/utils/icon-config.js +22 -0
  274. package/dist/collection/utils/lightboxI18n.js +42 -0
  275. package/dist/collection/utils/normalizeText.js +94 -0
  276. package/dist/collection/utils/overlayScroll.js +20 -0
  277. package/dist/collection/utils/positioning.js +40 -25
  278. package/dist/collection/utils/requiredMark.js +11 -0
  279. package/dist/components/co-accordion.js +1 -1
  280. package/dist/components/co-autocomplete.js +1 -1
  281. package/dist/components/co-avatar.js +1 -1
  282. package/dist/components/co-button.js +1 -1
  283. package/dist/components/co-calendar.d.ts +11 -0
  284. package/dist/components/co-calendar.js +1 -0
  285. package/dist/components/co-card.js +1 -1
  286. package/dist/components/co-checkbox-group.js +1 -1
  287. package/dist/components/co-checkbox.js +1 -1
  288. package/dist/components/co-chip.js +1 -1
  289. package/dist/components/co-color-picker.d.ts +11 -0
  290. package/dist/components/co-color-picker.js +1 -0
  291. package/dist/components/co-column-picker.d.ts +11 -0
  292. package/dist/components/co-column-picker.js +1 -0
  293. package/dist/components/co-combobox.js +1 -1
  294. package/dist/components/co-command-search.js +1 -1
  295. package/dist/components/co-data-table-pagination.js +1 -1
  296. package/dist/components/co-data-table.js +1 -1
  297. package/dist/components/co-date-field.d.ts +11 -0
  298. package/dist/components/co-date-field.js +1 -0
  299. package/dist/components/co-date-picker.d.ts +11 -0
  300. package/dist/components/co-date-picker.js +1 -0
  301. package/dist/components/co-date-range-picker.d.ts +11 -0
  302. package/dist/components/co-date-range-picker.js +1 -0
  303. package/dist/components/co-date-range.js +1 -1
  304. package/dist/components/co-drawer.js +1 -1
  305. package/dist/components/co-empty-state.js +1 -1
  306. package/dist/components/co-fab.js +1 -1
  307. package/dist/components/co-file-field.d.ts +11 -0
  308. package/dist/components/co-file-field.js +1 -0
  309. package/dist/components/co-helper-text.js +1 -1
  310. package/dist/components/co-icon-button.js +1 -1
  311. package/dist/components/co-icon.js +1 -1
  312. package/dist/components/co-input.js +1 -1
  313. package/dist/components/co-json-field.d.ts +11 -0
  314. package/dist/components/co-json-field.js +1 -0
  315. package/dist/components/co-lightbox.d.ts +11 -0
  316. package/dist/components/co-lightbox.js +1 -0
  317. package/dist/components/co-list-item.js +1 -1
  318. package/dist/components/co-menu-divider.js +1 -1
  319. package/dist/components/co-menu-item.js +1 -1
  320. package/dist/components/co-menu.js +1 -1
  321. package/dist/components/co-modal.js +1 -1
  322. package/dist/components/co-navbar.js +1 -1
  323. package/dist/components/co-number-field.js +1 -1
  324. package/dist/components/co-overlay.js +1 -1
  325. package/dist/components/co-page-header.js +1 -1
  326. package/dist/components/co-phone-field.d.ts +11 -0
  327. package/dist/components/co-phone-field.js +1 -0
  328. package/dist/components/co-popover.js +1 -1
  329. package/dist/components/co-progress-bar.js +1 -1
  330. package/dist/components/co-progress-circle.d.ts +11 -0
  331. package/dist/components/co-progress-circle.js +1 -0
  332. package/dist/components/co-radio-group.js +1 -1
  333. package/dist/components/co-radio.js +1 -1
  334. package/dist/components/co-rating.js +1 -1
  335. package/dist/components/co-ref-field.js +1 -1
  336. package/dist/components/co-rich-text-editor.d.ts +11 -0
  337. package/dist/components/co-rich-text-editor.js +1 -0
  338. package/dist/components/co-rich-text-toolbar.d.ts +11 -0
  339. package/dist/components/co-rich-text-toolbar.js +1 -0
  340. package/dist/components/co-rich-text-viewer.d.ts +11 -0
  341. package/dist/components/co-rich-text-viewer.js +1 -0
  342. package/dist/components/co-row.js +1 -1
  343. package/dist/components/co-select.js +1 -1
  344. package/dist/components/co-separator.js +1 -1
  345. package/dist/components/co-sidebar-nav.js +1 -1
  346. package/dist/components/co-sidebar.js +1 -1
  347. package/dist/components/co-slider.js +1 -1
  348. package/dist/components/co-switch.js +1 -1
  349. package/dist/components/co-tab-group.js +1 -1
  350. package/dist/components/co-tab.js +1 -1
  351. package/dist/components/co-tags-field.d.ts +11 -0
  352. package/dist/components/co-tags-field.js +1 -0
  353. package/dist/components/co-textarea.d.ts +11 -0
  354. package/dist/components/co-textarea.js +1 -0
  355. package/dist/components/co-toast.js +1 -1
  356. package/dist/components/co-toggle-button-group.js +1 -1
  357. package/dist/components/co-toggle-button.js +1 -1
  358. package/dist/components/co-tooltip.js +1 -1
  359. package/dist/components/co-transfer-list.js +1 -1
  360. package/dist/components/index.js +1 -1
  361. package/dist/components/{p-FBICWTuN.js → p-BXdfh__-.js} +1 -1
  362. package/dist/components/p-BchB6Hdr.js +1 -0
  363. package/dist/components/p-BeWXpX8I.js +1 -0
  364. package/dist/components/p-BiW0ubLs.js +1 -0
  365. package/dist/components/p-C1DCLOEl.js +1 -0
  366. package/dist/components/p-C2mZ7x_Y.js +1 -0
  367. package/dist/components/p-C9tHLXKS.js +1 -0
  368. package/dist/components/p-CQY6Ul7q.js +1 -0
  369. package/dist/components/p-CWneqh4n.js +1 -0
  370. package/dist/components/{p-B18FTYLq.js → p-CaMgu2_g.js} +1 -1
  371. package/dist/components/p-CyYF8IJE.js +1 -0
  372. package/dist/components/p-DBhNS7JD.js +1 -0
  373. package/dist/components/p-DObrQi5F.js +1 -0
  374. package/dist/components/p-DPi_U-Kl.js +1 -0
  375. package/dist/components/p-DcK0GGZC.js +2 -0
  376. package/dist/components/p-DqyWGweA.js +1 -0
  377. package/dist/components/{p-cpdUXBiS.js → p-MiSJXuBx.js} +1 -1
  378. package/dist/components/p-Sgn-2g8m.js +1 -0
  379. package/dist/components/{p-Cr8Yc0zj.js → p-jDjfGZJp.js} +1 -1
  380. package/dist/components/p-o8hrDIKe.js +1 -0
  381. package/dist/components/p-ox7HzCZn.js +10 -0
  382. package/dist/esm/co-accordion.entry.js +19 -4
  383. package/dist/esm/co-app-shell.entry.js +1 -1
  384. package/dist/esm/co-autocomplete.entry.js +51 -6
  385. package/dist/esm/co-avatar.entry.js +39 -6
  386. package/dist/esm/co-badge.entry.js +1 -1
  387. package/dist/esm/co-button-group.entry.js +1 -1
  388. package/dist/esm/co-button.entry.js +10 -5
  389. package/dist/esm/co-calendar_3.entry.js +688 -0
  390. package/dist/esm/co-card.entry.js +21 -4
  391. package/dist/esm/co-checkbox-group.entry.js +7 -5
  392. package/dist/esm/co-checkbox.entry.js +4 -4
  393. package/dist/esm/co-chip.entry.js +3 -3
  394. package/dist/esm/co-color-picker.entry.js +107 -0
  395. package/dist/esm/co-column-picker.entry.js +441 -0
  396. package/dist/esm/co-combobox.entry.js +51 -15
  397. package/dist/esm/co-command-search.entry.js +14 -7
  398. package/dist/esm/co-data-table-pagination.entry.js +5 -5
  399. package/dist/esm/co-data-table.entry.js +17 -5
  400. package/dist/esm/co-date-picker.entry.js +175 -0
  401. package/dist/esm/co-date-range-picker.entry.js +376 -0
  402. package/dist/esm/co-date-range.entry.js +13 -259
  403. package/dist/esm/co-empty-state.entry.js +2 -2
  404. package/dist/esm/co-fab.entry.js +3 -3
  405. package/dist/esm/co-file-field.entry.js +496 -0
  406. package/dist/esm/co-helper-text.entry.js +3 -3
  407. package/dist/esm/co-icon-button.entry.js +4 -4
  408. package/dist/esm/co-icon.entry.js +7 -4
  409. package/dist/esm/co-input.entry.js +13 -8
  410. package/dist/esm/co-json-field.entry.js +107 -0
  411. package/dist/esm/co-lightbox.entry.js +342 -0
  412. package/dist/esm/co-list-item.entry.js +14 -4
  413. package/dist/esm/co-loader.entry.js +1 -1
  414. package/dist/esm/co-menu-divider.entry.js +2 -2
  415. package/dist/esm/co-menu-item.entry.js +1 -1
  416. package/dist/esm/co-menu.entry.js +2 -2
  417. package/dist/esm/co-modal.entry.js +13 -3
  418. package/dist/esm/co-navbar.entry.js +4 -4
  419. package/dist/esm/co-number-field.entry.js +47 -11
  420. package/dist/esm/co-overlay.entry.js +2 -2
  421. package/dist/esm/co-page-header.entry.js +2 -2
  422. package/dist/esm/co-phone-field.entry.js +374 -0
  423. package/dist/esm/co-popover.entry.js +4 -4
  424. package/dist/esm/co-progress-bar.entry.js +3 -3
  425. package/dist/esm/co-progress-circle.entry.js +36 -0
  426. package/dist/esm/co-radio-group.entry.js +7 -5
  427. package/dist/esm/co-radio.entry.js +4 -4
  428. package/dist/esm/co-rating.entry.js +4 -4
  429. package/dist/esm/co-ref-field.entry.js +191 -21
  430. package/dist/esm/co-rich-text-editor.entry.js +233 -0
  431. package/dist/esm/co-rich-text-toolbar.entry.js +182 -0
  432. package/dist/esm/co-rich-text-viewer.entry.js +80 -0
  433. package/dist/esm/co-row.entry.js +3 -3
  434. package/dist/esm/co-select.entry.js +119 -18
  435. package/dist/esm/co-separator.entry.js +2 -2
  436. package/dist/esm/co-sidebar-nav.entry.js +30 -5
  437. package/dist/esm/co-sidebar.entry.js +3 -3
  438. package/dist/esm/co-slider.entry.js +3 -3
  439. package/dist/esm/co-switch.entry.js +9 -6
  440. package/dist/esm/co-tab-group.entry.js +2 -2
  441. package/dist/esm/co-tab.entry.js +3 -3
  442. package/dist/esm/co-tags-field.entry.js +203 -0
  443. package/dist/esm/co-textarea.entry.js +90 -0
  444. package/dist/esm/co-toast.entry.js +2 -2
  445. package/dist/esm/co-toggle-button-group.entry.js +7 -4
  446. package/dist/esm/co-toggle-button.entry.js +4 -4
  447. package/dist/esm/co-tooltip.entry.js +12 -6
  448. package/dist/esm/co-transfer-list.entry.js +20 -6
  449. package/dist/esm/cobalt.js +3 -3
  450. package/dist/esm/dateI18n-C1DCLOEl.js +103 -0
  451. package/dist/esm/dates-CyYF8IJE.js +416 -0
  452. package/dist/esm/{index-B0lqrhFo.js → index-BKmfyPZK.js} +79 -11
  453. package/dist/esm/index-BjAqSidM.js +27200 -0
  454. package/dist/esm/loader.js +3 -3
  455. package/dist/esm/normalizeText-CQY6Ul7q.js +92 -0
  456. package/dist/esm/overlayScroll-Bpv882_z.js +23 -0
  457. package/dist/esm/overlayscrollbars-ox7HzCZn.js +2840 -0
  458. package/dist/esm/{positioning-Am-OlB8h.js → positioning-C2mZ7x_Y.js} +40 -25
  459. package/dist/esm/requiredMark-DFvtYtkE.js +14 -0
  460. package/dist/esm/sanitizer-DcK0GGZC.js +1880 -0
  461. package/dist/types/components/co-accordion/co-accordion.d.ts +12 -2
  462. package/dist/types/components/co-autocomplete/co-autocomplete.d.ts +11 -0
  463. package/dist/types/components/co-avatar/co-avatar.d.ts +6 -2
  464. package/dist/types/components/co-button/co-button.d.ts +4 -0
  465. package/dist/types/components/co-calendar/co-calendar.d.ts +108 -0
  466. package/dist/types/components/co-card/co-card.d.ts +10 -2
  467. package/dist/types/components/co-checkbox-group/co-checkbox-group.d.ts +2 -0
  468. package/dist/types/components/co-color-picker/co-color-picker.d.ts +48 -0
  469. package/dist/types/components/co-color-picker/presets.d.ts +10 -0
  470. package/dist/types/components/co-column-picker/co-column-picker.d.ts +60 -0
  471. package/dist/types/components/co-column-picker/column-picker-node.d.ts +18 -0
  472. package/dist/types/components/co-column-picker/utils/column-picker-tree.d.ts +37 -0
  473. package/dist/types/components/co-combobox/co-combobox.d.ts +14 -1
  474. package/dist/types/components/co-command-search/co-command-search.d.ts +2 -0
  475. package/dist/types/components/co-data-table/co-data-table.d.ts +1 -0
  476. package/dist/types/components/co-date-field/co-date-field.d.ts +96 -0
  477. package/dist/types/components/co-date-picker/co-date-picker.d.ts +92 -0
  478. package/dist/types/components/co-date-range/co-date-range.d.ts +12 -50
  479. package/dist/types/components/co-date-range-picker/co-date-range-picker.d.ts +112 -0
  480. package/dist/types/components/co-drawer/co-drawer.d.ts +4 -0
  481. package/dist/types/components/co-file-field/co-file-field.d.ts +146 -0
  482. package/dist/types/components/co-file-field/co-file-field.utils.d.ts +18 -0
  483. package/dist/types/components/co-icon-button/co-icon-button.d.ts +1 -1
  484. package/dist/types/components/co-input/co-input.d.ts +4 -1
  485. package/dist/types/components/co-json-field/co-json-field.d.ts +66 -0
  486. package/dist/types/components/co-lightbox/co-lightbox.d.ts +95 -0
  487. package/dist/types/components/co-list-item/co-list-item.d.ts +1 -0
  488. package/dist/types/components/co-modal/co-modal.d.ts +4 -0
  489. package/dist/types/components/co-number-field/co-number-field.d.ts +16 -2
  490. package/dist/types/components/co-phone-field/co-phone-field.d.ts +56 -0
  491. package/dist/types/components/co-phone-field/dial-codes.d.ts +14 -0
  492. package/dist/types/components/co-progress-circle/co-progress-circle.d.ts +16 -0
  493. package/dist/types/components/co-radio-group/co-radio-group.d.ts +2 -0
  494. package/dist/types/components/co-ref-field/co-ref-field.d.ts +54 -1
  495. package/dist/types/components/co-rich-text-editor/co-rich-text-editor.d.ts +94 -0
  496. package/dist/types/components/co-rich-text-toolbar/co-rich-text-toolbar.d.ts +42 -0
  497. package/dist/types/components/co-rich-text-viewer/co-rich-text-viewer.d.ts +32 -0
  498. package/dist/types/components/co-select/co-select.d.ts +31 -1
  499. package/dist/types/components/co-switch/co-switch.d.ts +2 -0
  500. package/dist/types/components/co-tags-field/co-tags-field.d.ts +82 -0
  501. package/dist/types/components/co-textarea/co-textarea.d.ts +65 -0
  502. package/dist/types/components/co-toggle-button-group/co-toggle-button-group.d.ts +2 -0
  503. package/dist/types/components/co-transfer-list/co-transfer-list.d.ts +4 -0
  504. package/dist/types/components.d.ts +3796 -422
  505. package/dist/types/utils/dateI18n.d.ts +39 -0
  506. package/dist/types/utils/fileI18n.d.ts +34 -0
  507. package/dist/types/utils/icon-config.d.ts +20 -0
  508. package/dist/types/utils/lightboxI18n.d.ts +12 -0
  509. package/dist/types/utils/normalizeText.d.ts +41 -0
  510. package/dist/types/utils/overlayScroll.d.ts +17 -0
  511. package/dist/types/utils/positioning.d.ts +7 -14
  512. package/dist/types/utils/requiredMark.d.ts +13 -0
  513. package/package.json +9 -1
  514. package/dist/cjs/co-drawer.cjs.entry.js +0 -75
  515. package/dist/cjs/color-YhUkm10t.js +0 -32
  516. package/dist/cobalt/p-08afdc51.entry.js +0 -1
  517. package/dist/cobalt/p-1d3338b6.entry.js +0 -1
  518. package/dist/cobalt/p-1d91ec93.entry.js +0 -1
  519. package/dist/cobalt/p-230a23f3.entry.js +0 -1
  520. package/dist/cobalt/p-31bc842d.entry.js +0 -1
  521. package/dist/cobalt/p-37c1f700.entry.js +0 -1
  522. package/dist/cobalt/p-4dd7499c.entry.js +0 -1
  523. package/dist/cobalt/p-4e7ce8ee.entry.js +0 -1
  524. package/dist/cobalt/p-6793c51e.entry.js +0 -1
  525. package/dist/cobalt/p-689e38b3.entry.js +0 -1
  526. package/dist/cobalt/p-7028880b.entry.js +0 -1
  527. package/dist/cobalt/p-72113ec2.entry.js +0 -1
  528. package/dist/cobalt/p-8e54e74d.entry.js +0 -1
  529. package/dist/cobalt/p-92c39eed.entry.js +0 -1
  530. package/dist/cobalt/p-9887b828.entry.js +0 -1
  531. package/dist/cobalt/p-9a5c6600.entry.js +0 -1
  532. package/dist/cobalt/p-Am-OlB8h.js +0 -1
  533. package/dist/cobalt/p-B0lqrhFo.js +0 -2
  534. package/dist/cobalt/p-BG4WRR22.js +0 -1
  535. package/dist/cobalt/p-a1b248ad.entry.js +0 -1
  536. package/dist/cobalt/p-a470b764.entry.js +0 -1
  537. package/dist/cobalt/p-a4d55b1a.entry.js +0 -1
  538. package/dist/cobalt/p-b6840df4.entry.js +0 -1
  539. package/dist/cobalt/p-b89d54d9.entry.js +0 -1
  540. package/dist/cobalt/p-ba84631a.entry.js +0 -1
  541. package/dist/cobalt/p-c7517f86.entry.js +0 -1
  542. package/dist/cobalt/p-ca41eec2.entry.js +0 -1
  543. package/dist/cobalt/p-d29c77cb.entry.js +0 -1
  544. package/dist/cobalt/p-d9d8b10e.entry.js +0 -1
  545. package/dist/cobalt/p-da55678f.entry.js +0 -1
  546. package/dist/cobalt/p-dc5598d1.entry.js +0 -1
  547. package/dist/cobalt/p-e2c9cb00.entry.js +0 -1
  548. package/dist/cobalt/p-ebd68f56.entry.js +0 -1
  549. package/dist/cobalt/p-f051f44d.entry.js +0 -1
  550. package/dist/cobalt/p-fe1447a3.entry.js +0 -1
  551. package/dist/components/p-Am-OlB8h.js +0 -1
  552. package/dist/components/p-BG4WRR22.js +0 -1
  553. package/dist/components/p-wwWquAtm.js +0 -1
  554. package/dist/esm/co-drawer.entry.js +0 -73
  555. package/dist/esm/color-BG4WRR22.js +0 -30
@@ -0,0 +1,1880 @@
1
+ /*! @license DOMPurify 3.4.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.8/LICENSE */
2
+
3
+ function _arrayLikeToArray(r, a) {
4
+ (null == a || a > r.length) && (a = r.length);
5
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
6
+ return n;
7
+ }
8
+ function _arrayWithHoles(r) {
9
+ if (Array.isArray(r)) return r;
10
+ }
11
+ function _iterableToArrayLimit(r, l) {
12
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
13
+ if (null != t) {
14
+ var e,
15
+ n,
16
+ i,
17
+ u,
18
+ a = [],
19
+ f = true,
20
+ o = false;
21
+ try {
22
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true);
23
+ } catch (r) {
24
+ o = true, n = r;
25
+ } finally {
26
+ try {
27
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
28
+ } finally {
29
+ if (o) throw n;
30
+ }
31
+ }
32
+ return a;
33
+ }
34
+ }
35
+ function _nonIterableRest() {
36
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
37
+ }
38
+ function _slicedToArray(r, e) {
39
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
40
+ }
41
+ function _unsupportedIterableToArray(r, a) {
42
+ if (r) {
43
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
44
+ var t = {}.toString.call(r).slice(8, -1);
45
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
46
+ }
47
+ }
48
+
49
+ const entries = Object.entries,
50
+ setPrototypeOf = Object.setPrototypeOf,
51
+ isFrozen = Object.isFrozen,
52
+ getPrototypeOf = Object.getPrototypeOf,
53
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
54
+ let freeze = Object.freeze,
55
+ seal = Object.seal,
56
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
57
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
58
+ apply = _ref.apply,
59
+ construct = _ref.construct;
60
+ if (!freeze) {
61
+ freeze = function freeze(x) {
62
+ return x;
63
+ };
64
+ }
65
+ if (!seal) {
66
+ seal = function seal(x) {
67
+ return x;
68
+ };
69
+ }
70
+ if (!apply) {
71
+ apply = function apply(func, thisArg) {
72
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
73
+ args[_key - 2] = arguments[_key];
74
+ }
75
+ return func.apply(thisArg, args);
76
+ };
77
+ }
78
+ if (!construct) {
79
+ construct = function construct(Func) {
80
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
81
+ args[_key2 - 1] = arguments[_key2];
82
+ }
83
+ return new Func(...args);
84
+ };
85
+ }
86
+ const arrayForEach = unapply(Array.prototype.forEach);
87
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
88
+ const arrayPop = unapply(Array.prototype.pop);
89
+ const arrayPush = unapply(Array.prototype.push);
90
+ const arraySplice = unapply(Array.prototype.splice);
91
+ const arrayIsArray = Array.isArray;
92
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
93
+ const stringToString = unapply(String.prototype.toString);
94
+ const stringMatch = unapply(String.prototype.match);
95
+ const stringReplace = unapply(String.prototype.replace);
96
+ const stringIndexOf = unapply(String.prototype.indexOf);
97
+ const stringTrim = unapply(String.prototype.trim);
98
+ const numberToString = unapply(Number.prototype.toString);
99
+ const booleanToString = unapply(Boolean.prototype.toString);
100
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
101
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
102
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
103
+ const objectToString = unapply(Object.prototype.toString);
104
+ const regExpTest = unapply(RegExp.prototype.test);
105
+ const typeErrorCreate = unconstruct(TypeError);
106
+ /**
107
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
108
+ *
109
+ * @param func - The function to be wrapped and called.
110
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
111
+ */
112
+ function unapply(func) {
113
+ return function (thisArg) {
114
+ if (thisArg instanceof RegExp) {
115
+ thisArg.lastIndex = 0;
116
+ }
117
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
118
+ args[_key3 - 1] = arguments[_key3];
119
+ }
120
+ return apply(func, thisArg, args);
121
+ };
122
+ }
123
+ /**
124
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
125
+ *
126
+ * @param func - The constructor function to be wrapped and called.
127
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
128
+ */
129
+ function unconstruct(Func) {
130
+ return function () {
131
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
132
+ args[_key4] = arguments[_key4];
133
+ }
134
+ return construct(Func, args);
135
+ };
136
+ }
137
+ /**
138
+ * Add properties to a lookup table
139
+ *
140
+ * @param set - The set to which elements will be added.
141
+ * @param array - The array containing elements to be added to the set.
142
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
143
+ * @returns The modified set with added elements.
144
+ */
145
+ function addToSet(set, array) {
146
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
147
+ if (setPrototypeOf) {
148
+ // Make 'in' and truthy checks like Boolean(set.constructor)
149
+ // independent of any properties defined on Object.prototype.
150
+ // Prevent prototype setters from intercepting set as a this value.
151
+ setPrototypeOf(set, null);
152
+ }
153
+ if (!arrayIsArray(array)) {
154
+ return set;
155
+ }
156
+ let l = array.length;
157
+ while (l--) {
158
+ let element = array[l];
159
+ if (typeof element === 'string') {
160
+ const lcElement = transformCaseFunc(element);
161
+ if (lcElement !== element) {
162
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
163
+ if (!isFrozen(array)) {
164
+ array[l] = lcElement;
165
+ }
166
+ element = lcElement;
167
+ }
168
+ }
169
+ set[element] = true;
170
+ }
171
+ return set;
172
+ }
173
+ /**
174
+ * Clean up an array to harden against CSPP
175
+ *
176
+ * @param array - The array to be cleaned.
177
+ * @returns The cleaned version of the array
178
+ */
179
+ function cleanArray(array) {
180
+ for (let index = 0; index < array.length; index++) {
181
+ const isPropertyExist = objectHasOwnProperty(array, index);
182
+ if (!isPropertyExist) {
183
+ array[index] = null;
184
+ }
185
+ }
186
+ return array;
187
+ }
188
+ /**
189
+ * Shallow clone an object
190
+ *
191
+ * @param object - The object to be cloned.
192
+ * @returns A new object that copies the original.
193
+ */
194
+ function clone(object) {
195
+ const newObject = create(null);
196
+ for (const _ref2 of entries(object)) {
197
+ var _ref3 = _slicedToArray(_ref2, 2);
198
+ const property = _ref3[0];
199
+ const value = _ref3[1];
200
+ const isPropertyExist = objectHasOwnProperty(object, property);
201
+ if (isPropertyExist) {
202
+ if (arrayIsArray(value)) {
203
+ newObject[property] = cleanArray(value);
204
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
205
+ newObject[property] = clone(value);
206
+ } else {
207
+ newObject[property] = value;
208
+ }
209
+ }
210
+ }
211
+ return newObject;
212
+ }
213
+ /**
214
+ * Convert non-node values into strings without depending on direct property access.
215
+ *
216
+ * @param value - The value to stringify.
217
+ * @returns A string representation of the provided value.
218
+ */
219
+ function stringifyValue(value) {
220
+ switch (typeof value) {
221
+ case 'string':
222
+ {
223
+ return value;
224
+ }
225
+ case 'number':
226
+ {
227
+ return numberToString(value);
228
+ }
229
+ case 'boolean':
230
+ {
231
+ return booleanToString(value);
232
+ }
233
+ case 'bigint':
234
+ {
235
+ return bigintToString ? bigintToString(value) : '0';
236
+ }
237
+ case 'symbol':
238
+ {
239
+ return symbolToString ? symbolToString(value) : 'Symbol()';
240
+ }
241
+ case 'undefined':
242
+ {
243
+ return objectToString(value);
244
+ }
245
+ case 'function':
246
+ case 'object':
247
+ {
248
+ if (value === null) {
249
+ return objectToString(value);
250
+ }
251
+ const valueAsRecord = value;
252
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
253
+ if (typeof valueToString === 'function') {
254
+ const stringified = valueToString(valueAsRecord);
255
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
256
+ }
257
+ return objectToString(value);
258
+ }
259
+ default:
260
+ {
261
+ return objectToString(value);
262
+ }
263
+ }
264
+ }
265
+ /**
266
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
267
+ *
268
+ * @param object - The object to look up the getter function in its prototype chain.
269
+ * @param prop - The property name for which to find the getter function.
270
+ * @returns The getter function found in the prototype chain or a fallback function.
271
+ */
272
+ function lookupGetter(object, prop) {
273
+ while (object !== null) {
274
+ const desc = getOwnPropertyDescriptor(object, prop);
275
+ if (desc) {
276
+ if (desc.get) {
277
+ return unapply(desc.get);
278
+ }
279
+ if (typeof desc.value === 'function') {
280
+ return unapply(desc.value);
281
+ }
282
+ }
283
+ object = getPrototypeOf(object);
284
+ }
285
+ function fallbackValue() {
286
+ return null;
287
+ }
288
+ return fallbackValue;
289
+ }
290
+ function isRegex(value) {
291
+ try {
292
+ regExpTest(value, '');
293
+ return true;
294
+ } catch (_unused) {
295
+ return false;
296
+ }
297
+ }
298
+
299
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
300
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
301
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
302
+ // List of SVG elements that are disallowed by default.
303
+ // We still need to know them so that we can do namespace
304
+ // checks properly in case one wants to add them to
305
+ // allow-list.
306
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
307
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
308
+ // Similarly to SVG, we want to know all MathML elements,
309
+ // even those that we disallow by default.
310
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
311
+ const text = freeze(['#text']);
312
+
313
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
314
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
315
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
316
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
317
+
318
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
319
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
320
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
321
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
322
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
323
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
324
+ );
325
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
326
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
327
+ );
328
+ const DOCTYPE_NAME = seal(/^html$/i);
329
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
330
+
331
+ /* eslint-disable @typescript-eslint/indent */
332
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
333
+ const NODE_TYPE = {
334
+ element: 1,
335
+ text: 3,
336
+ // Deprecated
337
+ progressingInstruction: 7,
338
+ comment: 8,
339
+ document: 9,
340
+ documentFragment: 11};
341
+ const getGlobal = function getGlobal() {
342
+ return typeof window === 'undefined' ? null : window;
343
+ };
344
+ /**
345
+ * Creates a no-op policy for internal use only.
346
+ * Don't export this function outside this module!
347
+ * @param trustedTypes The policy factory.
348
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
349
+ * @return The policy created (or null, if Trusted Types
350
+ * are not supported or creating the policy failed).
351
+ */
352
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
353
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
354
+ return null;
355
+ }
356
+ // Allow the callers to control the unique policy name
357
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
358
+ // Policy creation with duplicate names throws in Trusted Types.
359
+ let suffix = null;
360
+ const ATTR_NAME = 'data-tt-policy-suffix';
361
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
362
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
363
+ }
364
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
365
+ try {
366
+ return trustedTypes.createPolicy(policyName, {
367
+ createHTML(html) {
368
+ return html;
369
+ },
370
+ createScriptURL(scriptUrl) {
371
+ return scriptUrl;
372
+ }
373
+ });
374
+ } catch (_) {
375
+ // Policy creation failed (most likely another DOMPurify script has
376
+ // already run). Skip creating the policy, as this will only cause errors
377
+ // if TT are enforced.
378
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
379
+ return null;
380
+ }
381
+ };
382
+ const _createHooksMap = function _createHooksMap() {
383
+ return {
384
+ afterSanitizeAttributes: [],
385
+ afterSanitizeElements: [],
386
+ afterSanitizeShadowDOM: [],
387
+ beforeSanitizeAttributes: [],
388
+ beforeSanitizeElements: [],
389
+ beforeSanitizeShadowDOM: [],
390
+ uponSanitizeAttribute: [],
391
+ uponSanitizeElement: [],
392
+ uponSanitizeShadowNode: []
393
+ };
394
+ };
395
+ function createDOMPurify() {
396
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
397
+ const DOMPurify = root => createDOMPurify(root);
398
+ DOMPurify.version = '3.4.8';
399
+ DOMPurify.removed = [];
400
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
401
+ // Not running in a browser, provide a factory function
402
+ // so that you can pass your own Window
403
+ DOMPurify.isSupported = false;
404
+ return DOMPurify;
405
+ }
406
+ let document = window.document;
407
+ const originalDocument = document;
408
+ const currentScript = originalDocument.currentScript;
409
+ const HTMLTemplateElement = window.HTMLTemplateElement,
410
+ Node = window.Node,
411
+ Element = window.Element,
412
+ NodeFilter = window.NodeFilter;
413
+ const DOMParser = window.DOMParser,
414
+ trustedTypes = window.trustedTypes;
415
+ const ElementPrototype = Element.prototype;
416
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
417
+ const remove = lookupGetter(ElementPrototype, 'remove');
418
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
419
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
420
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
421
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
422
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
423
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
424
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
425
+ // As per issue #47, the web-components registry is inherited by a
426
+ // new document created via createHTMLDocument. As per the spec
427
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
428
+ // a new empty registry is used when creating a template contents owner
429
+ // document, so we use that as our parent document to ensure nothing
430
+ // is inherited.
431
+ if (typeof HTMLTemplateElement === 'function') {
432
+ const template = document.createElement('template');
433
+ if (template.content && template.content.ownerDocument) {
434
+ document = template.content.ownerDocument;
435
+ }
436
+ }
437
+ let trustedTypesPolicy;
438
+ let emptyHTML = '';
439
+ // Tracks whether we are already inside a call to the configured Trusted Types
440
+ // policy's `createHTML`. If the supplied `TRUSTED_TYPES_POLICY.createHTML`
441
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
442
+ // re-enter the policy and recurse until the stack overflows. We detect that
443
+ // re-entry and throw a clear, actionable error instead.
444
+ let IN_POLICY_CREATE_HTML = 0;
445
+ const _createTrustedHTML = function _createTrustedHTML(html) {
446
+ if (IN_POLICY_CREATE_HTML > 0) {
447
+ throw typeErrorCreate('The configured TRUSTED_TYPES_POLICY.createHTML must not call ' + 'DOMPurify.sanitize, as that causes infinite recursion. Do not pass ' + 'a policy whose createHTML wraps DOMPurify as TRUSTED_TYPES_POLICY; ' + 'see the "DOMPurify and Trusted Types" section of the README.');
448
+ }
449
+ IN_POLICY_CREATE_HTML++;
450
+ try {
451
+ return trustedTypesPolicy.createHTML(html);
452
+ } finally {
453
+ IN_POLICY_CREATE_HTML--;
454
+ }
455
+ };
456
+ const _document = document,
457
+ implementation = _document.implementation,
458
+ createNodeIterator = _document.createNodeIterator,
459
+ createDocumentFragment = _document.createDocumentFragment,
460
+ getElementsByTagName = _document.getElementsByTagName;
461
+ const importNode = originalDocument.importNode;
462
+ let hooks = _createHooksMap();
463
+ /**
464
+ * Expose whether this browser supports running the full DOMPurify.
465
+ */
466
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
467
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
468
+ ERB_EXPR$1 = ERB_EXPR,
469
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
470
+ DATA_ATTR$1 = DATA_ATTR,
471
+ ARIA_ATTR$1 = ARIA_ATTR,
472
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
473
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
474
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
475
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
476
+ /**
477
+ * We consider the elements and attributes below to be safe. Ideally
478
+ * don't add any new ones but feel free to remove unwanted ones.
479
+ */
480
+ /* allowed element names */
481
+ let ALLOWED_TAGS = null;
482
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
483
+ /* Allowed attribute names */
484
+ let ALLOWED_ATTR = null;
485
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
486
+ /*
487
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
488
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
489
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
490
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
491
+ */
492
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
493
+ tagNameCheck: {
494
+ writable: true,
495
+ configurable: false,
496
+ enumerable: true,
497
+ value: null
498
+ },
499
+ attributeNameCheck: {
500
+ writable: true,
501
+ configurable: false,
502
+ enumerable: true,
503
+ value: null
504
+ },
505
+ allowCustomizedBuiltInElements: {
506
+ writable: true,
507
+ configurable: false,
508
+ enumerable: true,
509
+ value: false
510
+ }
511
+ }));
512
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
513
+ let FORBID_TAGS = null;
514
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
515
+ let FORBID_ATTR = null;
516
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
517
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
518
+ tagCheck: {
519
+ writable: true,
520
+ configurable: false,
521
+ enumerable: true,
522
+ value: null
523
+ },
524
+ attributeCheck: {
525
+ writable: true,
526
+ configurable: false,
527
+ enumerable: true,
528
+ value: null
529
+ }
530
+ }));
531
+ /* Decide if ARIA attributes are okay */
532
+ let ALLOW_ARIA_ATTR = true;
533
+ /* Decide if custom data attributes are okay */
534
+ let ALLOW_DATA_ATTR = true;
535
+ /* Decide if unknown protocols are okay */
536
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
537
+ /* Decide if self-closing tags in attributes are allowed.
538
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
539
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
540
+ /* Output should be safe for common template engines.
541
+ * This means, DOMPurify removes data attributes, mustaches and ERB
542
+ */
543
+ let SAFE_FOR_TEMPLATES = false;
544
+ /* Output should be safe even for XML used within HTML and alike.
545
+ * This means, DOMPurify removes comments when containing risky content.
546
+ */
547
+ let SAFE_FOR_XML = true;
548
+ /* Decide if document with <html>... should be returned */
549
+ let WHOLE_DOCUMENT = false;
550
+ /* Track whether config is already set on this instance of DOMPurify. */
551
+ let SET_CONFIG = false;
552
+ /* Decide if all elements (e.g. style, script) must be children of
553
+ * document.body. By default, browsers might move them to document.head */
554
+ let FORCE_BODY = false;
555
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
556
+ * string (or a TrustedHTML object if Trusted Types are supported).
557
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
558
+ */
559
+ let RETURN_DOM = false;
560
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
561
+ * string (or a TrustedHTML object if Trusted Types are supported) */
562
+ let RETURN_DOM_FRAGMENT = false;
563
+ /* Try to return a Trusted Type object instead of a string, return a string in
564
+ * case Trusted Types are not supported */
565
+ let RETURN_TRUSTED_TYPE = false;
566
+ /* Output should be free from DOM clobbering attacks?
567
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
568
+ */
569
+ let SANITIZE_DOM = true;
570
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
571
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
572
+ *
573
+ * HTML/DOM spec rules that enable DOM Clobbering:
574
+ * - Named Access on Window (§7.3.3)
575
+ * - DOM Tree Accessors (§3.1.5)
576
+ * - Form Element Parent-Child Relations (§4.10.3)
577
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
578
+ * - HTMLCollection (§4.2.10.2)
579
+ *
580
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
581
+ * with a constant string, i.e., `user-content-`
582
+ */
583
+ let SANITIZE_NAMED_PROPS = false;
584
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
585
+ /* Keep element content when removing element? */
586
+ let KEEP_CONTENT = true;
587
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
588
+ * of importing it into a new Document and returning a sanitized copy */
589
+ let IN_PLACE = false;
590
+ /* Allow usage of profiles like html, svg and mathMl */
591
+ let USE_PROFILES = {};
592
+ /* Tags to ignore content of when KEEP_CONTENT is true */
593
+ let FORBID_CONTENTS = null;
594
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
595
+ /* Tags that are safe for data: URIs */
596
+ let DATA_URI_TAGS = null;
597
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
598
+ /* Attributes safe for values like "javascript:" */
599
+ let URI_SAFE_ATTRIBUTES = null;
600
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
601
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
602
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
603
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
604
+ /* Document namespace */
605
+ let NAMESPACE = HTML_NAMESPACE;
606
+ let IS_EMPTY_INPUT = false;
607
+ /* Allowed XHTML+XML namespaces */
608
+ let ALLOWED_NAMESPACES = null;
609
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
610
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
611
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
612
+ // Certain elements are allowed in both SVG and HTML
613
+ // namespace. We need to specify them explicitly
614
+ // so that they don't get erroneously deleted from
615
+ // HTML namespace.
616
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
617
+ /* Parsing of strict XHTML documents */
618
+ let PARSER_MEDIA_TYPE = null;
619
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
620
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
621
+ let transformCaseFunc = null;
622
+ /* Keep a reference to config to pass to hooks */
623
+ let CONFIG = null;
624
+ /* Ideally, do not touch anything below this line */
625
+ /* ______________________________________________ */
626
+ const formElement = document.createElement('form');
627
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
628
+ return testValue instanceof RegExp || testValue instanceof Function;
629
+ };
630
+ /**
631
+ * _parseConfig
632
+ *
633
+ * @param cfg optional config literal
634
+ */
635
+ // eslint-disable-next-line complexity
636
+ const _parseConfig = function _parseConfig() {
637
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
638
+ if (CONFIG && CONFIG === cfg) {
639
+ return;
640
+ }
641
+ /* Shield configuration object from tampering */
642
+ if (!cfg || typeof cfg !== 'object') {
643
+ cfg = {};
644
+ }
645
+ /* Shield configuration object from prototype pollution */
646
+ cfg = clone(cfg);
647
+ PARSER_MEDIA_TYPE =
648
+ // eslint-disable-next-line unicorn/prefer-includes
649
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
650
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
651
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
652
+ /* Set configuration parameters */
653
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
654
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
655
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
656
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
657
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
658
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
659
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
660
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
661
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
662
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
663
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
664
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
665
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
666
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
667
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
668
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
669
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
670
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
671
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
672
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
673
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
674
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
675
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
676
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
677
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
678
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
679
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); // Default built-in map
680
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ['annotation-xml']); // Default built-in map
681
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
682
+ CUSTOM_ELEMENT_HANDLING = create(null);
683
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
684
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
685
+ }
686
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
687
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
688
+ }
689
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
690
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
691
+ }
692
+ if (SAFE_FOR_TEMPLATES) {
693
+ ALLOW_DATA_ATTR = false;
694
+ }
695
+ if (RETURN_DOM_FRAGMENT) {
696
+ RETURN_DOM = true;
697
+ }
698
+ /* Parse profile info */
699
+ if (USE_PROFILES) {
700
+ ALLOWED_TAGS = addToSet({}, text);
701
+ ALLOWED_ATTR = create(null);
702
+ if (USE_PROFILES.html === true) {
703
+ addToSet(ALLOWED_TAGS, html$1);
704
+ addToSet(ALLOWED_ATTR, html);
705
+ }
706
+ if (USE_PROFILES.svg === true) {
707
+ addToSet(ALLOWED_TAGS, svg$1);
708
+ addToSet(ALLOWED_ATTR, svg);
709
+ addToSet(ALLOWED_ATTR, xml);
710
+ }
711
+ if (USE_PROFILES.svgFilters === true) {
712
+ addToSet(ALLOWED_TAGS, svgFilters);
713
+ addToSet(ALLOWED_ATTR, svg);
714
+ addToSet(ALLOWED_ATTR, xml);
715
+ }
716
+ if (USE_PROFILES.mathMl === true) {
717
+ addToSet(ALLOWED_TAGS, mathMl$1);
718
+ addToSet(ALLOWED_ATTR, mathMl);
719
+ addToSet(ALLOWED_ATTR, xml);
720
+ }
721
+ }
722
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
723
+ * leaking across calls when switching from function to array config */
724
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
725
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
726
+ /* Merge configuration parameters */
727
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
728
+ if (typeof cfg.ADD_TAGS === 'function') {
729
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
730
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
731
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
732
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
733
+ }
734
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
735
+ }
736
+ }
737
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
738
+ if (typeof cfg.ADD_ATTR === 'function') {
739
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
740
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
741
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
742
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
743
+ }
744
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
745
+ }
746
+ }
747
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
748
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
749
+ }
750
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
751
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
752
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
753
+ }
754
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
755
+ }
756
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
757
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
758
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
759
+ }
760
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
761
+ }
762
+ /* Add #text in case KEEP_CONTENT is set to true */
763
+ if (KEEP_CONTENT) {
764
+ ALLOWED_TAGS['#text'] = true;
765
+ }
766
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
767
+ if (WHOLE_DOCUMENT) {
768
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
769
+ }
770
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
771
+ if (ALLOWED_TAGS.table) {
772
+ addToSet(ALLOWED_TAGS, ['tbody']);
773
+ delete FORBID_TAGS.tbody;
774
+ }
775
+ if (cfg.TRUSTED_TYPES_POLICY) {
776
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
777
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
778
+ }
779
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
780
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
781
+ }
782
+ // Overwrite existing TrustedTypes policy.
783
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
784
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
785
+ // Sign local variables required by `sanitize`. If the supplied policy's
786
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
787
+ // throws via the re-entrancy guard. Restore the previous policy first so
788
+ // the instance is not left in a poisoned state. See #1422.
789
+ try {
790
+ emptyHTML = _createTrustedHTML('');
791
+ } catch (error) {
792
+ trustedTypesPolicy = previousTrustedTypesPolicy;
793
+ throw error;
794
+ }
795
+ } else {
796
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
797
+ if (trustedTypesPolicy === undefined && cfg.TRUSTED_TYPES_POLICY !== null) {
798
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
799
+ }
800
+ // If creating the internal policy succeeded sign internal variables.
801
+ // Note: a falsy `trustedTypesPolicy` (null when policy creation failed or
802
+ // was skipped via `TRUSTED_TYPES_POLICY: null`, or undefined when no
803
+ // policy has been initialized yet) must be excluded here, otherwise we
804
+ // would call `.createHTML` on a non-policy and throw. See #1422.
805
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
806
+ emptyHTML = _createTrustedHTML('');
807
+ }
808
+ }
809
+ /*
810
+ * Mirror the clone-before-mutate pattern already applied above for
811
+ * cfg.ADD_TAGS / cfg.ADD_ATTR: if any uponSanitize* hook is
812
+ * registered AND the set still points at the default constant,
813
+ * clone it. The hook then mutates the clone (in-call widening
814
+ * still works exactly as documented) and the next default-cfg
815
+ * call rebinds to the untouched original via the reassignment at
816
+ * the top of this function.
817
+ */
818
+ if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
819
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
820
+ }
821
+ if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
822
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
823
+ }
824
+ // Prevent further manipulation of configuration.
825
+ // Not available in IE8, Safari 5, etc.
826
+ if (freeze) {
827
+ freeze(cfg);
828
+ }
829
+ CONFIG = cfg;
830
+ };
831
+ /* Keep track of all possible SVG and MathML tags
832
+ * so that we can perform the namespace checks
833
+ * correctly. */
834
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
835
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
836
+ /**
837
+ * @param element a DOM element whose namespace is being checked
838
+ * @returns Return false if the element has a
839
+ * namespace that a spec-compliant parser would never
840
+ * return. Return true otherwise.
841
+ */
842
+ const _checkValidNamespace = function _checkValidNamespace(element) {
843
+ let parent = getParentNode(element);
844
+ // In JSDOM, if we're inside shadow DOM, then parentNode
845
+ // can be null. We just simulate parent in this case.
846
+ if (!parent || !parent.tagName) {
847
+ parent = {
848
+ namespaceURI: NAMESPACE,
849
+ tagName: 'template'
850
+ };
851
+ }
852
+ const tagName = stringToLowerCase(element.tagName);
853
+ const parentTagName = stringToLowerCase(parent.tagName);
854
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
855
+ return false;
856
+ }
857
+ if (element.namespaceURI === SVG_NAMESPACE) {
858
+ // The only way to switch from HTML namespace to SVG
859
+ // is via <svg>. If it happens via any other tag, then
860
+ // it should be killed.
861
+ if (parent.namespaceURI === HTML_NAMESPACE) {
862
+ return tagName === 'svg';
863
+ }
864
+ // The only way to switch from MathML to SVG is via`
865
+ // svg if parent is either <annotation-xml> or MathML
866
+ // text integration points.
867
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
868
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
869
+ }
870
+ // We only allow elements that are defined in SVG
871
+ // spec. All others are disallowed in SVG namespace.
872
+ return Boolean(ALL_SVG_TAGS[tagName]);
873
+ }
874
+ if (element.namespaceURI === MATHML_NAMESPACE) {
875
+ // The only way to switch from HTML namespace to MathML
876
+ // is via <math>. If it happens via any other tag, then
877
+ // it should be killed.
878
+ if (parent.namespaceURI === HTML_NAMESPACE) {
879
+ return tagName === 'math';
880
+ }
881
+ // The only way to switch from SVG to MathML is via
882
+ // <math> and HTML integration points
883
+ if (parent.namespaceURI === SVG_NAMESPACE) {
884
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
885
+ }
886
+ // We only allow elements that are defined in MathML
887
+ // spec. All others are disallowed in MathML namespace.
888
+ return Boolean(ALL_MATHML_TAGS[tagName]);
889
+ }
890
+ if (element.namespaceURI === HTML_NAMESPACE) {
891
+ // The only way to switch from SVG to HTML is via
892
+ // HTML integration points, and from MathML to HTML
893
+ // is via MathML text integration points
894
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
895
+ return false;
896
+ }
897
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
898
+ return false;
899
+ }
900
+ // We disallow tags that are specific for MathML
901
+ // or SVG and should never appear in HTML namespace
902
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
903
+ }
904
+ // For XHTML and XML documents that support custom namespaces
905
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
906
+ return true;
907
+ }
908
+ // The code should never reach this place (this means
909
+ // that the element somehow got namespace that is not
910
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
911
+ // Return false just in case.
912
+ return false;
913
+ };
914
+ /**
915
+ * _forceRemove
916
+ *
917
+ * @param node a DOM node
918
+ */
919
+ const _forceRemove = function _forceRemove(node) {
920
+ arrayPush(DOMPurify.removed, {
921
+ element: node
922
+ });
923
+ try {
924
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
925
+ getParentNode(node).removeChild(node);
926
+ } catch (_) {
927
+ remove(node);
928
+ }
929
+ };
930
+ /**
931
+ * _removeAttribute
932
+ *
933
+ * @param name an Attribute name
934
+ * @param element a DOM node
935
+ */
936
+ const _removeAttribute = function _removeAttribute(name, element) {
937
+ try {
938
+ arrayPush(DOMPurify.removed, {
939
+ attribute: element.getAttributeNode(name),
940
+ from: element
941
+ });
942
+ } catch (_) {
943
+ arrayPush(DOMPurify.removed, {
944
+ attribute: null,
945
+ from: element
946
+ });
947
+ }
948
+ element.removeAttribute(name);
949
+ // We void attribute values for unremovable "is" attributes
950
+ if (name === 'is') {
951
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
952
+ try {
953
+ _forceRemove(element);
954
+ } catch (_) {}
955
+ } else {
956
+ try {
957
+ element.setAttribute(name, '');
958
+ } catch (_) {}
959
+ }
960
+ }
961
+ };
962
+ /**
963
+ * _initDocument
964
+ *
965
+ * @param dirty - a string of dirty markup
966
+ * @return a DOM, filled with the dirty markup
967
+ */
968
+ const _initDocument = function _initDocument(dirty) {
969
+ /* Create a HTML document */
970
+ let doc = null;
971
+ let leadingWhitespace = null;
972
+ if (FORCE_BODY) {
973
+ dirty = '<remove></remove>' + dirty;
974
+ } else {
975
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
976
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
977
+ leadingWhitespace = matches && matches[0];
978
+ }
979
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
980
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
981
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
982
+ }
983
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
984
+ /*
985
+ * Use the DOMParser API by default, fallback later if needs be
986
+ * DOMParser not work for svg when has multiple root element.
987
+ */
988
+ if (NAMESPACE === HTML_NAMESPACE) {
989
+ try {
990
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
991
+ } catch (_) {}
992
+ }
993
+ /* Use createHTMLDocument in case DOMParser is not available */
994
+ if (!doc || !doc.documentElement) {
995
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
996
+ try {
997
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
998
+ } catch (_) {
999
+ // Syntax error if dirtyPayload is invalid xml
1000
+ }
1001
+ }
1002
+ const body = doc.body || doc.documentElement;
1003
+ if (dirty && leadingWhitespace) {
1004
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1005
+ }
1006
+ /* Work on whole document or just its body */
1007
+ if (NAMESPACE === HTML_NAMESPACE) {
1008
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1009
+ }
1010
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1011
+ };
1012
+ /**
1013
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1014
+ *
1015
+ * @param root The root element or node to start traversing on.
1016
+ * @return The created NodeIterator
1017
+ */
1018
+ const _createNodeIterator = function _createNodeIterator(root) {
1019
+ return createNodeIterator.call(root.ownerDocument || root, root,
1020
+ // eslint-disable-next-line no-bitwise
1021
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1022
+ };
1023
+ /**
1024
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1025
+ * character data of an element subtree. Used as the final safety net for
1026
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1027
+ * which only form after text-node normalization (e.g. fragments split across
1028
+ * stripped elements) cannot survive into a template-evaluating framework.
1029
+ *
1030
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1031
+ * in place rather than round-tripping through innerHTML. This preserves
1032
+ * descendant node references (important for IN_PLACE callers), avoids a
1033
+ * serialize/reparse cycle, and reads literal character data — which means
1034
+ * `<%...%>` in text content matches the ERB regex against its real bytes
1035
+ * instead of the HTML-entity-escaped form innerHTML would produce.
1036
+ *
1037
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1038
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
1039
+ *
1040
+ * @param node The root element whose character data should be scrubbed.
1041
+ */
1042
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1043
+ var _node$querySelectorAl, _node$querySelectorAl2;
1044
+ node.normalize();
1045
+ const walker = createNodeIterator.call(node.ownerDocument || node, node,
1046
+ // eslint-disable-next-line no-bitwise
1047
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1048
+ let currentNode = walker.nextNode();
1049
+ while (currentNode) {
1050
+ let data = currentNode.data;
1051
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1052
+ data = stringReplace(data, expr, ' ');
1053
+ });
1054
+ currentNode.data = data;
1055
+ currentNode = walker.nextNode();
1056
+ }
1057
+ // NodeIterator does not descend into <template>.content per the DOM spec,
1058
+ // so we must explicitly recurse into each template's content fragment,
1059
+ // mirroring the approach used by _sanitizeShadowDOM.
1060
+ const templates = (_node$querySelectorAl = (_node$querySelectorAl2 = node.querySelectorAll) === null || _node$querySelectorAl2 === void 0 ? void 0 : _node$querySelectorAl2.call(node, 'template')) !== null && _node$querySelectorAl !== void 0 ? _node$querySelectorAl : [];
1061
+ arrayForEach(Array.from(templates), tmpl => {
1062
+ if (_isDocumentFragment(tmpl.content)) {
1063
+ _scrubTemplateExpressions2(tmpl.content);
1064
+ }
1065
+ });
1066
+ };
1067
+ /**
1068
+ * _isClobbered
1069
+ *
1070
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1071
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1072
+ * `name` attribute matching a prototype property shadows that property
1073
+ * on direct reads. We use this check at the IN_PLACE entry-point and
1074
+ * during attribute sanitization to refuse clobbered forms.
1075
+ *
1076
+ * @param element element to check for clobbering attacks
1077
+ * @return true if clobbered, false if safe
1078
+ */
1079
+ const _isClobbered = function _isClobbered(element) {
1080
+ // Realm-independent tag-name probe. If we can't determine the tag
1081
+ // name at all, we can't reason about clobbering — return false
1082
+ // (the caller's other defences still apply).
1083
+ const realTagName = getNodeName ? getNodeName(element) : null;
1084
+ if (typeof realTagName !== 'string') {
1085
+ return false;
1086
+ }
1087
+ if (transformCaseFunc(realTagName) !== 'form') {
1088
+ return false;
1089
+ }
1090
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
1091
+ // Realm-safe NamedNodeMap detection: equality against the cached
1092
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
1093
+ // makes the direct read diverge from the cached read; a clean form
1094
+ // (same-realm OR foreign-realm) has both reads pointing at the same
1095
+ // canonical NamedNodeMap.
1096
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
1097
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
1098
+ // returns the integer 1 for any Element regardless of realm; direct
1099
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
1100
+ // the named child element. Cheap addition — nodeType is read from
1101
+ // an internal slot, no serialization cost — and removes a residual
1102
+ // clobbering surface used by several mXSS / PI / comment branches
1103
+ // in _sanitizeElements that compare currentNode.nodeType directly.
1104
+ element.nodeType !== getNodeType(element) ||
1105
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
1106
+ // "childNodes" shadows the prototype getter. Direct reads of
1107
+ // form.childNodes from a clobbered form return the named child
1108
+ // instead of the real NodeList, so any walk that reads it directly
1109
+ // skips the form's real children. Compare the direct read to the
1110
+ // cached Node.prototype getter — when the form's named-property
1111
+ // getter intercepts the read, the two values differ and we flag
1112
+ // the form. This catches every clobbering child type (input,
1113
+ // select, etc.) regardless of whether the named child happens to
1114
+ // carry a numeric .length, which a typeof-based probe would miss
1115
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
1116
+ element.childNodes !== getChildNodes(element);
1117
+ };
1118
+ /**
1119
+ * Checks whether the given value is a DocumentFragment from any realm.
1120
+ *
1121
+ * The realm-independent replacement reads `nodeType` through the cached
1122
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1123
+ * constant (11). nodeType is a numeric value resolved from the node's
1124
+ * internal slot, identical across realms for the same kind of node.
1125
+ *
1126
+ * @param value object to check
1127
+ * @return true if value is a DocumentFragment-shaped node from any realm
1128
+ */
1129
+ const _isDocumentFragment = function _isDocumentFragment(value) {
1130
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1131
+ return false;
1132
+ }
1133
+ try {
1134
+ return getNodeType(value) === NODE_TYPE.documentFragment;
1135
+ } catch (_) {
1136
+ return false;
1137
+ }
1138
+ };
1139
+ /**
1140
+ * Checks whether the given object is a DOM node, including nodes that
1141
+ * originate from a different window/realm (e.g. an iframe's
1142
+ * contentDocument). The previous `value instanceof Node` check was
1143
+ * realm-bound: nodes from a different window failed it, causing
1144
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
1145
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1146
+ *
1147
+ * @param value object to check whether it's a DOM node
1148
+ * @return true if value is a DOM node from any realm
1149
+ */
1150
+ const _isNode = function _isNode(value) {
1151
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1152
+ return false;
1153
+ }
1154
+ try {
1155
+ return typeof getNodeType(value) === 'number';
1156
+ } catch (_) {
1157
+ return false;
1158
+ }
1159
+ };
1160
+ function _executeHooks(hooks, currentNode, data) {
1161
+ arrayForEach(hooks, hook => {
1162
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1163
+ });
1164
+ }
1165
+ /**
1166
+ * _sanitizeElements
1167
+ *
1168
+ * @protect nodeName
1169
+ * @protect textContent
1170
+ * @protect removeChild
1171
+ * @param currentNode to check for permission to exist
1172
+ * @return true if node was killed, false if left alive
1173
+ */
1174
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1175
+ let content = null;
1176
+ /* Execute a hook if present */
1177
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1178
+ /* Check if element is clobbered or can clobber */
1179
+ if (_isClobbered(currentNode)) {
1180
+ _forceRemove(currentNode);
1181
+ return true;
1182
+ }
1183
+ /* Now let's check the element's type and name */
1184
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
1185
+ /* Execute a hook if present */
1186
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1187
+ tagName,
1188
+ allowedTags: ALLOWED_TAGS
1189
+ });
1190
+ /* Detect mXSS attempts abusing namespace confusion */
1191
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
1192
+ _forceRemove(currentNode);
1193
+ return true;
1194
+ }
1195
+ /* Remove risky CSS construction leading to mXSS */
1196
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1197
+ _forceRemove(currentNode);
1198
+ return true;
1199
+ }
1200
+ /* Remove any occurrence of processing instructions */
1201
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1202
+ _forceRemove(currentNode);
1203
+ return true;
1204
+ }
1205
+ /* Remove any kind of possibly harmful comments */
1206
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1207
+ _forceRemove(currentNode);
1208
+ return true;
1209
+ }
1210
+ /* Remove element if anything forbids its presence */
1211
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1212
+ /* Check if we have a custom element to handle */
1213
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1214
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1215
+ return false;
1216
+ }
1217
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1218
+ return false;
1219
+ }
1220
+ }
1221
+ /* Keep content except for bad-listed elements.
1222
+ Use the cached prototype getters exclusively — the previous code
1223
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
1224
+ fallbacks, but the cached getters always return the canonical
1225
+ value (or null for a real parent-less node), so the fallback
1226
+ path was dead in safe cases and a clobbering surface in unsafe
1227
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
1228
+ parentNode)` check already gates correctly. */
1229
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1230
+ const parentNode = getParentNode(currentNode);
1231
+ const childNodes = getChildNodes(currentNode);
1232
+ if (childNodes && parentNode) {
1233
+ const childCount = childNodes.length;
1234
+ for (let i = childCount - 1; i >= 0; --i) {
1235
+ const childClone = cloneNode(childNodes[i], true);
1236
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
1237
+ }
1238
+ }
1239
+ }
1240
+ _forceRemove(currentNode);
1241
+ return true;
1242
+ }
1243
+ /* Check whether element has a valid namespace.
1244
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
1245
+ nodeType getter rather than `instanceof Element`, which is realm-
1246
+ bound and short-circuits to false for any node minted in a different
1247
+ realm — letting a foreign-realm element with a forbidden namespace
1248
+ slip past the namespace check entirely. */
1249
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
1250
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1251
+ _forceRemove(currentNode);
1252
+ return true;
1253
+ }
1254
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1255
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1256
+ _forceRemove(currentNode);
1257
+ return true;
1258
+ }
1259
+ /* Sanitize element content to be template-safe */
1260
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1261
+ /* Get the element's text content */
1262
+ content = currentNode.textContent;
1263
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1264
+ content = stringReplace(content, expr, ' ');
1265
+ });
1266
+ if (currentNode.textContent !== content) {
1267
+ arrayPush(DOMPurify.removed, {
1268
+ element: currentNode.cloneNode()
1269
+ });
1270
+ currentNode.textContent = content;
1271
+ }
1272
+ }
1273
+ /* Execute a hook if present */
1274
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1275
+ return false;
1276
+ };
1277
+ /**
1278
+ * _isValidAttribute
1279
+ *
1280
+ * @param lcTag Lowercase tag name of containing element.
1281
+ * @param lcName Lowercase attribute name.
1282
+ * @param value Attribute value.
1283
+ * @return Returns true if `value` is valid, otherwise false.
1284
+ */
1285
+ // eslint-disable-next-line complexity
1286
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1287
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1288
+ if (FORBID_ATTR[lcName]) {
1289
+ return false;
1290
+ }
1291
+ /* Make sure attribute cannot clobber */
1292
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1293
+ return false;
1294
+ }
1295
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1296
+ /* Allow valid data-* attributes: At least one character after "-"
1297
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1298
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1299
+ We don't need to check the value; it's always URI safe. */
1300
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
1301
+ if (
1302
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1303
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1304
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1305
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||
1306
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1307
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1308
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
1309
+ return false;
1310
+ }
1311
+ /* Check value is safe. First, is attr inert? If so, is safe */
1312
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {
1313
+ return false;
1314
+ } else ;
1315
+ return true;
1316
+ };
1317
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
1318
+ * never be treated as basic custom elements even when a permissive
1319
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
1320
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
1321
+ /**
1322
+ * _isBasicCustomElement
1323
+ * checks if at least one dash is included in tagName, and it's not the first char
1324
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1325
+ *
1326
+ * @param tagName name of the tag of the node to sanitize
1327
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1328
+ */
1329
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1330
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1331
+ };
1332
+ /**
1333
+ * _sanitizeAttributes
1334
+ *
1335
+ * @protect attributes
1336
+ * @protect nodeName
1337
+ * @protect removeAttribute
1338
+ * @protect setAttribute
1339
+ *
1340
+ * @param currentNode to sanitize
1341
+ */
1342
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1343
+ /* Execute a hook if present */
1344
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
1345
+ const attributes = currentNode.attributes;
1346
+ /* Check if we have attributes; if not we might have a text node */
1347
+ if (!attributes || _isClobbered(currentNode)) {
1348
+ return;
1349
+ }
1350
+ const hookEvent = {
1351
+ attrName: '',
1352
+ attrValue: '',
1353
+ keepAttr: true,
1354
+ allowedAttributes: ALLOWED_ATTR,
1355
+ forceKeepAttr: undefined
1356
+ };
1357
+ let l = attributes.length;
1358
+ /* Go backwards over all attributes; safely remove bad ones */
1359
+ while (l--) {
1360
+ const attr = attributes[l];
1361
+ const name = attr.name,
1362
+ namespaceURI = attr.namespaceURI,
1363
+ attrValue = attr.value;
1364
+ const lcName = transformCaseFunc(name);
1365
+ const initValue = attrValue;
1366
+ let value = name === 'value' ? initValue : stringTrim(initValue);
1367
+ /* Execute a hook if present */
1368
+ hookEvent.attrName = lcName;
1369
+ hookEvent.attrValue = value;
1370
+ hookEvent.keepAttr = true;
1371
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1372
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
1373
+ value = hookEvent.attrValue;
1374
+ /* Full DOM Clobbering protection via namespace isolation,
1375
+ * Prefix id and name attributes with `user-content-`
1376
+ */
1377
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
1378
+ // Remove the attribute with this value
1379
+ _removeAttribute(name, currentNode);
1380
+ // Prefix the value and later re-create the attribute with the sanitized value
1381
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1382
+ }
1383
+ // Else: already prefixed, leave the attribute alone — the prefix is
1384
+ // itself the clobbering protection, and re-applying it is incorrect.
1385
+ /* Work around a security issue with comments inside attributes */
1386
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1387
+ _removeAttribute(name, currentNode);
1388
+ continue;
1389
+ }
1390
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
1391
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
1392
+ _removeAttribute(name, currentNode);
1393
+ continue;
1394
+ }
1395
+ /* Did the hooks approve of the attribute? */
1396
+ if (hookEvent.forceKeepAttr) {
1397
+ continue;
1398
+ }
1399
+ /* Did the hooks approve of the attribute? */
1400
+ if (!hookEvent.keepAttr) {
1401
+ _removeAttribute(name, currentNode);
1402
+ continue;
1403
+ }
1404
+ /* Work around a security issue in jQuery 3.0 */
1405
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1406
+ _removeAttribute(name, currentNode);
1407
+ continue;
1408
+ }
1409
+ /* Sanitize attribute content to be template-safe */
1410
+ if (SAFE_FOR_TEMPLATES) {
1411
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1412
+ value = stringReplace(value, expr, ' ');
1413
+ });
1414
+ }
1415
+ /* Is `value` valid for this attribute? */
1416
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1417
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1418
+ _removeAttribute(name, currentNode);
1419
+ continue;
1420
+ }
1421
+ /* Handle attributes that require Trusted Types */
1422
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1423
+ if (namespaceURI) ; else {
1424
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1425
+ case 'TrustedHTML':
1426
+ {
1427
+ value = _createTrustedHTML(value);
1428
+ break;
1429
+ }
1430
+ case 'TrustedScriptURL':
1431
+ {
1432
+ value = trustedTypesPolicy.createScriptURL(value);
1433
+ break;
1434
+ }
1435
+ }
1436
+ }
1437
+ }
1438
+ /* Handle invalid data-* attribute set by try-catching it */
1439
+ if (value !== initValue) {
1440
+ try {
1441
+ if (namespaceURI) {
1442
+ currentNode.setAttributeNS(namespaceURI, name, value);
1443
+ } else {
1444
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1445
+ currentNode.setAttribute(name, value);
1446
+ }
1447
+ if (_isClobbered(currentNode)) {
1448
+ _forceRemove(currentNode);
1449
+ } else {
1450
+ arrayPop(DOMPurify.removed);
1451
+ }
1452
+ } catch (_) {
1453
+ _removeAttribute(name, currentNode);
1454
+ }
1455
+ }
1456
+ }
1457
+ /* Execute a hook if present */
1458
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
1459
+ };
1460
+ /**
1461
+ * _sanitizeShadowDOM
1462
+ *
1463
+ * @param fragment to iterate over recursively
1464
+ */
1465
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1466
+ let shadowNode = null;
1467
+ const shadowIterator = _createNodeIterator(fragment);
1468
+ /* Execute a hook if present */
1469
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1470
+ while (shadowNode = shadowIterator.nextNode()) {
1471
+ /* Execute a hook if present */
1472
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1473
+ /* Sanitize tags and elements */
1474
+ _sanitizeElements(shadowNode);
1475
+ /* Check attributes next */
1476
+ _sanitizeAttributes(shadowNode);
1477
+ /* Deep shadow DOM detected.
1478
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
1479
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
1480
+ recurse into <template>.content from foreign realms too. */
1481
+ if (_isDocumentFragment(shadowNode.content)) {
1482
+ _sanitizeShadowDOM2(shadowNode.content);
1483
+ }
1484
+ /* An element iterated here may itself host an attached
1485
+ shadow root. The default NodeIterator does not enter shadow
1486
+ trees, so a shadow root nested inside template.content was
1487
+ previously reached by no walk at all (the pre-pass at
1488
+ _sanitizeAttachedShadowRoots descends via childNodes, which
1489
+ doesn't enter template.content; the template-content recursion
1490
+ above iterates the content but never inspected shadowRoot).
1491
+ Walk it explicitly. The nodeType guard avoids reading
1492
+ shadowRoot off text / comment / CDATA / PI nodes that the
1493
+ iterator also surfaces. */
1494
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
1495
+ if (shadowNodeType === NODE_TYPE.element) {
1496
+ const innerSr = getShadowRoot ? getShadowRoot(shadowNode) : shadowNode.shadowRoot;
1497
+ if (_isDocumentFragment(innerSr)) {
1498
+ _sanitizeAttachedShadowRoots2(innerSr);
1499
+ _sanitizeShadowDOM2(innerSr);
1500
+ }
1501
+ }
1502
+ }
1503
+ /* Execute a hook if present */
1504
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
1505
+ };
1506
+ /**
1507
+ * _sanitizeAttachedShadowRoots
1508
+ *
1509
+ * Walks `root` and feeds every attached shadow root we encounter into
1510
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
1511
+ * does not descend into shadow trees, so nodes inside an attached
1512
+ * shadow root would otherwise be skipped entirely.
1513
+ *
1514
+ * Two real input paths put attached shadow roots in front of us:
1515
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
1516
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
1517
+ * shadow root because it was created with `clonable: true`.
1518
+ *
1519
+ * This pass runs once, up front, so the main iteration loop (and the
1520
+ * existing _sanitizeShadowDOM template-content recursion) stay
1521
+ * untouched — string-input paths are not affected.
1522
+ *
1523
+ * @param root the subtree root to walk for attached shadow roots
1524
+ */
1525
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
1526
+ const nodeType = getNodeType ? getNodeType(root) : root.nodeType;
1527
+ if (nodeType === NODE_TYPE.element) {
1528
+ const sr = getShadowRoot ? getShadowRoot(root) : root.shadowRoot;
1529
+ // Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType-based
1530
+ // detection rather than `instanceof DocumentFragment`, which is
1531
+ // realm-bound and silently skipped shadow roots whose host element
1532
+ // belonged to a foreign realm (e.g. iframe.contentDocument
1533
+ // attachShadow). A foreign-realm ShadowRoot extends the foreign
1534
+ // realm's DocumentFragment, not ours, so the old instanceof check
1535
+ // returned false and the shadow subtree was never walked.
1536
+ if (_isDocumentFragment(sr)) {
1537
+ // Recurse first so that nested shadow roots are reached even if
1538
+ // _sanitizeShadowDOM removes hosts at this level.
1539
+ _sanitizeAttachedShadowRoots2(sr);
1540
+ _sanitizeShadowDOM2(sr);
1541
+ }
1542
+ }
1543
+ // Snapshot children before recursing. Sanitization of one subtree
1544
+ // (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
1545
+ // and naive nextSibling traversal would silently skip the rest of
1546
+ // the list once a node is detached.
1547
+ const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
1548
+ if (!childNodes) {
1549
+ return;
1550
+ }
1551
+ const snapshot = [];
1552
+ arrayForEach(childNodes, child => {
1553
+ arrayPush(snapshot, child);
1554
+ });
1555
+ for (const child of snapshot) {
1556
+ _sanitizeAttachedShadowRoots2(child);
1557
+ }
1558
+ /* When the root is a <template>, also descend into root.content */
1559
+ if (nodeType === NODE_TYPE.element) {
1560
+ const rootName = getNodeName ? getNodeName(root) : null;
1561
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
1562
+ const content = root.content;
1563
+ if (_isDocumentFragment(content)) {
1564
+ _sanitizeAttachedShadowRoots2(content);
1565
+ }
1566
+ }
1567
+ }
1568
+ };
1569
+ // eslint-disable-next-line complexity
1570
+ DOMPurify.sanitize = function (dirty) {
1571
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1572
+ let body = null;
1573
+ let importedNode = null;
1574
+ let currentNode = null;
1575
+ let returnNode = null;
1576
+ /* Make sure we have a string to sanitize.
1577
+ DO NOT return early, as this will return the wrong type if
1578
+ the user has requested a DOM object rather than a string */
1579
+ IS_EMPTY_INPUT = !dirty;
1580
+ if (IS_EMPTY_INPUT) {
1581
+ dirty = '<!-->';
1582
+ }
1583
+ /* Stringify, in case dirty is an object */
1584
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1585
+ dirty = stringifyValue(dirty);
1586
+ if (typeof dirty !== 'string') {
1587
+ throw typeErrorCreate('dirty is not a string, aborting');
1588
+ }
1589
+ }
1590
+ /* Return dirty HTML if DOMPurify cannot run */
1591
+ if (!DOMPurify.isSupported) {
1592
+ return dirty;
1593
+ }
1594
+ /* Assign config vars */
1595
+ if (!SET_CONFIG) {
1596
+ _parseConfig(cfg);
1597
+ }
1598
+ /* Clean up removed elements */
1599
+ DOMPurify.removed = [];
1600
+ /* Check if dirty is correctly typed for IN_PLACE */
1601
+ if (typeof dirty === 'string') {
1602
+ IN_PLACE = false;
1603
+ }
1604
+ if (IN_PLACE) {
1605
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
1606
+ Read nodeName through the cached prototype getter — a clobbering
1607
+ child named "nodeName" on the form root would otherwise shadow
1608
+ the property and let this check skip the root-allowlist
1609
+ validation entirely. */
1610
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
1611
+ if (typeof nn === 'string') {
1612
+ const tagName = transformCaseFunc(nn);
1613
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1614
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1615
+ }
1616
+ }
1617
+ /* Pre-flight the root through _isClobbered. The iterator-driven
1618
+ removal path can not detach a parent-less root: _forceRemove
1619
+ falls through to Element.prototype.remove(), which per spec
1620
+ is a no-op on a node with no parent. A clobbered root would
1621
+ then survive the main loop with its attributes uninspected,
1622
+ because _sanitizeAttributes early-returns on _isClobbered. The
1623
+ result would be an attacker-controlled form, complete with any
1624
+ event-handler attributes the caller passed in, handed back to
1625
+ the application unsanitized. Refuse to sanitize such a root
1626
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
1627
+ if (_isClobbered(dirty)) {
1628
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
1629
+ }
1630
+ /* Sanitize attached shadow roots before the main iterator runs.
1631
+ The iterator does not descend into shadow trees. */
1632
+ _sanitizeAttachedShadowRoots2(dirty);
1633
+ } else if (_isNode(dirty)) {
1634
+ /* If dirty is a DOM element, append to an empty document to avoid
1635
+ elements being stripped by the parser */
1636
+ body = _initDocument('<!---->');
1637
+ importedNode = body.ownerDocument.importNode(dirty, true);
1638
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1639
+ /* Node is already a body, use as is */
1640
+ body = importedNode;
1641
+ } else if (importedNode.nodeName === 'HTML') {
1642
+ body = importedNode;
1643
+ } else {
1644
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1645
+ body.appendChild(importedNode);
1646
+ }
1647
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
1648
+ them before the main iterator runs, since the iterator does not
1649
+ descend into shadow trees. The walk routes every read through a
1650
+ cached prototype getter so clobbering descendants on a form root
1651
+ cannot hide a shadow host from this pass. */
1652
+ _sanitizeAttachedShadowRoots2(importedNode);
1653
+ } else {
1654
+ /* Exit directly if we have nothing to do */
1655
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1656
+ // eslint-disable-next-line unicorn/prefer-includes
1657
+ dirty.indexOf('<') === -1) {
1658
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
1659
+ }
1660
+ /* Initialize the document to work on */
1661
+ body = _initDocument(dirty);
1662
+ /* Check we have a DOM node from the data */
1663
+ if (!body) {
1664
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1665
+ }
1666
+ }
1667
+ /* Remove first element node (ours) if FORCE_BODY is set */
1668
+ if (body && FORCE_BODY) {
1669
+ _forceRemove(body.firstChild);
1670
+ }
1671
+ /* Get node iterator */
1672
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1673
+ /* Now start iterating over the created document */
1674
+ while (currentNode = nodeIterator.nextNode()) {
1675
+ /* Sanitize tags and elements */
1676
+ _sanitizeElements(currentNode);
1677
+ /* Check attributes next */
1678
+ _sanitizeAttributes(currentNode);
1679
+ /* Shadow DOM detected, sanitize it.
1680
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
1681
+ instead of instanceof, so foreign-realm <template>.content is
1682
+ walked correctly. */
1683
+ if (_isDocumentFragment(currentNode.content)) {
1684
+ _sanitizeShadowDOM2(currentNode.content);
1685
+ }
1686
+ }
1687
+ /* If we sanitized `dirty` in-place, return it. */
1688
+ if (IN_PLACE) {
1689
+ if (SAFE_FOR_TEMPLATES) {
1690
+ _scrubTemplateExpressions2(dirty);
1691
+ }
1692
+ return dirty;
1693
+ }
1694
+ /* Return sanitized string or DOM */
1695
+ if (RETURN_DOM) {
1696
+ if (SAFE_FOR_TEMPLATES) {
1697
+ _scrubTemplateExpressions2(body);
1698
+ }
1699
+ if (RETURN_DOM_FRAGMENT) {
1700
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1701
+ while (body.firstChild) {
1702
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1703
+ returnNode.appendChild(body.firstChild);
1704
+ }
1705
+ } else {
1706
+ returnNode = body;
1707
+ }
1708
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1709
+ /*
1710
+ AdoptNode() is not used because internal state is not reset
1711
+ (e.g. the past names map of a HTMLFormElement), this is safe
1712
+ in theory but we would rather not risk another attack vector.
1713
+ The state that is cloned by importNode() is explicitly defined
1714
+ by the specs.
1715
+ */
1716
+ returnNode = importNode.call(originalDocument, returnNode, true);
1717
+ }
1718
+ return returnNode;
1719
+ }
1720
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1721
+ /* Serialize doctype if allowed */
1722
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1723
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1724
+ }
1725
+ /* Sanitize final string template-safe */
1726
+ if (SAFE_FOR_TEMPLATES) {
1727
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1728
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
1729
+ });
1730
+ }
1731
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
1732
+ };
1733
+ DOMPurify.setConfig = function () {
1734
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1735
+ _parseConfig(cfg);
1736
+ SET_CONFIG = true;
1737
+ };
1738
+ DOMPurify.clearConfig = function () {
1739
+ CONFIG = null;
1740
+ SET_CONFIG = false;
1741
+ };
1742
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1743
+ /* Initialize shared config vars if necessary. */
1744
+ if (!CONFIG) {
1745
+ _parseConfig({});
1746
+ }
1747
+ const lcTag = transformCaseFunc(tag);
1748
+ const lcName = transformCaseFunc(attr);
1749
+ return _isValidAttribute(lcTag, lcName, value);
1750
+ };
1751
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1752
+ if (typeof hookFunction !== 'function') {
1753
+ return;
1754
+ }
1755
+ arrayPush(hooks[entryPoint], hookFunction);
1756
+ };
1757
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
1758
+ if (hookFunction !== undefined) {
1759
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
1760
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
1761
+ }
1762
+ return arrayPop(hooks[entryPoint]);
1763
+ };
1764
+ DOMPurify.removeHooks = function (entryPoint) {
1765
+ hooks[entryPoint] = [];
1766
+ };
1767
+ DOMPurify.removeAllHooks = function () {
1768
+ hooks = _createHooksMap();
1769
+ };
1770
+ return DOMPurify;
1771
+ }
1772
+ var purify = createDOMPurify();
1773
+
1774
+ const BASE_INLINE = ['p', 'br', 'strong', 'em', 'a', 'span'];
1775
+ const BASE_ATTR = ['href', 'target', 'rel', 'data-mention-id', 'data-mention-label'];
1776
+ const SANITIZE_CONFIGS = {
1777
+ comment: {
1778
+ ALLOWED_TAGS: [...BASE_INLINE],
1779
+ ALLOWED_ATTR: [...BASE_ATTR],
1780
+ ALLOW_DATA_ATTR: false,
1781
+ },
1782
+ task: {
1783
+ ALLOWED_TAGS: [...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote'],
1784
+ ALLOWED_ATTR: [...BASE_ATTR],
1785
+ ALLOW_DATA_ATTR: false,
1786
+ },
1787
+ email: {
1788
+ ALLOWED_TAGS: [
1789
+ ...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote',
1790
+ 'h2', 'h3', 'div', 'img',
1791
+ ],
1792
+ ALLOWED_ATTR: [...BASE_ATTR, 'style', 'data-variable', 'src', 'alt', 'width', 'height'],
1793
+ ALLOW_DATA_ATTR: false,
1794
+ },
1795
+ document: {
1796
+ ALLOWED_TAGS: [
1797
+ ...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote',
1798
+ 'h1', 'h2', 'h3', 'h4', 'hr', 'div', 'mark', 'img',
1799
+ 'table', 'thead', 'tbody', 'tr', 'th', 'td',
1800
+ ],
1801
+ ALLOWED_ATTR: [...BASE_ATTR, 'style', 'data-variable', 'colspan', 'rowspan', 'src', 'alt', 'width', 'height'],
1802
+ ALLOW_DATA_ATTR: false,
1803
+ },
1804
+ };
1805
+ /** Tags forbidden in every preset, regardless of the allow-list. */
1806
+ const FORBID_TAGS = ['script', 'iframe', 'object', 'embed', 'form', 'input', 'textarea', 'style'];
1807
+ /** Attributes forbidden in every preset (event handlers handled by DOMPurify itself). */
1808
+ const FORBID_ATTR = ['onerror', 'onload', 'onclick'];
1809
+ /**
1810
+ * Resolve the effective config for a preset + feature overrides. Features can
1811
+ * only ADD capabilities (mirroring `getExtensions`, where they register extra
1812
+ * nodes); they never narrow a preset's base whitelist.
1813
+ */
1814
+ function configFor(preset, features) {
1815
+ const cfg = SANITIZE_CONFIGS[preset] ?? SANITIZE_CONFIGS.task;
1816
+ if (!features)
1817
+ return cfg;
1818
+ const tags = new Set(cfg.ALLOWED_TAGS);
1819
+ const attr = new Set(cfg.ALLOWED_ATTR);
1820
+ if (features.image) {
1821
+ tags.add('img');
1822
+ ['src', 'alt', 'width', 'height'].forEach((a) => attr.add(a));
1823
+ }
1824
+ if (features.variables)
1825
+ attr.add('data-variable');
1826
+ // mentions: data-mention-id/label are already in BASE_ATTR for every preset.
1827
+ return { ...cfg, ALLOWED_TAGS: [...tags], ALLOWED_ATTR: [...attr] };
1828
+ }
1829
+ /**
1830
+ * `style` is only allowed in email/document, and even there we cap it to the
1831
+ * properties our extensions actually emit (TextStyle/Color). Everything else —
1832
+ * position, background-image url(), etc. — is UI-redressing/tracking surface.
1833
+ */
1834
+ const STYLE_ALLOWED_PROPS = new Set(['color', 'background-color', 'text-align']);
1835
+ let styleHookInstalled = false;
1836
+ function ensureStyleHook() {
1837
+ if (styleHookInstalled)
1838
+ return;
1839
+ styleHookInstalled = true;
1840
+ purify.addHook('uponSanitizeAttribute', (_node, data) => {
1841
+ if (data.attrName !== 'style')
1842
+ return;
1843
+ const safe = data.attrValue
1844
+ .split(';')
1845
+ .map((d) => d.trim())
1846
+ .filter((d) => {
1847
+ const colon = d.indexOf(':');
1848
+ if (colon <= 0)
1849
+ return false;
1850
+ const prop = d.slice(0, colon).trim().toLowerCase();
1851
+ return STYLE_ALLOWED_PROPS.has(prop) && !/url\s*\(|expression\s*\(/i.test(d);
1852
+ });
1853
+ data.attrValue = safe.join('; ');
1854
+ if (!data.attrValue)
1855
+ data.keepAttr = false;
1856
+ });
1857
+ }
1858
+ /**
1859
+ * Sanitize an HTML string for the given preset (+ feature overrides — pass the
1860
+ * same `features` you gave `getExtensions`/`createEditor` so the whitelist
1861
+ * stays in lock-step with the schema). Always strips script/iframe/style-tag/
1862
+ * form/event-handlers and `javascript:` URLs (DOMPurify default).
1863
+ */
1864
+ function sanitize(html, preset = 'task', features) {
1865
+ if (!html)
1866
+ return '';
1867
+ ensureStyleHook();
1868
+ const cfg = configFor(preset, features);
1869
+ return purify.sanitize(html, {
1870
+ ALLOWED_TAGS: cfg.ALLOWED_TAGS,
1871
+ ALLOWED_ATTR: cfg.ALLOWED_ATTR,
1872
+ ALLOW_DATA_ATTR: cfg.ALLOW_DATA_ATTR ?? false,
1873
+ FORBID_TAGS,
1874
+ FORBID_ATTR,
1875
+ // Keep relative/safe links only; DOMPurify drops javascript: by default.
1876
+ ADD_ATTR: ['target'],
1877
+ });
1878
+ }
1879
+
1880
+ export { SANITIZE_CONFIGS as S, sanitize as s };