Comparing version 0.0.17 to 0.0.18
@@ -1,2 +0,5 @@ | ||
var ie=Object.defineProperty,je=Object.defineProperties,Ke=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertyNames,ve=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ce=(e,r,t)=>r in e?ie(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,H=(e,r)=>{for(var t in r||(r={}))Fe.call(r,t)&&Ce(e,t,r[t]);if(ve)for(var t of ve(r))Qe.call(r,t)&&Ce(e,t,r[t]);return e},Oe=(e,r)=>je(e,qe(r)),et=e=>ie(e,"__esModule",{value:!0});var Ne=(e,r)=>()=>(e&&(r=e(e=0)),r);var tt=(e,r)=>{for(var t in r)ie(e,t,{get:r[t],enumerable:!0})},rt=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Ze(r))!Fe.call(e,s)&&(t||s!=="default")&&ie(e,s,{get:()=>r[s],enumerable:!(i=Ke(r,s))||i.enumerable});return e};var nt=(e=>(r,t)=>e&&e.get(r)||(t=rt(et({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var u=Ne(()=>{});var ke={};tt(ke,{default:()=>it});import*as ot from"yoga-layout-prebuilt";var it,We=Ne(()=>{u();it=ot});u();u();u();var ae;{let e=(We(),nt(ke));e.default?ae=e.default:ae=e}function at(e){ae=e}function V(){return ae}u();u();import{LineBreaker as st}from"css-line-break";import{splitGraphemes as ft}from"text-segmentation";function me(e){let r=typeof e;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function Pe(e){return/^class\s/.test(Function.prototype.toString.call(e))}function ee(e,r){return[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]}function k(e,r,t){let i=r[e];return typeof i=="undefined"?t:i}var Ge=void 0,de=typeof Intl!="undefined"&&"Segmenter"in Intl,lt=de?new Intl.Segmenter(Ge,{granularity:"word"}):null,ut=de?new Intl.Segmenter(Ge,{granularity:"grapheme"}):null,pe=[32,160,4961,65792,65793,4153,4241].map(e=>String.fromCodePoint(e)),ct=e=>{let r=st(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],i;for(;!(i=r.next()).done;)if(i.value){let s=i.value.slice(),o="";for(let n=0;n<s.length;n++){let a=s[n];pe.includes(a)?(o.length&&t.push(o),t.push(a),o=""):o+=a}o.length&&t.push(o)}return t};function se(e,r){return de?r==="word"?[...lt.segment(e)].map(t=>t.segment):[...ut.segment(e)].map(t=>t.segment):r==="word"?ct(e):ft(e)}u();u();var De={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};u();var mt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function ge(e){let r={};for(let t in e)mt.has(t)&&(r[t]=e[t]);return r}u();import{getPropertyName as Me,getStylesForProperty as ht}from"css-to-react-native";import Ue from"parse-css-dimension";import{parseElementStyle as bt}from"css-background-parser";u();import dt from"postcss-value-parser";import pt from"parse-css-dimension";function gt(e,r){try{let t=new pt(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*r};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function he(e,r,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let i=gt(e,r);return i.absolute?{[t?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[t?"xRelative":"yRelative"]:i.relative}:{}}}function be(e,r){if(typeof e=="number")return{xAbsolute:e};let t;try{t=dt(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return t.length===1?he(t[0],r,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),H(H({},he(t[0],r,!0)),he(t[1],r,!1))):{}}var yt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Be=[1,0,0,1,0,0];function xt(e,r){return typeof r=="number"?yt.has(e)?String(r):r+"px":r}function Ye(e,r){if(typeof e=="number")return e;try{let t=new Ue(e);if(t.type==="length")switch(t.unit){case"em":return t.value*r;case"rem":return t.value*16;default:return t.value}else if(t.type==="angle")switch(t.unit){case"deg":return t.value;case"rad":return t.value*180/Math.PI;default:return t.value}}catch{}}function fe(e,r){let t=[];for(let o in e){let n=Me(o);t.push([n,xt(n,e[o])])}let i=t.reduce((o,n)=>{let a=Me(n[0]),f=n[1];return Object.assign(o,ht(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:o}=bt(i);i.backgroundImage=o}let s=i.fontSize||r.fontSize;if(typeof s=="string")try{let o=new Ue(s);switch(o.unit){case"em":s=o.value*r.fontSize;break;case"rem":s=o.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s),i.transformOrigin&&(i.transformOrigin=be(i.transformOrigin,s));for(let o in i){let n=i[o];if(typeof n=="string"){let a=Ye(n,s);typeof a!="undefined"&&(i[o]=a),n=i[o]}if(o==="opacity"&&(n=i[o]=n*r.opacity),o==="transform"){let a=[...Be],f=n;for(let c of f){let b=Object.keys(c)[0],p=c[b],d=typeof p=="string"?Ye(p,s):p,g=[...Be];switch(b){case"translateX":g[4]=d;break;case"translateY":g[5]=d;break;case"scaleX":g[0]=d;break;case"scaleY":g[3]=d;break;case"rotate":let m=d*Math.PI/180,x=Math.cos(m),I=Math.sin(m);g[0]=x,g[1]=I,g[2]=-I,g[3]=x;break;case"skewX":g[2]=Math.tan(d*Math.PI/180);break;case"skewY":g[1]=Math.tan(d*Math.PI/180);break}a=ee(g,a)}i.transform=a}}return i}function ye(e,r,t,i,s){let o=V(),n=H(H(H({},t),fe(De[r],t)),fe(i,t));if(r==="img"){let a=parseInt(s.width),c=parseInt(s.height)/a;n.width||(n.width=a),n.height||(n.height=c*n.width)}return e.setDisplay(k(n.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(k(n.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setAlignItems(k(n.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),e.setAlignSelf(k(n.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setJustifyContent(k(n.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),e.setFlexDirection(k(n.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),e.setFlexWrap(k(n.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&e.setFlexBasis(n.flexBasis),e.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),e.setFlexShrink(typeof n.flexShrink=="undefined"?1:n.flexShrink),typeof n.maxHeight!="undefined"&&e.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&e.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&e.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&e.setMinWidth(n.minWidth),e.setOverflow(k(n.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),e.setMargin(o.EDGE_TOP,n.marginTop||0),e.setMargin(o.EDGE_BOTTOM,n.marginBottom||0),e.setMargin(o.EDGE_LEFT,n.marginLeft||0),e.setMargin(o.EDGE_RIGHT,n.marginRight||0),e.setBorder(o.EDGE_TOP,n.borderWidth||0),e.setBorder(o.EDGE_BOTTOM,n.borderWidth||0),e.setBorder(o.EDGE_LEFT,n.borderWidth||0),e.setBorder(o.EDGE_RIGHT,n.borderWidth||0),e.setPadding(o.EDGE_TOP,n.paddingTop||0),e.setPadding(o.EDGE_BOTTOM,n.paddingBottom||0),e.setPadding(o.EDGE_LEFT,n.paddingLeft||0),e.setPadding(o.EDGE_RIGHT,n.paddingRight||0),e.setPositionType(k(n.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&e.setPosition(o.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&e.setPosition(o.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&e.setPosition(o.EDGE_LEFT,n.left),typeof n.right!="undefined"&&e.setPosition(o.EDGE_RIGHT,n.right),typeof n.height!="undefined"?e.setHeight(n.height):e.setHeightAuto(),typeof n.width!="undefined"?e.setWidth(n.width):e.setWidthAuto(),[n,ge(n)]}u();u();u();function re({left:e,top:r,width:t,height:i},s,o,n){var f,c,b,p;let a;if(o)a=s;else{let d=(c=n==null?void 0:n.xAbsolute)!=null?c:((f=n==null?void 0:n.xRelative)!=null?f:50)*t/100,g=(p=n==null?void 0:n.yAbsolute)!=null?p:((b=n==null?void 0:n.yRelative)!=null?b:50)*i/100,m=e+d,x=r+g;a=ee([1,0,0,1,m,x],ee(s,[1,0,0,1,-m,-x])),s.__parent&&(a=ee(s.__parent,a)),s.splice(0,6,...a)}return`matrix(${a.map(d=>d.toFixed(2)).join(",")})`}function Xe({left:e,top:r,width:t,height:i,isInheritingTransform:s},o){let n="",a=1;return o.transform&&(n=re({left:e,top:r,width:t,height:i},o.transform,s,o.transformOrigin)),o.opacity&&(a=+o.opacity),{matrix:n,opacity:a}}function xe({id:e,content:r,filter:t,left:i,top:s,width:o,height:n,matrix:a,opacity:f,image:c,debug:b},p){let d="";return b&&(d=`<rect x="${i}" y="${s}" width="${o}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),c?`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<image href="${c}" x="${i}" y="${s}" width="${o}" height="${n}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${t?"</g>":""}${d}`:`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<text x="${i}" y="${s}" width="${o}" height="${n}" fill="${p.color}" font-weight="${p.fontWeight}" font-style="${p.fontStyle}" font-size="${p.fontSize}" font-family="${p.fontFamily}" ${p.letterSpacing?`letter-spacing="${p.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${r}</text>${t?"</g>":""}${d}`}u();function Z({id:e,width:r,height:t},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-s,0),n=Math.max(i.shadowOffset.width+s+r,r),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+t,t);return`<defs><filter id="satori_s-${e}" x="${o/r*100}%" y="${a/t*100}%" width="${(n-o)/r*100}%" height="${(f-a)/t*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var $e=void 0;function*Ee(e,r){let t=V(),{parentStyle:i,parent:s,font:o,id:n,isInheritingTransform:a,debug:f,embedFont:c,graphemeImages:b}=r;i.textTransform==="uppercase"?e=e.toLocaleUpperCase($e):i.textTransform==="lowercase"?e=e.toLocaleLowerCase($e):i.textTransform==="capitalize"&&(e=se(e,"word").map(S=>se(S,"grapheme").map((L,M)=>M===0?L.toLocaleUpperCase($e):L).join("")).join(""));let p=k(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),d=se(e,p),g=t.Node.create();g.setAlignItems(t.ALIGN_BASELINE),i.textAlign==="left"?g.setJustifyContent(t.JUSTIFY_FLEX_START):i.textAlign==="center"?g.setJustifyContent(t.JUSTIFY_CENTER):i.textAlign==="right"?g.setJustifyContent(t.JUSTIFY_FLEX_END):i.textAlign==="justify"&&g.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),s.insertChild(g,s.getChildCount());let m=o.getFont(i),x=m.ascender/m.unitsPerEm*i.fontSize,I=-(m.descender/m.unitsPerEm)*i.fontSize,_=x+I,h=_*1.2,E=(i.fontSize-_)/2,{textAlign:v}=i,P=[],U=[],w=[],G=new Map,K=S=>{if(G.has(S))return G.get(S);let L=o.measure(m,S,i);return G.set(S,L),L};g.setMeasureFunc(S=>{let L=0,M="",B=0,F=0,Y=0,te=-1;P=[],U=[0];for(let X=0;X<d.length;X++){let z=d[X];if(pe.includes(z))M+=z,B=K(M),w[X]=null;else{let j=b&&b[z]?i.fontSize:K(z);F||(M="",B=0);let we=B||",.!?:-@)>]}%#".indexOf(z[0])<0,Ae=!F||!!B;we&&F+B+j>S?(P.push(F),L++,F=j,U.push(1),te=-1):(F+=B+j,Ae&&U[U.length-1]++),M="",B=0,Ae&&te++,Y=Math.max(Y,F),w[X]={y:L*h-E,x:F-j,width:j,line:L,lineIndex:te}}}return F&&(L++,P.push(F)),L>1&&(Y=S),{width:Y,height:L*h}});let[q,W]=yield,C="",{left:D,top:A,width:O,height:Q}=g.getComputedLayout(),l=q+D,y=W+A,{matrix:$,opacity:N}=Xe({left:D,top:A,width:O,height:Q,isInheritingTransform:a},i),J="";i.textShadowOffset&&(J=Z({width:O,height:Q,id:n},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let ce="";for(let S=0;S<d.length;S++){if(!w[S])continue;let L=d[S],M=null,B=null,F=w[S].y,Y=w[S].x,te=w[S].width,X=w[S].line;if(P.length>1){let z=O-P[X];if(v==="right"||v==="end")Y+=z;else if(v==="center")Y+=z/2;else if(v==="justify"&&X<P.length-1){let j=U[X];Y+=(j>1?z/(j-1):0)*w[S].lineIndex}}b&&b[L]?B=b[L]:c?M=o.getSVG(m,L,Oe(H({},i),{left:l+Y,top:y+F+x,letterSpacing:i.letterSpacing})):F+=x,M?ce+=M+" ":C+=xe({content:L,filter:J,id:n,left:l+Y,top:y+F,width:te,height:h,matrix:$,opacity:N,image:B,debug:f},i)}if(ce){let S="";f&&(S=`<rect x="${l}" y="${y}" width="${O}" height="${Q}" fill="transparent" stroke="#575eff" stroke-width="1" ${$?`transform="${$}"`:""}></rect>`),C+=`${J?`${J}<g filter="url(#satori_s-${n})">`:""}<path fill="${i.color}" ${$?`transform="${$}"`:""} ${N!==1?`opacity="${N}"`:""} d="${ce}"></path>${J?"</g>":""}${S}`}return C}u();u();import $t from"parse-css-dimension";u();var Se=Se||{};Se.parse=function(){var e={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function t(l){var y=new Error(r+": "+l);throw y.source=r,y}function i(){var l=s();return r.length>0&&t("Invalid input not EOF"),l}function s(){return E(o)}function o(){return n("linear-gradient",e.linearGradient,f)||n("repeating-linear-gradient",e.repeatingLinearGradient,f)||n("radial-gradient",e.radialGradient,p)||n("repeating-radial-gradient",e.repeatingRadialGradient,p)}function n(l,y,$){return a(y,function(N){var J=$();return J&&(O(e.comma)||t("Missing comma before color stops")),{type:l,orientation:J,colorStops:E(v)}})}function a(l,y){var $=O(l);if($){O(e.startCall)||t("Missing (");var N=y($);return O(e.endCall)||t("Missing )"),N}}function f(){return c()||b()}function c(){return A("directional",e.sideOrCorner,1)}function b(){return A("angular",e.angleValue,1)}function p(){var l,y=d(),$;return y&&(l=[],l.push(y),$=r,O(e.comma)&&(y=d(),y?l.push(y):r=$)),l}function d(){var l=g()||m();if(l)l.at=I();else{var y=x();if(y){l=y;var $=I();$&&(l.at=$)}else{var N=_();N&&(l={type:"default-radial",at:N})}}return l}function g(){var l=A("shape",/^(circle)/i,0);return l&&(l.style=D()||x()),l}function m(){var l=A("shape",/^(ellipse)/i,0);return l&&(l.style=W()||x()),l}function x(){return A("extent-keyword",e.extentKeywords,1)}function I(){if(A("position",/^at/,0)){var l=_();return l||t("Missing positioning value"),l}}function _(){var l=h();if(l.x||l.y)return{type:"position",value:l}}function h(){return{x:W(),y:W()}}function E(l){var y=l(),$=[];if(y)for($.push(y);O(e.comma);)y=l(),y?$.push(y):t("One extra comma");return $}function v(){var l=P();return l||t("Expected color definition"),l.length=W(),l}function P(){return w()||K()||G()||U()}function U(){return A("literal",e.literalColor,0)}function w(){return A("hex",e.hexColor,1)}function G(){return a(e.rgbColor,function(){return{type:"rgb",value:E(q)}})}function K(){return a(e.rgbaColor,function(){return{type:"rgba",value:E(q)}})}function q(){return O(e.number)[1]}function W(){return A("%",e.percentageValue,1)||C()||D()}function C(){return A("position-keyword",e.positionKeywords,1)}function D(){return A("px",e.pixelValue,1)||A("em",e.emValue,1)}function A(l,y,$){var N=O(y);if(N)return{type:l,value:N[$]}}function O(l){var y,$;return $=/^[\n\r\t\s]+/.exec(r),$&&Q($[0].length),y=l.exec(r),y&&Q(y[0].length),y}function Q(l){r=r.substr(l)}return function(l){return r=l.toString(),i()}}();var ze=Se;function Et(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function St(e,r){return typeof e=="string"&&e.endsWith("%")?r*parseFloat(e)/100:+e}function He(e,{x:r,y:t,defaultX:i,defaultY:s}){return(e?e.split(" ").map(o=>{try{let n=new $t(o);return n.type==="length"||n.type==="number"?n.value:n.value+n.unit}catch{return null}}).filter(o=>o!==null):[i,s]).map((o,n)=>St(o,[r,t][n]))}function Re({id:e,width:r,height:t},{image:i,size:s,position:o}){let n=He(s,{x:r,y:t,defaultX:r,defaultY:t}),a=He(o,{x:r,y:t,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=ze.parse(i)[0],c,b,p,d;if(f.orientation.type==="directional")[c,b,p,d]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let h=+f.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(h),v=Math.sin(h);c=0,b=0,p=E,d=v,p<0&&(c-=p,p=0),d<0&&(b-=d,d=0)}let g=r,m=[];for(let h of f.colorStops){let E=Et(h);if(!m.length&&(m.push({offset:0,color:E}),typeof h.length=="undefined"||h.length.value==="0"))continue;let v=typeof h.length=="undefined"?void 0:h.length.type==="%"?h.length.value/100:h.length.value/g;m.push({offset:v,color:E})}m.length||m.push({offset:0,color:"transparent"});let x=m[m.length-1];x.offset!==1&&(typeof x.offset=="undefined"?x.offset=1:m.push({offset:1,color:x.color}));let I=0,_=1;for(let h=0;h<m.length;h++)if(typeof m[h].offset=="undefined"){for(_<h&&(_=h);typeof m[_].offset=="undefined";)_++;m[h].offset=(m[_].offset-m[I].offset)/(_-I)*(h-I)+m[I].offset}else I=h;return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${c}" y1="${b}" x2="${p}" y2="${d}">${m.map(h=>`<stop offset="${h.offset*100}%" stop-color="${h.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${e}`,`<pattern id="satori_bi${e}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${n[0]}" height="${n[1]}"><image href="${f}" x="0" y="0" width="${n[0]}" height="${n[1]}"/></pattern>`]}}u();function le(e,r,t){return t<e+r&&(t/2<e&&t/2<r?e=r=t/2:t/2<e?e=t-r:t/2<r&&(r=t-e)),[e,r]}function ne({left:e,top:r,width:t,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:n,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return o=Math.min(o||0,t,i),n=Math.min(n||0,t,i),a=Math.min(a||0,t,i),f=Math.min(f||0,t,i),!o&&!n&&!a&&!f?"":([o,n]=le(o,n,t),[o,a]=le(o,a,i),[n,f]=le(n,f,i),[a,f]=le(a,f,t),`M${e+o},${r} h${t-o-n} a${n},${n} 0 0 1 ${n},${n} v${i-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-t} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function Te({id:e,left:r,top:t,width:i,height:s,isInheritingTransform:o,debug:n},a){if(a.display==="none")return"";let f="rect",c="transparent",b=0,p="",d="",g=[],m=1,x="";if(a.backgroundColor&&g.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,c=a.borderColor),a.opacity&&(m=+a.opacity),a.transform&&(p=re({left:r,top:t,width:i,height:s},a.transform,o,a.transformOrigin)),a.backgroundImage){let h=a.backgroundImage.map((E,v)=>Re({id:e+"_"+v,width:i,height:s},E)).filter(Boolean);for(let E of h)d+=E[1],g.push(`url(#${E[0]})`)}let I=ne({left:r,top:t,width:i,height:s},a);I&&(f="path");let _=Z({width:i,height:s,id:e},a);return g.length||g.push("transparent"),n&&(x=`<rect x="${r}" y="${t}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${d?`<defs>${d}</defs>`:""}${_?`${_}<g filter="url(#satori_s-${e})">`:""}${m!==1?`<g opacity="${m}">`:""}${g.map((h,E)=>h==="transparent"&&!(E===g.length-1&&b)?"":`<${f} x="${r}" y="${t}" width="${i}" height="${s}" fill="${h}" ${E===g.length-1&&b?`stroke="${c}" stroke-width="${b}"`:""} ${I?`d="${I}"`:""} ${p?`transform="${p}"`:""}></${f}>`).join("")}${m!==1?"</g>":""}${_?"</g>":""}${x}`}u();function _e({id:e,left:r,top:t,width:i,height:s,src:o,debug:n},a){if(a.display==="none")return"";let f="",c=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",p=ne({left:r,top:t,width:i,height:s},a);p&&(f=`<clipPath id="satori_c-${e}"><path x="${r}" y="${t}" width="${i}" height="${s}" d="${p}"></path></clipPath>`),a.opacity&&(c=+a.opacity);let d=Z({width:i,height:s,id:e},a);return`${d}${d?`<g filter="url(#satori_s-${e})">`:""}${f}<image href="${o}" x="${r}" y="${t}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${f?`clip-path="url(#satori_c-${e})"`:""} ${c!==1?`opacity="${c}"`:""}></image>${d?"</g>":""}`}function*oe(e,r){let t=V(),{id:i,inheritedStyle:s,parent:o,font:n,debug:a,embedFont:f=!0,graphemeImages:c}=r;if(e===null||typeof e=="undefined")return yield,"";if(!me(e)||typeof e.type=="function"){let C;if(!me(e))C=Ee(String(e),r);else{if(Pe(e.type))throw new Error("Class component is not supported.");C=oe(e.type(e.props),r)}C.next();let D=yield;return C.next(D).value}let{type:b,props:p}=e,{style:d,children:g}=p,m=t.Node.create();o.insertChild(m,o.getChildCount());let[x,I]=ye(m,b,s,d,p),_=x.transform===s.transform;_||(x.transform.__parent=s.transform);let h=typeof g=="undefined"?[]:[].concat(g),E=[],v=0;for(let C of h){let D=oe(C,{id:i*h.length+ ++v,parentStyle:x,inheritedStyle:I,isInheritingTransform:!0,parent:m,font:n,embedFont:f,debug:a,graphemeImages:c});D.next(),E.push(D)}let[P,U]=yield;x.position==="absolute"&&m.calculateLayout();let{left:w,top:G,width:K,height:q}=m.getComputedLayout();w+=P,G+=U;let W="";b==="img"?W=_e({id:i,left:w,top:G,width:K,height:q,src:p.src,isInheritingTransform:_,debug:a},x):W=Te({id:i,left:w,top:G,width:K,height:q,isInheritingTransform:_,debug:a},x);for(let C of E)W+=C.next([w,G]).value;return W}u();import Ve from"@shuding/opentype.js";var ue=class{constructor(r){this.fonts=new Map;for(let t of r){let i=t.data,s="buffer"in i?Ve.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Ve.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(t.name)||this.fonts.set(t.name,[]),this.fonts.get(t.name).push([s,t.weight,t.style])}}get({name:r,weight:t,style:i}){if(!this.fonts.has(r))return this.defaultFont;t==="normal"&&(t=400),t==="bold"&&(t=700);let s=[...this.fonts.get(r)];return s.sort(([o,n,a],[f,c,b])=>{if(n!==c)return n?!c||n===t?-1:c===t?1:t===400&&n===500||t===500&&n===400?-1:t===400&&c===500||t===500&&c===400?1:t<400?n<t&&c<t?c-n:n<t?-1:c<t?1:n-c:t<n&&t<c?n-c:t<n?-1:t<c?1:c-n:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:r,fontWeight:t=400,fontStyle:i="normal"}){return this.get({name:r,weight:t,style:i})}measure(r,t,{fontSize:i,letterSpacing:s=0}){return r.getAdvanceWidth(t,i,{letterSpacing:s/i})}getSVG(r,t,{fontSize:i,top:s,left:o,letterSpacing:n=0}){return r.getPath(t,o,s,i,{letterSpacing:n/i}).toPathData(1)}};u();function Ie({width:e,height:r,content:t},i){return`<svg width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}var Le=new WeakMap;function Je(e,r){let t=V();if(!t)throw new Error("Satori is not initialized.");let i;Le.has(r.fonts)?i=Le.get(r.fonts):Le.set(r.fonts,i=new ue(r.fonts));let s=t.Node.create();s.setWidth(r.width),s.setHeight(r.height),s.setFlexDirection(t.FLEX_DIRECTION_ROW),s.setFlexWrap(t.WRAP_WRAP),s.setAlignContent(t.ALIGN_AUTO),s.setAlignItems(t.ALIGN_FLEX_START),s.setJustifyContent(t.JUSTIFY_FLEX_START);let o=oe(e,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});o.next(),s.calculateLayout(r.width,r.height,t.DIRECTION_LTR);let n=o.next([0,0]).value;return Ie({width:r.width,height:r.height,content:n})}export{Je as default,at as init}; | ||
var xt=Object.defineProperty,St=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var rt=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var nt=(t,r,e)=>r in t?xt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,D=(t,r)=>{for(var e in r||(r={}))Et.call(r,e)&&nt(t,e,r[e]);if(rt)for(var e of rt(r))Rt.call(r,e)&&nt(t,e,r[e]);return t},te=(t,r)=>St(t,_t(r));import*as Tt from"yoga-layout-prebuilt";var it=Tt;var ve;ve=it.default;function wt(t){ve=t}function Q(){return ve}import{LineBreaker as It}from"css-line-break";import{splitGraphemes as Lt}from"text-segmentation";function ke(t){let r=typeof t;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function ot(t){return/^class\s/.test(Function.prototype.toString.call(t))}function fe(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}function H(t,r,e){let o=r[t];return typeof o=="undefined"?e:o}var at=void 0,Ae=typeof Intl!="undefined"&&"Segmenter"in Intl&&process.env.NODE_ENV!=="test",Ct=Ae?new Intl.Segmenter(at,{granularity:"word"}):null,vt=Ae?new Intl.Segmenter(at,{granularity:"grapheme"}):null,de=[32,160,4961,65792,65793,4153,4241,10].map(t=>String.fromCodePoint(t)),kt=t=>{let r=It(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],o;for(;!(o=r.next()).done;)if(o.value){let a=o.value.slice(),i="";for(let n=0;n<a.length;n++){let s=a[n];de.includes(s)?(i.length&&e.push(i),e.push(s),i=""):i+=s}i.length&&e.push(i)}return e};function ce(t,r){return Ae?r==="word"?[...Ct.segment(t)].map(e=>e.segment):[...vt.segment(t)].map(e=>e.segment):r==="word"?kt(t):Lt(t)}function y(t,r,e){let o="";for(let[a,i]of Object.entries(r))typeof i!="undefined"&&(o+=` ${a}="${i}"`);return e?`<${t}${o}>${e}</${t}>`:`<${t}${o}/>`}var st={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var At=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textAlign","textTransform","textShadowOffset","textShadowColor","textShadowRadius","textDecorationLine","textDecorationStyle","textDecorationColor","whiteSpace","transform","wordBreak","opacity","_viewportWidth","_viewportHeight","_inheritedClipPathId","_inheritedBackgroundClipTextPath"]);function Pe(t){let r={};for(let e in t)At.has(e)&&(r[e]=t[e]);return r}import{getPropertyName as Ft,getStylesForProperty as $t}from"css-to-react-native";import ut from"parse-css-dimension";import{parseElementStyle as Nt}from"css-background-parser";import Pt from"postcss-value-parser";import Wt from"parse-css-dimension";function Ot(t,r){try{let e=new Wt(t);switch(e.unit){case"px":return{absolute:e.value};case"em":return{absolute:e.value*r};case"rem":return{absolute:e.value*16};case"%":return{relative:e.value};default:return{}}}catch{return{}}}function We(t,r,e){switch(t){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let o=Ot(t,r);return o.absolute?{[e?"xAbsolute":"yAbsolute"]:o.absolute}:o.relative?{[e?"xRelative":"yRelative"]:o.relative}:{}}}function Oe(t,r){if(typeof t=="number")return{xAbsolute:t};let e;try{e=Pt(t).nodes.filter(o=>o.type==="word").map(o=>o.value)}catch{return{}}return e.length===1?We(e[0],r,!0):e.length===2?((e[0]==="top"||e[0]==="bottom"||e[1]==="left"||e[1]==="right")&&e.reverse(),D(D({},We(e[0],r,!0)),We(e[1],r,!1))):{}}var Mt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Gt=new Set(["lineHeight"]),ft=[1,0,0,1,0,0];function Dt(t,r,e,o){return t==="border"&&!e.includes(r.borderColor)?r.borderColor=o:t==="textDecoration"&&!e.includes(r.textDecorationColor)&&(r.textDecorationColor=o),r}function lt(t,r){return typeof r=="number"?Mt.has(t)?Gt.has(t)?r:String(r):r+"px":r}function Fe(t,r,e,{percentage:o}={percentage:!1}){if(typeof t=="number")return t;try{let a=new ut(t);if(a.type==="length")switch(a.unit){case"em":return a.value*r;case"rem":return a.value*16;case"vw":return~~(a.value*e._viewportWidth/100);case"vh":return~~(a.value*e._viewportHeight/100);default:return a.value}else if(a.type==="angle")switch(a.unit){case"deg":return a.value;case"rad":return a.value*180/Math.PI;default:return a.value}else if(a.type==="percentage"&&o)return a.value/100*r}catch{}}function Ee(t,r){let e={};for(let a in t){if(a.startsWith("_")){e[a]=t[a];continue}let i=Ft(a);Object.assign(e,i==="lineHeight"?{lineHeight:lt(i,t[a])}:Dt(i,$t(i,lt(i,t[a]),!0),t[a],t.color||r.color))}if(e.backgroundImage){let{backgrounds:a}=Nt(e);e.backgroundImage=a}let o=e.fontSize||r.fontSize;if(typeof o=="string")try{let a=new ut(o);switch(a.unit){case"em":o=a.value*r.fontSize;break;case"rem":o=a.value*16;break}}catch{o=16}typeof e.fontSize!="undefined"&&(e.fontSize=o),e.transformOrigin&&(e.transformOrigin=Oe(e.transformOrigin,o));for(let a in e){let i=e[a];if(a==="lineHeight")typeof i=="string"&&(i=e[a]=Fe(i,o,r,{percentage:!0})/o);else if(typeof i=="string"){let n=Fe(i,o,r);typeof n!="undefined"&&(e[a]=n),i=e[a]}if(a==="opacity"&&(i=e[a]=i*r.opacity),a==="transform"){let n=[...ft],s=i;for(let f of s){let p=Object.keys(f)[0],g=f[p],u=typeof g=="string"?Fe(g,o,r):g,m=[...ft];switch(p){case"translateX":m[4]=u;break;case"translateY":m[5]=u;break;case"scale":m[0]=u,m[3]=u;break;case"scaleX":m[0]=u;break;case"scaleY":m[3]=u;break;case"rotate":let h=u*Math.PI/180,d=Math.cos(h),c=Math.sin(h);m[0]=d,m[1]=c,m[2]=-c,m[3]=d;break;case"skewX":m[2]=Math.tan(u*Math.PI/180);break;case"skewY":m[1]=Math.tan(u*Math.PI/180);break}n=fe(m,n)}e.transform=n}}return e}function $e(t,r,e,o,a){let i=Q(),n=D(D(D({},e),Ee(st[r],e)),Ee(o,e));if(r==="img"){let s=parseInt(a.width),p=parseInt(a.height)/s;n.width||(n.width=s),n.height||(n.height=p*n.width)}return t.setDisplay(H(n.display,{flex:i.DISPLAY_FLEX,none:i.DISPLAY_NONE},i.DISPLAY_FLEX)),t.setAlignContent(H(n.alignContent,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,"space-between":i.ALIGN_SPACE_BETWEEN,"space-around":i.ALIGN_SPACE_AROUND,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setAlignItems(H(n.alignItems,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_FLEX_START)),t.setAlignSelf(H(n.alignSelf,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setJustifyContent(H(n.justifyContent,{center:i.JUSTIFY_CENTER,"flex-start":i.JUSTIFY_FLEX_START,"flex-end":i.JUSTIFY_FLEX_END,"space-between":i.JUSTIFY_SPACE_BETWEEN,"space-around":i.JUSTIFY_SPACE_AROUND},i.JUSTIFY_FLEX_START)),t.setFlexDirection(H(n.flexDirection,{row:i.FLEX_DIRECTION_ROW,column:i.FLEX_DIRECTION_COLUMN,"row-reverse":i.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":i.FLEX_DIRECTION_COLUMN_REVERSE},i.FLEX_DIRECTION_ROW)),t.setFlexWrap(H(n.flexWrap,{wrap:i.WRAP_WRAP,nowrap:i.WRAP_NO_WRAP,"wrap-reverse":i.WRAP_WRAP_REVERSE},i.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&t.setFlexBasis(n.flexBasis),t.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),t.setFlexShrink(typeof n.flexShrink=="undefined"?0:n.flexShrink),typeof n.maxHeight!="undefined"&&t.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&t.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&t.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&t.setMinWidth(n.minWidth),t.setOverflow(H(n.overflow,{visible:i.OVERFLOW_VISIBLE,hidden:i.OVERFLOW_HIDDEN},i.OVERFLOW_VISIBLE)),t.setMargin(i.EDGE_TOP,n.marginTop||0),t.setMargin(i.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(i.EDGE_LEFT,n.marginLeft||0),t.setMargin(i.EDGE_RIGHT,n.marginRight||0),t.setBorder(i.EDGE_TOP,n.borderWidth||0),t.setBorder(i.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(i.EDGE_LEFT,n.borderWidth||0),t.setBorder(i.EDGE_RIGHT,n.borderWidth||0),t.setPadding(i.EDGE_TOP,n.paddingTop||0),t.setPadding(i.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(i.EDGE_LEFT,n.paddingLeft||0),t.setPadding(i.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(H(n.position,{absolute:i.POSITION_TYPE_ABSOLUTE,relative:i.POSITION_TYPE_RELATIVE},i.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(i.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(i.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(i.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(i.EDGE_RIGHT,n.right),typeof n.height!="undefined"?t.setHeight(n.height):t.setHeightAuto(),typeof n.width!="undefined"?t.setWidth(n.width):t.setWidthAuto(),[n,Pe(n)]}function re({left:t,top:r,width:e,height:o},a,i,n){var f,p,g,u;let s;if(i)s=a;else{let m=(p=n==null?void 0:n.xAbsolute)!=null?p:((f=n==null?void 0:n.xRelative)!=null?f:50)*e/100,h=(u=n==null?void 0:n.yAbsolute)!=null?u:((g=n==null?void 0:n.yRelative)!=null?g:50)*o/100,d=t+m,c=r+h;s=fe([1,0,0,1,d,c],fe(a,[1,0,0,1,-d,-c])),a.__parent&&(s=fe(a.__parent,s)),a.splice(0,6,...s)}return`matrix(${s.map(m=>m.toFixed(2)).join(",")})`}function dt({left:t,top:r,width:e,height:o,isInheritingTransform:a},i){let n="",s=1;return i.transform&&(n=re({left:t,top:r,width:e,height:o},i.transform,a,i.transformOrigin)),i.opacity&&(s=+i.opacity),{matrix:n,opacity:s}}function Ne({id:t,content:r,filter:e,left:o,top:a,width:i,height:n,matrix:s,opacity:f,image:p,clipPathId:g,debug:u,shape:m,decorationShape:h},d){let c="";if(u&&(c=y("rect",{x:o,y:a,width:i,height:.5,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0})),p){let x={href:p,x:o,y:a,width:i,height:n,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0};return[(e?`${e}<g filter="url(#satori_s-${t})">`:"")+y("image",te(D({},x),{opacity:f!==1?f:void 0}))+(h||"")+(e?"</g>":"")+c,""]}let R={x:o,y:a,width:i,height:n,"font-weight":d.fontWeight,"font-style":d.fontStyle,"font-size":d.fontSize,"font-family":d.fontFamily,"letter-spacing":d.letterSpacing||void 0,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0};return[(e?`${e}<g filter="url(#satori_s-${t})">`:"")+y("text",te(D({},R),{fill:d.color,opacity:f!==1?f:void 0}),r)+(h||"")+(e?"</g>":"")+c,m?y("text",R,r):""]}function ne({id:t,width:r,height:e},o){if(!o.shadowColor||!o.shadowOffset||typeof o.shadowRadius=="undefined")return"";let a=o.shadowRadius*o.shadowRadius/4,i=Math.min(o.shadowOffset.width-a,0),n=Math.max(o.shadowOffset.width+a+r,r),s=Math.min(o.shadowOffset.height-a,0),f=Math.max(o.shadowOffset.height+a+e,e);return`<defs><filter id="satori_s-${t}" x="${i/r*100}%" y="${s/e*100}%" width="${(n-i)/r*100}%" height="${(f-s)/e*100}%"><feDropShadow dx="${o.shadowOffset.width}" dy="${o.shadowOffset.height}" stdDeviation="${o.shadowRadius/2}" flood-color="${o.shadowColor}" flood-opacity="1"/></filter></defs>`}function Me({width:t,left:r,top:e,ascender:o,clipPathId:a},i){let{textDecorationColor:n,textDecorationStyle:s,textDecorationLine:f,fontSize:p}=i;if(!f||f==="none")return"";let g=Math.max(1,p*.1),u=f==="line-through"?e+o*.75:f==="underline"?e+o*1.25:e,m=s==="dashed"?`${g*1.2} ${g*2}`:s==="dotted"?`0 ${g*2}`:void 0;return y("line",{x1:r,y1:u,x2:r+t,y2:u,stroke:n,"stroke-width":g,"stroke-dasharray":m,"stroke-linecap":s==="dotted"?"round":"square","clip-path":a?`url(#${a})`:void 0})}var Ge=void 0;function*De(t,r){var Qe;let e=Q(),{parentStyle:o,inheritedStyle:a,parent:i,font:n,id:s,isInheritingTransform:f,debug:p,embedFont:g,graphemeImages:u}=r;o.textTransform==="uppercase"?t=t.toLocaleUpperCase(Ge):o.textTransform==="lowercase"?t=t.toLocaleLowerCase(Ge):o.textTransform==="capitalize"&&(t=ce(t,"word").map(_=>ce(_,"grapheme").map((E,N)=>N===0?E.toLocaleUpperCase(Ge):E).join("")).join(""));let m=H(o.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),h=ce(t,m),d=e.Node.create();d.setAlignItems(e.ALIGN_BASELINE),o.textAlign==="left"?d.setJustifyContent(e.JUSTIFY_FLEX_START):o.textAlign==="center"?d.setJustifyContent(e.JUSTIFY_CENTER):o.textAlign==="right"?d.setJustifyContent(e.JUSTIFY_FLEX_END):o.textAlign==="justify"&&d.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),i.insertChild(d,i.getChildCount());let{textAlign:c,textOverflow:R,whiteSpace:x,lineHeight:Y,_inheritedBackgroundClipTextPath:L}=o,O=n.getFont(o),F=o.fontSize,P=O.ascender/O.unitsPerEm*F,v=-(O.descender/O.unitsPerEm)*F,C=P+v,M=Y/1.2*F-C,W=C*Y/1.2,j=(o.fontSize-C)/2,G=[],U=[],S=[],$=new Map,z=_=>{if($.has(_))return $.get(_);let E=n.measure(O,_,o);return $.set(_,E),E},l=0,b="",T=0;for(let _ of h){let E=!1,N=u&&u[_];x==="pre"?E=_[0]===` | ||
`:x!=="nowrap"&&(N||de.includes(_[0]))&&(E=!0),E?(x==="nowrap"?T+=z(b)+o.fontSize:(l=Math.max(l,z(b)),N&&(l=Math.max(l,o.fontSize))),b=""):(!de.includes(_[0])||!b)&&(b+=_===` | ||
`?" ":_)}l=Math.max(l,z(b)+T);let X=i.getMinWidth(),ie=i.getMaxWidth(),gt=i.getWidth();isNaN(gt.value)&&(isNaN(X.value)||X.unit===1&&X.value>l)&&(isNaN(ie.value)||ie.unit===1&&(l=Math.min(l,ie.value)),i.setMinWidth(l)),typeof o.flexShrink=="undefined"&&i.setFlexShrink(1);let je=["pre-wrap","pre"].includes(x);d.setMeasureFunc(_=>{let E=0,N="",V=0,B=0,K=0,q=-1;G=[],U=[0];for(let Z=0;Z<h.length;Z++){let k=h[Z];if(!je&&de.includes(k[0]))N||(N=" "),V=z(N),S[Z]=null;else{let ae=je&&k===` | ||
`,A=ae?0:u&&u[k]?o.fontSize:z(k);B||(N="",V=0);let J=V||",.!?:-@)>]}%#".indexOf(k[0])<0,se=!B||!!V;ae||Z&&J&&B+V+A>_&&x!=="nowrap"&&x!=="pre"?(G.push(B),E++,B=A,U.push(1),q=-1,ae||(K=Math.max(K,_))):(B+=V+A,se&&U[U.length-1]++),N="",V=0,se&&q++,K=Math.max(K,B),S[Z]={y:E*W-j,x:B-A,width:A,line:E,lineIndex:q}}}return B&&(E++,G.push(B)),{width:K,height:E*W}});let[ht,bt]=yield,we="",ge="",oe=a._inheritedClipPathId,{left:Ke,top:qe,width:le,height:Ie}=d.getComputedLayout(),Le=i.getComputedWidth()-i.getComputedPadding(e.EDGE_LEFT)-i.getComputedPadding(e.EDGE_RIGHT)-i.getComputedBorder(e.EDGE_LEFT)-i.getComputedBorder(e.EDGE_RIGHT),he=ht+Ke,be=bt+qe,{matrix:ee,opacity:ye}=dt({left:Ke,top:qe,width:le,height:Ie,isInheritingTransform:f},o),ue="";o.textShadowOffset&&(ue=ne({width:le,height:Ie,id:s},{shadowColor:o.textShadowColor,shadowOffset:o.textShadowOffset,shadowRadius:o.textShadowRadius}));let xe="",Se="",Ce=-1,Ze=R==="ellipsis"?z("\u2026"):0,yt=R==="ellipsis"?z(" "):0,_e={};for(let _=0;_<h.length;_++){if(!S[_])continue;let E=S[_],N=h[_],V=null,B=u?u[N]:null,K=E.y,q=E.x,Z=E.width,k=E.line;if(k===Ce)continue;let ae=!1;if(G.length>1){let A=le-G[k];if(c==="right"||c==="end")q+=A;else if(c==="center")q+=A/2;else if(c==="justify"&&k<G.length-1){let J=U[k];q+=(J>1?A/(J-1):0)*E.lineIndex,ae=!0}}if(_e[k]||(_e[k]=[q,ae?le:G[k]]),R==="ellipsis"&&G[k]>Le&&E.x+Z+Ze+yt>Le){let A=ce(N,"grapheme"),J="",se=0;for(let et of A){let tt=E.x+z(J+et);if(J&&tt+Ze>Le)break;J+=et,se=tt}N=J+"\u2026",Ce=k,_e[k][1]=se}if(B?K+=j:g?V=n.getSVG(O,N,te(D({},o),{left:he+q,top:be+K+P+M/2,letterSpacing:o.letterSpacing})):K+=P+M/2,o.textDecorationLine&&(k!==((Qe=S[_+1])==null?void 0:Qe.line)||Ce===k)){let A=_e[k];A&&!A[2]&&(xe+=Me({left:he+A[0],top:be+W*+k,width:A[1],ascender:P+M/2,clipPathId:oe},o),A[2]=1)}if(V)Se+=V+" ";else{let[A,J]=Ne({content:N,filter:ue,id:s,left:he+q,top:be+K,width:Z,height:W,matrix:ee,opacity:ye,image:B,clipPathId:oe,debug:p,shape:!!L,decorationShape:xe},o);we+=A,ge+=J,xe=""}}if(Se){let _="";p&&(_=y("rect",{x:he,y:be,width:le,height:Ie,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:ee||void 0,"clip-path":oe?`url(#${oe})`:void 0}));let E=o.color!=="transparent"&&ye!==0?y("path",{fill:o.color,d:Se,transform:ee||void 0,opacity:ye!==1?ye:void 0,"clip-path":oe?`url(#${oe})`:void 0}):"";L&&(ge=y("path",{d:Se,transform:ee||void 0})),we+=(ue?`${ue}<g filter="url(#satori_s-${s})">`:"")+E+xe+(ue?"</g>":"")+_}return ge&&(o._inheritedBackgroundClipTextPath.value+=ge),we}import Bt from"parse-css-dimension";var Be=Be||{};Be.parse=function(){var t={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function e(l){var b=new Error(r+": "+l);throw b.source=r,b}function o(){var l=a();return r.length>0&&e("Invalid input not EOF"),l}function a(){return L(i)}function i(){return n("linear-gradient",t.linearGradient,f)||n("repeating-linear-gradient",t.repeatingLinearGradient,f)||n("radial-gradient",t.radialGradient,u)||n("repeating-radial-gradient",t.repeatingRadialGradient,u)}function n(l,b,T){return s(b,function(X){var ie=T();return ie&&($(t.comma)||e("Missing comma before color stops")),{type:l,orientation:ie,colorStops:L(O)}})}function s(l,b){var T=$(l);if(T){$(t.startCall)||e("Missing (");var X=b(T);return $(t.endCall)||e("Missing )"),X}}function f(){return p()||g()}function p(){return S("directional",t.sideOrCorner,1)}function g(){return S("angular",t.angleValue,1)}function u(){var l,b=m(),T;return b&&(l=[],l.push(b),T=r,$(t.comma)&&(b=m(),b?l.push(b):r=T)),l}function m(){var l=h()||d();if(l)l.at=R();else{var b=c();if(b){l=b;var T=R();T&&(l.at=T)}else{var X=x();X&&(l={type:"default-radial",at:X})}}return l}function h(){var l=S("shape",/^(circle)/i,0);return l&&(l.style=U()||c()),l}function d(){var l=S("shape",/^(ellipse)/i,0);return l&&(l.style=j()||c()),l}function c(){return S("extent-keyword",t.extentKeywords,1)}function R(){if(S("position",/^at/,0)){var l=x();return l||e("Missing positioning value"),l}}function x(){var l=Y();if(l.x||l.y)return{type:"position",value:l}}function Y(){return{x:j(),y:j()}}function L(l){var b=l(),T=[];if(b)for(T.push(b);$(t.comma);)b=l(),b?T.push(b):e("One extra comma");return T}function O(){var l=F();return l||e("Expected color definition"),l.length=j(),l}function F(){return v()||M()||C()||P()}function P(){return S("literal",t.literalColor,0)}function v(){return S("hex",t.hexColor,1)}function C(){return s(t.rgbColor,function(){return{type:"rgb",value:L(W)}})}function M(){return s(t.rgbaColor,function(){return{type:"rgba",value:L(W)}})}function W(){return $(t.number)[1]}function j(){return S("%",t.percentageValue,1)||G()||U()}function G(){return S("position-keyword",t.positionKeywords,1)}function U(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(l,b,T){var X=$(b);if(X)return{type:l,value:X[T]}}function $(l){var b,T;return T=/^[\n\r\t\s]+/.exec(r),T&&z(T[0].length),b=l.exec(r),b&&z(b[0].length),b}function z(l){r=r.substr(l)}return function(l){return r=l.toString(),o()}}();var Ye=Be;function Yt(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function Xt(t,r){return typeof t=="string"&&t.endsWith("%")?r*parseFloat(t)/100:+t}function ct(t,{x:r,y:e,defaultX:o,defaultY:a}){return(t?t.split(" ").map(i=>{try{let n=new Bt(i);return n.type==="length"||n.type==="number"?n.value:n.value+n.unit}catch{return null}}).filter(i=>i!==null):[o,a]).map((i,n)=>Xt(i,[r,e][n]))}function mt(t,r){let e=[];for(let n of r){let s=Yt(n);if(!e.length&&(e.push({offset:0,color:s}),typeof n.length=="undefined"||n.length.value==="0"))continue;let f=typeof n.length=="undefined"?void 0:n.length.type==="%"?n.length.value/100:n.length.value/t;e.push({offset:f,color:s})}e.length||e.push({offset:0,color:"transparent"});let o=e[e.length-1];o.offset!==1&&(typeof o.offset=="undefined"?o.offset=1:e.push({offset:1,color:o.color}));let a=0,i=1;for(let n=0;n<e.length;n++)if(typeof e[n].offset=="undefined"){for(i<n&&(i=n);typeof e[i].offset=="undefined";)i++;e[n].offset=(e[i].offset-e[a].offset)/(i-a)*(n-a)+e[a].offset}else a=n;return e}function Xe({id:t,width:r,height:e},{image:o,size:a,position:i,repeat:n}){let s=n==="repeat-x"||n==="repeat",f=n==="repeat-y"||n==="repeat",p=ct(a,{x:r,y:e,defaultX:r,defaultY:e}),g=ct(i,{x:r,y:e,defaultX:0,defaultY:0});if(o.startsWith("linear-gradient(")){let u=Ye.parse(o)[0],m,h,d,c;if(u.orientation.type==="directional")[m,h,d,c]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[u.orientation.value];else if(u.orientation.type==="angular"){let x=+u.orientation.value/180*Math.PI-Math.PI/2,Y=Math.cos(x),L=Math.sin(x);m=0,h=0,d=Y,c=L,d<0&&(m-=d,d=0),c<0&&(h-=c,c=0)}let R=mt(r,u.colorStops);return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${m}" y1="${h}" x2="${d}" y2="${c}">${R.map(x=>`<stop offset="${x.offset*100}%" stop-color="${x.color}"/>`).join("")}</linearGradient>`]}if(o.startsWith("radial-gradient(")){let u=Ye.parse(o)[0],m=u.orientation[0],[h,d]=p,c="circle",R=h/2,x=d/2;if(m.type==="shape"){if(c=m.value,m.at)if(m.at.type==="position")R=m.at.value.x.value,x=m.at.value.y.value;else throw new Error("orientation.at.type not implemented: "+m.at.type)}else throw new Error("orientation.type not implemented: "+m.type);let Y=mt(r,u.colorStops),L=`satori_radial_${t}`,O=`satori_pattern_${t}`,F={},P=Math.max(Math.abs(h-R),Math.abs(R)),v=Math.max(Math.abs(d-x),Math.abs(x));if(c==="circle")F.r=Math.sqrt(P*P+v*v);else if(c==="ellipse"){let W=v!==0?P/v:1;F.ry=Math.sqrt(P*P+v*v*W*W)/W,F.rx=F.ry*W}let C=y("pattern",{id:O,x:g[0],y:g[1],width:s?h:"100%",height:f?d:"100%",patternUnits:"userSpaceOnUse"},y("radialGradient",{id:L},Y.map(W=>y("stop",{offset:W.offset,"stop-color":W.color})).join(""))+y(c,te(D({cx:R,cy:x,width:h,height:d},F),{fill:`url(#${L})`})));return[O,C]}if(o.startsWith("url(")){let u=o.slice(4,-1);return[`satori_bi${t}`,y("pattern",{id:`satori_bi${t}`,patternContentUnits:"userSpaceOnUse",patternUnits:"userSpaceOnUse",x:g[0],y:g[1],width:s?p[0]:"100%",height:f?p[1]:"100%"},y("image",{x:0,y:0,width:p[0],height:p[1],href:u}))]}}function Re(t,r,e){return e<t+r&&(e/2<t&&e/2<r?t=r=e/2:e/2<t?t=e-r:e/2<r&&(r=e-t)),[t,r]}function me({left:t,top:r,width:e,height:o},a){let{borderTopLeftRadius:i,borderTopRightRadius:n,borderBottomLeftRadius:s,borderBottomRightRadius:f}=a;return i=Math.min(i||0,e,o),n=Math.min(n||0,e,o),s=Math.min(s||0,e,o),f=Math.min(f||0,e,o),!i&&!n&&!s&&!f?"":([i,n]=Re(i,n,e),[i,s]=Re(i,s,o),[n,f]=Re(n,f,o),[s,f]=Re(s,f,e),`M${t+i},${r} h${e-i-n} a${n},${n} 0 0 1 ${n},${n} v${o-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+s-e} a${s},${s} 0 0 1 ${-s},${-s} v${s+i-o} a${i},${i} 0 0 1 ${i},${-i}`)}function He({left:t,top:r,width:e,height:o,path:a,id:i},n){return n.overflow!=="hidden"?"":a?y("clipPath",{id:`satori_cp-${i}`,"clip-path":n._inheritedClipPathId?`url(#${n._inheritedClipPathId})`:void 0},y("path",{x:t,y:r,width:e,height:o,d:a})):y("clipPath",{id:`satori_cp-${i}`,"clip-path":n._inheritedClipPathId?`url(#${n._inheritedClipPathId})`:void 0},y("rect",{x:t,y:r,width:e,height:o}))}function Ue({id:t,left:r,top:e,width:o,height:a,isInheritingTransform:i,debug:n},s){if(s.display==="none")return"";let f="rect",p="transparent",g=0,u="",m="",h=[],d=1,c="";s.backgroundColor&&h.push(s.backgroundColor),s.borderWidth&&(g=s.borderWidth,p=s.borderColor),s.opacity&&(d=+s.opacity),s.transform&&(u=re({left:r,top:e,width:o,height:a},s.transform,i,s.transformOrigin));let R="";if(s.backgroundImage){let v=s.backgroundImage.map((C,M)=>Xe({id:t+"_"+M,width:o,height:a},C)).filter(Boolean);for(let C of v)h.push(`url(#${C[0]})`),m+=C[1],C[2]&&(R+=C[2])}let x=me({left:r,top:e,width:o,height:a},s);x&&(f="path");let Y=He({left:r,top:e,width:o,height:a,path:x,id:t},s),L=s._inheritedClipPathId,O=ne({width:o,height:a,id:t},s);n&&(c=y("rect",{x:r,y:e,width:o,height:a,fill:"transparent",stroke:"#ff5757","stroke-width":1,transform:u||void 0,"clip-path":L?`url(#${L})`:void 0})),h.length||h.push("transparent");let{backgroundClip:F}=s,P=h.map((v,C)=>{if(v==="transparent"&&!(C===h.length-1&&g))return"";let M=C===h.length-1&&g&&F!=="text";return y(f,{x:r,y:e,width:o,height:a,fill:v,stroke:M?p:void 0,"stroke-width":M?g:void 0,d:x||void 0,transform:u||void 0,"clip-path":F==="text"?`url(#satori_bct-${t})`:L?`url(#${L})`:void 0})}).join("");return F==="text"&&g&&(P=y(f,{x:r,y:e,width:o,height:a,fill:"transparent",stroke:p,"stroke-width":g,d:x||void 0,transform:u||void 0,"clip-path":L?`url(#${L})`:void 0})+P),(m?`<defs>${m}</defs>`:"")+Y+(O?`${O}<g filter="url(#satori_s-${t})">`:"")+(d!==1?`<g opacity="${d}">`:"")+(R||P)+(d!==1?"</g>":"")+(O?"</g>":"")+c}function ze({id:t,left:r,top:e,width:o,height:a,src:i,debug:n,isInheritingTransform:s},f){if(f.display==="none")return"";let p="",g=1,u="",m=f.objectFit==="contain"?"xMidYMid":f.objectFit==="cover"?"xMidYMid slice":"none",h=me({left:r,top:e,width:o,height:a},f),d=f._inheritedClipPathId;h&&(p=y("clipPath",{id:`satori_c-${t}`,"clip-path":d?`url(#${d})`:void 0},y("path",{x:r,y:e,width:o,height:a,d:h}))),f.opacity&&(g=+f.opacity);let c=ne({width:o,height:a,id:t},f);return f.transform&&(u=re({left:r,top:e,width:o,height:a},f.transform,s,f.transformOrigin)),c+(c?`<g filter="url(#satori_s-${t})">`:"")+p+y("image",{x:r,y:e,width:o,height:a,href:i,preserveAspectRatio:m,transform:u||void 0,"clip-path":p?`url(#satori_c-${t})`:d?`url(#${d})`:void 0})+(c?"</g>":"")}function*pe(t,r){let e=Q(),{id:o,inheritedStyle:a,parent:i,font:n,debug:s,embedFont:f=!0,graphemeImages:p}=r;if(t===null||typeof t=="undefined")return yield,"";if(!ke(t)||typeof t.type=="function"){let S;if(!ke(t))S=De(String(t),r);else{if(ot(t.type))throw new Error("Class component is not supported.");S=pe(t.type(t.props),r)}S.next();let $=yield;return S.next($).value}let{type:g,props:u}=t,{style:m,children:h}=u,d=e.Node.create();i.insertChild(d,i.getChildCount());let[c,R]=$e(d,g,a,m,u),x=c.transform===a.transform;if(x||(c.transform.__parent=a.transform),c.overflow==="hidden"&&(R._inheritedClipPathId=`satori_cp-${o}`),c.backgroundClip==="text"){let S={value:""};R._inheritedBackgroundClipTextPath=S,c._inheritedBackgroundClipTextPath=S}let Y=typeof h=="undefined"?[]:[].concat(h),L=[],O=0;for(let S of Y){let $=pe(S,{id:o+"-"+O++,parentStyle:c,inheritedStyle:R,isInheritingTransform:!0,parent:d,font:n,embedFont:f,debug:s,graphemeImages:p});$.next(),L.push($)}let[F,P]=yield;c.position==="absolute"&&d.calculateLayout();let{left:v,top:C,width:M,height:W}=d.getComputedLayout();v+=F,C+=P;let j="",G="",U="";g==="img"?G=ze({id:o,left:v,top:C,width:M,height:W,src:u.src,isInheritingTransform:x,debug:s},c):G=Ue({id:o,left:v,top:C,width:M,height:W,isInheritingTransform:x,debug:s},c);for(let S of L)j+=S.next([v,C]).value;return c._inheritedBackgroundClipTextPath&&(U+=y("clipPath",{id:`satori_bct-${o}`,"clip-path":c._inheritedClipPathId?`url(#${c._inheritedClipPathId})`:void 0},c._inheritedBackgroundClipTextPath.value)),U+G+j}import Ht from"@shuding/opentype.js";var Te=class{constructor(r){this.fonts=new Map;for(let e of r){let o=e.data,a=Ht.parse("buffer"in o?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o,{lowMemory:!0});this.defaultFont||(this.defaultFont=a),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([a,e.weight,e.style])}}get({name:r,weight:e,style:o}){if(!this.fonts.has(r))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let a=[...this.fonts.get(r)];return a.sort(([i,n,s],[f,p,g])=>{if(n!==p)return n?!p||n===e?-1:p===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&p===500||e===500&&p===400?1:e<400?n<e&&p<e?p-n:n<e?-1:p<e?1:n-p:e<n&&e<p?n-p:e<n?-1:e<p?1:p-n:1;if(s!==g){if(s===o)return-1;if(g===o)return 1}return-1}),a[0][0]}getFont({fontFamily:r,fontWeight:e=400,fontStyle:o="normal"}){return this.get({name:r,weight:e,style:o})}measure(r,e,{fontSize:o,letterSpacing:a=0}){return r.getAdvanceWidth(e,o,{letterSpacing:a/o})}getSVG(r,e,{fontSize:o,top:a,left:i,letterSpacing:n=0}){return r.getPath(e,i,a,o,{letterSpacing:n/o}).toPathData(1)}};function Ve({width:t,height:r,content:e}){return y("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,xmlns:"http://www.w3.org/2000/svg"},e)}var Je=new WeakMap;function pt(t,r){let e=Q();if(!e)throw new Error("Satori is not initialized.");let o;Je.has(r.fonts)?o=Je.get(r.fonts):Je.set(r.fonts,o=new Te(r.fonts));let a=e.Node.create();a.setWidth(r.width),a.setHeight(r.height),a.setFlexDirection(e.FLEX_DIRECTION_ROW),a.setFlexWrap(e.WRAP_WRAP),a.setAlignContent(e.ALIGN_AUTO),a.setAlignItems(e.ALIGN_FLEX_START),a.setJustifyContent(e.JUSTIFY_FLEX_START),a.setOverflow(e.OVERFLOW_HIDDEN);let i=pe(t,{id:"id",parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1,whiteSpace:"normal",_viewportWidth:r.width,_viewportHeight:r.height},parent:a,font:o,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});i.next(),a.calculateLayout(r.width,r.height,e.DIRECTION_LTR);let n=i.next([0,0]).value;return a.freeRecursive(),Ve({width:r.width,height:r.height,content:n})}export{pt as default,wt as init}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,5 @@ | ||
var Ue=Object.defineProperty,Xe=Object.defineProperties;var ze=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var He=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable;var we=(e,n,t)=>n in e?Ue(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,z=(e,n)=>{for(var t in n||(n={}))He.call(n,t)&&we(e,t,n[t]);if(Le)for(var t of Le(n))Ve.call(n,t)&&we(e,t,n[t]);return e},Ae=(e,n)=>Xe(e,ze(n));var ve;function Je(e){ve=e}function H(){return ve}import{LineBreaker as je}from"css-line-break";import{splitGraphemes as Ke}from"text-segmentation";function le(e){let n=typeof e;return!(n==="number"||n==="bigint"||n==="string"||n==="boolean")}function Ce(e){return/^class\s/.test(Function.prototype.toString.call(e))}function Q(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}function N(e,n,t){let i=n[e];return typeof i=="undefined"?t:i}var Fe=void 0,ue=typeof Intl!="undefined"&&"Segmenter"in Intl,qe=ue?new Intl.Segmenter(Fe,{granularity:"word"}):null,Ze=ue?new Intl.Segmenter(Fe,{granularity:"grapheme"}):null,ce=[32,160,4961,65792,65793,4153,4241].map(e=>String.fromCodePoint(e)),Qe=e=>{let n=je(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],i;for(;!(i=n.next()).done;)if(i.value){let s=i.value.slice(),o="";for(let r=0;r<s.length;r++){let a=s[r];ce.includes(a)?(o.length&&t.push(o),t.push(a),o=""):o+=a}o.length&&t.push(o)}return t};function oe(e,n){return ue?n==="word"?[...qe.segment(e)].map(t=>t.segment):[...Ze.segment(e)].map(t=>t.segment):n==="word"?Qe(e):Ke(e)}var Oe={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var et=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function me(e){let n={};for(let t in e)et.has(t)&&(n[t]=e[t]);return n}import{getPropertyName as Ne,getStylesForProperty as ot}from"css-to-react-native";import Pe from"parse-css-dimension";import{parseElementStyle as it}from"css-background-parser";import tt from"postcss-value-parser";import rt from"parse-css-dimension";function nt(e,n){try{let t=new rt(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*n};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function de(e,n,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let i=nt(e,n);return i.absolute?{[t?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[t?"xRelative":"yRelative"]:i.relative}:{}}}function pe(e,n){if(typeof e=="number")return{xAbsolute:e};let t;try{t=tt(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return t.length===1?de(t[0],n,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),z(z({},de(t[0],n,!0)),de(t[1],n,!1))):{}}var at=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),ke=[1,0,0,1,0,0];function st(e,n){return typeof n=="number"?at.has(e)?String(n):n+"px":n}function We(e,n){if(typeof e=="number")return e;try{let t=new Pe(e);if(t.type==="length")switch(t.unit){case"em":return t.value*n;case"rem":return t.value*16;default:return t.value}else if(t.type==="angle")switch(t.unit){case"deg":return t.value;case"rad":return t.value*180/Math.PI;default:return t.value}}catch{}}function ie(e,n){let t=[];for(let o in e){let r=Ne(o);t.push([r,st(r,e[o])])}let i=t.reduce((o,r)=>{let a=Ne(r[0]),f=r[1];return Object.assign(o,ot(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:o}=it(i);i.backgroundImage=o}let s=i.fontSize||n.fontSize;if(typeof s=="string")try{let o=new Pe(s);switch(o.unit){case"em":s=o.value*n.fontSize;break;case"rem":s=o.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s),i.transformOrigin&&(i.transformOrigin=pe(i.transformOrigin,s));for(let o in i){let r=i[o];if(typeof r=="string"){let a=We(r,s);typeof a!="undefined"&&(i[o]=a),r=i[o]}if(o==="opacity"&&(r=i[o]=r*n.opacity),o==="transform"){let a=[...ke],f=r;for(let u of f){let h=Object.keys(u)[0],d=u[h],m=typeof d=="string"?We(d,s):d,p=[...ke];switch(h){case"translateX":p[4]=m;break;case"translateY":p[5]=m;break;case"scaleX":p[0]=m;break;case"scaleY":p[3]=m;break;case"rotate":let c=m*Math.PI/180,y=Math.cos(c),_=Math.sin(c);p[0]=y,p[1]=_,p[2]=-_,p[3]=y;break;case"skewX":p[2]=Math.tan(m*Math.PI/180);break;case"skewY":p[1]=Math.tan(m*Math.PI/180);break}a=Q(p,a)}i.transform=a}}return i}function ge(e,n,t,i,s){let o=H(),r=z(z(z({},t),ie(Oe[n],t)),ie(i,t));if(n==="img"){let a=parseInt(s.width),u=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=u*r.width)}return e.setDisplay(N(r.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(N(r.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setAlignItems(N(r.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),e.setAlignSelf(N(r.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setJustifyContent(N(r.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),e.setFlexDirection(N(r.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),e.setFlexWrap(N(r.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&e.setFlexBasis(r.flexBasis),e.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),e.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&e.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&e.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&e.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&e.setMinWidth(r.minWidth),e.setOverflow(N(r.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),e.setMargin(o.EDGE_TOP,r.marginTop||0),e.setMargin(o.EDGE_BOTTOM,r.marginBottom||0),e.setMargin(o.EDGE_LEFT,r.marginLeft||0),e.setMargin(o.EDGE_RIGHT,r.marginRight||0),e.setBorder(o.EDGE_TOP,r.borderWidth||0),e.setBorder(o.EDGE_BOTTOM,r.borderWidth||0),e.setBorder(o.EDGE_LEFT,r.borderWidth||0),e.setBorder(o.EDGE_RIGHT,r.borderWidth||0),e.setPadding(o.EDGE_TOP,r.paddingTop||0),e.setPadding(o.EDGE_BOTTOM,r.paddingBottom||0),e.setPadding(o.EDGE_LEFT,r.paddingLeft||0),e.setPadding(o.EDGE_RIGHT,r.paddingRight||0),e.setPositionType(N(r.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&e.setPosition(o.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&e.setPosition(o.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&e.setPosition(o.EDGE_LEFT,r.left),typeof r.right!="undefined"&&e.setPosition(o.EDGE_RIGHT,r.right),typeof r.height!="undefined"?e.setHeight(r.height):e.setHeightAuto(),typeof r.width!="undefined"?e.setWidth(r.width):e.setWidthAuto(),[r,me(r)]}function te({left:e,top:n,width:t,height:i},s,o,r){var f,u,h,d;let a;if(o)a=s;else{let m=(u=r==null?void 0:r.xAbsolute)!=null?u:((f=r==null?void 0:r.xRelative)!=null?f:50)*t/100,p=(d=r==null?void 0:r.yAbsolute)!=null?d:((h=r==null?void 0:r.yRelative)!=null?h:50)*i/100,c=e+m,y=n+p;a=Q([1,0,0,1,c,y],Q(s,[1,0,0,1,-c,-y])),s.__parent&&(a=Q(s.__parent,a)),s.splice(0,6,...a)}return`matrix(${a.map(m=>m.toFixed(2)).join(",")})`}function Ge({left:e,top:n,width:t,height:i,isInheritingTransform:s},o){let r="",a=1;return o.transform&&(r=te({left:e,top:n,width:t,height:i},o.transform,s,o.transformOrigin)),o.opacity&&(a=+o.opacity),{matrix:r,opacity:a}}function he({id:e,content:n,filter:t,left:i,top:s,width:o,height:r,matrix:a,opacity:f,image:u,debug:h},d){let m="";return h&&(m=`<rect x="${i}" y="${s}" width="${o}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),u?`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<image href="${u}" x="${i}" y="${s}" width="${o}" height="${r}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${t?"</g>":""}${m}`:`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<text x="${i}" y="${s}" width="${o}" height="${r}" fill="${d.color}" font-weight="${d.fontWeight}" font-style="${d.fontStyle}" font-size="${d.fontSize}" font-family="${d.fontFamily}" ${d.letterSpacing?`letter-spacing="${d.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${n}</text>${t?"</g>":""}${m}`}function q({id:e,width:n,height:t},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+n,n),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+t,t);return`<defs><filter id="satori_s-${e}" x="${o/n*100}%" y="${a/t*100}%" width="${(r-o)/n*100}%" height="${(f-a)/t*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var be=void 0;function*ye(e,n){let t=H(),{parentStyle:i,parent:s,font:o,id:r,isInheritingTransform:a,debug:f,embedFont:u,graphemeImages:h}=n;i.textTransform==="uppercase"?e=e.toLocaleUpperCase(be):i.textTransform==="lowercase"?e=e.toLocaleLowerCase(be):i.textTransform==="capitalize"&&(e=oe(e,"word").map(E=>oe(E,"grapheme").map((I,M)=>M===0?I.toLocaleUpperCase(be):I).join("")).join(""));let d=N(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),m=oe(e,d),p=t.Node.create();p.setAlignItems(t.ALIGN_BASELINE),i.textAlign==="left"?p.setJustifyContent(t.JUSTIFY_FLEX_START):i.textAlign==="center"?p.setJustifyContent(t.JUSTIFY_CENTER):i.textAlign==="right"?p.setJustifyContent(t.JUSTIFY_FLEX_END):i.textAlign==="justify"&&p.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),s.insertChild(p,s.getChildCount());let c=o.getFont(i),y=c.ascender/c.unitsPerEm*i.fontSize,_=-(c.descender/c.unitsPerEm)*i.fontSize,S=y+_,g=S*1.2,$=(i.fontSize-S)/2,{textAlign:A}=i,W=[],Y=[],L=[],P=new Map,j=E=>{if(P.has(E))return P.get(E);let I=o.measure(c,E,i);return P.set(E,I),I};p.setMeasureFunc(E=>{let I=0,M="",D=0,C=0,B=0,ee=-1;W=[],Y=[0];for(let U=0;U<m.length;U++){let X=m[U];if(ce.includes(X))M+=X,D=j(M),L[U]=null;else{let J=h&&h[X]?i.fontSize:j(X);C||(M="",D=0);let _e=D||",.!?:-@)>]}%#".indexOf(X[0])<0,Ie=!C||!!D;_e&&C+D+J>E?(W.push(C),I++,C=J,Y.push(1),ee=-1):(C+=D+J,Ie&&Y[Y.length-1]++),M="",D=0,Ie&&ee++,B=Math.max(B,C),L[U]={y:I*g-$,x:C-J,width:J,line:I,lineIndex:ee}}}return C&&(I++,W.push(C)),I>1&&(B=E),{width:B,height:I*g}});let[K,k]=yield,v="",{left:G,top:w,width:F,height:Z}=p.getComputedLayout(),l=K+G,b=k+w,{matrix:x,opacity:O}=Ge({left:G,top:w,width:F,height:Z,isInheritingTransform:a},i),V="";i.textShadowOffset&&(V=q({width:F,height:Z,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let fe="";for(let E=0;E<m.length;E++){if(!L[E])continue;let I=m[E],M=null,D=null,C=L[E].y,B=L[E].x,ee=L[E].width,U=L[E].line;if(W.length>1){let X=F-W[U];if(A==="right"||A==="end")B+=X;else if(A==="center")B+=X/2;else if(A==="justify"&&U<W.length-1){let J=Y[U];B+=(J>1?X/(J-1):0)*L[E].lineIndex}}h&&h[I]?D=h[I]:u?M=o.getSVG(c,I,Ae(z({},i),{left:l+B,top:b+C+y,letterSpacing:i.letterSpacing})):C+=y,M?fe+=M+" ":v+=he({content:I,filter:V,id:r,left:l+B,top:b+C,width:ee,height:g,matrix:x,opacity:O,image:D,debug:f},i)}if(fe){let E="";f&&(E=`<rect x="${l}" y="${b}" width="${F}" height="${Z}" fill="transparent" stroke="#575eff" stroke-width="1" ${x?`transform="${x}"`:""}></rect>`),v+=`${V?`${V}<g filter="url(#satori_s-${r})">`:""}<path fill="${i.color}" ${x?`transform="${x}"`:""} ${O!==1?`opacity="${O}"`:""} d="${fe}"></path>${V?"</g>":""}${E}`}return v}import ft from"parse-css-dimension";var xe=xe||{};xe.parse=function(){var e={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},n="";function t(l){var b=new Error(n+": "+l);throw b.source=n,b}function i(){var l=s();return n.length>0&&t("Invalid input not EOF"),l}function s(){return $(o)}function o(){return r("linear-gradient",e.linearGradient,f)||r("repeating-linear-gradient",e.repeatingLinearGradient,f)||r("radial-gradient",e.radialGradient,d)||r("repeating-radial-gradient",e.repeatingRadialGradient,d)}function r(l,b,x){return a(b,function(O){var V=x();return V&&(F(e.comma)||t("Missing comma before color stops")),{type:l,orientation:V,colorStops:$(A)}})}function a(l,b){var x=F(l);if(x){F(e.startCall)||t("Missing (");var O=b(x);return F(e.endCall)||t("Missing )"),O}}function f(){return u()||h()}function u(){return w("directional",e.sideOrCorner,1)}function h(){return w("angular",e.angleValue,1)}function d(){var l,b=m(),x;return b&&(l=[],l.push(b),x=n,F(e.comma)&&(b=m(),b?l.push(b):n=x)),l}function m(){var l=p()||c();if(l)l.at=_();else{var b=y();if(b){l=b;var x=_();x&&(l.at=x)}else{var O=S();O&&(l={type:"default-radial",at:O})}}return l}function p(){var l=w("shape",/^(circle)/i,0);return l&&(l.style=G()||y()),l}function c(){var l=w("shape",/^(ellipse)/i,0);return l&&(l.style=k()||y()),l}function y(){return w("extent-keyword",e.extentKeywords,1)}function _(){if(w("position",/^at/,0)){var l=S();return l||t("Missing positioning value"),l}}function S(){var l=g();if(l.x||l.y)return{type:"position",value:l}}function g(){return{x:k(),y:k()}}function $(l){var b=l(),x=[];if(b)for(x.push(b);F(e.comma);)b=l(),b?x.push(b):t("One extra comma");return x}function A(){var l=W();return l||t("Expected color definition"),l.length=k(),l}function W(){return L()||j()||P()||Y()}function Y(){return w("literal",e.literalColor,0)}function L(){return w("hex",e.hexColor,1)}function P(){return a(e.rgbColor,function(){return{type:"rgb",value:$(K)}})}function j(){return a(e.rgbaColor,function(){return{type:"rgba",value:$(K)}})}function K(){return F(e.number)[1]}function k(){return w("%",e.percentageValue,1)||v()||G()}function v(){return w("position-keyword",e.positionKeywords,1)}function G(){return w("px",e.pixelValue,1)||w("em",e.emValue,1)}function w(l,b,x){var O=F(b);if(O)return{type:l,value:O[x]}}function F(l){var b,x;return x=/^[\n\r\t\s]+/.exec(n),x&&Z(x[0].length),b=l.exec(n),b&&Z(b[0].length),b}function Z(l){n=n.substr(l)}return function(l){return n=l.toString(),i()}}();var Me=xe;function lt(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function ut(e,n){return typeof e=="string"&&e.endsWith("%")?n*parseFloat(e)/100:+e}function De(e,{x:n,y:t,defaultX:i,defaultY:s}){return(e?e.split(" ").map(o=>{try{let r=new ft(o);return r.type==="length"||r.type==="number"?r.value:r.value+r.unit}catch{return null}}).filter(o=>o!==null):[i,s]).map((o,r)=>ut(o,[n,t][r]))}function $e({id:e,width:n,height:t},{image:i,size:s,position:o}){let r=De(s,{x:n,y:t,defaultX:n,defaultY:t}),a=De(o,{x:n,y:t,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=Me.parse(i)[0],u,h,d,m;if(f.orientation.type==="directional")[u,h,d,m]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let g=+f.orientation.value/180*Math.PI-Math.PI/2,$=Math.cos(g),A=Math.sin(g);u=0,h=0,d=$,m=A,d<0&&(u-=d,d=0),m<0&&(h-=m,m=0)}let p=n,c=[];for(let g of f.colorStops){let $=lt(g);if(!c.length&&(c.push({offset:0,color:$}),typeof g.length=="undefined"||g.length.value==="0"))continue;let A=typeof g.length=="undefined"?void 0:g.length.type==="%"?g.length.value/100:g.length.value/p;c.push({offset:A,color:$})}c.length||c.push({offset:0,color:"transparent"});let y=c[c.length-1];y.offset!==1&&(typeof y.offset=="undefined"?y.offset=1:c.push({offset:1,color:y.color}));let _=0,S=1;for(let g=0;g<c.length;g++)if(typeof c[g].offset=="undefined"){for(S<g&&(S=g);typeof c[S].offset=="undefined";)S++;c[g].offset=(c[S].offset-c[_].offset)/(S-_)*(g-_)+c[_].offset}else _=g;return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${u}" y1="${h}" x2="${d}" y2="${m}">${c.map(g=>`<stop offset="${g.offset*100}%" stop-color="${g.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${e}`,`<pattern id="satori_bi${e}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${r[0]}" height="${r[1]}"><image href="${f}" x="0" y="0" width="${r[0]}" height="${r[1]}"/></pattern>`]}}function ae(e,n,t){return t<e+n&&(t/2<e&&t/2<n?e=n=t/2:t/2<e?e=t-n:t/2<n&&(n=t-e)),[e,n]}function re({left:e,top:n,width:t,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return o=Math.min(o||0,t,i),r=Math.min(r||0,t,i),a=Math.min(a||0,t,i),f=Math.min(f||0,t,i),!o&&!r&&!a&&!f?"":([o,r]=ae(o,r,t),[o,a]=ae(o,a,i),[r,f]=ae(r,f,i),[a,f]=ae(a,f,t),`M${e+o},${n} h${t-o-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-t} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function Ee({id:e,left:n,top:t,width:i,height:s,isInheritingTransform:o,debug:r},a){if(a.display==="none")return"";let f="rect",u="transparent",h=0,d="",m="",p=[],c=1,y="";if(a.backgroundColor&&p.push(a.backgroundColor),a.borderWidth&&(h=a.borderWidth,u=a.borderColor),a.opacity&&(c=+a.opacity),a.transform&&(d=te({left:n,top:t,width:i,height:s},a.transform,o,a.transformOrigin)),a.backgroundImage){let g=a.backgroundImage.map(($,A)=>$e({id:e+"_"+A,width:i,height:s},$)).filter(Boolean);for(let $ of g)m+=$[1],p.push(`url(#${$[0]})`)}let _=re({left:n,top:t,width:i,height:s},a);_&&(f="path");let S=q({width:i,height:s,id:e},a);return p.length||p.push("transparent"),r&&(y=`<rect x="${n}" y="${t}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${S?`${S}<g filter="url(#satori_s-${e})">`:""}${c!==1?`<g opacity="${c}">`:""}${p.map((g,$)=>g==="transparent"&&!($===p.length-1&&h)?"":`<${f} x="${n}" y="${t}" width="${i}" height="${s}" fill="${g}" ${$===p.length-1&&h?`stroke="${u}" stroke-width="${h}"`:""} ${_?`d="${_}"`:""} ${d?`transform="${d}"`:""}></${f}>`).join("")}${c!==1?"</g>":""}${S?"</g>":""}${y}`}function Se({id:e,left:n,top:t,width:i,height:s,src:o,debug:r},a){if(a.display==="none")return"";let f="",u=1,h=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",d=re({left:n,top:t,width:i,height:s},a);d&&(f=`<clipPath id="satori_c-${e}"><path x="${n}" y="${t}" width="${i}" height="${s}" d="${d}"></path></clipPath>`),a.opacity&&(u=+a.opacity);let m=q({width:i,height:s,id:e},a);return`${m}${m?`<g filter="url(#satori_s-${e})">`:""}${f}<image href="${o}" x="${n}" y="${t}" width="${i}" height="${s}" preserveAspectRatio="${h}" ${f?`clip-path="url(#satori_c-${e})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${m?"</g>":""}`}function*ne(e,n){let t=H(),{id:i,inheritedStyle:s,parent:o,font:r,debug:a,embedFont:f=!0,graphemeImages:u}=n;if(e===null||typeof e=="undefined")return yield,"";if(!le(e)||typeof e.type=="function"){let v;if(!le(e))v=ye(String(e),n);else{if(Ce(e.type))throw new Error("Class component is not supported.");v=ne(e.type(e.props),n)}v.next();let G=yield;return v.next(G).value}let{type:h,props:d}=e,{style:m,children:p}=d,c=t.Node.create();o.insertChild(c,o.getChildCount());let[y,_]=ge(c,h,s,m,d),S=y.transform===s.transform;S||(y.transform.__parent=s.transform);let g=typeof p=="undefined"?[]:[].concat(p),$=[],A=0;for(let v of g){let G=ne(v,{id:i*g.length+ ++A,parentStyle:y,inheritedStyle:_,isInheritingTransform:!0,parent:c,font:r,embedFont:f,debug:a,graphemeImages:u});G.next(),$.push(G)}let[W,Y]=yield;y.position==="absolute"&&c.calculateLayout();let{left:L,top:P,width:j,height:K}=c.getComputedLayout();L+=W,P+=Y;let k="";h==="img"?k=Se({id:i,left:L,top:P,width:j,height:K,src:d.src,isInheritingTransform:S,debug:a},y):k=Ee({id:i,left:L,top:P,width:j,height:K,isInheritingTransform:S,debug:a},y);for(let v of $)k+=v.next([L,P]).value;return k}import Be from"@shuding/opentype.js";var se=class{constructor(n){this.fonts=new Map;for(let t of n){let i=t.data,s="buffer"in i?Be.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Be.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(t.name)||this.fonts.set(t.name,[]),this.fonts.get(t.name).push([s,t.weight,t.style])}}get({name:n,weight:t,style:i}){if(!this.fonts.has(n))return this.defaultFont;t==="normal"&&(t=400),t==="bold"&&(t=700);let s=[...this.fonts.get(n)];return s.sort(([o,r,a],[f,u,h])=>{if(r!==u)return r?!u||r===t?-1:u===t?1:t===400&&r===500||t===500&&r===400?-1:t===400&&u===500||t===500&&u===400?1:t<400?r<t&&u<t?u-r:r<t?-1:u<t?1:r-u:t<r&&t<u?r-u:t<r?-1:t<u?1:u-r:1;if(a!==h){if(a===i)return-1;if(h===i)return 1}return-1}),s[0][0]}getFont({fontFamily:n,fontWeight:t=400,fontStyle:i="normal"}){return this.get({name:n,weight:t,style:i})}measure(n,t,{fontSize:i,letterSpacing:s=0}){return n.getAdvanceWidth(t,i,{letterSpacing:s/i})}getSVG(n,t,{fontSize:i,top:s,left:o,letterSpacing:r=0}){return n.getPath(t,o,s,i,{letterSpacing:r/i}).toPathData(1)}};function Re({width:e,height:n,content:t},i){return`<svg width="${e}" height="${n}" viewBox="0 0 ${e} ${n}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}var Te=new WeakMap;function Ye(e,n){let t=H();if(!t)throw new Error("Satori is not initialized.");let i;Te.has(n.fonts)?i=Te.get(n.fonts):Te.set(n.fonts,i=new se(n.fonts));let s=t.Node.create();s.setWidth(n.width),s.setHeight(n.height),s.setFlexDirection(t.FLEX_DIRECTION_ROW),s.setFlexWrap(t.WRAP_WRAP),s.setAlignContent(t.ALIGN_AUTO),s.setAlignItems(t.ALIGN_FLEX_START),s.setJustifyContent(t.JUSTIFY_FLEX_START);let o=ne(e,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:n.embedFont,debug:n.debug,graphemeImages:n.graphemeImages});o.next(),s.calculateLayout(n.width,n.height,t.DIRECTION_LTR);let r=o.next([0,0]).value;return Re({width:n.width,height:n.height,content:r})}export{Ye as default,Je as init}; | ||
var xt=Object.defineProperty,St=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var rt=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var nt=(t,r,e)=>r in t?xt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,D=(t,r)=>{for(var e in r||(r={}))Et.call(r,e)&&nt(t,e,r[e]);if(rt)for(var e of rt(r))Rt.call(r,e)&&nt(t,e,r[e]);return t},te=(t,r)=>St(t,_t(r));var it={};var ve;ve=it.default;function Tt(t){ve=t}function Q(){return ve}import{LineBreaker as wt}from"css-line-break";import{splitGraphemes as It}from"text-segmentation";function ke(t){let r=typeof t;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function ot(t){return/^class\s/.test(Function.prototype.toString.call(t))}function fe(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}function H(t,r,e){let o=r[t];return typeof o=="undefined"?e:o}var at=void 0,Ae=typeof Intl!="undefined"&&"Segmenter"in Intl&&process.env.NODE_ENV!=="test",Lt=Ae?new Intl.Segmenter(at,{granularity:"word"}):null,Ct=Ae?new Intl.Segmenter(at,{granularity:"grapheme"}):null,de=[32,160,4961,65792,65793,4153,4241,10].map(t=>String.fromCodePoint(t)),vt=t=>{let r=wt(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],o;for(;!(o=r.next()).done;)if(o.value){let a=o.value.slice(),i="";for(let n=0;n<a.length;n++){let s=a[n];de.includes(s)?(i.length&&e.push(i),e.push(s),i=""):i+=s}i.length&&e.push(i)}return e};function ce(t,r){return Ae?r==="word"?[...Lt.segment(t)].map(e=>e.segment):[...Ct.segment(t)].map(e=>e.segment):r==="word"?vt(t):It(t)}function y(t,r,e){let o="";for(let[a,i]of Object.entries(r))typeof i!="undefined"&&(o+=` ${a}="${i}"`);return e?`<${t}${o}>${e}</${t}>`:`<${t}${o}/>`}var st={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var kt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textAlign","textTransform","textShadowOffset","textShadowColor","textShadowRadius","textDecorationLine","textDecorationStyle","textDecorationColor","whiteSpace","transform","wordBreak","opacity","_viewportWidth","_viewportHeight","_inheritedClipPathId","_inheritedBackgroundClipTextPath"]);function Pe(t){let r={};for(let e in t)kt.has(e)&&(r[e]=t[e]);return r}import{getPropertyName as Ot,getStylesForProperty as Ft}from"css-to-react-native";import ut from"parse-css-dimension";import{parseElementStyle as $t}from"css-background-parser";import At from"postcss-value-parser";import Pt from"parse-css-dimension";function Wt(t,r){try{let e=new Pt(t);switch(e.unit){case"px":return{absolute:e.value};case"em":return{absolute:e.value*r};case"rem":return{absolute:e.value*16};case"%":return{relative:e.value};default:return{}}}catch{return{}}}function We(t,r,e){switch(t){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let o=Wt(t,r);return o.absolute?{[e?"xAbsolute":"yAbsolute"]:o.absolute}:o.relative?{[e?"xRelative":"yRelative"]:o.relative}:{}}}function Oe(t,r){if(typeof t=="number")return{xAbsolute:t};let e;try{e=At(t).nodes.filter(o=>o.type==="word").map(o=>o.value)}catch{return{}}return e.length===1?We(e[0],r,!0):e.length===2?((e[0]==="top"||e[0]==="bottom"||e[1]==="left"||e[1]==="right")&&e.reverse(),D(D({},We(e[0],r,!0)),We(e[1],r,!1))):{}}var Nt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Mt=new Set(["lineHeight"]),ft=[1,0,0,1,0,0];function Gt(t,r,e,o){return t==="border"&&!e.includes(r.borderColor)?r.borderColor=o:t==="textDecoration"&&!e.includes(r.textDecorationColor)&&(r.textDecorationColor=o),r}function lt(t,r){return typeof r=="number"?Nt.has(t)?Mt.has(t)?r:String(r):r+"px":r}function Fe(t,r,e,{percentage:o}={percentage:!1}){if(typeof t=="number")return t;try{let a=new ut(t);if(a.type==="length")switch(a.unit){case"em":return a.value*r;case"rem":return a.value*16;case"vw":return~~(a.value*e._viewportWidth/100);case"vh":return~~(a.value*e._viewportHeight/100);default:return a.value}else if(a.type==="angle")switch(a.unit){case"deg":return a.value;case"rad":return a.value*180/Math.PI;default:return a.value}else if(a.type==="percentage"&&o)return a.value/100*r}catch{}}function Ee(t,r){let e={};for(let a in t){if(a.startsWith("_")){e[a]=t[a];continue}let i=Ot(a);Object.assign(e,i==="lineHeight"?{lineHeight:lt(i,t[a])}:Gt(i,Ft(i,lt(i,t[a]),!0),t[a],t.color||r.color))}if(e.backgroundImage){let{backgrounds:a}=$t(e);e.backgroundImage=a}let o=e.fontSize||r.fontSize;if(typeof o=="string")try{let a=new ut(o);switch(a.unit){case"em":o=a.value*r.fontSize;break;case"rem":o=a.value*16;break}}catch{o=16}typeof e.fontSize!="undefined"&&(e.fontSize=o),e.transformOrigin&&(e.transformOrigin=Oe(e.transformOrigin,o));for(let a in e){let i=e[a];if(a==="lineHeight")typeof i=="string"&&(i=e[a]=Fe(i,o,r,{percentage:!0})/o);else if(typeof i=="string"){let n=Fe(i,o,r);typeof n!="undefined"&&(e[a]=n),i=e[a]}if(a==="opacity"&&(i=e[a]=i*r.opacity),a==="transform"){let n=[...ft],s=i;for(let f of s){let p=Object.keys(f)[0],g=f[p],u=typeof g=="string"?Fe(g,o,r):g,m=[...ft];switch(p){case"translateX":m[4]=u;break;case"translateY":m[5]=u;break;case"scale":m[0]=u,m[3]=u;break;case"scaleX":m[0]=u;break;case"scaleY":m[3]=u;break;case"rotate":let h=u*Math.PI/180,d=Math.cos(h),c=Math.sin(h);m[0]=d,m[1]=c,m[2]=-c,m[3]=d;break;case"skewX":m[2]=Math.tan(u*Math.PI/180);break;case"skewY":m[1]=Math.tan(u*Math.PI/180);break}n=fe(m,n)}e.transform=n}}return e}function $e(t,r,e,o,a){let i=Q(),n=D(D(D({},e),Ee(st[r],e)),Ee(o,e));if(r==="img"){let s=parseInt(a.width),p=parseInt(a.height)/s;n.width||(n.width=s),n.height||(n.height=p*n.width)}return t.setDisplay(H(n.display,{flex:i.DISPLAY_FLEX,none:i.DISPLAY_NONE},i.DISPLAY_FLEX)),t.setAlignContent(H(n.alignContent,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,"space-between":i.ALIGN_SPACE_BETWEEN,"space-around":i.ALIGN_SPACE_AROUND,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setAlignItems(H(n.alignItems,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_FLEX_START)),t.setAlignSelf(H(n.alignSelf,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),t.setJustifyContent(H(n.justifyContent,{center:i.JUSTIFY_CENTER,"flex-start":i.JUSTIFY_FLEX_START,"flex-end":i.JUSTIFY_FLEX_END,"space-between":i.JUSTIFY_SPACE_BETWEEN,"space-around":i.JUSTIFY_SPACE_AROUND},i.JUSTIFY_FLEX_START)),t.setFlexDirection(H(n.flexDirection,{row:i.FLEX_DIRECTION_ROW,column:i.FLEX_DIRECTION_COLUMN,"row-reverse":i.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":i.FLEX_DIRECTION_COLUMN_REVERSE},i.FLEX_DIRECTION_ROW)),t.setFlexWrap(H(n.flexWrap,{wrap:i.WRAP_WRAP,nowrap:i.WRAP_NO_WRAP,"wrap-reverse":i.WRAP_WRAP_REVERSE},i.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&t.setFlexBasis(n.flexBasis),t.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),t.setFlexShrink(typeof n.flexShrink=="undefined"?0:n.flexShrink),typeof n.maxHeight!="undefined"&&t.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&t.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&t.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&t.setMinWidth(n.minWidth),t.setOverflow(H(n.overflow,{visible:i.OVERFLOW_VISIBLE,hidden:i.OVERFLOW_HIDDEN},i.OVERFLOW_VISIBLE)),t.setMargin(i.EDGE_TOP,n.marginTop||0),t.setMargin(i.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(i.EDGE_LEFT,n.marginLeft||0),t.setMargin(i.EDGE_RIGHT,n.marginRight||0),t.setBorder(i.EDGE_TOP,n.borderWidth||0),t.setBorder(i.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(i.EDGE_LEFT,n.borderWidth||0),t.setBorder(i.EDGE_RIGHT,n.borderWidth||0),t.setPadding(i.EDGE_TOP,n.paddingTop||0),t.setPadding(i.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(i.EDGE_LEFT,n.paddingLeft||0),t.setPadding(i.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(H(n.position,{absolute:i.POSITION_TYPE_ABSOLUTE,relative:i.POSITION_TYPE_RELATIVE},i.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(i.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(i.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(i.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(i.EDGE_RIGHT,n.right),typeof n.height!="undefined"?t.setHeight(n.height):t.setHeightAuto(),typeof n.width!="undefined"?t.setWidth(n.width):t.setWidthAuto(),[n,Pe(n)]}function re({left:t,top:r,width:e,height:o},a,i,n){var f,p,g,u;let s;if(i)s=a;else{let m=(p=n==null?void 0:n.xAbsolute)!=null?p:((f=n==null?void 0:n.xRelative)!=null?f:50)*e/100,h=(u=n==null?void 0:n.yAbsolute)!=null?u:((g=n==null?void 0:n.yRelative)!=null?g:50)*o/100,d=t+m,c=r+h;s=fe([1,0,0,1,d,c],fe(a,[1,0,0,1,-d,-c])),a.__parent&&(s=fe(a.__parent,s)),a.splice(0,6,...s)}return`matrix(${s.map(m=>m.toFixed(2)).join(",")})`}function dt({left:t,top:r,width:e,height:o,isInheritingTransform:a},i){let n="",s=1;return i.transform&&(n=re({left:t,top:r,width:e,height:o},i.transform,a,i.transformOrigin)),i.opacity&&(s=+i.opacity),{matrix:n,opacity:s}}function Ne({id:t,content:r,filter:e,left:o,top:a,width:i,height:n,matrix:s,opacity:f,image:p,clipPathId:g,debug:u,shape:m,decorationShape:h},d){let c="";if(u&&(c=y("rect",{x:o,y:a,width:i,height:.5,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0})),p){let x={href:p,x:o,y:a,width:i,height:n,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0};return[(e?`${e}<g filter="url(#satori_s-${t})">`:"")+y("image",te(D({},x),{opacity:f!==1?f:void 0}))+(h||"")+(e?"</g>":"")+c,""]}let R={x:o,y:a,width:i,height:n,"font-weight":d.fontWeight,"font-style":d.fontStyle,"font-size":d.fontSize,"font-family":d.fontFamily,"letter-spacing":d.letterSpacing||void 0,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0};return[(e?`${e}<g filter="url(#satori_s-${t})">`:"")+y("text",te(D({},R),{fill:d.color,opacity:f!==1?f:void 0}),r)+(h||"")+(e?"</g>":"")+c,m?y("text",R,r):""]}function ne({id:t,width:r,height:e},o){if(!o.shadowColor||!o.shadowOffset||typeof o.shadowRadius=="undefined")return"";let a=o.shadowRadius*o.shadowRadius/4,i=Math.min(o.shadowOffset.width-a,0),n=Math.max(o.shadowOffset.width+a+r,r),s=Math.min(o.shadowOffset.height-a,0),f=Math.max(o.shadowOffset.height+a+e,e);return`<defs><filter id="satori_s-${t}" x="${i/r*100}%" y="${s/e*100}%" width="${(n-i)/r*100}%" height="${(f-s)/e*100}%"><feDropShadow dx="${o.shadowOffset.width}" dy="${o.shadowOffset.height}" stdDeviation="${o.shadowRadius/2}" flood-color="${o.shadowColor}" flood-opacity="1"/></filter></defs>`}function Me({width:t,left:r,top:e,ascender:o,clipPathId:a},i){let{textDecorationColor:n,textDecorationStyle:s,textDecorationLine:f,fontSize:p}=i;if(!f||f==="none")return"";let g=Math.max(1,p*.1),u=f==="line-through"?e+o*.75:f==="underline"?e+o*1.25:e,m=s==="dashed"?`${g*1.2} ${g*2}`:s==="dotted"?`0 ${g*2}`:void 0;return y("line",{x1:r,y1:u,x2:r+t,y2:u,stroke:n,"stroke-width":g,"stroke-dasharray":m,"stroke-linecap":s==="dotted"?"round":"square","clip-path":a?`url(#${a})`:void 0})}var Ge=void 0;function*De(t,r){var Qe;let e=Q(),{parentStyle:o,inheritedStyle:a,parent:i,font:n,id:s,isInheritingTransform:f,debug:p,embedFont:g,graphemeImages:u}=r;o.textTransform==="uppercase"?t=t.toLocaleUpperCase(Ge):o.textTransform==="lowercase"?t=t.toLocaleLowerCase(Ge):o.textTransform==="capitalize"&&(t=ce(t,"word").map(_=>ce(_,"grapheme").map((E,N)=>N===0?E.toLocaleUpperCase(Ge):E).join("")).join(""));let m=H(o.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),h=ce(t,m),d=e.Node.create();d.setAlignItems(e.ALIGN_BASELINE),o.textAlign==="left"?d.setJustifyContent(e.JUSTIFY_FLEX_START):o.textAlign==="center"?d.setJustifyContent(e.JUSTIFY_CENTER):o.textAlign==="right"?d.setJustifyContent(e.JUSTIFY_FLEX_END):o.textAlign==="justify"&&d.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),i.insertChild(d,i.getChildCount());let{textAlign:c,textOverflow:R,whiteSpace:x,lineHeight:Y,_inheritedBackgroundClipTextPath:L}=o,O=n.getFont(o),F=o.fontSize,P=O.ascender/O.unitsPerEm*F,v=-(O.descender/O.unitsPerEm)*F,C=P+v,M=Y/1.2*F-C,W=C*Y/1.2,j=(o.fontSize-C)/2,G=[],U=[],S=[],$=new Map,z=_=>{if($.has(_))return $.get(_);let E=n.measure(O,_,o);return $.set(_,E),E},l=0,b="",T=0;for(let _ of h){let E=!1,N=u&&u[_];x==="pre"?E=_[0]===` | ||
`:x!=="nowrap"&&(N||de.includes(_[0]))&&(E=!0),E?(x==="nowrap"?T+=z(b)+o.fontSize:(l=Math.max(l,z(b)),N&&(l=Math.max(l,o.fontSize))),b=""):(!de.includes(_[0])||!b)&&(b+=_===` | ||
`?" ":_)}l=Math.max(l,z(b)+T);let X=i.getMinWidth(),ie=i.getMaxWidth(),gt=i.getWidth();isNaN(gt.value)&&(isNaN(X.value)||X.unit===1&&X.value>l)&&(isNaN(ie.value)||ie.unit===1&&(l=Math.min(l,ie.value)),i.setMinWidth(l)),typeof o.flexShrink=="undefined"&&i.setFlexShrink(1);let je=["pre-wrap","pre"].includes(x);d.setMeasureFunc(_=>{let E=0,N="",V=0,B=0,K=0,q=-1;G=[],U=[0];for(let Z=0;Z<h.length;Z++){let k=h[Z];if(!je&&de.includes(k[0]))N||(N=" "),V=z(N),S[Z]=null;else{let ae=je&&k===` | ||
`,A=ae?0:u&&u[k]?o.fontSize:z(k);B||(N="",V=0);let J=V||",.!?:-@)>]}%#".indexOf(k[0])<0,se=!B||!!V;ae||Z&&J&&B+V+A>_&&x!=="nowrap"&&x!=="pre"?(G.push(B),E++,B=A,U.push(1),q=-1,ae||(K=Math.max(K,_))):(B+=V+A,se&&U[U.length-1]++),N="",V=0,se&&q++,K=Math.max(K,B),S[Z]={y:E*W-j,x:B-A,width:A,line:E,lineIndex:q}}}return B&&(E++,G.push(B)),{width:K,height:E*W}});let[ht,bt]=yield,we="",ge="",oe=a._inheritedClipPathId,{left:Ke,top:qe,width:le,height:Ie}=d.getComputedLayout(),Le=i.getComputedWidth()-i.getComputedPadding(e.EDGE_LEFT)-i.getComputedPadding(e.EDGE_RIGHT)-i.getComputedBorder(e.EDGE_LEFT)-i.getComputedBorder(e.EDGE_RIGHT),he=ht+Ke,be=bt+qe,{matrix:ee,opacity:ye}=dt({left:Ke,top:qe,width:le,height:Ie,isInheritingTransform:f},o),ue="";o.textShadowOffset&&(ue=ne({width:le,height:Ie,id:s},{shadowColor:o.textShadowColor,shadowOffset:o.textShadowOffset,shadowRadius:o.textShadowRadius}));let xe="",Se="",Ce=-1,Ze=R==="ellipsis"?z("\u2026"):0,yt=R==="ellipsis"?z(" "):0,_e={};for(let _=0;_<h.length;_++){if(!S[_])continue;let E=S[_],N=h[_],V=null,B=u?u[N]:null,K=E.y,q=E.x,Z=E.width,k=E.line;if(k===Ce)continue;let ae=!1;if(G.length>1){let A=le-G[k];if(c==="right"||c==="end")q+=A;else if(c==="center")q+=A/2;else if(c==="justify"&&k<G.length-1){let J=U[k];q+=(J>1?A/(J-1):0)*E.lineIndex,ae=!0}}if(_e[k]||(_e[k]=[q,ae?le:G[k]]),R==="ellipsis"&&G[k]>Le&&E.x+Z+Ze+yt>Le){let A=ce(N,"grapheme"),J="",se=0;for(let et of A){let tt=E.x+z(J+et);if(J&&tt+Ze>Le)break;J+=et,se=tt}N=J+"\u2026",Ce=k,_e[k][1]=se}if(B?K+=j:g?V=n.getSVG(O,N,te(D({},o),{left:he+q,top:be+K+P+M/2,letterSpacing:o.letterSpacing})):K+=P+M/2,o.textDecorationLine&&(k!==((Qe=S[_+1])==null?void 0:Qe.line)||Ce===k)){let A=_e[k];A&&!A[2]&&(xe+=Me({left:he+A[0],top:be+W*+k,width:A[1],ascender:P+M/2,clipPathId:oe},o),A[2]=1)}if(V)Se+=V+" ";else{let[A,J]=Ne({content:N,filter:ue,id:s,left:he+q,top:be+K,width:Z,height:W,matrix:ee,opacity:ye,image:B,clipPathId:oe,debug:p,shape:!!L,decorationShape:xe},o);we+=A,ge+=J,xe=""}}if(Se){let _="";p&&(_=y("rect",{x:he,y:be,width:le,height:Ie,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:ee||void 0,"clip-path":oe?`url(#${oe})`:void 0}));let E=o.color!=="transparent"&&ye!==0?y("path",{fill:o.color,d:Se,transform:ee||void 0,opacity:ye!==1?ye:void 0,"clip-path":oe?`url(#${oe})`:void 0}):"";L&&(ge=y("path",{d:Se,transform:ee||void 0})),we+=(ue?`${ue}<g filter="url(#satori_s-${s})">`:"")+E+xe+(ue?"</g>":"")+_}return ge&&(o._inheritedBackgroundClipTextPath.value+=ge),we}import Dt from"parse-css-dimension";var Be=Be||{};Be.parse=function(){var t={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function e(l){var b=new Error(r+": "+l);throw b.source=r,b}function o(){var l=a();return r.length>0&&e("Invalid input not EOF"),l}function a(){return L(i)}function i(){return n("linear-gradient",t.linearGradient,f)||n("repeating-linear-gradient",t.repeatingLinearGradient,f)||n("radial-gradient",t.radialGradient,u)||n("repeating-radial-gradient",t.repeatingRadialGradient,u)}function n(l,b,T){return s(b,function(X){var ie=T();return ie&&($(t.comma)||e("Missing comma before color stops")),{type:l,orientation:ie,colorStops:L(O)}})}function s(l,b){var T=$(l);if(T){$(t.startCall)||e("Missing (");var X=b(T);return $(t.endCall)||e("Missing )"),X}}function f(){return p()||g()}function p(){return S("directional",t.sideOrCorner,1)}function g(){return S("angular",t.angleValue,1)}function u(){var l,b=m(),T;return b&&(l=[],l.push(b),T=r,$(t.comma)&&(b=m(),b?l.push(b):r=T)),l}function m(){var l=h()||d();if(l)l.at=R();else{var b=c();if(b){l=b;var T=R();T&&(l.at=T)}else{var X=x();X&&(l={type:"default-radial",at:X})}}return l}function h(){var l=S("shape",/^(circle)/i,0);return l&&(l.style=U()||c()),l}function d(){var l=S("shape",/^(ellipse)/i,0);return l&&(l.style=j()||c()),l}function c(){return S("extent-keyword",t.extentKeywords,1)}function R(){if(S("position",/^at/,0)){var l=x();return l||e("Missing positioning value"),l}}function x(){var l=Y();if(l.x||l.y)return{type:"position",value:l}}function Y(){return{x:j(),y:j()}}function L(l){var b=l(),T=[];if(b)for(T.push(b);$(t.comma);)b=l(),b?T.push(b):e("One extra comma");return T}function O(){var l=F();return l||e("Expected color definition"),l.length=j(),l}function F(){return v()||M()||C()||P()}function P(){return S("literal",t.literalColor,0)}function v(){return S("hex",t.hexColor,1)}function C(){return s(t.rgbColor,function(){return{type:"rgb",value:L(W)}})}function M(){return s(t.rgbaColor,function(){return{type:"rgba",value:L(W)}})}function W(){return $(t.number)[1]}function j(){return S("%",t.percentageValue,1)||G()||U()}function G(){return S("position-keyword",t.positionKeywords,1)}function U(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(l,b,T){var X=$(b);if(X)return{type:l,value:X[T]}}function $(l){var b,T;return T=/^[\n\r\t\s]+/.exec(r),T&&z(T[0].length),b=l.exec(r),b&&z(b[0].length),b}function z(l){r=r.substr(l)}return function(l){return r=l.toString(),o()}}();var Ye=Be;function Bt(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function Yt(t,r){return typeof t=="string"&&t.endsWith("%")?r*parseFloat(t)/100:+t}function ct(t,{x:r,y:e,defaultX:o,defaultY:a}){return(t?t.split(" ").map(i=>{try{let n=new Dt(i);return n.type==="length"||n.type==="number"?n.value:n.value+n.unit}catch{return null}}).filter(i=>i!==null):[o,a]).map((i,n)=>Yt(i,[r,e][n]))}function mt(t,r){let e=[];for(let n of r){let s=Bt(n);if(!e.length&&(e.push({offset:0,color:s}),typeof n.length=="undefined"||n.length.value==="0"))continue;let f=typeof n.length=="undefined"?void 0:n.length.type==="%"?n.length.value/100:n.length.value/t;e.push({offset:f,color:s})}e.length||e.push({offset:0,color:"transparent"});let o=e[e.length-1];o.offset!==1&&(typeof o.offset=="undefined"?o.offset=1:e.push({offset:1,color:o.color}));let a=0,i=1;for(let n=0;n<e.length;n++)if(typeof e[n].offset=="undefined"){for(i<n&&(i=n);typeof e[i].offset=="undefined";)i++;e[n].offset=(e[i].offset-e[a].offset)/(i-a)*(n-a)+e[a].offset}else a=n;return e}function Xe({id:t,width:r,height:e},{image:o,size:a,position:i,repeat:n}){let s=n==="repeat-x"||n==="repeat",f=n==="repeat-y"||n==="repeat",p=ct(a,{x:r,y:e,defaultX:r,defaultY:e}),g=ct(i,{x:r,y:e,defaultX:0,defaultY:0});if(o.startsWith("linear-gradient(")){let u=Ye.parse(o)[0],m,h,d,c;if(u.orientation.type==="directional")[m,h,d,c]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[u.orientation.value];else if(u.orientation.type==="angular"){let x=+u.orientation.value/180*Math.PI-Math.PI/2,Y=Math.cos(x),L=Math.sin(x);m=0,h=0,d=Y,c=L,d<0&&(m-=d,d=0),c<0&&(h-=c,c=0)}let R=mt(r,u.colorStops);return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${m}" y1="${h}" x2="${d}" y2="${c}">${R.map(x=>`<stop offset="${x.offset*100}%" stop-color="${x.color}"/>`).join("")}</linearGradient>`]}if(o.startsWith("radial-gradient(")){let u=Ye.parse(o)[0],m=u.orientation[0],[h,d]=p,c="circle",R=h/2,x=d/2;if(m.type==="shape"){if(c=m.value,m.at)if(m.at.type==="position")R=m.at.value.x.value,x=m.at.value.y.value;else throw new Error("orientation.at.type not implemented: "+m.at.type)}else throw new Error("orientation.type not implemented: "+m.type);let Y=mt(r,u.colorStops),L=`satori_radial_${t}`,O=`satori_pattern_${t}`,F={},P=Math.max(Math.abs(h-R),Math.abs(R)),v=Math.max(Math.abs(d-x),Math.abs(x));if(c==="circle")F.r=Math.sqrt(P*P+v*v);else if(c==="ellipse"){let W=v!==0?P/v:1;F.ry=Math.sqrt(P*P+v*v*W*W)/W,F.rx=F.ry*W}let C=y("pattern",{id:O,x:g[0],y:g[1],width:s?h:"100%",height:f?d:"100%",patternUnits:"userSpaceOnUse"},y("radialGradient",{id:L},Y.map(W=>y("stop",{offset:W.offset,"stop-color":W.color})).join(""))+y(c,te(D({cx:R,cy:x,width:h,height:d},F),{fill:`url(#${L})`})));return[O,C]}if(o.startsWith("url(")){let u=o.slice(4,-1);return[`satori_bi${t}`,y("pattern",{id:`satori_bi${t}`,patternContentUnits:"userSpaceOnUse",patternUnits:"userSpaceOnUse",x:g[0],y:g[1],width:s?p[0]:"100%",height:f?p[1]:"100%"},y("image",{x:0,y:0,width:p[0],height:p[1],href:u}))]}}function Re(t,r,e){return e<t+r&&(e/2<t&&e/2<r?t=r=e/2:e/2<t?t=e-r:e/2<r&&(r=e-t)),[t,r]}function me({left:t,top:r,width:e,height:o},a){let{borderTopLeftRadius:i,borderTopRightRadius:n,borderBottomLeftRadius:s,borderBottomRightRadius:f}=a;return i=Math.min(i||0,e,o),n=Math.min(n||0,e,o),s=Math.min(s||0,e,o),f=Math.min(f||0,e,o),!i&&!n&&!s&&!f?"":([i,n]=Re(i,n,e),[i,s]=Re(i,s,o),[n,f]=Re(n,f,o),[s,f]=Re(s,f,e),`M${t+i},${r} h${e-i-n} a${n},${n} 0 0 1 ${n},${n} v${o-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+s-e} a${s},${s} 0 0 1 ${-s},${-s} v${s+i-o} a${i},${i} 0 0 1 ${i},${-i}`)}function He({left:t,top:r,width:e,height:o,path:a,id:i},n){return n.overflow!=="hidden"?"":a?y("clipPath",{id:`satori_cp-${i}`,"clip-path":n._inheritedClipPathId?`url(#${n._inheritedClipPathId})`:void 0},y("path",{x:t,y:r,width:e,height:o,d:a})):y("clipPath",{id:`satori_cp-${i}`,"clip-path":n._inheritedClipPathId?`url(#${n._inheritedClipPathId})`:void 0},y("rect",{x:t,y:r,width:e,height:o}))}function Ue({id:t,left:r,top:e,width:o,height:a,isInheritingTransform:i,debug:n},s){if(s.display==="none")return"";let f="rect",p="transparent",g=0,u="",m="",h=[],d=1,c="";s.backgroundColor&&h.push(s.backgroundColor),s.borderWidth&&(g=s.borderWidth,p=s.borderColor),s.opacity&&(d=+s.opacity),s.transform&&(u=re({left:r,top:e,width:o,height:a},s.transform,i,s.transformOrigin));let R="";if(s.backgroundImage){let v=s.backgroundImage.map((C,M)=>Xe({id:t+"_"+M,width:o,height:a},C)).filter(Boolean);for(let C of v)h.push(`url(#${C[0]})`),m+=C[1],C[2]&&(R+=C[2])}let x=me({left:r,top:e,width:o,height:a},s);x&&(f="path");let Y=He({left:r,top:e,width:o,height:a,path:x,id:t},s),L=s._inheritedClipPathId,O=ne({width:o,height:a,id:t},s);n&&(c=y("rect",{x:r,y:e,width:o,height:a,fill:"transparent",stroke:"#ff5757","stroke-width":1,transform:u||void 0,"clip-path":L?`url(#${L})`:void 0})),h.length||h.push("transparent");let{backgroundClip:F}=s,P=h.map((v,C)=>{if(v==="transparent"&&!(C===h.length-1&&g))return"";let M=C===h.length-1&&g&&F!=="text";return y(f,{x:r,y:e,width:o,height:a,fill:v,stroke:M?p:void 0,"stroke-width":M?g:void 0,d:x||void 0,transform:u||void 0,"clip-path":F==="text"?`url(#satori_bct-${t})`:L?`url(#${L})`:void 0})}).join("");return F==="text"&&g&&(P=y(f,{x:r,y:e,width:o,height:a,fill:"transparent",stroke:p,"stroke-width":g,d:x||void 0,transform:u||void 0,"clip-path":L?`url(#${L})`:void 0})+P),(m?`<defs>${m}</defs>`:"")+Y+(O?`${O}<g filter="url(#satori_s-${t})">`:"")+(d!==1?`<g opacity="${d}">`:"")+(R||P)+(d!==1?"</g>":"")+(O?"</g>":"")+c}function ze({id:t,left:r,top:e,width:o,height:a,src:i,debug:n,isInheritingTransform:s},f){if(f.display==="none")return"";let p="",g=1,u="",m=f.objectFit==="contain"?"xMidYMid":f.objectFit==="cover"?"xMidYMid slice":"none",h=me({left:r,top:e,width:o,height:a},f),d=f._inheritedClipPathId;h&&(p=y("clipPath",{id:`satori_c-${t}`,"clip-path":d?`url(#${d})`:void 0},y("path",{x:r,y:e,width:o,height:a,d:h}))),f.opacity&&(g=+f.opacity);let c=ne({width:o,height:a,id:t},f);return f.transform&&(u=re({left:r,top:e,width:o,height:a},f.transform,s,f.transformOrigin)),c+(c?`<g filter="url(#satori_s-${t})">`:"")+p+y("image",{x:r,y:e,width:o,height:a,href:i,preserveAspectRatio:m,transform:u||void 0,"clip-path":p?`url(#satori_c-${t})`:d?`url(#${d})`:void 0})+(c?"</g>":"")}function*pe(t,r){let e=Q(),{id:o,inheritedStyle:a,parent:i,font:n,debug:s,embedFont:f=!0,graphemeImages:p}=r;if(t===null||typeof t=="undefined")return yield,"";if(!ke(t)||typeof t.type=="function"){let S;if(!ke(t))S=De(String(t),r);else{if(ot(t.type))throw new Error("Class component is not supported.");S=pe(t.type(t.props),r)}S.next();let $=yield;return S.next($).value}let{type:g,props:u}=t,{style:m,children:h}=u,d=e.Node.create();i.insertChild(d,i.getChildCount());let[c,R]=$e(d,g,a,m,u),x=c.transform===a.transform;if(x||(c.transform.__parent=a.transform),c.overflow==="hidden"&&(R._inheritedClipPathId=`satori_cp-${o}`),c.backgroundClip==="text"){let S={value:""};R._inheritedBackgroundClipTextPath=S,c._inheritedBackgroundClipTextPath=S}let Y=typeof h=="undefined"?[]:[].concat(h),L=[],O=0;for(let S of Y){let $=pe(S,{id:o+"-"+O++,parentStyle:c,inheritedStyle:R,isInheritingTransform:!0,parent:d,font:n,embedFont:f,debug:s,graphemeImages:p});$.next(),L.push($)}let[F,P]=yield;c.position==="absolute"&&d.calculateLayout();let{left:v,top:C,width:M,height:W}=d.getComputedLayout();v+=F,C+=P;let j="",G="",U="";g==="img"?G=ze({id:o,left:v,top:C,width:M,height:W,src:u.src,isInheritingTransform:x,debug:s},c):G=Ue({id:o,left:v,top:C,width:M,height:W,isInheritingTransform:x,debug:s},c);for(let S of L)j+=S.next([v,C]).value;return c._inheritedBackgroundClipTextPath&&(U+=y("clipPath",{id:`satori_bct-${o}`,"clip-path":c._inheritedClipPathId?`url(#${c._inheritedClipPathId})`:void 0},c._inheritedBackgroundClipTextPath.value)),U+G+j}import Xt from"@shuding/opentype.js";var Te=class{constructor(r){this.fonts=new Map;for(let e of r){let o=e.data,a=Xt.parse("buffer"in o?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o,{lowMemory:!0});this.defaultFont||(this.defaultFont=a),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([a,e.weight,e.style])}}get({name:r,weight:e,style:o}){if(!this.fonts.has(r))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let a=[...this.fonts.get(r)];return a.sort(([i,n,s],[f,p,g])=>{if(n!==p)return n?!p||n===e?-1:p===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&p===500||e===500&&p===400?1:e<400?n<e&&p<e?p-n:n<e?-1:p<e?1:n-p:e<n&&e<p?n-p:e<n?-1:e<p?1:p-n:1;if(s!==g){if(s===o)return-1;if(g===o)return 1}return-1}),a[0][0]}getFont({fontFamily:r,fontWeight:e=400,fontStyle:o="normal"}){return this.get({name:r,weight:e,style:o})}measure(r,e,{fontSize:o,letterSpacing:a=0}){return r.getAdvanceWidth(e,o,{letterSpacing:a/o})}getSVG(r,e,{fontSize:o,top:a,left:i,letterSpacing:n=0}){return r.getPath(e,i,a,o,{letterSpacing:n/o}).toPathData(1)}};function Ve({width:t,height:r,content:e}){return y("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,xmlns:"http://www.w3.org/2000/svg"},e)}var Je=new WeakMap;function pt(t,r){let e=Q();if(!e)throw new Error("Satori is not initialized.");let o;Je.has(r.fonts)?o=Je.get(r.fonts):Je.set(r.fonts,o=new Te(r.fonts));let a=e.Node.create();a.setWidth(r.width),a.setHeight(r.height),a.setFlexDirection(e.FLEX_DIRECTION_ROW),a.setFlexWrap(e.WRAP_WRAP),a.setAlignContent(e.ALIGN_AUTO),a.setAlignItems(e.ALIGN_FLEX_START),a.setJustifyContent(e.JUSTIFY_FLEX_START),a.setOverflow(e.OVERFLOW_HIDDEN);let i=pe(t,{id:"id",parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1,whiteSpace:"normal",_viewportWidth:r.width,_viewportHeight:r.height},parent:a,font:o,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});i.next(),a.calculateLayout(r.width,r.height,e.DIRECTION_LTR);let n=i.next([0,0]).value;return a.freeRecursive(),Ve({width:r.width,height:r.height,content:n})}export{pt as default,Tt as init}; | ||
//# sourceMappingURL=index.wasm.js.map |
{ | ||
"name": "satori", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "Satori converts HTML JSX to SVG string.", | ||
@@ -18,9 +18,8 @@ "module": "./dist/esm/index.js", | ||
"scripts": { | ||
"types": "tsc --noEmit", | ||
"dev": "NODE_ENV=development tsup src/index.ts --watch --ignore-watch playground", | ||
"build": "NODE_ENV=production pnpm run types && pnpm run build:asmjs && pnpm run build:wasm", | ||
"build:asmjs": "tsup", | ||
"build": "NODE_ENV=production pnpm run test && pnpm run build:default && pnpm run build:wasm", | ||
"build:default": "tsup", | ||
"build:wasm": "WASM=1 tsup", | ||
"test": "vitest run", | ||
"dev:test": "vitest" | ||
"test": "NODE_ENV=test vitest run --outputTruncateLength=9999999", | ||
"dev:test": "NODE_ENV=test vitest --update --outputTruncateLength=9999999" | ||
}, | ||
@@ -49,6 +48,7 @@ "repository": { | ||
"@types/yoga-layout": "^1.9.4", | ||
"@vitest/ui": "^0.7.6", | ||
"react": "^17.0.2", | ||
"tsup": "^5.11.13", | ||
"typescript": "^4.5.5", | ||
"vitest": "^0.2.5" | ||
"vitest": "0.7.6" | ||
}, | ||
@@ -55,0 +55,0 @@ "dependencies": { |
@@ -149,3 +149,3 @@ <h1 align="center"> | ||
| `background-color` | Supported | | ||
| `background-image` | Support `linear-gradient`, `url` | | ||
| `background-image` | Support `linear-gradient`, `radial-gradient`, `url` | | ||
| `word-break` | Supported | | ||
@@ -156,8 +156,8 @@ | `text-shadow` | Supported | | ||
| `background-size` | Support two-value size string such as `10px 20%` | | ||
| `background-clip` | TBD | | ||
| `background-repeat` | TBD | | ||
| `background-origin` | TBD | | ||
| `text-decoration` | TBD | | ||
| `line-height` | TBD | | ||
| `white-space` | TBD | | ||
| `white-space` | Support `normal`, `pre`, `pre-wrap` and `nowrap` | | ||
| `text-overflow` | Support `clip` and `ellipsis` | | ||
| `text-decoration` | Support line types `underline` and `line-through`, and styles `dotted`, `dashed`, `solid` | | ||
| `line-height` | Supported | | ||
| `background-clip` | Support `border-box` and `text` | | ||
| `background-repeat` | Supported | | ||
@@ -169,2 +169,4 @@ Note: | ||
3. `box-sizing` is set to `border-box` for all elements. | ||
4. `calc` isn't supported. | ||
5. `overflow: hidden` and `transform` can't be used together. | ||
@@ -171,0 +173,0 @@ ## Contribute |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
308249
265
204
9
2