@zumer/snapdom 2.0.0-dev.3 → 2.0.0-dev.4
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.
- package/README.md +50 -9
- package/dist/modules/chunks/chunk-23Q2XEDO.js +7 -0
- package/dist/modules/chunks/chunk-2FBS3OGP.js +7 -0
- package/dist/modules/chunks/chunk-43NWAKSV.js +7 -0
- package/dist/modules/chunks/chunk-5EIHY65Z.js +7 -0
- package/dist/modules/chunks/chunk-6FO4Y3OG.js +10 -0
- package/dist/modules/chunks/chunk-AOOOETXS.js +7 -0
- package/dist/modules/chunks/chunk-DV3SVS7E.js +10 -0
- package/dist/modules/chunks/chunk-FPOOW4FJ.js +7 -0
- package/dist/modules/chunks/chunk-FQFF5KMG.js +7 -0
- package/dist/modules/chunks/chunk-GU6SHZKJ.js +7 -0
- package/dist/modules/chunks/chunk-JUQT3OWD.js +7 -0
- package/dist/modules/chunks/chunk-LO3HOQZX.js +8 -0
- package/dist/modules/chunks/chunk-MI3WCG7V.js +8 -0
- package/dist/modules/chunks/chunk-R6NINER4.js +7 -0
- package/dist/modules/chunks/chunk-TWGUMDQG.js +10 -0
- package/dist/modules/chunks/chunk-UI252PBJ.js +7 -0
- package/dist/modules/chunks/chunk-XUQSCYHL.js +10 -0
- package/dist/modules/chunks/chunk-ZHRUQIHZ.js +7 -0
- package/dist/modules/chunks/rasterize-NVVIIRN2.js +7 -0
- package/dist/modules/chunks/rasterize-XGEI2GKT.js +7 -0
- package/dist/modules/exporters/download.js +7 -0
- package/dist/modules/exporters/toBlob.js +7 -0
- package/dist/modules/exporters/toCanvas.js +7 -0
- package/dist/modules/exporters/toImg.js +7 -0
- package/dist/modules/exporters/toJpg.js +7 -0
- package/dist/modules/exporters/toPng.js +7 -0
- package/dist/modules/exporters/toSvg.js +7 -0
- package/dist/modules/exporters/toWebp.js +7 -0
- package/dist/modules/plugins.js +7 -0
- package/dist/modules/preCache.js +7 -0
- package/dist/modules/snapdom.js +7 -0
- package/dist/snapdom.js +13 -5187
- package/dist/snapdom.mjs +1569 -1328
- package/package.json +29 -24
- package/dist/snapdom.min.js +0 -8
- package/dist/snapdom.min.mjs +0 -8
package/dist/snapdom.min.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var x={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function Ft(t="soft"){switch(x.session.__counterEpoch=(x.session.__counterEpoch||0)+1,t){case"auto":{x.session.styleMap=new Map,x.session.nodeMap=new Map;return}case"soft":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap,x.computedStyle=new WeakMap,x.baseStyle=new Map,x.defaultStyle=new Map,x.image=new Map,x.background=new Map,x.resource=new Map,x.font=new Set;return}default:{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}}}function ot(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function Yt(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(n,o)=>{let s=o.split(",").map(r=>r.trim());return s.length!==6?`matrix(${o})`:(s[4]="0",s[5]="0",`matrix(${s.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(n,o)=>{let s=o.split(",").map(r=>r.trim());return s.length!==16?`matrix3d(${o})`:(s[12]="0",s[13]="0",`matrix3d(${s.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function G(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function zn(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,s=0;function r(i,l,c){if(s>=n)return;let a=Date.now();(o.get(l)||0)>a||(o.set(l,a+e),s++,i==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(i,l){r("warn",i,l)},errorOnce(i,l){r("error",i,l)},reset(){o.clear(),s=0}}}var be=zn("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Kt=new Map,$t=new Map;function jn(t){return/^data:|^blob:|^about:blank$/i.test(t)}function Vn(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,s=new URL(o||".",n),r=new URL(t,n);if(r.origin===s.origin)return!0;let i=r.searchParams;if(i&&(i.has("url")||i.has("target")))return!0}catch{}return!1}function Xn(t,e){if(!e||jn(t)||Vn(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location<"u"?o.origin!==location.origin:!0}catch{return!!e}}function Yn(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",G(t)).replace("{url}",encodeURIComponent(t));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(t)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(t)}`;if(e.endsWith("/"))return`${e}${G(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function we(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result||"")),o.onerror=()=>n(new Error("read_failed")),o.readAsDataURL(t)})}function Kn(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function T(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,s=e.useProxy||"",r=e.errorTTL??8e3,i=e.headers||{},l=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,m="",b=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],w=/;base64/i.test(m)?atob(b):decodeURIComponent(b),S=new Uint8Array([...w].map(C=>C.charCodeAt(0))),k=new Blob([S],{type:(m||"").split(";")[0]||""});return{ok:!0,data:k,status:200,url:t,fromCache:!1,mime:k.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let m=await fetch(t);if(!m.ok)return{ok:!1,data:null,status:m.status,url:t,fromCache:!1,reason:"http_error"};let b=await m.blob(),g=b.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await we(b),status:m.status,url:t,fromCache:!1,mime:g}:n==="text"?{ok:!0,data:await b.text(),status:m.status,url:t,fromCache:!1,mime:g}:{ok:!0,data:b,status:m.status,url:t,fromCache:!1,mime:g}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(t))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:t,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:t,fromCache:!1};let c=Kn(t,{as:n,timeout:o,useProxy:s,errorTTL:r}),a=$t.get(c);if(a&&a.until>Date.now())return{...a.result,fromCache:!0};a&&$t.delete(c);let u=Kt.get(c);if(u)return u;let d=Xn(t,s)?Yn(t,s):t,p=e.credentials;if(!p)try{let m=typeof location<"u"&&location.href?location.href:"http://localhost/",b=new URL(t,m);p=typeof location<"u"&&b.origin===location.origin?"include":"omit"}catch{p="omit"}let h=new AbortController,y=setTimeout(()=>h.abort("timeout"),o),f=(async()=>{try{let m=await fetch(d,{signal:h.signal,credentials:p,headers:i});if(!m.ok){let w={ok:!1,data:null,status:m.status,url:d,fromCache:!1,reason:"http_error"};if(r>0&&$t.set(c,{until:Date.now()+r,result:w}),!l){let S=`${m.status} ${m.statusText||""}`.trim();be.warnOnce(`http:${m.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${S} while fetching ${n} ${t}`)}return e.onError&&e.onError(w),w}if(n==="text")return{ok:!0,data:await m.text(),status:m.status,url:d,fromCache:!1};let b=await m.blob(),g=b.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await we(b),status:m.status,url:d,fromCache:!1,mime:g}:{ok:!0,data:b,status:m.status,url:d,fromCache:!1,mime:g}}catch(m){let b=m&&typeof m=="object"&&"name"in m&&m.name==="AbortError"?String(m.message||"").includes("timeout")?"timeout":"abort":"network",g={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:b};if(!/^blob:/i.test(t)&&r>0&&$t.set(c,{until:Date.now()+r,result:g}),!l){let w=`${b}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,S=b==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:b==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;be.errorOnce(w,S)}return e.onError&&e.onError(g),g}finally{clearTimeout(y),Kt.delete(c)}})();return Kt.set(c,f),f}async function rt(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=ot(t);if(!o)return t;let s=G(o);if(x.background.has(s)){let r=x.background.get(s);return r?`url("${r}")`:"none"}try{let r=await T(s,{as:"dataURL",useProxy:e.useProxy});return r.ok?(x.background.set(s,r.data),`url("${r.data}")`):(x.background.set(s,null),"none")}catch{return x.background.set(s,null),"none"}}var It=new Set(["meta","script","noscript","title","link","template"]),ft=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),Gn=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"];function Gt(){for(let t of Gn){let e=String(t).toLowerCase();It.has(e)||ft.has(e)||Qt(e)}}function Qt(t){if(t=String(t).toLowerCase(),ft.has(t)){let r={};return x.defaultStyle.set(t,r),r}if(x.defaultStyle.has(t))return x.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),s={};for(let r of o){if(xe(r))continue;let i=o.getPropertyValue(r);s[r]=i}return e.removeChild(n),x.defaultStyle.set(t,s),s}var Qn=/(?:^|-)(animation|transition)(?:-|$)/i,Jn=/^(--|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,Zn=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope"]);function xe(t){let e=String(t).toLowerCase();return!!(Zn.has(e)||Jn.test(e)||Qn.test(e))}function dt(t,e){if(e=String(e||"").toLowerCase(),ft.has(e))return"";let n=[],o=Qt(e);for(let[s,r]of Object.entries(t)){if(xe(s))continue;let i=o[s];r&&r!==i&&n.push(`${s}:${r}`)}return n.sort(),n.join(";")}function Jt(t){let e=new Set;return t.nodeType!==Node.ELEMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(t.tagName&&e.add(t.tagName.toLowerCase()),typeof t.querySelectorAll=="function"&&t.querySelectorAll("*").forEach(n=>e.add(n.tagName.toLowerCase())),Array.from(e))}function Zt(t){let e=new Map;for(let o of t){let s=x.defaultStyle.get(o);if(!s)continue;let r=Object.entries(s).map(([i,l])=>`${i}:${l};`).sort().join("");r&&(e.has(r)||e.set(r,[]),e.get(r).push(o))}let n="";for(let[o,s]of e.entries())n+=`${s.join(",")} { ${o} }
|
|
2
|
-
`;return n}function te(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,o=1;for(let s of e)n.set(s,`c${o++}`);return n}function st(t,e=null){if(!(t instanceof Element))return window.getComputedStyle(t,e);let n=x.computedStyle.get(t);if(n||(n=new Map,x.computedStyle.set(t,n)),!n.has(e)){let o=window.getComputedStyle(t,e);n.set(e,o)}return n.get(e)}function Lt(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function bt(t){let e=[],n=0,o=0;for(let s=0;s<t.length;s++){let r=t[s];r==="("&&n++,r===")"&&n--,r===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function V(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function W(){if(typeof navigator>"u")return!1;let t=navigator.userAgent||"",e=t.toLowerCase(),n=e.includes("safari")&&!e.includes("chrome")&&!e.includes("crios")&&!e.includes("fxios")&&!e.includes("android"),o=/applewebkit/i.test(t),s=/mobile/i.test(t),r=!/safari/i.test(t),i=o&&s&&r,l=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),a=/ipad|iphone|ipod/.test(e)&&o;return n||i||l||c||a}var Se=new WeakMap,ee=new Map,ne=0;function wt(){ne++}var Ce=!1;function to(t=document.documentElement){if(!Ce){Ce=!0;try{new MutationObserver(()=>wt()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>wt()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.("loadingdone",wt),e.ready?.then(()=>wt()).catch(()=>{}))}catch{}}}function eo(t,e={}){let n={},o=t.getPropertyValue("visibility");for(let r=0;r<t.length;r++){let i=t[r],l=t.getPropertyValue(i);(i==="background-image"||i==="content")&&l.includes("url(")&&!l.includes("data:")&&(l="none"),n[i]=l}let s=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let r of s)if(!n[r])try{let i=t.getPropertyValue(r);i&&(n[r]=i)}catch{}if(e.embedFonts){let r=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let i of r)if(!n[i])try{let l=t.getPropertyValue(i);l&&(n[i]=l)}catch{}}return o==="hidden"&&(n.opacity="0"),n}var ke=new WeakMap;function no(t){let e=ke.get(t);return e||(e=Object.entries(t).sort((o,s)=>o[0]<s[0]?-1:o[0]>s[0]?1:0).map(([o,s])=>`${o}:${s}`).join(";"),ke.set(t,e),e)}function oo(t,e=null,n={}){let o=Se.get(t);if(o&&o.epoch===ne)return o.snapshot;let s=e||getComputedStyle(t),r=eo(s,n);return lo(t,s,r),Se.set(t,{epoch:ne,snapshot:r}),r}function ro(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:ee,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:e||{}}:{session:x.session,persist:{snapshotKeyCache:ee,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:t||e||{}}}async function Q(t,e,n,o){if(t.tagName==="STYLE")return;let s=ro(n,o),r=s.options&&s.options.cache||"auto";if(r!=="disabled"&&to(document.documentElement),r==="disabled"&&!s.session.__bumpedForDisabled&&(wt(),ee.clear(),s.session.__bumpedForDisabled=!0),ft.has(t.tagName?.toLowerCase())){let p=t.getAttribute?.("style");p&&e.setAttribute("style",p)}let{session:i,persist:l}=s;i.styleCache.has(t)||i.styleCache.set(t,getComputedStyle(t));let c=i.styleCache.get(t),a=oo(t,c,s.options),u=no(a),d=l.snapshotKeyCache.get(u);if(!d){let p=t.tagName?.toLowerCase()||"div";d=dt(a,p),l.snapshotKeyCache.set(u,d)}i.styleMap.set(e,d)}function so(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function io(t){return t.backgroundImage&&t.backgroundImage!=="none"||t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&t.backgroundColor!=="transparent"||(parseFloat(t.borderTopWidth)||0)>0||(parseFloat(t.borderBottomWidth)||0)>0||(parseFloat(t.paddingTop)||0)>0||(parseFloat(t.paddingBottom)||0)>0?!0:(t.overflowBlock||t.overflowY||"visible")!=="visible"}function ao(t){let e=t.parentElement;if(!e)return!1;let n=getComputedStyle(e).display||"";return n.includes("flex")||n.includes("grid")}function co(t,e){if(t.textContent&&/\S/.test(t.textContent))return!0;let n=t.firstElementChild,o=t.lastElementChild;if(n&&n.tagName==="BR"||o&&o.tagName==="BR")return!0;let s=t.scrollHeight;if(s===0)return!1;let r=parseFloat(e.paddingTop)||0,i=parseFloat(e.paddingBottom)||0;return s>r+i}function lo(t,e,n){if(t instanceof HTMLElement&&t.style&&t.style.height)return;let o=e.display||"";if(o.includes("flex")||o.includes("grid")||so(t))return;let s=e.position;s==="absolute"||s==="fixed"||s==="sticky"||e.transform==="none"&&(io(e)||ao(t)||co(t,e)&&(delete n.height,delete n["block-size"]))}var Me=["fill","stroke","color","background-color","stop-color"],Ae=new Map;function uo(t,e){let n=e+"::"+t.toLowerCase(),o=Ae.get(n);if(o)return o;let s=document,r=e==="http://www.w3.org/2000/svg"?s.createElementNS(e,t):s.createElement(t),i=s.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",i.appendChild(r),s.documentElement.appendChild(i);let l=getComputedStyle(r),c={};for(let a of Me)c[a]=l.getPropertyValue(a)||"";return i.remove(),Ae.set(n,c),c}function ve(t,e){if(!(t instanceof Element)||!(e instanceof Element))return;let n=t.getAttribute?.("style"),o=!!(n&&n.includes("var("));if(!o&&t.attributes?.length){let r=t.attributes;for(let i=0;i<r.length;i++){let l=r[i];if(l&&typeof l.value=="string"&&l.value.includes("var(")){o=!0;break}}}let s=null;if(o)try{s=getComputedStyle(t)}catch{}if(o){let r=t.style;if(r&&r.length)for(let i=0;i<r.length;i++){let l=r[i],c=r.getPropertyValue(l);if(!c||!c.includes("var("))continue;let a=s&&s.getPropertyValue(l);if(a)try{e.style.setProperty(l,a.trim(),r.getPropertyPriority(l))}catch{}}}if(o&&t.attributes?.length){let r=t.attributes;for(let i=0;i<r.length;i++){let l=r[i];if(!l||typeof l.value!="string"||!l.value.includes("var("))continue;let c=l.name,a=s&&s.getPropertyValue(c);if(a)try{e.style.setProperty(c,a.trim())}catch{}}}if(!o){if(!s)try{s=getComputedStyle(t)}catch{s=null}if(!s)return;let r=t.namespaceURI||"html",i=uo(t.tagName,r);for(let l of Me){let c=s.getPropertyValue(l)||"",a=i[l]||"";if(c&&c!==a)try{e.style.setProperty(l,c.trim())}catch{}}}}function Nt(t,e,n){return Promise.all(t.map(o=>new Promise(s=>{function r(){V(i=>{(i&&typeof i.timeRemaining=="function"?i.timeRemaining()>0:!0)?e(o,s):r()},{fast:n})}r()})))}function fo(t){return t=t.trim(),!t||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function mo(t,e,n=!0){return t.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{if(o.startsWith(":where(")||o.startsWith("@"))return o;let s=n?fo(o):o;return`:where(${e} ${s})`}).join(", ")}function Fe(t,e){return t?(t=t.replace(/:host\(([^)]+)\)/g,(n,o)=>`:where(${e}:is(${o.trim()}))`),t=t.replace(/:host\b/g,`:where(${e})`),t=t.replace(/:host-context\(([^)]+)\)/g,(n,o)=>`:where(:where(${o.trim()}) ${e})`),t=t.replace(/::slotted\(([^)]+)\)/g,(n,o)=>`:where(${e} ${o.trim()})`),t=t.replace(/(^|})(\s*)([^@}{]+){/g,(n,o,s,r)=>{let i=mo(r,e,!0);return`${o}${s}${i}{`}),t):""}function $e(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function Ie(t){let e="";try{t.querySelectorAll("style").forEach(o=>{e+=(o.textContent||"")+`
|
|
3
|
-
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{if(o&&o.cssRules)for(let s of o.cssRules)e+=s.cssText+`
|
|
4
|
-
`}catch{}}catch{}return e}function Le(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function Re(t,e){try{let n=t.currentSrc||t.src||"";if(!n)return;e.setAttribute("src",n),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Ne(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function po(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Te(t,e,n){let o=[];for(let s of e){let r=po(t,s);r&&o.push(`${s}: ${r};`)}return o.length?`${n}{${o.join("")}}
|
|
5
|
-
`:""}function Pe(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}async function ho(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),s=0;for(;s<e&&(!o||!o.body&&!o.documentElement);)await new Promise(r=>setTimeout(r,0)),o=n(),s++;return o&&(o.body||o.documentElement)?o:null}function go(t){let e=t.getBoundingClientRect(),n=0,o=0,s=0,r=0;try{let c=getComputedStyle(t);n=parseFloat(c.borderLeftWidth)||0,o=parseFloat(c.borderRightWidth)||0,s=parseFloat(c.borderTopWidth)||0,r=parseFloat(c.borderBottomWidth)||0}catch{}let i=Math.max(0,Math.round(e.width-(n+o))),l=Math.max(0,Math.round(e.height-(s+r)));return{contentWidth:i,contentHeight:l,rect:e}}function yo(t,e,n){let o=t.createElement("style");return o.setAttribute("data-sd-iframe-pin",""),o.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(o),()=>{try{o.remove()}catch{}}}async function _e(t,e,n){let o=await ho(t,3);if(!o)throw new Error("iframe document not accessible/ready");let{contentWidth:s,contentHeight:r,rect:i}=go(t),l=n?.snap;if(!l||typeof l.toPng!="function")throw new Error("snapdom.toPng not available in iframe or window");let c={...n,scale:1},a=yo(o,s,r),u;try{u=await l.toPng(o.documentElement,c)}finally{a()}u.style.display="block",u.style.width=`${s}px`,u.style.height=`${r}px`;let d=document.createElement("div");return e.nodeMap.set(d,t),Q(t,d,e,n),d.style.overflow="hidden",d.style.display="block",d.style.width||(d.style.width=`${Math.round(i.width)}px`),d.style.height||(d.style.height=`${Math.round(i.height)}px`),d.appendChild(u),d}var xt=new Map;async function St(t){if(x.resource?.has(t))return x.resource.get(t);if(xt.has(t))return xt.get(t);let e=(async()=>{let n=await T(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return x.resource?.set(t,n.data),n.data})();xt.set(t,e);try{let n=await e;return xt.set(t,n),n}catch(n){throw xt.delete(t),n}}var bo=/\bblob:[^)"'\s]+/g;async function Ee(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(bo)||[]));if(e.length===0)return t;let n=t;for(let o of e)try{let s=await St(o);n=n.split(o).join(s)}catch{}return n}function Rt(t){return typeof t=="string"&&t.startsWith("blob:")}function wo(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function xo(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function We(t){if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let i of e)try{let c=i.getAttribute("src")||i.currentSrc||"";if(Rt(c)){let u=await St(c);i.setAttribute("src",u)}let a=i.getAttribute("srcset");if(a&&a.includes("blob:")){let u=wo(a),d=!1;for(let p of u)if(Rt(p.url))try{p.url=await St(p.url),d=!0}catch{}d&&i.setAttribute("srcset",xo(u))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let i of n)try{let l="http://www.w3.org/1999/xlink",c=i.getAttribute("href")||i.getAttributeNS?.(l,"href");if(Rt(c)){let a=await St(c);i.setAttribute("href",a),i.removeAttributeNS?.(l,"href")}}catch{}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let i of o)try{let l=i.getAttribute("style");if(l&&l.includes("blob:")){let c=await Ee(l);i.setAttribute("style",c)}}catch{}let s=t.querySelectorAll?t.querySelectorAll("style"):[];for(let i of s)try{let l=i.textContent||"";l.includes("blob:")&&(i.textContent=await Ee(l))}catch{}let r=["poster"];for(let i of r){let l=t.querySelectorAll?t.querySelectorAll(`[${i}^='blob:']`):[];for(let c of l)try{let a=c.getAttribute(i);Rt(a)&&c.setAttribute(i,await St(a))}catch{}}}async function Ct(t,e,n){if(!t)throw new Error("Invalid node");let o=new Set,s=null,r=null;if(t.nodeType===Node.ELEMENT_NODE){let a=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||It.has(a))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide"){let a=document.createElement("div"),u=t.getBoundingClientRect();return a.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,a}else if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let a of n.exclude)try{if(t.matches?.(a)){if(n.excludeMode==="hide"){let u=document.createElement("div"),d=t.getBoundingClientRect();return u.style.cssText=`display:inline-block;width:${d.width}px;height:${d.height}px;visibility:hidden;`,u}else if(n.excludeMode==="remove")return null}}catch(u){console.warn(`Invalid selector in exclude option: ${a}`,u)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide"){let a=document.createElement("div"),u=t.getBoundingClientRect();return a.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,a}else if(n.filterMode==="remove")return null}}catch(a){console.warn("Error in filter function:",a)}if(t.tagName==="IFRAME"){let a=!1;try{a=!!(t.contentDocument||t.contentWindow?.document)}catch{a=!1}if(a)try{return await _e(t,e,n)}catch(u){console.warn("[SnapDOM] iframe rasterization failed, fallback:",u)}if(n.placeholders){let u=document.createElement("div");return u.style.cssText=`width:${t.offsetWidth}px;height:${t.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,Q(t,u,e,n),u}else{let u=t.getBoundingClientRect(),d=document.createElement("div");return d.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,Q(t,d,e,n),d}}if(t.getAttribute("data-capture")==="placeholder"){let a=t.cloneNode(!1);e.nodeMap.set(a,t),Q(t,a,e,n);let u=document.createElement("div");return u.textContent=t.getAttribute("data-placeholder-text")||"",u.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",a.appendChild(u),a}if(t.tagName==="CANVAS"){let a="";try{let d=t.getContext("2d",{willReadFrequently:!0});try{d&&d.getImageData(0,0,1,1)}catch{}if(await new Promise(p=>requestAnimationFrame(p)),a=t.toDataURL("image/png"),!a||a==="data:,"){try{d&&d.getImageData(0,0,1,1)}catch{}if(await new Promise(p=>requestAnimationFrame(p)),a=t.toDataURL("image/png"),!a||a==="data:,"){let p=document.createElement("canvas");p.width=t.width,p.height=t.height;let h=p.getContext("2d");h&&(h.drawImage(t,0,0),a=p.toDataURL("image/png"))}}}catch{}let u=document.createElement("img");try{u.decoding="sync",u.loading="eager"}catch{}a&&(u.src=a),u.width=t.width,u.height=t.height;try{let d=getComputedStyle(t);d.width&&(u.style.width=d.width),d.height&&(u.style.height=d.height)}catch{}return e.nodeMap.set(u,t),Q(t,u,e,n),u}let i;try{if(i=t.cloneNode(!1),ve(t,i),e.nodeMap.set(i,t),t.tagName==="IMG"){Re(t,i);try{let a=t.getBoundingClientRect(),u=Math.round(a.width||0),d=Math.round(a.height||0);if(!u||!d){let p=window.getComputedStyle(t),h=parseFloat(p.width)||0,y=parseFloat(p.height)||0,f=parseInt(t.getAttribute("width")||"",10)||0,m=parseInt(t.getAttribute("height")||"",10)||0,b=t.width||t.naturalWidth||0,g=t.height||t.naturalHeight||0;u=Math.round(u||h||f||b||0),d=Math.round(d||y||m||g||0)}u&&(i.dataset.snapdomWidth=String(u)),d&&(i.dataset.snapdomHeight=String(d))}catch{}}}catch(a){throw console.error("[Snapdom] Failed to clone node:",t,a),a}if(t instanceof HTMLTextAreaElement){let a=t.getBoundingClientRect();i.style.width=`${a.width}px`,i.style.height=`${a.height}px`}if(t instanceof HTMLInputElement&&(i.value=t.value,i.setAttribute("value",t.value),t.checked!==void 0&&(i.checked=t.checked,t.checked&&i.setAttribute("checked",""),t.indeterminate&&(i.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(s=t.value),t instanceof HTMLTextAreaElement&&(r=t.value),Q(t,i,e,n),t.shadowRoot){let m=function(g,w){if(g.nodeType===Node.ELEMENT_NODE&&g.tagName==="STYLE")return w(null);Ct(g,e,n).then(S=>{w(S||null)}).catch(()=>{w(null)})};try{let g=t.shadowRoot.querySelectorAll("slot");for(let w of g){let S=[];try{S=w.assignedNodes?.({flatten:!0})||w.assignedNodes?.()||[]}catch{S=w.assignedNodes?.()||[]}for(let k of S)o.add(k)}}catch{}let a=$e(e),u=`[data-sd="${a}"]`;try{i.setAttribute("data-sd",a)}catch{}let d=Ie(t.shadowRoot),p=Fe(d,u),h=Ne(d),y=Te(t,h,u);Le(i,y+p,a);let f=document.createDocumentFragment(),b=await Nt(Array.from(t.shadowRoot.childNodes),m,n.fast);f.append(...b.filter(g=>!!g)),i.appendChild(f)}if(t.tagName==="SLOT"){let p=function(y,f){Ct(y,e,n).then(m=>{m&&Pe(m),f(m||null)}).catch(()=>{f(null)})},a=t.assignedNodes?.({flatten:!0})||[],u=a.length>0?a:Array.from(t.childNodes),d=document.createDocumentFragment(),h=await Nt(Array.from(u),p,n.fast);return d.append(...h.filter(y=>!!y)),d}function l(a,u){if(o.has(a))return u(null);Ct(a,e,n).then(d=>{u(d||null)}).catch(()=>{u(null)})}let c=await Nt(Array.from(t.childNodes),l,n.fast);if(i.append(...c.filter(a=>!!a)),s!==null&&i instanceof HTMLSelectElement){i.value=s;for(let a of i.options)a.value===s?a.setAttribute("selected",""):a.removeAttribute("selected")}return r!==null&&i instanceof HTMLTextAreaElement&&(i.textContent=r),i}var So=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],mt=Object.assign({materialIconsFilled:"https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2",materialIconsOutlined:"https://fonts.gstatic.com/s/materialiconsoutlined/v110/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcel5euIg.woff2",materialIconsRound:"https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2",materialIconsSharp:"https://fonts.gstatic.com/s/materialiconssharp/v110/oPWQ_lt5nv4pWNJpghLP75WiFR4kLh3kvmvRImcycg.woff2"},typeof window<"u"&&window.__SNAPDOM_ICON_FONTS__||{}),oe=[];function Oe(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?oe.push(n):typeof n=="string"?oe.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function B(t){let e=typeof t=="string"?t:"",n=[...So,...oe];for(let o of n)if(o instanceof RegExp&&o.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}function Co(t=""){let e=String(t).toLowerCase();return/\bmaterial\s*icons\b/.test(e)||/\bmaterial\s*symbols\b/.test(e)}var Ue=new Map;function ko(t=""){let e=Object.create(null),n=String(t||""),o=/['"]?\s*([A-Za-z]{3,4})\s*['"]?\s*([+-]?\d+(?:\.\d+)?)\s*/g,s;for(;s=o.exec(n);)e[s[1].toUpperCase()]=Number(s[2]);return e}async function Ao(t,e,n){let o=String(t||""),s=o.toLowerCase(),r=String(e||"").toLowerCase();if(/\bmaterial\s*icons\b/.test(s)&&!/\bsymbols\b/.test(s))return{familyForMeasure:o,familyForCanvas:o};if(!/\bmaterial\s*symbols\b/.test(s))return{familyForMeasure:o,familyForCanvas:o};let l=n&&(n.FILL??n.fill),c="outlined";/\brounded\b/.test(r)||/\bround\b/.test(r)?c="rounded":/\bsharp\b/.test(r)?c="sharp":/\boutlined\b/.test(r)&&(c="outlined");let a=l===1,u=null;if(a&&(c==="outlined"&&mt.materialIconsFilled?u={url:mt.materialIconsFilled,alias:"snapdom-mi-filled"}:c==="rounded"&&mt.materialIconsRound?u={url:mt.materialIconsRound,alias:"snapdom-mi-round"}:c==="sharp"&&mt.materialIconsSharp&&(u={url:mt.materialIconsSharp,alias:"snapdom-mi-sharp"})),!u)return{familyForMeasure:o,familyForCanvas:o};if(!Ue.has(u.alias))try{let p=new FontFace(u.alias,`url(${u.url})`,{style:"normal",weight:"400"});document.fonts.add(p),await p.load(),Ue.set(u.alias,!0)}catch{return{familyForMeasure:o,familyForCanvas:o}}let d=`"${u.alias}"`;return{familyForMeasure:d,familyForCanvas:d}}async function Mo(t="Material Icons",e=24){try{await Promise.all([document.fonts.load(`400 ${e}px "${String(t).replace(/["']/g,"")}"`),document.fonts.ready])}catch{}}function vo(t){let e=t.getPropertyValue("-webkit-text-fill-color")?.trim()||"",n=/^transparent$/i.test(e)||/rgba?\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e);if(e&&!n&&e.toLowerCase()!=="currentcolor")return e;let o=t.color?.trim();return o&&o!=="inherit"?o:"#000"}async function Eo(t,{family:e="Material Icons",weight:n="normal",fontSize:o=32,color:s="#000",variation:r="",className:i=""}={}){let l=String(e||"").replace(/^['"]+|['"]+$/g,""),c=window.devicePixelRatio||1,a=ko(r),{familyForMeasure:u,familyForCanvas:d}=await Ao(l,i,a);await Mo(d.replace(/^["']+|["']+$/g,""),o);let p=document.createElement("span");p.textContent=t,p.style.position="absolute",p.style.visibility="hidden",p.style.left="-99999px",p.style.whiteSpace="nowrap",p.style.fontFamily=u,p.style.fontWeight=String(n||"normal"),p.style.fontSize=`${o}px`,p.style.lineHeight="1",p.style.margin="0",p.style.padding="0",p.style.fontFeatureSettings="'liga' 1",p.style.fontVariantLigatures="normal",p.style.color=s,document.body.appendChild(p);let h=p.getBoundingClientRect(),y=Math.max(1,Math.ceil(h.width)),f=Math.max(1,Math.ceil(h.height));document.body.removeChild(p);let m=document.createElement("canvas");m.width=y*c,m.height=f*c;let b=m.getContext("2d");b.scale(c,c),b.font=`${n?`${n} `:""}${o}px ${d}`,b.textAlign="left",b.textBaseline="top",b.fillStyle=s;try{b.fontKerning="normal"}catch{}return b.fillText(t,0,0),{dataUrl:m.toDataURL(),width:y,height:f}}async function Be(t,e){if(!(t instanceof Element))return 0;let n='.material-icons, [class*="material-symbols"]',o=Array.from(t.querySelectorAll(n)).filter(i=>i&&i.textContent&&i.textContent.trim());if(o.length===0)return 0;let s=e instanceof Element?Array.from(e.querySelectorAll(n)).filter(i=>i&&i.textContent&&i.textContent.trim()):[],r=0;for(let i=0;i<o.length;i++){let l=o[i],c=s[i]||null;try{let a=getComputedStyle(c||l),u=a.fontFamily||"Material Icons";if(!Co(u))continue;let d=(c||l).textContent.trim();if(!d)continue;let p=parseInt(a.fontSize,10)||24,h=a.fontWeight&&a.fontWeight!=="normal"?a.fontWeight:"normal",y=vo(a),f=a.fontVariationSettings&&a.fontVariationSettings!=="normal"?a.fontVariationSettings:"",m=(c||l).className||"",{dataUrl:b,width:g,height:w}=await Eo(d,{family:u,weight:h,fontSize:p,color:y,variation:f,className:m});l.textContent="";let S=l.ownerDocument.createElement("img");S.src=b,S.alt=d,S.style.height=`${p}px`,S.style.width=`${Math.max(1,Math.round(g/w*p))}px`,S.style.objectFit="contain",S.style.verticalAlign=getComputedStyle(l).verticalAlign||"baseline",l.appendChild(S),r++}catch{}}return r}async function qe(t,e,n,o=32,s="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let r=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let i=document.createElement("span");i.textContent=t,i.style.position="absolute",i.style.visibility="hidden",i.style.fontFamily=`"${e}"`,i.style.fontWeight=n||"normal",i.style.fontSize=`${o}px`,i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.padding="0",i.style.margin="0",document.body.appendChild(i);let l=i.getBoundingClientRect(),c=Math.ceil(l.width),a=Math.ceil(l.height);document.body.removeChild(i);let u=document.createElement("canvas");u.width=Math.max(1,c*r),u.height=Math.max(1,a*r);let d=u.getContext("2d");return d.scale(r,r),d.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,d.textAlign="left",d.textBaseline="top",d.fillStyle=s,d.fillText(t,0,0),{dataUrl:u.toDataURL(),width:c,height:a}}var Fo=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function _t(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!Fo.has(n.toLowerCase()))return n}return""}function Tt(t){let e=String(t??"400").trim().toLowerCase();if(e==="normal")return 400;if(e==="bold")return 700;let n=parseInt(e,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function re(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function $o(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Io(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let s=Tt(n[1]),r=Tt(n[2]);return{min:Math.min(s,r),max:Math.max(s,r)}}let o=Tt(e);return{min:o,max:o}}function Lo(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Ro(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let r=parseFloat(n[1]),i=parseFloat(n[2]);return{min:Math.min(r,i),max:Math.max(r,i)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),s=o?parseFloat(o[1]):100;return{min:s,max:s}}function No(t,e){if(!t)return!1;try{let n=new URL(t,location.href);if(n.origin===location.origin)return!0;let s=n.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(l=>s.endsWith(l)))return!0;let i=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(i)||/\.woff2?(\b|$)/.test(i))return!0;for(let l of e){let c=l.toLowerCase().replace(/\s+/g,"+"),a=l.toLowerCase().replace(/\s+/g,"-");if(i.includes(c)||i.includes(a))return!0}return!1}catch{return!1}}function To(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function De(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,o,s)=>{let r=(s||"").trim();if(!r||/^data:|^blob:|^https?:|^file:|^about:/i.test(r))return n;let i=r;try{i=new URL(r,e||location.href).href}catch{}return`url("${i}")`})}var se=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,Pt=4;async function Po(t,e,n){if(!t)return t;let o=new Set;function s(l,c){try{return new URL(l,c||location.href).href}catch{return l}}async function r(l,c,a=0){if(a>Pt)return console.warn(`[snapDOM] @import depth exceeded (${Pt}) at ${c}`),l;let u="",d=0,p;for(;p=se.exec(l);){u+=l.slice(d,p.index),d=se.lastIndex;let h=(p[2]||p[4]||"").trim(),y=s(h,c);if(o.has(y)){console.warn(`[snapDOM] Skipping circular @import: ${y}`);continue}o.add(y);let f="";try{let m=await T(y,{as:"text",useProxy:n,silent:!0});m.ok&&typeof m.data=="string"&&(f=m.data)}catch{}f?(f=De(f,y),f=await r(f,y,a+1),u+=`
|
|
6
|
-
/* inlined: ${y} */
|
|
7
|
-
${f}
|
|
8
|
-
`):u+=p[0]}return u+=l.slice(d),u}let i=De(t,e||location.href);return i=await r(i,e||location.href,0),i}var ze=/url\((["']?)([^"')]+)\1\)/g,_o=/@font-face[^{}]*\{[^}]*\}/g;function je(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let s=o.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!s)continue;let r=s[1],i=s[2],l=c=>{if(!c.includes("?"))return parseInt(c,16);let a=parseInt(c.replace(/\?/g,"0"),16),u=parseInt(c.replace(/\?/g,"F"),16);return[a,u]};if(i){let c=l(r),a=l(i),u=Array.isArray(c)?c[0]:c,d=Array.isArray(a)?a[1]:a;e.push([Math.min(u,d),Math.max(u,d)])}else{let c=l(r);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function Ve(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,s]of e)if(n>=o&&n<=s)return!0;return!1}function ie(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(ze)){let s=(o[2]||"").trim();if(!(!s||s.startsWith("data:"))){if(!/^https?:/i.test(s))try{s=new URL(s,e||location.href).href}catch{}n.push(s)}}return n}async function Xe(t,e,n=""){let o=t;for(let s of t.matchAll(ze)){let r=ot(s[0]);if(!r)continue;let i=r;if(!i.startsWith("http")&&!i.startsWith("data:"))try{i=new URL(i,e||location.href).href}catch{}if(!B(i)){if(x.resource?.has(i)){x.font?.add(i),o=o.replace(s[0],`url(${x.resource.get(i)})`);continue}if(!x.font?.has(i))try{let l=await T(i,{as:"dataURL",useProxy:n,silent:!0});if(l.ok&&typeof l.data=="string"){let c=l.data;x.resource?.set(i,c),x.font?.add(i),o=o.replace(s[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",i)}}}return o}function Wo(t){if(!t.length)return null;let e=(l,c)=>t.some(([a,u])=>!(u<l||a>c)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),s=e(880,1023),r=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":r?"cyrillic":s?"greek":o?"latin-ext":n?"latin":null}function He(t={}){let e=new Set((t.families||[]).map(s=>String(s).toLowerCase())),n=new Set((t.domains||[]).map(s=>String(s).toLowerCase())),o=new Set((t.subsets||[]).map(s=>String(s).toLowerCase()));return(s,r)=>{if(e.size&&e.has(s.family.toLowerCase()))return!0;if(n.size)for(let i of s.srcUrls)try{if(n.has(new URL(i).host.toLowerCase()))return!0}catch{}if(o.size){let i=Wo(r);if(i&&o.has(i))return!0}return!1}}function Uo(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,o=[];for(let r of t.match(e)||[]){let i=r.match(/font-family:\s*([^;]+);/i)?.[1]||"",l=_t(i),c=(r.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),a=(r.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),u=(r.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),d=(r.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),p=(r.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),h=ie(p,location.href),y=h.length?h.map(m=>String(m).toLowerCase()).sort().join("|"):p.toLowerCase(),f=[String(l||"").toLowerCase(),c,a,u,d.toLowerCase(),y].join("|");n.has(f)||(n.add(f),o.push(r))}if(o.length===0)return t;let s=0;return t.replace(e,()=>o[s++]||"")}function Oo(t,e,n,o){let s=Array.from(t||[]).sort().join("|"),r=e?JSON.stringify({families:(e.families||[]).map(c=>String(c).toLowerCase()).sort(),domains:(e.domains||[]).map(c=>String(c).toLowerCase()).sort(),subsets:(e.subsets||[]).map(c=>String(c).toLowerCase()).sort()}):"",i=(n||[]).map(c=>`${(c.family||"").toLowerCase()}::${c.weight||"normal"}::${c.style||"normal"}::${c.src||""}`).sort().join("|");return`fonts-embed-css::req=${s}::ex=${r}::lf=${i}::px=${o||""}`}async function Ye(t,e,n,o){let s;try{s=t.cssRules||[]}catch{return}let r=(i,l)=>{try{return new URL(i,l||location.href).href}catch{return i}};for(let i of s){if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){let l=i.href?r(i.href,e):e;if(o.depth>=Pt){console.warn(`[snapDOM] CSSOM import depth exceeded (${Pt}) at ${l}`);continue}if(l&&o.visitedSheets.has(l)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${l}`);continue}l&&o.visitedSheets.add(l);let c={...o,depth:(o.depth||0)+1};await Ye(i.styleSheet,l,n,c);continue}if(i.type===CSSRule.FONT_FACE_RULE){let l=(i.style.getPropertyValue("font-family")||"").trim(),c=_t(l);if(!c||B(c))continue;let a=(i.style.getPropertyValue("font-weight")||"400").trim(),u=(i.style.getPropertyValue("font-style")||"normal").trim(),d=(i.style.getPropertyValue("font-stretch")||"100%").trim(),p=(i.style.getPropertyValue("src")||"").trim(),h=(i.style.getPropertyValue("unicode-range")||"").trim();if(!o.faceMatchesRequired(c,u,a,d))continue;let y=je(h);if(!Ve(o.usedCodepoints,y))continue;let f={family:c,weightSpec:a,styleSpec:u,stretchSpec:d,unicodeRange:h,srcRaw:p,srcUrls:ie(p,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(f,y))continue;if(/url\(/i.test(p)){let m=await Xe(p,e||location.href,o.useProxy);await n(`@font-face{font-family:${c};src:${m};font-style:${u};font-weight:${a};font-stretch:${d};${h?`unicode-range:${h};`:""}}`)}else await n(`@font-face{font-family:${c};src:${p};font-style:${u};font-weight:${a};font-stretch:${d};${h?`unicode-range:${h};`:""}}`)}}}async function Wt({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:s=""}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let r=new Map;for(let f of t){let[m,b,g,w]=String(f).split("__");if(!m)continue;let S=r.get(m)||[];S.push({w:parseInt(b,10),s:g,st:parseInt(w,10)}),r.set(m,S)}function i(f,m,b,g){if(!r.has(f))return!1;let w=r.get(f),S=Io(b),k=Lo(m),C=Ro(g),M=S.min!==S.max,L=S.min,I=E=>k.kind==="normal"&&E==="normal"||k.kind!=="normal"&&(E==="italic"||E==="oblique"),N=!1;for(let E of w){let P=M?E.w>=S.min&&E.w<=S.max:E.w===L,U=I(re(E.s)),D=E.st>=C.min&&E.st<=C.max;if(P&&U&&D){N=!0;break}}if(N)return!0;if(!M)for(let E of w){let P=I(re(E.s)),U=E.st>=C.min&&E.st<=C.max;if(Math.abs(L-E.w)<=300&&P&&U)return!0}return!1}let l=He(n),c=Oo(t,n,o,s);if(x.resource?.has(c))return x.resource.get(c);let a=To(t),u=[],d=se;for(let f of document.querySelectorAll("style")){let m=f.textContent||"";for(let b of m.matchAll(d)){let g=(b[2]||b[4]||"").trim();if(!g||B(g))continue;!!document.querySelector(`link[rel="stylesheet"][href="${g}"]`)||u.push(g)}}u.length&&await Promise.all(u.map(f=>new Promise(m=>{if(document.querySelector(`link[rel="stylesheet"][href="${f}"]`))return m(null);let b=document.createElement("link");b.rel="stylesheet",b.href=f,b.setAttribute("data-snapdom","injected-import"),b.onload=()=>m(b),b.onerror=()=>m(null),document.head.appendChild(b)})));let p="",h=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(f=>!!f.href);for(let f of h)try{if(B(f.href))continue;let m="",b=!1;try{b=new URL(f.href,location.href).origin===location.origin}catch{}if(!b&&!No(f.href,a))continue;if(b){let w=Array.from(document.styleSheets).find(S=>S.href===f.href);if(w)try{let S=w.cssRules||[];m=Array.from(S).map(k=>k.cssText).join("")}catch{}}if(!m&&(m=(await T(f.href,{as:"text",useProxy:s})).data,B(f.href)))continue;m=await Po(m,f.href,s);let g="";for(let w of m.match(_o)||[]){let S=(w.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),k=_t(S);if(!k||B(k))continue;let C=(w.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),M=(w.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),L=(w.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),I=(w.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),N=(w.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),E=ie(N,f.href);if(!i(k,M,C,L))continue;let P=je(I);if(!Ve(e,P))continue;let U={family:k,weightSpec:C,styleSpec:M,stretchSpec:L,unicodeRange:I,srcRaw:N,srcUrls:E,href:f.href};if(n&&l(U,P))continue;let D=/url\(/i.test(N)?await Xe(w,f.href,s):w;g+=D}g.trim()&&(p+=g)}catch{console.warn("[snapDOM] Failed to process stylesheet:",f.href)}let y={requiredIndex:r,usedCodepoints:e,faceMatchesRequired:i,simpleExcluder:n?He(n):null,useProxy:s,visitedSheets:new Set,depth:0};for(let f of document.styleSheets)if(!(f.href&&h.some(m=>m.href===f.href)))try{let m=f.href||location.href;m&&y.visitedSheets.add(m),await Ye(f,m,async b=>{p+=b},y)}catch{}try{for(let f of document.fonts||[]){if(!f||!f.family||f.status!=="loaded"||!f._snapdomSrc)continue;let m=String(f.family).replace(/^['"]+|['"]+$/g,"");if(B(m)||!r.has(m)||n?.families&&n.families.some(g=>String(g).toLowerCase()===m.toLowerCase()))continue;let b=f._snapdomSrc;if(!String(b).startsWith("data:")){if(x.resource?.has(f._snapdomSrc))b=x.resource.get(f._snapdomSrc),x.font?.add(f._snapdomSrc);else if(!x.font?.has(f._snapdomSrc))try{let g=await T(f._snapdomSrc,{as:"dataURL",useProxy:s,silent:!0});if(g.ok&&typeof g.data=="string")b=g.data,x.resource?.set(f._snapdomSrc,b),x.font?.add(f._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",f._snapdomSrc);continue}}p+=`@font-face{font-family:'${m}';src:url(${b});font-style:${f.style||"normal"};font-weight:${f.weight||"normal"};}`}}catch{}for(let f of o){if(!f||typeof f!="object")continue;let m=String(f.family||"").replace(/^['"]+|['"]+$/g,"");if(!m||B(m)||!r.has(m)||n?.families&&n.families.some(C=>String(C).toLowerCase()===m.toLowerCase()))continue;let b=f.weight!=null?String(f.weight):"normal",g=f.style!=null?String(f.style):"normal",w=f.stretchPct!=null?`${f.stretchPct}%`:"100%",S=String(f.src||""),k=S;if(!k.startsWith("data:")){if(x.resource?.has(S))k=x.resource.get(S),x.font?.add(S);else if(!x.font?.has(S))try{let C=await T(S,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string")k=C.data,x.resource?.set(S,k),x.font?.add(S);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",S);continue}}p+=`@font-face{font-family:'${m}';src:url(${k});font-style:${g};font-weight:${b};font-stretch:${w};}`}return p&&(p=Uo(p),x.resource?.set(c,p)),p}function Ut(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=i=>{let l=_t(i.fontFamily);if(!l)return;let c=(a,u,d)=>`${l}__${Tt(a)}__${re(u)}__${$o(d)}`;e.add(c(i.fontWeight,i.fontStyle,i.fontStretch))};o(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&o(s);let r=getComputedStyle(t,"::after");for(r&&r.content&&r.content!=="none"&&o(r);n.nextNode();){let i=n.currentNode,l=getComputedStyle(i);o(l);let c=getComputedStyle(i,"::before");c&&c.content&&c.content!=="none"&&o(c);let a=getComputedStyle(i,"::after");a&&a.content&&a.content!=="none"&&o(a)}return e}function Ot(t){let e=new Set,n=s=>{if(s)for(let r of s)e.add(r.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let s=o.currentNode;if(s.nodeType===Node.TEXT_NODE)n(s.nodeValue||"");else if(s.nodeType===Node.ELEMENT_NODE){let r=s;for(let i of["::before","::after"]){let c=getComputedStyle(r,i)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let a=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(a)for(let u of a)try{e.add(parseInt(u.slice(1),16))}catch{}}}}}return e}async function Bt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let s=document.createElement("div");s.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let r of n){let i=document.createElement("span");i.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",i.style.fontFamily=`"${r}"`,i.style.fontWeight="700",i.style.fontStyle="italic",i.style.fontSize="32px",i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.margin="0",i.style.padding="0",s.appendChild(i)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)o(),await new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r)))}function Je(t){return/\bcounter\s*\(|\bcounters\s*\(/.test(t||"")}function Bo(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Ke(t,e=!1){let n="",o=Math.max(1,t);for(;o>0;)o--,n=String.fromCharCode(97+o%26)+n,o=Math.floor(o/26);return e?n.toUpperCase():n}function Ge(t,e=!0){let n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],o=Math.max(1,Math.min(3999,t)),s="";for(let[r,i]of n)for(;o>=r;)s+=i,o-=r;return e?s:s.toLowerCase()}function Qe(t,e){switch((e||"decimal").toLowerCase()){case"decimal":return String(Math.max(0,t));case"decimal-leading-zero":return(t<10?"0":"")+String(Math.max(0,t));case"lower-alpha":return Ke(t,!1);case"upper-alpha":return Ke(t,!0);case"lower-roman":return Ge(t,!1);case"upper-roman":return Ge(t,!0);default:return String(Math.max(0,t))}}function Ze(t){let e=()=>x?.session?.__counterEpoch??0,n=e(),o=new WeakMap,s=t instanceof Document?t.documentElement:t,r=p=>p&&p.tagName==="LI",i=p=>{let h=0,y=p?.parentElement;if(!y)return 0;for(let f of y.children){if(f===p)break;f.tagName==="LI"&&h++}return h},l=p=>{let h=new Map;for(let[y,f]of p)h.set(y,f.slice());return h},c=(p,h,y)=>{let f=l(p),m;try{m=y.style?.counterReset||getComputedStyle(y).counterReset}catch{}if(m&&m!=="none")for(let g of m.split(",")){let w=g.trim().split(/\s+/),S=w[0],k=Number.isFinite(Number(w[1]))?Number(w[1]):0;if(!S)continue;let C=h.get(S);if(C&&C.length){let M=C.slice();M.push(k),f.set(S,M)}else f.set(S,[k])}let b;try{b=y.style?.counterIncrement||getComputedStyle(y).counterIncrement}catch{}if(b&&b!=="none")for(let g of b.split(",")){let w=g.trim().split(/\s+/),S=w[0],k=Number.isFinite(Number(w[1]))?Number(w[1]):1;if(!S)continue;let C=f.get(S)||[];C.length===0&&C.push(0),C[C.length-1]+=k,f.set(S,C)}try{if(getComputedStyle(y).display==="list-item"&&r(y)){let w=y.parentElement,S=1;if(w&&w.tagName==="OL"){let C=w.getAttribute("start"),M=Number.isFinite(Number(C))?Number(C):1,L=i(y),I=y.getAttribute("value");S=Number.isFinite(Number(I))?Number(I):M+L}else S=1+i(y);let k=f.get("list-item")||[];k.length===0&&k.push(0),k[k.length-1]=S,f.set("list-item",k)}}catch{}return f},a=(p,h,y)=>{let f=c(y,h,p);o.set(p,f);let m=f;for(let b of p.children)m=a(b,f,m);return f},u=new Map;a(s,u,u);function d(){let p=e();if(p!==n){n=p;let h=new Map;a(s,h,h)}}return{get(p,h){d();let y=o.get(p)?.get(h);return y&&y.length?y[y.length-1]:0},getStack(p,h){d();let y=o.get(p)?.get(h);return y?y.slice():[]}}}function tn(t,e,n){if(!t||t==="none")return t;try{let o=/\b(counter|counters)\s*\(([^)]+)\)/g,s=t.replace(o,(r,i,l)=>{let c=String(l).split(",").map(a=>a.trim());if(i==="counter"){let a=c[0]?.replace(/^["']|["']$/g,""),u=(c[1]||"decimal").toLowerCase(),d=n.get(e,a);return Qe(d,u)}else{let a=c[0]?.replace(/^["']|["']$/g,""),u=c[1]?.replace(/^["']|["']$/g,"")??"",d=(c[2]||"decimal").toLowerCase(),p=n.getStack(e,a);return p.length?p.map(y=>Qe(y,d)).join(u):""}});return Bo(s)}catch{return"- "}}var pt=new WeakMap,en=300;function Do(t,e){let n=sn(t);return e?(e.__pseudoPreflightFp!==n&&(e.__pseudoPreflight=on(t),e.__pseudoPreflightFp=n),!!e.__pseudoPreflight):on(t)}function ae(t){try{return t&&t.cssRules?t.cssRules:null}catch{return null}}function sn(t){let e=t.querySelectorAll('style,link[rel~="stylesheet"]'),n=`n:${e.length}|`,o=0;for(let r=0;r<e.length;r++){let i=e[r];if(i.tagName==="STYLE"){let l=i.textContent?i.textContent.length:0;n+=`S${l}|`;let c=i.sheet,a=c?ae(c):null;a&&(o+=a.length)}else{let l=i.getAttribute("href")||"",c=i.getAttribute("media")||"all";n+=`L${l}|m:${c}|`;let a=i.sheet,u=a?ae(a):null;u&&(o+=u.length)}}let s=t.adoptedStyleSheets;return n+=`ass:${Array.isArray(s)?s.length:0}|tr:${o}`,n}function nn(t,e,n){let o=ae(t);if(!o)return!1;for(let s=0;s<o.length;s++){if(n.budget<=0)return!1;let r=o[s],i=r&&r.cssText?r.cssText:"";n.budget--;for(let l of e)if(i.includes(l))return!0;if(r&&r.cssRules&&r.cssRules.length)for(let l=0;l<r.cssRules.length&&n.budget>0;l++){let c=r.cssRules[l],a=c&&c.cssText?c.cssText:"";n.budget--;for(let u of e)if(a.includes(u))return!0}if(n.budget<=0)return!1}return!1}function on(t=document){let e=sn(t),n=pt.get(t);if(n&&n.fingerprint===e)return n.result;let o=["::before","::after","::first-letter",":before",":after",":first-letter","counter(","counters(","counter-increment","counter-reset"],s=t.querySelectorAll("style");for(let i=0;i<s.length;i++){let l=s[i].textContent||"";for(let c of o)if(l.includes(c))return pt.set(t,{fingerprint:e,result:!0}),!0}let r=t.adoptedStyleSheets;if(Array.isArray(r)&&r.length){let i={budget:en};try{for(let l of r)if(nn(l,o,i))return pt.set(t,{fingerprint:e,result:!0}),!0}catch{}}{let i=t.querySelectorAll('style,link[rel~="stylesheet"]'),l={budget:en};for(let c=0;c<i.length&&l.budget>0;c++){let a=i[c],u=null;if(a.tagName,u=a.sheet||null,u&&nn(u,o,l))return pt.set(t,{fingerprint:e,result:!0}),!0}}return t.querySelector('[style*="counter("], [style*="counters("]')?(pt.set(t,{fingerprint:e,result:!0}),!0):(pt.set(t,{fingerprint:e,result:!1}),!1)}var ht=new WeakMap,rn=-1;function Ho(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function qo(t){if(!t)return"";let e=[],n=/"([^"]*)"/g,o;for(;o=n.exec(t);)e.push(o[1]);return e.length?e.join(""):Ho(t)}function ce(t,e){let n=t.parentElement,o=n?ht.get(n):null;return o?{get(s,r){let i=e.get(s,r),l=o.get(r);return typeof l=="number"?Math.max(i,l):i},getStack(s,r){let i=e.getStack(s,r);if(!i.length)return i;let l=o.get(r);if(typeof l=="number"){let c=i.slice();return c[c.length-1]=Math.max(c[c.length-1],l),c}return i}}:e}function le(t,e,n){let o=new Map;function s(c){let a=[];if(!c||c==="none")return a;for(let u of String(c).split(",")){let d=u.trim().split(/\s+/),p=d[0],h=Number.isFinite(Number(d[1]))?Number(d[1]):void 0;p&&a.push({name:p,num:h})}return a}let r=s(e?.counterReset),i=s(e?.counterIncrement);function l(c){if(o.has(c))return o.get(c).slice();let a=n.getStack(t,c);a=a.length?a.slice():[];let u=r.find(p=>p.name===c);if(u){let p=Number.isFinite(u.num)?u.num:0;a=a.length?[...a,p]:[p]}let d=i.find(p=>p.name===c);if(d){let p=Number.isFinite(d.num)?d.num:1;a.length===0&&(a=[0]),a[a.length-1]+=p}return o.set(c,a.slice()),a}return{get(c,a){let u=l(a);return u.length?u[u.length-1]:0},getStack(c,a){return l(a)},__incs:i}}function zo(t,e,n){let o;try{o=getComputedStyle(t,e)}catch{}let s=o?.content;if(!s||s==="none"||s==="normal")return{text:"",incs:[]};let r=ce(t,n),i=le(t,o,r),l=Je(s)?tn(s,t,i):s;return{text:qo(l),incs:i.__incs||[]}}async function ue(t,e,n,o){if(!(t instanceof Element)||!(e instanceof Element))return;let s=t.ownerDocument||document;if(!Do(s,n))return;let r=x?.session?.__counterEpoch??0;if(rn!==r&&(ht=new WeakMap,n&&(n.__counterCtx=null),rn=r),!n.__counterCtx)try{n.__counterCtx=Ze(t.ownerDocument||document)}catch{}let i=n.__counterCtx;for(let a of["::before","::after","::first-letter"])try{let u=st(t,a);if(!u||u.content==="none"&&u.backgroundImage==="none"&&u.backgroundColor==="transparent"&&(u.borderStyle==="none"||parseFloat(u.borderWidth)===0)&&(!u.transform||u.transform==="none")&&u.display==="inline")continue;if(a==="::first-letter"){let $=getComputedStyle(t);if(!(u.color!==$.color||u.fontSize!==$.fontSize||u.fontWeight!==$.fontWeight))continue;let _=Array.from(e.childNodes).find(zt=>zt.nodeType===Node.TEXT_NODE&&zt.textContent?.trim().length>0);if(!_)continue;let O=_.textContent,at=O.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],Ht=O.slice(at?.length||0);if(!at||/[\uD800-\uDFFF]/.test(at))continue;let ct=document.createElement("span");ct.textContent=at,ct.dataset.snapdomPseudo="::first-letter";let qt=Lt(u),Mt=dt(qt,"span");n.styleMap.set(ct,Mt);let vt=document.createTextNode(Ht);e.replaceChild(vt,_),e.insertBefore(ct,vt);continue}let p=u.content??"",h=p===""||p==="none"||p==="normal",{text:y,incs:f}=zo(t,a,i),m=u.backgroundImage,b=u.backgroundColor,g=u.fontFamily,w=parseInt(u.fontSize)||32,S=parseInt(u.fontWeight)||!1,k=u.color||"#000",C=u.borderStyle,M=parseFloat(u.borderWidth),L=u.transform,I=B(g),N=!h&&y!=="",E=m&&m!=="none",P=b&&b!=="transparent"&&b!=="rgba(0, 0, 0, 0)",U=C&&C!=="none"&&M>0,D=L&&L!=="none";if(!(N||E||P||U||D)){if(f&&f.length&&t.parentElement){let $=ht.get(t.parentElement)||new Map;for(let{name:R}of f){if(!R)continue;let _=ce(t,i),nt=le(t,getComputedStyle(t,a),_).get(t,R);$.set(R,nt)}ht.set(t.parentElement,$)}continue}let v=document.createElement("span");v.dataset.snapdomPseudo=a,v.style.pointerEvents="none";let tt=Lt(u),et=dt(tt,"span");if(n.styleMap.set(v,et),I&&y&&y.length===1){let{dataUrl:$,width:R,height:_}=await qe(y,g,S,w,k),O=document.createElement("img");O.src=$,O.style=`height:${w}px;width:${R/_*w}px;object-fit:contain;`,v.appendChild(O),e.dataset.snapdomHasIcon="true"}else if(y&&y.startsWith("url(")){let $=ot(y);if($?.trim())try{let R=document.createElement("img"),_=await T(G($),{as:"dataURL",useProxy:o.useProxy});R.src=_.data,R.style=`width:${w}px;height:auto;object-fit:contain;`,v.appendChild(R)}catch(R){console.error(`[snapdom] Error in pseudo ${a} for`,t,R)}}else!I&&N&&(v.textContent=y);v.style.backgroundImage="none","maskImage"in v.style&&(v.style.maskImage="none"),"webkitMaskImage"in v.style&&(v.style.webkitMaskImage="none");try{v.style.backgroundRepeat=u.backgroundRepeat,v.style.backgroundSize=u.backgroundSize,u.backgroundPositionX&&u.backgroundPositionY?(v.style.backgroundPositionX=u.backgroundPositionX,v.style.backgroundPositionY=u.backgroundPositionY):v.style.backgroundPosition=u.backgroundPosition,v.style.backgroundOrigin=u.backgroundOrigin,v.style.backgroundClip=u.backgroundClip,v.style.backgroundAttachment=u.backgroundAttachment,v.style.backgroundBlendMode=u.backgroundBlendMode}catch{}if(E)try{let $=bt(m),R=await Promise.all($.map(rt));v.style.backgroundImage=R.join(", ")}catch($){console.warn(`[snapdom] Failed to inline background-image for ${a}`,$)}P&&(v.style.backgroundColor=b);let it=v.childNodes.length>0||v.textContent?.trim()!==""||E||P||U||D;if(f&&f.length&&t.parentElement){let $=ht.get(t.parentElement)||new Map,R=ce(t,i),_=le(t,getComputedStyle(t,a),R);for(let{name:O}of f){if(!O)continue;let nt=_.get(t,O);$.set(O,nt)}ht.set(t.parentElement,$)}if(!it)continue;a==="::before"?e.insertBefore(v,e.firstChild):e.appendChild(v)}catch(u){console.warn(`[snapdom] Failed to capture ${a} for`,t,u)}let l=Array.from(t.children),c=Array.from(e.children).filter(a=>!a.dataset.snapdomPseudo);for(let a=0;a<Math.min(l.length,c.length);a++)await ue(l[a],c[a],n,o)}function an(t,e){if(!t||!(t instanceof Element))return;let n=t.ownerDocument||document,o=e||n,s=t instanceof SVGSVGElement?[t]:Array.from(t.querySelectorAll("svg"));if(s.length===0)return;let r=/url\(\s*#([^)]+)\)/g,i=["fill","stroke","filter","clip-path","mask","marker","marker-start","marker-mid","marker-end"],l=g=>window.CSS&&CSS.escape?CSS.escape(g):g.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),c=new Set(Array.from(t.querySelectorAll("[id]")).map(g=>g.id)),a=new Set,u=!1,d=g=>{if(!g)return;r.lastIndex=0;let w;for(;w=r.exec(g);){u=!0;let S=(w[1]||"").trim();S&&!c.has(S)&&a.add(S)}},p=g=>{let w=g.querySelectorAll('use[href^="#"], use[xlink\\:href^="#"]');for(let C of w){let M=C.getAttribute("href")||C.getAttribute("xlink:href");if(!M||!M.startsWith("#"))continue;u=!0;let L=M.slice(1).trim();L&&!c.has(L)&&a.add(L)}let k=g.querySelectorAll('*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("], *[clip-path^="url("],*[mask^="url("],*[marker^="url("], *[marker-start^="url("],*[marker-mid^="url("], *[marker-end^="url("]');for(let C of k){d(C.getAttribute("style")||"");for(let M of i)d(C.getAttribute(M))}};for(let g of s)p(g);if(!u)return;let h=t.querySelector("svg.inline-defs-container");h||(h=n.createElementNS("http://www.w3.org/2000/svg","svg"),h.classList.add("inline-defs-container"),h.setAttribute("aria-hidden","true"),h.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),t.insertBefore(h,t.firstChild||null));let y=h.querySelector("defs")||null,f=g=>{if(!g||c.has(g))return null;let w=l(g),S=k=>{let C=o.querySelector(k);return C&&!t.contains(C)?C:null};return S(`svg defs > *#${w}`)||S(`svg > symbol#${w}`)||S(`*#${w}`)};if(!a.size)return;let m=new Set(a),b=new Set;for(;m.size;){let g=m.values().next().value;if(m.delete(g),!g||c.has(g)||b.has(g))continue;let w=f(g);if(!w){b.add(g);continue}y||(y=n.createElementNS("http://www.w3.org/2000/svg","defs"),h.appendChild(y));let S=w.cloneNode(!0);S.id||S.setAttribute("id",g),y.appendChild(S),b.add(g),c.add(g);let k=[S,...S.querySelectorAll("*")];for(let C of k){let M=C.getAttribute?.("href")||C.getAttribute?.("xlink:href");if(M&&M.startsWith("#")){let I=M.slice(1).trim();I&&!c.has(I)&&!b.has(I)&&m.add(I)}let L=C.getAttribute?.("style")||"";L&&d(L);for(let I of i){let N=C.getAttribute?.(I);N&&d(N)}}}}function ln(t,e){if(!t||!e)return;let n=t.scrollTop||0;if(!n)return;getComputedStyle(e).position==="static"&&(e.style.position="relative");let o=t.getBoundingClientRect(),s=t.clientHeight,r="data-snap-ph",i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;i.nextNode();){let l=i.currentNode,c=getComputedStyle(l),a=c.position;if(a!=="sticky"&&a!=="-webkit-sticky")continue;let u=cn(c.top),d=cn(c.bottom);if(u==null&&d==null)continue;let p=jo(l,t),h=Vo(e,p,r);if(!h)continue;let y=l.getBoundingClientRect(),f=y.width,m=y.height,b=y.left-o.left;if(!(f>0&&m>0)||!Number.isFinite(b))continue;let g=u!=null?u+n:n+(s-m-d);if(!Number.isFinite(g))continue;let w=Number.parseInt(c.zIndex,10),S=Number.isFinite(w),k=S?Math.max(w,1)+1:2,C=S?w-1:0,M=h.cloneNode(!1);M.setAttribute(r,"1"),M.style.position="sticky",M.style.left=`${b}px`,M.style.top=`${g}px`,M.style.width=`${f}px`,M.style.height=`${m}px`,M.style.visibility="hidden",M.style.zIndex=String(C),M.style.overflow="hidden",M.style.background="transparent",M.style.boxShadow="none",M.style.filter="none",h.parentElement?.insertBefore(M,h),h.style.position="absolute",h.style.left=`${b}px`,h.style.top=`${g}px`,h.style.bottom="auto",h.style.zIndex=String(k),h.style.pointerEvents="none"}}function cn(t){if(!t||t==="auto")return null;let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}function jo(t,e){let n=[];for(let o=t;o&&o!==e;){let s=o.parentElement;if(!s)break;n.push(Array.prototype.indexOf.call(s.children,o)),o=s}return n.reverse()}function Vo(t,e,n){let o=t;for(let s=0;s<e.length;s++)if(o=Xo(o,n)[e[s]],!o)return null;return o instanceof HTMLElement?o:null}function Xo(t,e){let n=[],o=t.children;for(let s=0;s<o.length;s++){let r=o[s];r.hasAttribute(e)||n.push(r)}return n}function un(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,s=e.borderStyle,r=e.borderWidth,i=n!=="none"&&parseFloat(o)>0,l=s==="none"||parseFloat(r)===0;i&&l&&(t.style.border=`${o} solid transparent`)}async function fn(t,e={}){let n={styleMap:x.session.styleMap,styleCache:x.session.styleCache,nodeMap:x.session.nodeMap},o,s="",r="";un(t);try{an(t)}catch(c){console.warn("inlineExternal defs or symbol failed:",c)}try{o=await Ct(t,n,e,t)}catch(c){throw console.warn("deepClone failed:",c),c}try{await ue(t,o,n,e)}catch(c){console.warn("inlinePseudoElements failed:",c)}await We(o);try{let c=o.querySelectorAll("style[data-sd]");for(let a of c)r+=a.textContent||"",a.remove()}catch{}let i=te(n.styleMap);s=Array.from(i.entries()).map(([c,a])=>`.${a}{${c}}`).join(""),s=r+s;for(let[c,a]of n.styleMap.entries()){if(c.tagName==="STYLE")continue;if(c.getRootNode&&c.getRootNode()instanceof ShadowRoot){c.setAttribute("style",a.replace(/;/g,"; "));continue}let u=i.get(a);u&&c.classList.add(u);let d=c.style?.backgroundImage,p=c.dataset?.snapdomHasIcon;d&&d!=="none"&&(c.style.backgroundImage=d),p&&(c.style.verticalAlign="middle",c.style.display="inline")}for(let[c,a]of n.nodeMap.entries()){let u=a.scrollLeft,d=a.scrollTop;if((u||d)&&c instanceof HTMLElement){c.style.overflow="hidden",c.style.scrollbarWidth="none",c.style.msOverflowStyle="none";let h=document.createElement("div");for(h.style.transform=`translate(${-u}px, ${-d}px)`,h.style.willChange="transform",h.style.display="inline-block",h.style.width="100%";c.firstChild;)h.appendChild(c.firstChild);c.appendChild(h)}}let l=o instanceof HTMLElement&&o.firstElementChild instanceof HTMLElement?o.firstElementChild:o;if(ln(t,l),t===n.nodeMap.get(o)){let c=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,c);let a=Yt(c.transform);o.style.margin="0",o.style.top="auto",o.style.left="auto",o.style.right="auto",o.style.bottom="auto",o.style.animation="none",o.style.transition="none",o.style.willChange="auto",o.style.float="none",o.style.clear="none",o.style.transform=a||""}for(let[c,a]of n.nodeMap.entries())a.tagName==="PRE"&&(c.style.marginTop="0",c.style.marginBlockStart="0");return{clone:o,classCSS:s,styleCache:n.styleCache}}function Yo(t){let e=parseInt(t.dataset?.snapdomWidth||"",10)||0,n=parseInt(t.dataset?.snapdomHeight||"",10)||0,o=parseInt(t.getAttribute("width")||"",10)||0,s=parseInt(t.getAttribute("height")||"",10)||0,r=parseFloat(t.style?.width||"")||0,i=parseFloat(t.style?.height||"")||0,l=e||r||o||t.width||t.naturalWidth||100,c=n||i||s||t.height||t.naturalHeight||100;return{width:l,height:c}}async function dn(t,e={}){let n=Array.from(t.querySelectorAll("img")),o=async s=>{if(!s.getAttribute("src")){let u=s.currentSrc||s.src||"";u&&s.setAttribute("src",u)}s.removeAttribute("srcset"),s.removeAttribute("sizes");let r=s.src||"";if(!r)return;let i=await T(r,{as:"dataURL",useProxy:e.useProxy});if(i.ok&&typeof i.data=="string"&&i.data.startsWith("data:")){s.src=i.data,s.width||(s.width=s.naturalWidth||100),s.height||(s.height=s.naturalHeight||100);return}let{width:l,height:c}=Yo(s),{fallbackURL:a}=e||{};if(a)try{let u=typeof a=="function"?await a({width:l,height:c,src:r,element:s}):a;if(u){let d=await T(u,{as:"dataURL",useProxy:e.useProxy});s.src=d.data,s.width||(s.width=l),s.height||(s.height=c);return}}catch{}if(e.placeholders!==!1){let u=document.createElement("div");u.style.cssText=[`width:${l}px`,`height:${c}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${c}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),u.textContent="img",s.replaceWith(u)}else{let u=document.createElement("div");u.style.cssText=`display:inline-block;width:${l}px;height:${c}px;visibility:hidden;`,s.replaceWith(u)}};for(let s=0;s<n.length;s+=4){let r=n.slice(s,s+4).map(o);await Promise.allSettled(r)}}async function Dt(t,e,n,o={}){let s=[[t,e]],r=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],i=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],l=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],c=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;s.length;){let[a,u]=s.shift(),d=n.get(a)||st(a);n.has(a)||n.set(a,d);let p=(()=>{let f=d.getPropertyValue("border-image"),m=d.getPropertyValue("border-image-source");return f&&f!=="none"||m&&m!=="none"})();for(let f of l){let m=d.getPropertyValue(f);m&&u.style.setProperty(f,m)}for(let f of r){let m=d.getPropertyValue(f);if(!m||m==="none")continue;let b=bt(m),g=await Promise.all(b.map(w=>rt(w,o)));g.some(w=>w&&w!=="none"&&!/^url\(undefined/.test(w))&&u.style.setProperty(f,g.join(", "))}for(let f of i){let m=d.getPropertyValue(f);!m||m==="initial"||u.style.setProperty(f,m)}if(p)for(let f of c){let m=d.getPropertyValue(f);!m||m==="initial"||u.style.setProperty(f,m)}let h=Array.from(a.children),y=Array.from(u.children).filter(f=>!(f.dataset&&f.dataset.snapdomPseudo));for(let f=0;f<Math.min(h.length,y.length);f++)s.push([h[f],y[f]])}}function mn(t){if(!t)return()=>{};let e=Ko(t);if(e<=0)return()=>{};if(!Jo(t))return()=>{};let n=getComputedStyle(t),o=Math.round(Go(n)*e+Qo(n)),s=t.textContent??"",r=s;if(t.scrollHeight<=o+.5)return()=>{};let i=0,l=s.length,c=-1;for(;i<=l;){let a=i+l>>1;t.textContent=s.slice(0,a)+"\u2026",t.scrollHeight<=o+.5?(c=a,i=a+1):l=a-1}return t.textContent=(c>=0?s.slice(0,c):"")+"\u2026",()=>{t.textContent=r}}function Ko(t){let e=getComputedStyle(t),n=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");n=(n||"").trim();let o=parseInt(n,10);return Number.isFinite(o)&&o>0?o:0}function Go(t){let e=(t.lineHeight||"").trim(),n=parseFloat(t.fontSize)||16;return!e||e==="normal"?Math.round(n*1.2):e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*n):e.endsWith("%")?Math.round(parseFloat(e)/100*n):Math.round(n*1.2)}function Qo(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function Jo(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var kt=[];function pn(t){if(!t)return null;if(Array.isArray(t)){let[e,n]=t;return typeof e=="function"?e(n):e}if(typeof t=="object"&&"plugin"in t){let{plugin:e,options:n}=t;return typeof e=="function"?e(n):e}return typeof t=="function"?t():t}function fe(...t){let e=t.flat();for(let n of e){let o=pn(n);o&&(kt.some(s=>s&&s.name&&o.name&&s.name===o.name)||kt.push(o))}}function hn(t){return(t&&Array.isArray(t.plugins)?t.plugins:kt)||kt}async function q(t,e,n){let o=n,s=hn(e);for(let r of s){let i=r&&typeof r[t]=="function"?r[t]:null;if(!i)continue;let l=await i(e,o);typeof l<"u"&&(o=l)}return o}async function gn(t,e,n){let o=[],s=hn(e);for(let r of s){let i=r&&typeof r[t]=="function"?r[t]:null;if(!i)continue;let l=await i(e,n);typeof l<"u"&&o.push(l)}return o}function Zo(t){let e=[];if(Array.isArray(t))for(let n of t){let o=pn(n);if(!o||!o.name)continue;let s=e.findIndex(r=>r&&r.name===o.name);s>=0&&e.splice(s,1),e.push(o)}for(let n of kt)n&&n.name&&!e.some(o=>o.name===n.name)&&e.push(n);return Object.freeze(e)}function yn(t,e,n=!1){return!t||t.plugins&&!n||(t.plugins=Zo(e)),t}function bn(t,e){if(!t||!e||!e.style)return;let n=getComputedStyle(t);try{e.style.boxShadow="none"}catch{}try{e.style.textShadow="none"}catch{}try{e.style.outline="none"}catch{}let s=(n.filter||"").replace(/\bblur\([^()]*\)\s*/gi,"").replace(/\bdrop-shadow\([^()]*\)\s*/gi,"").trim().replace(/\s+/g," ");try{e.style.filter=s.length?s:"none"}catch{}}function tr(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(;e.nextNode();)n.push(e.currentNode);for(let o of n)o.remove()}function er(t,e={}){let{stripFrameworkDirectives:n=!0}=e,o=new Set(["xml","xlink"]),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;s.nextNode();){let r=s.currentNode;for(let i of Array.from(r.attributes)){let l=i.name;if(l.includes("@")){r.removeAttribute(l);continue}if(l.includes(":")){let c=l.split(":",1)[0];if(!o.has(c)){r.removeAttribute(l);continue}}if(n&&(l.startsWith("x-")||l.startsWith("v-")||l.startsWith(":")||l.startsWith("on:")||l.startsWith("bind:")||l.startsWith("let:")||l.startsWith("class:"))){r.removeAttribute(l);continue}}}}function wn(t,e={}){t&&(er(t,e),tr(t))}function nr(t){try{let e=t.getAttribute?.("style")||"";return/\b(height|width|block-size|inline-size)\s*:/.test(e)}catch{return!1}}function or(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function rr(t,e){if(!(t instanceof Element)||nr(t)||or(t))return!1;let n=e.position;if(n==="absolute"||n==="fixed"||n==="sticky")return!1;let o=e.display||"";return!(o.includes("flex")||o.includes("grid")||o.startsWith("table")||e.transform&&e.transform!=="none")}function xn(t,e,n=new Map){function o(s,r){if(!(s instanceof Element)||!(r instanceof Element))return;let i=s.childElementCount>r.childElementCount,l=n.get(s)||getComputedStyle(s);if(n.has(s)||n.set(s,l),i&&rr(s,l)){r.style.height||(r.style.height="auto"),r.style.width||(r.style.width="auto"),r.style.removeProperty("block-size"),r.style.removeProperty("inline-size"),r.style.minHeight||(r.style.minHeight="0"),r.style.minWidth||(r.style.minWidth="0"),r.style.maxHeight||(r.style.maxHeight="none"),r.style.maxWidth||(r.style.maxWidth="none");let u=l.overflowY||l.overflowBlock||"visible",d=l.overflowX||l.overflowInline||"visible";(u!=="visible"||d!=="visible")&&(r.style.overflow="visible")}let c=Array.from(s.children),a=Array.from(r.children);for(let u=0;u<Math.min(c.length,a.length);u++)o(c[u],a[u])}o(t,e)}function sr(t){let e=getComputedStyle(t);return!(e.display==="none"||e.position==="absolute"||e.position==="fixed"||e.position==="sticky"||(e.cssFloat||e.float||"none")!=="none"||e.transform&&e.transform!=="none")}function ir(t,e){if(!(t instanceof Element))return!1;if(t.getAttribute("data-capture")==="exclude"&&e?.excludeMode==="remove")return!0;if(Array.isArray(e?.exclude))for(let n of e.exclude)try{if(t.matches(n))return e.excludeMode==="remove"}catch{}return!1}function Sn(t,e){let n=getComputedStyle(t),o=t.getBoundingClientRect(),s=1/0,r=-1/0,i=!1,l=Array.from(t.children);for(let h of l){if(ir(h,e)||!sr(h))continue;let y=h.getBoundingClientRect(),f=y.top-o.top,m=y.bottom-o.top;m<=f||(f<s&&(s=f),m>r&&(r=m),i=!0)}let c=i?Math.max(0,r-s):0,a=parseFloat(n.borderTopWidth)||0,u=parseFloat(n.borderBottomWidth)||0,d=parseFloat(n.paddingTop)||0,p=parseFloat(n.paddingBottom)||0;return a+u+d+p+c}var A=(t,e=3)=>Number.isFinite(t)?Math.round(t*10**e)/10**e:t;function Cn(t){let e=t.boxShadow||"";if(!e||e==="none")return{top:0,right:0,bottom:0,left:0};let n=e.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(l=>l.trim()),o=0,s=0,r=0,i=0;for(let l of n){let c=l.match(/-?\d+(\.\d+)?px/g)?.map(f=>parseFloat(f))||[];if(c.length<2)continue;let[a,u,d=0,p=0]=c,h=Math.abs(a)+d+p,y=Math.abs(u)+d+p;s=Math.max(s,h+Math.max(a,0)),i=Math.max(i,h+Math.max(-a,0)),r=Math.max(r,y+Math.max(u,0)),o=Math.max(o,y+Math.max(-u,0))}return{top:Math.ceil(o),right:Math.ceil(s),bottom:Math.ceil(r),left:Math.ceil(i)}}function kn(t){let e=(t.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),n=e?Math.ceil(parseFloat(e[1])||0):0;return{top:n,right:n,bottom:n,left:n}}function An(t){if((t.outlineStyle||"none")==="none")return{top:0,right:0,bottom:0,left:0};let e=Math.ceil(parseFloat(t.outlineWidth||"0")||0);return{top:e,right:e,bottom:e,left:e}}function Mn(t){let e=`${t.filter||""} ${t.webkitFilter||""}`.trim();if(!e||e==="none")return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let n=e.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[],o=0,s=0,r=0,i=0,l=!1;for(let c of n){l=!0;let a=c.match(/-?\d+(?:\.\d+)?px/gi)?.map(f=>parseFloat(f))||[],[u=0,d=0,p=0]=a,h=Math.abs(u)+p,y=Math.abs(d)+p;s=Math.max(s,h+Math.max(u,0)),i=Math.max(i,h+Math.max(-u,0)),r=Math.max(r,y+Math.max(d,0)),o=Math.max(o,y+Math.max(-d,0))}return{bleed:{top:A(o),right:A(s),bottom:A(r),left:A(i)},has:l}}function vn(t,e){if(!t||!e||!e.style)return null;let n=getComputedStyle(t);try{e.style.transformOrigin="0 0"}catch{}try{"translate"in e.style&&(e.style.translate="none"),"rotate"in e.style&&(e.style.rotate="none")}catch{}let o=n.transform||"none";if(!o||o==="none")try{let r=Ln(t);if(r.a===1&&r.b===0&&r.c===0&&r.d===1)return e.style.transform="none",{a:1,b:0,c:0,d:1}}catch{}let s=o.match(/^matrix\(\s*([^)]+)\)$/i);if(s){let r=s[1].split(",").map(i=>parseFloat(i.trim()));if(r.length===6&&r.every(Number.isFinite)){let[i,l,c,a]=r,u=Math.sqrt(i*i+l*l)||0,d=0,p=0,h=0,y=0,f=0,m=0;u>0&&(d=i/u,p=l/u,h=d*c+p*a,y=c-d*h,f=a-p*h,m=Math.sqrt(y*y+f*f)||0,m>0?h=h/m:h=0);let b=u,g=0,w=h*m,S=m;try{e.style.transform=`matrix(${b}, ${g}, ${w}, ${S}, 0, 0)`}catch{}return{a:b,b:g,c:w,d:S}}}try{let r=String(o).trim();return e.style.transform=r+" translate(0px, 0px) rotate(0deg)",null}catch{return null}}function me(t,e,n,o,s){let r=n.a,i=n.b,l=n.c,c=n.d,a=n.e||0,u=n.f||0;function d(b,g){let w=b-o,S=g-s,k=r*w+l*S,C=i*w+c*S;return k+=o+a,C+=s+u,[k,C]}let p=[d(0,0),d(t,0),d(0,e),d(t,e)],h=1/0,y=1/0,f=-1/0,m=-1/0;for(let[b,g]of p)b<h&&(h=b),g<y&&(y=g),b>f&&(f=b),g>m&&(m=g);return{minX:h,minY:y,maxX:f,maxY:m,width:f-h,height:m-y}}function En(t,e,n){let o=(t.transformOrigin||"0 0").trim().split(/\s+/),[s,r]=[o[0]||"0",o[1]||"0"],i=(l,c)=>{let a=l.toLowerCase();return a==="left"||a==="top"?0:a==="center"?c/2:a==="right"||a==="bottom"?c:a.endsWith("px")?parseFloat(a)||0:a.endsWith("%")?(parseFloat(a)||0)*c/100:/^-?\d+(\.\d+)?$/.test(a)&&parseFloat(a)||0};return{ox:i(s,e),oy:i(r,n)}}function Fn(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let s=c=>{try{return typeof n.has=="function"&&!n.has(c)||typeof n.get!="function"?null:n.get(c)}catch{return null}},r=s("rotate");if(r)if(r.angle){let c=r.angle;e.rotate=c.unit==="rad"?c.value*180/Math.PI+"deg":c.value+c.unit}else r.unit?e.rotate=r.unit==="rad"?r.value*180/Math.PI+"deg":r.value+r.unit:e.rotate=String(r);else{let c=getComputedStyle(t);e.rotate=c.rotate&&c.rotate!=="none"?c.rotate:"0deg"}let i=s("scale");if(i){let c="x"in i&&i.x?.value!=null?i.x.value:Array.isArray(i)?i[0]?.value:Number(i)||1,a="y"in i&&i.y?.value!=null?i.y.value:Array.isArray(i)?i[1]?.value:c;e.scale=`${c} ${a}`}else{let c=getComputedStyle(t);e.scale=c.scale&&c.scale!=="none"?c.scale:null}let l=s("translate");if(l){let c="x"in l&&"value"in l.x?l.x.value:Array.isArray(l)?l[0]?.value:0,a="y"in l&&"value"in l.y?l.y.value:Array.isArray(l)?l[1]?.value:0,u="x"in l&&l.x?.unit?l.x.unit:"px",d="y"in l&&l.y?.unit?l.y.unit:"px";e.translate=`${c}${u} ${a}${d}`}else{let c=getComputedStyle(t);e.translate=c.translate&&c.translate!=="none"?c.translate:null}return e}let o=getComputedStyle(t);return e.rotate=o.rotate&&o.rotate!=="none"?o.rotate:"0deg",e.scale=o.scale&&o.scale!=="none"?o.scale:null,e.translate=o.translate&&o.translate!=="none"?o.translate:null,e}var de=null;function ar(){if(de)return de;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(t),de=t,t}function $n(t){let e=ar(),n=document.createElement("div");n.style.transformOrigin="0 0",t.baseTransform&&(n.style.transform=t.baseTransform),t.rotate&&(n.style.rotate=t.rotate),t.scale&&(n.style.scale=t.scale),t.translate&&(n.style.translate=t.translate),e.appendChild(n);let o=Ln(n);return e.removeChild(n),o}function In(t){let e=getComputedStyle(t),n=e.transform||"none";if(n!=="none"&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(n))return!0;let s=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",r=e.scale&&e.scale!=="none"&&e.scale!=="1",i=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(s||r||i)}function Ln(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}async function pe(t,e){if(!t)throw new Error("Element cannot be null or undefined");Ft(e.cache);let n=e.fast,o=e.outerTransforms!==!1,s=!!e.outerShadows,r={element:t,options:e,plugins:e.plugins},i,l,c,a="",u="",d,p,h=null;await q("beforeSnap",r),await q("beforeClone",r);let y=mn(r.element);try{({clone:i,classCSS:l,styleCache:c}=await fn(r.element,r.options)),!o&&i&&(h=vn(r.element,i)),!s&&i&&bn(r.element,i)}finally{y()}if(r={clone:i,classCSS:l,styleCache:c,...r},await q("afterClone",r),wn(r.clone),r.options?.excludeMode==="remove")try{xn(r.element,r.clone,r.styleCache)}catch(g){console.warn("[snapdom] shrink pass failed:",g)}try{await Be(r.clone,r.element)}catch{}await new Promise(g=>{V(async()=>{await dn(r.clone,r.options),g()},{fast:n})}),await new Promise(g=>{V(async()=>{await Dt(r.element,r.clone,r.styleCache,r.options),g()},{fast:n})}),e.embedFonts&&await new Promise(g=>{V(async()=>{let w=Ut(r.element),S=Ot(r.element);if(W()){let k=new Set(Array.from(w).map(C=>String(C).split("__")[0]).filter(Boolean));await Bt(k,1)}a=await Wt({required:w,usedCodepoints:S,preCached:!1,exclude:r.options.excludeFonts,useProxy:r.options.useProxy}),g()},{fast:n})});let f=Jt(r.clone).sort(),m=f.join(",");x.baseStyle.has(m)?u=x.baseStyle.get(m):await new Promise(g=>{V(()=>{u=Zt(f),x.baseStyle.set(m,u),g()},{fast:n})}),r={fontsCSS:a,baseCSS:u,...r},await q("beforeRender",r),await new Promise(g=>{V(()=>{let w=getComputedStyle(r.element),S=r.element.getBoundingClientRect(),k=Math.max(1,A(r.element.offsetWidth||parseFloat(w.width)||S.width||1)),C=Math.max(1,A(r.element.offsetHeight||parseFloat(w.height)||S.height||1));if(r.options?.excludeMode==="remove"){let H=Sn(r.element,r.options);Number.isFinite(H)&&H>0&&(C=Math.max(1,Math.min(C,A(H+1))))}let M=(H,j=NaN)=>{let ut=typeof H=="string"?parseFloat(H):H;return Number.isFinite(ut)?ut:j},L=M(r.options.width),I=M(r.options.height),N=k,E=C,P=Number.isFinite(L),U=Number.isFinite(I),D=C>0?k/C:1;P&&U?(N=Math.max(1,A(L)),E=Math.max(1,A(I))):P?(N=Math.max(1,A(L)),E=Math.max(1,A(N/(D||1)))):U?(E=Math.max(1,A(I)),N=Math.max(1,A(E*(D||1)))):(N=k,E=C);let Z=0,v=0,tt=k,et=C;if(!o&&h&&Number.isFinite(h.a)){let H={a:h.a,b:h.b||0,c:h.c||0,d:h.d||1,e:0,f:0},j=me(k,C,H,0,0);Z=A(j.minX),v=A(j.minY),tt=A(j.maxX),et=A(j.maxY)}else if(o&&cr(r.element)){let j=w.transform&&w.transform!=="none"?w.transform:"",ut=Fn(r.element),Xt=$n({baseTransform:j,rotate:ut.rotate||"0deg",scale:ut.scale,translate:ut.translate}),{ox:Dn,oy:Hn}=En(w,k,C),qn=Xt.is2D?Xt:new DOMMatrix(Xt.toString()),Et=me(k,C,qn,Dn,Hn);Z=A(Et.minX),v=A(Et.minY),tt=A(Et.maxX),et=A(Et.maxY)}let yt=Cn(w),it=kn(w),$=An(w),R=Mn(w),_=s?{top:A(yt.top+it.top+$.top+R.bleed.top),right:A(yt.right+it.right+$.right+R.bleed.right),bottom:A(yt.bottom+it.bottom+$.bottom+R.bleed.bottom),left:A(yt.left+it.left+$.left+R.bleed.left)}:{top:0,right:0,bottom:0,left:0};Z=A(Z-_.left),v=A(v-_.top),tt=A(tt+_.right),et=A(et+_.bottom);let O=Math.max(1,A(tt-Z)),nt=Math.max(1,A(et-v)),at=P||U?A(N/k):1,Ht=U||P?A(E/C):1,ct=Math.max(1,A(O*at)),qt=Math.max(1,A(nt*Ht)),Mt="http://www.w3.org/2000/svg",vt=W()?1:0,Y=A(vt+(o?0:1)),K=document.createElementNS(Mt,"foreignObject"),_n=A(Z),Wn=A(v);K.setAttribute("x",String(A(-(_n-Y)))),K.setAttribute("y",String(A(-(Wn-Y)))),K.setAttribute("width",String(A(k+Y*2))),K.setAttribute("height",String(A(C+Y*2))),K.style.overflow="visible";let ge=document.createElement("style");ge.textContent=r.baseCSS+r.fontsCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+r.classCSS,K.appendChild(ge);let lt=document.createElement("div");lt.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),lt.style.width=`${A(k)}px`,lt.style.height=`${A(C)}px`,lt.style.overflow="visible",r.clone.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),lt.appendChild(r.clone),K.appendChild(lt);let Un=new XMLSerializer().serializeToString(K),jt=A(O+Y*2),Vt=A(nt+Y*2),ye=P||U;e.meta={w0:k,h0:C,vbW:jt,vbH:Vt,targetW:N,targetH:E};let On=W()&&ye?jt:A(ct+Y*2),Bn=W()&&ye?Vt:A(qt+Y*2);p=`<svg xmlns="${Mt}" width="${On}" height="${Bn}" viewBox="0 0 ${jt} ${Vt}">`+Un+"</svg>",d=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(p)}`,r={svgString:p,dataURL:d,...r},g()},{fast:n})}),await q("afterRender",r);let b=document.getElementById("snapdom-sandbox");return b&&b.style.position==="absolute"&&b.remove(),r.dataURL}function cr(t){return In(t)}function lr(t){if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function Rn(t={}){let e=t.format??"png";e==="jpg"&&(e="jpeg");let n=lr(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],excludeMode:t.excludeMode??"hide",filter:t.filter??null,filterMode:t.filterMode??"hide",placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fallbackURL:t.fallbackURL??void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:e,type:t.type??"svg",quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(e)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1}}function ur(t){return typeof t=="string"&&/^data:image\/svg\+xml/i.test(t)}function fr(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function dr(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function mr(t){let e=[],n="",o=0;for(let s=0;s<t.length;s++){let r=t[s];r==="("&&o++,r===")"&&(o=Math.max(0,o-1)),r===";"&&o===0?(e.push(n),n=""):n+=r}return n.trim()&&e.push(n),e.map(s=>s.trim()).filter(Boolean)}function pr(t){let e=[],n="",o=0;for(let r=0;r<t.length;r++){let i=t[r];i==="("&&o++,i===")"&&(o=Math.max(0,o-1)),i===","&&o===0?(e.push(n.trim()),n=""):n+=i}n.trim()&&e.push(n.trim());let s=[];for(let r of e){if(/\binset\b/i.test(r))continue;let i=r.match(/-?\d+(?:\.\d+)?px/gi)||[],[l="0px",c="0px",a="0px"]=i,u=r.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/ig,"").trim().replace(/\s{2,}/g," "),d=!!u&&u!==",";s.push(`drop-shadow(${l} ${c} ${a}${d?` ${u}`:""})`)}return s.join(" ")}function Nn(t){let e=mr(t),n=null,o=null,s=null,r=[];for(let l of e){let c=l.indexOf(":");if(c<0)continue;let a=l.slice(0,c).trim().toLowerCase(),u=l.slice(c+1).trim();a==="box-shadow"?s=u:a==="filter"?n=u:a==="-webkit-filter"?o=u:r.push([a,u])}if(s){let l=pr(s);l&&(n=n?`${n} ${l}`:l,o=o?`${o} ${l}`:l)}let i=[...r];return n&&i.push(["filter",n]),o&&i.push(["-webkit-filter",o]),i.map(([l,c])=>`${l}:${c}`).join(";")}function hr(t){return t.replace(/([^{}]+)\{([^}]*)\}/g,(e,n,o)=>`${n}{${Nn(o)}}`)}function gr(t){return t=t.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(e,n)=>e.replace(n,hr(n))),t=t.replace(/style=(['"])([\s\S]*?)\1/gi,(e,n,o)=>`style=${n}${Nn(o)}${n}`),t}function yr(t){if(!W()||!ur(t))return t;try{let e=fr(t),n=gr(e);return dr(n)}catch{return t}}async function X(t,e){let{width:n,height:o,scale:s=1,dpr:r=1,meta:i={},backgroundColor:l}=e;t=yr(t);let c=new Image;c.loading="eager",c.decoding="sync",c.crossOrigin="anonymous",c.src=t,await c.decode();let a=c.naturalWidth,u=c.naturalHeight,d=Number.isFinite(i.w0)?i.w0:a,p=Number.isFinite(i.h0)?i.h0:u,h,y,f=Number.isFinite(n),m=Number.isFinite(o);if(f&&m)h=Math.max(1,n),y=Math.max(1,o);else if(f){let w=n/Math.max(1,d);h=n,y=p*w}else if(m){let w=o/Math.max(1,p);y=o,h=d*w}else h=a,y=u;h=h*s,y=y*s;let b=document.createElement("canvas");b.width=h*r,b.height=y*r,b.style.width=`${h}px`,b.style.height=`${y}px`;let g=b.getContext("2d");return r!==1&&g.scale(r,r),l&&(g.save(),g.fillStyle=l,g.fillRect(0,0,h,y),g.restore()),g.drawImage(c,0,0,h,y),b}async function z(t,e){let n=await X(t,e),o=new Image;return o.src=n.toDataURL(`image/${e.format}`,e.quality),await o.decode(),o.style.width=`${n.width/e.dpr}px`,o.style.height=`${n.height/e.dpr}px`,o}async function gt(t,e){let{scale:n=1,width:o,height:s,meta:r={}}=e,i=Number.isFinite(o),l=Number.isFinite(s),c=Number.isFinite(n)&&n!==1||i||l;if(W()&&c)return await z(t,{...e,format:"png",quality:1,meta:r});let a=new Image;if(a.decoding="sync",a.loading="eager",a.src=t,await a.decode(),i&&l)a.style.width=`${o}px`,a.style.height=`${s}px`;else if(i){let u=Number.isFinite(r.w0)?r.w0:a.naturalWidth,d=Number.isFinite(r.h0)?r.h0:a.naturalHeight,p=o/Math.max(1,u);a.style.width=`${o}px`,a.style.height=`${Math.round(d*p)}px`}else if(l){let u=Number.isFinite(r.w0)?r.w0:a.naturalWidth,d=Number.isFinite(r.h0)?r.h0:a.naturalHeight,p=s/Math.max(1,d);a.style.height=`${s}px`,a.style.width=`${Math.round(u*p)}px`}else{let u=Math.round(a.naturalWidth*n),d=Math.round(a.naturalHeight*n);if(a.style.width=`${u}px`,a.style.height=`${d}px`,typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let h=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${u}"`).replace(/height="[^"]*"/,`height="${d}"`);t=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(h)}`,a.src=t}catch{}}return a}async function At(t,e){let n=e.type;if(n==="svg"){let s=decodeURIComponent(t.split(",")[1]);return new Blob([s],{type:"image/svg+xml"})}let o=await X(t,e);return new Promise(s=>o.toBlob(r=>s(r),`image/${n}`,e.quality))}async function Tn(t,e){if(e.dpr=1,e.format==="svg"){let s=await At(t,{...e,type:"svg"}),r=URL.createObjectURL(s),i=document.createElement("a");i.href=r,i.download=e.filename,i.click(),URL.revokeObjectURL(r);return}let n=await X(t,e),o=document.createElement("a");o.href=n.toDataURL(`image/${e.format}`,e.quality),o.download=e.filename,o.click()}F.plugins=(...t)=>(fe(...t),F);var Pn=Symbol("snapdom.internal"),J=Symbol("snapdom.internal.silent"),he=!1;async function F(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=Rn(e);if(yn(n,e&&e.plugins),W()&&(n.embedFonts===!0||wr(t)))for(let o=0;o<3;o++)try{await br(t,e),console.log("safariWarmup:",o),he=!1}catch{}return n.iconFonts&&n.iconFonts.length>0&&Oe(n.iconFonts),n.snap||(n.snap={toPng:(o,s)=>F.toPng(o,s),toSvg:(o,s)=>F.toSvg(o,s)}),F.capture(t,n,Pn)}F.plugins=(...t)=>(fe(...t),F);F.capture=async(t,e,n)=>{if(n!==Pn)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let o=await pe(t,e),s={img:async(f,m)=>gt(o,{...f,...m||{}}),svg:async(f,m)=>gt(o,{...f,...m||{}}),canvas:async(f,m)=>X(o,{...f,...m||{}}),blob:async(f,m)=>At(o,{...f,...m||{}}),png:async(f,m)=>z(o,{...f,...m||{},format:"png"}),jpeg:async(f,m)=>z(o,{...f,...m||{},format:"jpeg"}),webp:async(f,m)=>z(o,{...f,...m||{},format:"webp"}),download:async(f,m)=>Tn(o,{...f,...m||{}})},i={...e,export:{url:o},exports:{svg:f=>gt(o,{...e,...f||{},[J]:!0}),canvas:f=>X(o,{...e,...f||{},[J]:!0}),png:f=>z(o,{...e,...f||{},format:"png",[J]:!0}),jpeg:f=>z(o,{...e,...f||{},format:"jpeg",[J]:!0}),jpg:f=>z(o,{...e,...f||{},format:"jpeg",[J]:!0}),webp:f=>z(o,{...e,...f||{},format:"webp",[J]:!0}),blob:f=>At(o,{...e,...f||{},[J]:!0}),img:f=>gt(o,{...e,...f||{},[J]:!0})}},l=await gn("defineExports",i),c=Object.assign({},...l.filter(f=>f&&typeof f=="object")),a={...s,...c};a.jpeg&&!a.jpg&&(a.jpg=(f,m)=>a.jpeg(f,m));function u(f,m){let b={...e,...m||{}};return(f==="jpeg"||f==="jpg")&&(b.backgroundColor==null||b.backgroundColor==="transparent")&&(b.backgroundColor="#ffffff"),b}let d=!1,p=Promise.resolve();async function h(f,m){let b=async()=>{let g=a[f];if(!g)throw new Error(`[snapdom] Unknown export type: ${f}`);let w=u(f,m),S={...e,export:{type:f,options:w,url:o}};await q("beforeExport",S);let k=await g(S,w);return await q("afterExport",S,k),d||(d=!0,await q("afterSnap",e)),k};return p=p.then(b)}let y={url:o,toRaw:()=>o,to:(f,m)=>h(f,m),toImg:f=>h("img",f),toSvg:f=>h("svg",f),toCanvas:f=>h("canvas",f),toBlob:f=>h("blob",f),toPng:f=>h("png",f),toJpg:f=>h("jpg",f),toWebp:f=>h("webp",f),download:f=>h("download",f)};for(let f of Object.keys(a)){let m="to"+f.charAt(0).toUpperCase()+f.slice(1);y[m]||(y[m]=b=>h(f,b))}return y};F.toRaw=(t,e)=>F(t,e).then(n=>n.toRaw());F.toImg=(t,e)=>F(t,e).then(n=>n.toImg());F.toSvg=(t,e)=>F(t,e).then(n=>n.toSvg());F.toCanvas=(t,e)=>F(t,e).then(n=>n.toCanvas());F.toBlob=(t,e)=>F(t,e).then(n=>n.toBlob());F.toPng=(t,e)=>F(t,{...e,format:"png"}).then(n=>n.toPng());F.toJpg=(t,e)=>F(t,{...e,format:"jpeg"}).then(n=>n.toJpg());F.toWebp=(t,e)=>F(t,{...e,format:"webp"}).then(n=>n.toWebp());F.download=(t,e)=>F(t,e).then(n=>n.download());async function br(t,e){if(he)return;let n={...e,fast:!0,embedFonts:!0,scale:.2},o;try{o=await pe(t,n)}catch{}await new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s))),o&&await new Promise(s=>{let r=new Image;try{r.decoding="sync",r.loading="eager"}catch{}r.style.cssText="position:fixed;left:0px;top:0px;width:10px;height:10px;opacity:0.01;pointer-events:none;",r.src=o,document.body.appendChild(r),(async()=>{try{typeof r.decode=="function"&&await r.decode()}catch{}let i=performance.now();for(;!(r.complete&&r.naturalWidth>0)&&performance.now()-i<900;)await new Promise(l=>setTimeout(l,50));await new Promise(l=>requestAnimationFrame(l));try{r.remove()}catch{}s()})()}),t.querySelectorAll("canvas").forEach(s=>{try{let r=s.getContext("2d",{willReadFrequently:!0});r&&r.getImageData(0,0,1,1)}catch{}}),he=!0}function wr(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let n=e.currentNode,o=getComputedStyle(n),s=o.backgroundImage&&o.backgroundImage!=="none",r=o.maskImage&&o.maskImage!=="none"||o.webkitMaskImage&&o.webkitMaskImage!=="none";if(s||r||n.tagName==="CANVAS")return!0}return!1}async function xr(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,s=e.cache??e.cacheOpt??"full";Ft(s);try{await document.fonts?.ready}catch{}try{Gt()}catch{}x.session=x.session||{},x.session.styleCache||(x.session.styleCache=new WeakMap),x.image=x.image||new Map,x.background=x.background||new Map;try{await Dt(t,void 0,x.session.styleCache,{useProxy:o})}catch{}let r=[],i=[];try{if(t&&t.nodeType===1){let c=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];i=[t,...c],r=[],t.tagName==="IMG"&&t.getAttribute("src")&&r.push(t),r.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(r=Array.from(t.querySelectorAll("img[src]")),i=Array.from(t.querySelectorAll("*")))}catch{}let l=[];for(let c of r){let a=c?.currentSrc||c?.src;if(a&&!x.image.has(a)){let u=Promise.resolve().then(async()=>{let d=await T(a,{as:"dataURL",useProxy:o});d?.ok&&typeof d.data=="string"&&x.image.set(a,d.data)}).catch(()=>{});l.push(u)}}for(let c of i){let a="";try{a=c?.style?.backgroundImage||"",(!a||a==="none")&&(a=st(c).backgroundImage)}catch{}if(a&&a!=="none"){let u=a.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let d of u){let p=Promise.resolve().then(()=>rt(d,{...e,useProxy:o})).catch(()=>{});l.push(p)}}}if(n)try{let c=Ut(t),a=Ot(t);if(typeof W=="function"?W():!!W){let d=new Set(Array.from(c).map(p=>String(p).split("__")[0]).filter(Boolean));await Bt(d,3)}await Wt({required:c,usedCodepoints:a,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o})}catch{}await Promise.allSettled(l)}export{xr as preCache,F as snapdom};
|