Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@zumer/snapdom

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zumer/snapdom - npm Package Compare versions

Comparing version
2.5.0
to
2.6.0
+1
-1
dist/plugins.mjs
/*
* SnapDOM
* v2.5.0
* v2.6.0
* Author: Juan Martin Muda

@@ -5,0 +5,0 @@ * License: MIT

/*
* SnapDOM
* v2.5.0
* v2.6.0
* Author: Juan Martin Muda
* License: MIT
*/
var L=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let o=this.keys().next().value;o!==void 0&&this.delete(o)}return super.set(e,n)}},u={image:new L(100),background:new L(100),resource:new L(150),defaultStyle:new L(30),baseStyle:new L(50),computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function J(t="soft"){switch(u.session.__counterEpoch=(u.session.__counterEpoch||0)+1,t){case"auto":{u.session.styleMap=new Map,u.session.nodeMap=new Map;return}case"soft":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap,u.computedStyle=new WeakMap,u.baseStyle=new L(50),u.defaultStyle=new L(30),u.image=new L(100),u.background=new L(100),u.resource=new L(150),u.font=new Set;return}default:{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap;return}}}function B(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function v(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function Z(t,e){if(!t||/^(data|blob|about|#)/i.test(t.trim()))return t;try{let n=e||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(t,n).href}catch{return t}}function yt(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,a=0;function i(r,f,c){if(a>=n)return;let l=Date.now();(o.get(f)||0)>l||(o.set(f,l+e),a++,r==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(r,f){i("warn",r,f)},errorOnce(r,f){i("error",r,f)},reset(){o.clear(),a=0}}}var tt=yt("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),z=new Map,W=new Map;function wt(t){return/^data:|^blob:|^about:blank$/i.test(t)}function St(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,a=new URL(o||".",n),i=new URL(t,n);if(i.origin===a.origin)return!0;let r=i.searchParams;if(r&&(r.has("url")||r.has("target")))return!0}catch{}return!1}function bt(t,e){if(!e||wt(t)||St(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 Ct(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",v(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}${v(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function et(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 xt(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function M(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,a=e.useProxy||"",i=e.errorTTL??8e3,r=e.headers||{},f=!!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[,s="",d=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],y=/;base64/i.test(s)?atob(d):decodeURIComponent(d),w=new Uint8Array([...y].map(A=>A.charCodeAt(0))),C=new Blob([w],{type:(s||"").split(";")[0]||""});return{ok:!0,data:C,status:200,url:t,fromCache:!1,mime:C.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let s=await fetch(t);if(!s.ok)return{ok:!1,data:null,status:s.status,url:t,fromCache:!1,reason:"http_error"};let d=await s.blob(),g=d.type||s.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await et(d),status:s.status,url:t,fromCache:!1,mime:g}:n==="text"?{ok:!0,data:await d.text(),status:s.status,url:t,fromCache:!1,mime:g}:{ok:!0,data:d,status:s.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=xt(t,{as:n,timeout:o,useProxy:a,errorTTL:i}),l=W.get(c);if(l&&l.until>Date.now())return{...l.result,fromCache:!0};l&&W.delete(c);let m=z.get(c);if(m)return m;let p=bt(t,a)?Ct(t,a):t,S=e.credentials;if(!S)try{let s=typeof location<"u"&&location.href?location.href:"http://localhost/",d=new URL(t,s);S=typeof location<"u"&&d.origin===location.origin?"include":"omit"}catch{S="omit"}let b=new AbortController,x=setTimeout(()=>b.abort("timeout"),o),h=(async()=>{try{let s=await fetch(p,{signal:b.signal,credentials:S,headers:r});if(!s.ok){let y={ok:!1,data:null,status:s.status,url:p,fromCache:!1,reason:"http_error"};if(i>0&&W.set(c,{until:Date.now()+i,result:y}),!f){let w=`${s.status} ${s.statusText||""}`.trim();tt.warnOnce(`http:${s.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${w} while fetching ${n} ${t}`)}return e.onError&&e.onError(y),y}if(n==="text")return{ok:!0,data:await s.text(),status:s.status,url:p,fromCache:!1};let d=await s.blob(),g=d.type||s.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await et(d),status:s.status,url:p,fromCache:!1,mime:g}:{ok:!0,data:d,status:s.status,url:p,fromCache:!1,mime:g}}catch(s){let d=s&&typeof s=="object"&&"name"in s&&s.name==="AbortError"?String(s.message||"").includes("timeout")?"timeout":"abort":"network",g={ok:!1,data:null,status:0,url:p,fromCache:!1,reason:d};if(!/^blob:/i.test(t)&&i>0&&W.set(c,{until:Date.now()+i,result:g}),!f){let y=`${d}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,w=d==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:d==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;tt.errorOnce(y,w)}return e.onError&&e.onError(g),g}finally{clearTimeout(x),z.delete(c)}})();return z.set(c,h),h}async function P(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=B(t);if(!o)return t;let a=Z(o),i=v(a);if(u.background.has(i)){let r=u.background.get(i);return r?`url("${r}")`:"none"}try{let r=await M(i,{as:"dataURL",useProxy:e.useProxy});return r.ok?(u.background.set(i,r.data),`url("${r.data}")`):(u.background.set(i,null),"none")}catch{return u.background.set(i,null),"none"}}var nt=new Set(["meta","script","noscript","title","link","template"]),K=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"]),At=["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 Y(){for(let t of At){let e=String(t).toLowerCase();nt.has(e)||K.has(e)||ot(e)}}function ot(t){if(t=String(t).toLowerCase(),K.has(t)){let i={};return u.defaultStyle.set(t,i),i}if(u.defaultStyle.has(t))return u.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),a={};for(let i of o){if(rt(i))continue;let r=o.getPropertyValue(i);a[i]=r}return e.removeChild(n),u.defaultStyle.set(t,a),a}var kt=/(?:^|-)(animation|transition)(?:-|$)/i,Rt=/^(--.+|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,Lt=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 rt(t){let e=String(t).toLowerCase();return!!(Lt.has(e)||Rt.test(e)||kt.test(e))}function $t(t){try{let e=t?.ownerDocument;if(!e)return typeof window<"u"?window:null;let n=e.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let o=0;o<window.frames.length;o++)try{if(window.frames[o]?.document===e)return window.frames[o]}catch{}}catch{}return typeof window<"u"?window:null}function N(t,e=null){let n=()=>{let i={length:0,getPropertyValue:()=>"",item:()=>""};return i[Symbol.iterator]=function*(){},i};if(!(t instanceof Element)){let i=typeof window<"u"?window:null;if(i&&typeof i.getComputedStyle=="function")try{return i.getComputedStyle(t,e)||n()}catch{return n()}return n()}let o=u.computedStyle.get(t);o||(o=new Map,u.computedStyle.set(t,o));let a=o.get(e);if(!a){let i=$t(t),r=null;try{r=i&&typeof i.getComputedStyle=="function"?i.getComputedStyle(t,e):null}catch{}if(!r&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(r=window.getComputedStyle(t,e))}catch{}a=r||n(),o.set(e,a)}return a}function q(t){let e=[],n=0,o=0;for(let a=0;a<t.length;a++){let i=t[a];i==="("&&n++,i===")"&&n--,i===","&&n===0&&(e.push(t.slice(o,a).trim()),o=a+1)}return e.push(t.slice(o).trim()),e}function D(){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),a=/mobile/i.test(t),i=!/safari/i.test(t),r=o&&a&&i,f=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),l=/ipad|iphone|ipod/.test(e)&&o;return n||r||f||c||l}var Mt=[/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],de=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__||{}),Et=[];function E(t){let e=typeof t=="string"?t:"",n=[...Mt,...Et];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))}var _t=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),Ft=["katex","mathjax","mathml"];function X(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!_t.has(n.toLowerCase()))return n}return""}function V(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 j(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Ut(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function It(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let a=V(n[1]),i=V(n[2]);return{min:Math.min(a,i),max:Math.max(a,i)}}let o=V(e);return{min:o,max:o}}function Ot(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Tt(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let i=parseFloat(n[1]),r=parseFloat(n[2]);return{min:Math.min(i,r),max:Math.max(i,r)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),a=o?parseFloat(o[1]):100;return{min:a,max:a}}function vt(t){return!t||typeof t!="string"?"":t.replace(/\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\s+/g,"-")}function Pt(t,e,n=[]){if(!t)return!1;try{let o=new URL(t,location.href);if(o.origin===location.origin)return!0;let i=o.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com","cdn.jsdelivr.net","unpkg.com","cdnjs.cloudflare.com","esm.sh"].some(c=>i.endsWith(c))||n.some(c=>i===c.toLowerCase()||i.endsWith("."+c.toLowerCase())))return!0;let f=(o.pathname+o.search).toLowerCase();if(/\bfont(s)?\b/.test(f)||/\.woff2?(\b|$)/.test(f)||Ft.some(c=>f.includes(c)))return!0;for(let c of e){let l=c.toLowerCase().replace(/\s+/g,"+"),m=c.toLowerCase().replace(/\s+/g,"-"),p=vt(c);if(f.includes(l)||f.includes(m)||p&&f.includes(p))return!0}return!1}catch{return!1}}function Nt(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function st(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,o,a)=>{let i=(a||"").trim();if(!i||/^data:|^blob:|^https?:|^file:|^about:/i.test(i))return n;let r=i;try{r=new URL(i,e||location.href).href}catch{}return`url("${r}")`})}var H=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,G=4;async function Dt(t,e,n){if(!t)return t;let o=new Set;function a(f,c){try{return new URL(f,c||location.href).href}catch{return f}}async function i(f,c,l=0){if(l>G)return console.warn(`[snapDOM] @import depth exceeded (${G}) at ${c}`),f;let m="",p=0,S;for(;S=H.exec(f);){m+=f.slice(p,S.index),p=H.lastIndex;let b=(S[2]||S[4]||"").trim(),x=a(b,c);if(o.has(x)){console.warn(`[snapDOM] Skipping circular @import: ${x}`);continue}o.add(x);let h="";try{let s=await M(x,{as:"text",useProxy:n,silent:!0});s.ok&&typeof s.data=="string"&&(h=s.data)}catch{}h?(h=st(h,x),h=await i(h,x,l+1),m+=`
var L=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let o=this.keys().next().value;o!==void 0&&this.delete(o)}return super.set(e,n)}},u={image:new L(100),background:new L(100),resource:new L(150),defaultStyle:new L(30),baseStyle:new L(50),computedStyle:new WeakMap,measureHints:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function J(t="soft"){switch(u.session.__counterEpoch=(u.session.__counterEpoch||0)+1,t){case"auto":{u.session.styleMap=new Map,u.session.nodeMap=new Map;return}case"soft":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap,u.computedStyle=new WeakMap,u.baseStyle=new L(50),u.defaultStyle=new L(30),u.image=new L(100),u.background=new L(100),u.resource=new L(150),u.font=new Set;return}default:{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap;return}}}function W(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function v(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function Z(t,e){if(!t||/^(data|blob|about|#)/i.test(t.trim()))return t;try{let n=e||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(t,n).href}catch{return t}}function wt(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,a=0;function i(r,f,c){if(a>=n)return;let l=Date.now();(o.get(f)||0)>l||(o.set(f,l+e),a++,r==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(r,f){i("warn",r,f)},errorOnce(r,f){i("error",r,f)},reset(){o.clear(),a=0}}}var tt=wt("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),X=new Map,B=new Map;function St(t){return/^data:|^blob:|^about:blank$/i.test(t)}function bt(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,a=new URL(o||".",n),i=new URL(t,n);if(i.origin===a.origin)return!0;let r=i.searchParams;if(r&&(r.has("url")||r.has("target")))return!0}catch{}return!1}function Ct(t,e){if(!e||St(t)||bt(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 xt(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",v(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}${v(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function et(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 kt(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function M(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,a=e.useProxy||"",i=e.errorTTL??8e3,r=e.headers||{},f=!!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[,s="",d=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],y=/;base64/i.test(s)?atob(d):decodeURIComponent(d),w=new Uint8Array([...y].map(k=>k.charCodeAt(0))),C=new Blob([w],{type:(s||"").split(";")[0]||""});return{ok:!0,data:C,status:200,url:t,fromCache:!1,mime:C.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let s=await fetch(t);if(!s.ok)return{ok:!1,data:null,status:s.status,url:t,fromCache:!1,reason:"http_error"};let d=await s.blob(),g=d.type||s.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await et(d),status:s.status,url:t,fromCache:!1,mime:g}:n==="text"?{ok:!0,data:await d.text(),status:s.status,url:t,fromCache:!1,mime:g}:{ok:!0,data:d,status:s.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=kt(t,{as:n,timeout:o,useProxy:a,errorTTL:i}),l=B.get(c);if(l&&l.until>Date.now())return{...l.result,fromCache:!0};l&&B.delete(c);let m=X.get(c);if(m)return m;let p=Ct(t,a)?xt(t,a):t,S=e.credentials;if(!S)try{let s=typeof location<"u"&&location.href?location.href:"http://localhost/",d=new URL(t,s);S=typeof location<"u"&&d.origin===location.origin?"include":"omit"}catch{S="omit"}let b=new AbortController,x=setTimeout(()=>b.abort("timeout"),o),h=(async()=>{try{let s=await fetch(p,{signal:b.signal,credentials:S,headers:r});if(!s.ok){let y={ok:!1,data:null,status:s.status,url:p,fromCache:!1,reason:"http_error"};if(i>0&&B.set(c,{until:Date.now()+i,result:y}),!f){let w=`${s.status} ${s.statusText||""}`.trim();tt.warnOnce(`http:${s.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${w} while fetching ${n} ${t}`)}return e.onError&&e.onError(y),y}if(n==="text")return{ok:!0,data:await s.text(),status:s.status,url:p,fromCache:!1};let d=await s.blob(),g=d.type||s.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await et(d),status:s.status,url:p,fromCache:!1,mime:g}:{ok:!0,data:d,status:s.status,url:p,fromCache:!1,mime:g}}catch(s){let d=s&&typeof s=="object"&&"name"in s&&s.name==="AbortError"?String(s.message||"").includes("timeout")?"timeout":"abort":"network",g={ok:!1,data:null,status:0,url:p,fromCache:!1,reason:d};if(!/^blob:/i.test(t)&&i>0&&B.set(c,{until:Date.now()+i,result:g}),!f){let y=`${d}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,w=d==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:d==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;tt.errorOnce(y,w)}return e.onError&&e.onError(g),g}finally{clearTimeout(x),X.delete(c)}})();return X.set(c,h),h}async function P(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=W(t);if(!o)return t;let a=Z(o),i=v(a);if(u.background.has(i)){let r=u.background.get(i);return r?`url("${r}")`:"none"}try{let r=await M(i,{as:"dataURL",useProxy:e.useProxy});return r.ok?(u.background.set(i,r.data),`url("${r.data}")`):(u.background.set(i,null),"none")}catch{return u.background.set(i,null),"none"}}var nt=new Set(["meta","script","noscript","title","link","template"]),z=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"]),At=["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 K(){for(let t of At){let e=String(t).toLowerCase();nt.has(e)||z.has(e)||ot(e)}}function ot(t){if(t=String(t).toLowerCase(),z.has(t)){let i={};return u.defaultStyle.set(t,i),i}if(u.defaultStyle.has(t))return u.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),a={};for(let i of o){if(rt(i))continue;let r=o.getPropertyValue(i);a[i]=r}return e.removeChild(n),u.defaultStyle.set(t,a),a}var Rt=/(?:^|-)(animation|transition)(?:-|$)/i,Lt=/^(--.+|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,$t=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","zoom"]);function rt(t){let e=String(t).toLowerCase();return!!($t.has(e)||Lt.test(e)||Rt.test(e))}function Mt(t){try{let e=t?.ownerDocument;if(!e)return typeof window<"u"?window:null;let n=e.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let o=0;o<window.frames.length;o++)try{if(window.frames[o]?.document===e)return window.frames[o]}catch{}}catch{}return typeof window<"u"?window:null}function N(t,e=null){let n=()=>{let i={length:0,getPropertyValue:()=>"",item:()=>""};return i[Symbol.iterator]=function*(){},i};if(!(t instanceof Element)){let i=typeof window<"u"?window:null;if(i&&typeof i.getComputedStyle=="function")try{return i.getComputedStyle(t,e)||n()}catch{return n()}return n()}let o=u.computedStyle.get(t);o||(o=new Map,u.computedStyle.set(t,o));let a=o.get(e);if(!a){let i=Mt(t),r=null;try{r=i&&typeof i.getComputedStyle=="function"?i.getComputedStyle(t,e):null}catch{}if(!r&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(r=window.getComputedStyle(t,e))}catch{}a=r||n(),o.set(e,a)}return a}function q(t){let e=[],n=0,o=0;for(let a=0;a<t.length;a++){let i=t[a];i==="("&&n++,i===")"&&n--,i===","&&n===0&&(e.push(t.slice(o,a).trim()),o=a+1)}return e.push(t.slice(o).trim()),e}function D(){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),a=/mobile/i.test(t),i=!/safari/i.test(t),r=o&&a&&i,f=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),l=/ipad|iphone|ipod/.test(e)&&o;return n||r||f||c||l}var Et=[/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],pe=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__||{}),_t=[];function E(t){let e=typeof t=="string"?t:"",n=[...Et,..._t];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))}var it=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),Ft=["katex","mathjax","mathml"];function H(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!it.has(n.toLowerCase()))return n}return""}function Ut(t){if(!t)return[];let e=[];for(let n of t.split(",")){let o=n.trim().replace(/^['"]+|['"]+$/g,"");o&&(it.has(o.toLowerCase())||e.push(o))}return e}function V(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 j(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function It(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Ot(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let a=V(n[1]),i=V(n[2]);return{min:Math.min(a,i),max:Math.max(a,i)}}let o=V(e);return{min:o,max:o}}function Tt(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function vt(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let i=parseFloat(n[1]),r=parseFloat(n[2]);return{min:Math.min(i,r),max:Math.max(i,r)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),a=o?parseFloat(o[1]):100;return{min:a,max:a}}function Pt(t){return!t||typeof t!="string"?"":t.replace(/\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\s+/g,"-")}function Nt(t,e,n=[]){if(!t)return!1;try{let o=new URL(t,location.href);if(o.origin===location.origin)return!0;let i=o.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com","cdn.jsdelivr.net","unpkg.com","cdnjs.cloudflare.com","esm.sh"].some(c=>i.endsWith(c))||n.some(c=>i===c.toLowerCase()||i.endsWith("."+c.toLowerCase())))return!0;let f=(o.pathname+o.search).toLowerCase();if(/\bfont(s)?\b/.test(f)||/\.woff2?(\b|$)/.test(f)||Ft.some(c=>f.includes(c)))return!0;for(let c of e){let l=c.toLowerCase().replace(/\s+/g,"+"),m=c.toLowerCase().replace(/\s+/g,"-"),p=Pt(c);if(f.includes(l)||f.includes(m)||p&&f.includes(p))return!0}return!1}catch{return!1}}function Dt(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function st(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,o,a)=>{let i=(a||"").trim();if(!i||/^data:|^blob:|^https?:|^file:|^about:/i.test(i))return n;let r=i;try{r=new URL(i,e||location.href).href}catch{}return`url("${r}")`})}var Y=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,G=4;async function Wt(t,e,n){if(!t)return t;let o=new Set;function a(f,c){try{return new URL(f,c||location.href).href}catch{return f}}async function i(f,c,l=0){if(l>G)return console.warn(`[snapDOM] @import depth exceeded (${G}) at ${c}`),f;let m="",p=0,S;for(;S=Y.exec(f);){m+=f.slice(p,S.index),p=Y.lastIndex;let b=(S[2]||S[4]||"").trim(),x=a(b,c);if(o.has(x)){console.warn(`[snapDOM] Skipping circular @import: ${x}`);continue}o.add(x);let h="";try{let s=await M(x,{as:"text",useProxy:n,silent:!0});s.ok&&typeof s.data=="string"&&(h=s.data)}catch{}h?(h=st(h,x),h=await i(h,x,l+1),m+=`
/* inlined: ${x} */
${h}
`):m+=S[0]}return m+=f.slice(p),m}let r=st(t,e||location.href);return r=await i(r,e||location.href,0),r}var it=/url\((["']?)([^"')]+)\1\)/g,Bt=/@font-face[^{}]*\{[^}]*\}/g;function ct(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let a=o.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!a)continue;let i=a[1],r=a[2],f=c=>{if(!c.includes("?"))return parseInt(c,16);let l=parseInt(c.replace(/\?/g,"0"),16),m=parseInt(c.replace(/\?/g,"F"),16);return[l,m]};if(r){let c=f(i),l=f(r),m=Array.isArray(c)?c[0]:c,p=Array.isArray(l)?l[1]:l;e.push([Math.min(m,p),Math.max(m,p)])}else{let c=f(i);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function lt(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,a]of e)if(n>=o&&n<=a)return!0;return!1}function Q(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(it)){let a=(o[2]||"").trim();if(!(!a||a.startsWith("data:"))){if(!/^https?:/i.test(a))try{a=new URL(a,e||location.href).href}catch{}n.push(a)}}return n}async function ft(t,e,n=""){let o=t;for(let a of t.matchAll(it)){let i=B(a[0]);if(!i)continue;let r=i;if(!r.startsWith("http")&&!r.startsWith("data:"))try{r=new URL(r,e||location.href).href}catch{}if(!E(r)){if(u.resource?.has(r)){u.font?.add(r),o=o.replace(a[0],`url(${u.resource.get(r)})`);continue}if(!u.font?.has(r))try{let f=await M(r,{as:"dataURL",useProxy:n,silent:!0});if(f.ok&&typeof f.data=="string"){let c=f.data;u.resource?.set(r,c),u.font?.add(r),o=o.replace(a[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",r)}}}return o}function Wt(t){if(!t.length)return null;let e=(f,c)=>t.some(([l,m])=>!(m<f||l>c)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),a=e(880,1023),i=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":i?"cyrillic":a?"greek":o?"latin-ext":n?"latin":null}function at(t={}){let e=new Set((t.families||[]).map(a=>String(a).toLowerCase())),n=new Set((t.domains||[]).map(a=>String(a).toLowerCase())),o=new Set((t.subsets||[]).map(a=>String(a).toLowerCase()));return(a,i)=>{if(e.size&&e.has(a.family.toLowerCase()))return!0;if(n.size)for(let r of a.srcUrls)try{if(n.has(new URL(r).host.toLowerCase()))return!0}catch{}if(o.size){let r=Wt(i);if(r&&o.has(r))return!0}return!1}}function qt(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,o=[];for(let i of t.match(e)||[]){let r=i.match(/font-family:\s*([^;]+);/i)?.[1]||"",f=X(r),c=(i.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),l=(i.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),m=(i.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),p=(i.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),S=(i.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),b=Q(S,location.href),x=b.length?b.map(s=>String(s).toLowerCase()).sort().join("|"):S.toLowerCase(),h=[String(f||"").toLowerCase(),c,l,m,p.toLowerCase(),x].join("|");n.has(h)||(n.add(h),o.push(i))}if(o.length===0)return t;let a=0;return t.replace(e,()=>o[a++]||"")}function Vt(t,e,n,o,a){let i=Array.from(t||[]).sort().join("|"),r=e?JSON.stringify({families:(e.families||[]).map(m=>String(m).toLowerCase()).sort(),domains:(e.domains||[]).map(m=>String(m).toLowerCase()).sort(),subsets:(e.subsets||[]).map(m=>String(m).toLowerCase()).sort()}):"",f=(n||[]).map(m=>`${(m.family||"").toLowerCase()}::${m.weight||"normal"}::${m.style||"normal"}::${m.src||""}`).sort().join("|"),c=o||"",l=(a||[]).map(m=>String(m).toLowerCase()).sort().join("|");return`fonts-embed-css::req=${i}::ex=${r}::lf=${f}::px=${c}::fd=${l}`}async function ut(t,e,n,o){let a;try{a=t.cssRules||[]}catch{return}let i=(r,f)=>{try{return new URL(r,f||location.href).href}catch{return r}};for(let r of a){if(r.type===CSSRule.IMPORT_RULE&&r.styleSheet){let f=r.href?i(r.href,e):e;if(o.depth>=G){console.warn(`[snapDOM] CSSOM import depth exceeded (${G}) at ${f}`);continue}if(f&&o.visitedSheets.has(f)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${f}`);continue}f&&o.visitedSheets.add(f);let c={...o,depth:(o.depth||0)+1};await ut(r.styleSheet,f,n,c);continue}if(r.type===CSSRule.FONT_FACE_RULE){let f=(r.style.getPropertyValue("font-family")||"").trim(),c=X(f);if(!c||E(c))continue;let l=(r.style.getPropertyValue("font-weight")||"400").trim(),m=(r.style.getPropertyValue("font-style")||"normal").trim(),p=(r.style.getPropertyValue("font-stretch")||"100%").trim(),S=(r.style.getPropertyValue("src")||"").trim(),b=(r.style.getPropertyValue("unicode-range")||"").trim();if(!o.faceMatchesRequired(c,m,l,p))continue;let x=ct(b);if(!lt(o.usedCodepoints,x))continue;let h={family:c,weightSpec:l,styleSpec:m,stretchSpec:p,unicodeRange:b,srcRaw:S,srcUrls:Q(S,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(h,x))continue;if(/url\(/i.test(S)){let s=await ft(S,e||location.href,o.useProxy);await n(`@font-face{font-family:${c};src:${s};font-style:${m};font-weight:${l};font-stretch:${p};${b?`unicode-range:${b};`:""}}`)}else await n(`@font-face{font-family:${c};src:${S};font-style:${m};font-weight:${l};font-stretch:${p};${b?`unicode-range:${b};`:""}}`)}}}async function mt({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:a="",fontStylesheetDomains:i=[]}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let r=new Map;for(let s of t){let[d,g,y,w]=String(s).split("__");if(!d)continue;let C=r.get(d)||[];C.push({w:parseInt(g,10),s:y,st:parseInt(w,10)}),r.set(d,C)}function f(s,d,g,y){if(!r.has(s))return!1;let w=r.get(s),C=It(g),A=Ot(d),R=Tt(y),F=C.min!==C.max,U=C.min,T=k=>A.kind==="normal"&&k==="normal"||A.kind!=="normal"&&(k==="italic"||k==="oblique"),I=!1;for(let k of w){let $=F?k.w>=C.min&&k.w<=C.max:k.w===U,_=T(j(k.s)),O=k.st>=R.min&&k.st<=R.max;if($&&_&&O){I=!0;break}}if(I)return!0;if(!F)for(let k of w){let $=T(j(k.s)),_=k.st>=R.min&&k.st<=R.max;if(Math.abs(U-k.w)<=300&&$&&_)return!0}if(!F&&A.kind==="normal"&&w.some($=>j($.s)!=="normal"))for(let $ of w){let _=Math.abs(U-$.w)<=300,O=$.st>=R.min&&$.st<=R.max;if(_&&O)return!0}return!1}let c=at(n),l=Vt(t,n,o,a,i);if(u.resource?.has(l))return u.resource.get(l);let m=Nt(t),p=[],S=H;for(let s of document.querySelectorAll("style")){let d=s.textContent||"";for(let g of d.matchAll(S)){let y=(g[2]||g[4]||"").trim();if(!y||E(y))continue;!!document.querySelector(`link[rel="stylesheet"][href="${y}"]`)||p.push(y)}}p.length&&await Promise.all(p.map(s=>new Promise(d=>{if(document.querySelector(`link[rel="stylesheet"][href="${s}"]`))return d(null);let g=document.createElement("link");g.rel="stylesheet",g.href=s,g.setAttribute("data-snapdom","injected-import"),g.onload=()=>d(g),g.onerror=()=>d(null),document.head.appendChild(g)})));let b="",x=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(s=>!!s.href);for(let s of x)try{if(E(s.href))continue;let d="",g=!1;try{g=new URL(s.href,location.href).origin===location.origin}catch{}if(!g){let w=Array.isArray(i)?i:[];if(!Pt(s.href,m,w))continue}if(g){let w=Array.from(document.styleSheets).find(C=>C.href===s.href);if(w)try{let C=w.cssRules||[];d=Array.from(C).map(A=>A.cssText).join("")}catch{}}if(!d){let w=await M(s.href,{as:"text",useProxy:a});if(w?.ok&&typeof w.data=="string"&&(d=w.data),E(s.href))continue}d=await Dt(d,s.href,a);let y="";for(let w of d.match(Bt)||[]){let C=(w.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),A=X(C);if(!A||E(A))continue;let R=(w.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),F=(w.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),U=(w.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),T=(w.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),I=(w.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),k=Q(I,s.href);if(!f(A,F,R,U))continue;let $=ct(T);if(!lt(e,$))continue;let _={family:A,weightSpec:R,styleSpec:F,stretchSpec:U,unicodeRange:T,srcRaw:I,srcUrls:k,href:s.href};if(n&&c(_,$))continue;let O=/url\(/i.test(I)?await ft(w,s.href,a):w;y+=O}y.trim()&&(b+=y)}catch{console.warn("[snapDOM] Failed to process stylesheet:",s.href)}let h={requiredIndex:r,usedCodepoints:e,faceMatchesRequired:f,simpleExcluder:n?at(n):null,useProxy:a,visitedSheets:new Set,depth:0};for(let s of document.styleSheets)if(!(s.href&&x.some(d=>d.href===s.href)))try{let d=s.href||location.origin+"/";d&&h.visitedSheets.add(d),await ut(s,d,async g=>{b+=g},h)}catch{}try{for(let s of document.fonts||[]){if(!s||!s.family||s.status!=="loaded"||!s._snapdomSrc)continue;let d=String(s.family).replace(/^['"]+|['"]+$/g,"");if(E(d)||!r.has(d)||n?.families&&n.families.some(y=>String(y).toLowerCase()===d.toLowerCase()))continue;let g=s._snapdomSrc;if(!String(g).startsWith("data:")){if(u.resource?.has(s._snapdomSrc))g=u.resource.get(s._snapdomSrc),u.font?.add(s._snapdomSrc);else if(!u.font?.has(s._snapdomSrc))try{let y=await M(s._snapdomSrc,{as:"dataURL",useProxy:a,silent:!0});if(y.ok&&typeof y.data=="string")g=y.data,u.resource?.set(s._snapdomSrc,g),u.font?.add(s._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",s._snapdomSrc);continue}}b+=`@font-face{font-family:'${d}';src:url(${g});font-style:${s.style||"normal"};font-weight:${s.weight||"normal"};}`}}catch{}for(let s of o){if(!s||typeof s!="object")continue;let d=String(s.family||"").replace(/^['"]+|['"]+$/g,"");if(!d||E(d)||!r.has(d)||n?.families&&n.families.some(R=>String(R).toLowerCase()===d.toLowerCase()))continue;let g=s.weight!=null?String(s.weight):"normal",y=s.style!=null?String(s.style):"normal",w=s.stretchPct!=null?`${s.stretchPct}%`:"100%",C=String(s.src||""),A=C;if(!A.startsWith("data:")){if(u.resource?.has(C))A=u.resource.get(C),u.font?.add(C);else if(!u.font?.has(C))try{let R=await M(C,{as:"dataURL",useProxy:a,silent:!0});if(R.ok&&typeof R.data=="string")A=R.data,u.resource?.set(C,A),u.font?.add(C);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",C);continue}}b+=`@font-face{font-family:'${d}';src:url(${A});font-style:${y};font-weight:${g};font-stretch:${w};}`}return b&&(b=qt(b),u.resource?.set(l,b)),b}function dt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=r=>{let f=X(r.fontFamily);if(!f)return;let c=(l,m,p)=>`${f}__${V(l)}__${j(m)}__${Ut(p)}`;e.add(c(r.fontWeight,r.fontStyle,r.fontStretch))};o(getComputedStyle(t));let a=getComputedStyle(t,"::before");a&&a.content&&a.content!=="none"&&o(a);let i=getComputedStyle(t,"::after");for(i&&i.content&&i.content!=="none"&&o(i);n.nextNode();){let r=n.currentNode,f=getComputedStyle(r);o(f);let c=getComputedStyle(r,"::before");c&&c.content&&c.content!=="none"&&o(c);let l=getComputedStyle(r,"::after");l&&l.content&&l.content!=="none"&&o(l)}return e}function pt(t){let e=new Set,n=a=>{if(a)for(let i of a)e.add(i.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let a=o.currentNode;if(a.nodeType===Node.TEXT_NODE)n(a.nodeValue||"");else if(a.nodeType===Node.ELEMENT_NODE){let i=a;for(let r of["::before","::after"]){let c=getComputedStyle(i,r)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let l=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(l)for(let m of l)try{e.add(parseInt(m.slice(1),16))}catch{}}}}}return e}async function ht(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let a=document.createElement("div");a.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let i of n){let r=document.createElement("span");r.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",r.style.fontFamily=`"${i}"`,r.style.fontWeight="700",r.style.fontStyle="italic",r.style.fontSize="32px",r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.margin="0",r.style.padding="0",a.appendChild(r)}document.body.appendChild(a),a.offsetWidth,document.body.removeChild(a)};for(let a=0;a<Math.max(1,e);a++)o(),await new Promise(i=>requestAnimationFrame(()=>requestAnimationFrame(i)))}async function gt(t,e,n,o={}){let a=[[t,e]],i=["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"],r=["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"],f=["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(;a.length;){let[l,m]=a.shift();if(!m)continue;let p=n.get(l)||N(l);n.has(l)||n.set(l,p);let S=(()=>{let h=p.getPropertyValue("border-image"),s=p.getPropertyValue("border-image-source");return h&&h!=="none"||s&&s!=="none"})();for(let h of f){let s=p.getPropertyValue(h);s&&m.style.setProperty(h,s)}for(let h of i){let s=p.getPropertyValue(h);if(h==="background-image"&&(!s||s==="none")){let y=p.getPropertyValue("background");y&&/url\s*\(/.test(y)&&(s=q(y).find(w=>/url\s*\(/.test(w))||s)}if(!s||s==="none")continue;let d=q(s),g=await Promise.all(d.map(y=>P(y,o)));g.some(y=>y&&y!=="none"&&!/^url\(undefined/.test(y))&&m.style.setProperty(h,g.join(", "))}for(let h of r){let s=p.getPropertyValue(h);!s||s==="initial"||m.style.setProperty(h,s)}if(S)for(let h of c){let s=p.getPropertyValue(h);!s||s==="initial"||m.style.setProperty(h,s)}let b=l.shadowRoot?Array.from(l.shadowRoot.children).filter(h=>h.tagName!=="STYLE"):Array.from(l.children),x=Array.from(m.children).filter(h=>!(h.dataset?.snapdomPseudo||h.tagName==="STYLE"&&h.dataset?.sd));for(let h=0;h<Math.min(b.length,x.length);h++)a.push([b[h],x[h]])}}async function $e(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,a=e.cache??e.cacheOpt??"full";J(a);try{await document.fonts?.ready}catch{}try{Y()}catch{}u.session=u.session||{},u.session.styleCache||(u.session.styleCache=new WeakMap),u.image=u.image||new L(100),u.background=u.background||new L(100);try{await gt(t,void 0,u.session.styleCache,{useProxy:o})}catch{}let i=[],r=[];try{if(t&&t.nodeType===1){let c=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];r=[t,...c],i=[],t.tagName==="IMG"&&t.getAttribute("src")&&i.push(t),i.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(i=Array.from(t.querySelectorAll("img[src]")),r=Array.from(t.querySelectorAll("*")))}catch{}let f=[];for(let c of i){let l=c?.currentSrc||c?.src;if(l&&!u.image.has(l)){let m=Promise.resolve().then(async()=>{let p=await M(l,{as:"dataURL",useProxy:o});p?.ok&&typeof p.data=="string"&&u.image.set(l,p.data)}).catch(()=>{});f.push(m)}}for(let c of r){let l="";try{l=c?.style?.backgroundImage||"",(!l||l==="none")&&(l=N(c).backgroundImage)}catch{}if(l&&l!=="none"){let m=l.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let p of m){let S=Promise.resolve().then(()=>P(p,{...e,useProxy:o})).catch(()=>{});f.push(S)}}}if(n)try{let c=dt(t),l=pt(t);if(typeof D=="function"?D():!!D){let p=new Set(Array.from(c).map(S=>String(S).split("__")[0]).filter(Boolean));await ht(p,3)}await mt({required:c,usedCodepoints:l,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(f)}export{$e as preCache};
`):m+=S[0]}return m+=f.slice(p),m}let r=st(t,e||location.href);return r=await i(r,e||location.href,0),r}var ct=/url\((["']?)([^"')]+)\1\)/g,Bt=/@font-face[^{}]*\{[^}]*\}/g;function lt(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let a=o.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!a)continue;let i=a[1],r=a[2],f=c=>{if(!c.includes("?"))return parseInt(c,16);let l=parseInt(c.replace(/\?/g,"0"),16),m=parseInt(c.replace(/\?/g,"F"),16);return[l,m]};if(r){let c=f(i),l=f(r),m=Array.isArray(c)?c[0]:c,p=Array.isArray(l)?l[1]:l;e.push([Math.min(m,p),Math.max(m,p)])}else{let c=f(i);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function ft(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,a]of e)if(n>=o&&n<=a)return!0;return!1}function Q(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(ct)){let a=(o[2]||"").trim();if(!(!a||a.startsWith("data:"))){if(!/^https?:/i.test(a))try{a=new URL(a,e||location.href).href}catch{}n.push(a)}}return n}async function ut(t,e,n=""){let o=t;for(let a of t.matchAll(ct)){let i=W(a[0]);if(!i)continue;let r=i;if(!r.startsWith("http")&&!r.startsWith("data:"))try{r=new URL(r,e||location.href).href}catch{}if(!E(r)){if(u.resource?.has(r)){u.font?.add(r),o=o.replace(a[0],`url(${u.resource.get(r)})`);continue}if(!u.font?.has(r))try{let f=await M(r,{as:"dataURL",useProxy:n,silent:!0});if(f.ok&&typeof f.data=="string"){let c=f.data;u.resource?.set(r,c),u.font?.add(r),o=o.replace(a[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",r)}}}return o}function qt(t){if(!t.length)return null;let e=(f,c)=>t.some(([l,m])=>!(m<f||l>c)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),a=e(880,1023),i=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":i?"cyrillic":a?"greek":o?"latin-ext":n?"latin":null}function at(t={}){let e=new Set((t.families||[]).map(a=>String(a).toLowerCase())),n=new Set((t.domains||[]).map(a=>String(a).toLowerCase())),o=new Set((t.subsets||[]).map(a=>String(a).toLowerCase()));return(a,i)=>{if(e.size&&e.has(a.family.toLowerCase()))return!0;if(n.size)for(let r of a.srcUrls)try{if(n.has(new URL(r).host.toLowerCase()))return!0}catch{}if(o.size){let r=qt(i);if(r&&o.has(r))return!0}return!1}}function Vt(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,o=[];for(let i of t.match(e)||[]){let r=i.match(/font-family:\s*([^;]+);/i)?.[1]||"",f=H(r),c=(i.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),l=(i.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),m=(i.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),p=(i.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),S=(i.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),b=Q(S,location.href),x=b.length?b.map(s=>String(s).toLowerCase()).sort().join("|"):S.toLowerCase(),h=[String(f||"").toLowerCase(),c,l,m,p.toLowerCase(),x].join("|");n.has(h)||(n.add(h),o.push(i))}if(o.length===0)return t;let a=0;return t.replace(e,()=>o[a++]||"")}function jt(t,e,n,o,a){let i=Array.from(t||[]).sort().join("|"),r=e?JSON.stringify({families:(e.families||[]).map(m=>String(m).toLowerCase()).sort(),domains:(e.domains||[]).map(m=>String(m).toLowerCase()).sort(),subsets:(e.subsets||[]).map(m=>String(m).toLowerCase()).sort()}):"",f=(n||[]).map(m=>`${(m.family||"").toLowerCase()}::${m.weight||"normal"}::${m.style||"normal"}::${m.src||""}`).sort().join("|"),c=o||"",l=(a||[]).map(m=>String(m).toLowerCase()).sort().join("|");return`fonts-embed-css::req=${i}::ex=${r}::lf=${f}::px=${c}::fd=${l}`}async function mt(t,e,n,o){let a;try{a=t.cssRules||[]}catch{return}let i=(r,f)=>{try{return new URL(r,f||location.href).href}catch{return r}};for(let r of a){if(r.type===CSSRule.IMPORT_RULE&&r.styleSheet){let f=r.href?i(r.href,e):e;if(o.depth>=G){console.warn(`[snapDOM] CSSOM import depth exceeded (${G}) at ${f}`);continue}if(f&&o.visitedSheets.has(f)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${f}`);continue}f&&o.visitedSheets.add(f);let c={...o,depth:(o.depth||0)+1};await mt(r.styleSheet,f,n,c);continue}if(r.type===CSSRule.FONT_FACE_RULE){let f=(r.style.getPropertyValue("font-family")||"").trim(),c=H(f);if(!c||E(c))continue;let l=(r.style.getPropertyValue("font-weight")||"400").trim(),m=(r.style.getPropertyValue("font-style")||"normal").trim(),p=(r.style.getPropertyValue("font-stretch")||"100%").trim(),S=(r.style.getPropertyValue("src")||"").trim(),b=(r.style.getPropertyValue("unicode-range")||"").trim();if(!o.faceMatchesRequired(c,m,l,p))continue;let x=lt(b);if(!ft(o.usedCodepoints,x))continue;let h={family:c,weightSpec:l,styleSpec:m,stretchSpec:p,unicodeRange:b,srcRaw:S,srcUrls:Q(S,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(h,x))continue;if(/url\(/i.test(S)){let s=await ut(S,e||location.href,o.useProxy);await n(`@font-face{font-family:${c};src:${s};font-style:${m};font-weight:${l};font-stretch:${p};${b?`unicode-range:${b};`:""}}`)}else await n(`@font-face{font-family:${c};src:${S};font-style:${m};font-weight:${l};font-stretch:${p};${b?`unicode-range:${b};`:""}}`)}}}async function dt({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:a="",fontStylesheetDomains:i=[]}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let r=new Map;for(let s of t){let[d,g,y,w]=String(s).split("__");if(!d)continue;let C=r.get(d)||[];C.push({w:parseInt(g,10),s:y,st:parseInt(w,10)}),r.set(d,C)}function f(s,d,g,y){if(!r.has(s))return!1;let w=r.get(s),C=Ot(g),k=Tt(d),R=vt(y),F=C.min!==C.max,U=C.min,T=A=>k.kind==="normal"&&A==="normal"||k.kind!=="normal"&&(A==="italic"||A==="oblique"),I=!1;for(let A of w){let $=F?A.w>=C.min&&A.w<=C.max:A.w===U,_=T(j(A.s)),O=A.st>=R.min&&A.st<=R.max;if($&&_&&O){I=!0;break}}if(I)return!0;if(!F)for(let A of w){let $=T(j(A.s)),_=A.st>=R.min&&A.st<=R.max;if(Math.abs(U-A.w)<=300&&$&&_)return!0}if(!F&&k.kind==="normal"&&w.some($=>j($.s)!=="normal"))for(let $ of w){let _=Math.abs(U-$.w)<=300,O=$.st>=R.min&&$.st<=R.max;if(_&&O)return!0}return!1}let c=at(n),l=jt(t,n,o,a,i);if(u.resource?.has(l))return u.resource.get(l);let m=Dt(t),p=[],S=Y;for(let s of document.querySelectorAll("style")){let d=s.textContent||"";for(let g of d.matchAll(S)){let y=(g[2]||g[4]||"").trim();if(!y||E(y))continue;!!document.querySelector(`link[rel="stylesheet"][href="${y}"]`)||p.push(y)}}p.length&&await Promise.all(p.map(s=>new Promise(d=>{if(document.querySelector(`link[rel="stylesheet"][href="${s}"]`))return d(null);let g=document.createElement("link");g.rel="stylesheet",g.href=s,g.setAttribute("data-snapdom","injected-import"),g.onload=()=>d(g),g.onerror=()=>d(null),document.head.appendChild(g)})));let b="",x=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(s=>!!s.href);for(let s of x)try{if(E(s.href))continue;let d="",g=!1;try{g=new URL(s.href,location.href).origin===location.origin}catch{}if(!g){let w=Array.isArray(i)?i:[];if(!Nt(s.href,m,w))continue}if(g){let w=Array.from(document.styleSheets).find(C=>C.href===s.href);if(w)try{let C=w.cssRules||[];d=Array.from(C).map(k=>k.cssText).join("")}catch{}}if(!d){let w=await M(s.href,{as:"text",useProxy:a});if(w?.ok&&typeof w.data=="string"&&(d=w.data),E(s.href))continue}d=await Wt(d,s.href,a);let y="";for(let w of d.match(Bt)||[]){let C=(w.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),k=H(C);if(!k||E(k))continue;let R=(w.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),F=(w.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),U=(w.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),T=(w.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),I=(w.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),A=Q(I,s.href);if(!f(k,F,R,U))continue;let $=lt(T);if(!ft(e,$))continue;let _={family:k,weightSpec:R,styleSpec:F,stretchSpec:U,unicodeRange:T,srcRaw:I,srcUrls:A,href:s.href};if(n&&c(_,$))continue;let O=/url\(/i.test(I)?await ut(w,s.href,a):w;y+=O}y.trim()&&(b+=y)}catch{console.warn("[snapDOM] Failed to process stylesheet:",s.href)}let h={requiredIndex:r,usedCodepoints:e,faceMatchesRequired:f,simpleExcluder:n?at(n):null,useProxy:a,visitedSheets:new Set,depth:0};for(let s of document.styleSheets)if(!(s.href&&x.some(d=>d.href===s.href)))try{let d=s.href||location.origin+"/";d&&h.visitedSheets.add(d),await mt(s,d,async g=>{b+=g},h)}catch{}try{for(let s of document.fonts||[]){if(!s||!s.family||s.status!=="loaded"||!s._snapdomSrc)continue;let d=String(s.family).replace(/^['"]+|['"]+$/g,"");if(E(d)||!r.has(d)||n?.families&&n.families.some(y=>String(y).toLowerCase()===d.toLowerCase()))continue;let g=s._snapdomSrc;if(!String(g).startsWith("data:")){if(u.resource?.has(s._snapdomSrc))g=u.resource.get(s._snapdomSrc),u.font?.add(s._snapdomSrc);else if(!u.font?.has(s._snapdomSrc))try{let y=await M(s._snapdomSrc,{as:"dataURL",useProxy:a,silent:!0});if(y.ok&&typeof y.data=="string")g=y.data,u.resource?.set(s._snapdomSrc,g),u.font?.add(s._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",s._snapdomSrc);continue}}b+=`@font-face{font-family:'${d}';src:url(${g});font-style:${s.style||"normal"};font-weight:${s.weight||"normal"};}`}}catch{}for(let s of o){if(!s||typeof s!="object")continue;let d=String(s.family||"").replace(/^['"]+|['"]+$/g,"");if(!d||E(d)||!r.has(d)||n?.families&&n.families.some(R=>String(R).toLowerCase()===d.toLowerCase()))continue;let g=s.weight!=null?String(s.weight):"normal",y=s.style!=null?String(s.style):"normal",w=s.stretchPct!=null?`${s.stretchPct}%`:"100%",C=String(s.src||""),k=C;if(!k.startsWith("data:")){if(u.resource?.has(C))k=u.resource.get(C),u.font?.add(C);else if(!u.font?.has(C))try{let R=await M(C,{as:"dataURL",useProxy:a,silent:!0});if(R.ok&&typeof R.data=="string")k=R.data,u.resource?.set(C,k),u.font?.add(C);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",C);continue}}b+=`@font-face{font-family:'${d}';src:url(${k});font-style:${y};font-weight:${g};font-stretch:${w};}`}return b&&(b=Vt(b),u.resource?.set(l,b)),b}function pt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=r=>{let f=Ut(r.fontFamily);if(f.length)for(let c of f){let l=(m,p,S)=>`${c}__${V(m)}__${j(p)}__${It(S)}`;e.add(l(r.fontWeight,r.fontStyle,r.fontStretch))}};o(getComputedStyle(t));let a=getComputedStyle(t,"::before");a&&a.content&&a.content!=="none"&&o(a);let i=getComputedStyle(t,"::after");for(i&&i.content&&i.content!=="none"&&o(i);n.nextNode();){let r=n.currentNode,f=getComputedStyle(r);o(f);let c=getComputedStyle(r,"::before");c&&c.content&&c.content!=="none"&&o(c);let l=getComputedStyle(r,"::after");l&&l.content&&l.content!=="none"&&o(l)}return e}function ht(t){let e=new Set,n=a=>{if(a)for(let i of a)e.add(i.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let a=o.currentNode;if(a.nodeType===Node.TEXT_NODE)n(a.nodeValue||"");else if(a.nodeType===Node.ELEMENT_NODE){let i=a;for(let r of["::before","::after"]){let c=getComputedStyle(i,r)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let l=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(l)for(let m of l)try{e.add(parseInt(m.slice(1),16))}catch{}}}}}return e}async function gt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let a=document.createElement("div");a.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let i of n){let r=document.createElement("span");r.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",r.style.fontFamily=`"${i}"`,r.style.fontWeight="700",r.style.fontStyle="italic",r.style.fontSize="32px",r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.margin="0",r.style.padding="0",a.appendChild(r)}document.body.appendChild(a),a.offsetWidth,document.body.removeChild(a)};for(let a=0;a<Math.max(1,e);a++)o(),await new Promise(i=>requestAnimationFrame(()=>requestAnimationFrame(i)))}async function yt(t,e,n,o={}){let a=[[t,e]],i=["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"],r=["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"],f=["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(;a.length;){let[l,m]=a.shift();if(!m)continue;let p=n.get(l)||N(l);n.has(l)||n.set(l,p);let S=(()=>{let h=p.getPropertyValue("border-image"),s=p.getPropertyValue("border-image-source");return h&&h!=="none"||s&&s!=="none"})();for(let h of f){let s=p.getPropertyValue(h);s&&m.style.setProperty(h,s)}for(let h of i){let s=p.getPropertyValue(h);if(h==="background-image"&&(!s||s==="none")){let y=p.getPropertyValue("background");y&&/url\s*\(/.test(y)&&(s=q(y).filter(w=>/url\s*\(/.test(w)).join(", ")||s)}if(!s||s==="none")continue;let d=q(s),g=await Promise.all(d.map(y=>P(y,o)));g.some(y=>y&&y!=="none"&&!/^url\(undefined/.test(y))&&m.style.setProperty(h,g.join(", "))}for(let h of r){let s=p.getPropertyValue(h);!s||s==="initial"||m.style.setProperty(h,s)}if(S)for(let h of c){let s=p.getPropertyValue(h);!s||s==="initial"||m.style.setProperty(h,s)}let b=l.shadowRoot?Array.from(l.shadowRoot.children).filter(h=>h.tagName!=="STYLE"):Array.from(l.children),x=Array.from(m.children).filter(h=>!(h.dataset?.snapdomPseudo||h.tagName==="STYLE"&&h.dataset?.sd));for(let h=0;h<Math.min(b.length,x.length);h++)a.push([b[h],x[h]])}}async function Me(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,a=e.cache??e.cacheOpt??"full";J(a);try{await document.fonts?.ready}catch{}try{K()}catch{}u.session=u.session||{},u.session.styleCache||(u.session.styleCache=new WeakMap),u.image=u.image||new L(100),u.background=u.background||new L(100);try{await yt(t,void 0,u.session.styleCache,{useProxy:o})}catch{}let i=[],r=[];try{if(t&&t.nodeType===1){let c=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];r=[t,...c],i=[],t.tagName==="IMG"&&t.getAttribute("src")&&i.push(t),i.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(i=Array.from(t.querySelectorAll("img[src]")),r=Array.from(t.querySelectorAll("*")))}catch{}let f=[];for(let c of i){let l=c?.currentSrc||c?.src;if(l&&!u.image.has(l)){let m=Promise.resolve().then(async()=>{let p=await M(l,{as:"dataURL",useProxy:o});p?.ok&&typeof p.data=="string"&&u.image.set(l,p.data)}).catch(()=>{});f.push(m)}}for(let c of r){let l="";try{l=c?.style?.backgroundImage||"",(!l||l==="none")&&(l=N(c).backgroundImage)}catch{}if(l&&l!=="none"){let m=l.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let p of m){let S=Promise.resolve().then(()=>P(p,{...e,useProxy:o})).catch(()=>{});f.push(S)}}}if(n)try{let c=pt(t),l=ht(t);if(typeof D=="function"?D():!!D){let p=new Set(Array.from(c).map(S=>String(S).split("__")[0]).filter(Boolean));await gt(p,3)}await dt({required:c,usedCodepoints:l,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(f)}export{Me as preCache};
{
"name": "@zumer/snapdom",
"version": "2.5.0",
"version": "2.6.0",
"description": "snapDOM captures HTML elements to images with exceptional speed and accuracy.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display