/*! For license information please see purify.min.js.LICENSE.txt */ !function(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(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;c||(c=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),s||(s=function(e,t){return new e(...t)});const m=b(Array.prototype.forEach),u=b(Array.prototype.pop),f=b(Array.prototype.push),p=b(String.prototype.toLowerCase),d=b(String.prototype.toString),h=b(String.prototype.match),g=b(String.prototype.replace),T=b(String.prototype.indexOf),y=b(String.prototype.trim),E=b(RegExp.prototype.test),A=(_=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),r=1;r/gm),H=a(/\${[\w\W]*}/gm),z=a(/^data-[\-\w.\u00B7-\uFFFF]/),B=a(/^aria-[\-\w]+$/),W=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=a(/^(?:\w+script|data):/i),Y=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),j=a(/^html$/i);var q=Object.freeze({__proto__:null,MUSTACHE_EXPR:P,ERB_EXPR:F,TMPLIT_EXPR:H,DATA_ATTR:z,ARIA_ATTR:B,IS_ALLOWED_URI:W,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:Y,DOCTYPE_NAME:j}),X=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const o=e=>t(e);if(o.version="3.0.3",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;const r=n.document,a=r.currentScript;let{document:l}=n;const{DocumentFragment:c,HTMLTemplateElement:s,Node:_,Element:b,NodeFilter:P,NamedNodeMap:F=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:H,DOMParser:z,trustedTypes:B}=n,G=b.prototype,Y=R(G,"cloneNode"),X=R(G,"nextSibling"),K=R(G,"childNodes"),V=R(G,"parentNode");if("function"==typeof s){const e=l.createElement("template");e.content&&e.content.ownerDocument&&(l=e.content.ownerDocument)}let $,Z="";const{implementation:J,createNodeIterator:Q,createDocumentFragment:ee,getElementsByTagName:te}=l,{importNode:ne}=r;let oe={};o.isSupported="function"==typeof e&&"function"==typeof V&&J&&void 0!==J.createHTMLDocument;const{MUSTACHE_EXPR:re,ERB_EXPR:ie,TMPLIT_EXPR:ae,DATA_ATTR:le,ARIA_ATTR:ce,IS_SCRIPT_OR_DATA:se,ATTR_WHITESPACE:me}=q;let{IS_ALLOWED_URI:ue}=q,fe=null;const pe=N({},[...w,...D,...L,...v,...k]);let de=null;const he=N({},[...O,...I,...M,...U]);let ge=Object.seal(Object.create(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}})),Te=null,ye=null,Ee=!0,Ae=!0,_e=!1,be=!0,Ne=!1,Se=!1,Re=!1,we=!1,De=!1,Le=!1,xe=!1,ve=!0,Ce=!1,ke=!0,Oe=!1,Ie={},Me=null;const Ue=N({},["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"]);let Pe=null;const Fe=N({},["audio","video","img","source","image","track"]);let He=null;const ze=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Be="http://www.w3.org/1998/Math/MathML",We="http://www.w3.org/2000/svg",Ge="http://www.w3.org/1999/xhtml";let Ye=Ge,je=!1,qe=null;const Xe=N({},[Be,We,Ge],d);let Ke;const Ve=["application/xhtml+xml","text/html"];let $e,Ze=null;const Je=l.createElement("form"),Qe=function(e){return e instanceof RegExp||e instanceof Function},et=function(e){if(!Ze||Ze!==e){if(e&&"object"==typeof e||(e={}),e=S(e),Ke=Ke=-1===Ve.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,$e="application/xhtml+xml"===Ke?d:p,fe="ALLOWED_TAGS"in e?N({},e.ALLOWED_TAGS,$e):pe,de="ALLOWED_ATTR"in e?N({},e.ALLOWED_ATTR,$e):he,qe="ALLOWED_NAMESPACES"in e?N({},e.ALLOWED_NAMESPACES,d):Xe,He="ADD_URI_SAFE_ATTR"in e?N(S(ze),e.ADD_URI_SAFE_ATTR,$e):ze,Pe="ADD_DATA_URI_TAGS"in e?N(S(Fe),e.ADD_DATA_URI_TAGS,$e):Fe,Me="FORBID_CONTENTS"in e?N({},e.FORBID_CONTENTS,$e):Ue,Te="FORBID_TAGS"in e?N({},e.FORBID_TAGS,$e):{},ye="FORBID_ATTR"in e?N({},e.FORBID_ATTR,$e):{},Ie="USE_PROFILES"in e&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Ae=!1!==e.ALLOW_DATA_ATTR,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,be=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ne=e.SAFE_FOR_TEMPLATES||!1,Se=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,Le=e.RETURN_DOM_FRAGMENT||!1,xe=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,ve=!1!==e.SANITIZE_DOM,Ce=e.SANITIZE_NAMED_PROPS||!1,ke=!1!==e.KEEP_CONTENT,Oe=e.IN_PLACE||!1,ue=e.ALLOWED_URI_REGEXP||W,Ye=e.NAMESPACE||Ge,ge=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Qe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ge.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Qe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ge.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(ge.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ne&&(Ae=!1),Le&&(De=!0),Ie&&(fe=N({},[...k]),de=[],!0===Ie.html&&(N(fe,w),N(de,O)),!0===Ie.svg&&(N(fe,D),N(de,I),N(de,U)),!0===Ie.svgFilters&&(N(fe,L),N(de,I),N(de,U)),!0===Ie.mathMl&&(N(fe,v),N(de,M),N(de,U))),e.ADD_TAGS&&(fe===pe&&(fe=S(fe)),N(fe,e.ADD_TAGS,$e)),e.ADD_ATTR&&(de===he&&(de=S(de)),N(de,e.ADD_ATTR,$e)),e.ADD_URI_SAFE_ATTR&&N(He,e.ADD_URI_SAFE_ATTR,$e),e.FORBID_CONTENTS&&(Me===Ue&&(Me=S(Me)),N(Me,e.FORBID_CONTENTS,$e)),ke&&(fe["#text"]=!0),Se&&N(fe,["html","head","body"]),fe.table&&(N(fe,["tbody"]),delete Te.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');$=e.TRUSTED_TYPES_POLICY,Z=$.createHTML("")}else void 0===$&&($=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(B,a)),null!==$&&"string"==typeof Z&&(Z=$.createHTML(""));i&&i(e),Ze=e}},tt=N({},["mi","mo","mn","ms","mtext"]),nt=N({},["foreignobject","desc","title","annotation-xml"]),ot=N({},["title","style","font","a","script"]),rt=N({},D);N(rt,L),N(rt,x);const it=N({},v);N(it,C);const at=function(e){f(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},lt=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!de[e])if(De||Le)try{at(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},ct=function(e){let t,n;if(we)e=""+e;else{const t=h(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Ke&&Ye===Ge&&(e=''+e+"");const o=$?$.createHTML(e):e;if(Ye===Ge)try{t=(new z).parseFromString(o,Ke)}catch(e){}if(!t||!t.documentElement){t=J.createDocument(Ye,"template",null);try{t.documentElement.innerHTML=je?Z:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(l.createTextNode(n),r.childNodes[0]||null),Ye===Ge?te.call(t,Se?"html":"body")[0]:Se?t.documentElement:r},st=function(e){return Q.call(e.ownerDocument||e,e,P.SHOW_ELEMENT|P.SHOW_COMMENT|P.SHOW_TEXT,null,!1)},mt=function(e){return"object"==typeof _?e instanceof _:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ut=function(e,t,n){oe[e]&&m(oe[e],(e=>{e.call(o,t,n,Ze)}))},ft=function(e){let t;if(ut("beforeSanitizeElements",e,null),function(e){return e instanceof H&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof F)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)}(e))return at(e),!0;const n=$e(e.nodeName);if(ut("uponSanitizeElement",e,{tagName:n,allowedTags:fe}),e.hasChildNodes()&&!mt(e.firstElementChild)&&(!mt(e.content)||!mt(e.content.firstElementChild))&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return at(e),!0;if(!fe[n]||Te[n]){if(!Te[n]&&dt(n)){if(ge.tagNameCheck instanceof RegExp&&E(ge.tagNameCheck,n))return!1;if(ge.tagNameCheck instanceof Function&&ge.tagNameCheck(n))return!1}if(ke&&!Me[n]){const t=V(e)||e.parentNode,n=K(e)||e.childNodes;if(n&&t)for(let o=n.length-1;o>=0;--o)t.insertBefore(Y(n[o],!0),X(e))}return at(e),!0}return e instanceof b&&!function(e){let t=V(e);t&&t.tagName||(t={namespaceURI:Ye,tagName:"template"});const n=p(e.tagName),o=p(t.tagName);return!!qe[e.namespaceURI]&&(e.namespaceURI===We?t.namespaceURI===Ge?"svg"===n:t.namespaceURI===Be?"svg"===n&&("annotation-xml"===o||tt[o]):Boolean(rt[n]):e.namespaceURI===Be?t.namespaceURI===Ge?"math"===n:t.namespaceURI===We?"math"===n&&nt[o]:Boolean(it[n]):e.namespaceURI===Ge?!(t.namespaceURI===We&&!nt[o])&&!(t.namespaceURI===Be&&!tt[o])&&!it[n]&&(ot[n]||!rt[n]):!("application/xhtml+xml"!==Ke||!qe[e.namespaceURI]))}(e)?(at(e),!0):"noscript"!==n&&"noembed"!==n||!E(/<\/no(script|embed)/i,e.innerHTML)?(Ne&&3===e.nodeType&&(t=e.textContent,t=g(t,re," "),t=g(t,ie," "),t=g(t,ae," "),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),ut("afterSanitizeElements",e,null),!1):(at(e),!0)},pt=function(e,t,n){if(ve&&("id"===t||"name"===t)&&(n in l||n in Je))return!1;if(Ae&&!ye[t]&&E(le,t));else if(Ee&&E(ce,t));else if(!de[t]||ye[t]){if(!(dt(e)&&(ge.tagNameCheck instanceof RegExp&&E(ge.tagNameCheck,e)||ge.tagNameCheck instanceof Function&&ge.tagNameCheck(e))&&(ge.attributeNameCheck instanceof RegExp&&E(ge.attributeNameCheck,t)||ge.attributeNameCheck instanceof Function&&ge.attributeNameCheck(t))||"is"===t&&ge.allowCustomizedBuiltInElements&&(ge.tagNameCheck instanceof RegExp&&E(ge.tagNameCheck,n)||ge.tagNameCheck instanceof Function&&ge.tagNameCheck(n))))return!1}else if(He[t]);else if(E(ue,g(n,me,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!Pe[e])if(_e&&!E(se,g(n,me,"")));else if(n)return!1;return!0},dt=function(e){return e.indexOf("-")>0},ht=function(e){let t,n,r,i;ut("beforeSanitizeAttributes",e,null);const{attributes:a}=e;if(!a)return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:de};for(i=a.length;i--;){t=a[i];const{name:c,namespaceURI:s}=t;if(n="value"===c?t.value:y(t.value),r=$e(c),l.attrName=r,l.attrValue=n,l.keepAttr=!0,l.forceKeepAttr=void 0,ut("uponSanitizeAttribute",e,l),n=l.attrValue,l.forceKeepAttr)continue;if(lt(c,e),!l.keepAttr)continue;if(!be&&E(/\/>/i,n)){lt(c,e);continue}Ne&&(n=g(n,re," "),n=g(n,ie," "),n=g(n,ae," "));const m=$e(e.nodeName);if(pt(m,r,n)){if(!Ce||"id"!==r&&"name"!==r||(lt(c,e),n="user-content-"+n),$&&"object"==typeof B&&"function"==typeof B.getAttributeType)if(s);else switch(B.getAttributeType(m,r)){case"TrustedHTML":n=$.createHTML(n);break;case"TrustedScriptURL":n=$.createScriptURL(n)}try{s?e.setAttributeNS(s,c,n):e.setAttribute(c,n),u(o.removed)}catch(e){}}}ut("afterSanitizeAttributes",e,null)},gt=function e(t){let n;const o=st(t);for(ut("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)ut("uponSanitizeShadowNode",n,null),ft(n)||(n.content instanceof c&&e(n.content),ht(n));ut("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,n,i,a,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(je=!e,je&&(e="\x3c!--\x3e"),"string"!=typeof e&&!mt(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Re||et(l),o.removed=[],"string"==typeof e&&(Oe=!1),Oe){if(e.nodeName){const t=$e(e.nodeName);if(!fe[t]||Te[t])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof _)t=ct("\x3c!----\x3e"),n=t.ownerDocument.importNode(e,!0),1===n.nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?t=n:t.appendChild(n);else{if(!De&&!Ne&&!Se&&-1===e.indexOf("<"))return $&&xe?$.createHTML(e):e;if(t=ct(e),!t)return De?null:xe?Z:""}t&&we&&at(t.firstChild);const s=st(Oe?e:t);for(;i=s.nextNode();)ft(i)||(i.content instanceof c&>(i.content),ht(i));if(Oe)return e;if(De){if(Le)for(a=ee.call(t.ownerDocument);t.firstChild;)a.appendChild(t.firstChild);else a=t;return(de.shadowroot||de.shadowrootmod)&&(a=ne.call(r,a,!0)),a}let m=Se?t.outerHTML:t.innerHTML;return Se&&fe["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&E(j,t.ownerDocument.doctype.name)&&(m="\n"+m),Ne&&(m=g(m,re," "),m=g(m,ie," "),m=g(m,ae," ")),$&&xe?$.createHTML(m):m},o.setConfig=function(e){et(e),Re=!0},o.clearConfig=function(){Ze=null,Re=!1},o.isValidAttribute=function(e,t,n){Ze||et({});const o=$e(e),r=$e(t);return pt(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&(oe[e]=oe[e]||[],f(oe[e],t))},o.removeHook=function(e){if(oe[e])return u(oe[e])},o.removeHooks=function(e){oe[e]&&(oe[e]=[])},o.removeAllHooks=function(){oe={}},o}();return X}));