Ocideck/assets/web_export/purify.min.js
Brenno de Winter f08055c7ae Upgrade vendored JS and add deps-check CVE gate (#3)
Upgrade the JavaScript bundles inlined into the offline HTML export:
DOMPurify 3.1.7 -> 3.4.9 (clears 10 OSV advisories), marked 12.0.2 -> 18.0.5,
highlight.js 11.9.0 -> 11.11.1. mermaid 10.9.6 and MathJax 3.2.2 are kept
(no known CVEs) and now guarded rather than chased.

Pin every bundle in assets/web_export/MANIFEST.json (npm name, version, source,
sha256, licence) and add tool/check_bundled_js.dart: it verifies each file
still matches the manifest hash and queries the OSV database for known
vulnerabilities. Wired as `make deps-check`, into `check-full`, and into CI
next to the licence check. THIRD_PARTY_NOTICES.md updated for the now-standalone
DOMPurify bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 22:16:29 +02:00

3 lines
28 KiB
JavaScript

/*! @license DOMPurify 3.4.9 | (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.9/LICENSE */
!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";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(e){s=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const n=Object.entries,o=Object.setPrototypeOf,r=Object.isFrozen,i=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor;let l=Object.freeze,c=Object.seal,s=Object.create,u="undefined"!=typeof Reflect&&Reflect,f=u.apply,p=u.construct;l||(l=function(e){return e}),c||(c=function(e){return e}),f||(f=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),p||(p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const m=L(Array.prototype.forEach),d=L(Array.prototype.lastIndexOf),h=L(Array.prototype.pop),g=L(Array.prototype.push),y=L(Array.prototype.splice),T=Array.isArray,b=L(String.prototype.toLowerCase),A=L(String.prototype.toString),S=L(String.prototype.match),E=L(String.prototype.replace),_=L(String.prototype.indexOf),N=L(String.prototype.trim),O=L(Number.prototype.toString),w=L(Boolean.prototype.toString),D="undefined"==typeof BigInt?null:L(BigInt.prototype.toString),R="undefined"==typeof Symbol?null:L(Symbol.prototype.toString),v=L(Object.prototype.hasOwnProperty),I=L(Object.prototype.toString),C=L(RegExp.prototype.test),x=(k=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p(k,t)});var k;function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return f(e,t,o)}}function M(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;if(o&&o(e,null),!T(t))return e;let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(r(t)||(t[i]=e),o=e)}e[o]=!0}return e}function P(e){for(let t=0;t<e.length;t++){v(e,t)||(e[t]=null)}return e}function z(e){const o=s(null);for(const i of n(e)){var r=t(i,2);const n=r[0],a=r[1];v(e,n)&&(T(a)?o[n]=P(a):a&&"object"==typeof a&&a.constructor===Object?o[n]=z(a):o[n]=a)}return o}function U(e,t){for(;null!==e;){const n=a(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=i(e)}return function(){return null}}const F=l(["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"]),H=l(["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"]),B=l(["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"]),j=l(["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"]),G=l(["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"]),W=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y=l(["#text"]),q=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),X=l(["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"]),$=l(["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"]),K=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),V=c(/{{[\w\W]*|^[\w\W]*}}/g),Z=c(/<%[\w\W]*|^[\w\W]*%>/g),J=c(/\${[\w\W]*/g),Q=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=c(/^aria-[\-\w]+$/),te=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=c(/^(?:\w+script|data):/i),oe=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=c(/^html$/i),ie=c(/^[a-z][.\w]*(-[.\w]+)+$/i),ae=1,le=3,ce=7,se=8,ue=9,fe=11,pe=function(){return"undefined"==typeof window?null:window};var me=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pe();const o=t=>e(t);if(o.version="3.4.9",o.removed=[],!t||!t.document||t.document.nodeType!==ue||!t.Element)return o.isSupported=!1,o;let r=t.document;const i=r,a=i.currentScript;t.DocumentFragment;const c=t.HTMLTemplateElement,u=t.Node,f=t.Element,p=t.NodeFilter,k=t.NamedNodeMap;void 0===k&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const L=t.DOMParser,P=t.trustedTypes,me=f.prototype,de=U(me,"cloneNode"),he=U(me,"remove"),ge=U(me,"nextSibling"),ye=U(me,"childNodes"),Te=U(me,"parentNode"),be=U(me,"shadowRoot"),Ae=U(me,"attributes"),Se=u&&u.prototype?U(u.prototype,"nodeType"):null,Ee=u&&u.prototype?U(u.prototype,"nodeName"):null;if("function"==typeof c){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let _e,Ne,Oe="",we=!1,De=0;const Re=function(){if(De>0)throw x('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ve=function(e){Re(),De++;try{return _e.createHTML(e)}finally{De--}},Ie=function(e){Re(),De++;try{return _e.createScriptURL(e)}finally{De--}},Ce=function(){return we||(Ne=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}}(P,a),we=!0),Ne},xe=r,ke=xe.implementation,Le=xe.createNodeIterator,Me=xe.createDocumentFragment,Pe=xe.getElementsByTagName,ze=i.importNode;let Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof n&&"function"==typeof Te&&ke&&void 0!==ke.createHTMLDocument;const Fe=V,He=Z,Be=J,je=Q,Ge=ee,We=ne,Ye=oe,qe=ie;let Xe=te,$e=null;const Ke=M({},[...F,...H,...B,...G,...Y]);let Ve=null;const Ze=M({},[...q,...X,...$,...K]);let Je=Object.seal(s(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}})),Qe=null,et=null;const tt=Object.seal(s(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nt=!0,ot=!0,rt=!1,it=!0,at=!1,lt=!0,ct=!1,st=!1,ut=!1,ft=!1,pt=!1,mt=!1,dt=!0,ht=!1;const gt="user-content-";let yt=!0,Tt=!1,bt={},At=null;const St=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Et=null;const _t=M({},["audio","video","img","source","image","track"]);let Nt=null;const Ot=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),wt="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",Rt="http://www.w3.org/1999/xhtml";let vt=Rt,It=!1,Ct=null;const xt=M({},[wt,Dt,Rt],A);let kt=M({},["mi","mo","mn","ms","mtext"]),Lt=M({},["annotation-xml"]);const Mt=M({},["title","style","font","a","script"]);let Pt=null;const zt=["application/xhtml+xml","text/html"];let Ut=null,Ft=null;const Ht=r.createElement("form"),Bt=function(e){return e instanceof RegExp||e instanceof Function},jt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Ft&&Ft===e)return;e&&"object"==typeof e||(e={}),e=z(e),Pt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ut="application/xhtml+xml"===Pt?A:b,$e=v(e,"ALLOWED_TAGS")&&T(e.ALLOWED_TAGS)?M({},e.ALLOWED_TAGS,Ut):Ke,Ve=v(e,"ALLOWED_ATTR")&&T(e.ALLOWED_ATTR)?M({},e.ALLOWED_ATTR,Ut):Ze,Ct=v(e,"ALLOWED_NAMESPACES")&&T(e.ALLOWED_NAMESPACES)?M({},e.ALLOWED_NAMESPACES,A):xt,Nt=v(e,"ADD_URI_SAFE_ATTR")&&T(e.ADD_URI_SAFE_ATTR)?M(z(Ot),e.ADD_URI_SAFE_ATTR,Ut):Ot,Et=v(e,"ADD_DATA_URI_TAGS")&&T(e.ADD_DATA_URI_TAGS)?M(z(_t),e.ADD_DATA_URI_TAGS,Ut):_t,At=v(e,"FORBID_CONTENTS")&&T(e.FORBID_CONTENTS)?M({},e.FORBID_CONTENTS,Ut):St,Qe=v(e,"FORBID_TAGS")&&T(e.FORBID_TAGS)?M({},e.FORBID_TAGS,Ut):z({}),et=v(e,"FORBID_ATTR")&&T(e.FORBID_ATTR)?M({},e.FORBID_ATTR,Ut):z({}),bt=!!v(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?z(e.USE_PROFILES):e.USE_PROFILES),nt=!1!==e.ALLOW_ARIA_ATTR,ot=!1!==e.ALLOW_DATA_ATTR,rt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,it=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,at=e.SAFE_FOR_TEMPLATES||!1,lt=!1!==e.SAFE_FOR_XML,ct=e.WHOLE_DOCUMENT||!1,ft=e.RETURN_DOM||!1,pt=e.RETURN_DOM_FRAGMENT||!1,mt=e.RETURN_TRUSTED_TYPE||!1,ut=e.FORCE_BODY||!1,dt=!1!==e.SANITIZE_DOM,ht=e.SANITIZE_NAMED_PROPS||!1,yt=!1!==e.KEEP_CONTENT,Tt=e.IN_PLACE||!1,Xe=function(e){try{return C(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:te,vt="string"==typeof e.NAMESPACE?e.NAMESPACE:Rt,kt=v(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?z(e.MATHML_TEXT_INTEGRATION_POINTS):M({},["mi","mo","mn","ms","mtext"]),Lt=v(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?z(e.HTML_INTEGRATION_POINTS):M({},["annotation-xml"]);const t=v(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?z(e.CUSTOM_ELEMENT_HANDLING):s(null);if(Je=s(null),v(t,"tagNameCheck")&&Bt(t.tagNameCheck)&&(Je.tagNameCheck=t.tagNameCheck),v(t,"attributeNameCheck")&&Bt(t.attributeNameCheck)&&(Je.attributeNameCheck=t.attributeNameCheck),v(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Je.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),at&&(ot=!1),pt&&(ft=!0),bt&&($e=M({},Y),Ve=s(null),!0===bt.html&&(M($e,F),M(Ve,q)),!0===bt.svg&&(M($e,H),M(Ve,X),M(Ve,K)),!0===bt.svgFilters&&(M($e,B),M(Ve,X),M(Ve,K)),!0===bt.mathMl&&(M($e,G),M(Ve,$),M(Ve,K))),tt.tagCheck=null,tt.attributeCheck=null,v(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?tt.tagCheck=e.ADD_TAGS:T(e.ADD_TAGS)&&($e===Ke&&($e=z($e)),M($e,e.ADD_TAGS,Ut))),v(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?tt.attributeCheck=e.ADD_ATTR:T(e.ADD_ATTR)&&(Ve===Ze&&(Ve=z(Ve)),M(Ve,e.ADD_ATTR,Ut))),v(e,"ADD_URI_SAFE_ATTR")&&T(e.ADD_URI_SAFE_ATTR)&&M(Nt,e.ADD_URI_SAFE_ATTR,Ut),v(e,"FORBID_CONTENTS")&&T(e.FORBID_CONTENTS)&&(At===St&&(At=z(At)),M(At,e.FORBID_CONTENTS,Ut)),v(e,"ADD_FORBID_CONTENTS")&&T(e.ADD_FORBID_CONTENTS)&&(At===St&&(At=z(At)),M(At,e.ADD_FORBID_CONTENTS,Ut)),yt&&($e["#text"]=!0),ct&&M($e,["html","head","body"]),$e.table&&(M($e,["tbody"]),delete Qe.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=_e;_e=e.TRUSTED_TYPES_POLICY;try{Oe=ve("")}catch(e){throw _e=t,e}}else null===e.TRUSTED_TYPES_POLICY?(_e=void 0,Oe=""):(void 0===_e&&(_e=Ce()),_e&&"string"==typeof Oe&&(Oe=ve("")));(Ue.uponSanitizeElement.length>0||Ue.uponSanitizeAttribute.length>0)&&$e===Ke&&($e=z($e)),Ue.uponSanitizeAttribute.length>0&&Ve===Ze&&(Ve=z(Ve)),l&&l(e),Ft=e},Gt=M({},[...H,...B,...j]),Wt=M({},[...G,...W]),Yt=function(e){g(o.removed,{element:e});try{Te(e).removeChild(e)}catch(t){if(he(e),!Te(e))throw x("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},qt=function(e){const t=ye?ye(e):e.childNodes;if(t){const e=[];m(t,t=>{g(e,t)}),m(e,e=>{try{he(e)}catch(e){}})}const n=Ae?Ae(e):null;if(n)for(let t=n.length-1;t>=0;--t){const o=n[t],r=o&&o.name;if("string"==typeof r)try{e.removeAttribute(r)}catch(e){}}},Xt=function(e,t){try{g(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){g(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ft||pt)try{Yt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},$t=function(e){const t=Ae?Ae(e):e.attributes;if(t)for(let n=t.length-1;n>=0;--n){const o=t[n],r=o&&o.name;if("string"==typeof r&&!Ve[Ut(r)])try{e.removeAttribute(r)}catch(e){}}},Kt=function(e){let t=null,n=null;if(ut)e="<remove></remove>"+e;else{const t=S(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Pt&&vt===Rt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=_e?ve(e):e;if(vt===Rt)try{t=(new L).parseFromString(o,Pt)}catch(e){}if(!t||!t.documentElement){t=ke.createDocument(vt,"template",null);try{t.documentElement.innerHTML=It?Oe:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),vt===Rt?Pe.call(t,ct?"html":"body")[0]:ct?t.documentElement:i},Vt=function(e){return Le.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Zt=function(e){var t,n;e.normalize();const o=Le.call(e.ownerDocument||e,e,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null);let r=o.nextNode();for(;r;){let e=r.data;m([Fe,He,Be],t=>{e=E(e,t," ")}),r.data=e,r=o.nextNode()}const i=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];m(Array.from(i),e=>{Qt(e.content)&&Zt(e.content)})},Jt=function(e){const t=Ee?Ee(e):null;return"string"==typeof t&&("form"===Ut(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Ae(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==Se(e)||e.childNodes!==ye(e)))},Qt=function(e){if(!Se||"object"!=typeof e||null===e)return!1;try{return Se(e)===fe}catch(e){return!1}},en=function(e){if(!Se||"object"!=typeof e||null===e)return!1;try{return"number"==typeof Se(e)}catch(e){return!1}};function tn(e,t,n){m(e,e=>{e.call(o,t,n,Ft)})}const nn=function(e){let t=null;if(tn(Ue.beforeSanitizeElements,e,null),Jt(e))return Yt(e),!0;const n=Ut(Ee?Ee(e):e.nodeName);if(tn(Ue.uponSanitizeElement,e,{tagName:n,allowedTags:$e}),lt&&e.hasChildNodes()&&!en(e.firstElementChild)&&C(/<[/\w!]/g,e.innerHTML)&&C(/<[/\w!]/g,e.textContent))return Yt(e),!0;if(lt&&e.namespaceURI===Rt&&"style"===n&&en(e.firstElementChild))return Yt(e),!0;if(e.nodeType===ce)return Yt(e),!0;if(lt&&e.nodeType===se&&C(/<[/\w]/g,e.data))return Yt(e),!0;if(Qe[n]||!(tt.tagCheck instanceof Function&&tt.tagCheck(n))&&!$e[n]){if(!Qe[n]&&an(n)){if(Je.tagNameCheck instanceof RegExp&&C(Je.tagNameCheck,n))return!1;if(Je.tagNameCheck instanceof Function&&Je.tagNameCheck(n))return!1}if(yt&&!At[n]){const t=Te(e),n=ye(e);if(n&&t){for(let o=n.length-1;o>=0;--o){const r=Tt?n[o]:de(n[o],!0);t.insertBefore(r,ge(e))}}}return Yt(e),!0}return((Se?Se(e):e.nodeType)!==ae||function(e){let t=Te(e);t&&t.tagName||(t={namespaceURI:vt,tagName:"template"});const n=b(e.tagName),o=b(t.tagName);return!!Ct[e.namespaceURI]&&(e.namespaceURI===Dt?t.namespaceURI===Rt?"svg"===n:t.namespaceURI===wt?"svg"===n&&("annotation-xml"===o||kt[o]):Boolean(Gt[n]):e.namespaceURI===wt?t.namespaceURI===Rt?"math"===n:t.namespaceURI===Dt?"math"===n&&Lt[o]:Boolean(Wt[n]):e.namespaceURI===Rt?!(t.namespaceURI===Dt&&!Lt[o])&&!(t.namespaceURI===wt&&!kt[o])&&!Wt[n]&&(Mt[n]||!Gt[n]):!("application/xhtml+xml"!==Pt||!Ct[e.namespaceURI]))}(e))&&("noscript"!==n&&"noembed"!==n&&"noframes"!==n||!C(/<\/no(script|embed|frames)/i,e.innerHTML))?(at&&e.nodeType===le&&(t=e.textContent,m([Fe,He,Be],e=>{t=E(t,e," ")}),e.textContent!==t&&(g(o.removed,{element:e.cloneNode()}),e.textContent=t)),tn(Ue.afterSanitizeElements,e,null),!1):(Yt(e),!0)},on=function(e,t,n){if(et[t])return!1;if(dt&&("id"===t||"name"===t)&&(n in r||n in Ht))return!1;const o=Ve[t]||tt.attributeCheck instanceof Function&&tt.attributeCheck(t,e);if(ot&&!et[t]&&C(je,t));else if(nt&&C(Ge,t));else if(!o||et[t]){if(!(an(e)&&(Je.tagNameCheck instanceof RegExp&&C(Je.tagNameCheck,e)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(e))&&(Je.attributeNameCheck instanceof RegExp&&C(Je.attributeNameCheck,t)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(t,e))||"is"===t&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&C(Je.tagNameCheck,n)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(n))))return!1}else if(Nt[t]);else if(C(Xe,E(n,Ye,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!Et[e]){if(rt&&!C(We,E(n,Ye,"")));else if(n)return!1}else;return!0},rn=M({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),an=function(e){return!rn[b(e)]&&C(qe,e)},ln=function(e){tn(Ue.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Jt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ve,forceKeepAttr:void 0};let r=t.length;for(;r--;){const i=t[r],a=i.name,l=i.namespaceURI,c=i.value,s=Ut(a),u=c;let f="value"===a?u:N(u);if(n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,tn(Ue.uponSanitizeAttribute,e,n),f=n.attrValue,!ht||"id"!==s&&"name"!==s||0===_(f,gt)||(Xt(a,e),f=gt+f),lt&&C(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){Xt(a,e);continue}if("attributename"===s&&S(f,"href")){Xt(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){Xt(a,e);continue}if(!it&&C(/\/>/i,f)){Xt(a,e);continue}at&&m([Fe,He,Be],e=>{f=E(f,e," ")});const p=Ut(e.nodeName);if(on(p,s,f)){if(_e&&"object"==typeof P&&"function"==typeof P.getAttributeType)if(l);else switch(P.getAttributeType(p,s)){case"TrustedHTML":f=ve(f);break;case"TrustedScriptURL":f=Ie(f)}if(f!==u)try{l?e.setAttributeNS(l,a,f):e.setAttribute(a,f),Jt(e)?Yt(e):h(o.removed)}catch(t){Xt(a,e)}}else Xt(a,e)}tn(Ue.afterSanitizeAttributes,e,null)},cn=function(e){let t=null;const n=Vt(e);for(tn(Ue.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){tn(Ue.uponSanitizeShadowNode,t,null),nn(t),ln(t),Qt(t.content)&&cn(t.content);if((Se?Se(t):t.nodeType)===ae){const e=be?be(t):t.shadowRoot;Qt(e)&&(sn(e),cn(e))}}tn(Ue.afterSanitizeShadowDOM,e,null)},sn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){cn(e.shadow);continue}const n=e.node,o=(Se?Se(n):n.nodeType)===ae,r=ye?ye(n):n.childNodes;if(r)for(let e=r.length-1;e>=0;--e)t.push({node:r[e],shadow:null});if(o){const e=Ee?Ee(n):null;if("string"==typeof e&&"template"===Ut(e)){const e=n.content;Qt(e)&&t.push({node:e,shadow:null})}}if(o){const e=be?be(n):n.shadowRoot;Qt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,a=null,l=null;if(It=!e,It&&(e="\x3c!--\x3e"),"string"!=typeof e&&!en(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return O(e);case"boolean":return w(e);case"bigint":return D?D(e):"0";case"symbol":return R?R(e):"Symbol()";case"undefined":default:return I(e);case"function":case"object":{if(null===e)return I(e);const t=e,n=U(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:I(e)}return I(e)}}}(e)))throw x("dirty is not a string, aborting");if(!o.isSupported)return e;st||jt(t),o.removed=[];const c=Tt&&"string"!=typeof e&&en(e);if(c){const t=Ee?Ee(e):e.nodeName;if("string"==typeof t){const e=Ut(t);if(!$e[e]||Qe[e])throw x("root node is forbidden and cannot be sanitized in-place")}if(Jt(e))throw x("root node is clobbered and cannot be sanitized in-place");try{sn(e)}catch(t){throw qt(e),t}}else if(en(e))n=Kt("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===ae&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),sn(r);else{if(!ft&&!at&&!ct&&-1===e.indexOf("<"))return _e&&mt?ve(e):e;if(n=Kt(e),!n)return ft?null:mt?Oe:""}n&&ut&&Yt(n.firstChild);const s=Vt(c?e:n);try{for(;a=s.nextNode();)nn(a),ln(a),Qt(a.content)&&cn(a.content)}catch(t){throw c&&qt(e),t}if(c)return m(o.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();(Se?Se(e):e.nodeType)===ae&&$t(e);const n=ye?ye(e):e.childNodes;if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e.element)}),at&&Zt(e),e;if(ft){if(at&&Zt(n),pt)for(l=Me.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(Ve.shadowroot||Ve.shadowrootmode)&&(l=ze.call(i,l,!0)),l}let u=ct?n.outerHTML:n.innerHTML;return ct&&$e["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&C(re,n.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+u),at&&m([Fe,He,Be],e=>{u=E(u,e," ")}),_e&&mt?ve(u):u},o.setConfig=function(){jt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),st=!0},o.clearConfig=function(){Ft=null,st=!1,_e=Ne,Oe=""},o.isValidAttribute=function(e,t,n){Ft||jt({});const o=Ut(e),r=Ut(t);return on(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&g(Ue[e],t)},o.removeHook=function(e,t){if(void 0!==t){const n=d(Ue[e],t);return-1===n?void 0:y(Ue[e],n,1)[0]}return h(Ue[e])},o.removeHooks=function(e){Ue[e]=[]},o.removeAllHooks=function(){Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();return me});
//# sourceMappingURL=purify.min.js.map