((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()})(this,function(){function je(){for(var e=arguments.length,t=new Array(e),n=0;n{for(let e=0;e/gm),u=e(/\${[\w\W]*}/gm),p=e(/^data-[\-\w.\u00B7-\uFFFF]/),f=e(/^aria-[\-\w]+$/),gt=e(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),d=e(/^(?:\w+script|data):/i),h=e(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Tt=e(/^html$/i),g=e(/^[a-z][.\w]*(-[.\w]+)+$/i);var yt=Object.freeze({__proto__:null,MUSTACHE_EXPR:t,ERB_EXPR:n,TMPLIT_EXPR:u,DATA_ATTR:p,ARIA_ATTR:f,IS_ALLOWED_URI:gt,IS_SCRIPT_OR_DATA:d,ATTR_WHITESPACE:h,DOCTYPE_NAME:Tt,CUSTOM_ELEMENT:g});let T=function I(){var e=0I(e);if(s.version="3.1.6",s.removed=[],!e||!e.document||9!==e.document.nodeType)return s.isSupported=!1,s;let r=e.document,c=r,U=c.currentScript,{DocumentFragment:P,HTMLTemplateElement:F,Node:m,Element:H,NodeFilter:t,NamedNodeMap:z=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:B,DOMParser:W,trustedTypes:u}=e,n=H.prototype,G=it(n,"cloneNode"),Y=it(n,"remove"),j=it(n,"nextSibling"),X=it(n,"childNodes"),a=it(n,"parentNode");if("function"==typeof F){let e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}function q(e){return e instanceof RegExp||e instanceof Function}function p(){let e=0{if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;var o="data-tt-policy-suffix",t="dompurify"+((n=t&&t.hasAttribute(o)?t.getAttribute(o):n)?"#"+n:"");try{return e.createPolicy(t,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+t+" could not be created."),null}})(u,U):f)&&"string"==typeof d&&(d=f.createHTML(""));qe&&qe(e),O=e}}function $(t){let e=null,n=null;if(Se)t=""+t;else{let e=et(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===L&&C===w&&(t=''+t+"");var o=f?f.createHTML(t):t;if(C===w)try{e=(new W).parseFromString(o,L)}catch(t){}if(!e||!e.documentElement){e=te.createDocument(C,"template",null);try{e.documentElement.innerHTML=xe?d:o}catch(t){}}return o=e.body||e.documentElement,t&&n&&o.insertBefore(r.createTextNode(n),o.childNodes[0]||null),C===w?re.call(e,E?"html":"body")[0]:E?e.documentElement:o}function K(e){return ne.call(e.ownerDocument||e,e,t.SHOW_ELEMENT|t.SHOW_COMMENT|t.SHOW_TEXT|t.SHOW_PROCESSING_INSTRUCTION|t.SHOW_CDATA_SECTION,null)}function V(e){return"function"==typeof m&&e instanceof m}function Z(o){let t=null;if(M("beforeSanitizeElements",o,null),!Ge(o)){let e=D(o.nodeName);if(M("uponSanitizeElement",o,{tagName:e,allowedTags:h}),(!o.hasChildNodes()||V(o.firstElementChild)||!ot(/<[/\w]/g,o.innerHTML)||!ot(/<[/\w]/g,o.textContent))&&!(7===o.nodeType||Ne&&8===o.nodeType&&ot(/<[/\w]/g,o.data))){if(h[e]&&!T[e])return(!(o instanceof H)||(e=>{let t=a(e);t&&t.tagName||(t={namespaceURI:C,tagName:"template"});var n=Je(e.tagName),o=Je(t.tagName);return Me[e.namespaceURI]&&(e.namespaceURI===R?t.namespaceURI===w?"svg"===n:t.namespaceURI===v?"svg"===n&&("annotation-xml"===o||Fe[o]):Boolean(Be[n]):e.namespaceURI===v?t.namespaceURI===w?"math"===n:t.namespaceURI===R?"math"===n&&He[o]:Boolean(We[n]):e.namespaceURI===w?(t.namespaceURI!==R||He[o])&&(t.namespaceURI!==v||Fe[o])&&!We[n]&&(ze[n]||!Be[n]):"application/xhtml+xml"===L&&Me[e.namespaceURI])})(o))&&("noscript"!==e&&"noembed"!==e&&"noframes"!==e||!ot(/<\/no(script|embed|frames)/i,o.innerHTML))?(y&&3===o.nodeType&&(t=o.textContent,Ke([ie,le,ce],e=>{t=tt(t,e," ")}),o.textContent!==t)&&(Ze(s.removed,{element:o.cloneNode()}),o.textContent=t),M("afterSanitizeElements",o,null),!1):(k(o),!0);if(!T[e]&&J(e)){if(i.tagNameCheck instanceof RegExp&&ot(i.tagNameCheck,e))return;if(i.tagNameCheck instanceof Function&&i.tagNameCheck(e))return}if(we&&!S[e]){let t=a(o)||o.parentNode,n=X(o)||o.childNodes;if(n&&t)for(let e=n.length-1;0<=e;--e){var r=G(n[e],!0);r.__removalCount=(o.__removalCount||0)+1,t.insertBefore(r,j(o))}}}}return k(o),1}function J(e){return"annotation-xml"!==e&&et(e,fe)}function Q(n){M("beforeSanitizeAttributes",n,null);var o=n.attributes;if(o){var r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:g};let e=o.length;for(;e--;){var{name:a,namespaceURI:i,value:l}=o[e],c=D(a);let t="value"===a?l:_t(l);if(r.attrName=c,r.attrValue=t,r.keepAttr=!0,r.forceKeepAttr=void 0,M("uponSanitizeAttribute",n,r),t=r.attrValue,Ne&&ot(/((--!?|])>)|<\/(style|title)/i,t))x(a,n);else if(!r.forceKeepAttr&&(x(a,n),r.keepAttr))if(!Ae&&ot(/\/>/i,t))x(a,n);else{y&&Ke([ie,le,ce],e=>{t=tt(t,e," ")});l=D(n.nodeName);if(Ye(l,c,t)){if(!Re||"id"!==c&&"name"!==c||(x(a,n),t="user-content-"+t),f&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!i)switch(u.getAttributeType(l,c)){case"TrustedHTML":t=f.createHTML(t);break;case"TrustedScriptURL":t=f.createScriptURL(t)}try{i?n.setAttributeNS(i,a,t):n.setAttribute(a,t),Ge(n)?k(n):Ve(s.removed)}catch(n){}}}}M("afterSanitizeAttributes",n,null)}}function ee(e){var t,n=K(e);for(M("beforeSanitizeShadowDOM",e,null);t=n.nextNode();)M("uponSanitizeShadowNode",t,null),Z(t)||(t.content instanceof P&&ee(t.content),Q(t));M("afterSanitizeShadowDOM",e,null)}let f,d="",{implementation:te,createNodeIterator:ne,createDocumentFragment:oe,getElementsByTagName:re}=r,ae=c.importNode,o={},{MUSTACHE_EXPR:ie,ERB_EXPR:le,TMPLIT_EXPR:ce,DATA_ATTR:se,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:ue,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:fe}=(s.isSupported="function"==typeof Xe&&"function"==typeof a&&te&&void 0!==te.createHTMLDocument,yt),de=yt.IS_ALLOWED_URI,h=null,he=rt({},[...lt,...ct,...st,...mt,...ut]),g=null,ge=rt({},[...pt,...ft,...dt,...ht]),i=Object.seal($e(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),T=null,Te=null,ye=!0,Ee=!0,_e=!1,Ae=!0,y=!1,Ne=!0,E=!1,be=!1,Se=!1,_=!1,A=!1,N=!1,ve=!0,Re=!1,we=!0,b=!1,l={},S=null,Ce=rt({},["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"]),Le=null,De=rt({},["audio","video","img","source","image","track"]),Oe=null,ke=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),v="http://www.w3.org/1998/Math/MathML",R="http://www.w3.org/2000/svg",w="http://www.w3.org/1999/xhtml",C=w,xe,Me=null,Ie=rt({},[v,R,w],Qe),L=null,Ue=["application/xhtml+xml","text/html"],D=null,O=null,Pe=r.createElement("form"),Fe=rt({},["mi","mo","mn","ms","mtext"]),He=rt({},["foreignobject","annotation-xml"]),ze=rt({},["title","style","font","a","script"]),Be=rt({},[...ct,...st,...At]),We=rt({},[...mt,...Nt]),k=function(t){Ze(s.removed,{element:t});try{a(t).removeChild(t)}catch(e){Y(t)}},x=function(e,t){try{Ze(s.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Ze(s.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!g[e])if(_||A)try{k(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ge=function(e){return e instanceof B&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof z)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},M=function(e,t,n){o[e]&&Ke(o[e],e=>{e.call(s,t,n,O)})},Ye=function(e,t,n){if(ve&&("id"===t||"name"===t)&&(n in r||n in Pe))return!1;if((!Ee||Te[t]||!ot(se,t))&&(!ye||!ot(me,t)))if(!g[t]||Te[t]){if(!(J(e)&&(i.tagNameCheck instanceof RegExp&&ot(i.tagNameCheck,e)||i.tagNameCheck instanceof Function&&i.tagNameCheck(e))&&(i.attributeNameCheck instanceof RegExp&&ot(i.attributeNameCheck,t)||i.attributeNameCheck instanceof Function&&i.attributeNameCheck(t))||"is"===t&&i.allowCustomizedBuiltInElements&&(i.tagNameCheck instanceof RegExp&&ot(i.tagNameCheck,n)||i.tagNameCheck instanceof Function&&i.tagNameCheck(n))))return!1}else if(!Oe[t]&&!ot(de,tt(n,pe,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Et(n,"data:")||!Le[e])&&(!_e||ot(ue,tt(n,pe,"")))&&n)return!1;return!0};return s.sanitize=function(t){let e=1\n"+l),y&&Ke([ie,le,ce],e=>{l=tt(l,e," ")}),f&&N?f.createHTML(l):l},s.setConfig=function(){p(0