feat(Dom2Image): bump version 10.0.6 - #1140
Merged
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis release updates Dom2Image to version 10.0.6 and refreshes its bundled generated snapdom module, so review should focus on package metadata correctness and any behavioral or compatibility impact from the runtime update. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 security issues
Security issues:
- User controlled data in methods like
innerHTML,outerHTMLordocument.writeis an anti-pattern that can lead to XSS vulnerabilities (link) - User controlled data in a
n.innerHTMLis an anti-pattern that can lead to XSS vulnerabilities (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/BootstrapBlazor.Dom2Image/wwwroot/lib/snapdom.mjs" line_range="39" />
<code_context>
}`,Yf=Math.max(1,Math.min(4,(typeof navigator<"u"&&navigator.hardwareConcurrency||2)-1)),Ft=null,Kf=0,Qf=0,ae=new Map;function Js(){for(let t of ae.values())t(void 0);if(ae.clear(),Array.isArray(Ft))for(let t of Ft)try{t?.terminate()}catch{}Ft=!1}function Jf(){let t,e=null;try{t=URL.createObjectURL(new Blob([Xf],{type:"text/javascript"})),e=new Worker(t),e.onmessage=n=>{let r=ae.get(n.data.id);r&&(ae.delete(n.data.id),r(n.data.error?void 0:n.data.url??null))},e.onerror=Js}catch{e=null}return t&&URL.revokeObjectURL(t),e}function Zf(){if(Ft===!1)return!1;if(Ft===null){if(typeof Worker>"u"||typeof OffscreenCanvas>"u")return Ft=!1;Ft=[]}let t=Kf++%Yf;if(!Ft[t]){let e=Jf();if(!e)return Js(),!1;Ft[t]=e}return Ft[t]}var tu=5e3;function eu(t,e,n,r,i){let o=Zf();return o?new Promise(s=>{let a=++Qf,c=setTimeout(()=>{ae.delete(a),s(void 0)},tu);ae.set(a,f=>{clearTimeout(c),s(f)});try{o.postMessage({id:a,dataURL:i?"":t,blob:i,srcLength:t.length,targetW:e,targetH:n,resFactor:Qs,quality:Ks,mime:r})}catch{clearTimeout(c),ae.delete(a),s(void 0)}}):Promise.resolve(void 0)}async function yo(t,e,n,r){if(typeof t!="string"||!t.startsWith("data:image")||t.startsWith("data:image/svg"))return null;e=Math.ceil(e),n=Math.ceil(n);let i=t.length+":"+t.slice(0,64)+t.slice(-64)+":"+e+"x"+n,o=P.compress,s=o.get(i);if(s?.source===t)return s.result;let a=Yn.get(i);if(a?.source===t&&a.cache===o)return a.promise;let c=(async()=>{let l=zf(t),u=l==="image/jpeg"?"image/jpeg":l==="image/webp"?"image/webp":"image/png",p=Gf(t);if(p&&p.w>0&&p.h>0&&!qs(p.w,p.h,e,n))return null;if(t.length>=jf){let S=await eu(t,e,n,u,r);if(S!==void 0)return S}let h;try{h=await Hf(t)}catch{return null}let d=h.naturalWidth||h.width,m=h.naturalHeight||h.height;if(!d||!m)return null;let g=qs(d,m,e,n);if(!g)return null;let y=g*Qs,b=Math.max(1,Math.round(d*y)),w=Math.max(1,Math.round(m*y)),C=document.createElement("canvas");C.width=b,C.height=w;let x=C.getContext("2d");if(!x)return null;x.imageSmoothingEnabled=!0,x.imageSmoothingQuality="high",x.drawImage(h,0,0,b,w);try{let S=C.toDataURL(u,Ks);if(typeof S=="string"&&S.startsWith("data:image")&&S.length<t.length)return S}catch{}return null})(),f={source:t,promise:c,cache:o};Yn.set(i,f);try{let l=await c;return Vf(o,i,t,l),l}finally{Yn.get(i)===f&&Yn.delete(i)}}async function nu(t,e,n=new Map,r={}){if(!e.compress)return{count:0,before:0,after:0};let i=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&i.unshift(t);let o=0,s=0,a=0,c=async l=>{let u=l.getAttribute("src")||"";if(!u.startsWith("data:image")||u.startsWith("data:image/svg"))return;let p=parseFloat(l.dataset.snapdomWidth)||parseFloat(l.style.width)||l.width||0,h=parseFloat(l.dataset.snapdomHeight)||parseFloat(l.style.height)||l.height||0;if(!p||!h)return;let d=r.value||=go(t,e),m=d.density*d.stretch(n.get(l)||l),g=await yo(u,p*m,h*m,l.__snapdomBlob);g&&(o++,s+=u.length,a+=g.length,l.setAttribute("src",g),Kn(l,"attribute","src",u,g,e))},f=6;for(let l=0;l<i.length;l+=f)await Promise.allSettled(i.slice(l,l+f).map(c));return{count:o,before:s,after:a}}var ru=/^(cover|contain|(\d+(\.\d+)?%(\s+\d+(\.\d+)?%)?))$/;function ou(t){let e=t.offsetWidth||t.getBoundingClientRect().width||0,n=t.offsetHeight||t.getBoundingClientRect().height||0;return{w:e,h:n}}async function iu(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=[],o=[t,...t.querySelectorAll("*")];for(let f of o){let l=f.style&&f.style.backgroundImage;l&&l.includes("data:image")&&i.push(f)}let s=0,a=async f=>{let l=n.get(f);if(!l||!l.isConnected)return;let u;try{u=getComputedStyle(l)}catch{return}if((u.backgroundRepeat||"repeat").toLowerCase().split(",").some(v=>v.trim()!=="no-repeat"))return;let h=(f.style.backgroundSize||u.backgroundSize||"auto").toLowerCase();if(h.split(",").some(v=>!ru.test(v.trim())))return;let{w:d,h:m}=ou(l);if(!d||!m)return;let g=Math.max(1,...(h.match(/\d+(?:\.\d+)?%/g)||[]).map(v=>parseFloat(v)/100)),y=r.value||=go(t,e),b=y.density*y.stretch(l)*g,w=d*b,C=m*b,x=f.style.backgroundImage,S=[...x.matchAll(/url\((['"]?)(data:image\/[^)'"]+)\1\)/gi)],A=x;for(let v of S){let M=v[2];if(M.startsWith("data:image/svg"))continue;let k=await yo(M,w,C);k&&(A=A.split(M).join(k),s++)}A!==x&&(f.style.setProperty("background-image",A,f.style.getPropertyPriority("background-image")),Kn(f,"style","background-image",x,f.style.backgroundImage,e))},c=6;for(let f=0;f<i.length;f+=c)await Promise.allSettled(i.slice(f,f+c).map(a));return{count:s}}async function su(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=Array.from(t.querySelectorAll("image"));t.localName==="image"&&i.unshift(t);let o=0,s=async c=>{let f=c.getAttribute("href")||(typeof c.getAttributeNS=="function"?c.getAttributeNS("http://www.w3.org/1999/xlink","href"):null);if(!f||!f.startsWith("data:image")||f.startsWith("data:image/svg"))return;let l=c.getAttribute("width")||"",u=c.getAttribute("height")||"";if(l.includes("%")||u.includes("%"))return;let p=n.get(c),h=p?W(p):c.style,d=(C,x)=>{if(/^\d+(?:\.\d+)?px$/.test(h?.[C]||""))return parseFloat(h[C]);if(/^\d+(?:\.\d+)?(?:px)?$/.test(x.trim()))return parseFloat(x);try{return p?.[C]?.baseVal?.value||0}catch{return 0}},m=d("width",l),g=d("height",u);if(!m||!g)return;let y=r.value||=go(t,e),b=y.density*y.stretch(p||c),w=await yo(f,m*b,g*b);w&&(c.setAttribute("href",w),Kn(c,"attribute","href",f,w,e),c.hasAttribute("xlink:href")&&(c.setAttributeNS(Gs,"xlink:href",w),Kn(c,"attribute","xlink:href",f,w,e)),o++)},a=6;for(let c=0;c<i.length;c+=a)await Promise.allSettled(i.slice(c,c+a).map(s));return{count:o}}async function Zn(t,e,n){if(!e.compress)return;let r={};await nu(t,e,n,r),await iu(t,e,n,r),await su(t,e,n,r)}ht();dt();wt();function au(t,e){if(Y())return t;let n=t.indexOf("</style>");if(n===-1)return t;let r=/<style\b[^>]*>[\s\S]*?<\/style>/g,i=[],o=n,s;for(r.lastIndex=n;s=r.exec(t);)i.push({text:t.slice(o,s.index),intern:!0}),i.push({text:s[0],intern:!1}),o=r.lastIndex;i.push({text:t.slice(o),intern:!0});let a=new Map,c=/ style="([^"]*)"/g,f;for(let y of i)if(y.intern)for(c.lastIndex=0;f=c.exec(y.text);)a.set(f[1],(a.get(f[1])||0)+1);let l=0;for(let[y,b]of a)b>1&&(l+=(b-1)*y.length);if(l<2048||t.includes(" data-sdi="))return t;let u=cu(e,i.some(y=>!y.intern),t.includes("data-snapdom-asset"));if(u===null)return t;let p=new Map,h=0,d=[],m=(y,b)=>{if((a.get(b)||0)<2||u.has(b))return y;let w=p.get(b);return w===void 0&&(w="i"+(h++).toString(36),p.set(b,w),d.push(`[data-sdi="${w}"]{${b}}`)),` data-sdi="${w}"`},g="";for(let y of i)g+=y.intern?y.text.replace(c,m):y.text;return t.slice(0,n)+d.join("")+g}function cu(t,e,n){let r=new Set;if(!e&&!n)return r;if(!t||t.querySelector("[data-sdi]"))return null;let i=c=>{let f=c.getAttribute("style");f&&r.add(f)};if(n&&t.querySelectorAll("[data-snapdom-asset][style]").forEach(i),e)try{let c=f=>{for(let l of f){if(l.type===CSSRule.IMPORT_RULE||l.type===CSSRule.NAMESPACE_RULE)throw new Error("External or namespaced CSS");if(l.selectorText){if(/\[\s*style\b|data-sdi|\[[^\]]*\\|&/i.test(l.selectorText))throw new Error("Attribute-dependent or nested CSS");t.querySelectorAll(l.selectorText).forEach(i)}l.cssRules&&c(l.cssRules)}};for(let f of[...t.querySelectorAll("style")].slice(1)){let l=f.textContent||"";if(/@import\b/i.test(l))return null;let u=new CSSStyleSheet;u.replaceSync(l),c(u.cssRules)}}catch{return null}let o=new Set,s=document.createElement("div"),a=new XMLSerializer;for(let c of r){s.setAttribute("style",c);let f=a.serializeToString(s).match(/ style="([^"]*)"/);f&&o.add(f[1])}return o}async function tr(t,e){let{clipWindow:n,outerTransforms:r,outerShadows:i,rootTransform2D:o,fontsCSS:s}=e,a=t.options;if(t!==a){let{options:K,...tt}=t;t=Object.assign(a,tt),Object.defineProperty(t,"options",{value:t,configurable:!0})}let c,f;Fs(t,s),await Nt("beforeRender",t);let l=W(t.element),u=t.element.getBoundingClientRect(),p=Math.max(1,I(t.element.offsetWidth||parseFloat(l.width)||u.width||1)),h=Math.max(1,I(t.element.offsetHeight||parseFloat(l.height)||u.height||1)),d=t.element.ownerDocument||document;if(!n&&(t.element===d.body||t.element===d.documentElement)&&!t.__pinned){let K=Math.max(t.element.scrollHeight||0,d.documentElement?.scrollHeight||0,d.body?.scrollHeight||0),tt=Math.max(t.element.scrollWidth||0,d.documentElement?.scrollWidth||0,d.body?.scrollWidth||0);K>0&&(h=Math.max(h,I(K))),tt>0&&(p=Math.max(p,I(tt)));try{let Q=(t.scrollbarCSS||"").length+(t.baseCSS||"").length+(t.fontsCSS||"").length+(t.classCSS||"").length,et=P.measureHints.get(t.element);if(et&&et.cssLen===Q&&et.w0===p&&et.docH===K&&et.docW===tt)et.csh>0&&(h=Math.max(h,I(et.csh))),et.csw>0&&(p=Math.max(p,I(et.csw)));else{let nt=d.createElement("div");J(nt),nt.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+p+"px!important;overflow:visible!important;visibility:hidden!important;";let Xt=nt.attachShadow({mode:"open"}),Yt=d.createElement("style");Yt.textContent=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS,Xt.appendChild(Yt),Xt.appendChild(t.clone.cloneNode(!0)),d.body.appendChild(nt);let He=nt.scrollHeight,Ot=nt.scrollWidth;d.body.removeChild(nt),P.measureHints.set(t.element,{cssLen:Q,w0:p,docH:K,docW:tt,csh:He,csw:Ot}),He>0&&(h=Math.max(h,I(He))),Ot>0&&(p=Math.max(p,I(Ot)))}}catch{}}if(t.options?.excludeMode==="remove"||typeof t.options?.filter=="function"&&t.options.filterMode==="remove"){let K=fo(t.element,t.options),tt=1,Q=fo(t.element,{}),et=Math.max(2,h*.15);Number.isFinite(Q)&&Q>=h-et&&Number.isFinite(K)&&K>0&&(h=Math.max(1,Math.min(h,I(K+tt))))}if(t.options?.reconcile)try{let K=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS;Rs(t.element,t.clone,K,t.nodeMap,p,h)}catch(K){console.warn("[snapdom] reconcile pass failed:",K)}let g=(K,tt=NaN)=>{let Q=typeof K=="string"?parseFloat(K):K;return Number.isFinite(Q)?Q:tt},y=g(t.options.width),b=g(t.options.height),w=n?I(n.width):p,C=n?I(n.height):h,x=w,S=C,A=Number.isFinite(y),v=Number.isFinite(b),M=C>0?w/C:1;A&&v?(x=Math.max(1,I(y)),S=Math.max(1,I(b))):A?(x=Math.max(1,I(y)),S=Math.max(1,I(x/(M||1)))):v&&(S=Math.max(1,I(b)),x=Math.max(1,I(S*(M||1))));let k=0,R=0,E=p,T=h;if(n){let K=0,tt=0;if(bo(t.element)){let Q=null;if(!r&&o&&Number.isFinite(o.a))Q={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0};else{let et=se(t.element),nt=lo(l.transform&&l.transform!=="none"?l.transform:"",et);nt&&nt.is2D&&(Q={a:nt.a,b:nt.b,c:nt.c,d:nt.d,e:0,f:0})}if(Q&&!(Q.a===1&&Q.b===0&&Q.c===0&&Q.d===1)){let{ox:et,oy:nt}=on(l,p,h),Xt=Re(p,h,Q,et,nt);K=Xt.minX,tt=Xt.minY}}k=I(n.x+K),R=I(n.y+tt),E=I(k+n.width),T=I(R+n.height)}else if(!r&&o&&Number.isFinite(o.a)){let K={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0},tt=Re(p,h,K,0,0);k=I(tt.minX),R=I(tt.minY),E=I(tt.maxX),T=I(tt.maxY)}else if(r&&bo(t.element)){let tt=l.transform&&l.transform!=="none"?l.transform:"",Q=se(t.element),et=qt({baseTransform:tt,rotate:Q.rotate||"0deg",scale:Q.scale,translate:Q.translate,width:p,height:h}),{ox:nt,oy:Xt}=on(l,p,h),Yt=et.is2D?et:new DOMMatrix(et.toString()),He={a:Yt.a,b:Yt.b,c:Yt.c,d:Yt.d,e:0,f:0},Ot=Re(p,h,He,nt,Xt);k=I(Ot.minX),R=I(Ot.minY),E=I(Ot.maxX),T=I(Ot.maxY)}let N=no(l),O=ro(l),H=oo(l),_=io(l),L=so(l),$=u.width>0?(E-k)/u.width:1,F=u.height>0?(T-R)/u.height:1,V=i==="subtree"&&!n?ys(t.element,t.nodeMap,t.styleCache,$,F):{top:0,right:0,bottom:0,left:0},z=n?{top:0,right:0,bottom:0,left:0}:i?{top:I(Math.max(N.top,O.top,V.top)+H.top+_.top+L.bleed.top),right:I(Math.max(N.right,O.right,V.right)+H.right+_.right+L.bleed.right),bottom:I(Math.max(N.bottom,O.bottom,V.bottom)+H.bottom+_.bottom+L.bleed.bottom),left:I(Math.max(N.left,O.left,V.left)+H.left+_.left+L.bleed.left)}:{top:H.top,right:H.right,bottom:H.bottom,left:H.left};k=I(k-z.left),R=I(R-z.top),E=I(E+z.right),T=I(T+z.bottom);let q=Math.max(1,I(E-k)),B=Math.max(1,I(T-R)),Z="http://www.w3.org/2000/svg",Mt=bo(t.element)?2:0,gt=I(Mt+(r?0:1)),st=Math.ceil(q+gt*2),at=Math.ceil(B+gt*2),$t=I(-(I(k)-gt)),U=I(-(I(R)-gt)),G=Math.max(0,$t),j=Math.max(0,U),ut=I(st-Math.min(0,$t)),Et=I(at-Math.min(0,U)),yt=document.createElementNS(Z,"foreignObject");yt.setAttribute("x",String(Math.min(0,$t))),yt.setAttribute("y",String(Math.min(0,U))),yt.setAttribute("width",String(ut)),yt.setAttribute("height",String(Et)),yt.style.overflow="visible";let fe=document.createElement("style"),dn="svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}";fe.textContent=(t.scrollbarCSS||"")+t.baseCSS+t.fontsCSS+dn+t.classCSS,yt.appendChild(fe);let Be=document.createElement("div");Be.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),Be.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${ut}px;height:${Et}px`+(G!==0||j!==0?`;padding:${j}px 0 0 ${G}px !important`:""),Be.appendChild(t.clone),yt.appendChild(Be);let fr=new XMLSerializer().serializeToString(yt),It=A||v,ur=Object.freeze({w0:w,h0:C,vbW:st,vbH:at,targetW:x,targetH:S,contentX:I($t+(n?k:0)),contentY:I(U+(n?R:0)),clip:n?Object.freeze({x:I(k),y:I(R),width:w,height:C}):null});Object.defineProperty(a,"meta",{value:ur,enumerable:!0,writable:!1,configurable:!0});let dr=!It||Y()?st:A?x:I(st*(S/at)),pn=!It||Y()?at:v?S:I(at*(x/st)),Wt=parseFloat(W(d.documentElement)?.fontSize)||16;f=`<svg xmlns="${Z}" width="${dr}" height="${pn}" viewBox="0 0 ${st} ${at}" font-size="${Wt}px">`+au(fr,yt)+"</svg>",c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,t.svgString=f,t.dataURL=c,a.__artifacts={classCSS:t.classCSS||"",fontsCSS:t.fontsCSS||"",baseCSS:t.baseCSS||"",scrollbarCSS:t.scrollbarCSS||""},await Nt("afterRender",t),t.clone=t.nodeMap=t.styleCache=t.svgString=null;let pr=[...document.querySelectorAll("#snapdom-sandbox")].find(Ut);return pr&&pr.style.position==="absolute"&&pr.remove(),t.dataURL}function bo(t){return ws(t)}function lu(t){let e=Array.isArray(t.plugins)?t.plugins:mo(),n=[];for(let r of e){let i=Ne(r);i&&typeof i.resolveNode=="function"&&n.push(i.resolveNode.bind(i))}return n.length?n:null}async function Zs(t,e){if(!t)throw new Error("Element cannot be null or undefined");e.__session=Ls(e.cache),delete e.__compressedAssets,delete e.__compressedSnapshot,delete e.__compressionDensity,e.__resolveNodeHooks=lu(e);let n=e;n.element=t,Object.defineProperty(n,"options",{value:n,configurable:!0});let r,i,o,s,a,c,f,l="",u=null,p=e.needs||ft,h=n.format,d=n.type;await Nt("beforeSnap",n);let m=n.format!==h&&/^(?:png|jpe?g|webp|svg)$/i.test(n.format),g=n.type!==d&&/^(?:png|jpe?g|webp|svg)$/i.test(n.type);if(m||g){let E=String(m?n.format:n.type).toLowerCase();n.format=E==="jpg"?"jpeg":E,n.type=n.format,n.__explicitFormat=n.format,/^(?:jpeg|webp)$/.test(n.format)&&(n.backgroundColor==null||n.backgroundColor==="transparent")&&(n.backgroundColor="#ffffff")}await Nt("beforeClone",n);let y=n.outerTransforms!==!1,b=n.outerShadows==="subtree"?"subtree":!!n.outerShadows,w=n.clip?On(n.element,n.clip):null;if(e.__styleShare===void 0)try{e.__styleShare=mi(n.element)&&(typeof n.element.getAnimations!="function"||n.element.getAnimations({subtree:!0}).length===0)}catch{e.__styleShare=!1}let C=qn(n.element,w);try{({clone:r,classCSS:i,classPrefixCSS:o,styleCache:s,nodeMap:a,reconcileRisk:c,clipWindow:f}=await Ts(n.element,n.options)),c>0&&!e.reconcile&&(St(e.__session,"reconcile-risk","text in inline/table-cell elements kept natural width and may re-wrap; pass { reconcile: true } for pixel-exact layout"),P.warnedReconcile||(P.warnedReconcile=!0,console.warn("[snapdom] Text in inline/table-cell elements kept its natural width and may re-wrap under font-fallback rasterization. Pass { reconcile: true } for pixel-exact layout (roughly doubles capture time)."))),!y&&r&&(u=bs(n.element,r)),!b&&r&&As(n.element,r,n.options),r&&(Es(n.element,r,a),Ms(n.element,r))}finally{C()}if(n.clone=r,n.classCSS=i,n.styleCache=s,n.nodeMap=a,await Nt("afterClone",n),!$e(p,"render"))return null;if(Dn(n.clone),n.options?.excludeMode==="remove"||typeof n.options?.filter=="function"&&n.options.filterMode==="remove")try{_s(n.element,n.clone,n.styleCache,n.nodeMap)}catch(E){St(e.__session,"shrink-failed","shrink pass failed",E),console.warn("[snapdom] shrink pass failed:",E)}try{await Rn(n.clone,n.element,n.nodeMap)}catch{}let x=E=>Promise.resolve().then(E),S=(async()=>{await Promise.all([x(()=>Un(n.clone,n.options)),x(()=>zn(n.element,n.clone,n.styleCache,n.options,n.nodeMap))]);try{Ns(n.element,n.clone,n.nodeMap)}catch(E){St(e.__session,"backdrop-filter-failed","backdrop-filter emulation failed",E),console.warn("[snapdom] backdrop-filter emulation failed:",E)}if(e.compress&&(e.__compressionClip=f,e.__compressionRootTransform=u,await x(()=>Zn(n.clone,n.options,n.nodeMap))),e.captureSelection)try{Ui(n.nodeMap)}catch(E){St(e.__session,"selection-compose-failed","field selection compose failed",E)}})(),A=Promise.resolve();(e.embedFonts==="auto"?((n.element.ownerDocument||document).fonts?.size||0)>0:e.embedFonts)&&(A=x(async()=>{let E=n.element.ownerDocument||document,T=w?H=>{try{let _=H.getBoundingClientRect();return _.right>=w.left-200&&_.left<=w.right+200&&_.bottom>=w.top-200&&_.top<=w.bottom+200}catch{return!0}}:null,{required:N,usedCodepoints:O}=!w&&e.__fontUsage||Pn(n.element,T);if(e.embedFonts==="auto"){let H=new Set;try{for(let L of E.fonts)H.add(String(L.family).replace(/["']/g,"").toLowerCase())}catch{}if(!(H.size>0&&Array.from(N).some(L=>H.has(String(L).split("__")[0].toLowerCase()))))return}if(Y()){let H=new Set(Array.from(N).map(_=>String(_).split("__")[0]).filter(Boolean));await Nn(H,1,E)}l=await es({required:N,usedCodepoints:O,exclude:n.options.excludeFonts,localFonts:n.options.localFonts,useProxy:n.options.useProxy,fontStylesheetDomains:n.options.fontStylesheetDomains,iconMatchers:n.options.__iconMatchers,doc:E})})),await Promise.all([S,A]);let M=(n.options.plugins||[]).some(E=>E&&(typeof E.beforeRender=="function"||typeof E.afterRender=="function"));n.options.engine;let k=n.clone;Jn(k,e.__compressedAssets);let R=await tr(n,{clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,fontsCSS:l});if(e.__compressedSnapshot=Qn(k,e.__compressedAssets),typeof e.__retain=="function")try{e.__retain({clone:r,nodeMap:a,styleCache:s,styleMap:e.__session.styleMap,classPrefixCSS:o,fontsCSS:l,clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,__compressedAssets:e.__compressedAssets,__compressionDensity:e.__compressionDensity})}catch{}return R}dt();bt();var fu=new Set(["png","jpeg","jpg","webp","svg"]);function ta(t={}){let e=typeof t.type=="string"&&fu.has(t.type.toLowerCase())?t.type.toLowerCase():null,n=t.format??e??"png";n==="jpg"&&(n="jpeg");let r=t.format!=null?n:e==="jpg"?"jpeg":e,i=zo(t.cache),o=t.exclude==null?[]:Array.isArray(t.exclude)?t.exclude:[t.exclude],s=[],a=[];for(let u of o)typeof u=="string"?s.push(u):typeof u=="function"?a.push(u):u!=null&&console.warn("[snapdom] Ignored invalid exclude entry (expected selector string or predicate):",u);let c=t.excludeMode??"hide",f=u=>{if(!u||u.nodeType!==1)return!1;if(u.getAttribute("data-capture")==="exclude")return!0;for(let p of Array.isArray(l.exclude)?l.exclude:[])try{if(u.matches(p))return!0}catch{}for(let p of Array.isArray(l.excludePredicates)?l.excludePredicates:[])try{if(p(u))return!0}catch{}if(typeof l.filter=="function")try{if(!l.filter(u))return!0}catch{}return!1},l={debug:t.debug??!1,scale:t.scale??1,exclude:s,excludePredicates:a.length?a:null,excludeMode:c,filter:t.filter??null,filterMode:t.filterMode??"hide",shouldExclude:f,placeholders:t.placeholders!==!1,captureSelection:t.captureSelection??!1,canvas:rt(t.canvas,"canvas")?t.canvas:null,embedFonts:t.embedFonts??"auto",iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],__iconMatchers:Vi(t.iconFonts),localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fontStylesheetDomains:Array.isArray(t.fontStylesheetDomains)?t.fontStylesheetDomains:[],fallbackURL:t.fallbackURL??void 0,cache:i,__styleShare:t.__styleShare,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:n,__explicitFormat:r,type:n,quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(n)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1,reconcile:t.reconcile??!1,burst:t.burst,engine:t.engine,invalidate:t.invalidate??!1,__pinned:t.__pinned===!0,clip:t.clip??null,compress:t.compress!==!1,excludeStyleProps:t.excludeStyleProps??null,resolvePicturePlaceholders:t.resolvePicturePlaceholders!==!1};return l}kt();Qt();ht();var ea="svg,iframe,canvas,video,audio,object,embed,slot,template,picture,style,pre";function uu(t){try{return t.matches?.("dialog,[popover]")||!!t.querySelector?.("dialog,[popover]")}catch{return!0}}var du=/(?:^|;)\s*(?:-webkit-)?backdrop-filter:\s*(?!none(?:\s*!important)?(?:;|$))[^;]+/i;function pu(t){if(t.__usesBackdropFilter!==void 0)return t.__usesBackdropFilter;let e=!1;for(let n of t.styleMap.values())if(du.test(n)){e=!0;break}return t.__usesBackdropFilter=e,e}function hu(t,e){let n=e.has("backdrop-filter")||e.has("-webkit-backdrop-filter");if(!n&&(n=(o=>/(?:^|;)\s*(?:-webkit-)?backdrop-filter\s*:/i.test(o.getAttribute?.("style")||""))(t),!n))try{n=!!t.querySelector?.('[style*="backdrop-filter" i]')}catch{n=!0}if(!n)return!1;let r=[t];t.querySelectorAll&&r.push(...t.querySelectorAll("*"));for(let i of r){let o=getComputedStyle(i),s=o.getPropertyValue("backdrop-filter")||o.getPropertyValue("-webkit-backdrop-filter");if(s&&s!=="none")return!0}return!1}var wo=new WeakMap;function mu(t,e){if(wo.has(e))return wo.get(e);let n=!1,r={budget:2e4},i=o=>{for(let s=0;s<o.length&&!n;s++){if(--r.budget<0){n=!0;return}let a=o[s],c=a.selectorText;if(c&&/[+~]|:has\(/.test(c)){n=!0;return}let f=a.style;if(f&&(f.counterReset||f.counterIncrement||f.counterSet||f.content&&f.content.includes("counter"))){n=!0;return}a.cssRules&&a.cssRules.length&&i(a.cssRules)}};try{for(let o of t.styleSheets){let s=null;try{s=o.cssRules}catch{n=!0}if(n)break;s&&i(s)}if(!n){let o=t.adoptedStyleSheets;if(Array.isArray(o))for(let s of o){if(n)break;try{i(s.cssRules)}catch{n=!0}}}}catch{n=!0}return wo.set(e,n),n}var gu=1/16;function yu(t,e){if(t===e)return!0;if(!t.endsWith("px")||!e.endsWith("px"))return!1;let n=parseFloat(t),r=parseFloat(e);return Number.isFinite(n)&&Number.isFinite(r)&&Math.abs(n-r)<=gu}var er=new Map,bu=["width","height","min-width","min-height"];function wu(t){let e=er.get(t);if(e===void 0){e=null;for(let n of bu){let r=t.match(new RegExp("(?:^|;)"+n+":([^;]+)"));r&&r[1].endsWith("px")&&((e||={})[n]=r[1])}er.size>5e3&&er.clear(),er.set(t,e)}return e}function Su(t){if(!(!t.classList||!t.classList.length))for(let e of Array.from(t.classList))/^c\d+$/.test(e)&&t.classList.remove(e)}function xu(t,e){let n=[t];for(;n.length;){let r=n.pop();if(r.nodeType===1){let i=e.nodeMap.get(r);i!==void 0&&(e.nodeMap.delete(r),e.srcToClone.get(i)===r&&e.srcToClone.delete(i)),e.styleMap.delete(r)}for(let i=r.firstChild;i;i=i.nextSibling)n.push(i)}}var So={attempts:0,served:0,reconciled:0};async function na(t,e,n){So.attempts++;try{let r=await vu(t,e,n);return r&&So.served++,r}catch{return null}}async function vu(t,e,n){let r=e.retained;if(!r||!r.clone||!r.styleMap||!r.srcToClone||n.reconcile||n.clip||n.captureSelection||r.clipWindow||t.scrollTop||t.scrollLeft||uu(t)||pu(r)||r.fontsCSS||Xn(n))return null;for(let u of n.plugins||[])if(u&&(typeof u.beforeSnap=="function"||typeof u.beforeClone=="function"||typeof u.resolveNode=="function"||typeof u.afterClone=="function"))return null;if(r.classPrefixCSS&&(r.classPrefixCSS.includes("::marker")||r.classPrefixCSS.includes("::first-line"))||n.excludeMode==="remove")return null;let i=t.ownerDocument||document,o=Ze(t);if(!o||mu(i,o))return null;let s=[];t:for(let u of e.dirtyRoots){if(!u.isConnected||u===t||!t.contains(u))return null;for(let p of e.dirtyRoots)if(p!==u&&p!==t&&p.contains(u))continue t;s.push(u)}if(!s.length)return null;n.__compressedAssets=r.__compressedAssets,n.__compressionDensity=r.__compressionDensity,n.__compressionRootTransform=r.rootTransform2D;for(let u of s){if(u.parentElement===t||u.matches?.(ea)||u.querySelector?.(ea)||hu(u,o))return null;let p=r.srcToClone.get(u);if(!p||!p.parentNode)return null;let h=new Map,d={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:h,options:n},m=qn(u,null),g=Wn(u),y;try{y=await ie(u,d,n)}finally{g(),m()}if(!y||y.nodeType!==1||y.querySelector?.("style[data-sd]")||(await _e(u,y,d,n),d.__pseudoCSS))return null;await Cn(y,d),Dn(y);try{await Rn(y,u,h)}catch{}if(await Promise.all([Un(y,n),zn(u,y,r.styleCache,n,h)]),n.compress)try{await Zn(y,n,h)}catch{}for(let[b,w]of h.entries())po(b,w);p.replaceWith(y),xu(p,r);for(let[b,w]of h.entries())r.nodeMap.set(b,w),r.srcToClone.set(w,b)}let a={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:r.nodeMap,options:n};for(let[u,p]of r.nodeMap.entries()){if(!p||p.nodeType!==1||!p.isConnected)continue;let h=r.styleMap.get(u);if(!h)continue;let d=wu(h);if(!d)continue;let m=null,g=!1;for(let y in d)if(m||=getComputedStyle(p),!yu(m.getPropertyValue(y),d[y])){g=!0;break}if(g){if(n.__compressedAssets?.has(u))return null;So.reconciled++,await lt(p,u,a,n)}}let c=Ge(r.styleMap);for(let[u,p]of r.styleMap.entries())Su(u),uo(u,p,c);let f=(r.classPrefixCSS||"")+Array.from(c.entries()).map(([u,p])=>`.${p}{${u}}`).join("");Jn(r.clone,n.__compressedAssets);let l=await tr({element:t,options:n,plugins:n.plugins,clone:r.clone,classCSS:f,styleCache:r.styleCache,nodeMap:r.nodeMap},{clipWindow:null,outerTransforms:r.outerTransforms,outerShadows:r.outerShadows,rootTransform2D:r.rootTransform2D,fontsCSS:r.fontsCSS||""});return n.__compressedSnapshot=Qn(r.clone,n.__compressedAssets),r.__compressedAssets=n.__compressedAssets,r.__compressionDensity=n.__compressionDensity,l}bt();var vo=new WeakMap,rr=new WeakMap,da=new WeakSet,xo=new WeakMap,ku=64,an=new Map,pa=["scroll","input","change","focusin","focusout","pointerdown","pointerup","pointercancel","keydown","keyup","beforetoggle","toggle"],Cu=["(prefers-color-scheme: dark)","(prefers-reduced-motion: reduce)","(prefers-contrast: more)","(forced-colors: active)","(inverted-colors: inverted)","(prefers-reduced-transparency: reduce)","(hover: hover)","(any-hover: hover)","(pointer: coarse)","(any-pointer: coarse)","(color-gamut: p3)","(dynamic-range: high)"];function Au(t){let e=t?.defaultView;return typeof e?.matchMedia!="function"?"":Cu.map(n=>{try{return e.matchMedia(n).matches?"1":"0"}catch{return"?"}}).join("")}function ra(t){let e=[];for(let n=t;n;){try{let r=n.getBoundingClientRect();e.push(r.x,r.y,r.width,r.height)}catch{e.push("?")}n.parentElement?n=n.parentElement:n=n.getRootNode?.()?.host||null}return e.join("|")}function oa(t,e){if(e.disposed||(an.delete(t),an.set(t,e),an.size<=ku))return;let[n,r]=an.entries().next().value;ha(n,r)}function ha(t,e){e.disposed=!0,an.delete(t),vo.delete(t);for(let n of e.observers)try{n.disconnect()}catch{}for(let n of pa)t.removeEventListener(n,e.onMediaDirty,!0);for(let n of e.trackedShadowRoots.keys())for(let r of Co)n.removeEventListener(r,e.onMediaDirty,!0);for(let[n,r]of e.trackedImages)n.removeEventListener("load",r),n.removeEventListener("error",r);e.trackedImages.clear(),e.trackedShadowRoots.clear(),e.images.length=0,e.controls.length=0,e.scrollNodes.length=0,e.observers.length=0,e.last=null,e.retained=null,e.retainedFrameDriven=!1}function ma(t){if(da.has(t))return!1;rr.delete(t);let e=[t],n=[],r=[];for(let i=0;i<e.length;i++){let o=e[i],s=[];o?.nodeType===1&&s.push(o);try{s.push(...o.querySelectorAll("*"))}catch{return!1}for(let a of s){a.shadowRoot&&e.push(a.shadowRoot);let c=String(a.localName||a.tagName||"").toLowerCase();if(/^(?:iframe|canvas|video|audio|object|embed|marquee|blink)$/.test(c)||c==="progress"&&!a.hasAttribute("value")||/^(?:animate|animatetransform|animatemotion|set)$/.test(c))return!1;let f="";if(c==="img"){r.push(a);try{f=a.currentSrc||a.src||""}catch{}}/^(?:input|textarea|select|option)$/.test(c)&&n.push(a);let l=a.getAttribute?.("style")||"",u=xo.get(a);if(f||l){if((!u||u.src!==f||u.style!==l)&&(u={src:f,style:l,animated:We(f)||We(l)},xo.set(a,u)),u.animated)return!1}else u&&xo.delete(a)}}return rr.set(t,{roots:e.slice(1),controls:n,images:r}),!0}function ko(t,e){if(!t.querySelectorAll)return!1;let n=rr.get(t);rr.delete(t);let r=new Set(n?.roots||[]);if(n&&(e.controls=n.controls,e.scannedImages=n.images),!n){let i=[t];for(let o=0;o<i.length;o++){let s=i[o];s.shadowRoot&&!r.has(s.shadowRoot)&&(r.add(s.shadowRoot),i.push(s.shadowRoot));for(let a of s.querySelectorAll("*"))a.shadowRoot&&!r.has(a.shadowRoot)&&(r.add(a.shadowRoot),i.push(a.shadowRoot))}}for(let[i,o]of e.trackedShadowRoots)if(!r.has(i)){try{o.disconnect()}catch{}for(let a of Co)i.removeEventListener(a,e.onMediaDirty,!0);e.trackedShadowRoots.delete(i);let s=e.observers.indexOf(o);s>=0&&e.observers.splice(s,1)}for(let i of r)if(!e.trackedShadowRoots.has(i))try{let o=new MutationObserver(e.markDirty);o.observe(i,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),o.__flush=e.markDirty,e.observers.push(o),e.trackedShadowRoots.set(i,o);for(let s of Co)i.addEventListener(s,e.onMediaDirty,{capture:!0,passive:!0});e.retained&&e.dirtyAll()}catch{}return!!n}var Co=["scroll","change","beforetoggle","toggle"];function or(t,e){return[t,...e.trackedShadowRoots.keys()]}function Ao(t,e){let n=e.scannedImages;if(e.scannedImages=null,!n){n=[],t.tagName==="IMG"&&n.push(t);for(let r of or(t,e))r.querySelectorAll&&n.push(...r.querySelectorAll("img"))}if(e.images=n,e.trackedImages.size){let r=new Set(n);for(let[i,o]of e.trackedImages)r.has(i)||(i.removeEventListener("load",o),i.removeEventListener("error",o),e.trackedImages.delete(i))}for(let r of n){if(r.complete||e.trackedImages.has(r))continue;let i=()=>{e.capturing&&(e.torn=!0),e.dirty=!0,e.dirtyRoots=null,r.removeEventListener("load",i),r.removeEventListener("error",i),e.trackedImages.delete(r)};e.trackedImages.set(r,i),r.addEventListener("load",i),r.addEventListener("error",i)}}function Mu(t){let e=new Map,n=new Map,r=new Map;for(let i of t)if(te(i))if(i.type==="attributes"){let o=e.get(i.target);o||e.set(i.target,o=new Map),o.has(i.attributeName)||o.set(i.attributeName,i.oldValue)}else if(i.type==="characterData")n.has(i.target)||n.set(i.target,i.oldValue);else if(i.type==="childList"){let o=r.get(i.target);o||r.set(i.target,o=new Map);for(let s of i.addedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)+1)}for(let s of i.removedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)-1)}}else return!0;for(let[i,o]of e)for(let[s,a]of o)if(i.getAttribute(s)!==a)return!0;for(let[i,o]of n)if(i.data!==o)return!0;for(let i of r.values())for(let o of i.values())if(o!==0)return!0;return!1}var Eu=/(?:^data:image\/(?:gif|apng)|\.(?:gif|apng)(?=[?#)'"\s;]|$))/i,Ie=t=>t&&(typeof t=="object"||typeof t=="function")?nr(t):"-";function _u(t,e=131072){if(t=String(t||"").trim(),!/^data:/i.test(t))return"";let n=t.indexOf(",");if(n<0)return"";let r=t.slice(0,n),i=t.slice(n+1);try{if(/;base64/i.test(r)){let o=Math.ceil(e/3)*4;return atob(i.slice(0,o-o%4))}return i.slice(0,e*3).replace(/%([0-9a-f]{2})/gi,(o,s)=>String.fromCharCode(parseInt(s,16))).slice(0,e)}catch{return""}}function Ru(t){let e=(t.match(/^data:([^;,]+)/i)?.[1]||"").toLowerCase();if(e==="image/gif"||e==="image/apng")return!0;if(!/image\/(?:png|webp|avif|svg\+xml)/.test(e))return!1;let n=_u(t);return e==="image/png"?n.includes("acTL"):e==="image/webp"?n.includes("ANIM")||n.includes("ANMF")||n.includes("VP8X")&&!!(n.charCodeAt(n.indexOf("VP8X")+8)&2):e==="image/avif"?n.includes("avis"):/<(?:animate|animateTransform|animateMotion|set)\b|@keyframes\b|animation(?:-name)?\s*:/i.test(n)}function ia(t){let e=String(t||"").trim();return e?Eu.test(e)?!0:/^data:/i.test(e)?Ru(e):!1:!1}function We(t){let e=String(t||"");if(ia(e))return!0;for(let n of e.matchAll(/url\(\s*(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|([^)]*))\s*\)/gi))if(ia(n[1]??n[2]??n[3]))return!0;return!1}function sa(t,e=null){let n=t&&t.clone;if(!n)return!1;let r=e?e.map(i=>t.srcToClone?.get(i)).filter(Boolean):[n];for(let i of r)for(let o of ga(i))if(We(o.getAttribute?.("src"))||We(o.getAttribute?.("href"))||We(o.getAttribute?.("style"))||We(t.styleMap?.get(o)))return!0;return!1}function ga(t){let e=[];t&&t.nodeType===1&&e.push(t);try{e.push(...t.querySelectorAll("*"))}catch{}return e}function Mo(t,e){let n=[],r=new Set,i=o=>{o&&!r.has(o)&&(r.add(o),n.push(o))};t.matches?.("input,textarea,select,option")&&i(t);for(let o of or(t,e))try{for(let s of o.querySelectorAll("input,textarea,select,option"))i(s)}catch{}e.controls=n}function Eo(t,e){let n=[],r=new Set,i=(o,s=!1)=>{if(!(!o||r.has(o))){r.add(o);try{(s||o.scrollLeft||o.scrollTop||o.scrollWidth>o.clientWidth||o.scrollHeight>o.clientHeight)&&n.push(o)}catch{}}};for(let o=t;o;o=o.parentElement)i(o,!0);for(let o of or(t,e))for(let s of ga(o))i(s);e.scrollNodes=n}function aa(t,e){let n=t.ownerDocument||document,r=n.defaultView,i=[r?.location?.hash||"",Au(n),r?.innerWidth||0,r?.innerHeight||0,r?.devicePixelRatio||1,r?.screen?.orientation?.type||""];try{i.push(...[...n.adoptedStyleSheets||[]].map(Ie))}catch{}for(let l of e.trackedShadowRoots.keys())try{i.push("#shadow",...[...l.adoptedStyleSheets||[]].map(Ie))}catch{}let o=n.activeElement,s=n.fullscreenElement;(o?.contains(t)||t.contains(o))&&i.push(Ie(o)),(s?.contains(t)||t.contains(s))&&i.push(Ie(s));let a=[r?.scrollX||0,r?.scrollY||0];for(let l of e.scrollNodes)a.push(l.scrollLeft||0,l.scrollTop||0);let c=[];for(let l of e.controls){let u=String(l.localName||"").toLowerCase();u==="input"?c.push(l.type,Ve(l)?l.value.length:l.value,l.checked?1:0,l.indeterminate?1:0):u==="textarea"?c.push(l.value):u==="select"?c.push(l.selectedIndex,l.value):c.push(l.selected?1:0)}let f=[];for(let l of e.images){let u="";try{u=l.currentSrc||l.src||""}catch{}f.push(u,l.complete?1:0,l.naturalWidth||0,l.naturalHeight||0)}return{style:i.join("|"),scroll:a.join("|"),controls:c,images:f,frameDriven:e.retainedFrameDriven}}function Le(t,e,n){if(!t)return!1;let r=t[n],i=e[n];if(r===i)return!0;if(!Array.isArray(r)||r.length!==i.length)return!1;for(let o=0;o<r.length;o++)if(r[o]!==i[o])return!1;return!0}function ca(t,e){let n=new Set;for(let r of or(t,e))try{let i=r.getAnimations?.(r.nodeType===1?{subtree:!0}:void 0)||[];for(let o of i)n.add(o)}catch{}return[...n]}function la(t){return t.map(e=>[Ie(e),e.playState,Math.round((Number(e.currentTime)||0)*10),e.playbackRate].join(":")).join("|")}function Fu(t,e,n){if(!n||n.nodeType!==1)return null;if(n===t||t.contains(n))return t;for(let r of e.trackedShadowRoots.keys())if(r.contains(n))return r;return null}function Tu(t){let e={dirty:!0,pending:[],torn:!1,dirtyRoots:new Set,retained:null,retainedFrameDriven:!1,disposed:!1,capturing:!1,last:null,inflight:Promise.resolve(),observers:[],trackedShadowRoots:new Map,trackedImages:new Map,images:[],scannedImages:null,scrollNodes:[],controls:[],envEpoch:we(),styleEpoch:ee(),styleStamp:Je(t),outsideMutations:wn(t),geometry:null,renderState:null},n=()=>{e.dirty=!0,e.dirtyRoots=null},r=a=>{if(!e.dirtyRoots)return;let c=a&&(a.nodeType===1?a:a.parentElement);if(!c||c===t||!t.contains(c)||e.dirtyRoots.size>=12){e.dirtyRoots=null;return}e.dirtyRoots.add(c)},i=a=>{if(e.capturing){for(let c of a)e.pending.push(c);return}for(let c of a)te(c)&&(e.dirty=!0,r(c.target))},o=()=>{if(e.capturing){e.torn=!0;return}n()};e.dirtyAll=n;try{let a=new MutationObserver(i);a.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),a.__flush=i,e.observers.push(a)}catch{}e.markDirty=i,e.onMediaDirty=o;try{for(let a of pa)t.addEventListener(a,o,{capture:!0,passive:!0})}catch{}return ko(t,e)||Mo(t,e),Eo(t,e),Ao(t,e),e}var $u=0,fa=new WeakMap;function nr(t){let e=fa.get(t);return e||(e="@"+ ++$u,fa.set(t,e)),e}function _o(t,e){let n=typeof t;if(n==="undefined")return null;if(t===null||n==="boolean"||n==="number"||n==="string")return JSON.stringify(t);if(n==="function"||n==="symbol")return n==="symbol"?null:JSON.stringify(nr(t));if(n!=="object")return null;if(typeof t.nodeType=="number")return JSON.stringify(nr(t));if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let s of t){let a=_o(s,e);if(a===null)return null;o.push(a)}return"["+o.join(",")+"]"}let r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)return JSON.stringify(nr(t));let i=[];for(let o of Object.keys(t).sort()){let s=t[o];if(s===void 0)continue;let a=_o(s,e);if(a===null)return null;i.push(JSON.stringify(o)+":"+a)}return"{"+i.join(",")+"}"}finally{e.delete(t)}}function ua(t,e){let{burst:n,invalidate:r,...i}=t||{};try{let o=_o(i,new Set);return o===null?null:`${(e||[]).map(Ie).join(",")}:${o}`}catch{return null}}function ya(t,e,n,r,i=null){let o=vo.get(t);o||(o=Tu(t),o.baselineSignature=ua(e,n.plugins),vo.set(t,o));let s=ua(e,n.plugins),a=async()=>{if(o.disposed)return r();let f=s===null||s!==o.baselineSignature;f&&s!==null?o.pendingSig===s?(o.baselineSignature=s,o.last=null,o.dirty=!0,o.dirtyRoots=null,o.pendingSig=null,f=!1):o.pendingSig=s:o.pendingSig=null,ko(t,o),Ao(t,o);for(let A of o.observers)A.__flush(A.takeRecords());Rt();let l=wn(t);o.dirty&&o.outsideMutations!==l&&o.dirtyAll(),o.outsideMutations=l;let u=t.getRootNode?.(),p=[...o.trackedShadowRoots.keys()];u?.nodeType===11&&!p.includes(u)&&p.push(u),xn(t.ownerDocument||document,p);let h=Je(t);o.styleStamp!==h&&(o.styleStamp=h,o.dirty||o.dirtyAll());let d=aa(t,o),m=ca(t,o);d.animation=la(m),o.renderState&&(!Le(o.renderState,d,"style")&&(Se(),o.dirtyAll()),Le(o.renderState,d,"scroll")||o.dirtyAll(),Le(o.renderState,d,"controls")||(ne(t),o.dirtyAll()),!Le(o.renderState,d,"images")&&!o.dirty&&o.dirtyAll());let g=we();o.envEpoch!==g&&(o.dirtyAll(),o.envEpoch=g);let y=ee();if(o.styleEpoch!==y&&(o.styleEpoch=y,!o.dirty)){let A=ra(t);o.geometry!==null&&A!==o.geometry&&(ne(t),o.dirtyAll()),o.geometry=A}n.invalidate&&o.dirtyAll();let b=!1,w=!!o.renderState&&!Le(o.renderState,d,"animation");try{let A=new Set;w&&m.length===0&&(A=null);for(let v of m){let M=v.playState==="running";if(!M&&!w)continue;M&&(b=!0),w=!0;let k=v.effect?.target;if(Fu(t,o,k)===t)A.add(k);else{A=null;break}}if(w&&A&&A.size&&o.retained){o.dirty=!0;for(let v of A)o.dirtyRoots&&o.dirtyRoots.add(v),ne(v)}else w&&!A&&o.dirtyAll()}catch{}let C=d.frameDriven,x=b||C;if(x&&(o.last=null),C&&o.dirtyAll(),!f&&!x&&!o.dirty&&o.last)return oa(t,o),o.last;o.capturing=!0;let S=null;try{let A=null,v=!1,M=null;if(!f&&o.dirty&&o.retained&&o.dirtyRoots&&o.dirtyRoots.size&&i){M=[...o.dirtyRoots];let k=await na(t,o,n);k&&(A=await i(k),v=!0)}if(A||(f||(n.__retain=k=>{let R=new Map;for(let[E,T]of k.nodeMap.entries())R.set(T,E);S={...k,srcToClone:R}}),A=await r()),!f&&!o.disposed){o.dirty=!1,o.dirtyRoots=new Set,S?(o.retained=S,o.retainedFrameDriven=sa(S),Mo(t,o),Eo(t,o)):v&&(o.retainedFrameDriven||=sa(o.retained,M),Mo(t,o),Eo(t,o));let k=aa(t,o);k.animation=la(ca(t,o));let R=["style","scroll","controls","images"];b||R.push("animation");let E=R.every(T=>Le(d,k,T));o.renderState=k,o.styleEpoch=ee(),o.styleStamp=Je(t),o.geometry=ra(t),o.renderState.frameDriven?(da.add(t),ha(t,o)):E?!x&&!o.renderState.frameDriven&&(o.last=A,oa(t,o)):(o.dirtyAll(),o.last=null)}return A}finally{n.__retain=void 0;for(let v of o.observers)for(let M of v.takeRecords())o.pending.push(M);Rt();let A=wn(t);(o.torn||Mu(o.pending)||A!==l)&&(o.dirtyAll(),o.last=null),o.outsideMutations=A,o.styleEpoch=ee(),o.styleStamp=Je(t),o.pending.length=0,o.torn=!1,o.capturing=!1,o.disposed||(ko(t,o),Ao(t,o))}},c=o.inflight.then(a,a);return o.inflight=c.catch(()=>{}),c}var ir=null;function Sa(t){ir=t}var Pu='button, a[href], [role="button"], input, select, summary, label, [tabindex]',Ro=!1,cn=null,Fo=new WeakMap,ba=!1;function xa(t,e){!Ro||!cn||e&&e.burst===!1||Fo.set(cn.control,{element:t,options:e&&typeof e=="object"?{...e}:e})}function va(t){let e={control:t};cn=e,setTimeout(()=>{cn===e&&(cn=null)},0)}function $o(t){let e=t.target,n=e&&(e.nodeType===1?e:e.parentElement);return n&&n.closest?n.closest(Pu):null}function wa(t){if(t.type==="keydown"&&t.key!=="Enter"&&t.key!==" ")return;let e=$o(t);e&&(va(e),To(t,!1))}function Nu(t){let e=$o(t);e&&va(e)}function To(t,e=!0){if(!ir||document.visibilityState==="hidden")return;let n=$o(t);if(!n||t.type==="pointerenter"&&t.target!==n)return;let r=Fo.get(n);if(r){if(!r.element.isConnected){Fo.delete(n);return}ir(r.element,r.options).catch(()=>{});return}e&&!ba&&(ba=!0,ir(document.body,{clip:"viewport",burst:!1}).catch(()=>{}))}function ka(){if(Ro||typeof document>"u"||typeof document.addEventListener!="function")return;Ro=!0;let t={capture:!0,passive:!0};document.addEventListener("pointerdown",wa,t),document.addEventListener("keydown",wa,t),document.addEventListener("click",Nu,t),document.addEventListener("pointerenter",To,t),document.addEventListener("focusin",To,t)}wt();function td(...t){return ho(...t),X}async function ed(t,e){if(typeof t!="string"||!t.trim())throw new Error("[snapdom.fromString] html string required");let n=document.createElement("div");J(n),n.style.cssText="position:fixed;left:-99999px;top:0;pointer-events:none;",n.innerHTML=t,document.body.appendChild(n);try{await pt();let r=Array.from(n.childNodes).some(o=>o.nodeType===3&&o.textContent.trim()),i=n.children.length===1&&!r?n.firstElementChild:n;return await Ho(i,{...e||{},burst:!1})}finally{n.remove()}}var nd="3.0.0",X=Object.assign(Ho,{plugins:td,fromString:ed,version:nd,preCapture:ka});Sa(Ho);var Uo=Symbol("snapdom.internal"),rd=Symbol("snapdom.internal.silent"),La=new Set(["png","jpeg","jpg","webp","svg"]);async function Ho(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=ta(e);n.element=t,n.invalidate&&Se(),zs(n,e&&e.plugins);let{stage:r,loweredBy:i}=Ds(n);n.needs=r,n.__needsLoweredBy=i;let o=$e(r,"render"),s=n.burst===!0||!Xn(n),a=typeof n.filter=="function"||!!n.excludePredicates||typeof n.excludeStyleProps=="function"||typeof n.fallbackURL=="function",f=o&&!n.captureSelection&&n.burst!==!1&&s&&!a&&ma(t);return f&&xa(t,e),n.snap||(n.snap={toPng:(l,u)=>X.toPng(l,u),toSvg:(l,u)=>X.toSvg(l,u)}),f?ya(t,e,n,()=>X.capture(t,n,Uo),l=>Ia(l,n)):X.capture(t,n,Uo)}X.capture=async(t,e,n)=>{if(n!==Uo)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");if($e(e.needs||ft,"render")&&Y()){if(e.embedFonts)try{let o=t.ownerDocument||document,s=new Set;if(e.embedFonts==="auto"){try{for(let l of o.fonts)s.add(String(l.family).replace(/["']/g,"").toLowerCase())}catch{}if(s.size===0)throw null}let a=Pn(t);e.clip||(e.__fontUsage=a);let c=a.required,f=new Set([...c].map(l=>String(l).split("__")[0]).filter(Boolean));if(e.embedFonts==="auto"&&(f=new Set([...f].filter(l=>s.has(l.toLowerCase()))),f.size===0))throw null;await Nn(f,1,o)}catch{}let i=Array.from(t.querySelectorAll("canvas"));t.tagName==="CANVAS"&&i.unshift(t);for(let o of i)try{if(nn(o))continue;let s=o.getContext("2d",{willReadFrequently:!0});s&&s.getImageData(0,0,1,1)}catch(s){D(e,"safari canvas poke failed",s)}}let r=await Zs(t,e);return Ia(r,e)};async function Ia(t,e){let n=e.needs||ft,r=$e(n,"render"),i=_=>Us(n,e.__needsLoweredBy||[],_),o=typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?t:null,s=o?null:t,a=()=>s??=o.toDataURL(),c=o||t;o&&(t="");let f=e.__compressedSnapshot,l=e.__compressionDensity;delete e.__compressedSnapshot,delete e.__compressedAssets;let u,p=e.meta||{},d=(Number.isFinite(e.width)||Number.isFinite(e.height))&&!Y(),m=d?Number.isFinite(e.width)?p.targetW/p.vbW:p.targetH/p.vbH:1,g=d?Number.isFinite(e.height)?p.targetH/p.vbH:p.targetW/p.vbW:1,y=_=>{if(o||!f?.size)return c;let L=p.vbW,$=p.vbH,F=_.crop;F&&(L=Math.max(1,Math.min(L,F.x+F.width)-Math.max(0,F.x)),$=Math.max(1,Math.min($,F.y+F.height)-Math.max(0,F.y)));let V=Number.isFinite(_.width),z=Number.isFinite(_.height);return(V&&z?Math.max(_.width/L,_.height/$):V?_.width/L*(F?Math.max(1,g/m):1):z?_.height/$*(F?Math.max(1,m/g):1):(_.scale||1)*Math.max(m,g))*(_.dpr||1)<=l?c:u??=Ys(a(),f)},b=async(_,L)=>{let{rasterize:$}=await Promise.resolve().then(()=>(De(),un));return $(c,{..._,...L||{},format:"png"})},w=()=>{if(!r)throw i("svgString");if(o)throw new Error("[snapdom] svgString: engine:'html-in-canvas' produces a raster capture; there is no serialized SVG");let _=t.indexOf(",");return _>=0?decodeURIComponent(t.slice(_+1)):""},C=_=>Object.defineProperty({..._||{},svgString:w},"url",r?{get:a,enumerable:!0}:{get(){throw i("export.url")},enumerable:!1,configurable:!0}),x={img:async(_,L)=>{if(o)return b(_,L);let{toImg:$}=await Promise.resolve().then(()=>(Oo(),Wo)),F={..._,...L||{}};return $(y(F),F)},svg:async(_,L)=>{if(o)return b(_,L);let{toSvg:$}=await Promise.resolve().then(()=>(Oo(),Wo)),F={..._,...L||{}};return $(y(F),F)},canvas:async(_,L)=>{let{toCanvas:$}=await Promise.resolve().then(()=>(Oe(),Fa)),F={..._,...L||{}};return $(y(F),F)},blob:async(_,L)=>{let{toBlob:$}=await Promise.resolve().then(()=>(Bo(),Ta)),F={..._,...L||{}};return $(y(F),F)},png:async(_,L)=>{let{rasterize:$}=await Promise.resolve().then(()=>(De(),un)),F={..._,...L||{},format:"png"};return $(y(F),F)},jpeg:async(_,L)=>{let{rasterize:$}=await Promise.resolve().then(()=>(De(),un)),F={..._,...L||{},format:"jpeg"};return $(y(F),F)},webp:async(_,L)=>{let{rasterize:$}=await Promise.resolve().then(()=>(De(),un)),F={..._,...L||{},format:"webp"};return $(y(F),F)},download:async(_,L)=>{let{download:$}=await Promise.resolve().then(()=>(Na(),Pa)),F={..._,...L||{}};return $(y(F),F)}};if(!r)for(let _ of Object.keys(x)){let L=_==="download"?"download()":`to${_.charAt(0).toUpperCase()}${_.slice(1)}()`;x[_]=async()=>{throw i(L)}}let S={};for(let _ of["img","svg","canvas","blob","png","jpeg","webp"])S[_]=async L=>x[_](e,{...E(_,L||{}),[rd]:!0});S.jpg=S.jpeg;let A=_=>Object.defineProperty({...e,..._},"options",{value:e,configurable:!0}),v=A({artifacts:e.__artifacts||null,export:C(),exports:S}),M=await Gn("defineExports",v),k=Object.assign({},...M.filter(_=>_&&typeof _=="object").reverse()),R={...x,...k};R.jpeg&&!R.jpg&&(R.jpg=(_,L)=>R.jpeg(_,L));function E(_,L){let $=L||{},F={...e,...$},V=typeof $.type=="string"?$.type.toLowerCase():"",z=typeof $.format=="string"?$.format.toLowerCase():La.has(V)?V:"";z&&(F.format=z==="jpg"?"jpeg":z),F.__explicitFormat=z?F.format:e.__explicitFormat??null,_==="blob"&&!F.__explicitFormat&&(F.format=o?"png":"svg"),F.type=F.format;let q=Z=>Z==="jpeg"||Z==="jpg"||Z==="webp";return[_,F.format,V].map(Z=>typeof Z=="string"?Z.toLowerCase():"").find(q)&&(F.backgroundColor==null||F.backgroundColor==="transparent")&&(F.backgroundColor="#ffffff"),F.scale!==1&&(Number.isFinite(F.width)||Number.isFinite(F.height))&&D(F,"width/height define the output size \u2014 scale is ignored when either is set"),F}let T=!1,N=Promise.resolve();async function O(_,L){let $=Object.freeze(L&&typeof L=="object"?{...L}:{}),F=async()=>{let z=R[_];if(!z)throw new Error(`[snapdom] Unknown export type: ${_}`);let q=E(_,$),B=A({artifacts:e.__artifacts||null,export:C({type:_,options:q,requestedOptions:$})}),Z=q.format,Mt=q.type;await Gn("beforeExport",B,{format:_,options:q});let Lt=q.format!==Z?q.format:q.type!==Mt?q.type:"",gt=typeof Lt=="string"?Lt.toLowerCase():"";La.has(gt)&&(q.format=gt==="jpg"?"jpeg":gt,q.type=q.format,q.__explicitFormat=q.format,/^(?:jpeg|webp)$/.test(q.format)&&(q.backgroundColor==null||q.backgroundColor==="transparent")&&(q.backgroundColor="#ffffff"));let st=await z(B,q);return await Gn("afterExport",B,{format:_,options:q,result:st}),T||(T=!0,await Nt("afterSnap",e)),st},V=N.then(F);return N=V.catch(()=>{}),V}let H={url:t,needs:n,warnings:e.__session&&e.__session.warnings||[],toRaw:()=>{if(!r)throw i("toRaw()");return a()},to:(_,L)=>O(_,L),toImg:_=>O("img",_),toSvg:_=>O("svg",_),toCanvas:_=>O("canvas",_),toBlob:_=>O("blob",_),toPng:_=>O("png",_),toJpg:_=>O("jpg",_),toWebp:_=>O("webp",_),download:_=>O("download",_)};r?o&&Object.defineProperty(H,"url",{get:a,enumerable:!0,configurable:!0}):Object.defineProperty(H,"url",{get(){throw i("url")},enumerable:!1,configurable:!0}),Object.defineProperty(H,"meta",r?{value:e.meta,enumerable:!0}:{get(){throw i("meta")},enumerable:!1,configurable:!0});for(let _ of Object.keys(R)){let L="to"+_.charAt(0).toUpperCase()+_.slice(1);H[L]||(H[L]=$=>O(_,$))}return H}X.toRaw=(t,e)=>X(t,e).then(n=>n.toRaw());X.toImg=(t,e)=>X(t,e).then(n=>n.toImg());X.toSvg=(t,e)=>X(t,e).then(n=>n.toSvg());X.toCanvas=(t,e)=>X(t,e).then(n=>n.toCanvas());X.toBlob=(t,e)=>X(t,e).then(n=>n.toBlob());X.toPng=(t,e)=>X(t,{...e,format:"png"}).then(n=>n.toPng());X.toJpg=(t,e)=>X(t,{...e,format:"jpeg"}).then(n=>n.toJpg());X.toWebp=(t,e)=>X(t,{...e,format:"webp"}).then(n=>n.toWebp());X.download=(t,e)=>X(t,e).then(n=>n.download());export{ft as DEFAULT_STAGE,Te as STAGES,Bs as assertNeeds,Wf as clearPlugins,mo as getGlobalPlugins,Ne as normalizePlugin,ho as registerPlugins,X as snapdom};
</code_context>
<issue_to_address>
**security (javascript.browser.security.insecure-document-method):** User controlled data in methods like `innerHTML`, `outerHTML` or `document.write` is an anti-pattern that can lead to XSS vulnerabilities
*Source: opengrep*
</issue_to_address>
### Comment 2
<location path="src/components/BootstrapBlazor.Dom2Image/wwwroot/lib/snapdom.mjs" line_range="39" />
<code_context>
}`,Yf=Math.max(1,Math.min(4,(typeof navigator<"u"&&navigator.hardwareConcurrency||2)-1)),Ft=null,Kf=0,Qf=0,ae=new Map;function Js(){for(let t of ae.values())t(void 0);if(ae.clear(),Array.isArray(Ft))for(let t of Ft)try{t?.terminate()}catch{}Ft=!1}function Jf(){let t,e=null;try{t=URL.createObjectURL(new Blob([Xf],{type:"text/javascript"})),e=new Worker(t),e.onmessage=n=>{let r=ae.get(n.data.id);r&&(ae.delete(n.data.id),r(n.data.error?void 0:n.data.url??null))},e.onerror=Js}catch{e=null}return t&&URL.revokeObjectURL(t),e}function Zf(){if(Ft===!1)return!1;if(Ft===null){if(typeof Worker>"u"||typeof OffscreenCanvas>"u")return Ft=!1;Ft=[]}let t=Kf++%Yf;if(!Ft[t]){let e=Jf();if(!e)return Js(),!1;Ft[t]=e}return Ft[t]}var tu=5e3;function eu(t,e,n,r,i){let o=Zf();return o?new Promise(s=>{let a=++Qf,c=setTimeout(()=>{ae.delete(a),s(void 0)},tu);ae.set(a,f=>{clearTimeout(c),s(f)});try{o.postMessage({id:a,dataURL:i?"":t,blob:i,srcLength:t.length,targetW:e,targetH:n,resFactor:Qs,quality:Ks,mime:r})}catch{clearTimeout(c),ae.delete(a),s(void 0)}}):Promise.resolve(void 0)}async function yo(t,e,n,r){if(typeof t!="string"||!t.startsWith("data:image")||t.startsWith("data:image/svg"))return null;e=Math.ceil(e),n=Math.ceil(n);let i=t.length+":"+t.slice(0,64)+t.slice(-64)+":"+e+"x"+n,o=P.compress,s=o.get(i);if(s?.source===t)return s.result;let a=Yn.get(i);if(a?.source===t&&a.cache===o)return a.promise;let c=(async()=>{let l=zf(t),u=l==="image/jpeg"?"image/jpeg":l==="image/webp"?"image/webp":"image/png",p=Gf(t);if(p&&p.w>0&&p.h>0&&!qs(p.w,p.h,e,n))return null;if(t.length>=jf){let S=await eu(t,e,n,u,r);if(S!==void 0)return S}let h;try{h=await Hf(t)}catch{return null}let d=h.naturalWidth||h.width,m=h.naturalHeight||h.height;if(!d||!m)return null;let g=qs(d,m,e,n);if(!g)return null;let y=g*Qs,b=Math.max(1,Math.round(d*y)),w=Math.max(1,Math.round(m*y)),C=document.createElement("canvas");C.width=b,C.height=w;let x=C.getContext("2d");if(!x)return null;x.imageSmoothingEnabled=!0,x.imageSmoothingQuality="high",x.drawImage(h,0,0,b,w);try{let S=C.toDataURL(u,Ks);if(typeof S=="string"&&S.startsWith("data:image")&&S.length<t.length)return S}catch{}return null})(),f={source:t,promise:c,cache:o};Yn.set(i,f);try{let l=await c;return Vf(o,i,t,l),l}finally{Yn.get(i)===f&&Yn.delete(i)}}async function nu(t,e,n=new Map,r={}){if(!e.compress)return{count:0,before:0,after:0};let i=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&i.unshift(t);let o=0,s=0,a=0,c=async l=>{let u=l.getAttribute("src")||"";if(!u.startsWith("data:image")||u.startsWith("data:image/svg"))return;let p=parseFloat(l.dataset.snapdomWidth)||parseFloat(l.style.width)||l.width||0,h=parseFloat(l.dataset.snapdomHeight)||parseFloat(l.style.height)||l.height||0;if(!p||!h)return;let d=r.value||=go(t,e),m=d.density*d.stretch(n.get(l)||l),g=await yo(u,p*m,h*m,l.__snapdomBlob);g&&(o++,s+=u.length,a+=g.length,l.setAttribute("src",g),Kn(l,"attribute","src",u,g,e))},f=6;for(let l=0;l<i.length;l+=f)await Promise.allSettled(i.slice(l,l+f).map(c));return{count:o,before:s,after:a}}var ru=/^(cover|contain|(\d+(\.\d+)?%(\s+\d+(\.\d+)?%)?))$/;function ou(t){let e=t.offsetWidth||t.getBoundingClientRect().width||0,n=t.offsetHeight||t.getBoundingClientRect().height||0;return{w:e,h:n}}async function iu(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=[],o=[t,...t.querySelectorAll("*")];for(let f of o){let l=f.style&&f.style.backgroundImage;l&&l.includes("data:image")&&i.push(f)}let s=0,a=async f=>{let l=n.get(f);if(!l||!l.isConnected)return;let u;try{u=getComputedStyle(l)}catch{return}if((u.backgroundRepeat||"repeat").toLowerCase().split(",").some(v=>v.trim()!=="no-repeat"))return;let h=(f.style.backgroundSize||u.backgroundSize||"auto").toLowerCase();if(h.split(",").some(v=>!ru.test(v.trim())))return;let{w:d,h:m}=ou(l);if(!d||!m)return;let g=Math.max(1,...(h.match(/\d+(?:\.\d+)?%/g)||[]).map(v=>parseFloat(v)/100)),y=r.value||=go(t,e),b=y.density*y.stretch(l)*g,w=d*b,C=m*b,x=f.style.backgroundImage,S=[...x.matchAll(/url\((['"]?)(data:image\/[^)'"]+)\1\)/gi)],A=x;for(let v of S){let M=v[2];if(M.startsWith("data:image/svg"))continue;let k=await yo(M,w,C);k&&(A=A.split(M).join(k),s++)}A!==x&&(f.style.setProperty("background-image",A,f.style.getPropertyPriority("background-image")),Kn(f,"style","background-image",x,f.style.backgroundImage,e))},c=6;for(let f=0;f<i.length;f+=c)await Promise.allSettled(i.slice(f,f+c).map(a));return{count:s}}async function su(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=Array.from(t.querySelectorAll("image"));t.localName==="image"&&i.unshift(t);let o=0,s=async c=>{let f=c.getAttribute("href")||(typeof c.getAttributeNS=="function"?c.getAttributeNS("http://www.w3.org/1999/xlink","href"):null);if(!f||!f.startsWith("data:image")||f.startsWith("data:image/svg"))return;let l=c.getAttribute("width")||"",u=c.getAttribute("height")||"";if(l.includes("%")||u.includes("%"))return;let p=n.get(c),h=p?W(p):c.style,d=(C,x)=>{if(/^\d+(?:\.\d+)?px$/.test(h?.[C]||""))return parseFloat(h[C]);if(/^\d+(?:\.\d+)?(?:px)?$/.test(x.trim()))return parseFloat(x);try{return p?.[C]?.baseVal?.value||0}catch{return 0}},m=d("width",l),g=d("height",u);if(!m||!g)return;let y=r.value||=go(t,e),b=y.density*y.stretch(p||c),w=await yo(f,m*b,g*b);w&&(c.setAttribute("href",w),Kn(c,"attribute","href",f,w,e),c.hasAttribute("xlink:href")&&(c.setAttributeNS(Gs,"xlink:href",w),Kn(c,"attribute","xlink:href",f,w,e)),o++)},a=6;for(let c=0;c<i.length;c+=a)await Promise.allSettled(i.slice(c,c+a).map(s));return{count:o}}async function Zn(t,e,n){if(!e.compress)return;let r={};await nu(t,e,n,r),await iu(t,e,n,r),await su(t,e,n,r)}ht();dt();wt();function au(t,e){if(Y())return t;let n=t.indexOf("</style>");if(n===-1)return t;let r=/<style\b[^>]*>[\s\S]*?<\/style>/g,i=[],o=n,s;for(r.lastIndex=n;s=r.exec(t);)i.push({text:t.slice(o,s.index),intern:!0}),i.push({text:s[0],intern:!1}),o=r.lastIndex;i.push({text:t.slice(o),intern:!0});let a=new Map,c=/ style="([^"]*)"/g,f;for(let y of i)if(y.intern)for(c.lastIndex=0;f=c.exec(y.text);)a.set(f[1],(a.get(f[1])||0)+1);let l=0;for(let[y,b]of a)b>1&&(l+=(b-1)*y.length);if(l<2048||t.includes(" data-sdi="))return t;let u=cu(e,i.some(y=>!y.intern),t.includes("data-snapdom-asset"));if(u===null)return t;let p=new Map,h=0,d=[],m=(y,b)=>{if((a.get(b)||0)<2||u.has(b))return y;let w=p.get(b);return w===void 0&&(w="i"+(h++).toString(36),p.set(b,w),d.push(`[data-sdi="${w}"]{${b}}`)),` data-sdi="${w}"`},g="";for(let y of i)g+=y.intern?y.text.replace(c,m):y.text;return t.slice(0,n)+d.join("")+g}function cu(t,e,n){let r=new Set;if(!e&&!n)return r;if(!t||t.querySelector("[data-sdi]"))return null;let i=c=>{let f=c.getAttribute("style");f&&r.add(f)};if(n&&t.querySelectorAll("[data-snapdom-asset][style]").forEach(i),e)try{let c=f=>{for(let l of f){if(l.type===CSSRule.IMPORT_RULE||l.type===CSSRule.NAMESPACE_RULE)throw new Error("External or namespaced CSS");if(l.selectorText){if(/\[\s*style\b|data-sdi|\[[^\]]*\\|&/i.test(l.selectorText))throw new Error("Attribute-dependent or nested CSS");t.querySelectorAll(l.selectorText).forEach(i)}l.cssRules&&c(l.cssRules)}};for(let f of[...t.querySelectorAll("style")].slice(1)){let l=f.textContent||"";if(/@import\b/i.test(l))return null;let u=new CSSStyleSheet;u.replaceSync(l),c(u.cssRules)}}catch{return null}let o=new Set,s=document.createElement("div"),a=new XMLSerializer;for(let c of r){s.setAttribute("style",c);let f=a.serializeToString(s).match(/ style="([^"]*)"/);f&&o.add(f[1])}return o}async function tr(t,e){let{clipWindow:n,outerTransforms:r,outerShadows:i,rootTransform2D:o,fontsCSS:s}=e,a=t.options;if(t!==a){let{options:K,...tt}=t;t=Object.assign(a,tt),Object.defineProperty(t,"options",{value:t,configurable:!0})}let c,f;Fs(t,s),await Nt("beforeRender",t);let l=W(t.element),u=t.element.getBoundingClientRect(),p=Math.max(1,I(t.element.offsetWidth||parseFloat(l.width)||u.width||1)),h=Math.max(1,I(t.element.offsetHeight||parseFloat(l.height)||u.height||1)),d=t.element.ownerDocument||document;if(!n&&(t.element===d.body||t.element===d.documentElement)&&!t.__pinned){let K=Math.max(t.element.scrollHeight||0,d.documentElement?.scrollHeight||0,d.body?.scrollHeight||0),tt=Math.max(t.element.scrollWidth||0,d.documentElement?.scrollWidth||0,d.body?.scrollWidth||0);K>0&&(h=Math.max(h,I(K))),tt>0&&(p=Math.max(p,I(tt)));try{let Q=(t.scrollbarCSS||"").length+(t.baseCSS||"").length+(t.fontsCSS||"").length+(t.classCSS||"").length,et=P.measureHints.get(t.element);if(et&&et.cssLen===Q&&et.w0===p&&et.docH===K&&et.docW===tt)et.csh>0&&(h=Math.max(h,I(et.csh))),et.csw>0&&(p=Math.max(p,I(et.csw)));else{let nt=d.createElement("div");J(nt),nt.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+p+"px!important;overflow:visible!important;visibility:hidden!important;";let Xt=nt.attachShadow({mode:"open"}),Yt=d.createElement("style");Yt.textContent=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS,Xt.appendChild(Yt),Xt.appendChild(t.clone.cloneNode(!0)),d.body.appendChild(nt);let He=nt.scrollHeight,Ot=nt.scrollWidth;d.body.removeChild(nt),P.measureHints.set(t.element,{cssLen:Q,w0:p,docH:K,docW:tt,csh:He,csw:Ot}),He>0&&(h=Math.max(h,I(He))),Ot>0&&(p=Math.max(p,I(Ot)))}}catch{}}if(t.options?.excludeMode==="remove"||typeof t.options?.filter=="function"&&t.options.filterMode==="remove"){let K=fo(t.element,t.options),tt=1,Q=fo(t.element,{}),et=Math.max(2,h*.15);Number.isFinite(Q)&&Q>=h-et&&Number.isFinite(K)&&K>0&&(h=Math.max(1,Math.min(h,I(K+tt))))}if(t.options?.reconcile)try{let K=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS;Rs(t.element,t.clone,K,t.nodeMap,p,h)}catch(K){console.warn("[snapdom] reconcile pass failed:",K)}let g=(K,tt=NaN)=>{let Q=typeof K=="string"?parseFloat(K):K;return Number.isFinite(Q)?Q:tt},y=g(t.options.width),b=g(t.options.height),w=n?I(n.width):p,C=n?I(n.height):h,x=w,S=C,A=Number.isFinite(y),v=Number.isFinite(b),M=C>0?w/C:1;A&&v?(x=Math.max(1,I(y)),S=Math.max(1,I(b))):A?(x=Math.max(1,I(y)),S=Math.max(1,I(x/(M||1)))):v&&(S=Math.max(1,I(b)),x=Math.max(1,I(S*(M||1))));let k=0,R=0,E=p,T=h;if(n){let K=0,tt=0;if(bo(t.element)){let Q=null;if(!r&&o&&Number.isFinite(o.a))Q={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0};else{let et=se(t.element),nt=lo(l.transform&&l.transform!=="none"?l.transform:"",et);nt&&nt.is2D&&(Q={a:nt.a,b:nt.b,c:nt.c,d:nt.d,e:0,f:0})}if(Q&&!(Q.a===1&&Q.b===0&&Q.c===0&&Q.d===1)){let{ox:et,oy:nt}=on(l,p,h),Xt=Re(p,h,Q,et,nt);K=Xt.minX,tt=Xt.minY}}k=I(n.x+K),R=I(n.y+tt),E=I(k+n.width),T=I(R+n.height)}else if(!r&&o&&Number.isFinite(o.a)){let K={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0},tt=Re(p,h,K,0,0);k=I(tt.minX),R=I(tt.minY),E=I(tt.maxX),T=I(tt.maxY)}else if(r&&bo(t.element)){let tt=l.transform&&l.transform!=="none"?l.transform:"",Q=se(t.element),et=qt({baseTransform:tt,rotate:Q.rotate||"0deg",scale:Q.scale,translate:Q.translate,width:p,height:h}),{ox:nt,oy:Xt}=on(l,p,h),Yt=et.is2D?et:new DOMMatrix(et.toString()),He={a:Yt.a,b:Yt.b,c:Yt.c,d:Yt.d,e:0,f:0},Ot=Re(p,h,He,nt,Xt);k=I(Ot.minX),R=I(Ot.minY),E=I(Ot.maxX),T=I(Ot.maxY)}let N=no(l),O=ro(l),H=oo(l),_=io(l),L=so(l),$=u.width>0?(E-k)/u.width:1,F=u.height>0?(T-R)/u.height:1,V=i==="subtree"&&!n?ys(t.element,t.nodeMap,t.styleCache,$,F):{top:0,right:0,bottom:0,left:0},z=n?{top:0,right:0,bottom:0,left:0}:i?{top:I(Math.max(N.top,O.top,V.top)+H.top+_.top+L.bleed.top),right:I(Math.max(N.right,O.right,V.right)+H.right+_.right+L.bleed.right),bottom:I(Math.max(N.bottom,O.bottom,V.bottom)+H.bottom+_.bottom+L.bleed.bottom),left:I(Math.max(N.left,O.left,V.left)+H.left+_.left+L.bleed.left)}:{top:H.top,right:H.right,bottom:H.bottom,left:H.left};k=I(k-z.left),R=I(R-z.top),E=I(E+z.right),T=I(T+z.bottom);let q=Math.max(1,I(E-k)),B=Math.max(1,I(T-R)),Z="http://www.w3.org/2000/svg",Mt=bo(t.element)?2:0,gt=I(Mt+(r?0:1)),st=Math.ceil(q+gt*2),at=Math.ceil(B+gt*2),$t=I(-(I(k)-gt)),U=I(-(I(R)-gt)),G=Math.max(0,$t),j=Math.max(0,U),ut=I(st-Math.min(0,$t)),Et=I(at-Math.min(0,U)),yt=document.createElementNS(Z,"foreignObject");yt.setAttribute("x",String(Math.min(0,$t))),yt.setAttribute("y",String(Math.min(0,U))),yt.setAttribute("width",String(ut)),yt.setAttribute("height",String(Et)),yt.style.overflow="visible";let fe=document.createElement("style"),dn="svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}";fe.textContent=(t.scrollbarCSS||"")+t.baseCSS+t.fontsCSS+dn+t.classCSS,yt.appendChild(fe);let Be=document.createElement("div");Be.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),Be.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${ut}px;height:${Et}px`+(G!==0||j!==0?`;padding:${j}px 0 0 ${G}px !important`:""),Be.appendChild(t.clone),yt.appendChild(Be);let fr=new XMLSerializer().serializeToString(yt),It=A||v,ur=Object.freeze({w0:w,h0:C,vbW:st,vbH:at,targetW:x,targetH:S,contentX:I($t+(n?k:0)),contentY:I(U+(n?R:0)),clip:n?Object.freeze({x:I(k),y:I(R),width:w,height:C}):null});Object.defineProperty(a,"meta",{value:ur,enumerable:!0,writable:!1,configurable:!0});let dr=!It||Y()?st:A?x:I(st*(S/at)),pn=!It||Y()?at:v?S:I(at*(x/st)),Wt=parseFloat(W(d.documentElement)?.fontSize)||16;f=`<svg xmlns="${Z}" width="${dr}" height="${pn}" viewBox="0 0 ${st} ${at}" font-size="${Wt}px">`+au(fr,yt)+"</svg>",c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,t.svgString=f,t.dataURL=c,a.__artifacts={classCSS:t.classCSS||"",fontsCSS:t.fontsCSS||"",baseCSS:t.baseCSS||"",scrollbarCSS:t.scrollbarCSS||""},await Nt("afterRender",t),t.clone=t.nodeMap=t.styleCache=t.svgString=null;let pr=[...document.querySelectorAll("#snapdom-sandbox")].find(Ut);return pr&&pr.style.position==="absolute"&&pr.remove(),t.dataURL}function bo(t){return ws(t)}function lu(t){let e=Array.isArray(t.plugins)?t.plugins:mo(),n=[];for(let r of e){let i=Ne(r);i&&typeof i.resolveNode=="function"&&n.push(i.resolveNode.bind(i))}return n.length?n:null}async function Zs(t,e){if(!t)throw new Error("Element cannot be null or undefined");e.__session=Ls(e.cache),delete e.__compressedAssets,delete e.__compressedSnapshot,delete e.__compressionDensity,e.__resolveNodeHooks=lu(e);let n=e;n.element=t,Object.defineProperty(n,"options",{value:n,configurable:!0});let r,i,o,s,a,c,f,l="",u=null,p=e.needs||ft,h=n.format,d=n.type;await Nt("beforeSnap",n);let m=n.format!==h&&/^(?:png|jpe?g|webp|svg)$/i.test(n.format),g=n.type!==d&&/^(?:png|jpe?g|webp|svg)$/i.test(n.type);if(m||g){let E=String(m?n.format:n.type).toLowerCase();n.format=E==="jpg"?"jpeg":E,n.type=n.format,n.__explicitFormat=n.format,/^(?:jpeg|webp)$/.test(n.format)&&(n.backgroundColor==null||n.backgroundColor==="transparent")&&(n.backgroundColor="#ffffff")}await Nt("beforeClone",n);let y=n.outerTransforms!==!1,b=n.outerShadows==="subtree"?"subtree":!!n.outerShadows,w=n.clip?On(n.element,n.clip):null;if(e.__styleShare===void 0)try{e.__styleShare=mi(n.element)&&(typeof n.element.getAnimations!="function"||n.element.getAnimations({subtree:!0}).length===0)}catch{e.__styleShare=!1}let C=qn(n.element,w);try{({clone:r,classCSS:i,classPrefixCSS:o,styleCache:s,nodeMap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #1139
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Update Dom2Image to version 10.0.6 with refreshed image capture support and corrected download handling.
Bug Fixes:
Enhancements:
Build: