IZOKQ2GT.js
4 lines · archify/explainer/vendor/pele/chunks/IZOKQ2GT.js at a406594
1import{d as $,f as I}from"./XTDUIGUI.js";var H=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,P=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,U={"&":"&","<":"<",">":">",'"':"""};function b(t){return H.test(t)?t.replace(P,e=>U[e]??""):t}function y(t){return b($(t))}var v=[];for(let t=0;t<100;t++)v.push(t===0?"":t%10===0?"."+t/10:"."+(t<10?"0"+t:t));function x(t){let e=Math.round(t*100);if(e===0)return"0";if(e>0){if(e<1e11){let i=Math.floor(e/100);return i+v[e-i*100]}}else if(e>-1e11){let i=-e,n=Math.floor(i/100);return"-"+n+v[i-n*100]}return String(e/100)}function ft(t,e,i,n,s){let d=t.lines;if(d.length===0)return"";let f=t.lineHeight,l=t.size*.35,p=i-t.height/2+f/2+l;if(d.length===1&&d[0].length===1&&d[0][0].icon===void 0&&d[0][0].style===0)return`<text${n} x="${x(e)}" y="${x(p)}" text-anchor="middle">${b(d[0][0].text)}</text>`;let o=Y(t);n=q(n,o);let a="",c="";for(let r=0;r<d.length;r++){let u=d[r],m=!1;for(let g of u)g.icon!==void 0&&(m=!0);if(m){let g=e-t.widths[r]/2;for(let h of u){if(h.icon!==void 0){let w=t.size*1.1,S=s?.(h.icon)??"";c+=`<svg class="pele-icon" data-icon="${y(h.icon)}" x="${x(g)}" y="${x(p-l-w/2)}" width="${x(w)}" height="${x(w)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${S}</svg>`}else h.text!==""&&(a+=`<tspan x="${x(g)}" y="${x(p)}" text-anchor="start"${T(h.style&~o)}>${b(h.text)}</tspan>`);g+=h.width}}else{for(let g=0;g<u.length;g++){let h=u[g],w=g===0?` x="${x(e)}" y="${x(p)}"`:"";a+=`<tspan${w}${T(h.style&~o)}>${b(h.text)}</tspan>`}u.length===0&&(a+=`<tspan x="${x(e)}" y="${x(p)}"> </tspan>`)}p+=f}return`<text${n} text-anchor="middle" xml:space="preserve">${a}</text>${c}`}var O=' font-weight="var(--_w)"',L=' font-style="italic"';function T(t){return(t&1?O:"")+(t&2?L:"")}function Y(t){let e=3,i=!1;for(let n of t.lines)for(let s of n)s.icon!==void 0||s.text===""||(e&=s.style,i=!0);return i?e:0}function q(t,e){return t+(e&1&&!t.includes(' font-weight="')?O:"")+(e&2&&!t.includes(' font-style="')?L:"")}var C="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)",pt="var(--_fm)",_="var(--pele-radius,4px)",ut="var(--pele-critical,#e45756)",k=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,G=new RegExp(String.raw`^\s*${k}(?:\s*,\s*${k})*\s*$`,"u");function M(t,e){return t&&G.test(t)?t:e}function N(t,e,i){return`;--_fm:var(--pele-font-mono,${M(i,"monospace")});font:${t}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${M(e,"sans-serif")})`}var K=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),z=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),X=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,A={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function gt(t){if(t.length===0)return A;let e=new Map,i=new Map;for(let o of t){let a=o.indexOf(":");if(a<=0)continue;let c=o.slice(0,a).trim().toLowerCase(),r=o.slice(a+1).replace(/!important/gi,"").trim();r===""||X.test(r)||(K.has(c)&&e.set(c,r),z.has(c)&&i.set(c==="color"?"fill":c,r))}if(e.size===0&&i.size===0)return A;let n="",s="";for(let[o,a]of e)n+=`${o}:${a};`,o!=="fill"&&o!=="fill-opacity"&&(s+=`${o}:${a};`);let d="";for(let[o,a]of i)d+=`${o}:${a};`;let f=i.get("font-weight"),l=i.get("font-size"),p=l&&/^[\d.]+(px)?$/.test(l)?parseFloat(l):void 0;return{shape:n?` style="${b(n)}"`:"",line:s?` style="${b(s)}"`:"",text:d?` style="${b(d)}"`:"",stroke:e.get("stroke"),bold:f==="bold"||f==="bolder"||Number(f)>=600,italic:i.get("font-style")==="italic",fontSize:p!==void 0&&p>0&&p<=200?p:void 0}}var Z=/[^\w-]+/g;function ht(t){let e=t.replace(Z," ").trim();return e===""?"":" "+e}var J=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function mt(t){let e=(t%8+8)%8;return`var(--pele-series-${e+1},${J[e]})`}var E=` rx="${_}"`,Q=/<rect\b[^>]*>/g;function V(t){return t.includes(E)?t.replace(Q,e=>{let i=e.indexOf(E);if(i<0)return e;let n=e.slice(0,i)+e.slice(i+E.length),s=n.indexOf(' style="');if(s>=0)return`${n.slice(0,s+8)}rx:var(--_r);${n.slice(s+8)}`;let d=n.endsWith("/>")?n.length-2:n.length-1;return`${n.slice(0,d)} style="rx:var(--_r)"${n.slice(d)}`}):t}var W=[["--_tw","title"],["--_hw","heading"],["--_w","bold"]];function $t(t,e,i,n,s,d,f){let l=b(s.idPrefix??"pele"),p="",o="";d.accTitle&&(p+=`<title id="${l}-title">${y(d.accTitle)}</title>`,o+=` aria-labelledby="${l}-title"`),d.accDescr&&(p+=`<desc id="${l}-desc">${y(d.accDescr)}</desc>`,o+=` aria-describedby="${l}-desc"`);let a=s.responsive===!1?"":"max-width:100%;height:auto;";f=V(f);let c=f.includes("var(--_r)")?`;--_r:${_}`:"";for(let[r,u]of W)f.includes(`var(${r})`)&&(c+=`;${r}:var(--pele-${u}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${t}" viewBox="0 0 ${e} ${i}" width="${e}" height="${i}" style="${a}${C}${c}${b(N(n,s.fontFamily,s.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${t}"${o}>`+p+f+"</svg>"}var tt=1.5,et=/<br\s*\/?>|\\n|\n/gi,D=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,B=/(fa[bklrs]?):fa-([\w-]+)/g,nt=/[<\\\n*_]|fa[bklrs]?:fa-/,it={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function st(t){let e=t.split(`
2`),i=1/0;for(let n of e){if(n.trim()==="")continue;let s=n.length-n.trimStart().length;s<i&&(i=s)}return i===1/0||i===0?t:e.map(n=>n.slice(Math.min(i,n.length-n.trimStart().length))).join(`
3`)}function R(t,e,i){if(e==="")return;let n=$(e),s=t[t.length-1];s&&s.style===i&&s.icon===void 0?s.text+=n:t.push({text:n,style:i,width:0})}function ot(t,e,i){if(!e.includes(":fa-")){R(t,e,i);return}let n=0;B.lastIndex=0;let s;for(;(s=B.exec(e))!==null;){let d=`${s[1]}:fa-${s[2]}`;if(R(t,e.slice(n,s.index),i),n=s.index+s[0].length,I(d)!=="")t.push({text:"",style:i,icon:d,width:0});else if(e[n]===" ")n++;else if(n===e.length){let f=t[t.length-1];f&&f.icon===void 0&&(f.text=f.text.trimEnd())}}R(t,e.slice(n),i)}function rt(t,e,i,n){let s=n,d=0,f="",l=0,p=e.length,o=()=>{ot(t,f,s),f=""};for(;l<p;){let a=e[l];if(a==="<"){D.lastIndex=l;let c=D.exec(e);if(c&&c.index===l){let r=c[1].toLowerCase(),u=e[l+1]==="/",m=r==="b"||r==="strong"?1:r==="i"||r==="em"?2:0;m&&(o(),s=u?s&~m|n&m:s|m),l+=c[0].length;continue}}else if(i&&(a==="*"||a==="_")){let c=e[l+1]===a,r=c?1:2,u=c?2:1,m=(d&r)===0,g=l>0?e[l-1]:" ",h=l+u<p?e[l+u]:" ",w=m&&h.trim()!==""&&e.indexOf(c?a+a:a,l+u)!==-1,S=!m&&g.trim()!=="",F=a==="_"&&/\w/.test(g)&&/\w/.test(h);if((w||S)&&!F){o(),d=w?d|r:d&~r,s=w?s|r:s&~r|n&r,l+=u;continue}}f+=a,l++}o()}function lt(t,e,i){let n=0;for(let s of t)s.width=s.icon!==void 0?i*1.25:e.width(s.text,i,s.style),n+=s.width;return n}function j(t,e,i,n,s,d){let f=[],l=0,p=()=>{let o=f[f.length-1];if(o&&o.icon===void 0){let a=o.text.trimEnd();if(a!==o.text){o.text=a;let c=e.width(a,i,o.style);l+=c-o.width,o.width=c}}s.push(f),d.push(l),f=[],l=0};for(let o of t){if(o.icon!==void 0){let a=i*1.25;l>0&&l+a>n&&p(),f.push({...o,width:a}),l+=a;continue}for(let a of o.text.match(/\s*\S+\s*|\s+/g)??[]){let c=a;l>0&&l+e.width(c.trimEnd(),i,o.style)>n&&(p(),c=c.trimStart());let r=f[f.length-1];if(r&&r.style===o.style&&r.icon===void 0){r.text+=c,r.width=e.width(r.text,i,r.style),l=0;for(let u of f)l+=u.width}else{let u=e.width(c,i,o.style);f.push({text:c,style:o.style,width:u}),l+=u}}}(f.length>0||s.length===0)&&p()}function _t(t,e,i,n,s,d=0){if(t===void 0||t==="")return it;let f=Math.round(n*tt);if(!nt.test(t)&&!t.includes("&")&&!t.includes("fl")){let c=t.trim(),r=i.width(c,n,d);if(r<=s||!c.includes(" "))return{lines:[[{text:c,style:d,width:r}]],widths:[r],width:r,height:f,size:n,lineHeight:f};let u=[],m=[];j([{text:c,style:d,width:r}],i,n,s,u,m);let g=0;for(let h of m)h>g&&(g=h);return{lines:u,widths:m,width:g,height:u.length*f,size:n,lineHeight:f}}let l=e?st(t.replace(/\r\n?/g,`
4`)).trim():t.trim(),p=[],o=[],a=0;for(let c of l.split(et)){let r=[];rt(r,c.trim(),e,d);let u=lt(r,i,n);u>s?j(r,i,n,s,p,o):(p.push(r),o.push(u))}for(let c of o)c>a&&(a=c);return{lines:p,widths:o,width:a,height:p.length*f,size:n,lineHeight:f}}export{b as a,y as b,x as c,ft as d,T as e,Y as f,q as g,pt as h,_ as i,ut as j,gt as k,ht as l,mt as m,$t as n,_t as o};