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

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

@@ -926,2 +926,3 @@ <p align="center">

<a href="https://github.com/tinchox5" title="tinchox5"><img src="https://avatars.githubusercontent.com/u/11557901?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="tinchox5"/></a>
<a href="https://github.com/pdufour" title="pdufour"><img src="https://avatars.githubusercontent.com/u/1239145?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="pdufour"/></a>
<a href="https://github.com/Jarvis2018" title="Jarvis2018"><img src="https://avatars.githubusercontent.com/u/36788851?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="Jarvis2018"/></a>

@@ -944,2 +945,3 @@ <a href="https://github.com/tarwin" title="tarwin"><img src="https://avatars.githubusercontent.com/u/646149?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="tarwin"/></a>

<a href="https://github.com/mon-jai" title="mon-jai"><img src="https://avatars.githubusercontent.com/u/91261297?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="mon-jai"/></a>
<a href="https://github.com/puneetdixit200" title="puneetdixit200"><img src="https://avatars.githubusercontent.com/u/236133619?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="puneetdixit200"/></a>
<a href="https://github.com/RinZ27" title="RinZ27"><img src="https://avatars.githubusercontent.com/u/222222878?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="RinZ27"/></a>

@@ -953,4 +955,2 @@ <a href="https://github.com/sharuzzaman" title="sharuzzaman"><img src="https://avatars.githubusercontent.com/u/7421941?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="sharuzzaman"/></a>

<a href="https://github.com/jhbae200" title="jhbae200"><img src="https://avatars.githubusercontent.com/u/20170610?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="jhbae200"/></a>
<a href="https://github.com/xiaobai-web715" title="xiaobai-web715"><img src="https://avatars.githubusercontent.com/u/81091224?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="xiaobai-web715"/></a>
<a href="https://github.com/miusuncle" title="miusuncle"><img src="https://avatars.githubusercontent.com/u/7549857?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="miusuncle"/></a>
</p>

@@ -961,3 +961,3 @@ <!-- CONTRIBUTORS:END -->

Special thanks to [@megaphonecolin](https://github.com/megaphonecolin), [@sdraper69](https://github.com/sdraper69), [@reynaldichernando](https://github.com/reynaldichernando), [@gamma-app](https://github.com/gamma-app) and [@jrjohnson](https://github.com/jrjohnson),for supporting this project!
Special thanks to [@megaphonecolin](https://github.com/megaphonecolin), [@sdraper69](https://github.com/sdraper69), [@reynaldichernando](https://github.com/reynaldichernando), [@gamma-app](https://github.com/gamma-app), [@jrjohnson](https://github.com/jrjohnson), and [@ryanander](https://github.com/ryanander) for supporting this project!

@@ -964,0 +964,0 @@ If you'd like to support this project too, you can [become a sponsor](https://github.com/sponsors/tinchox5).

@@ -61,2 +61,4 @@ /**

quality?: number;
/** Output format for capture/export helpers. Default "png". */
format?: BlobType;

@@ -218,2 +220,4 @@ /** Cross-origin proxy prefix (used as a fallback when CORS blocks). */

filename?: string;
/** Output format for the downloaded file. Default "png". */
format?: BlobType;
/** Override default blob type for this download. */

@@ -220,0 +224,0 @@ type?: BlobType;

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

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