@touchvue/chat 1.0.0-beta.5 → 1.0.0-beta.51

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 (443) hide show
  1. package/README.md +25 -25
  2. package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  3. package/es/_virtual/_plugin-vue_export-helper.mjs.map +1 -0
  4. package/es/index.mjs.map +1 -1
  5. package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs +4816 -0
  6. package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs.map +1 -0
  7. package/es/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.mjs +1536 -0
  8. package/es/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.mjs.map +1 -0
  9. package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs +7824 -0
  10. package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs.map +1 -0
  11. package/es/package.json.css +1 -1
  12. package/es/package.json.mjs +2 -2
  13. package/es/packages/components/index.mjs +1 -1
  14. package/es/packages/components/resolver.mjs.map +1 -1
  15. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs +3 -2
  16. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs.map +1 -1
  17. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs +219 -159
  18. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs.map +1 -1
  19. package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs +3 -2
  20. package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs.map +1 -1
  21. package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs +27 -13
  22. package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs.map +1 -1
  23. package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs +3 -2
  24. package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs.map +1 -1
  25. package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs +182 -41
  26. package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs.map +1 -1
  27. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs +3 -2
  28. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs.map +1 -1
  29. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs +15 -10
  30. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs.map +1 -1
  31. package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs +3 -2
  32. package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs.map +1 -1
  33. package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs +18 -11
  34. package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs.map +1 -1
  35. package/es/packages/components/touchchat/component/CardView.vue.mjs +3 -2
  36. package/es/packages/components/touchchat/component/CardView.vue.mjs.map +1 -1
  37. package/es/packages/components/touchchat/component/CardView.vue2.mjs +66 -42
  38. package/es/packages/components/touchchat/component/CardView.vue2.mjs.map +1 -1
  39. package/es/packages/components/touchchat/component/FileContent.vue.mjs +7 -0
  40. package/es/packages/components/touchchat/component/FileContent.vue.mjs.map +1 -0
  41. package/es/packages/components/touchchat/component/FileContent.vue2.mjs +206 -0
  42. package/es/packages/components/touchchat/component/FileContent.vue2.mjs.map +1 -0
  43. package/es/packages/components/touchchat/component/FileView.vue.mjs +3 -2
  44. package/es/packages/components/touchchat/component/FileView.vue.mjs.map +1 -1
  45. package/es/packages/components/touchchat/component/FileView.vue2.mjs +17 -4
  46. package/es/packages/components/touchchat/component/FileView.vue2.mjs.map +1 -1
  47. package/es/packages/components/touchchat/component/HelloChat.vue.mjs +3 -2
  48. package/es/packages/components/touchchat/component/HelloChat.vue.mjs.map +1 -1
  49. package/es/packages/components/touchchat/component/HelloChat.vue2.mjs +26 -14
  50. package/es/packages/components/touchchat/component/HelloChat.vue2.mjs.map +1 -1
  51. package/es/packages/components/touchchat/component/ImageFile.vue.mjs +7 -0
  52. package/es/packages/components/touchchat/component/ImageFile.vue.mjs.map +1 -0
  53. package/es/packages/components/touchchat/component/ImageFile.vue2.mjs +162 -0
  54. package/es/packages/components/touchchat/component/ImageFile.vue2.mjs.map +1 -0
  55. package/es/packages/components/touchchat/component/ImageView.vue.mjs +3 -2
  56. package/es/packages/components/touchchat/component/ImageView.vue.mjs.map +1 -1
  57. package/es/packages/components/touchchat/component/ImageView.vue2.mjs +1 -1
  58. package/es/packages/components/touchchat/component/ImageView.vue2.mjs.map +1 -1
  59. package/es/packages/components/touchchat/component/LinkView.vue.mjs +3 -2
  60. package/es/packages/components/touchchat/component/LinkView.vue.mjs.map +1 -1
  61. package/es/packages/components/touchchat/component/LinkView.vue2.mjs +19 -5
  62. package/es/packages/components/touchchat/component/LinkView.vue2.mjs.map +1 -1
  63. package/es/packages/components/touchchat/component/MarkLayer.vue.mjs +7 -0
  64. package/es/packages/components/touchchat/component/MarkLayer.vue.mjs.map +1 -0
  65. package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs +56 -0
  66. package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs.map +1 -0
  67. package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs +7 -0
  68. package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs.map +1 -0
  69. package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs +121 -0
  70. package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs.map +1 -0
  71. package/es/packages/components/touchchat/component/PDFFile.vue.mjs +7 -0
  72. package/es/packages/components/touchchat/component/PDFFile.vue.mjs.map +1 -0
  73. package/es/packages/components/touchchat/component/PDFFile.vue2.mjs +211 -0
  74. package/es/packages/components/touchchat/component/PDFFile.vue2.mjs.map +1 -0
  75. package/es/packages/components/touchchat/component/QuoteContent.vue.mjs +7 -0
  76. package/es/packages/components/touchchat/component/QuoteContent.vue.mjs.map +1 -0
  77. package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs +40 -0
  78. package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs.map +1 -0
  79. package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs +7 -0
  80. package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs.map +1 -0
  81. package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs +160 -0
  82. package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs.map +1 -0
  83. package/es/packages/components/touchchat/component/Screenshot.vue.mjs +7 -0
  84. package/es/packages/components/touchchat/component/Screenshot.vue.mjs.map +1 -0
  85. package/es/packages/components/touchchat/component/Screenshot.vue2.mjs +208 -0
  86. package/es/packages/components/touchchat/component/Screenshot.vue2.mjs.map +1 -0
  87. package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs +7 -0
  88. package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs.map +1 -0
  89. package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs +69 -0
  90. package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs.map +1 -0
  91. package/es/packages/components/touchchat/component/UploadView.vue.mjs +7 -0
  92. package/es/packages/components/touchchat/component/UploadView.vue.mjs.map +1 -0
  93. package/es/packages/components/touchchat/component/UploadView.vue2.mjs +186 -0
  94. package/es/packages/components/touchchat/component/UploadView.vue2.mjs.map +1 -0
  95. package/es/packages/components/touchchat/component/UploadView_api.vue.mjs +7 -0
  96. package/es/packages/components/touchchat/component/UploadView_api.vue.mjs.map +1 -0
  97. package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs +166 -0
  98. package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs.map +1 -0
  99. package/es/packages/components/touchchat/component/VideoFile.vue.mjs +7 -0
  100. package/es/packages/components/touchchat/component/VideoFile.vue.mjs.map +1 -0
  101. package/es/packages/components/touchchat/component/VideoFile.vue2.mjs +33 -0
  102. package/es/packages/components/touchchat/component/VideoFile.vue2.mjs.map +1 -0
  103. package/es/packages/components/touchchat/component/VoiceView.vue.mjs +7 -0
  104. package/es/packages/components/touchchat/component/VoiceView.vue.mjs.map +1 -0
  105. package/es/packages/components/touchchat/component/VoiceView.vue2.mjs +165 -0
  106. package/es/packages/components/touchchat/component/VoiceView.vue2.mjs.map +1 -0
  107. package/es/packages/components/touchchat/img/file/doc.png.mjs +4 -0
  108. package/es/packages/components/touchchat/img/file/doc.png.mjs.map +1 -0
  109. package/es/packages/components/touchchat/img/file/docx.png.mjs +4 -0
  110. package/es/packages/components/touchchat/img/file/docx.png.mjs.map +1 -0
  111. package/es/packages/components/touchchat/img/file/gif.png.mjs +4 -0
  112. package/es/packages/components/touchchat/img/file/gif.png.mjs.map +1 -0
  113. package/es/packages/components/touchchat/img/file/html.png.mjs +4 -0
  114. package/es/packages/components/touchchat/img/file/html.png.mjs.map +1 -0
  115. package/es/packages/components/touchchat/img/file/jpg.png.mjs +4 -0
  116. package/es/packages/components/touchchat/img/file/jpg.png.mjs.map +1 -0
  117. package/es/packages/components/touchchat/img/file/mp3.png.mjs +4 -0
  118. package/es/packages/components/touchchat/img/file/mp3.png.mjs.map +1 -0
  119. package/es/packages/components/touchchat/img/file/mp4.png.mjs +4 -0
  120. package/es/packages/components/touchchat/img/file/mp4.png.mjs.map +1 -0
  121. package/es/packages/components/touchchat/img/file/music.png.mjs +4 -0
  122. package/es/packages/components/touchchat/img/file/music.png.mjs.map +1 -0
  123. package/es/packages/components/touchchat/img/file/pdf.png.mjs +4 -0
  124. package/es/packages/components/touchchat/img/file/pdf.png.mjs.map +1 -0
  125. package/es/packages/components/touchchat/img/file/png.png.mjs +4 -0
  126. package/es/packages/components/touchchat/img/file/png.png.mjs.map +1 -0
  127. package/es/packages/components/touchchat/img/file/ppt.png.mjs +4 -0
  128. package/es/packages/components/touchchat/img/file/ppt.png.mjs.map +1 -0
  129. package/es/packages/components/touchchat/img/file/pptx.png.mjs +4 -0
  130. package/es/packages/components/touchchat/img/file/pptx.png.mjs.map +1 -0
  131. package/es/packages/components/touchchat/img/file/txt.png.mjs +4 -0
  132. package/es/packages/components/touchchat/img/file/txt.png.mjs.map +1 -0
  133. package/es/packages/components/touchchat/img/file/xls.png.mjs +4 -0
  134. package/es/packages/components/touchchat/img/file/xls.png.mjs.map +1 -0
  135. package/es/packages/components/touchchat/img/file/xlsx.png.mjs +4 -0
  136. package/es/packages/components/touchchat/img/file/xlsx.png.mjs.map +1 -0
  137. package/es/packages/components/touchchat/img/svg/reset.svg.mjs +4 -0
  138. package/es/packages/components/touchchat/img/svg/reset.svg.mjs.map +1 -0
  139. package/es/packages/components/touchchat/index.mjs +5 -5
  140. package/es/packages/components/touchchat/index.mjs.map +1 -1
  141. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs +7 -0
  142. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs.map +1 -0
  143. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs +59 -0
  144. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs.map +1 -0
  145. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs +3 -2
  146. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs.map +1 -1
  147. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs +319 -139
  148. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs.map +1 -1
  149. package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs +18 -0
  150. package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs.map +1 -0
  151. package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs +145 -0
  152. package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs.map +1 -0
  153. package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs +19 -0
  154. package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs.map +1 -0
  155. package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs +693 -0
  156. package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs.map +1 -0
  157. package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs +55 -0
  158. package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs.map +1 -0
  159. package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs +155 -0
  160. package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs.map +1 -0
  161. package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs +345 -0
  162. package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs.map +1 -0
  163. package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs +74 -0
  164. package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs.map +1 -0
  165. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs +3 -2
  166. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs.map +1 -1
  167. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs +473 -44
  168. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs.map +1 -1
  169. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs +3 -2
  170. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs.map +1 -1
  171. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs +180 -98
  172. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs.map +1 -1
  173. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs +3 -2
  174. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs.map +1 -1
  175. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs +29 -12
  176. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs.map +1 -1
  177. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs +3 -2
  178. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs.map +1 -1
  179. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs +175 -62
  180. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs.map +1 -1
  181. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs +3 -2
  182. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs.map +1 -1
  183. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs +14 -8
  184. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs.map +1 -1
  185. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs +7 -0
  186. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs.map +1 -0
  187. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs +1034 -0
  188. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs.map +1 -0
  189. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs +3 -2
  190. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs.map +1 -1
  191. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs +276 -1004
  192. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs.map +1 -1
  193. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs +3 -2
  194. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs.map +1 -1
  195. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs +346 -122
  196. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs.map +1 -1
  197. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs +3 -2
  198. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs.map +1 -1
  199. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs +143 -64
  200. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs.map +1 -1
  201. package/es/packages/components/touchchat/src/index.vue.mjs +3 -2
  202. package/es/packages/components/touchchat/src/index.vue.mjs.map +1 -1
  203. package/es/packages/components/touchchat/src/index.vue2.mjs +252 -143
  204. package/es/packages/components/touchchat/src/index.vue2.mjs.map +1 -1
  205. package/es/packages/components/touchchat/src/types/a2a.mjs +11 -0
  206. package/es/packages/components/touchchat/src/types/a2a.mjs.map +1 -0
  207. package/es/packages/components/touchchat/utils/a2aService.mjs +316 -0
  208. package/es/packages/components/touchchat/utils/a2aService.mjs.map +1 -0
  209. package/es/packages/components/touchchat/utils/fetchStream.mjs +8 -2
  210. package/es/packages/components/touchchat/utils/fetchStream.mjs.map +1 -1
  211. package/es/packages/components/touchchat/utils/markdown.mjs +31 -13
  212. package/es/packages/components/touchchat/utils/markdown.mjs.map +1 -1
  213. package/es/packages/utils/config.mjs.map +1 -1
  214. package/es/packages/utils/types.mjs.map +1 -1
  215. package/global.d.ts +2 -2
  216. package/lib/_virtual/_plugin-vue_export-helper.js +14 -0
  217. package/lib/_virtual/_plugin-vue_export-helper.js.map +1 -0
  218. package/lib/index.js.map +1 -1
  219. package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js +4819 -0
  220. package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js.map +1 -0
  221. package/lib/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.js +1540 -0
  222. package/lib/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.js.map +1 -0
  223. package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js +7828 -0
  224. package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js.map +1 -0
  225. package/lib/package.json.css +1 -1
  226. package/lib/package.json.js +2 -2
  227. package/lib/packages/components/index.js +2 -2
  228. package/lib/packages/components/resolver.js.map +1 -1
  229. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js +3 -2
  230. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js.map +1 -1
  231. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js +219 -159
  232. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js.map +1 -1
  233. package/lib/packages/components/touchchat/component/AiRobot/face.vue.js +3 -2
  234. package/lib/packages/components/touchchat/component/AiRobot/face.vue.js.map +1 -1
  235. package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js +26 -12
  236. package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js.map +1 -1
  237. package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js +3 -2
  238. package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js.map +1 -1
  239. package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js +181 -40
  240. package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js.map +1 -1
  241. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js +3 -2
  242. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js.map +1 -1
  243. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js +15 -10
  244. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js.map +1 -1
  245. package/lib/packages/components/touchchat/component/AiRobot/start.vue.js +3 -2
  246. package/lib/packages/components/touchchat/component/AiRobot/start.vue.js.map +1 -1
  247. package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js +17 -10
  248. package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js.map +1 -1
  249. package/lib/packages/components/touchchat/component/CardView.vue.js +3 -2
  250. package/lib/packages/components/touchchat/component/CardView.vue.js.map +1 -1
  251. package/lib/packages/components/touchchat/component/CardView.vue2.js +66 -42
  252. package/lib/packages/components/touchchat/component/CardView.vue2.js.map +1 -1
  253. package/lib/packages/components/touchchat/component/FileContent.vue.js +11 -0
  254. package/lib/packages/components/touchchat/component/FileContent.vue.js.map +1 -0
  255. package/lib/packages/components/touchchat/component/FileContent.vue2.js +210 -0
  256. package/lib/packages/components/touchchat/component/FileContent.vue2.js.map +1 -0
  257. package/lib/packages/components/touchchat/component/FileView.vue.js +3 -2
  258. package/lib/packages/components/touchchat/component/FileView.vue.js.map +1 -1
  259. package/lib/packages/components/touchchat/component/FileView.vue2.js +16 -3
  260. package/lib/packages/components/touchchat/component/FileView.vue2.js.map +1 -1
  261. package/lib/packages/components/touchchat/component/HelloChat.vue.js +3 -2
  262. package/lib/packages/components/touchchat/component/HelloChat.vue.js.map +1 -1
  263. package/lib/packages/components/touchchat/component/HelloChat.vue2.js +26 -14
  264. package/lib/packages/components/touchchat/component/HelloChat.vue2.js.map +1 -1
  265. package/lib/packages/components/touchchat/component/ImageFile.vue.js +11 -0
  266. package/lib/packages/components/touchchat/component/ImageFile.vue.js.map +1 -0
  267. package/lib/packages/components/touchchat/component/ImageFile.vue2.js +166 -0
  268. package/lib/packages/components/touchchat/component/ImageFile.vue2.js.map +1 -0
  269. package/lib/packages/components/touchchat/component/ImageView.vue.js +3 -2
  270. package/lib/packages/components/touchchat/component/ImageView.vue.js.map +1 -1
  271. package/lib/packages/components/touchchat/component/ImageView.vue2.js +1 -1
  272. package/lib/packages/components/touchchat/component/ImageView.vue2.js.map +1 -1
  273. package/lib/packages/components/touchchat/component/LinkView.vue.js +3 -2
  274. package/lib/packages/components/touchchat/component/LinkView.vue.js.map +1 -1
  275. package/lib/packages/components/touchchat/component/LinkView.vue2.js +18 -4
  276. package/lib/packages/components/touchchat/component/LinkView.vue2.js.map +1 -1
  277. package/lib/packages/components/touchchat/component/MarkLayer.vue.js +11 -0
  278. package/lib/packages/components/touchchat/component/MarkLayer.vue.js.map +1 -0
  279. package/lib/packages/components/touchchat/component/MarkLayer.vue2.js +60 -0
  280. package/lib/packages/components/touchchat/component/MarkLayer.vue2.js.map +1 -0
  281. package/lib/packages/components/touchchat/component/ModuleSelect.vue.js +11 -0
  282. package/lib/packages/components/touchchat/component/ModuleSelect.vue.js.map +1 -0
  283. package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js +125 -0
  284. package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js.map +1 -0
  285. package/lib/packages/components/touchchat/component/PDFFile.vue.js +11 -0
  286. package/lib/packages/components/touchchat/component/PDFFile.vue.js.map +1 -0
  287. package/lib/packages/components/touchchat/component/PDFFile.vue2.js +215 -0
  288. package/lib/packages/components/touchchat/component/PDFFile.vue2.js.map +1 -0
  289. package/lib/packages/components/touchchat/component/QuoteContent.vue.js +11 -0
  290. package/lib/packages/components/touchchat/component/QuoteContent.vue.js.map +1 -0
  291. package/lib/packages/components/touchchat/component/QuoteContent.vue2.js +44 -0
  292. package/lib/packages/components/touchchat/component/QuoteContent.vue2.js.map +1 -0
  293. package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js +11 -0
  294. package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js.map +1 -0
  295. package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js +164 -0
  296. package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js.map +1 -0
  297. package/lib/packages/components/touchchat/component/Screenshot.vue.js +11 -0
  298. package/lib/packages/components/touchchat/component/Screenshot.vue.js.map +1 -0
  299. package/lib/packages/components/touchchat/component/Screenshot.vue2.js +212 -0
  300. package/lib/packages/components/touchchat/component/Screenshot.vue2.js.map +1 -0
  301. package/lib/packages/components/touchchat/component/ThoughtChain.vue.js +11 -0
  302. package/lib/packages/components/touchchat/component/ThoughtChain.vue.js.map +1 -0
  303. package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js +73 -0
  304. package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js.map +1 -0
  305. package/lib/packages/components/touchchat/component/UploadView.vue.js +11 -0
  306. package/lib/packages/components/touchchat/component/UploadView.vue.js.map +1 -0
  307. package/lib/packages/components/touchchat/component/UploadView.vue2.js +190 -0
  308. package/lib/packages/components/touchchat/component/UploadView.vue2.js.map +1 -0
  309. package/lib/packages/components/touchchat/component/UploadView_api.vue.js +11 -0
  310. package/lib/packages/components/touchchat/component/UploadView_api.vue.js.map +1 -0
  311. package/lib/packages/components/touchchat/component/UploadView_api.vue2.js +170 -0
  312. package/lib/packages/components/touchchat/component/UploadView_api.vue2.js.map +1 -0
  313. package/lib/packages/components/touchchat/component/VideoFile.vue.js +11 -0
  314. package/lib/packages/components/touchchat/component/VideoFile.vue.js.map +1 -0
  315. package/lib/packages/components/touchchat/component/VideoFile.vue2.js +37 -0
  316. package/lib/packages/components/touchchat/component/VideoFile.vue2.js.map +1 -0
  317. package/lib/packages/components/touchchat/component/VoiceView.vue.js +11 -0
  318. package/lib/packages/components/touchchat/component/VoiceView.vue.js.map +1 -0
  319. package/lib/packages/components/touchchat/component/VoiceView.vue2.js +169 -0
  320. package/lib/packages/components/touchchat/component/VoiceView.vue2.js.map +1 -0
  321. package/lib/packages/components/touchchat/img/file/doc.png.js +8 -0
  322. package/lib/packages/components/touchchat/img/file/doc.png.js.map +1 -0
  323. package/lib/packages/components/touchchat/img/file/docx.png.js +8 -0
  324. package/lib/packages/components/touchchat/img/file/docx.png.js.map +1 -0
  325. package/lib/packages/components/touchchat/img/file/gif.png.js +8 -0
  326. package/lib/packages/components/touchchat/img/file/gif.png.js.map +1 -0
  327. package/lib/packages/components/touchchat/img/file/html.png.js +8 -0
  328. package/lib/packages/components/touchchat/img/file/html.png.js.map +1 -0
  329. package/lib/packages/components/touchchat/img/file/jpg.png.js +8 -0
  330. package/lib/packages/components/touchchat/img/file/jpg.png.js.map +1 -0
  331. package/lib/packages/components/touchchat/img/file/mp3.png.js +8 -0
  332. package/lib/packages/components/touchchat/img/file/mp3.png.js.map +1 -0
  333. package/lib/packages/components/touchchat/img/file/mp4.png.js +8 -0
  334. package/lib/packages/components/touchchat/img/file/mp4.png.js.map +1 -0
  335. package/lib/packages/components/touchchat/img/file/music.png.js +8 -0
  336. package/lib/packages/components/touchchat/img/file/music.png.js.map +1 -0
  337. package/lib/packages/components/touchchat/img/file/pdf.png.js +8 -0
  338. package/lib/packages/components/touchchat/img/file/pdf.png.js.map +1 -0
  339. package/lib/packages/components/touchchat/img/file/png.png.js +8 -0
  340. package/lib/packages/components/touchchat/img/file/png.png.js.map +1 -0
  341. package/lib/packages/components/touchchat/img/file/ppt.png.js +8 -0
  342. package/lib/packages/components/touchchat/img/file/ppt.png.js.map +1 -0
  343. package/lib/packages/components/touchchat/img/file/pptx.png.js +8 -0
  344. package/lib/packages/components/touchchat/img/file/pptx.png.js.map +1 -0
  345. package/lib/packages/components/touchchat/img/file/txt.png.js +8 -0
  346. package/lib/packages/components/touchchat/img/file/txt.png.js.map +1 -0
  347. package/lib/packages/components/touchchat/img/file/xls.png.js +8 -0
  348. package/lib/packages/components/touchchat/img/file/xls.png.js.map +1 -0
  349. package/lib/packages/components/touchchat/img/file/xlsx.png.js +8 -0
  350. package/lib/packages/components/touchchat/img/file/xlsx.png.js.map +1 -0
  351. package/lib/packages/components/touchchat/img/svg/reset.svg.js +8 -0
  352. package/lib/packages/components/touchchat/img/svg/reset.svg.js.map +1 -0
  353. package/lib/packages/components/touchchat/index.js +6 -6
  354. package/lib/packages/components/touchchat/index.js.map +1 -1
  355. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js +11 -0
  356. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js.map +1 -0
  357. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js +63 -0
  358. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js.map +1 -0
  359. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js +3 -2
  360. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js.map +1 -1
  361. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js +318 -138
  362. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js.map +1 -1
  363. package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js +21 -0
  364. package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js.map +1 -0
  365. package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js +147 -0
  366. package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js.map +1 -0
  367. package/lib/packages/components/touchchat/src/AiChat/Chat/types.js +22 -0
  368. package/lib/packages/components/touchchat/src/AiChat/Chat/types.js.map +1 -0
  369. package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js +695 -0
  370. package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js.map +1 -0
  371. package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js +57 -0
  372. package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js.map +1 -0
  373. package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js +157 -0
  374. package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js.map +1 -0
  375. package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js +347 -0
  376. package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js.map +1 -0
  377. package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js +76 -0
  378. package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js.map +1 -0
  379. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js +3 -2
  380. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js.map +1 -1
  381. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js +472 -43
  382. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js.map +1 -1
  383. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js +3 -2
  384. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js.map +1 -1
  385. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js +179 -97
  386. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js.map +1 -1
  387. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js +3 -2
  388. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js.map +1 -1
  389. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js +28 -11
  390. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js.map +1 -1
  391. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js +3 -2
  392. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js.map +1 -1
  393. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js +174 -61
  394. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js.map +1 -1
  395. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js +3 -2
  396. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js.map +1 -1
  397. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js +14 -8
  398. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js.map +1 -1
  399. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js +11 -0
  400. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js.map +1 -0
  401. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js +1038 -0
  402. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js.map +1 -0
  403. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js +3 -2
  404. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js.map +1 -1
  405. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js +275 -1003
  406. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js.map +1 -1
  407. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js +3 -2
  408. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js.map +1 -1
  409. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js +345 -121
  410. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js.map +1 -1
  411. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js +3 -2
  412. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js.map +1 -1
  413. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js +142 -63
  414. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js.map +1 -1
  415. package/lib/packages/components/touchchat/src/index.vue.js +3 -2
  416. package/lib/packages/components/touchchat/src/index.vue.js.map +1 -1
  417. package/lib/packages/components/touchchat/src/index.vue2.js +251 -142
  418. package/lib/packages/components/touchchat/src/index.vue2.js.map +1 -1
  419. package/lib/packages/components/touchchat/src/types/a2a.js +13 -0
  420. package/lib/packages/components/touchchat/src/types/a2a.js.map +1 -0
  421. package/lib/packages/components/touchchat/utils/a2aService.js +319 -0
  422. package/lib/packages/components/touchchat/utils/a2aService.js.map +1 -0
  423. package/lib/packages/components/touchchat/utils/fetchStream.js +8 -2
  424. package/lib/packages/components/touchchat/utils/fetchStream.js.map +1 -1
  425. package/lib/packages/components/touchchat/utils/markdown.js +31 -13
  426. package/lib/packages/components/touchchat/utils/markdown.js.map +1 -1
  427. package/lib/packages/utils/config.js.map +1 -1
  428. package/lib/packages/utils/types.js.map +1 -1
  429. package/package.json +83 -83
  430. package/theme/components/index.css +969 -43
  431. package/theme/font/iconfont.woff +0 -0
  432. package/theme/font/iconfont.woff2 +0 -0
  433. package/theme/index.css +969 -43
  434. package/theme/skin/default.css +969 -43
  435. package/types/global.d.ts +2 -2
  436. package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs +0 -6
  437. package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs.map +0 -1
  438. package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs +0 -42
  439. package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs.map +0 -1
  440. package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js +0 -10
  441. package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js.map +0 -1
  442. package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js +0 -46
  443. package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js.map +0 -1
@@ -0,0 +1,1540 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /*! @license DOMPurify 3.4.3 | (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.3/LICENSE */
6
+
7
+ function _arrayLikeToArray(r, a) {
8
+ (null == a || a > r.length) && (a = r.length);
9
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
+ return n;
11
+ }
12
+ function _arrayWithHoles(r) {
13
+ if (Array.isArray(r)) return r;
14
+ }
15
+ function _iterableToArrayLimit(r, l) {
16
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
17
+ if (null != t) {
18
+ var e,
19
+ n,
20
+ i,
21
+ u,
22
+ a = [],
23
+ f = true,
24
+ o = false;
25
+ try {
26
+ 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 = !0);
27
+ } catch (r) {
28
+ o = true, n = r;
29
+ } finally {
30
+ try {
31
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
32
+ } finally {
33
+ if (o) throw n;
34
+ }
35
+ }
36
+ return a;
37
+ }
38
+ }
39
+ function _nonIterableRest() {
40
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ function _slicedToArray(r, e) {
43
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
44
+ }
45
+ function _unsupportedIterableToArray(r, a) {
46
+ if (r) {
47
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
48
+ var t = {}.toString.call(r).slice(8, -1);
49
+ 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;
50
+ }
51
+ }
52
+
53
+ const entries = Object.entries,
54
+ setPrototypeOf = Object.setPrototypeOf,
55
+ isFrozen = Object.isFrozen,
56
+ getPrototypeOf = Object.getPrototypeOf,
57
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
58
+ let freeze = Object.freeze,
59
+ seal = Object.seal,
60
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
61
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
62
+ apply = _ref.apply,
63
+ construct = _ref.construct;
64
+ if (!freeze) {
65
+ freeze = function freeze(x) {
66
+ return x;
67
+ };
68
+ }
69
+ if (!seal) {
70
+ seal = function seal(x) {
71
+ return x;
72
+ };
73
+ }
74
+ if (!apply) {
75
+ apply = function apply(func, thisArg) {
76
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
77
+ args[_key - 2] = arguments[_key];
78
+ }
79
+ return func.apply(thisArg, args);
80
+ };
81
+ }
82
+ if (!construct) {
83
+ construct = function construct(Func) {
84
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
85
+ args[_key2 - 1] = arguments[_key2];
86
+ }
87
+ return new Func(...args);
88
+ };
89
+ }
90
+ const arrayForEach = unapply(Array.prototype.forEach);
91
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
92
+ const arrayPop = unapply(Array.prototype.pop);
93
+ const arrayPush = unapply(Array.prototype.push);
94
+ const arraySplice = unapply(Array.prototype.splice);
95
+ const arrayIsArray = Array.isArray;
96
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
97
+ const stringToString = unapply(String.prototype.toString);
98
+ const stringMatch = unapply(String.prototype.match);
99
+ const stringReplace = unapply(String.prototype.replace);
100
+ const stringIndexOf = unapply(String.prototype.indexOf);
101
+ const stringTrim = unapply(String.prototype.trim);
102
+ const numberToString = unapply(Number.prototype.toString);
103
+ const booleanToString = unapply(Boolean.prototype.toString);
104
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
105
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
106
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
107
+ const objectToString = unapply(Object.prototype.toString);
108
+ const regExpTest = unapply(RegExp.prototype.test);
109
+ const typeErrorCreate = unconstruct(TypeError);
110
+ /**
111
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
112
+ *
113
+ * @param func - The function to be wrapped and called.
114
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
115
+ */
116
+ function unapply(func) {
117
+ return function (thisArg) {
118
+ if (thisArg instanceof RegExp) {
119
+ thisArg.lastIndex = 0;
120
+ }
121
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
122
+ args[_key3 - 1] = arguments[_key3];
123
+ }
124
+ return apply(func, thisArg, args);
125
+ };
126
+ }
127
+ /**
128
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
129
+ *
130
+ * @param func - The constructor function to be wrapped and called.
131
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
132
+ */
133
+ function unconstruct(Func) {
134
+ return function () {
135
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
136
+ args[_key4] = arguments[_key4];
137
+ }
138
+ return construct(Func, args);
139
+ };
140
+ }
141
+ /**
142
+ * Add properties to a lookup table
143
+ *
144
+ * @param set - The set to which elements will be added.
145
+ * @param array - The array containing elements to be added to the set.
146
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
147
+ * @returns The modified set with added elements.
148
+ */
149
+ function addToSet(set, array) {
150
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
151
+ if (setPrototypeOf) {
152
+ // Make 'in' and truthy checks like Boolean(set.constructor)
153
+ // independent of any properties defined on Object.prototype.
154
+ // Prevent prototype setters from intercepting set as a this value.
155
+ setPrototypeOf(set, null);
156
+ }
157
+ if (!arrayIsArray(array)) {
158
+ return set;
159
+ }
160
+ let l = array.length;
161
+ while (l--) {
162
+ let element = array[l];
163
+ if (typeof element === 'string') {
164
+ const lcElement = transformCaseFunc(element);
165
+ if (lcElement !== element) {
166
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
167
+ if (!isFrozen(array)) {
168
+ array[l] = lcElement;
169
+ }
170
+ element = lcElement;
171
+ }
172
+ }
173
+ set[element] = true;
174
+ }
175
+ return set;
176
+ }
177
+ /**
178
+ * Clean up an array to harden against CSPP
179
+ *
180
+ * @param array - The array to be cleaned.
181
+ * @returns The cleaned version of the array
182
+ */
183
+ function cleanArray(array) {
184
+ for (let index = 0; index < array.length; index++) {
185
+ const isPropertyExist = objectHasOwnProperty(array, index);
186
+ if (!isPropertyExist) {
187
+ array[index] = null;
188
+ }
189
+ }
190
+ return array;
191
+ }
192
+ /**
193
+ * Shallow clone an object
194
+ *
195
+ * @param object - The object to be cloned.
196
+ * @returns A new object that copies the original.
197
+ */
198
+ function clone(object) {
199
+ const newObject = create(null);
200
+ for (const _ref2 of entries(object)) {
201
+ var _ref3 = _slicedToArray(_ref2, 2);
202
+ const property = _ref3[0];
203
+ const value = _ref3[1];
204
+ const isPropertyExist = objectHasOwnProperty(object, property);
205
+ if (isPropertyExist) {
206
+ if (arrayIsArray(value)) {
207
+ newObject[property] = cleanArray(value);
208
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
209
+ newObject[property] = clone(value);
210
+ } else {
211
+ newObject[property] = value;
212
+ }
213
+ }
214
+ }
215
+ return newObject;
216
+ }
217
+ /**
218
+ * Convert non-node values into strings without depending on direct property access.
219
+ *
220
+ * @param value - The value to stringify.
221
+ * @returns A string representation of the provided value.
222
+ */
223
+ function stringifyValue(value) {
224
+ switch (typeof value) {
225
+ case 'string':
226
+ {
227
+ return value;
228
+ }
229
+ case 'number':
230
+ {
231
+ return numberToString(value);
232
+ }
233
+ case 'boolean':
234
+ {
235
+ return booleanToString(value);
236
+ }
237
+ case 'bigint':
238
+ {
239
+ return bigintToString ? bigintToString(value) : '0';
240
+ }
241
+ case 'symbol':
242
+ {
243
+ return symbolToString ? symbolToString(value) : 'Symbol()';
244
+ }
245
+ case 'undefined':
246
+ {
247
+ return objectToString(value);
248
+ }
249
+ case 'function':
250
+ case 'object':
251
+ {
252
+ if (value === null) {
253
+ return objectToString(value);
254
+ }
255
+ const valueAsRecord = value;
256
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
257
+ if (typeof valueToString === 'function') {
258
+ const stringified = valueToString(valueAsRecord);
259
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
260
+ }
261
+ return objectToString(value);
262
+ }
263
+ default:
264
+ {
265
+ return objectToString(value);
266
+ }
267
+ }
268
+ }
269
+ /**
270
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
271
+ *
272
+ * @param object - The object to look up the getter function in its prototype chain.
273
+ * @param prop - The property name for which to find the getter function.
274
+ * @returns The getter function found in the prototype chain or a fallback function.
275
+ */
276
+ function lookupGetter(object, prop) {
277
+ while (object !== null) {
278
+ const desc = getOwnPropertyDescriptor(object, prop);
279
+ if (desc) {
280
+ if (desc.get) {
281
+ return unapply(desc.get);
282
+ }
283
+ if (typeof desc.value === 'function') {
284
+ return unapply(desc.value);
285
+ }
286
+ }
287
+ object = getPrototypeOf(object);
288
+ }
289
+ function fallbackValue() {
290
+ return null;
291
+ }
292
+ return fallbackValue;
293
+ }
294
+ function isRegex(value) {
295
+ try {
296
+ regExpTest(value, '');
297
+ return true;
298
+ } catch (_unused) {
299
+ return false;
300
+ }
301
+ }
302
+
303
+ 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']);
304
+ 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']);
305
+ 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']);
306
+ // List of SVG elements that are disallowed by default.
307
+ // We still need to know them so that we can do namespace
308
+ // checks properly in case one wants to add them to
309
+ // allow-list.
310
+ 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']);
311
+ 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']);
312
+ // Similarly to SVG, we want to know all MathML elements,
313
+ // even those that we disallow by default.
314
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
315
+ const text = freeze(['#text']);
316
+
317
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', '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']);
318
+ 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']);
319
+ 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']);
320
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
321
+
322
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
323
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
324
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
325
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
326
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
327
+ 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
328
+ );
329
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
330
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
331
+ );
332
+ const DOCTYPE_NAME = seal(/^html$/i);
333
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
334
+
335
+ /* eslint-disable @typescript-eslint/indent */
336
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
337
+ const NODE_TYPE = {
338
+ element: 1,
339
+ text: 3,
340
+ // Deprecated
341
+ progressingInstruction: 7,
342
+ comment: 8,
343
+ document: 9};
344
+ const getGlobal = function getGlobal() {
345
+ return typeof window === 'undefined' ? null : window;
346
+ };
347
+ /**
348
+ * Creates a no-op policy for internal use only.
349
+ * Don't export this function outside this module!
350
+ * @param trustedTypes The policy factory.
351
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
352
+ * @return The policy created (or null, if Trusted Types
353
+ * are not supported or creating the policy failed).
354
+ */
355
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
356
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
357
+ return null;
358
+ }
359
+ // Allow the callers to control the unique policy name
360
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
361
+ // Policy creation with duplicate names throws in Trusted Types.
362
+ let suffix = null;
363
+ const ATTR_NAME = 'data-tt-policy-suffix';
364
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
365
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
366
+ }
367
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
368
+ try {
369
+ return trustedTypes.createPolicy(policyName, {
370
+ createHTML(html) {
371
+ return html;
372
+ },
373
+ createScriptURL(scriptUrl) {
374
+ return scriptUrl;
375
+ }
376
+ });
377
+ } catch (_) {
378
+ // Policy creation failed (most likely another DOMPurify script has
379
+ // already run). Skip creating the policy, as this will only cause errors
380
+ // if TT are enforced.
381
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
382
+ return null;
383
+ }
384
+ };
385
+ const _createHooksMap = function _createHooksMap() {
386
+ return {
387
+ afterSanitizeAttributes: [],
388
+ afterSanitizeElements: [],
389
+ afterSanitizeShadowDOM: [],
390
+ beforeSanitizeAttributes: [],
391
+ beforeSanitizeElements: [],
392
+ beforeSanitizeShadowDOM: [],
393
+ uponSanitizeAttribute: [],
394
+ uponSanitizeElement: [],
395
+ uponSanitizeShadowNode: []
396
+ };
397
+ };
398
+ function createDOMPurify() {
399
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
400
+ const DOMPurify = root => createDOMPurify(root);
401
+ DOMPurify.version = '3.4.3';
402
+ DOMPurify.removed = [];
403
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
404
+ // Not running in a browser, provide a factory function
405
+ // so that you can pass your own Window
406
+ DOMPurify.isSupported = false;
407
+ return DOMPurify;
408
+ }
409
+ let document = window.document;
410
+ const originalDocument = document;
411
+ const currentScript = originalDocument.currentScript;
412
+ const DocumentFragment = window.DocumentFragment,
413
+ HTMLTemplateElement = window.HTMLTemplateElement,
414
+ Node = window.Node,
415
+ Element = window.Element,
416
+ NodeFilter = window.NodeFilter,
417
+ _window$NamedNodeMap = window.NamedNodeMap,
418
+ NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
419
+ HTMLFormElement = window.HTMLFormElement,
420
+ DOMParser = window.DOMParser,
421
+ trustedTypes = window.trustedTypes;
422
+ const ElementPrototype = Element.prototype;
423
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
424
+ const remove = lookupGetter(ElementPrototype, 'remove');
425
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
426
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
427
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
428
+ // As per issue #47, the web-components registry is inherited by a
429
+ // new document created via createHTMLDocument. As per the spec
430
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
431
+ // a new empty registry is used when creating a template contents owner
432
+ // document, so we use that as our parent document to ensure nothing
433
+ // is inherited.
434
+ if (typeof HTMLTemplateElement === 'function') {
435
+ const template = document.createElement('template');
436
+ if (template.content && template.content.ownerDocument) {
437
+ document = template.content.ownerDocument;
438
+ }
439
+ }
440
+ let trustedTypesPolicy;
441
+ let emptyHTML = '';
442
+ const _document = document,
443
+ implementation = _document.implementation,
444
+ createNodeIterator = _document.createNodeIterator,
445
+ createDocumentFragment = _document.createDocumentFragment,
446
+ getElementsByTagName = _document.getElementsByTagName;
447
+ const importNode = originalDocument.importNode;
448
+ let hooks = _createHooksMap();
449
+ /**
450
+ * Expose whether this browser supports running the full DOMPurify.
451
+ */
452
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
453
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
454
+ ERB_EXPR$1 = ERB_EXPR,
455
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
456
+ DATA_ATTR$1 = DATA_ATTR,
457
+ ARIA_ATTR$1 = ARIA_ATTR,
458
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
459
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
460
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
461
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
462
+ /**
463
+ * We consider the elements and attributes below to be safe. Ideally
464
+ * don't add any new ones but feel free to remove unwanted ones.
465
+ */
466
+ /* allowed element names */
467
+ let ALLOWED_TAGS = null;
468
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
469
+ /* Allowed attribute names */
470
+ let ALLOWED_ATTR = null;
471
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
472
+ /*
473
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
474
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
475
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
476
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
477
+ */
478
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
479
+ tagNameCheck: {
480
+ writable: true,
481
+ configurable: false,
482
+ enumerable: true,
483
+ value: null
484
+ },
485
+ attributeNameCheck: {
486
+ writable: true,
487
+ configurable: false,
488
+ enumerable: true,
489
+ value: null
490
+ },
491
+ allowCustomizedBuiltInElements: {
492
+ writable: true,
493
+ configurable: false,
494
+ enumerable: true,
495
+ value: false
496
+ }
497
+ }));
498
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
499
+ let FORBID_TAGS = null;
500
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
501
+ let FORBID_ATTR = null;
502
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
503
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
504
+ tagCheck: {
505
+ writable: true,
506
+ configurable: false,
507
+ enumerable: true,
508
+ value: null
509
+ },
510
+ attributeCheck: {
511
+ writable: true,
512
+ configurable: false,
513
+ enumerable: true,
514
+ value: null
515
+ }
516
+ }));
517
+ /* Decide if ARIA attributes are okay */
518
+ let ALLOW_ARIA_ATTR = true;
519
+ /* Decide if custom data attributes are okay */
520
+ let ALLOW_DATA_ATTR = true;
521
+ /* Decide if unknown protocols are okay */
522
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
523
+ /* Decide if self-closing tags in attributes are allowed.
524
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
525
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
526
+ /* Output should be safe for common template engines.
527
+ * This means, DOMPurify removes data attributes, mustaches and ERB
528
+ */
529
+ let SAFE_FOR_TEMPLATES = false;
530
+ /* Output should be safe even for XML used within HTML and alike.
531
+ * This means, DOMPurify removes comments when containing risky content.
532
+ */
533
+ let SAFE_FOR_XML = true;
534
+ /* Decide if document with <html>... should be returned */
535
+ let WHOLE_DOCUMENT = false;
536
+ /* Track whether config is already set on this instance of DOMPurify. */
537
+ let SET_CONFIG = false;
538
+ /* Decide if all elements (e.g. style, script) must be children of
539
+ * document.body. By default, browsers might move them to document.head */
540
+ let FORCE_BODY = false;
541
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
542
+ * string (or a TrustedHTML object if Trusted Types are supported).
543
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
544
+ */
545
+ let RETURN_DOM = false;
546
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
547
+ * string (or a TrustedHTML object if Trusted Types are supported) */
548
+ let RETURN_DOM_FRAGMENT = false;
549
+ /* Try to return a Trusted Type object instead of a string, return a string in
550
+ * case Trusted Types are not supported */
551
+ let RETURN_TRUSTED_TYPE = false;
552
+ /* Output should be free from DOM clobbering attacks?
553
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
554
+ */
555
+ let SANITIZE_DOM = true;
556
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
557
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
558
+ *
559
+ * HTML/DOM spec rules that enable DOM Clobbering:
560
+ * - Named Access on Window (§7.3.3)
561
+ * - DOM Tree Accessors (§3.1.5)
562
+ * - Form Element Parent-Child Relations (§4.10.3)
563
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
564
+ * - HTMLCollection (§4.2.10.2)
565
+ *
566
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
567
+ * with a constant string, i.e., `user-content-`
568
+ */
569
+ let SANITIZE_NAMED_PROPS = false;
570
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
571
+ /* Keep element content when removing element? */
572
+ let KEEP_CONTENT = true;
573
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
574
+ * of importing it into a new Document and returning a sanitized copy */
575
+ let IN_PLACE = false;
576
+ /* Allow usage of profiles like html, svg and mathMl */
577
+ let USE_PROFILES = {};
578
+ /* Tags to ignore content of when KEEP_CONTENT is true */
579
+ let FORBID_CONTENTS = null;
580
+ 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']);
581
+ /* Tags that are safe for data: URIs */
582
+ let DATA_URI_TAGS = null;
583
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
584
+ /* Attributes safe for values like "javascript:" */
585
+ let URI_SAFE_ATTRIBUTES = null;
586
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
587
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
588
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
589
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
590
+ /* Document namespace */
591
+ let NAMESPACE = HTML_NAMESPACE;
592
+ let IS_EMPTY_INPUT = false;
593
+ /* Allowed XHTML+XML namespaces */
594
+ let ALLOWED_NAMESPACES = null;
595
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
596
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
597
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
598
+ // Certain elements are allowed in both SVG and HTML
599
+ // namespace. We need to specify them explicitly
600
+ // so that they don't get erroneously deleted from
601
+ // HTML namespace.
602
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
603
+ /* Parsing of strict XHTML documents */
604
+ let PARSER_MEDIA_TYPE = null;
605
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
606
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
607
+ let transformCaseFunc = null;
608
+ /* Keep a reference to config to pass to hooks */
609
+ let CONFIG = null;
610
+ /* Ideally, do not touch anything below this line */
611
+ /* ______________________________________________ */
612
+ const formElement = document.createElement('form');
613
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
614
+ return testValue instanceof RegExp || testValue instanceof Function;
615
+ };
616
+ /**
617
+ * _parseConfig
618
+ *
619
+ * @param cfg optional config literal
620
+ */
621
+ // eslint-disable-next-line complexity
622
+ const _parseConfig = function _parseConfig() {
623
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
624
+ if (CONFIG && CONFIG === cfg) {
625
+ return;
626
+ }
627
+ /* Shield configuration object from tampering */
628
+ if (!cfg || typeof cfg !== 'object') {
629
+ cfg = {};
630
+ }
631
+ /* Shield configuration object from prototype pollution */
632
+ cfg = clone(cfg);
633
+ PARSER_MEDIA_TYPE =
634
+ // eslint-disable-next-line unicorn/prefer-includes
635
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
636
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
637
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
638
+ /* Set configuration parameters */
639
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
640
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
641
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
642
+ 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;
643
+ 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;
644
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
645
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
646
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
647
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
648
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
649
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
650
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
651
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
652
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
653
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
654
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
655
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
656
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
657
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
658
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
659
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
660
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
661
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
662
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
663
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
664
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
665
+ 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
666
+ 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
667
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
668
+ CUSTOM_ELEMENT_HANDLING = create(null);
669
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
670
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
671
+ }
672
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
673
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
674
+ }
675
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
676
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
677
+ }
678
+ if (SAFE_FOR_TEMPLATES) {
679
+ ALLOW_DATA_ATTR = false;
680
+ }
681
+ if (RETURN_DOM_FRAGMENT) {
682
+ RETURN_DOM = true;
683
+ }
684
+ /* Parse profile info */
685
+ if (USE_PROFILES) {
686
+ ALLOWED_TAGS = addToSet({}, text);
687
+ ALLOWED_ATTR = create(null);
688
+ if (USE_PROFILES.html === true) {
689
+ addToSet(ALLOWED_TAGS, html$1);
690
+ addToSet(ALLOWED_ATTR, html);
691
+ }
692
+ if (USE_PROFILES.svg === true) {
693
+ addToSet(ALLOWED_TAGS, svg$1);
694
+ addToSet(ALLOWED_ATTR, svg);
695
+ addToSet(ALLOWED_ATTR, xml);
696
+ }
697
+ if (USE_PROFILES.svgFilters === true) {
698
+ addToSet(ALLOWED_TAGS, svgFilters);
699
+ addToSet(ALLOWED_ATTR, svg);
700
+ addToSet(ALLOWED_ATTR, xml);
701
+ }
702
+ if (USE_PROFILES.mathMl === true) {
703
+ addToSet(ALLOWED_TAGS, mathMl$1);
704
+ addToSet(ALLOWED_ATTR, mathMl);
705
+ addToSet(ALLOWED_ATTR, xml);
706
+ }
707
+ }
708
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
709
+ * leaking across calls when switching from function to array config */
710
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
711
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
712
+ /* Merge configuration parameters */
713
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
714
+ if (typeof cfg.ADD_TAGS === 'function') {
715
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
716
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
717
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
718
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
719
+ }
720
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
721
+ }
722
+ }
723
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
724
+ if (typeof cfg.ADD_ATTR === 'function') {
725
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
726
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
727
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
728
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
729
+ }
730
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
731
+ }
732
+ }
733
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
734
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
735
+ }
736
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
737
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
738
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
739
+ }
740
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
741
+ }
742
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
743
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
744
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
745
+ }
746
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
747
+ }
748
+ /* Add #text in case KEEP_CONTENT is set to true */
749
+ if (KEEP_CONTENT) {
750
+ ALLOWED_TAGS['#text'] = true;
751
+ }
752
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
753
+ if (WHOLE_DOCUMENT) {
754
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
755
+ }
756
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
757
+ if (ALLOWED_TAGS.table) {
758
+ addToSet(ALLOWED_TAGS, ['tbody']);
759
+ delete FORBID_TAGS.tbody;
760
+ }
761
+ if (cfg.TRUSTED_TYPES_POLICY) {
762
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
763
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
764
+ }
765
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
766
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
767
+ }
768
+ // Overwrite existing TrustedTypes policy.
769
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
770
+ // Sign local variables required by `sanitize`.
771
+ emptyHTML = trustedTypesPolicy.createHTML('');
772
+ } else {
773
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
774
+ if (trustedTypesPolicy === undefined) {
775
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
776
+ }
777
+ // If creating the internal policy succeeded sign internal variables.
778
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
779
+ emptyHTML = trustedTypesPolicy.createHTML('');
780
+ }
781
+ }
782
+ // Prevent further manipulation of configuration.
783
+ // Not available in IE8, Safari 5, etc.
784
+ if (freeze) {
785
+ freeze(cfg);
786
+ }
787
+ CONFIG = cfg;
788
+ };
789
+ /* Keep track of all possible SVG and MathML tags
790
+ * so that we can perform the namespace checks
791
+ * correctly. */
792
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
793
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
794
+ /**
795
+ * @param element a DOM element whose namespace is being checked
796
+ * @returns Return false if the element has a
797
+ * namespace that a spec-compliant parser would never
798
+ * return. Return true otherwise.
799
+ */
800
+ const _checkValidNamespace = function _checkValidNamespace(element) {
801
+ let parent = getParentNode(element);
802
+ // In JSDOM, if we're inside shadow DOM, then parentNode
803
+ // can be null. We just simulate parent in this case.
804
+ if (!parent || !parent.tagName) {
805
+ parent = {
806
+ namespaceURI: NAMESPACE,
807
+ tagName: 'template'
808
+ };
809
+ }
810
+ const tagName = stringToLowerCase(element.tagName);
811
+ const parentTagName = stringToLowerCase(parent.tagName);
812
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
813
+ return false;
814
+ }
815
+ if (element.namespaceURI === SVG_NAMESPACE) {
816
+ // The only way to switch from HTML namespace to SVG
817
+ // is via <svg>. If it happens via any other tag, then
818
+ // it should be killed.
819
+ if (parent.namespaceURI === HTML_NAMESPACE) {
820
+ return tagName === 'svg';
821
+ }
822
+ // The only way to switch from MathML to SVG is via`
823
+ // svg if parent is either <annotation-xml> or MathML
824
+ // text integration points.
825
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
826
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
827
+ }
828
+ // We only allow elements that are defined in SVG
829
+ // spec. All others are disallowed in SVG namespace.
830
+ return Boolean(ALL_SVG_TAGS[tagName]);
831
+ }
832
+ if (element.namespaceURI === MATHML_NAMESPACE) {
833
+ // The only way to switch from HTML namespace to MathML
834
+ // is via <math>. If it happens via any other tag, then
835
+ // it should be killed.
836
+ if (parent.namespaceURI === HTML_NAMESPACE) {
837
+ return tagName === 'math';
838
+ }
839
+ // The only way to switch from SVG to MathML is via
840
+ // <math> and HTML integration points
841
+ if (parent.namespaceURI === SVG_NAMESPACE) {
842
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
843
+ }
844
+ // We only allow elements that are defined in MathML
845
+ // spec. All others are disallowed in MathML namespace.
846
+ return Boolean(ALL_MATHML_TAGS[tagName]);
847
+ }
848
+ if (element.namespaceURI === HTML_NAMESPACE) {
849
+ // The only way to switch from SVG to HTML is via
850
+ // HTML integration points, and from MathML to HTML
851
+ // is via MathML text integration points
852
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
853
+ return false;
854
+ }
855
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
856
+ return false;
857
+ }
858
+ // We disallow tags that are specific for MathML
859
+ // or SVG and should never appear in HTML namespace
860
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
861
+ }
862
+ // For XHTML and XML documents that support custom namespaces
863
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
864
+ return true;
865
+ }
866
+ // The code should never reach this place (this means
867
+ // that the element somehow got namespace that is not
868
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
869
+ // Return false just in case.
870
+ return false;
871
+ };
872
+ /**
873
+ * _forceRemove
874
+ *
875
+ * @param node a DOM node
876
+ */
877
+ const _forceRemove = function _forceRemove(node) {
878
+ arrayPush(DOMPurify.removed, {
879
+ element: node
880
+ });
881
+ try {
882
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
883
+ getParentNode(node).removeChild(node);
884
+ } catch (_) {
885
+ remove(node);
886
+ }
887
+ };
888
+ /**
889
+ * _removeAttribute
890
+ *
891
+ * @param name an Attribute name
892
+ * @param element a DOM node
893
+ */
894
+ const _removeAttribute = function _removeAttribute(name, element) {
895
+ try {
896
+ arrayPush(DOMPurify.removed, {
897
+ attribute: element.getAttributeNode(name),
898
+ from: element
899
+ });
900
+ } catch (_) {
901
+ arrayPush(DOMPurify.removed, {
902
+ attribute: null,
903
+ from: element
904
+ });
905
+ }
906
+ element.removeAttribute(name);
907
+ // We void attribute values for unremovable "is" attributes
908
+ if (name === 'is') {
909
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
910
+ try {
911
+ _forceRemove(element);
912
+ } catch (_) {}
913
+ } else {
914
+ try {
915
+ element.setAttribute(name, '');
916
+ } catch (_) {}
917
+ }
918
+ }
919
+ };
920
+ /**
921
+ * _initDocument
922
+ *
923
+ * @param dirty - a string of dirty markup
924
+ * @return a DOM, filled with the dirty markup
925
+ */
926
+ const _initDocument = function _initDocument(dirty) {
927
+ /* Create a HTML document */
928
+ let doc = null;
929
+ let leadingWhitespace = null;
930
+ if (FORCE_BODY) {
931
+ dirty = '<remove></remove>' + dirty;
932
+ } else {
933
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
934
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
935
+ leadingWhitespace = matches && matches[0];
936
+ }
937
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
938
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
939
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
940
+ }
941
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
942
+ /*
943
+ * Use the DOMParser API by default, fallback later if needs be
944
+ * DOMParser not work for svg when has multiple root element.
945
+ */
946
+ if (NAMESPACE === HTML_NAMESPACE) {
947
+ try {
948
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
949
+ } catch (_) {}
950
+ }
951
+ /* Use createHTMLDocument in case DOMParser is not available */
952
+ if (!doc || !doc.documentElement) {
953
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
954
+ try {
955
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
956
+ } catch (_) {
957
+ // Syntax error if dirtyPayload is invalid xml
958
+ }
959
+ }
960
+ const body = doc.body || doc.documentElement;
961
+ if (dirty && leadingWhitespace) {
962
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
963
+ }
964
+ /* Work on whole document or just its body */
965
+ if (NAMESPACE === HTML_NAMESPACE) {
966
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
967
+ }
968
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
969
+ };
970
+ /**
971
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
972
+ *
973
+ * @param root The root element or node to start traversing on.
974
+ * @return The created NodeIterator
975
+ */
976
+ const _createNodeIterator = function _createNodeIterator(root) {
977
+ return createNodeIterator.call(root.ownerDocument || root, root,
978
+ // eslint-disable-next-line no-bitwise
979
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
980
+ };
981
+ /**
982
+ * _isClobbered
983
+ *
984
+ * @param element element to check for clobbering attacks
985
+ * @return true if clobbered, false if safe
986
+ */
987
+ const _isClobbered = function _isClobbered(element) {
988
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
989
+ };
990
+ /**
991
+ * Checks whether the given object is a DOM node.
992
+ *
993
+ * @param value object to check whether it's a DOM node
994
+ * @return true is object is a DOM node
995
+ */
996
+ const _isNode = function _isNode(value) {
997
+ return typeof Node === 'function' && value instanceof Node;
998
+ };
999
+ function _executeHooks(hooks, currentNode, data) {
1000
+ arrayForEach(hooks, hook => {
1001
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1002
+ });
1003
+ }
1004
+ /**
1005
+ * _sanitizeElements
1006
+ *
1007
+ * @protect nodeName
1008
+ * @protect textContent
1009
+ * @protect removeChild
1010
+ * @param currentNode to check for permission to exist
1011
+ * @return true if node was killed, false if left alive
1012
+ */
1013
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1014
+ let content = null;
1015
+ /* Execute a hook if present */
1016
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1017
+ /* Check if element is clobbered or can clobber */
1018
+ if (_isClobbered(currentNode)) {
1019
+ _forceRemove(currentNode);
1020
+ return true;
1021
+ }
1022
+ /* Now let's check the element's type and name */
1023
+ const tagName = transformCaseFunc(currentNode.nodeName);
1024
+ /* Execute a hook if present */
1025
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1026
+ tagName,
1027
+ allowedTags: ALLOWED_TAGS
1028
+ });
1029
+ /* Detect mXSS attempts abusing namespace confusion */
1030
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
1031
+ _forceRemove(currentNode);
1032
+ return true;
1033
+ }
1034
+ /* Remove risky CSS construction leading to mXSS */
1035
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1036
+ _forceRemove(currentNode);
1037
+ return true;
1038
+ }
1039
+ /* Remove any occurrence of processing instructions */
1040
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1041
+ _forceRemove(currentNode);
1042
+ return true;
1043
+ }
1044
+ /* Remove any kind of possibly harmful comments */
1045
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1046
+ _forceRemove(currentNode);
1047
+ return true;
1048
+ }
1049
+ /* Remove element if anything forbids its presence */
1050
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1051
+ /* Check if we have a custom element to handle */
1052
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1053
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1054
+ return false;
1055
+ }
1056
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1057
+ return false;
1058
+ }
1059
+ }
1060
+ /* Keep content except for bad-listed elements */
1061
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1062
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1063
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1064
+ if (childNodes && parentNode) {
1065
+ const childCount = childNodes.length;
1066
+ for (let i = childCount - 1; i >= 0; --i) {
1067
+ const childClone = cloneNode(childNodes[i], true);
1068
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
1069
+ }
1070
+ }
1071
+ }
1072
+ _forceRemove(currentNode);
1073
+ return true;
1074
+ }
1075
+ /* Check whether element has a valid namespace */
1076
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1077
+ _forceRemove(currentNode);
1078
+ return true;
1079
+ }
1080
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1081
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1082
+ _forceRemove(currentNode);
1083
+ return true;
1084
+ }
1085
+ /* Sanitize element content to be template-safe */
1086
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1087
+ /* Get the element's text content */
1088
+ content = currentNode.textContent;
1089
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1090
+ content = stringReplace(content, expr, ' ');
1091
+ });
1092
+ if (currentNode.textContent !== content) {
1093
+ arrayPush(DOMPurify.removed, {
1094
+ element: currentNode.cloneNode()
1095
+ });
1096
+ currentNode.textContent = content;
1097
+ }
1098
+ }
1099
+ /* Execute a hook if present */
1100
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1101
+ return false;
1102
+ };
1103
+ /**
1104
+ * _isValidAttribute
1105
+ *
1106
+ * @param lcTag Lowercase tag name of containing element.
1107
+ * @param lcName Lowercase attribute name.
1108
+ * @param value Attribute value.
1109
+ * @return Returns true if `value` is valid, otherwise false.
1110
+ */
1111
+ // eslint-disable-next-line complexity
1112
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1113
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1114
+ if (FORBID_ATTR[lcName]) {
1115
+ return false;
1116
+ }
1117
+ /* Make sure attribute cannot clobber */
1118
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1119
+ return false;
1120
+ }
1121
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1122
+ /* Allow valid data-* attributes: At least one character after "-"
1123
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1124
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1125
+ We don't need to check the value; it's always URI safe. */
1126
+ 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]) {
1127
+ if (
1128
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1129
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1130
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1131
+ _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)) ||
1132
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1133
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1134
+ 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 {
1135
+ return false;
1136
+ }
1137
+ /* Check value is safe. First, is attr inert? If so, is safe */
1138
+ } 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) {
1139
+ return false;
1140
+ } else ;
1141
+ return true;
1142
+ };
1143
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
1144
+ * never be treated as basic custom elements even when a permissive
1145
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
1146
+ 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']);
1147
+ /**
1148
+ * _isBasicCustomElement
1149
+ * checks if at least one dash is included in tagName, and it's not the first char
1150
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1151
+ *
1152
+ * @param tagName name of the tag of the node to sanitize
1153
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1154
+ */
1155
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1156
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1157
+ };
1158
+ /**
1159
+ * _sanitizeAttributes
1160
+ *
1161
+ * @protect attributes
1162
+ * @protect nodeName
1163
+ * @protect removeAttribute
1164
+ * @protect setAttribute
1165
+ *
1166
+ * @param currentNode to sanitize
1167
+ */
1168
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1169
+ /* Execute a hook if present */
1170
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
1171
+ const attributes = currentNode.attributes;
1172
+ /* Check if we have attributes; if not we might have a text node */
1173
+ if (!attributes || _isClobbered(currentNode)) {
1174
+ return;
1175
+ }
1176
+ const hookEvent = {
1177
+ attrName: '',
1178
+ attrValue: '',
1179
+ keepAttr: true,
1180
+ allowedAttributes: ALLOWED_ATTR,
1181
+ forceKeepAttr: undefined
1182
+ };
1183
+ let l = attributes.length;
1184
+ /* Go backwards over all attributes; safely remove bad ones */
1185
+ while (l--) {
1186
+ const attr = attributes[l];
1187
+ const name = attr.name,
1188
+ namespaceURI = attr.namespaceURI,
1189
+ attrValue = attr.value;
1190
+ const lcName = transformCaseFunc(name);
1191
+ const initValue = attrValue;
1192
+ let value = name === 'value' ? initValue : stringTrim(initValue);
1193
+ /* Execute a hook if present */
1194
+ hookEvent.attrName = lcName;
1195
+ hookEvent.attrValue = value;
1196
+ hookEvent.keepAttr = true;
1197
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1198
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
1199
+ value = hookEvent.attrValue;
1200
+ /* Full DOM Clobbering protection via namespace isolation,
1201
+ * Prefix id and name attributes with `user-content-`
1202
+ */
1203
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
1204
+ // Remove the attribute with this value
1205
+ _removeAttribute(name, currentNode);
1206
+ // Prefix the value and later re-create the attribute with the sanitized value
1207
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1208
+ }
1209
+ // Else: already prefixed, leave the attribute alone — the prefix is
1210
+ // itself the clobbering protection, and re-applying it is incorrect.
1211
+ /* Work around a security issue with comments inside attributes */
1212
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1213
+ _removeAttribute(name, currentNode);
1214
+ continue;
1215
+ }
1216
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
1217
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
1218
+ _removeAttribute(name, currentNode);
1219
+ continue;
1220
+ }
1221
+ /* Did the hooks approve of the attribute? */
1222
+ if (hookEvent.forceKeepAttr) {
1223
+ continue;
1224
+ }
1225
+ /* Did the hooks approve of the attribute? */
1226
+ if (!hookEvent.keepAttr) {
1227
+ _removeAttribute(name, currentNode);
1228
+ continue;
1229
+ }
1230
+ /* Work around a security issue in jQuery 3.0 */
1231
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1232
+ _removeAttribute(name, currentNode);
1233
+ continue;
1234
+ }
1235
+ /* Sanitize attribute content to be template-safe */
1236
+ if (SAFE_FOR_TEMPLATES) {
1237
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1238
+ value = stringReplace(value, expr, ' ');
1239
+ });
1240
+ }
1241
+ /* Is `value` valid for this attribute? */
1242
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1243
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1244
+ _removeAttribute(name, currentNode);
1245
+ continue;
1246
+ }
1247
+ /* Handle attributes that require Trusted Types */
1248
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1249
+ if (namespaceURI) ; else {
1250
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1251
+ case 'TrustedHTML':
1252
+ {
1253
+ value = trustedTypesPolicy.createHTML(value);
1254
+ break;
1255
+ }
1256
+ case 'TrustedScriptURL':
1257
+ {
1258
+ value = trustedTypesPolicy.createScriptURL(value);
1259
+ break;
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ /* Handle invalid data-* attribute set by try-catching it */
1265
+ if (value !== initValue) {
1266
+ try {
1267
+ if (namespaceURI) {
1268
+ currentNode.setAttributeNS(namespaceURI, name, value);
1269
+ } else {
1270
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1271
+ currentNode.setAttribute(name, value);
1272
+ }
1273
+ if (_isClobbered(currentNode)) {
1274
+ _forceRemove(currentNode);
1275
+ } else {
1276
+ arrayPop(DOMPurify.removed);
1277
+ }
1278
+ } catch (_) {
1279
+ _removeAttribute(name, currentNode);
1280
+ }
1281
+ }
1282
+ }
1283
+ /* Execute a hook if present */
1284
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
1285
+ };
1286
+ /**
1287
+ * _sanitizeShadowDOM
1288
+ *
1289
+ * @param fragment to iterate over recursively
1290
+ */
1291
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1292
+ let shadowNode = null;
1293
+ const shadowIterator = _createNodeIterator(fragment);
1294
+ /* Execute a hook if present */
1295
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1296
+ while (shadowNode = shadowIterator.nextNode()) {
1297
+ /* Execute a hook if present */
1298
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1299
+ /* Sanitize tags and elements */
1300
+ _sanitizeElements(shadowNode);
1301
+ /* Check attributes next */
1302
+ _sanitizeAttributes(shadowNode);
1303
+ /* Deep shadow DOM detected */
1304
+ if (shadowNode.content instanceof DocumentFragment) {
1305
+ _sanitizeShadowDOM2(shadowNode.content);
1306
+ }
1307
+ }
1308
+ /* Execute a hook if present */
1309
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
1310
+ };
1311
+ /**
1312
+ * _sanitizeAttachedShadowRoots
1313
+ *
1314
+ * Walks `root` and feeds every attached shadow root we encounter into
1315
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
1316
+ * does not descend into shadow trees, so nodes inside an attached
1317
+ * shadow root would otherwise be skipped entirely.
1318
+ *
1319
+ * Two real input paths put attached shadow roots in front of us:
1320
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
1321
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
1322
+ * shadow root because it was created with `clonable: true`.
1323
+ *
1324
+ * This pass runs once, up front, so the main iteration loop (and the
1325
+ * existing _sanitizeShadowDOM template-content recursion) stay
1326
+ * untouched — string-input paths are not affected.
1327
+ *
1328
+ * @param root the subtree root to walk for attached shadow roots
1329
+ */
1330
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
1331
+ if (root.nodeType === NODE_TYPE.element && root.shadowRoot instanceof DocumentFragment) {
1332
+ const sr = root.shadowRoot;
1333
+ // Recurse first so that nested shadow roots are reached even if
1334
+ // _sanitizeShadowDOM removes hosts at this level.
1335
+ _sanitizeAttachedShadowRoots2(sr);
1336
+ _sanitizeShadowDOM2(sr);
1337
+ }
1338
+ // Snapshot children before recursing. Sanitization of one subtree
1339
+ // (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
1340
+ // and naive nextSibling traversal would silently skip the rest of
1341
+ // the list once a node is detached.
1342
+ const childNodes = root.childNodes;
1343
+ if (!childNodes) {
1344
+ return;
1345
+ }
1346
+ const snapshot = [];
1347
+ arrayForEach(childNodes, child => {
1348
+ arrayPush(snapshot, child);
1349
+ });
1350
+ for (const child of snapshot) {
1351
+ _sanitizeAttachedShadowRoots2(child);
1352
+ }
1353
+ };
1354
+ // eslint-disable-next-line complexity
1355
+ DOMPurify.sanitize = function (dirty) {
1356
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1357
+ let body = null;
1358
+ let importedNode = null;
1359
+ let currentNode = null;
1360
+ let returnNode = null;
1361
+ /* Make sure we have a string to sanitize.
1362
+ DO NOT return early, as this will return the wrong type if
1363
+ the user has requested a DOM object rather than a string */
1364
+ IS_EMPTY_INPUT = !dirty;
1365
+ if (IS_EMPTY_INPUT) {
1366
+ dirty = '<!-->';
1367
+ }
1368
+ /* Stringify, in case dirty is an object */
1369
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1370
+ dirty = stringifyValue(dirty);
1371
+ if (typeof dirty !== 'string') {
1372
+ throw typeErrorCreate('dirty is not a string, aborting');
1373
+ }
1374
+ }
1375
+ /* Return dirty HTML if DOMPurify cannot run */
1376
+ if (!DOMPurify.isSupported) {
1377
+ return dirty;
1378
+ }
1379
+ /* Assign config vars */
1380
+ if (!SET_CONFIG) {
1381
+ _parseConfig(cfg);
1382
+ }
1383
+ /* Clean up removed elements */
1384
+ DOMPurify.removed = [];
1385
+ /* Check if dirty is correctly typed for IN_PLACE */
1386
+ if (typeof dirty === 'string') {
1387
+ IN_PLACE = false;
1388
+ }
1389
+ if (IN_PLACE) {
1390
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1391
+ const nn = dirty.nodeName;
1392
+ if (typeof nn === 'string') {
1393
+ const tagName = transformCaseFunc(nn);
1394
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1395
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1396
+ }
1397
+ }
1398
+ /* Sanitize attached shadow roots before the main iterator runs.
1399
+ The iterator does not descend into shadow trees. */
1400
+ _sanitizeAttachedShadowRoots2(dirty);
1401
+ } else if (dirty instanceof Node) {
1402
+ /* If dirty is a DOM element, append to an empty document to avoid
1403
+ elements being stripped by the parser */
1404
+ body = _initDocument('<!---->');
1405
+ importedNode = body.ownerDocument.importNode(dirty, true);
1406
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1407
+ /* Node is already a body, use as is */
1408
+ body = importedNode;
1409
+ } else if (importedNode.nodeName === 'HTML') {
1410
+ body = importedNode;
1411
+ } else {
1412
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1413
+ body.appendChild(importedNode);
1414
+ }
1415
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
1416
+ them before the main iterator runs, since the iterator does not
1417
+ descend into shadow trees. */
1418
+ _sanitizeAttachedShadowRoots2(importedNode);
1419
+ } else {
1420
+ /* Exit directly if we have nothing to do */
1421
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1422
+ // eslint-disable-next-line unicorn/prefer-includes
1423
+ dirty.indexOf('<') === -1) {
1424
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1425
+ }
1426
+ /* Initialize the document to work on */
1427
+ body = _initDocument(dirty);
1428
+ /* Check we have a DOM node from the data */
1429
+ if (!body) {
1430
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1431
+ }
1432
+ }
1433
+ /* Remove first element node (ours) if FORCE_BODY is set */
1434
+ if (body && FORCE_BODY) {
1435
+ _forceRemove(body.firstChild);
1436
+ }
1437
+ /* Get node iterator */
1438
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1439
+ /* Now start iterating over the created document */
1440
+ while (currentNode = nodeIterator.nextNode()) {
1441
+ /* Sanitize tags and elements */
1442
+ _sanitizeElements(currentNode);
1443
+ /* Check attributes next */
1444
+ _sanitizeAttributes(currentNode);
1445
+ /* Shadow DOM detected, sanitize it */
1446
+ if (currentNode.content instanceof DocumentFragment) {
1447
+ _sanitizeShadowDOM2(currentNode.content);
1448
+ }
1449
+ }
1450
+ /* If we sanitized `dirty` in-place, return it. */
1451
+ if (IN_PLACE) {
1452
+ return dirty;
1453
+ }
1454
+ /* Return sanitized string or DOM */
1455
+ if (RETURN_DOM) {
1456
+ if (SAFE_FOR_TEMPLATES) {
1457
+ body.normalize();
1458
+ let html = body.innerHTML;
1459
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1460
+ html = stringReplace(html, expr, ' ');
1461
+ });
1462
+ body.innerHTML = html;
1463
+ }
1464
+ if (RETURN_DOM_FRAGMENT) {
1465
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1466
+ while (body.firstChild) {
1467
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1468
+ returnNode.appendChild(body.firstChild);
1469
+ }
1470
+ } else {
1471
+ returnNode = body;
1472
+ }
1473
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1474
+ /*
1475
+ AdoptNode() is not used because internal state is not reset
1476
+ (e.g. the past names map of a HTMLFormElement), this is safe
1477
+ in theory but we would rather not risk another attack vector.
1478
+ The state that is cloned by importNode() is explicitly defined
1479
+ by the specs.
1480
+ */
1481
+ returnNode = importNode.call(originalDocument, returnNode, true);
1482
+ }
1483
+ return returnNode;
1484
+ }
1485
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1486
+ /* Serialize doctype if allowed */
1487
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1488
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1489
+ }
1490
+ /* Sanitize final string template-safe */
1491
+ if (SAFE_FOR_TEMPLATES) {
1492
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1493
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
1494
+ });
1495
+ }
1496
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1497
+ };
1498
+ DOMPurify.setConfig = function () {
1499
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1500
+ _parseConfig(cfg);
1501
+ SET_CONFIG = true;
1502
+ };
1503
+ DOMPurify.clearConfig = function () {
1504
+ CONFIG = null;
1505
+ SET_CONFIG = false;
1506
+ };
1507
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1508
+ /* Initialize shared config vars if necessary. */
1509
+ if (!CONFIG) {
1510
+ _parseConfig({});
1511
+ }
1512
+ const lcTag = transformCaseFunc(tag);
1513
+ const lcName = transformCaseFunc(attr);
1514
+ return _isValidAttribute(lcTag, lcName, value);
1515
+ };
1516
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1517
+ if (typeof hookFunction !== 'function') {
1518
+ return;
1519
+ }
1520
+ arrayPush(hooks[entryPoint], hookFunction);
1521
+ };
1522
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
1523
+ if (hookFunction !== undefined) {
1524
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
1525
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
1526
+ }
1527
+ return arrayPop(hooks[entryPoint]);
1528
+ };
1529
+ DOMPurify.removeHooks = function (entryPoint) {
1530
+ hooks[entryPoint] = [];
1531
+ };
1532
+ DOMPurify.removeAllHooks = function () {
1533
+ hooks = _createHooksMap();
1534
+ };
1535
+ return DOMPurify;
1536
+ }
1537
+ var purify = createDOMPurify();
1538
+
1539
+ exports.default = purify;
1540
+ //# sourceMappingURL=purify.es.js.map