url-sanitizer 5.3.6 → 5.3.7

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.
@@ -1,6 +1,6 @@
1
1
  var Pt="http://dummy.local",Ce={allow:Object.freeze([]),deny:Object.freeze([]),only:null,allowRelative:!1,debug:!1,revokeObjectURL:!1,maxBlobSize:16777216,maxLength:65536,schemes:new Set};var ye=o=>Object.prototype.toString.call(o).slice(8,-1),R=o=>typeof o=="string"||o instanceof String,X=(o,t)=>{console.warn(`[URLSanitizer Debug] ${o}`,t)};function ao(o,t){this.v=o,this.k=t}function Un(o,t){(t==null||t>o.length)&&(t=o.length);for(var n=0,s=Array(t);n<t;n++)s[n]=o[n];return s}function co(o){if(Array.isArray(o))return o}function lo(o,t){var n=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(n!=null){var s,i,u,f,d=[],p=!0,g=!1;try{if(u=(n=n.call(o)).next,t===0){if(Object(n)!==n)return;p=!1}else for(;!(p=(s=u.call(n)).done)&&(d.push(s.value),d.length!==t);p=!0);}catch(E){g=!0,i=E}finally{try{if(!p&&n.return!=null&&(f=n.return(),Object(f)!==f))return}finally{if(g)throw i}}return d}}function uo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fo(o,t){return co(o)||lo(o,t)||po(o,t)||uo()}function po(o,t){if(o){if(typeof o=="string")return Un(o,t);var n={}.toString.call(o).slice(8,-1);return n==="Object"&&o.constructor&&(n=o.constructor.name),n==="Map"||n==="Set"?Array.from(o):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Un(o,t):void 0}}function Ze(o){var t,n;function s(u,f){try{var d=o[u](f),p=d.value,g=p instanceof ao;Promise.resolve(g?p.v:p).then(function(E){if(g){var x=u==="return"&&p.k?u:"next";if(!p.k||E.done)return s(x,E);E=o[x](E).value}i(!!d.done,E)},function(E){s("throw",E)})}catch(E){i(2,E)}}function i(u,f){u===2?t.reject(f):t.resolve({value:f,done:u}),(t=t.next)?s(t.key,t.arg):n=null}this._invoke=function(u,f){return new Promise(function(d,p){var g={key:u,arg:f,resolve:d,reject:p,next:null};n?n=n.next=g:(t=n=g,s(u,f))})},typeof o.return!="function"&&(this.return=void 0)}Ze.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Ze.prototype.next=function(o){return this._invoke("next",o)},Ze.prototype.throw=function(o){return this._invoke("throw",o)},Ze.prototype.return=function(o){return this._invoke("return",o)};var qn=Object.entries,Mn=Object.setPrototypeOf,mo=Object.isFrozen,Kn=Object.getPrototypeOf,Zn=Object.getOwnPropertyDescriptor,N=Object.freeze,v=Object.seal,be=Object.create,Qn=typeof Reflect<"u"&&Reflect,Yt=Qn.apply,Vt=Qn.construct;N||(N=function(t){return t});v||(v=function(t){return t});Yt||(Yt=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),u=2;u<s;u++)i[u-2]=arguments[u];return t.apply(n,i)});Vt||(Vt=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});var K=S(Array.prototype.forEach);Array.prototype.indexOf;var ho=S(Array.prototype.lastIndexOf),Pn=S(Array.prototype.pop),De=S(Array.prototype.push),go=S(Array.prototype.slice),_o=S(Array.prototype.splice),Ae=Array.isArray,kt=Jn(Set),zt=S(Set.prototype.add),Ue=S(Set.prototype.has),ce=S(String.prototype.toLowerCase),Ft=S(String.prototype.toString),kn=S(String.prototype.match),Me=S(String.prototype.replace),zn=S(String.prototype.indexOf),Eo=S(String.prototype.trim),To=S(Number.prototype.toString),yo=S(Boolean.prototype.toString),Fn=typeof BigInt>"u"?null:S(BigInt.prototype.toString),Gn=typeof Symbol>"u"?null:S(Symbol.prototype.toString),k=S(Object.prototype.hasOwnProperty),Pe=S(Object.prototype.toString),I=S(RegExp.prototype.test),Z=Jn(TypeError);function S(o){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Yt(o,t,s)}}function Jn(o){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Vt(o,n)}}function T(o,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ce;if(Mn&&Mn(o,null),!Ae(t))return o;let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){let u=n(i);u!==i&&(mo(t)||(t[s]=u),i=u)}o[i]=!0}return o}function bo(o){for(let t=0;t<o.length;t++)k(o,t)||(o[t]=null);return o}function z(o){let t=be(null);for(let s of qn(o)){var n=fo(s,2);let i=n[0],u=n[1];k(o,i)&&(Ae(u)?t[i]=bo(u):u&&typeof u=="object"&&u.constructor===Object?t[i]=z(u):t[i]=u)}return t}function Ao(o){switch(typeof o){case"string":return o;case"number":return To(o);case"boolean":return yo(o);case"bigint":return Fn?Fn(o):"0";case"symbol":return Gn?Gn(o):"Symbol()";case"undefined":return Pe(o);case"function":case"object":{if(o===null)return Pe(o);let t=o,n=G(t,"toString");if(typeof n=="function"){let s=n(t);return typeof s=="string"?s:Pe(s)}return Pe(o)}default:return Pe(o)}}function G(o,t){for(;o!==null;){let s=Zn(o,t);if(s){if(s.get)return S(s.get);if(typeof s.value=="function")return S(s.value)}o=Kn(o)}function n(){return null}return n}function Ro(o,t){for(;o!==null;){let n=Zn(o,t);if(n)return n.get?S(n.get):null;o=Kn(o)}return null}function So(o){try{return I(o,""),!0}catch{return!1}}var Bn=N(["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"]),Gt=N(["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"]),Bt=N(["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"]),wo=N(["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"]),Ht=N(["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"]),xo=N(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hn=N(["#text"]),$n=N(["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"]),$t=N(["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","dominant-baseline","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","pointer-events","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-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","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"]),jn=N(["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"]),Qe=N(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Lo=v(/{{[\w\W]*|^[\w\W]*}}/g),Oo=v(/<%[\w\W]*|^[\w\W]*%>/g),No=v(/\${[\w\W]*/g),Io=v(/^data-[\-\w.\u00B7-\uFFFF]+$/),vo=v(/^aria-[\-\w]+$/),Wn=v(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Co=v(/^(?:\w+script|data):/i),Do=v(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Uo=v(/^html$/i),Mo=v(/^[a-z][.\w]*(-[.\w]+)+$/i),jt=v(/<[/\w!]/g),Yn=v(/<[/\w]/g),Po=v(/<\/no(script|embed|frames)/i),Vn=v(/\/>/i),L={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ko=N(T({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),zo=function(){return typeof window>"u"?null:window},Fo=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));let u="dompurify"+(s?"#"+s:"");try{return t.createPolicy(u,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+u+" could not be created."),null}},Xn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},te=function(t,n,s,i){return k(t,n)&&Ae(t[n])?T(i.base?z(i.base):{},t[n],i.transform):s},Wt=function(t,n,s){let i=k(t,n)?t[n]:void 0;return i&&typeof i=="object"?z(i):s()};function er(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:zo(),t=l=>er(l);if(t.version="3.4.17",t.removed=[],!o||!o.document||o.document.nodeType!==L.document||!o.Element)return t.isSupported=!1,t;let n=o.document,s=n,i=s.currentScript;o.DocumentFragment;let u=o.HTMLTemplateElement,f=o.Node,d=o.Element,p=o.NodeFilter;o.NamedNodeMap===void 0&&(o.NamedNodeMap||o.MozNamedAttrMap),o.HTMLFormElement;let g=o.DOMParser,E=o.trustedTypes,x=d.prototype,j=G(x,"cloneNode"),ct=G(x,"remove"),Jt=G(x,"removeAttributeNode"),xr=G(x,"nextSibling"),we=G(x,"childNodes"),ue=G(x,"parentNode"),lt=G(x,"shadowRoot"),ut=G(x,"attributes"),ne=f&&f.prototype?G(f.prototype,"nodeType"):null,fe=f&&f.prototype?G(f.prototype,"nodeName"):null,Ge=f&&f.prototype?G(f.prototype,"ownerDocument"):null,F=function(e){return ne?ne(e):e.nodeType},xe=function(e){return fe?fe(e):e.nodeName},en=Ro(x,"namespaceURI"),ft=function(e){return en?en(e):e.namespaceURI};if(typeof u=="function"){let l=n.createElement("template");l.content&&l.content.ownerDocument&&(n=l.content.ownerDocument)}let U,re="",pt,tn=!1,Le=0,nn=function(){if(Le>0)throw Z('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.')},pe=function(e){nn(),Le++;try{return U.createHTML(e)}finally{Le--}},Lr=function(e){nn(),Le++;try{return U.createScriptURL(e)}finally{Le--}},Or=function(){return tn||(pt=Fo(E,i),tn=!0),pt},Be=n,mt=Be.implementation,rn=Be.createNodeIterator,Nr=Be.createDocumentFragment,Ir=Be.getElementsByTagName,vr=s.importNode,y=Xn();t.isSupported=typeof qn=="function"&&typeof ue=="function"&&mt&&mt.createHTMLDocument!==void 0;let Cr=Lo,Dr=Oo,Ur=No,Mr=Io,Pr=vo,kr=Co,on=Do,zr=Mo,sn=Wn,b=null,dt=T({},[...Bn,...Gt,...Bt,...Ht,...Hn]),A=null,ht=T({},[...$n,...$t,...jn,...Qe]),W=Object.seal(be(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}})),Oe=null,an=null,Q=Object.seal(be(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),cn=!0,gt=!0,ln=!1,_t=!0,q=!1,oe=!0,se=!1,Et=!1,He=null,$e=null,Tt=!1,me=!1,je=!1,We=!1,un=!0,fn=!1,pn="user-content-",yt=!0,bt=!1,ie=null,de={},ae=null,mn=T({},["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"]),dn=null,hn=T({},["audio","video","img","source","image","track"]),gn=null,_n=T({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ye="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",Y="http://www.w3.org/1999/xhtml",he=Y,At=!1,Rt=null,Fr=T({},[Ye,Ve,Y],Ft),En=N(["mi","mo","mn","ms","mtext"]),St=T({},En),Tn=N(["annotation-xml"]),wt=T({},Tn),Gr=T({},["title","style","font","a","script"]),Ne=null,Br=["application/xhtml+xml","text/html"],Hr="text/html",w=null,ge=null,$r=n.createElement("form"),yn=function(e){return e instanceof RegExp||e instanceof Function},xt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ge&&ge===e)return;(!e||typeof e!="object")&&(e={}),e=z(e),Ne=Br.indexOf(e.PARSER_MEDIA_TYPE)===-1?Hr:e.PARSER_MEDIA_TYPE,w=Ne==="application/xhtml+xml"?Ft:ce,b=te(e,"ALLOWED_TAGS",dt,{transform:w}),A=te(e,"ALLOWED_ATTR",ht,{transform:w}),Rt=te(e,"ALLOWED_NAMESPACES",Fr,{transform:Ft}),gn=te(e,"ADD_URI_SAFE_ATTR",_n,{transform:w,base:_n}),dn=te(e,"ADD_DATA_URI_TAGS",hn,{transform:w,base:hn}),ae=te(e,"FORBID_CONTENTS",mn,{transform:w}),Oe=te(e,"FORBID_TAGS",z({}),{transform:w}),an=te(e,"FORBID_ATTR",z({}),{transform:w}),de=k(e,"USE_PROFILES")?e.USE_PROFILES&&typeof e.USE_PROFILES=="object"?z(e.USE_PROFILES):e.USE_PROFILES:!1,cn=e.ALLOW_ARIA_ATTR!==!1,gt=e.ALLOW_DATA_ATTR!==!1,ln=e.ALLOW_UNKNOWN_PROTOCOLS||!1,_t=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=e.SAFE_FOR_TEMPLATES||!1,oe=e.SAFE_FOR_XML!==!1,se=e.WHOLE_DOCUMENT||!1,me=e.RETURN_DOM||!1,je=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,Tt=e.FORCE_BODY||!1,un=e.SANITIZE_DOM!==!1,fn=e.SANITIZE_NAMED_PROPS||!1,yt=e.KEEP_CONTENT!==!1,bt=e.IN_PLACE||!1,sn=So(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Wn,he=typeof e.NAMESPACE=="string"?e.NAMESPACE:Y,St=Wt(e,"MATHML_TEXT_INTEGRATION_POINTS",()=>T({},En)),wt=Wt(e,"HTML_INTEGRATION_POINTS",()=>T({},Tn));let r=Wt(e,"CUSTOM_ELEMENT_HANDLING",()=>be(null));if(W=be(null),k(r,"tagNameCheck")&&yn(r.tagNameCheck)&&(W.tagNameCheck=r.tagNameCheck),k(r,"attributeNameCheck")&&yn(r.attributeNameCheck)&&(W.attributeNameCheck=r.attributeNameCheck),k(r,"allowCustomizedBuiltInElements")&&typeof r.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=r.allowCustomizedBuiltInElements),v(W),q&&(gt=!1),je&&(me=!0),de&&(b=T({},Hn),A=be(null),de.html===!0&&(T(b,Bn),T(A,$n)),de.svg===!0&&(T(b,Gt),T(A,$t),T(A,Qe)),de.svgFilters===!0&&(T(b,Bt),T(A,$t),T(A,Qe)),de.mathMl===!0&&(T(b,Ht),T(A,jn),T(A,Qe))),Q.tagCheck=null,Q.attributeCheck=null,k(e,"ADD_TAGS")&&(typeof e.ADD_TAGS=="function"?Q.tagCheck=e.ADD_TAGS:Ae(e.ADD_TAGS)&&(b===dt&&(b=z(b)),T(b,e.ADD_TAGS,w))),k(e,"ADD_ATTR")&&(typeof e.ADD_ATTR=="function"?Q.attributeCheck=e.ADD_ATTR:Ae(e.ADD_ATTR)&&(A===ht&&(A=z(A)),T(A,e.ADD_ATTR,w))),k(e,"ADD_FORBID_CONTENTS")&&Ae(e.ADD_FORBID_CONTENTS)&&(ae===mn&&(ae=z(ae)),T(ae,e.ADD_FORBID_CONTENTS,w)),yt&&(b["#text"]=!0),se&&T(b,["html","head","body"]),b.table&&(T(b,["tbody"]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let a=U;U=e.TRUSTED_TYPES_POLICY;try{re=pe("")}catch(c){throw U=a,c}}else e.TRUSTED_TYPES_POLICY===null?(U=void 0,re=""):(U===void 0&&(U=Or()),U&&typeof re=="string"&&(re=pe("")));N&&N(e),ge=e},bn=T({},[...Gt,...Bt,...wo]),An=T({},[...Ht,...xo]),jr=function(e,r,a){return r.namespaceURI===Y?e==="svg":r.namespaceURI===Ye?e==="svg"&&(a==="annotation-xml"||St[a]):!!bn[e]},Wr=function(e,r,a){return r.namespaceURI===Y?e==="math":r.namespaceURI===Ve?e==="math"&&wt[a]:!!An[e]},Yr=function(e,r,a){return r.namespaceURI===Ve&&!wt[a]||r.namespaceURI===Ye&&!St[a]?!1:!An[e]&&(Gr[e]||!bn[e])},Vr=function(e){let r=ft(e),a=ce(xe(e)),c=ue(e),m,h;return c&&F(c)===L.element?(m={namespaceURI:ft(c)},h=ce(xe(c))):(m={namespaceURI:he},h="template"),Rt[r]?r===Ve?jr(a,m,h):r===Ye?Wr(a,m,h):r===Y?Yr(a,m,h):!!(Ne==="application/xhtml+xml"&&Rt[r]):!1},J=function(e){De(t.removed,{element:e});try{ue(e).removeChild(e)}catch{if(ct(e),!ue(e))throw Z("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Rn=function(e,r,a){try{Jt(e,r)}catch{try{e.removeAttribute(a)}catch{}}},Lt=function(e){Nt(e);let r=we(e);r&&K(go(r),c=>{try{ct(c)}catch{}});let a=F(e)===L.element?ut(e):null;if(a)for(let c=a.length-1;c>=0;--c){let m=a[c],h=m&&m.name;typeof h=="string"&&Rn(e,m,h)}},_e=function(e,r,a){if(!a)try{a=r.getAttributeNode(e)}catch{a=null}De(t.removed,{attribute:a||null,from:r});try{a?Jt(r,a):r.removeAttribute(e)}catch{try{r.removeAttribute(e)}catch{}}if(e==="is")if(me||je)try{J(r)}catch{}else try{r.setAttribute(e,"")}catch{}},Sn=function(e){let r=ut(e);if(r)for(let a=r.length-1;a>=0;--a){let c=r[a],m=c&&c.name;typeof m!="string"||A[w(m)]||Rn(e,c,m)}},Ot=function(e,r){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,c=[e];for(;c.length>0;){let m=c.pop();if(r(m)===!1)continue;if(a&&F(m)===L.element){let _=lt(m);ee(_)&&c.push(_)}let h=we(m);if(h)for(let _=h.length-1;_>=0;--_)c.push(h[_])}},Nt=function(e){Ot(e,r=>{F(r)===L.element&&Sn(r)})},It=function(e){let r=[];return Ot(e,a=>{r.push(a)},!0),r},Xr=function(e,r){let a=kt();K(It(e),c=>{F(c)===L.element&&zt(a,c)}),K(r,c=>{F(c)===L.element&&!Ue(a,c)&&Sn(c)})},wn=function(e,r){let a=!1;return K(t.removed,c=>{c.element&&(a=a||c.element===e,Nt(c.element))}),Xr(e,r),a},qr=8,Kr=function(e,r){let a=ie,c=null,m=()=>(c||(c=kt(),K(r,h=>{zt(c,h)})),c);for(let h=0;;h++){let _=It(e),O=[e],V=!1;if(K(_,C=>{F(C)===L.documentFragment?De(O,C):!V&&!Ue(a,C)&&(V=Ue(m(),C))}),!V)return;if(h>=qr)throw Z("the tree kept changing during in-place sanitization; refusing to return it");K(O,(C,M)=>{Zr(C,M>0,e,m())})}},Zr=function(e,r,a,c){let m=vt(e),h;for(;h=m.nextNode();)!Ue(c,h)||Ue(ie,h)||(r&&H(y.uponSanitizeShadowNode,h,null),Dt(h,a),Ut(h,a),ee(h.content)&&ve(h.content))},Qr=function(e){ie&&zt(ie,e)},xn=function(e,r){return oe?e==="patchsrc"?!0:e==="for"&&r!=="label"&&r!=="output":!1},Jr=function(e){oe&&Ot(e,r=>{let a=F(r);if(a===L.processingInstruction||a===L.comment&&I(Yn,r.data)){try{ct(r)}catch{}return!1}if(a===L.element){let c=r,m=w(xe(r));try{c.hasAttribute&&c.hasAttribute("patchsrc")&&c.removeAttribute("patchsrc"),c.hasAttribute&&c.hasAttribute("for")&&xn("for",m)&&c.removeAttribute("for")}catch{}}return!0})},Ln=function(e){let r=null,a=null;if(Tt)e="<remove></remove>"+e;else{let h=kn(e,/^[\r\n\t ]+/);a=h&&h[0]}Ne==="application/xhtml+xml"&&he===Y&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let c=U?pe(e):e;if(he===Y)try{r=new g().parseFromString(c,Ne)}catch{}if(!r||!r.documentElement){r=mt.createDocument(he,"template",null);try{r.documentElement.innerHTML=At?re:c}catch{}}let m=r.body||r.documentElement;return e&&a&&m.insertBefore(n.createTextNode(a),m.childNodes[0]||null),he===Y?Ir.call(r,se?"html":"body")[0]:se?r.documentElement:m},vt=function(e){let r=Ge?Ge(e):e.ownerDocument;return rn.call(r||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Xe=function(e){return e=Me(e,Cr," "),e=Me(e,Dr," "),e=Me(e,Ur," "),e},Ct=function(e){var r;On(e);let a=(r=e.querySelectorAll)===null||r===void 0?void 0:r.call(e,"template");a&&K(a,c=>{ee(c.content)&&Ct(c.content)})},On=function(e){e.normalize();let r=Ge?Ge(e):e.ownerDocument,a=rn.call(r||e,e,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null),c=a.nextNode();for(;c;)c.data=Xe(c.data),c=a.nextNode()},qe=function(e){let r=fe?fe(e):null;return typeof r!="string"||w(r)!=="form"?!1:typeof e.nodeName!="string"||typeof e.textContent!="string"||typeof e.removeChild!="function"||e.attributes!==ut(e)||typeof e.removeAttribute!="function"||typeof e.removeAttributeNode!="function"||typeof e.getAttributeNode!="function"||typeof e.setAttribute!="function"||typeof e.namespaceURI!="string"||typeof e.insertBefore!="function"||typeof e.hasChildNodes!="function"||e.nodeType!==ne(e)||e.childNodes!==we(e)},ee=function(e){if(!ne||typeof e!="object"||e===null)return!1;try{return ne(e)===L.documentFragment}catch{return!1}},Ie=function(e){if(!ne||typeof e!="object"||e===null)return!1;try{return typeof ne(e)=="number"}catch{return!1}};function H(l,e,r){l.length!==0&&K(l,a=>{a.call(t,e,r,ge)})}let eo=function(e,r){return!!(oe&&e.hasChildNodes()&&!Ie(e.firstElementChild)&&I(jt,e.textContent)&&I(jt,e.innerHTML)||oe&&ko[r]&&F(e)===L.element&&ft(e)===Y&&(Ie(e.firstElementChild)||typeof e.textContent=="string"&&I(jt,e.textContent))||e.nodeType===L.processingInstruction||oe&&e.nodeType===L.comment&&I(Yn,e.data))},Ke=function(e,r){if(e instanceof RegExp)return I(e,r);if(e instanceof Function){for(var a=arguments.length,c=new Array(a>2?a-2:0),m=2;m<a;m++)c[m-2]=arguments[m];return!!e(r,...c)}return!1},to=function(e,r,a){if(!Oe[r]&&vn(r)&&Ke(W.tagNameCheck,r))return!1;if(yt&&!ae[r]&&!ae[ce(r)]){let c=ue(e),m=we(e);if(m&&c){let h=m.length;for(let _=h-1;_>=0;--_){let O=e===a?j(m[_],!0):m[_];c.insertBefore(O,xr(e))}}}return J(e),!0},Nn=function(e,r,a,c){return e.length===0?r:r===a||r===c?z(r):r},Ee=function(e,r){return e===r||ue(e)!==null?!1:(bt&&Nt(e),!0)},Dt=function(e,r){if(Qr(e),H(y.beforeSanitizeElements,e,null),Ee(e,r))return!0;if(qe(e))return J(e),!0;let a=w(xe(e));if(b=Nn(y.uponSanitizeElement,b,dt,He),H(y.uponSanitizeElement,e,{tagName:a,allowedTags:b}),Ee(e,r))return!0;if(eo(e,a))return J(e),!0;if(Oe[a]||!(Q.tagCheck instanceof Function&&Q.tagCheck(a))&&!b[a]){let c=to(e,a,r);return c===!1&&(H(y.afterSanitizeElements,e,null),Ee(e,r))?!0:c}if(F(e)===L.element&&!Vr(e)||(a==="noscript"||a==="noembed"||a==="noframes")&&I(Po,e.innerHTML))return J(e),!0;if(q&&e.nodeType===L.text){let c=Xe(e.textContent);e.textContent!==c&&(De(t.removed,{element:e.cloneNode()}),e.textContent=c)}return H(y.afterSanitizeElements,e,null),Ee(e,r)},In=function(e,r,a){if(an[r]||xn(r,e)||un&&(r==="id"||r==="name")&&(a in n||a in $r))return!1;let c=A[r]||Q.attributeCheck instanceof Function&&Q.attributeCheck(r,e);return gt&&I(Mr,r)||cn&&I(Pr,r)?!0:c?gn[r]||I(sn,Me(a,on,""))||(r==="src"||r==="xlink:href"||r==="href")&&e!=="script"&&zn(a,"data:")===0&&dn[e]||ln&&!I(kr,Me(a,on,""))?!0:!a:vn(e)&&Ke(W.tagNameCheck,e)&&Ke(W.attributeNameCheck,r,e)||r==="is"&&W.allowCustomizedBuiltInElements&&Ke(W.tagNameCheck,a)},no=T({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vn=function(e){return!no[ce(e)]&&I(zr,e)},ro=function(e,r,a,c){if(U&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!a)switch(E.getAttributeType(e,r)){case"TrustedHTML":return pe(c);case"TrustedScriptURL":return Lr(c)}return c},oo=function(e,r,a,c){try{return a?e.setAttributeNS(a,r,c):e.setAttribute(r,c),qe(e)?(J(e),!1):!0}catch{return _e(r,e),!1}},Cn=function(e,r){return oe&&I(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,r)?!0:ce(e)==="attributename"&&kn(r,"href")!==null},Ut=function(e,r){if(H(y.beforeSanitizeAttributes,e,null),Ee(e,r))return;let a=e.attributes;if(!a||qe(e))return;A=Nn(y.uponSanitizeAttribute,A,ht,$e);let c={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0},m=a.length,h=w(e.nodeName);for(;m--;){let _=a[m],O=_.name,V=_.namespaceURI,C=_.value,M=w(O),Te=C,P=O==="value"?Te:Eo(Te),Dn=!1;if(c.attrName=M,c.attrValue=P,c.keepAttr=!0,c.forceKeepAttr=void 0,H(y.uponSanitizeAttribute,e,c),P=c.attrValue,fn&&(M==="id"||M==="name")&&zn(P,pn)!==0&&(_e(O,e,_),P=pn+P,Dn=!0),Cn(O,P)){_e(O,e,_);continue}if(!c.forceKeepAttr){if(!c.keepAttr){_e(O,e,_);continue}if(!_t&&I(Vn,P)){_e(O,e,_);continue}if(q&&(P=Xe(P)),!In(h,M,P)){_e(O,e,_);continue}P=ro(h,M,V,P),P!==Te&&oo(e,O,V,P)&&Dn&&Pn(t.removed)}}H(y.afterSanitizeAttributes,e,null),Ee(e,r)},ve=function(e){let r=null,a=vt(e);for(H(y.beforeSanitizeShadowDOM,e,null);r=a.nextNode();)if(H(y.uponSanitizeShadowNode,r,null),Dt(r,e),Ut(r,e),ee(r.content)&&ve(r.content),F(r)===L.element){let c=lt(r);ee(c)&&(Mt(c),ve(c))}q&&On(e),H(y.afterSanitizeShadowDOM,e,null)},Mt=function(e){let r=[{node:e,shadow:null}];for(;r.length>0;){let a=r.pop();if(a.shadow){ve(a.shadow);continue}let c=a.node,m=F(c)===L.element,h=we(c);if(h)for(let _=h.length-1;_>=0;--_)r.push({node:h[_],shadow:null});if(m){let _=fe?fe(c):null;if(typeof _=="string"&&w(_)==="template"){let O=c.content;ee(O)&&r.push({node:O,shadow:null})}}if(m){let _=lt(c);ee(_)&&r.push({node:null,shadow:_},{node:_,shadow:null})}}};return t.sanitize=function(l){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=null,a=null,c=null,m=null;if(At=!l,At&&(l="<!-->"),typeof l!="string"&&!Ie(l)&&(l=Ao(l),typeof l!="string"))throw Z("dirty is not a string, aborting");if(!t.isSupported)return l;Et?(b=He,A=$e):xt(e),(y.uponSanitizeElement.length>0||y.uponSanitizeAttribute.length>0)&&(b=z(b)),y.uponSanitizeAttribute.length>0&&(A=z(A)),t.removed=[];let h=bt&&typeof l!="string"&&Ie(l),_=[],O=ie;if(h){Jr(l);let M=xe(l);if(typeof M=="string"){let Te=w(M);if(!b[Te]||Oe[Te])throw Lt(l),Z("root node is forbidden and cannot be sanitized in-place")}if(qe(l))throw Lt(l),Z("root node is clobbered and cannot be sanitized in-place");_=It(l),ie=kt()}else if(Ie(l))r=Ln("<!---->"),a=r.ownerDocument.importNode(l,!0),a.nodeType===L.element&&a.nodeName==="BODY"||a.nodeName==="HTML"?r=a:r.appendChild(a),Mt(r);else{if(!me&&!q&&!se&&l.indexOf("<")===-1)return U&&We?pe(l):l;if(r=Ln(l),!r)return me?null:We?re:""}r&&Tt&&J(r.firstChild);let V=h?l:r;try{h&&Mt(l);let M=vt(V);for(;c=M.nextNode();)Dt(c,V),Ut(c,V),ee(c.content)&&ve(c.content);h&&Kr(l,_)}catch(M){throw h&&(Lt(l),wn(l,_)),M}finally{ie=O}if(h){if(wn(l,_))throw Z("a node selected for removal could not be safely returned; refusing to sanitize in place");return q&&Ct(l),l}if(me){if(q&&Ct(r),je)for(m=Nr.call(r.ownerDocument);r.firstChild;)m.appendChild(r.firstChild);else m=r;return(A.shadowroot||A.shadowrootmode)&&(m=vr.call(s,m,!0)),m}let C=se?r.outerHTML:r.innerHTML;return se&&b["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&I(Uo,r.ownerDocument.doctype.name)&&(C="<!DOCTYPE "+r.ownerDocument.doctype.name+`>
3
- `+C),q&&(C=Xe(C)),U&&We?pe(C):C},t.setConfig=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xt(l),Et=!0,He=b,$e=A},t.clearConfig=function(){ge=null,Et=!1,He=null,$e=null,U=pt,re=""},t.isValidAttribute=function(l,e,r){ge||xt({});let a=w(l),c=w(e);return typeof r=="string"&&(Cn(e,r)||!_t&&I(Vn,r))?!1:In(a,c,r)},t.addHook=function(l,e){typeof e=="function"&&k(y,l)&&De(y[l],e)},t.removeHook=function(l,e){if(k(y,l)){if(e!==void 0){let r=ho(y[l],e);return r===-1?void 0:_o(y[l],r,1)[0]}return Pn(y[l])}},t.removeHooks=function(l){k(y,l)&&(y[l]=[])},t.removeAllHooks=function(){y=Xn()},t}var tr=er();var Je=tr(globalThis.window);var nr=/&amp;/gi,rr=/&(?=[#a-z0-9])(?![a-z0-9]+=)/i;var or=/#$/,sr=/^(?:application\/(?:[\w.-]+\+)?xml|image\/svg\+xml|text\/(?:html|xml))(?:\s*;\s*|$)/i;var ir=/\P{ASCII}/u,ar=/&#(x0*[\dA-F]{1,2}|0*\d{1,3});?/gi,cr=/(?:%[\dA-F]{2})+/gi,lr=/^((?:[^#%]|%(?!23))*)\?$/,et=/^[a-z][\da-z+.-]*$/,ur=/^(?:web\+[a-z]+|ext\+[a-z][\da-z.-]*)$/,le=/^(?:java|vb)script$/i,ke=/^(?:(?:java|vb)script|blob)$/i,Xt=/["'<>]|%(?:22|27|3C|3E)|&(?:apos|lt|gt|quot|#0*(?:34|39|60|62)|#x0*(?:22|27|3C|3E));/i,fr=/^%[\dA-F]{2}$/i,pr=/^(?:\/{2,}|\\|[a-z][a-z\d+\-.]*:[^/])/i;var mr=[9,10,13,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];var qt=new Set(mr),Kt=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),Bo=()=>{let o=new Map;for(let t=0;t<256;t++)!qt.has(t)&&!Kt.has(t)&&o.set(t,`\\x${t.toString(16).padStart(2,"0").toUpperCase()}`);return o},Zt=Bo();var[Re,$o,jo,Wo,Yo,Vo]=["&","#","<",">",'"',"'"].map(o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Xo={[Re]:`${Re}amp;`,[jo]:`${Re}lt;`,[Wo]:`${Re}gt;`,[Yo]:`${Re}quot;`,[Vo]:`${Re}${$o}39;`},Es=Array.from({length:256},(o,t)=>`%${t.toString(16).padStart(2,"0").toUpperCase()}`),Er=globalThis.process?.versions?.node!==void 0,Tr=`[${[...Zt.values()].join("")}]`,qo=new RegExp(Tr),Ko=new RegExp(Tr,"g"),Zo=new Uint8Array(65536),Ts=new TextEncoder,Qo=new TextDecoder("utf-8",{fatal:!0}),D=(o,t=!1)=>{if(!R(o))return null;let n=ir.test(o)?o.normalize("NFKC"):o;return t?n.trim().toLowerCase().replace(/:$/,""):n},B=(o,t,n=!1)=>{if(!R(o)||o==="")return null;let s=o,i=t&&R(t)?t:"";if(n&&(s=D(s),i&&(i=D(i))),typeof URL.parse=="function")return i?URL.parse(s,i):URL.parse(s);try{return i?new URL(s,i):new URL(s)}catch{return null}},yr=o=>R(o)?o.replace(/:$/,"").split("+"):[];var br=o=>{if(!R(o))return o;let t=fr.test(o)?o.toUpperCase():o;return Xo[t]??o},$=o=>{let t=R(o)?o:String(o);return t.length>64?`${t.slice(0,64)}...`:t},Ar=o=>R(o)?o.replace(or,"").replace(lr,"$1"):o,Jo=(o,t)=>{let n=/^x/i.test(t)?Number.parseInt(t.slice(1),16):Number.parseInt(t,10);if(!Number.isInteger(n)||n<0||n>=256)return o;if(Zt.has(n))return"";if(qt.has(n))return String.fromCharCode(n);let s=Kt.get(n);return String.fromCodePoint(s)},Rr=(o,t=0)=>{if(!R(o))throw new TypeError(`Expected String but got ${ye(o)}.`);if(!Number.isInteger(t))throw new TypeError(`Expected Number but got ${ye(t)}.`);let n;try{n=decodeURIComponent(o)}catch{n=o.replace(cr,i=>{try{return decodeURIComponent(i)}catch{return i}})}n=n.replace(Ko,"");let s=0;for(;s+t<16;s++){let i=n;if(n=n.replace(nr,"&").replace(ar,Jo),n===i)break}if(s+t>=16&&/&#/.test(n))throw new Error("Character references nested too deeply.");return n},rt=(o,t="",n="")=>{if(!R(o))return{mediaType:"",mediaTypes:[],data:"",isBase64:!1};let s=o.indexOf(",");if(s===-1)return{mediaType:o,mediaTypes:o.split(";"),data:"",isBase64:!1};let i=o.substring(0,s),u=o.substring(s+1),f=t===""&&n===""?u:u+t+n,d=i.split(";"),p=d.at(-1),g=p!==void 0&&p.length===6&&p.toLowerCase()==="base64";return{mediaType:i,mediaTypes:d,data:f,isBase64:g}},Sr=o=>{if(!R(o))throw new TypeError(`Expected String but got ${ye(o)}.`);let t,n=o;try{t=atob(o)}catch{n=o.replace(/\s/g,"");try{t=atob(n)}catch{throw new Error(`Invalid base64 data: ${$(o)}`)}}let s;if(Er&&globalThis.Buffer)s=globalThis.Buffer.from(t,"latin1");else{let i=t.length;i>65536?s=new Uint8Array(i):s=Zo.subarray(0,i);for(let u=0;u<i;u++)s[u]=t.charCodeAt(u)}try{let i=Qo.decode(s);return qo.test(i)?n:i}catch{return n}},ot=o=>{if(Er&&globalThis.Buffer)return globalThis.Buffer.from(o).toString("base64");let t=new Uint8Array(o);if(typeof t.toBase64=="function")return t.toBase64();let n=[];for(let s=0;s<t.length;s+=8192)n.push(String.fromCharCode(...t.subarray(s,s+8192)));return btoa(n.join(""))},es=async(o,t,n)=>{let s=o.body.getReader(),i=[],u="Operation aborted";if(n?.aborted)throw await s.cancel(u),s.releaseLock(),n.reason;let f=()=>{s.cancel(u).catch(()=>{})};n?.addEventListener("abort",f,{once:!0});try{let d=0;for(;d<=t;){if(n?.aborted)throw await s.cancel(u),n.reason;let{done:E,value:x}=await s.read();if(n?.aborted)throw n.reason;if(E)break;if(d+=x.byteLength,d>t)throw await s.cancel("Size limit exceeded"),new DOMException(`Payload (${d} bytes) exceeds max (${t} bytes).`,"NotReadableError");i.push(x)}let p=new Uint8Array(d),g=0;for(let E of i)p.set(E,g),g+=E.byteLength;return p.buffer}finally{n?.removeEventListener("abort",f),s.releaseLock()}},Qt=async(o,t,n)=>{let s=16777216;Number.isInteger(t)&&t>0&&(s=t);let i=await fetch(o,{signal:n});if(!i.ok){let g=`Failed to fetch ${$(o)}`;throw Number.isInteger(i.status)&&(i.statusText?g+=`: ${i.status} ${i.statusText}`:g+=`: ${i.status}`),new Error(g)}let u=i.headers.get("content-length");if(u){let p=Number.parseInt(u,10);if(Number.isInteger(p)&&p>s)throw new DOMException(`Payload (${p} bytes) exceeds max (${s} bytes).`,"NotReadableError")}let f=i.headers.get("content-type")||"",d;if(i.body)d=await es(i,s,n);else{let p=await i.blob();if(p.size>s)throw new DOMException(`Payload (${p.size} bytes) exceeds max (${s} bytes).`,"NotReadableError");d=await p.arrayBuffer()}return{buffer:d,mimeType:f}};var Fe=class{constructor(t,n=Ce){this.domPurify=t,this.nest=0,this.recurse=new Set,this.restrictScheme=!1,this.schemeMap=new Map([["blob",!1],["data",!1],["file",!1],["javascript",!1],["vbscript",!1]]),this.#e(n)}#e(t){let{allowRelative:n,debug:s,allow:i,deny:u,only:f,schemes:d}=t;if(this.allowRelative=!!n,this.debug=!!s,this.schemes=d,Array.isArray(f)){this.restrictScheme=!0;for(let p of f)this.#t(p)}else{if(Array.isArray(i)&&i.length)for(let p of i)this.#t(p);if(Array.isArray(u)&&u.length)for(let p of u){let g=D(p,!0);g&&this.schemeMap.set(g,!1)}}}#t(t){let n=D(t,!0);return!n||ke.test(n)||!et.test(n)||n.includes("+")&&n.split("+").some(i=>le.test(i))?!1:(this.schemeMap.set(n,!0),!0)}enter(t){return this.recurse.has(t)?(this.debug&&X(`Circular Data URL detected and skipped: ${$(t)}`),!1):(this.nest++,this.recurse.add(t),!0)}leave(t){this.nest--,this.recurse.delete(t)}},st=class{#e;constructor(t=Ce){this.#e=t}#t(t,n){if(n.nest>16)throw new Error("Data URLs nested too deeply.");let s=B(t,null,!0);if(!s){if(n.allowRelative&&!pr.test(t)){let u=B(t,Pt);if(u){let{protocol:f,hostname:d,pathname:p,search:g,hash:E}=u;if(f==="http:"&&d==="dummy.local")return this.#o(`${p}${g}${E}`)}}return null}let i=D(s.protocol,!0);if(n.restrictScheme&&!n.schemeMap.has(i))return null;if(i.includes("+")){let u=i.split("+");if(n.schemeMap.get(i)===!1||u.some(f=>n.schemeMap.get(f)===!1))return null}else if(n.schemeMap.has(i)){if(n.schemeMap.get(i)===!1)return null}else if(!n.schemes.has(i))return null;return i==="data"?this.#n(s,n):this.#o(s.href)}#n(t,n){let{mediaType:s,mediaTypes:i,data:u,isBase64:f}=rt(t.pathname,t.search,t.hash),d=u;if(f)try{d=Sr(u)}catch(p){return n.debug&&X("Failed to parse base64 data.",p),null}try{let p=Rr(d).trim(),g=B(p,Pt);if(!g||yr(g.protocol).some(x=>ke.test(x)))return null}catch(p){return n.debug&&X("Failed to parse inner data URL protocol.",p),null}return(!s||sr.test(s))&&(d=this.#s(d,n)),d?(f&&d!==u&&i.pop(),`data:${i.join(";")},${d}`):null}#s(t,n){let s="";try{s=decodeURIComponent(t)}catch{s=t}let i=(f,d)=>this.#r(f,d,n),u="";try{n.domPurify.addHook("uponSanitizeAttribute",i),u=n.domPurify.sanitize(s)}finally{n.domPurify.removeHook("uponSanitizeAttribute",i)}if(!u)return null;try{return encodeURI(Ar(u))}catch{return null}}#r(t,n,s){if(!n.attrValue||!/^\s*data:/i.test(n.attrValue))return;let i=B(n.attrValue,null,!0);if(!i||i.protocol!=="data:")return;let u=n.attrValue;if(!s.enter(u)){n.attrValue="";return}try{let f=this.#t(u,s);n.attrValue=f||""}finally{s.leave(u)}}#o(t){let n=t.length,s=n,i=Xt.exec(t);if(i&&(s=i.index),t.indexOf("&")>-1){let f=rr.exec(t);if(f){let d=f.index;d<s&&(s=d)}}if(s===n)return t;let u=t.charCodeAt(s-1);return(u===63||u===38)&&s--,t.substring(0,s)}sanitize(t,n=this.#e){if(!t||!R(t))return null;let{deny:s,maxLength:i,only:u,allowRelative:f}=n;if(Number.isInteger(i)&&t.length>i){let g=`URL length ${t.length} exceeds max length ${i}.`;throw new RangeError(g)}if(!(Array.isArray(s)&&s.length>0||Array.isArray(u)||f)&&/^https?:\/\//.test(t)&&!Xt.test(t)&&!t.includes("data:")){let g=B(t,null,!0);return g&&n.schemes.has(g.protocol.replace(/:$/,""))?g.href.replace(/%26/g,br):null}let p=new Fe(Je,n);return this.#t(t,p)}async sanitizeBuffer(t,n,s=this.#e){if(!(t instanceof ArrayBuffer))return null;let i=ot(t),f=`data:${n?`${n};base64`:"base64"},${i}`;if(Number.isInteger(s.maxLength)&&f.length>s.maxLength)throw new RangeError(`URL length ${f.length} exceeds max length ${s.maxLength}.`);let d=new Fe(Je,s);if(!d.schemeMap.get("data"))return null;let p=B(f);return p?this.#n(p,d):null}async sanitizeDataURL(t,n=this.#e){if(!t||!R(t))return null;let{maxLength:s}=n;if(Number.isInteger(s)&&t.length>s)throw new RangeError(`URL length ${t.length} exceeds max length ${s}.`);let i=B(t);if(!i)return null;let u=D(i.protocol,!0);if(u!=="data")return null;let f=new Fe(Je,n);return f.schemeMap.get(u)?this.#n(i,f):null}};var wr=["aaa","aaas","about","acap","acct","acd","ace","aceap","acedp","aceep","acelp","aceup","acr","adiumxtra","adt","aet","afp","afs","agtp","aim","alter","amss","android","appdata","apt","ar","ari","ark","ars","arv","at","attachment","aw","barion","beshare","bitcoin","bitcoincash","bl","blob","bluetooth","bolo","brid","browserext","cabal","caip","calculator","callto","canactid","cap","cast","casts","chrome","chrome-extension","cid","cm","coap","coaps","com-eventbrite-attendee","content","content-type","crid","cstr","cttps","cvs","dab","dat","data","dav","dhttp","diaspora","dict","did","dilithium3","dis","dlna-playcontainer","dlna-playsingle","dnp","dns","dntp","doi","donau","dpp","drm","dtmi","dtn","dvb","dvx","dweb","ed2k","eid","elsi","embedded","ens","esim","ethereum","example","ez","facetime","feed","feedready","fido","file","finger","first-run-pen-experience","fish","fm","ftp","fuchsia-pkg","gcx","gdsi","geo","gg","git","gitoid","gizmoproject","go","gopher","graph","gsos","gtalk","h323","haie","ham","hcap","hcp","hs20","http","https","hxxp","hxxps","hydrazone","hyper","i0","iax","ibi","ibi-","icap","icon","ilstring","im","imap","info","interaction","iotdisco","ipfs","ipn","ipns","ipp","ipps","iqa","irc","irc6","ircs","iris","iris.beep","iris.lwz","iris.xpc","iris.xpcs","isostore","itms","jabber","jar","jms","keyparc","lastfm","lbry","ldap","ldaps","leaptofrogans","lid","linkid","locus","lorawan","lpa","lvlt","machineProvisioningProgressReporter","magnet","mailto","maps","market","matrix","mdoc","mdoc-openid4vp","message","microsoft.windows.camera","microsoft.windows.camera.multipicker","microsoft.windows.camera.picker","mid","mms","mongodb","moz","moz-extension","mqtt","mqtts","ms-access","ms-appinstaller","ms-browser-extension","ms-calculator","ms-drive-to","ms-enrollment","ms-excel","ms-eyecontrolspeech","ms-gamebarservices","ms-gamingoverlay","ms-getoffice","ms-help","ms-infopath","ms-inputapp","ms-launchremotedesktop","ms-lockscreencomponent-config","ms-media-stream-id","ms-meetnow","ms-mixedrealitycapture","ms-mobileplans","ms-newsandinterests","ms-officeapp","ms-people","ms-personacard","ms-powerpoint","ms-project","ms-publisher","ms-recall","ms-remotedesktop","ms-remotedesktop-launch","ms-restoretabcompanion","ms-screenclip","ms-screensketch","ms-search","ms-search-repair","ms-secondary-screen-controller","ms-secondary-screen-setup","ms-settings","ms-settings-airplanemode","ms-settings-bluetooth","ms-settings-camera","ms-settings-cellular","ms-settings-cloudstorage","ms-settings-connectabledevices","ms-settings-displays-topology","ms-settings-emailandaccounts","ms-settings-language","ms-settings-location","ms-settings-lock","ms-settings-nfctransactions","ms-settings-notifications","ms-settings-power","ms-settings-privacy","ms-settings-proximity","ms-settings-screenrotation","ms-settings-wifi","ms-settings-workplace","ms-spd","ms-stickers","ms-sttoverlay","ms-transit-to","ms-useractivityset","ms-uup","ms-virtualtouchpad","ms-visio","ms-walk-to","ms-whiteboard","ms-whiteboard-cmd","ms-widgetboard","ms-widgets","ms-word","msnim","msrp","msrps","mss","mt","mtqp","mtrust","mumble","mupdate","musik","mvn","mvrp","mvrps","news","nfs","ni","nih","nntp","nostr","notes","npamp","num","ocf","oid","onenote","onenote-cmd","opaquelocktoken","openid","openpgp4fpr","opns","ord","ordmail","otpauth","palm","paparazzi","payto","pkcs11","pkg","platform","pop","pres","proxy","psyc","pttp","pwid","qb","query","quic-transport","redis","rediss","reload","res","resource","rmi","rsync","rtmfp","rtmp","rtsp","rtsps","rtspu","rttp","sarif","secondlife","secret-token","seki","service","session","sftp","sgn","shc","shelter","sieve","simpleledger","simplex","sip","sips","skype","smb","smp","sms","smtp","snmp","sns","soap.beep","soap.beeps","soldat","spacify","spiffe","spotify","ssb","ssh","sss","starknet","steam","stun","stuns","submit","svn","swh","swid","swidpath","tag","taler","tcxp","teamspeak","teapot","teapots","tel","teliaeid","telnet","tftp","things","thismessage","tii","tip","tn3270","tool","tttps","turn","turns","tv","udp","unreal","upn","urn","ust","ut2004","uuaid","uuid-in-package","v-event","vemmi","ventrilo","ves","view-source","vnc","vscode","vscode-insiders","vsls","w3","wasm","wasm-js","wcr","web3","webcal","wifi","ws","wss","wtai","wyciwyg","xcompute","xcon","xcon-userid","xfire","xftp","xmlrpc.beep","xmlrpc.beeps","xmpp","xrcp","xri","ymsgr","z39.50r","z39.50s","ztdnaid"];var it=class{#e=new Set(wr);get(){return[...this.#e]}getScheme(t){if(!R(t))return null;let n=this.parse(t);return n?this.normalize(n.protocol,!0):null}has(t){let n=this.normalize(t,!0);return n?this.#e.has(n):!1}normalize(t,n=!1){return D(t,n)}normalizeSchemes(t){if(Array.isArray(t)){let n=[];for(let s of t){let i=D(s,!0);i&&n.push(i)}return n}return[]}parse(t,n,s=!1){return B(t,n,s)}verifyURI(t,n){if(!R(t))return!1;let s=this.parse(t);return s?this.verifyScheme(s.protocol,n,!0):!1}verifyScheme(t,n,s=!1){let i=this.normalize(t,!0);if(!i)return!1;let u=n||this.#e;if(!i.includes("+"))return le.test(i)?!1:u.has(i);let f=i.split("+");return f.some(p=>le.test(p))?!1:u.has(i)?!0:s&&ur.test(i)||f.every(p=>u.has(p))}};var ns=Object.freeze(["href","origin","protocol","username","password","host","hostname","port","pathname","search","hash"]),at=class extends it{#e;#t;#n;constructor(){super(),this.#e=new Set(super.get()),this.#t={...Ce,schemes:this.#e},this.#n=new st(this.#t)}#s(t){return!R(t)||ke.test(t)||t.includes("+")&&t.split("+").some(s=>le.test(s))?!1:et.test(t)}#r(t,n={}){if(!R(t)||t==="")return{isValid:!1};let s={...this.#t,...n,allow:this.normalizeSchemes(n.allow),deny:this.normalizeSchemes(n.deny),only:Object.hasOwn(n,"only")?this.normalizeSchemes(n.only):this.#t.only,schemes:this.#e},i=this.getScheme(t);return i===null&&!s.allowRelative?{isValid:!1}:{options:s,scheme:i}}#o(t,n){let s={input:t,href:null,valid:!1};if(!R(t))return s.reason=`Invalid URL input: ${$(t)}`,s;if(t==="")return s.reason="Invalid URL input: (empty string)",s;let i,u=null;try{i=this.#n.sanitize(t,n),i||(u="Sanitization failed (blocked by allowed schemes or rules).")}catch(f){u=f.message}if(i){let f=B(i);if(s.valid=!0,f){if(D(f.protocol,!0)==="data"){let{mediaTypes:p,data:g,isBase64:E}=rt(f.pathname,f.search,f.hash);E&&p.pop(),s.data={mime:p.join(";"),base64:E,data:g}}else s.data=null;for(let p of ns){let g=f[p];R(g)&&(s[p]=g)}}else s.valid=!1,s.relative=!0,s.href=i,s.reason="Invalid as an absolute URL, but valid as a relative URL."}else s.reason=u;return s}async#a(t,n){try{let{buffer:s,mimeType:i}=await Qt(t,n.maxBlobSize,n.signal),u=ot(s),f=`data:${i?`${i};base64`:"base64"},${u}`,d=this.#o(f,n);return d.input=t,d}catch(s){if(s.name==="AbortError"||n.signal?.aborted)throw s;return n.debug&&X(`Failed to inspect blob URL: ${$(t)}`,s),{input:t,valid:!1,reason:s.message}}finally{n.revokeObjectURL&&URL.revokeObjectURL(t)}}#i(t,n){if(t instanceof TypeError||t.name==="AbortError"||n.signal?.aborted)throw t}get(){return[...this.#e]}has(t){let n=D(t,!0);return n?this.#e.has(n):!1}add(t){if(!R(t))throw new TypeError(`Expected String but got ${ye(t)}.`);let n=D(t,!0);if(!this.#s(n))throw new Error(`Invalid scheme: ${t}`);return this.#e.add(n),[...this.#e]}remove(t){if(!R(t))return!1;let n=D(t,!0);return this.#e.delete(n)}reset(){this.#e.clear();for(let t of super.get())this.#e.add(t)}async sanitizeURL(t,n){let{isValid:s,options:i,scheme:u}=this.#r(t,n);if(s===!1)return null;if(u==="blob"){let{allow:f,deny:d,only:p}=i,g=null;try{if(f.includes("blob")&&!d.includes("blob")||Array.isArray(p)&&p.includes("blob")){let E=null,x="";try{let j=await Qt(t,i.maxBlobSize,i.signal);E=j.buffer,x=j.mimeType}catch(j){if(j.name==="AbortError"||i.signal?.aborted)throw j;i.debug&&X(`Failed to fetch and convert blob URL: ${$(t)}`,j)}E&&(p?.length?p.includes("data")||(i.only=[...p,"data"]):(f.includes("data")||(i.allow=[...f,"data"]),i.deny=d.filter(j=>j!=="data")),g=await this.#n.sanitizeBuffer(E,x,i))}}catch(E){return this.#i(E,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,E),null}finally{i.revokeObjectURL&&URL.revokeObjectURL(t)}return g}try{return u==="data"?this.#n.sanitizeDataURL(t,i):this.#n.sanitize(t,i)}catch(f){return this.#i(f,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,f),null}}sanitizeURLSync(t,n){let{isValid:s,options:i,scheme:u}=this.#r(t,n);if(s===!1)return null;if(u==="blob")return i.revokeObjectURL&&URL.revokeObjectURL(t),null;try{return this.#n.sanitize(t,i)}catch(f){return this.#i(f,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,f),null}}async inspectURL(t,n={}){let{options:s,scheme:i}=this.#r(t,n);return i==="blob"?this.#a(t,s):this.#o(t,s)}isValidURI(t){return super.verifyURI(t,this.#e)}};var Se=new at,Bs=async(o,t)=>Se.sanitizeURL(o,t),Hs=(o,t)=>Se.sanitizeURLSync(o,t),$s=async(o,t={})=>Se.inspectURL(o,t),js=o=>Se.isValidURI(o),Ws=o=>Se.isValidURI(o),Ys=Se;export{at as URLSanitizer,Ys as default,$s as inspectURL,Ws as isURISync,js as isValidURI,Bs as sanitizeURL,Hs as sanitizeURLSync};
3
+ `+C),q&&(C=Xe(C)),U&&We?pe(C):C},t.setConfig=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xt(l),Et=!0,He=b,$e=A},t.clearConfig=function(){ge=null,Et=!1,He=null,$e=null,U=pt,re=""},t.isValidAttribute=function(l,e,r){ge||xt({});let a=w(l),c=w(e);return typeof r=="string"&&(Cn(e,r)||!_t&&I(Vn,r))?!1:In(a,c,r)},t.addHook=function(l,e){typeof e=="function"&&k(y,l)&&De(y[l],e)},t.removeHook=function(l,e){if(k(y,l)){if(e!==void 0){let r=ho(y[l],e);return r===-1?void 0:_o(y[l],r,1)[0]}return Pn(y[l])}},t.removeHooks=function(l){k(y,l)&&(y[l]=[])},t.removeAllHooks=function(){y=Xn()},t}var tr=er();var Je=tr(globalThis.window);var nr=/&amp;/gi,rr=/&(?=[#a-z0-9])(?![a-z0-9]+=)/i;var or=/#$/,sr=/^(?:application\/(?:[\w.-]+\+)?xml|image\/svg\+xml|text\/(?:html|xml))(?:\s*;\s*|$)/i;var ir=/\P{ASCII}/u,ar=/&#(x0*[\dA-F]{1,2}|0*\d{1,3});?/gi,cr=/(?:%[\dA-F]{2})+/gi,lr=/^((?:[^#%]|%(?!23))*)\?$/,et=/^[a-z][\da-z+.-]*$/,ur=/^(?:web\+[a-z]+|ext\+[a-z][\da-z.-]*)$/,le=/^(?:java|vb)script$/i,ke=/^(?:(?:java|vb)script|blob)$/i,Xt=/["'<>]|%(?:22|27|3C|3E)|&(?:apos|lt|gt|quot|#0*(?:34|39|60|62)|#x0*(?:22|27|3C|3E));/i,fr=/^%[\dA-F]{2}$/i,pr=/^(?:\/{2,}|\\|[a-z][a-z\d+\-.]*:[^/])/i;var mr=[9,10,13,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];var qt=new Set(mr),Kt=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),Bo=()=>{let o=new Map;for(let t=0;t<256;t++)!qt.has(t)&&!Kt.has(t)&&o.set(t,`\\x${t.toString(16).padStart(2,"0").toUpperCase()}`);return o},Zt=Bo();var[Re,$o,jo,Wo,Yo,Vo]=["&","#","<",">",'"',"'"].map(o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Xo={[Re]:`${Re}amp;`,[jo]:`${Re}lt;`,[Wo]:`${Re}gt;`,[Yo]:`${Re}quot;`,[Vo]:`${Re}${$o}39;`},Es=Array.from({length:256},(o,t)=>`%${t.toString(16).padStart(2,"0").toUpperCase()}`),Er=globalThis.process?.versions?.node!==void 0,Tr=`[${[...Zt.values()].join("")}]`,qo=new RegExp(Tr),Ko=new RegExp(Tr,"g"),Zo=new Uint8Array(65536),Ts=new TextEncoder,Qo=new TextDecoder("utf-8",{fatal:!0}),D=(o,t=!1)=>{if(!R(o))return null;let n=ir.test(o)?o.normalize("NFKC"):o;return t?n.trim().toLowerCase().replace(/:$/,""):n},B=(o,t,n=!1)=>{if(!R(o)||o==="")return null;let s=o,i=t&&R(t)?t:"";if(n&&(s=D(s),i&&(i=D(i))),typeof URL.parse=="function")return i?URL.parse(s,i):URL.parse(s);try{return i?new URL(s,i):new URL(s)}catch{return null}},yr=o=>R(o)?o.replace(/:$/,"").split("+"):[];var br=o=>{if(!R(o))return o;let t=fr.test(o)?o.toUpperCase():o;return Xo[t]??o},$=o=>{let t=R(o)?o:String(o);return t.length>64?`${t.slice(0,64)}...`:t},Ar=o=>R(o)?o.replace(or,"").replace(lr,"$1"):o,Jo=(o,t)=>{let n=/^x/i.test(t)?Number.parseInt(t.slice(1),16):Number.parseInt(t,10);if(!Number.isInteger(n)||n<0||n>=256)return o;if(Zt.has(n))return"";if(qt.has(n))return String.fromCharCode(n);let s=Kt.get(n);return String.fromCodePoint(s)},Rr=(o,t=0)=>{if(!R(o))throw new TypeError(`Expected String but got ${ye(o)}.`);if(!Number.isInteger(t))throw new TypeError(`Expected Number but got ${ye(t)}.`);let n;try{n=decodeURIComponent(o)}catch{n=o.replace(cr,i=>{try{return decodeURIComponent(i)}catch{return i}})}n=n.replace(Ko,"");let s=0;for(;s+t<16;s++){let i=n;if(n=n.replace(nr,"&").replace(ar,Jo),n===i)break}if(s+t>=16&&/&#/.test(n))throw new Error("Character references nested too deeply.");return n},rt=(o,t="",n="")=>{if(!R(o))return{mediaType:"",mediaTypes:[],data:"",isBase64:!1};let s=o.indexOf(",");if(s===-1)return{mediaType:o,mediaTypes:o.split(";"),data:"",isBase64:!1};let i=o.substring(0,s),u=o.substring(s+1),f=t===""&&n===""?u:u+t+n,d=i.split(";"),p=d.at(-1),g=p!==void 0&&p.length===6&&p.toLowerCase()==="base64";return{mediaType:i,mediaTypes:d,data:f,isBase64:g}},Sr=o=>{if(!R(o))throw new TypeError(`Expected String but got ${ye(o)}.`);let t,n=o;try{t=atob(o)}catch{n=o.replace(/\s/g,"");try{t=atob(n)}catch{throw new Error(`Invalid base64 data: ${$(o)}`)}}let s;if(Er&&globalThis.Buffer)s=globalThis.Buffer.from(t,"latin1");else{let i=t.length;i>65536?s=new Uint8Array(i):s=Zo.subarray(0,i);for(let u=0;u<i;u++)s[u]=t.charCodeAt(u)}try{let i=Qo.decode(s);return qo.test(i)?n:i}catch{return n}},ot=o=>{if(Er&&globalThis.Buffer)return globalThis.Buffer.from(o).toString("base64");let t=new Uint8Array(o);if(typeof t.toBase64=="function")return t.toBase64();let n=[];for(let s=0;s<t.length;s+=8192)n.push(String.fromCharCode(...t.subarray(s,s+8192)));return btoa(n.join(""))},es=async(o,t,n)=>{let s=o.body.getReader(),i=[],u="Operation aborted";if(n?.aborted)throw await s.cancel(u),s.releaseLock(),n.reason;let f=()=>{s.cancel(u).catch(()=>{})};n?.addEventListener("abort",f,{once:!0});try{let d=0;for(;d<=t;){if(n?.aborted)throw await s.cancel(u),n.reason;let{done:E,value:x}=await s.read();if(n?.aborted)throw n.reason;if(E)break;if(d+=x.byteLength,d>t)throw await s.cancel("Size limit exceeded"),new DOMException(`Payload (${d} bytes) exceeds max (${t} bytes).`,"NotReadableError");i.push(x)}let p=new Uint8Array(d),g=0;for(let E of i)p.set(E,g),g+=E.byteLength;return p.buffer}finally{n?.removeEventListener("abort",f),s.releaseLock()}},Qt=async(o,t,n)=>{let s=16777216;Number.isInteger(t)&&t>0&&(s=t);let i=await fetch(o,{signal:n});if(!i.ok){let g=`Failed to fetch ${$(o)}`;throw Number.isInteger(i.status)&&(i.statusText?g+=`: ${i.status} ${i.statusText}`:g+=`: ${i.status}`),new Error(g)}let u=i.headers.get("content-length");if(u){let p=Number.parseInt(u,10);if(Number.isInteger(p)&&p>s)throw new DOMException(`Payload (${p} bytes) exceeds max (${s} bytes).`,"NotReadableError")}let f=i.headers.get("content-type")||"",d;if(i.body)d=await es(i,s,n);else{let p=await i.blob();if(p.size>s)throw new DOMException(`Payload (${p.size} bytes) exceeds max (${s} bytes).`,"NotReadableError");d=await p.arrayBuffer()}return{buffer:d,mimeType:f}};var Fe=class{constructor(t,n=Ce){this.domPurify=t,this.nest=0,this.recurse=new Set,this.restrictScheme=!1,this.schemeMap=new Map([["blob",!1],["data",!1],["file",!1],["javascript",!1],["vbscript",!1]]),this.#e(n)}#e(t){let{allowRelative:n,debug:s,allow:i,deny:u,only:f,schemes:d}=t;if(this.allowRelative=!!n,this.debug=!!s,this.schemes=d,Array.isArray(f)){this.restrictScheme=!0;for(let p of f)this.#t(p)}else{if(Array.isArray(i)&&i.length)for(let p of i)this.#t(p);if(Array.isArray(u)&&u.length)for(let p of u){let g=D(p,!0);g&&this.schemeMap.set(g,!1)}}}#t(t){let n=D(t,!0);return!n||ke.test(n)||!et.test(n)||n.includes("+")&&n.split("+").some(i=>le.test(i))?!1:(this.schemeMap.set(n,!0),!0)}enter(t){return this.recurse.has(t)?(this.debug&&X(`Circular Data URL detected and skipped: ${$(t)}`),!1):(this.nest++,this.recurse.add(t),!0)}leave(t){this.nest--,this.recurse.delete(t)}},st=class{#e;constructor(t=Ce){this.#e=t}#t(t,n){if(n.nest>16)throw new Error("Data URLs nested too deeply.");let s=B(t,null,!0);if(!s){if(n.allowRelative&&!pr.test(t)){let u=B(t,Pt);if(u){let{protocol:f,hostname:d,pathname:p,search:g,hash:E}=u;if(f==="http:"&&d==="dummy.local")return this.#o(`${p}${g}${E}`)}}return null}let i=D(s.protocol,!0);if(n.restrictScheme&&!n.schemeMap.has(i))return null;if(i.includes("+")){let u=i.split("+");if(n.schemeMap.get(i)===!1||u.some(f=>n.schemeMap.get(f)===!1))return null}else if(n.schemeMap.has(i)){if(n.schemeMap.get(i)===!1)return null}else if(!n.schemes.has(i))return null;return i==="data"?this.#n(s,n):this.#o(s.href)}#n(t,n){let{mediaType:s,mediaTypes:i,data:u,isBase64:f}=rt(t.pathname,t.search,t.hash),d=u;if(f)try{d=Sr(u)}catch(p){return n.debug&&X("Failed to parse base64 data.",p),null}try{let p=Rr(d).trim(),g=B(p,Pt);if(!g||yr(g.protocol).some(x=>ke.test(x)))return null}catch(p){return n.debug&&X("Failed to parse inner data URL protocol.",p),null}return(!s||sr.test(s))&&(d=this.#s(d,n)),d?(f&&d!==u&&i.pop(),`data:${i.join(";")},${d}`):null}#s(t,n){let s="";try{s=decodeURIComponent(t)}catch{s=t}let i=(f,d)=>this.#r(f,d,n),u="";try{n.domPurify.addHook("uponSanitizeAttribute",i),u=n.domPurify.sanitize(s)}finally{n.domPurify.removeHook("uponSanitizeAttribute",i)}if(!u)return null;try{return encodeURI(Ar(u))}catch{return null}}#r(t,n,s){if(!n.attrValue||!/^\s*data:/i.test(n.attrValue))return;let i=B(n.attrValue,null,!0);if(!i||i.protocol!=="data:")return;let u=n.attrValue;if(!s.enter(u)){n.attrValue="";return}try{let f=this.#t(u,s);n.attrValue=f||""}finally{s.leave(u)}}#o(t){let n=t.length,s=n,i=Xt.exec(t);if(i&&(s=i.index),t.indexOf("&")>-1){let f=rr.exec(t);if(f){let d=f.index;d<s&&(s=d)}}if(s===n)return t;let u=t.charCodeAt(s-1);return(u===63||u===38)&&s--,t.substring(0,s)}sanitize(t,n=this.#e){if(!t||!R(t))return null;let{deny:s,maxLength:i,only:u,allowRelative:f}=n;if(Number.isInteger(i)&&t.length>i){let g=`URL length ${t.length} exceeds max length ${i}.`;throw new RangeError(g)}if(!(Array.isArray(s)&&s.length>0||Array.isArray(u)||f)&&/^https?:\/\//.test(t)&&!Xt.test(t)&&!t.includes("data:")){let g=B(t,null,!0);return g&&n.schemes.has(g.protocol.replace(/:$/,""))?g.href.replace(/%26/g,br):null}let p=new Fe(Je,n);return this.#t(t,p)}async sanitizeBuffer(t,n,s=this.#e){if(!(t instanceof ArrayBuffer))return null;let i=ot(t),f=`data:${n?`${n};base64`:"base64"},${i}`;if(Number.isInteger(s.maxLength)&&f.length>s.maxLength)throw new RangeError(`URL length ${f.length} exceeds max length ${s.maxLength}.`);let d=new Fe(Je,s);if(!d.schemeMap.get("data"))return null;let p=B(f);return p?this.#n(p,d):null}async sanitizeDataURL(t,n=this.#e){if(!t||!R(t))return null;let{maxLength:s}=n;if(Number.isInteger(s)&&t.length>s)throw new RangeError(`URL length ${t.length} exceeds max length ${s}.`);let i=B(t);if(!i)return null;let u=D(i.protocol,!0);if(u!=="data")return null;let f=new Fe(Je,n);return f.schemeMap.get(u)?this.#n(i,f):null}};var wr=["aaa","aaas","about","acap","acct","acd","ace","aceap","acedp","aceep","acelp","aceup","acr","adiumxtra","adt","aet","afp","afs","agtp","aim","alter","amss","android","appdata","apt","ar","ari","ark","ars","arv","at","attachment","aw","barion","beshare","bitcoin","bitcoincash","bl","blob","bluetooth","bolo","brid","browserext","cabal","caip","calculator","callto","canactid","cap","cast","casts","chrome","chrome-extension","cid","cm","coap","coaps","com-eventbrite-attendee","content","content-type","crid","cstr","cttps","cvs","dab","dat","data","dav","dhttp","diaspora","dict","did","dilithium3","dis","dlna-playcontainer","dlna-playsingle","dnp","dns","dntp","doi","donau","dpp","drm","dtmi","dtn","dvb","dvx","dweb","ed2k","eid","elsi","embedded","ens","esim","ethereum","example","ez","facetime","feed","feedready","fido","file","finger","first-run-pen-experience","fish","fm","ftp","fuchsia-pkg","gcx","gdsi","geo","gg","git","gitoid","gizmoproject","go","gopher","graph","gsos","gtalk","h323","haie","ham","hcap","hcp","hs20","http","https","hxxp","hxxps","hydrazone","hyper","i0","iax","ibi","ibi-","icap","icon","ilstring","im","imap","info","interaction","iotdisco","ipfs","ipn","ipns","ipp","ipps","iqa","irc","irc6","ircs","iris","iris.beep","iris.lwz","iris.xpc","iris.xpcs","isostore","itms","jabber","jar","jms","keyparc","lastfm","lbry","ldap","ldaps","leaptofrogans","lid","linkid","locus","lorawan","lpa","lvlt","machineProvisioningProgressReporter","magnet","mailto","maps","market","matrix","mdoc","mdoc-openid4vp","message","microsoft.windows.camera","microsoft.windows.camera.multipicker","microsoft.windows.camera.picker","mid","mms","mongodb","moz","moz-extension","mqtt","mqtts","ms-access","ms-appinstaller","ms-browser-extension","ms-calculator","ms-drive-to","ms-enrollment","ms-excel","ms-eyecontrolspeech","ms-gamebarservices","ms-gamingoverlay","ms-getoffice","ms-help","ms-infopath","ms-inputapp","ms-launchremotedesktop","ms-lockscreencomponent-config","ms-media-stream-id","ms-meetnow","ms-mixedrealitycapture","ms-mobileplans","ms-newsandinterests","ms-officeapp","ms-people","ms-personacard","ms-powerpoint","ms-project","ms-publisher","ms-recall","ms-remotedesktop","ms-remotedesktop-launch","ms-restoretabcompanion","ms-screenclip","ms-screensketch","ms-search","ms-search-repair","ms-secondary-screen-controller","ms-secondary-screen-setup","ms-settings","ms-settings-airplanemode","ms-settings-bluetooth","ms-settings-camera","ms-settings-cellular","ms-settings-cloudstorage","ms-settings-connectabledevices","ms-settings-displays-topology","ms-settings-emailandaccounts","ms-settings-language","ms-settings-location","ms-settings-lock","ms-settings-nfctransactions","ms-settings-notifications","ms-settings-power","ms-settings-privacy","ms-settings-proximity","ms-settings-screenrotation","ms-settings-wifi","ms-settings-workplace","ms-spd","ms-stickers","ms-sttoverlay","ms-transit-to","ms-useractivityset","ms-uup","ms-virtualtouchpad","ms-visio","ms-walk-to","ms-whiteboard","ms-whiteboard-cmd","ms-widgetboard","ms-widgets","ms-word","msnim","msrp","msrps","mss","mt","mtqp","mtrust","mumble","mupdate","musik","mvn","mvrp","mvrps","news","nfs","ni","nih","nntp","nostr","notes","npamp","num","ocf","oid","onenote","onenote-cmd","op","opaquelocktoken","openid","openpgp4fpr","opns","ord","ordmail","otpauth","palm","paparazzi","payto","pkcs11","pkg","platform","pop","pres","proxy","psyc","pttp","pwid","qb","query","quic-transport","redis","rediss","reload","res","resource","rmi","rsync","rtmfp","rtmp","rtsp","rtsps","rtspu","rttp","sarif","secondlife","secret-token","seki","service","session","sftp","sgn","shc","shelter","sieve","simpleledger","simplex","sip","sips","skype","smb","smp","sms","smtp","snmp","sns","soap.beep","soap.beeps","soldat","spacify","spiffe","spotify","ssb","ssh","sss","starknet","steam","stun","stuns","submit","svn","swh","swid","swidpath","tag","taler","tcxp","teamspeak","teapot","teapots","tel","teliaeid","telnet","tftp","things","thismessage","tii","tip","tn3270","tool","tttps","turn","turns","tv","udp","unreal","upn","urn","ust","ut2004","uuaid","uuid-in-package","v-event","vemmi","ventrilo","ves","view-source","vnc","vscode","vscode-insiders","vsls","w3","wasm","wasm-js","wcr","web3","webcal","wifi","ws","wss","wtai","wyciwyg","xcompute","xcon","xcon-userid","xfire","xftp","xmlrpc.beep","xmlrpc.beeps","xmpp","xrcp","xri","ymsgr","z39.50r","z39.50s","ztdnaid"];var it=class{#e=new Set(wr);get(){return[...this.#e]}getScheme(t){if(!R(t))return null;let n=this.parse(t);return n?this.normalize(n.protocol,!0):null}has(t){let n=this.normalize(t,!0);return n?this.#e.has(n):!1}normalize(t,n=!1){return D(t,n)}normalizeSchemes(t){if(Array.isArray(t)){let n=[];for(let s of t){let i=D(s,!0);i&&n.push(i)}return n}return[]}parse(t,n,s=!1){return B(t,n,s)}verifyURI(t,n){if(!R(t))return!1;let s=this.parse(t);return s?this.verifyScheme(s.protocol,n,!0):!1}verifyScheme(t,n,s=!1){let i=this.normalize(t,!0);if(!i)return!1;let u=n||this.#e;if(!i.includes("+"))return le.test(i)?!1:u.has(i);let f=i.split("+");return f.some(p=>le.test(p))?!1:u.has(i)?!0:s&&ur.test(i)||f.every(p=>u.has(p))}};var ns=Object.freeze(["href","origin","protocol","username","password","host","hostname","port","pathname","search","hash"]),at=class extends it{#e;#t;#n;constructor(){super(),this.#e=new Set(super.get()),this.#t={...Ce,schemes:this.#e},this.#n=new st(this.#t)}#s(t){return!R(t)||ke.test(t)||t.includes("+")&&t.split("+").some(s=>le.test(s))?!1:et.test(t)}#r(t,n={}){if(!R(t)||t==="")return{isValid:!1};let s={...this.#t,...n,allow:this.normalizeSchemes(n.allow),deny:this.normalizeSchemes(n.deny),only:Object.hasOwn(n,"only")?this.normalizeSchemes(n.only):this.#t.only,schemes:this.#e},i=this.getScheme(t);return i===null&&!s.allowRelative?{isValid:!1}:{options:s,scheme:i}}#o(t,n){let s={input:t,href:null,valid:!1};if(!R(t))return s.reason=`Invalid URL input: ${$(t)}`,s;if(t==="")return s.reason="Invalid URL input: (empty string)",s;let i,u=null;try{i=this.#n.sanitize(t,n),i||(u="Sanitization failed (blocked by allowed schemes or rules).")}catch(f){u=f.message}if(i){let f=B(i);if(s.valid=!0,f){if(D(f.protocol,!0)==="data"){let{mediaTypes:p,data:g,isBase64:E}=rt(f.pathname,f.search,f.hash);E&&p.pop(),s.data={mime:p.join(";"),base64:E,data:g}}else s.data=null;for(let p of ns){let g=f[p];R(g)&&(s[p]=g)}}else s.valid=!1,s.relative=!0,s.href=i,s.reason="Invalid as an absolute URL, but valid as a relative URL."}else s.reason=u;return s}async#a(t,n){try{let{buffer:s,mimeType:i}=await Qt(t,n.maxBlobSize,n.signal),u=ot(s),f=`data:${i?`${i};base64`:"base64"},${u}`,d=this.#o(f,n);return d.input=t,d}catch(s){if(s.name==="AbortError"||n.signal?.aborted)throw s;return n.debug&&X(`Failed to inspect blob URL: ${$(t)}`,s),{input:t,valid:!1,reason:s.message}}finally{n.revokeObjectURL&&URL.revokeObjectURL(t)}}#i(t,n){if(t instanceof TypeError||t.name==="AbortError"||n.signal?.aborted)throw t}get(){return[...this.#e]}has(t){let n=D(t,!0);return n?this.#e.has(n):!1}add(t){if(!R(t))throw new TypeError(`Expected String but got ${ye(t)}.`);let n=D(t,!0);if(!this.#s(n))throw new Error(`Invalid scheme: ${t}`);return this.#e.add(n),[...this.#e]}remove(t){if(!R(t))return!1;let n=D(t,!0);return this.#e.delete(n)}reset(){this.#e.clear();for(let t of super.get())this.#e.add(t)}async sanitizeURL(t,n){let{isValid:s,options:i,scheme:u}=this.#r(t,n);if(s===!1)return null;if(u==="blob"){let{allow:f,deny:d,only:p}=i,g=null;try{if(f.includes("blob")&&!d.includes("blob")||Array.isArray(p)&&p.includes("blob")){let E=null,x="";try{let j=await Qt(t,i.maxBlobSize,i.signal);E=j.buffer,x=j.mimeType}catch(j){if(j.name==="AbortError"||i.signal?.aborted)throw j;i.debug&&X(`Failed to fetch and convert blob URL: ${$(t)}`,j)}E&&(p?.length?p.includes("data")||(i.only=[...p,"data"]):(f.includes("data")||(i.allow=[...f,"data"]),i.deny=d.filter(j=>j!=="data")),g=await this.#n.sanitizeBuffer(E,x,i))}}catch(E){return this.#i(E,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,E),null}finally{i.revokeObjectURL&&URL.revokeObjectURL(t)}return g}try{return u==="data"?this.#n.sanitizeDataURL(t,i):this.#n.sanitize(t,i)}catch(f){return this.#i(f,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,f),null}}sanitizeURLSync(t,n){let{isValid:s,options:i,scheme:u}=this.#r(t,n);if(s===!1)return null;if(u==="blob")return i.revokeObjectURL&&URL.revokeObjectURL(t),null;try{return this.#n.sanitize(t,i)}catch(f){return this.#i(f,i),i.debug&&X(`Failed to sanitize URL: ${$(t)}`,f),null}}async inspectURL(t,n={}){let{options:s,scheme:i}=this.#r(t,n);return i==="blob"?this.#a(t,s):this.#o(t,s)}isValidURI(t){return super.verifyURI(t,this.#e)}};var Se=new at,Bs=async(o,t)=>Se.sanitizeURL(o,t),Hs=(o,t)=>Se.sanitizeURLSync(o,t),$s=async(o,t={})=>Se.inspectURL(o,t),js=o=>Se.isValidURI(o),Ws=o=>Se.isValidURI(o),Ys=Se;export{at as URLSanitizer,Ys as default,$s as inspectURL,Ws as isURISync,js as isValidURI,Bs as sanitizeURL,Hs as sanitizeURLSync};
4
4
  /*!
5
5
  * URL Sanitizer
6
6
  *