Comparing version 0.0.13 to 0.0.14-beta.0
@@ -1,3 +0,3 @@ | ||
var nt=Object.defineProperty,Pt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptor,Mt=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertyNames,Et=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable;var St=(t,r,e)=>r in t?nt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,K=(t,r)=>{for(var e in r||(r={}))_t.call(r,e)&&St(t,e,r[e]);if(Et)for(var e of Et(r))Yt.call(r,e)&&St(t,e,r[e]);return t},Tt=(t,r)=>Pt(t,Mt(r)),zt=t=>nt(t,"__esModule",{value:!0});var Rt=(t,r)=>()=>(t&&(r=t(t=0)),r);var Ut=(t,r)=>{for(var e in r)nt(t,e,{get:r[e],enumerable:!0})},Xt=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Dt(r))!_t.call(t,a)&&(e||a!=="default")&&nt(t,a,{get:()=>r[a],enumerable:!(i=Bt(r,a))||i.enumerable});return t};var Ht=(t=>(r,e)=>t&&t.get(r)||(e=Xt(zt({}),r,1),t&&t.set(r,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var m=Rt(()=>{});var It={};Ut(It,{default:()=>Jt});import*as Vt from"yoga-layout-prebuilt";var Jt,Lt=Rt(()=>{m();Jt=Vt});m();m();m();var ot;{let t=(Lt(),Ht(It));t.default?ot=t.default:ot=t}function jt(t){ot=t}function B(){return ot}m();m();function ft(t){let r=typeof t;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function wt(t){return/^class\s/.test(Function.prototype.toString.call(t))}function q(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 O(t,r,e){let i=r[t];return typeof i=="undefined"?e:i}m();m();var At={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"}};m();var Kt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function lt(t){let r={};for(let e in t)Kt.has(e)&&(r[e]=t[e]);return r}m();import{getPropertyName as Ct,getStylesForProperty as qt}from"css-to-react-native";import Nt from"parse-css-dimension";import{parseElementStyle as Zt}from"css-background-parser";var Qt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Ft=[1,0,0,1,0,0];function te(t,r){return typeof r=="number"?Qt.has(t)?String(r):r+"px":r}function Ot(t,r){if(typeof t=="number")return t;try{let e=new Nt(t);if(e.type==="length")switch(e.unit){case"em":return e.value*r;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function it(t,r){let e=[];for(let o in t){let n=Ct(o);e.push([n,te(n,t[o])])}let i=e.reduce((o,n)=>{let s=Ct(n[0]),c=n[1];return Object.assign(o,qt(s,c,!0))},{});if(i.backgroundImage){let{backgrounds:o}=Zt(i);i.backgroundImage=o}let a=i.fontSize||r.fontSize;if(typeof a=="string")try{let o=new Nt(a);switch(o.unit){case"em":a=o.value*r.fontSize;break;case"rem":a=o.value*16;break}}catch{a=16}typeof i.fontSize!="undefined"&&(i.fontSize=a);for(let o in i){let n=i[o];if(typeof n=="string"){let s=Ot(n,a);typeof s!="undefined"&&(i[o]=s),n=i[o]}if(o==="opacity"&&(n=i[o]=n*r.opacity),o==="transform"){let s=[...Ft],c=n;for(let u of c){let y=Object.keys(u)[0],d=u[y],p=typeof d=="string"?Ot(d,a):d,f=[...Ft];switch(y){case"translateX":f[4]=p;break;case"translateY":f[5]=p;break;case"scaleX":f[0]=p;break;case"scaleY":f[3]=p;break;case"rotate":let g=p*Math.PI/180,$=Math.cos(g),L=Math.sin(g);f[0]=$,f[1]=L,f[2]=-L,f[3]=$;break;case"skewX":f[2]=Math.tan(p*Math.PI/180);break;case"skewY":f[1]=Math.tan(p*Math.PI/180);break}s=q(f,s)}i.transform=s}}return i}function ut(t,r,e,i,a){let o=B(),n=K(K(K({},e),it(At[r],e)),it(i,e));if(r==="img"){let s=parseInt(a.width),u=parseInt(a.height)/s;n.width||(n.width=s),n.height||(n.height=u*n.width)}return t.setDisplay(O(n.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),t.setAlignContent(O(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)),t.setAlignItems(O(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)),t.setAlignSelf(O(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)),t.setJustifyContent(O(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)),t.setFlexDirection(O(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)),t.setFlexWrap(O(n.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.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"?1: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(O(n.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),t.setMargin(o.EDGE_TOP,n.marginTop||0),t.setMargin(o.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(o.EDGE_LEFT,n.marginLeft||0),t.setMargin(o.EDGE_RIGHT,n.marginRight||0),t.setBorder(o.EDGE_TOP,n.borderWidth||0),t.setBorder(o.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(o.EDGE_LEFT,n.borderWidth||0),t.setBorder(o.EDGE_RIGHT,n.borderWidth||0),t.setPadding(o.EDGE_TOP,n.paddingTop||0),t.setPadding(o.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(o.EDGE_LEFT,n.paddingLeft||0),t.setPadding(o.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(O(n.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(o.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(o.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(o.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(o.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,lt(n)]}m();import{LineBreaker as ee}from"css-line-break";import{splitGraphemes as re}from"text-segmentation";m();m();function Q({left:t,top:r,width:e,height:i},a,o){let n;if(o)n=a;else{let s=t+e/2,c=r+i/2;n=q([1,0,0,1,s,c],q(a,[1,0,0,1,-s,-c])),a.__parent&&(n=q(a.__parent,n)),a.splice(0,6,...n)}return`matrix(${n.map(s=>s.toFixed(2)).join(",")})`}function ct({id:t,content:r,filter:e,left:i,top:a,width:o,height:n,isInheritingTransform:s,path:c,image:u,debug:y},d){let p="",f=1,g="";return d.transform&&(p=Q({left:i,top:a,width:o,height:n},d.transform,s)),d.opacity&&(f=+d.opacity),y&&(g=`<rect x="${i}" y="${a}" width="${o}" height="${c===null?.5:n}" fill="transparent" stroke="#575eff" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),u?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${u}" x="${i}" y="${a}" width="${o}" height="${n}" ${p?`transform="${p}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${e?"</g>":""}${g}`:c===null?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${a}" width="${o}" height="${n}" 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}"`:""} ${p?`transform="${p}"`:""} ${f!==1?`opacity="${f}"`:""}>${r}</text>${e?"</g>":""}${g}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<path fill="${d.color}" ${p?`transform="${p}"`:""} ${f!==1?`opacity="${f}"`:""} d="${c}"></path>${e?"</g>":""}${g}`}m();function J({id:t,width:r,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let a=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-a,0),n=Math.max(i.shadowOffset.width+a+r,r),s=Math.min(i.shadowOffset.height-a,0),c=Math.max(i.shadowOffset.height+a+e,e);return`<defs><filter id="satori_s-${t}" x="${o/r*100}%" y="${s/e*100}%" width="${(n-o)/r*100}%" height="${(c-s)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var tt="en",pt=typeof Intl!="undefined"&&"Segmenter"in Intl,ne=pt?new Intl.Segmenter(tt,{granularity:"word"}):null,oe=pt?new Intl.Segmenter(tt,{granularity:"grapheme"}):null,ie=[32,160,4961,65792,65793,4153,4241],ae=t=>{let r=ee(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=r.next()).done;)if(i.value){let a=i.value.slice(),o=[].map.call(a,s=>s.codePointAt(0)),n="";o.forEach(s=>{ie.includes(s)?(n.length&&e.push(n),e.push(String.fromCodePoint(s)),n=""):n+=String.fromCodePoint(s)}),n.length&&e.push(n)}return e};function mt(t,r){return pt?r==="word"?[...ne.segment(t)].map(e=>e.segment):[...oe.segment(t)].map(e=>e.segment):r==="word"?ae(t):re(t)}function*dt(t,r){let e=B(),{parentStyle:i,parent:a,font:o,id:n,isInheritingTransform:s,debug:c,embedFont:u,graphemeImages:y}=r;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(tt):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(tt):i.textTransform==="capitalize"&&(t=mt(t,"word").map(x=>mt(x,"grapheme").map((W,l)=>l===0?W.toLocaleUpperCase(tt):W).join("")).join(""));let d=O(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),p=mt(t,d),f=e.Node.create();f.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?f.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?f.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?f.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&f.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),a.insertChild(f,a.getChildCount());let g=o.getFont(i),$=g.ascender/g.unitsPerEm*i.fontSize,L=-(g.descender/g.unitsPerEm)*i.fontSize,w=($+L)*1.2,{textAlign:E}=i,v=[],P=[],A=[];f.setMeasureFunc((x,W,l,h)=>{let b=[],S="",C=0,H="",I=0,V=0,j=-1;v=[],P=[0];for(let Y=0;Y<p.length;Y++){let z=p[Y];if([" ",` | ||
`," ","\u3000"].includes(z))S+=z,C=o.measure(g,S,i),A[Y]=null;else{let Z=y&&y[z]?i.fontSize:o.measure(g,z,i);I||(S="",C=0);let Gt=C||",.!?:-@)>]}%#".indexOf(z[0])<0,$t=!I||!!C;Gt&&I+C+Z>x?(v.push(I),b.push(H),H=z,I=Z,P.push(1),j=-1):(H+=S+z,I+=C+Z,$t&&P[P.length-1]++),S="",C=0,$t&&j++,V=Math.max(V,I),A[Y]={y:b.length*w,x:I-Z,width:Z,line:b.length,lineIndex:j}}}return I&&(b.push(H),v.push(I)),b.length>1&&(V=x),{width:V,height:b.length*w}});let[M,D]=yield,U="";i.position==="absolute"&&f.calculateLayout();let{left:X,top:k,width:F}=f.getComputedLayout(),G=M+X,R=D+k;for(let x=0;x<p.length;x++){if(!A[x])continue;let W=p[x],l=null,h=null,b=A[x].y,S=A[x].x,C=A[x].width,H=w,I=F-v[A[x].line];if(E==="right"||E==="end")S+=I;else if(E==="center")S+=I/2;else if(E==="justify"){let j=A[x].line;if(j<v.length-1){let Y=P[j];S+=(Y>1?I/(Y-1):0)*A[x].lineIndex}}y&&y[W]?h=y[W]:u?l=o.getSVG(g,W,Tt(K({},i),{left:G+S,top:R+b,letterSpacing:i.letterSpacing})):b+=$;let V="";i.textShadowOffset&&(V=J({width:C,height:H,id:n},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius})),U+=ct({content:W,filter:V,id:n,left:G+S,top:R+b,width:C,height:H,isInheritingTransform:s,path:l,image:h,debug:c},i)}return U}m();m();m();var gt=gt||{};gt.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 h=new Error(r+": "+l);throw h.source=r,h}function i(){var l=a();return r.length>0&&e("Invalid input not EOF"),l}function a(){return E(o)}function o(){return n("linear-gradient",t.linearGradient,c)||n("repeating-linear-gradient",t.repeatingLinearGradient,c)||n("radial-gradient",t.radialGradient,d)||n("repeating-radial-gradient",t.repeatingRadialGradient,d)}function n(l,h,b){return s(h,function(S){var C=b();return C&&(x(t.comma)||e("Missing comma before color stops")),{type:l,orientation:C,colorStops:E(v)}})}function s(l,h){var b=x(l);if(b){x(t.startCall)||e("Missing (");var S=h(b);return x(t.endCall)||e("Missing )"),S}}function c(){return u()||y()}function u(){return R("directional",t.sideOrCorner,1)}function y(){return R("angular",t.angleValue,1)}function d(){var l,h=p(),b;return h&&(l=[],l.push(h),b=r,x(t.comma)&&(h=p(),h?l.push(h):r=b)),l}function p(){var l=f()||g();if(l)l.at=L();else{var h=$();if(h){l=h;var b=L();b&&(l.at=b)}else{var S=N();S&&(l={type:"default-radial",at:S})}}return l}function f(){var l=R("shape",/^(circle)/i,0);return l&&(l.style=G()||$()),l}function g(){var l=R("shape",/^(ellipse)/i,0);return l&&(l.style=k()||$()),l}function $(){return R("extent-keyword",t.extentKeywords,1)}function L(){if(R("position",/^at/,0)){var l=N();return l||e("Missing positioning value"),l}}function N(){var l=w();if(l.x||l.y)return{type:"position",value:l}}function w(){return{x:k(),y:k()}}function E(l){var h=l(),b=[];if(h)for(b.push(h);x(t.comma);)h=l(),h?b.push(h):e("One extra comma");return b}function v(){var l=P();return l||e("Expected color definition"),l.length=k(),l}function P(){return M()||U()||D()||A()}function A(){return R("literal",t.literalColor,0)}function M(){return R("hex",t.hexColor,1)}function D(){return s(t.rgbColor,function(){return{type:"rgb",value:E(X)}})}function U(){return s(t.rgbaColor,function(){return{type:"rgba",value:E(X)}})}function X(){return x(t.number)[1]}function k(){return R("%",t.percentageValue,1)||F()||G()}function F(){return R("position-keyword",t.positionKeywords,1)}function G(){return R("px",t.pixelValue,1)||R("em",t.emValue,1)}function R(l,h,b){var S=x(h);if(S)return{type:l,value:S[b]}}function x(l){var h,b;return b=/^[\n\r\t\s]+/.exec(r),b&&W(b[0].length),h=l.exec(r),h&&W(h[0].length),h}function W(l){r=r.substr(l)}return function(l){return r=l.toString(),i()}}();var vt=gt;function se(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 ht({id:t,width:r},{image:e}){if(e.startsWith("linear-gradient(")){let i=vt.parse(e)[0],a,o,n,s;if(i.orientation.type==="directional")[a,o,n,s]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let f=+i.orientation.value/180*Math.PI-Math.PI/2,g=Math.cos(f),$=Math.sin(f);a=0,o=0,n=g,s=$,n<0&&(a-=n,n=0),s<0&&(o-=s,s=0)}let c=r,u=[];for(let f of i.colorStops){let g=se(f);if(!u.length&&(u.push({offset:0,color:g}),typeof f.length=="undefined"||f.length.value==="0"))continue;let $=typeof f.length=="undefined"?void 0:f.length.type==="%"?f.length.value/100:f.length.value/c;u.push({offset:$,color:g})}u.length||u.push({offset:0,color:"transparent"});let y=u[u.length-1];y.offset!==1&&(typeof y.offset=="undefined"?y.offset=1:u.push({offset:1,color:y.color}));let d=0,p=1;for(let f=0;f<u.length;f++)if(typeof u[f].offset=="undefined"){for(p<f&&(p=f);typeof u[p].offset=="undefined";)p++;u[f].offset=(u[p].offset-u[d].offset)/(p-d)*(f-d)+u[d].offset}else d=f;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${a}" y1="${o}" x2="${n}" y2="${s}">${u.map(f=>`<stop offset="${f.offset*100}%" stop-color="${f.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}m();function at(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 et({left:t,top:r,width:e,height:i},a){let{borderTopLeftRadius:o,borderTopRightRadius:n,borderBottomLeftRadius:s,borderBottomRightRadius:c}=a;return o=Math.min(o||0,e,i),n=Math.min(n||0,e,i),s=Math.min(s||0,e,i),c=Math.min(c||0,e,i),!o&&!n&&!s&&!c?"":([o,n]=at(o,n,e),[o,s]=at(o,s,i),[n,c]=at(n,c,i),[s,c]=at(s,c,e),`M${t+o},${r} h${e-o-n} a${n},${n} 0 0 1 ${n},${n} v${i-n-c} a${c},${c} 0 0 1 ${-c},${c} h${c+s-e} a${s},${s} 0 0 1 ${-s},${-s} v${s+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function bt({id:t,left:r,top:e,width:i,height:a,isInheritingTransform:o,debug:n},s){if(s.display==="none")return"";let c="rect",u="transparent",y=0,d="",p="",f=[],g=1,$="";if(s.backgroundColor&&f.push(s.backgroundColor),s.borderWidth&&(y=s.borderWidth,u=s.borderColor),s.opacity&&(g=+s.opacity),s.transform&&(d=Q({left:r,top:e,width:i,height:a},s.transform,o)),s.backgroundImage){let w=s.backgroundImage.map((E,v)=>ht({id:t+"_"+v,width:i,height:a},E)).filter(Boolean);for(let E of w)p+=E[1],f.push(`url(#${E[0]})`)}let L=et({left:r,top:e,width:i,height:a},s);L&&(c="path");let N=J({width:i,height:a,id:t},s);return f.length||f.push("transparent"),n&&($=`<rect x="${r}" y="${e}" width="${i}" height="${a}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${p?`<defs>${p}</defs>`:""}${N?`${N}<g filter="url(#satori_s-${t})">`:""}${g!==1?`<g opacity="${g}">`:""}${f.map((w,E)=>w==="transparent"&&!(E===f.length-1&&y)?"":`<${c} x="${r}" y="${e}" width="${i}" height="${a}" fill="${w}" ${E===f.length-1&&y?`stroke="${u}" stroke-width="${y}"`:""} ${L?`d="${L}"`:""} ${d?`transform="${d}"`:""}></${c}>`).join("")}${g!==1?"</g>":""}${N?"</g>":""}${$}`}m();function yt({id:t,left:r,top:e,width:i,height:a,src:o,debug:n},s){if(s.display==="none")return"";let c="",u=1,y=s.objectFit==="contain"?"xMidYMid":s.objectFit==="cover"?"xMidYMid slice":"none",d=et({left:r,top:e,width:i,height:a},s);d&&(c=`<clipPath id="satori_c-${t}"><path x="${r}" y="${e}" width="${i}" height="${a}" d="${d}"></path></clipPath>`),s.opacity&&(u=+s.opacity);let p=J({width:i,height:a,id:t},s);return`${p}${p?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${o}" x="${r}" y="${e}" width="${i}" height="${a}" preserveAspectRatio="${y}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${p?"</g>":""}`}function*rt(t,r){let e=B(),{id:i,inheritedStyle:a,parent:o,font:n,debug:s,embedFont:c=!0,graphemeImages:u}=r;if(t===null||typeof t=="undefined")return yield,"";if(!ft(t)||typeof t.type=="function"){let F;if(!ft(t))F=dt(String(t),r);else{if(wt(t.type))throw new Error("Class component is not supported.");F=rt(t.type(t.props),r)}F.next();let G=yield;return F.next(G).value}let{type:y,props:d}=t,{style:p,children:f}=d,g=e.Node.create();o.insertChild(g,o.getChildCount());let[$,L]=ut(g,y,a,p,d),N=$.transform===a.transform;N||($.transform.__parent=a.transform);let w=typeof f=="undefined"?[]:[].concat(f),E=[],v=0;for(let F of w){let G=rt(F,{id:i*w.length+ ++v,parentStyle:$,inheritedStyle:L,isInheritingTransform:!0,parent:g,font:n,embedFont:c,debug:s,graphemeImages:u});G.next(),E.push(G)}let[P,A]=yield;$.position==="absolute"&&g.calculateLayout();let{left:M,top:D,width:U,height:X}=g.getComputedLayout();M+=P,D+=A;let k="";y==="img"?k=yt({id:i,left:M,top:D,width:U,height:X,src:d.src,isInheritingTransform:N,debug:s},$):k=bt({id:i,left:M,top:D,width:U,height:X,isInheritingTransform:N,debug:s},$);for(let F of E)k+=F.next([M,D]).value;return k}m();import kt from"opentype.js";var st=class{constructor(r){this.fonts=new Map;for(let e of r){let i=e.data,a="buffer"in i?kt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):kt.parse(i);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:i}){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(([o,n,s],[c,u,y])=>{if(n!==u)return n?!u||n===e?-1:u===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&u===500||e===500&&u===400?1:e<400?n<e&&u<e?u-n:n<e?-1:u<e?1:n-u:e<n&&e<u?n-u:e<n?-1:e<u?1:u-n:1;if(s!==y){if(s===i)return-1;if(y===i)return 1}return-1}),a[0][0]}getFont({fontFamily:r,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:r,weight:e,style:i})}measure(r,e,{fontSize:i,letterSpacing:a=0}){return r.getAdvanceWidth(e,i,{letterSpacing:a/i})}getSVG(r,e,{fontSize:i,top:a,left:o,letterSpacing:n=0}){return a+=r.ascender/r.unitsPerEm*i,r.getPath(e,o,a,i,{letterSpacing:n/i}).toPathData(2)}};m();function xt({width:t,height:r,content:e},i){return`<svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function Wt(t,r){let e=B();if(!e)throw new Error("Satori is not initialized.");let i=new st(r.fonts),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);let o=rt(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:a,font:i,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});o.next(),a.calculateLayout(r.width,r.height,e.DIRECTION_LTR);let n=o.next([0,0]).value;return xt({width:r.width,height:r.height,content:n})}export{Wt as default,jt as init}; | ||
var at=Object.defineProperty,zt=Object.defineProperties,Ut=Object.getOwnPropertyDescriptor,Xt=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertyNames,Tt=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var It=(t,r,e)=>r in t?at(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Z=(t,r)=>{for(var e in r||(r={}))Lt.call(r,e)&&It(t,e,r[e]);if(Tt)for(var e of Tt(r))Vt.call(r,e)&&It(t,e,r[e]);return t},wt=(t,r)=>zt(t,Xt(r)),Jt=t=>at(t,"__esModule",{value:!0});var At=(t,r)=>()=>(t&&(r=t(t=0)),r);var jt=(t,r)=>{for(var e in r)at(t,e,{get:r[e],enumerable:!0})},Kt=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Ht(r))!Lt.call(t,s)&&(e||s!=="default")&&at(t,s,{get:()=>r[s],enumerable:!(i=Ut(r,s))||i.enumerable});return t};var qt=(t=>(r,e)=>t&&t.get(r)||(e=Kt(Jt({}),r,1),t&&t.set(r,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var d=At(()=>{});var Ct={};jt(Ct,{default:()=>Qt});import*as Zt from"yoga-layout-prebuilt";var Qt,Ft=At(()=>{d();Qt=Zt});d();d();d();var st;{let t=(Ft(),qt(Ct));t.default?st=t.default:st=t}function te(t){st=t}function B(){return st}d();d();function ct(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 Q(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 F(t,r,e){let i=r[t];return typeof i=="undefined"?e:i}d();d();var Nt={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"}};d();var ee=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function mt(t){let r={};for(let e in t)ee.has(e)&&(r[e]=t[e]);return r}d();import{getPropertyName as vt,getStylesForProperty as re}from"css-to-react-native";import Gt from"parse-css-dimension";import{parseElementStyle as ne}from"css-background-parser";var oe=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),kt=[1,0,0,1,0,0];function ie(t,r){return typeof r=="number"?oe.has(t)?String(r):r+"px":r}function Wt(t,r){if(typeof t=="number")return t;try{let e=new Gt(t);if(e.type==="length")switch(e.unit){case"em":return e.value*r;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function ft(t,r){let e=[];for(let o in t){let n=vt(o);e.push([n,ie(n,t[o])])}let i=e.reduce((o,n)=>{let a=vt(n[0]),c=n[1];return Object.assign(o,re(a,c,!0))},{});if(i.backgroundImage){let{backgrounds:o}=ne(i);i.backgroundImage=o}let s=i.fontSize||r.fontSize;if(typeof s=="string")try{let o=new Gt(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);for(let o in i){let n=i[o];if(typeof n=="string"){let a=Wt(n,s);typeof a!="undefined"&&(i[o]=a),n=i[o]}if(o==="opacity"&&(n=i[o]=n*r.opacity),o==="transform"){let a=[...kt],c=n;for(let l of c){let p=Object.keys(l)[0],h=l[p],g=typeof h=="string"?Wt(h,s):h,f=[...kt];switch(p){case"translateX":f[4]=g;break;case"translateY":f[5]=g;break;case"scaleX":f[0]=g;break;case"scaleY":f[3]=g;break;case"rotate":let y=g*Math.PI/180,x=Math.cos(y),I=Math.sin(y);f[0]=x,f[1]=I,f[2]=-I,f[3]=x;break;case"skewX":f[2]=Math.tan(g*Math.PI/180);break;case"skewY":f[1]=Math.tan(g*Math.PI/180);break}a=Q(f,a)}i.transform=a}}return i}function dt(t,r,e,i,s){let o=B(),n=Z(Z(Z({},e),ft(Nt[r],e)),ft(i,e));if(r==="img"){let a=parseInt(s.width),l=parseInt(s.height)/a;n.width||(n.width=a),n.height||(n.height=l*n.width)}return t.setDisplay(F(n.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),t.setAlignContent(F(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)),t.setAlignItems(F(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)),t.setAlignSelf(F(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)),t.setJustifyContent(F(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)),t.setFlexDirection(F(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)),t.setFlexWrap(F(n.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.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"?1: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(F(n.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),t.setMargin(o.EDGE_TOP,n.marginTop||0),t.setMargin(o.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(o.EDGE_LEFT,n.marginLeft||0),t.setMargin(o.EDGE_RIGHT,n.marginRight||0),t.setBorder(o.EDGE_TOP,n.borderWidth||0),t.setBorder(o.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(o.EDGE_LEFT,n.borderWidth||0),t.setBorder(o.EDGE_RIGHT,n.borderWidth||0),t.setPadding(o.EDGE_TOP,n.paddingTop||0),t.setPadding(o.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(o.EDGE_LEFT,n.paddingLeft||0),t.setPadding(o.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(F(n.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(o.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(o.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(o.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(o.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,mt(n)]}d();import{LineBreaker as ae}from"css-line-break";import{splitGraphemes as se}from"text-segmentation";d();d();function et({left:t,top:r,width:e,height:i},s,o){let n;if(o)n=s;else{let a=t+e/2,c=r+i/2;n=Q([1,0,0,1,a,c],Q(s,[1,0,0,1,-a,-c])),s.__parent&&(n=Q(s.__parent,n)),s.splice(0,6,...n)}return`matrix(${n.map(a=>a.toFixed(2)).join(",")})`}function Pt({left:t,top:r,width:e,height:i,isInheritingTransform:s},o){let n="",a=1,c="";return o.transform&&(n=et({left:t,top:r,width:e,height:i},o.transform,s)),o.opacity&&(a=+o.opacity),{matrix:n,opacity:a}}function gt({id:t,content:r,filter:e,left:i,top:s,width:o,height:n,matrix:a,opacity:c,path:l,image:p,debug:h},g){let f="";return h&&(f=`<rect x="${i}" y="${s}" width="${o}" height="${l===null?.5:n}" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),p?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${p}" x="${i}" y="${s}" width="${o}" height="${n}" ${a?`transform="${a}"`:""} ${c!==1?`opacity="${c}"`:""}></image>${e?"</g>":""}${f}`:l===null?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${o}" height="${n}" fill="${g.color}" font-weight="${g.fontWeight}" font-style="${g.fontStyle}" font-size="${g.fontSize}" font-family="${g.fontFamily}" ${g.letterSpacing?`letter-spacing="${g.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${c!==1?`opacity="${c}"`:""}>${r}</text>${e?"</g>":""}${f}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<path fill="${g.color}" ${a?`transform="${a}"`:""} ${c!==1?`opacity="${c}"`:""} d="${l}"></path>${e?"</g>":""}${f}`}d();function j({id:t,width:r,height:e},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),c=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${o/r*100}%" y="${a/e*100}%" width="${(n-o)/r*100}%" height="${(c-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var rt="en",ht=typeof Intl!="undefined"&&"Segmenter"in Intl,fe=ht?new Intl.Segmenter(rt,{granularity:"word"}):null,le=ht?new Intl.Segmenter(rt,{granularity:"grapheme"}):null,ue=[32,160,4961,65792,65793,4153,4241],ce=t=>{let r=ae(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=r.next()).done;)if(i.value){let s=i.value.slice(),o=[].map.call(s,a=>a.codePointAt(0)),n="";o.forEach(a=>{ue.includes(a)?(n.length&&e.push(n),e.push(String.fromCodePoint(a)),n=""):n+=String.fromCodePoint(a)}),n.length&&e.push(n)}return e};function pt(t,r){return ht?r==="word"?[...fe.segment(t)].map(e=>e.segment):[...le.segment(t)].map(e=>e.segment):r==="word"?ce(t):se(t)}function*bt(t,r){let e=B(),{parentStyle:i,parent:s,font:o,id:n,isInheritingTransform:a,debug:c,embedFont:l,graphemeImages:p}=r;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(rt):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(rt):i.textTransform==="capitalize"&&(t=pt(t,"word").map(m=>pt(m,"grapheme").map((b,R)=>R===0?b.toLocaleUpperCase(rt):b).join("")).join(""));let h=F(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),g=pt(t,h),f=e.Node.create();f.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?f.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?f.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?f.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&f.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(f,s.getChildCount());let y=o.getFont(i),x=y.ascender/y.unitsPerEm*i.fontSize,I=-(y.descender/y.unitsPerEm)*i.fontSize,L=(x+I)*1.2,{textAlign:$}=i,N=[],P=[],w=[];f.setMeasureFunc((m,b,R,K)=>{let W=[],k="",G=0,V="",T=0,J=0,q=-1;N=[],P=[0];for(let U=0;U<g.length;U++){let X=g[U];if([" ",` | ||
`," ","\u3000"].includes(X))k+=X,G=o.measure(y,k,i),w[U]=null;else{let tt=p&&p[X]?i.fontSize:o.measure(y,X,i);T||(k="",G=0);let Yt=G||",.!?:-@)>]}%#".indexOf(X[0])<0,Rt=!T||!!G;Yt&&T+G+tt>m?(N.push(T),W.push(V),V=X,T=tt,P.push(1),q=-1):(V+=k+X,T+=G+tt,Rt&&P[P.length-1]++),k="",G=0,Rt&&q++,J=Math.max(J,T),w[U]={y:W.length*L,x:T-tt,width:tt,line:W.length,lineIndex:q}}}return T&&(W.push(V),N.push(T)),W.length>1&&(J=m),{width:J,height:W.length*L}});let[D,Y]=yield,H="";i.position==="absolute"&&f.calculateLayout();let{left:z,top:C,width:A,height:M}=f.getComputedLayout(),_=D+z,v=Y+C,{matrix:it,opacity:u}=Pt({left:z,top:C,width:A,height:M,isInheritingTransform:a},i);for(let m=0;m<g.length;m++){if(!w[m])continue;let b=g[m],R=null,K=null,W=w[m].y,k=w[m].x,G=w[m].width,V=L,T=A-N[w[m].line];if($==="right"||$==="end")k+=T;else if($==="center")k+=T/2;else if($==="justify"){let q=w[m].line;if(q<N.length-1){let U=P[q];k+=(U>1?T/(U-1):0)*w[m].lineIndex}}p&&p[b]?K=p[b]:l?R=o.getSVG(y,b,wt(Z({},i),{left:_+k,top:v+W,letterSpacing:i.letterSpacing})):W+=x;let J="";i.textShadowOffset&&(J=j({width:G,height:V,id:n},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius})),H+=gt({content:b,filter:J,id:n,left:_+k,top:v+W,width:G,height:V,matrix:it,opacity:u,path:R,image:K,debug:c},i)}return H}d();d();d();var yt=yt||{};yt.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(u){var m=new Error(r+": "+u);throw m.source=r,m}function i(){var u=s();return r.length>0&&e("Invalid input not EOF"),u}function s(){return $(o)}function o(){return n("linear-gradient",t.linearGradient,c)||n("repeating-linear-gradient",t.repeatingLinearGradient,c)||n("radial-gradient",t.radialGradient,h)||n("repeating-radial-gradient",t.repeatingRadialGradient,h)}function n(u,m,b){return a(m,function(R){var K=b();return K&&(v(t.comma)||e("Missing comma before color stops")),{type:u,orientation:K,colorStops:$(N)}})}function a(u,m){var b=v(u);if(b){v(t.startCall)||e("Missing (");var R=m(b);return v(t.endCall)||e("Missing )"),R}}function c(){return l()||p()}function l(){return _("directional",t.sideOrCorner,1)}function p(){return _("angular",t.angleValue,1)}function h(){var u,m=g(),b;return m&&(u=[],u.push(m),b=r,v(t.comma)&&(m=g(),m?u.push(m):r=b)),u}function g(){var u=f()||y();if(u)u.at=I();else{var m=x();if(m){u=m;var b=I();b&&(u.at=b)}else{var R=O();R&&(u={type:"default-radial",at:R})}}return u}function f(){var u=_("shape",/^(circle)/i,0);return u&&(u.style=M()||x()),u}function y(){var u=_("shape",/^(ellipse)/i,0);return u&&(u.style=C()||x()),u}function x(){return _("extent-keyword",t.extentKeywords,1)}function I(){if(_("position",/^at/,0)){var u=O();return u||e("Missing positioning value"),u}}function O(){var u=L();if(u.x||u.y)return{type:"position",value:u}}function L(){return{x:C(),y:C()}}function $(u){var m=u(),b=[];if(m)for(b.push(m);v(t.comma);)m=u(),m?b.push(m):e("One extra comma");return b}function N(){var u=P();return u||e("Expected color definition"),u.length=C(),u}function P(){return D()||H()||Y()||w()}function w(){return _("literal",t.literalColor,0)}function D(){return _("hex",t.hexColor,1)}function Y(){return a(t.rgbColor,function(){return{type:"rgb",value:$(z)}})}function H(){return a(t.rgbaColor,function(){return{type:"rgba",value:$(z)}})}function z(){return v(t.number)[1]}function C(){return _("%",t.percentageValue,1)||A()||M()}function A(){return _("position-keyword",t.positionKeywords,1)}function M(){return _("px",t.pixelValue,1)||_("em",t.emValue,1)}function _(u,m,b){var R=v(m);if(R)return{type:u,value:R[b]}}function v(u){var m,b;return b=/^[\n\r\t\s]+/.exec(r),b&&it(b[0].length),m=u.exec(r),m&&it(m[0].length),m}function it(u){r=r.substr(u)}return function(u){return r=u.toString(),i()}}();var Mt=yt;function me(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({id:t,width:r},{image:e}){if(e.startsWith("linear-gradient(")){let i=Mt.parse(e)[0],s,o,n,a;if(i.orientation.type==="directional")[s,o,n,a]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let f=+i.orientation.value/180*Math.PI-Math.PI/2,y=Math.cos(f),x=Math.sin(f);s=0,o=0,n=y,a=x,n<0&&(s-=n,n=0),a<0&&(o-=a,a=0)}let c=r,l=[];for(let f of i.colorStops){let y=me(f);if(!l.length&&(l.push({offset:0,color:y}),typeof f.length=="undefined"||f.length.value==="0"))continue;let x=typeof f.length=="undefined"?void 0:f.length.type==="%"?f.length.value/100:f.length.value/c;l.push({offset:x,color:y})}l.length||l.push({offset:0,color:"transparent"});let p=l[l.length-1];p.offset!==1&&(typeof p.offset=="undefined"?p.offset=1:l.push({offset:1,color:p.color}));let h=0,g=1;for(let f=0;f<l.length;f++)if(typeof l[f].offset=="undefined"){for(g<f&&(g=f);typeof l[g].offset=="undefined";)g++;l[f].offset=(l[g].offset-l[h].offset)/(g-h)*(f-h)+l[h].offset}else h=f;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${s}" y1="${o}" x2="${n}" y2="${a}">${l.map(f=>`<stop offset="${f.offset*100}%" stop-color="${f.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}d();function lt(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 nt({left:t,top:r,width:e,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:n,borderBottomLeftRadius:a,borderBottomRightRadius:c}=s;return o=Math.min(o||0,e,i),n=Math.min(n||0,e,i),a=Math.min(a||0,e,i),c=Math.min(c||0,e,i),!o&&!n&&!a&&!c?"":([o,n]=lt(o,n,e),[o,a]=lt(o,a,i),[n,c]=lt(n,c,i),[a,c]=lt(a,c,e),`M${t+o},${r} h${e-o-n} a${n},${n} 0 0 1 ${n},${n} v${i-n-c} a${c},${c} 0 0 1 ${-c},${c} h${c+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function $t({id:t,left:r,top:e,width:i,height:s,isInheritingTransform:o,debug:n},a){if(a.display==="none")return"";let c="rect",l="transparent",p=0,h="",g="",f=[],y=1,x="";if(a.backgroundColor&&f.push(a.backgroundColor),a.borderWidth&&(p=a.borderWidth,l=a.borderColor),a.opacity&&(y=+a.opacity),a.transform&&(h=et({left:r,top:e,width:i,height:s},a.transform,o)),a.backgroundImage){let L=a.backgroundImage.map(($,N)=>xt({id:t+"_"+N,width:i,height:s},$)).filter(Boolean);for(let $ of L)g+=$[1],f.push(`url(#${$[0]})`)}let I=nt({left:r,top:e,width:i,height:s},a);I&&(c="path");let O=j({width:i,height:s,id:t},a);return f.length||f.push("transparent"),n&&(x=`<rect x="${r}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${h?`transform="${h}"`:""}></rect>`),`${g?`<defs>${g}</defs>`:""}${O?`${O}<g filter="url(#satori_s-${t})">`:""}${y!==1?`<g opacity="${y}">`:""}${f.map((L,$)=>L==="transparent"&&!($===f.length-1&&p)?"":`<${c} x="${r}" y="${e}" width="${i}" height="${s}" fill="${L}" ${$===f.length-1&&p?`stroke="${l}" stroke-width="${p}"`:""} ${I?`d="${I}"`:""} ${h?`transform="${h}"`:""}></${c}>`).join("")}${y!==1?"</g>":""}${O?"</g>":""}${x}`}d();function Et({id:t,left:r,top:e,width:i,height:s,src:o,debug:n},a){if(a.display==="none")return"";let c="",l=1,p=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",h=nt({left:r,top:e,width:i,height:s},a);h&&(c=`<clipPath id="satori_c-${t}"><path x="${r}" y="${e}" width="${i}" height="${s}" d="${h}"></path></clipPath>`),a.opacity&&(l=+a.opacity);let g=j({width:i,height:s,id:t},a);return`${g}${g?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${o}" x="${r}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${p}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${l!==1?`opacity="${l}"`:""}></image>${g?"</g>":""}`}function*ot(t,r){let e=B(),{id:i,inheritedStyle:s,parent:o,font:n,debug:a,embedFont:c=!0,graphemeImages:l}=r;if(t===null||typeof t=="undefined")return yield,"";if(!ct(t)||typeof t.type=="function"){let A;if(!ct(t))A=bt(String(t),r);else{if(Ot(t.type))throw new Error("Class component is not supported.");A=ot(t.type(t.props),r)}A.next();let M=yield;return A.next(M).value}let{type:p,props:h}=t,{style:g,children:f}=h,y=e.Node.create();o.insertChild(y,o.getChildCount());let[x,I]=dt(y,p,s,g,h),O=x.transform===s.transform;O||(x.transform.__parent=s.transform);let L=typeof f=="undefined"?[]:[].concat(f),$=[],N=0;for(let A of L){let M=ot(A,{id:i*L.length+ ++N,parentStyle:x,inheritedStyle:I,isInheritingTransform:!0,parent:y,font:n,embedFont:c,debug:a,graphemeImages:l});M.next(),$.push(M)}let[P,w]=yield;x.position==="absolute"&&y.calculateLayout();let{left:D,top:Y,width:H,height:z}=y.getComputedLayout();D+=P,Y+=w;let C="";p==="img"?C=Et({id:i,left:D,top:Y,width:H,height:z,src:h.src,isInheritingTransform:O,debug:a},x):C=$t({id:i,left:D,top:Y,width:H,height:z,isInheritingTransform:O,debug:a},x);for(let A of $)C+=A.next([D,Y]).value;return C}d();import Bt from"opentype.js";var ut=class{constructor(r){this.fonts=new Map;for(let e of r){let i=e.data,s="buffer"in i?Bt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Bt.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:r,weight:e,style:i}){if(!this.fonts.has(r))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(r)];return s.sort(([o,n,a],[c,l,p])=>{if(n!==l)return n?!l||n===e?-1:l===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&l===500||e===500&&l===400?1:e<400?n<e&&l<e?l-n:n<e?-1:l<e?1:n-l:e<n&&e<l?n-l:e<n?-1:e<l?1:l-n:1;if(a!==p){if(a===i)return-1;if(p===i)return 1}return-1}),s[0][0]}getFont({fontFamily:r,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:r,weight:e,style:i})}measure(r,e,{fontSize:i,letterSpacing:s=0}){return r.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(r,e,{fontSize:i,top:s,left:o,letterSpacing:n=0}){return s+=r.ascender/r.unitsPerEm*i,r.getPath(e,o,s,i,{letterSpacing:n/i}).toPathData(2)}};d();function St({width:t,height:r,content:e},i){return`<svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var _t=new WeakMap;function Dt(t,r){let e=B();if(!e)throw new Error("Satori is not initialized.");let i;_t.has(r.fonts)?i=_t.get(r.fonts):_t.set(r.fonts,i=new ut(r.fonts));let s=e.Node.create();s.setWidth(r.width),s.setHeight(r.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let o=ot(t,{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,e.DIRECTION_LTR);let n=o.next([0,0]).value;return St({width:r.width,height:r.height,content:n})}export{Dt as default,te as init}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
var Ot=Object.defineProperty,Nt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var yt=Object.getOwnPropertySymbols;var kt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable;var xt=(t,o,e)=>o in t?Ot(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,j=(t,o)=>{for(var e in o||(o={}))kt.call(o,e)&&xt(t,e,o[e]);if(yt)for(var e of yt(o))Wt.call(o,e)&&xt(t,e,o[e]);return t},$t=(t,o)=>Nt(t,vt(o));var Et;function Gt(t){Et=t}function P(){return Et}function it(t){let o=typeof t;return!(o==="number"||o==="bigint"||o==="string"||o==="boolean")}function St(t){return/^class\s/.test(Function.prototype.toString.call(t))}function K(t,o){return[t[0]*o[0]+t[2]*o[1],t[1]*o[0]+t[3]*o[1],t[0]*o[2]+t[2]*o[3],t[1]*o[2]+t[3]*o[3],t[0]*o[4]+t[2]*o[5]+t[4],t[1]*o[4]+t[3]*o[5]+t[5]]}function F(t,o,e){let i=o[t];return typeof i=="undefined"?e:i}var _t={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 Pt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function at(t){let o={};for(let e in t)Pt.has(e)&&(o[e]=t[e]);return o}import{getPropertyName as Tt,getStylesForProperty as Bt}from"css-to-react-native";import Lt from"parse-css-dimension";import{parseElementStyle as Mt}from"css-background-parser";var Dt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Rt=[1,0,0,1,0,0];function Yt(t,o){return typeof o=="number"?Dt.has(t)?String(o):o+"px":o}function It(t,o){if(typeof t=="number")return t;try{let e=new Lt(t);if(e.type==="length")switch(e.unit){case"em":return e.value*o;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function rt(t,o){let e=[];for(let n in t){let r=Tt(n);e.push([r,Yt(r,t[n])])}let i=e.reduce((n,r)=>{let a=Tt(r[0]),c=r[1];return Object.assign(n,Bt(a,c,!0))},{});if(i.backgroundImage){let{backgrounds:n}=Mt(i);i.backgroundImage=n}let s=i.fontSize||o.fontSize;if(typeof s=="string")try{let n=new Lt(s);switch(n.unit){case"em":s=n.value*o.fontSize;break;case"rem":s=n.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s);for(let n in i){let r=i[n];if(typeof r=="string"){let a=It(r,s);typeof a!="undefined"&&(i[n]=a),r=i[n]}if(n==="opacity"&&(r=i[n]=r*o.opacity),n==="transform"){let a=[...Rt],c=r;for(let u of c){let b=Object.keys(u)[0],d=u[b],m=typeof d=="string"?It(d,s):d,f=[...Rt];switch(b){case"translateX":f[4]=m;break;case"translateY":f[5]=m;break;case"scaleX":f[0]=m;break;case"scaleY":f[3]=m;break;case"rotate":let g=m*Math.PI/180,x=Math.cos(g),I=Math.sin(g);f[0]=x,f[1]=I,f[2]=-I,f[3]=x;break;case"skewX":f[2]=Math.tan(m*Math.PI/180);break;case"skewY":f[1]=Math.tan(m*Math.PI/180);break}a=K(f,a)}i.transform=a}}return i}function st(t,o,e,i,s){let n=P(),r=j(j(j({},e),rt(_t[o],e)),rt(i,e));if(o==="img"){let a=parseInt(s.width),u=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=u*r.width)}return t.setDisplay(F(r.display,{flex:n.DISPLAY_FLEX,none:n.DISPLAY_NONE},n.DISPLAY_FLEX)),t.setAlignContent(F(r.alignContent,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,"space-between":n.ALIGN_SPACE_BETWEEN,"space-around":n.ALIGN_SPACE_AROUND,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setAlignItems(F(r.alignItems,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_FLEX_START)),t.setAlignSelf(F(r.alignSelf,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setJustifyContent(F(r.justifyContent,{center:n.JUSTIFY_CENTER,"flex-start":n.JUSTIFY_FLEX_START,"flex-end":n.JUSTIFY_FLEX_END,"space-between":n.JUSTIFY_SPACE_BETWEEN,"space-around":n.JUSTIFY_SPACE_AROUND},n.JUSTIFY_FLEX_START)),t.setFlexDirection(F(r.flexDirection,{row:n.FLEX_DIRECTION_ROW,column:n.FLEX_DIRECTION_COLUMN,"row-reverse":n.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":n.FLEX_DIRECTION_COLUMN_REVERSE},n.FLEX_DIRECTION_ROW)),t.setFlexWrap(F(r.flexWrap,{wrap:n.WRAP_WRAP,nowrap:n.WRAP_NO_WRAP,"wrap-reverse":n.WRAP_WRAP_REVERSE},n.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(F(r.overflow,{visible:n.OVERFLOW_VISIBLE,hidden:n.OVERFLOW_HIDDEN},n.OVERFLOW_VISIBLE)),t.setMargin(n.EDGE_TOP,r.marginTop||0),t.setMargin(n.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(n.EDGE_LEFT,r.marginLeft||0),t.setMargin(n.EDGE_RIGHT,r.marginRight||0),t.setBorder(n.EDGE_TOP,r.borderWidth||0),t.setBorder(n.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(n.EDGE_LEFT,r.borderWidth||0),t.setBorder(n.EDGE_RIGHT,r.borderWidth||0),t.setPadding(n.EDGE_TOP,r.paddingTop||0),t.setPadding(n.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(n.EDGE_LEFT,r.paddingLeft||0),t.setPadding(n.EDGE_RIGHT,r.paddingRight||0),t.setPositionType(F(r.position,{absolute:n.POSITION_TYPE_ABSOLUTE,relative:n.POSITION_TYPE_RELATIVE},n.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(n.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(n.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(n.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(n.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,at(r)]}import{LineBreaker as zt}from"css-line-break";import{splitGraphemes as Ut}from"text-segmentation";function Z({left:t,top:o,width:e,height:i},s,n){let r;if(n)r=s;else{let a=t+e/2,c=o+i/2;r=K([1,0,0,1,a,c],K(s,[1,0,0,1,-a,-c])),s.__parent&&(r=K(s.__parent,r)),s.splice(0,6,...r)}return`matrix(${r.map(a=>a.toFixed(2)).join(",")})`}function ft({id:t,content:o,filter:e,left:i,top:s,width:n,height:r,isInheritingTransform:a,path:c,image:u,debug:b},d){let m="",f=1,g="";return d.transform&&(m=Z({left:i,top:s,width:n,height:r},d.transform,a)),d.opacity&&(f=+d.opacity),b&&(g=`<rect x="${i}" y="${s}" width="${n}" height="${c===null?.5:r}" fill="transparent" stroke="#575eff" stroke-width="1" ${m?`transform="${m}"`:""}></rect>`),u?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${u}" x="${i}" y="${s}" width="${n}" height="${r}" ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${e?"</g>":""}${g}`:c===null?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${n}" 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}"`:""} ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""}>${o}</text>${e?"</g>":""}${g}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<path fill="${d.color}" ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""} d="${c}"></path>${e?"</g>":""}${g}`}function V({id:t,width:o,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,n=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+o,o),a=Math.min(i.shadowOffset.height-s,0),c=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${n/o*100}%" y="${a/e*100}%" width="${(r-n)/o*100}%" height="${(c-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var Q="en",ut=typeof Intl!="undefined"&&"Segmenter"in Intl,Xt=ut?new Intl.Segmenter(Q,{granularity:"word"}):null,Ht=ut?new Intl.Segmenter(Q,{granularity:"grapheme"}):null,Vt=[32,160,4961,65792,65793,4153,4241],Jt=t=>{let o=zt(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=o.next()).done;)if(i.value){let s=i.value.slice(),n=[].map.call(s,a=>a.codePointAt(0)),r="";n.forEach(a=>{Vt.includes(a)?(r.length&&e.push(r),e.push(String.fromCodePoint(a)),r=""):r+=String.fromCodePoint(a)}),r.length&&e.push(r)}return e};function lt(t,o){return ut?o==="word"?[...Xt.segment(t)].map(e=>e.segment):[...Ht.segment(t)].map(e=>e.segment):o==="word"?Jt(t):Ut(t)}function*ct(t,o){let e=P(),{parentStyle:i,parent:s,font:n,id:r,isInheritingTransform:a,debug:c,embedFont:u,graphemeImages:b}=o;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(Q):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(Q):i.textTransform==="capitalize"&&(t=lt(t,"word").map(y=>lt(y,"grapheme").map((k,l)=>l===0?k.toLocaleUpperCase(Q):k).join("")).join(""));let d=F(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),m=lt(t,d),f=e.Node.create();f.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?f.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?f.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?f.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&f.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(f,s.getChildCount());let g=n.getFont(i),x=g.ascender/g.unitsPerEm*i.fontSize,I=-(g.descender/g.unitsPerEm)*i.fontSize,L=(x+I)*1.2,{textAlign:$}=i,N=[],G=[],w=[];f.setMeasureFunc((y,k,l,p)=>{let h=[],E="",A=0,X="",R=0,H=0,J=-1;N=[],G=[0];for(let D=0;D<m.length;D++){let Y=m[D];if([" ",` | ||
`," ","\u3000"].includes(Y))E+=Y,A=n.measure(g,E,i),w[D]=null;else{let q=b&&b[Y]?i.fontSize:n.measure(g,Y,i);R||(E="",A=0);let Ft=A||",.!?:-@)>]}%#".indexOf(Y[0])<0,bt=!R||!!A;Ft&&R+A+q>y?(N.push(R),h.push(X),X=Y,R=q,G.push(1),J=-1):(X+=E+Y,R+=A+q,bt&&G[G.length-1]++),E="",A=0,bt&&J++,H=Math.max(H,R),w[D]={y:h.length*L,x:R-q,width:q,line:h.length,lineIndex:J}}}return R&&(h.push(X),N.push(R)),h.length>1&&(H=y),{width:H,height:h.length*L}});let[B,M]=yield,z="";i.position==="absolute"&&f.calculateLayout();let{left:U,top:v,width:C}=f.getComputedLayout(),W=B+U,T=M+v;for(let y=0;y<m.length;y++){if(!w[y])continue;let k=m[y],l=null,p=null,h=w[y].y,E=w[y].x,A=w[y].width,X=L,R=C-N[w[y].line];if($==="right"||$==="end")E+=R;else if($==="center")E+=R/2;else if($==="justify"){let J=w[y].line;if(J<N.length-1){let D=G[J];E+=(D>1?R/(D-1):0)*w[y].lineIndex}}b&&b[k]?p=b[k]:u?l=n.getSVG(g,k,$t(j({},i),{left:W+E,top:T+h,letterSpacing:i.letterSpacing})):h+=x;let H="";i.textShadowOffset&&(H=V({width:A,height:X,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius})),z+=ft({content:k,filter:H,id:r,left:W+E,top:T+h,width:A,height:X,isInheritingTransform:a,path:l,image:p,debug:c},i)}return z}var mt=mt||{};mt.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]+\.?))/},o="";function e(l){var p=new Error(o+": "+l);throw p.source=o,p}function i(){var l=s();return o.length>0&&e("Invalid input not EOF"),l}function s(){return $(n)}function n(){return r("linear-gradient",t.linearGradient,c)||r("repeating-linear-gradient",t.repeatingLinearGradient,c)||r("radial-gradient",t.radialGradient,d)||r("repeating-radial-gradient",t.repeatingRadialGradient,d)}function r(l,p,h){return a(p,function(E){var A=h();return A&&(y(t.comma)||e("Missing comma before color stops")),{type:l,orientation:A,colorStops:$(N)}})}function a(l,p){var h=y(l);if(h){y(t.startCall)||e("Missing (");var E=p(h);return y(t.endCall)||e("Missing )"),E}}function c(){return u()||b()}function u(){return T("directional",t.sideOrCorner,1)}function b(){return T("angular",t.angleValue,1)}function d(){var l,p=m(),h;return p&&(l=[],l.push(p),h=o,y(t.comma)&&(p=m(),p?l.push(p):o=h)),l}function m(){var l=f()||g();if(l)l.at=I();else{var p=x();if(p){l=p;var h=I();h&&(l.at=h)}else{var E=O();E&&(l={type:"default-radial",at:E})}}return l}function f(){var l=T("shape",/^(circle)/i,0);return l&&(l.style=W()||x()),l}function g(){var l=T("shape",/^(ellipse)/i,0);return l&&(l.style=v()||x()),l}function x(){return T("extent-keyword",t.extentKeywords,1)}function I(){if(T("position",/^at/,0)){var l=O();return l||e("Missing positioning value"),l}}function O(){var l=L();if(l.x||l.y)return{type:"position",value:l}}function L(){return{x:v(),y:v()}}function $(l){var p=l(),h=[];if(p)for(h.push(p);y(t.comma);)p=l(),p?h.push(p):e("One extra comma");return h}function N(){var l=G();return l||e("Expected color definition"),l.length=v(),l}function G(){return B()||z()||M()||w()}function w(){return T("literal",t.literalColor,0)}function B(){return T("hex",t.hexColor,1)}function M(){return a(t.rgbColor,function(){return{type:"rgb",value:$(U)}})}function z(){return a(t.rgbaColor,function(){return{type:"rgba",value:$(U)}})}function U(){return y(t.number)[1]}function v(){return T("%",t.percentageValue,1)||C()||W()}function C(){return T("position-keyword",t.positionKeywords,1)}function W(){return T("px",t.pixelValue,1)||T("em",t.emValue,1)}function T(l,p,h){var E=y(p);if(E)return{type:l,value:E[h]}}function y(l){var p,h;return h=/^[\n\r\t\s]+/.exec(o),h&&k(h[0].length),p=l.exec(o),p&&k(p[0].length),p}function k(l){o=o.substr(l)}return function(l){return o=l.toString(),i()}}();var wt=mt;function jt(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 dt({id:t,width:o},{image:e}){if(e.startsWith("linear-gradient(")){let i=wt.parse(e)[0],s,n,r,a;if(i.orientation.type==="directional")[s,n,r,a]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let f=+i.orientation.value/180*Math.PI-Math.PI/2,g=Math.cos(f),x=Math.sin(f);s=0,n=0,r=g,a=x,r<0&&(s-=r,r=0),a<0&&(n-=a,a=0)}let c=o,u=[];for(let f of i.colorStops){let g=jt(f);if(!u.length&&(u.push({offset:0,color:g}),typeof f.length=="undefined"||f.length.value==="0"))continue;let x=typeof f.length=="undefined"?void 0:f.length.type==="%"?f.length.value/100:f.length.value/c;u.push({offset:x,color:g})}u.length||u.push({offset:0,color:"transparent"});let b=u[u.length-1];b.offset!==1&&(typeof b.offset=="undefined"?b.offset=1:u.push({offset:1,color:b.color}));let d=0,m=1;for(let f=0;f<u.length;f++)if(typeof u[f].offset=="undefined"){for(m<f&&(m=f);typeof u[m].offset=="undefined";)m++;u[f].offset=(u[m].offset-u[d].offset)/(m-d)*(f-d)+u[d].offset}else d=f;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${s}" y1="${n}" x2="${r}" y2="${a}">${u.map(f=>`<stop offset="${f.offset*100}%" stop-color="${f.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}function nt(t,o,e){return e<t+o&&(e/2<t&&e/2<o?t=o=e/2:e/2<t?t=e-o:e/2<o&&(o=e-t)),[t,o]}function tt({left:t,top:o,width:e,height:i},s){let{borderTopLeftRadius:n,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:c}=s;return n=Math.min(n||0,e,i),r=Math.min(r||0,e,i),a=Math.min(a||0,e,i),c=Math.min(c||0,e,i),!n&&!r&&!a&&!c?"":([n,r]=nt(n,r,e),[n,a]=nt(n,a,i),[r,c]=nt(r,c,i),[a,c]=nt(a,c,e),`M${t+n},${o} h${e-n-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-c} a${c},${c} 0 0 1 ${-c},${c} h${c+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+n-i} a${n},${n} 0 0 1 ${n},${-n}`)}function gt({id:t,left:o,top:e,width:i,height:s,isInheritingTransform:n,debug:r},a){if(a.display==="none")return"";let c="rect",u="transparent",b=0,d="",m="",f=[],g=1,x="";if(a.backgroundColor&&f.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,u=a.borderColor),a.opacity&&(g=+a.opacity),a.transform&&(d=Z({left:o,top:e,width:i,height:s},a.transform,n)),a.backgroundImage){let L=a.backgroundImage.map(($,N)=>dt({id:t+"_"+N,width:i,height:s},$)).filter(Boolean);for(let $ of L)m+=$[1],f.push(`url(#${$[0]})`)}let I=tt({left:o,top:e,width:i,height:s},a);I&&(c="path");let O=V({width:i,height:s,id:t},a);return f.length||f.push("transparent"),r&&(x=`<rect x="${o}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${O?`${O}<g filter="url(#satori_s-${t})">`:""}${g!==1?`<g opacity="${g}">`:""}${f.map((L,$)=>L==="transparent"&&!($===f.length-1&&b)?"":`<${c} x="${o}" y="${e}" width="${i}" height="${s}" fill="${L}" ${$===f.length-1&&b?`stroke="${u}" stroke-width="${b}"`:""} ${I?`d="${I}"`:""} ${d?`transform="${d}"`:""}></${c}>`).join("")}${g!==1?"</g>":""}${O?"</g>":""}${x}`}function pt({id:t,left:o,top:e,width:i,height:s,src:n,debug:r},a){if(a.display==="none")return"";let c="",u=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",d=tt({left:o,top:e,width:i,height:s},a);d&&(c=`<clipPath id="satori_c-${t}"><path x="${o}" y="${e}" width="${i}" height="${s}" d="${d}"></path></clipPath>`),a.opacity&&(u=+a.opacity);let m=V({width:i,height:s,id:t},a);return`${m}${m?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${n}" x="${o}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${m?"</g>":""}`}function*et(t,o){let e=P(),{id:i,inheritedStyle:s,parent:n,font:r,debug:a,embedFont:c=!0,graphemeImages:u}=o;if(t===null||typeof t=="undefined")return yield,"";if(!it(t)||typeof t.type=="function"){let C;if(!it(t))C=ct(String(t),o);else{if(St(t.type))throw new Error("Class component is not supported.");C=et(t.type(t.props),o)}C.next();let W=yield;return C.next(W).value}let{type:b,props:d}=t,{style:m,children:f}=d,g=e.Node.create();n.insertChild(g,n.getChildCount());let[x,I]=st(g,b,s,m,d),O=x.transform===s.transform;O||(x.transform.__parent=s.transform);let L=typeof f=="undefined"?[]:[].concat(f),$=[],N=0;for(let C of L){let W=et(C,{id:i*L.length+ ++N,parentStyle:x,inheritedStyle:I,isInheritingTransform:!0,parent:g,font:r,embedFont:c,debug:a,graphemeImages:u});W.next(),$.push(W)}let[G,w]=yield;x.position==="absolute"&&g.calculateLayout();let{left:B,top:M,width:z,height:U}=g.getComputedLayout();B+=G,M+=w;let v="";b==="img"?v=pt({id:i,left:B,top:M,width:z,height:U,src:d.src,isInheritingTransform:O,debug:a},x):v=gt({id:i,left:B,top:M,width:z,height:U,isInheritingTransform:O,debug:a},x);for(let C of $)v+=C.next([B,M]).value;return v}import At from"opentype.js";var ot=class{constructor(o){this.fonts=new Map;for(let e of o){let i=e.data,s="buffer"in i?At.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):At.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:o,weight:e,style:i}){if(!this.fonts.has(o))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(o)];return s.sort(([n,r,a],[c,u,b])=>{if(r!==u)return r?!u||r===e?-1:u===e?1:e===400&&r===500||e===500&&r===400?-1:e===400&&u===500||e===500&&u===400?1:e<400?r<e&&u<e?u-r:r<e?-1:u<e?1:r-u:e<r&&e<u?r-u:e<r?-1:e<u?1:u-r:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:o,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:o,weight:e,style:i})}measure(o,e,{fontSize:i,letterSpacing:s=0}){return o.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(o,e,{fontSize:i,top:s,left:n,letterSpacing:r=0}){return s+=o.ascender/o.unitsPerEm*i,o.getPath(e,n,s,i,{letterSpacing:r/i}).toPathData(2)}};function ht({width:t,height:o,content:e},i){return`<svg width="${t}" height="${o}" viewBox="0 0 ${t} ${o}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function Ct(t,o){let e=P();if(!e)throw new Error("Satori is not initialized.");let i=new ot(o.fonts),s=e.Node.create();s.setWidth(o.width),s.setHeight(o.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let n=et(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:o.embedFont,debug:o.debug,graphemeImages:o.graphemeImages});n.next(),s.calculateLayout(o.width,o.height,e.DIRECTION_LTR);let r=n.next([0,0]).value;return ht({width:o.width,height:o.height,content:r})}export{Ct as default,Gt as init}; | ||
var Gt=Object.defineProperty,Pt=Object.defineProperties;var Mt=Object.getOwnPropertyDescriptors;var St=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var _t=(t,o,e)=>o in t?Gt(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,q=(t,o)=>{for(var e in o||(o={}))Bt.call(o,e)&&_t(t,e,o[e]);if(St)for(var e of St(o))Dt.call(o,e)&&_t(t,e,o[e]);return t},Rt=(t,o)=>Pt(t,Mt(o));var Tt;function Yt(t){Tt=t}function M(){return Tt}function ft(t){let o=typeof t;return!(o==="number"||o==="bigint"||o==="string"||o==="boolean")}function It(t){return/^class\s/.test(Function.prototype.toString.call(t))}function Z(t,o){return[t[0]*o[0]+t[2]*o[1],t[1]*o[0]+t[3]*o[1],t[0]*o[2]+t[2]*o[3],t[1]*o[2]+t[3]*o[3],t[0]*o[4]+t[2]*o[5]+t[4],t[1]*o[4]+t[3]*o[5]+t[5]]}function C(t,o,e){let i=o[t];return typeof i=="undefined"?e:i}var Lt={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 zt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function lt(t){let o={};for(let e in t)zt.has(e)&&(o[e]=t[e]);return o}import{getPropertyName as wt,getStylesForProperty as Ut}from"css-to-react-native";import Ft from"parse-css-dimension";import{parseElementStyle as Xt}from"css-background-parser";var Ht=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),At=[1,0,0,1,0,0];function Vt(t,o){return typeof o=="number"?Ht.has(t)?String(o):o+"px":o}function Ct(t,o){if(typeof t=="number")return t;try{let e=new Ft(t);if(e.type==="length")switch(e.unit){case"em":return e.value*o;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function it(t,o){let e=[];for(let n in t){let r=wt(n);e.push([r,Vt(r,t[n])])}let i=e.reduce((n,r)=>{let a=wt(r[0]),c=r[1];return Object.assign(n,Ut(a,c,!0))},{});if(i.backgroundImage){let{backgrounds:n}=Xt(i);i.backgroundImage=n}let s=i.fontSize||o.fontSize;if(typeof s=="string")try{let n=new Ft(s);switch(n.unit){case"em":s=n.value*o.fontSize;break;case"rem":s=n.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s);for(let n in i){let r=i[n];if(typeof r=="string"){let a=Ct(r,s);typeof a!="undefined"&&(i[n]=a),r=i[n]}if(n==="opacity"&&(r=i[n]=r*o.opacity),n==="transform"){let a=[...At],c=r;for(let l of c){let g=Object.keys(l)[0],p=l[g],d=typeof p=="string"?Ct(p,s):p,f=[...At];switch(g){case"translateX":f[4]=d;break;case"translateY":f[5]=d;break;case"scaleX":f[0]=d;break;case"scaleY":f[3]=d;break;case"rotate":let b=d*Math.PI/180,y=Math.cos(b),T=Math.sin(b);f[0]=y,f[1]=T,f[2]=-T,f[3]=y;break;case"skewX":f[2]=Math.tan(d*Math.PI/180);break;case"skewY":f[1]=Math.tan(d*Math.PI/180);break}a=Z(f,a)}i.transform=a}}return i}function ut(t,o,e,i,s){let n=M(),r=q(q(q({},e),it(Lt[o],e)),it(i,e));if(o==="img"){let a=parseInt(s.width),l=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=l*r.width)}return t.setDisplay(C(r.display,{flex:n.DISPLAY_FLEX,none:n.DISPLAY_NONE},n.DISPLAY_FLEX)),t.setAlignContent(C(r.alignContent,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,"space-between":n.ALIGN_SPACE_BETWEEN,"space-around":n.ALIGN_SPACE_AROUND,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setAlignItems(C(r.alignItems,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_FLEX_START)),t.setAlignSelf(C(r.alignSelf,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setJustifyContent(C(r.justifyContent,{center:n.JUSTIFY_CENTER,"flex-start":n.JUSTIFY_FLEX_START,"flex-end":n.JUSTIFY_FLEX_END,"space-between":n.JUSTIFY_SPACE_BETWEEN,"space-around":n.JUSTIFY_SPACE_AROUND},n.JUSTIFY_FLEX_START)),t.setFlexDirection(C(r.flexDirection,{row:n.FLEX_DIRECTION_ROW,column:n.FLEX_DIRECTION_COLUMN,"row-reverse":n.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":n.FLEX_DIRECTION_COLUMN_REVERSE},n.FLEX_DIRECTION_ROW)),t.setFlexWrap(C(r.flexWrap,{wrap:n.WRAP_WRAP,nowrap:n.WRAP_NO_WRAP,"wrap-reverse":n.WRAP_WRAP_REVERSE},n.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(C(r.overflow,{visible:n.OVERFLOW_VISIBLE,hidden:n.OVERFLOW_HIDDEN},n.OVERFLOW_VISIBLE)),t.setMargin(n.EDGE_TOP,r.marginTop||0),t.setMargin(n.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(n.EDGE_LEFT,r.marginLeft||0),t.setMargin(n.EDGE_RIGHT,r.marginRight||0),t.setBorder(n.EDGE_TOP,r.borderWidth||0),t.setBorder(n.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(n.EDGE_LEFT,r.borderWidth||0),t.setBorder(n.EDGE_RIGHT,r.borderWidth||0),t.setPadding(n.EDGE_TOP,r.paddingTop||0),t.setPadding(n.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(n.EDGE_LEFT,r.paddingLeft||0),t.setPadding(n.EDGE_RIGHT,r.paddingRight||0),t.setPositionType(C(r.position,{absolute:n.POSITION_TYPE_ABSOLUTE,relative:n.POSITION_TYPE_RELATIVE},n.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(n.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(n.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(n.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(n.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,lt(r)]}import{LineBreaker as Jt}from"css-line-break";import{splitGraphemes as jt}from"text-segmentation";function tt({left:t,top:o,width:e,height:i},s,n){let r;if(n)r=s;else{let a=t+e/2,c=o+i/2;r=Z([1,0,0,1,a,c],Z(s,[1,0,0,1,-a,-c])),s.__parent&&(r=Z(s.__parent,r)),s.splice(0,6,...r)}return`matrix(${r.map(a=>a.toFixed(2)).join(",")})`}function Ot({left:t,top:o,width:e,height:i,isInheritingTransform:s},n){let r="",a=1,c="";return n.transform&&(r=tt({left:t,top:o,width:e,height:i},n.transform,s)),n.opacity&&(a=+n.opacity),{matrix:r,opacity:a}}function ct({id:t,content:o,filter:e,left:i,top:s,width:n,height:r,matrix:a,opacity:c,path:l,image:g,debug:p},d){let f="";return p&&(f=`<rect x="${i}" y="${s}" width="${n}" height="${l===null?.5:r}" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),g?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${g}" x="${i}" y="${s}" width="${n}" height="${r}" ${a?`transform="${a}"`:""} ${c!==1?`opacity="${c}"`:""}></image>${e?"</g>":""}${f}`:l===null?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${n}" 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}"`:""} ${c!==1?`opacity="${c}"`:""}>${o}</text>${e?"</g>":""}${f}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<path fill="${d.color}" ${a?`transform="${a}"`:""} ${c!==1?`opacity="${c}"`:""} d="${l}"></path>${e?"</g>":""}${f}`}function J({id:t,width:o,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,n=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+o,o),a=Math.min(i.shadowOffset.height-s,0),c=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${n/o*100}%" y="${a/e*100}%" width="${(r-n)/o*100}%" height="${(c-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var et="en",dt=typeof Intl!="undefined"&&"Segmenter"in Intl,Kt=dt?new Intl.Segmenter(et,{granularity:"word"}):null,qt=dt?new Intl.Segmenter(et,{granularity:"grapheme"}):null,Zt=[32,160,4961,65792,65793,4153,4241],Qt=t=>{let o=Jt(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=o.next()).done;)if(i.value){let s=i.value.slice(),n=[].map.call(s,a=>a.codePointAt(0)),r="";n.forEach(a=>{Zt.includes(a)?(r.length&&e.push(r),e.push(String.fromCodePoint(a)),r=""):r+=String.fromCodePoint(a)}),r.length&&e.push(r)}return e};function mt(t,o){return dt?o==="word"?[...Kt.segment(t)].map(e=>e.segment):[...qt.segment(t)].map(e=>e.segment):o==="word"?Qt(t):jt(t)}function*gt(t,o){let e=M(),{parentStyle:i,parent:s,font:n,id:r,isInheritingTransform:a,debug:c,embedFont:l,graphemeImages:g}=o;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(et):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(et):i.textTransform==="capitalize"&&(t=mt(t,"word").map(m=>mt(m,"grapheme").map((h,_)=>_===0?h.toLocaleUpperCase(et):h).join("")).join(""));let p=C(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),d=mt(t,p),f=e.Node.create();f.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?f.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?f.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?f.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&f.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(f,s.getChildCount());let b=n.getFont(i),y=b.ascender/b.unitsPerEm*i.fontSize,T=-(b.descender/b.unitsPerEm)*i.fontSize,I=(y+T)*1.2,{textAlign:x}=i,O=[],G=[],L=[];f.setMeasureFunc((m,h,_,j)=>{let k=[],v="",W=0,H="",R=0,V=0,K=-1;O=[],G=[0];for(let z=0;z<d.length;z++){let U=d[z];if([" ",` | ||
`," ","\u3000"].includes(U))v+=U,W=n.measure(b,v,i),L[z]=null;else{let Q=g&&g[U]?i.fontSize:n.measure(b,U,i);R||(v="",W=0);let Wt=W||",.!?:-@)>]}%#".indexOf(U[0])<0,Et=!R||!!W;Wt&&R+W+Q>m?(O.push(R),k.push(H),H=U,R=Q,G.push(1),K=-1):(H+=v+U,R+=W+Q,Et&&G[G.length-1]++),v="",W=0,Et&&K++,V=Math.max(V,R),L[z]={y:k.length*I,x:R-Q,width:Q,line:k.length,lineIndex:K}}}return R&&(k.push(H),O.push(R)),k.length>1&&(V=m),{width:V,height:k.length*I}});let[B,D]=yield,X="";i.position==="absolute"&&f.calculateLayout();let{left:Y,top:A,width:w,height:P}=f.getComputedLayout(),S=B+Y,N=D+A,{matrix:ot,opacity:u}=Ot({left:Y,top:A,width:w,height:P,isInheritingTransform:a},i);for(let m=0;m<d.length;m++){if(!L[m])continue;let h=d[m],_=null,j=null,k=L[m].y,v=L[m].x,W=L[m].width,H=I,R=w-O[L[m].line];if(x==="right"||x==="end")v+=R;else if(x==="center")v+=R/2;else if(x==="justify"){let K=L[m].line;if(K<O.length-1){let z=G[K];v+=(z>1?R/(z-1):0)*L[m].lineIndex}}g&&g[h]?j=g[h]:l?_=n.getSVG(b,h,Rt(q({},i),{left:S+v,top:N+k,letterSpacing:i.letterSpacing})):k+=y;let V="";i.textShadowOffset&&(V=J({width:W,height:H,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius})),X+=ct({content:h,filter:V,id:r,left:S+v,top:N+k,width:W,height:H,matrix:ot,opacity:u,path:_,image:j,debug:c},i)}return X}var pt=pt||{};pt.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]+\.?))/},o="";function e(u){var m=new Error(o+": "+u);throw m.source=o,m}function i(){var u=s();return o.length>0&&e("Invalid input not EOF"),u}function s(){return x(n)}function n(){return r("linear-gradient",t.linearGradient,c)||r("repeating-linear-gradient",t.repeatingLinearGradient,c)||r("radial-gradient",t.radialGradient,p)||r("repeating-radial-gradient",t.repeatingRadialGradient,p)}function r(u,m,h){return a(m,function(_){var j=h();return j&&(N(t.comma)||e("Missing comma before color stops")),{type:u,orientation:j,colorStops:x(O)}})}function a(u,m){var h=N(u);if(h){N(t.startCall)||e("Missing (");var _=m(h);return N(t.endCall)||e("Missing )"),_}}function c(){return l()||g()}function l(){return S("directional",t.sideOrCorner,1)}function g(){return S("angular",t.angleValue,1)}function p(){var u,m=d(),h;return m&&(u=[],u.push(m),h=o,N(t.comma)&&(m=d(),m?u.push(m):o=h)),u}function d(){var u=f()||b();if(u)u.at=T();else{var m=y();if(m){u=m;var h=T();h&&(u.at=h)}else{var _=F();_&&(u={type:"default-radial",at:_})}}return u}function f(){var u=S("shape",/^(circle)/i,0);return u&&(u.style=P()||y()),u}function b(){var u=S("shape",/^(ellipse)/i,0);return u&&(u.style=A()||y()),u}function y(){return S("extent-keyword",t.extentKeywords,1)}function T(){if(S("position",/^at/,0)){var u=F();return u||e("Missing positioning value"),u}}function F(){var u=I();if(u.x||u.y)return{type:"position",value:u}}function I(){return{x:A(),y:A()}}function x(u){var m=u(),h=[];if(m)for(h.push(m);N(t.comma);)m=u(),m?h.push(m):e("One extra comma");return h}function O(){var u=G();return u||e("Expected color definition"),u.length=A(),u}function G(){return B()||X()||D()||L()}function L(){return S("literal",t.literalColor,0)}function B(){return S("hex",t.hexColor,1)}function D(){return a(t.rgbColor,function(){return{type:"rgb",value:x(Y)}})}function X(){return a(t.rgbaColor,function(){return{type:"rgba",value:x(Y)}})}function Y(){return N(t.number)[1]}function A(){return S("%",t.percentageValue,1)||w()||P()}function w(){return S("position-keyword",t.positionKeywords,1)}function P(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(u,m,h){var _=N(m);if(_)return{type:u,value:_[h]}}function N(u){var m,h;return h=/^[\n\r\t\s]+/.exec(o),h&&ot(h[0].length),m=u.exec(o),m&&ot(m[0].length),m}function ot(u){o=o.substr(u)}return function(u){return o=u.toString(),i()}}();var Nt=pt;function te(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 ht({id:t,width:o},{image:e}){if(e.startsWith("linear-gradient(")){let i=Nt.parse(e)[0],s,n,r,a;if(i.orientation.type==="directional")[s,n,r,a]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let f=+i.orientation.value/180*Math.PI-Math.PI/2,b=Math.cos(f),y=Math.sin(f);s=0,n=0,r=b,a=y,r<0&&(s-=r,r=0),a<0&&(n-=a,a=0)}let c=o,l=[];for(let f of i.colorStops){let b=te(f);if(!l.length&&(l.push({offset:0,color:b}),typeof f.length=="undefined"||f.length.value==="0"))continue;let y=typeof f.length=="undefined"?void 0:f.length.type==="%"?f.length.value/100:f.length.value/c;l.push({offset:y,color:b})}l.length||l.push({offset:0,color:"transparent"});let g=l[l.length-1];g.offset!==1&&(typeof g.offset=="undefined"?g.offset=1:l.push({offset:1,color:g.color}));let p=0,d=1;for(let f=0;f<l.length;f++)if(typeof l[f].offset=="undefined"){for(d<f&&(d=f);typeof l[d].offset=="undefined";)d++;l[f].offset=(l[d].offset-l[p].offset)/(d-p)*(f-p)+l[p].offset}else p=f;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${s}" y1="${n}" x2="${r}" y2="${a}">${l.map(f=>`<stop offset="${f.offset*100}%" stop-color="${f.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}function at(t,o,e){return e<t+o&&(e/2<t&&e/2<o?t=o=e/2:e/2<t?t=e-o:e/2<o&&(o=e-t)),[t,o]}function rt({left:t,top:o,width:e,height:i},s){let{borderTopLeftRadius:n,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:c}=s;return n=Math.min(n||0,e,i),r=Math.min(r||0,e,i),a=Math.min(a||0,e,i),c=Math.min(c||0,e,i),!n&&!r&&!a&&!c?"":([n,r]=at(n,r,e),[n,a]=at(n,a,i),[r,c]=at(r,c,i),[a,c]=at(a,c,e),`M${t+n},${o} h${e-n-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-c} a${c},${c} 0 0 1 ${-c},${c} h${c+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+n-i} a${n},${n} 0 0 1 ${n},${-n}`)}function bt({id:t,left:o,top:e,width:i,height:s,isInheritingTransform:n,debug:r},a){if(a.display==="none")return"";let c="rect",l="transparent",g=0,p="",d="",f=[],b=1,y="";if(a.backgroundColor&&f.push(a.backgroundColor),a.borderWidth&&(g=a.borderWidth,l=a.borderColor),a.opacity&&(b=+a.opacity),a.transform&&(p=tt({left:o,top:e,width:i,height:s},a.transform,n)),a.backgroundImage){let I=a.backgroundImage.map((x,O)=>ht({id:t+"_"+O,width:i,height:s},x)).filter(Boolean);for(let x of I)d+=x[1],f.push(`url(#${x[0]})`)}let T=rt({left:o,top:e,width:i,height:s},a);T&&(c="path");let F=J({width:i,height:s,id:t},a);return f.length||f.push("transparent"),r&&(y=`<rect x="${o}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${d?`<defs>${d}</defs>`:""}${F?`${F}<g filter="url(#satori_s-${t})">`:""}${b!==1?`<g opacity="${b}">`:""}${f.map((I,x)=>I==="transparent"&&!(x===f.length-1&&g)?"":`<${c} x="${o}" y="${e}" width="${i}" height="${s}" fill="${I}" ${x===f.length-1&&g?`stroke="${l}" stroke-width="${g}"`:""} ${T?`d="${T}"`:""} ${p?`transform="${p}"`:""}></${c}>`).join("")}${b!==1?"</g>":""}${F?"</g>":""}${y}`}function yt({id:t,left:o,top:e,width:i,height:s,src:n,debug:r},a){if(a.display==="none")return"";let c="",l=1,g=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",p=rt({left:o,top:e,width:i,height:s},a);p&&(c=`<clipPath id="satori_c-${t}"><path x="${o}" y="${e}" width="${i}" height="${s}" d="${p}"></path></clipPath>`),a.opacity&&(l=+a.opacity);let d=J({width:i,height:s,id:t},a);return`${d}${d?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${n}" x="${o}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${g}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${l!==1?`opacity="${l}"`:""}></image>${d?"</g>":""}`}function*nt(t,o){let e=M(),{id:i,inheritedStyle:s,parent:n,font:r,debug:a,embedFont:c=!0,graphemeImages:l}=o;if(t===null||typeof t=="undefined")return yield,"";if(!ft(t)||typeof t.type=="function"){let w;if(!ft(t))w=gt(String(t),o);else{if(It(t.type))throw new Error("Class component is not supported.");w=nt(t.type(t.props),o)}w.next();let P=yield;return w.next(P).value}let{type:g,props:p}=t,{style:d,children:f}=p,b=e.Node.create();n.insertChild(b,n.getChildCount());let[y,T]=ut(b,g,s,d,p),F=y.transform===s.transform;F||(y.transform.__parent=s.transform);let I=typeof f=="undefined"?[]:[].concat(f),x=[],O=0;for(let w of I){let P=nt(w,{id:i*I.length+ ++O,parentStyle:y,inheritedStyle:T,isInheritingTransform:!0,parent:b,font:r,embedFont:c,debug:a,graphemeImages:l});P.next(),x.push(P)}let[G,L]=yield;y.position==="absolute"&&b.calculateLayout();let{left:B,top:D,width:X,height:Y}=b.getComputedLayout();B+=G,D+=L;let A="";g==="img"?A=yt({id:i,left:B,top:D,width:X,height:Y,src:p.src,isInheritingTransform:F,debug:a},y):A=bt({id:i,left:B,top:D,width:X,height:Y,isInheritingTransform:F,debug:a},y);for(let w of x)A+=w.next([B,D]).value;return A}import vt from"opentype.js";var st=class{constructor(o){this.fonts=new Map;for(let e of o){let i=e.data,s="buffer"in i?vt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):vt.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:o,weight:e,style:i}){if(!this.fonts.has(o))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(o)];return s.sort(([n,r,a],[c,l,g])=>{if(r!==l)return r?!l||r===e?-1:l===e?1:e===400&&r===500||e===500&&r===400?-1:e===400&&l===500||e===500&&l===400?1:e<400?r<e&&l<e?l-r:r<e?-1:l<e?1:r-l:e<r&&e<l?r-l:e<r?-1:e<l?1:l-r:1;if(a!==g){if(a===i)return-1;if(g===i)return 1}return-1}),s[0][0]}getFont({fontFamily:o,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:o,weight:e,style:i})}measure(o,e,{fontSize:i,letterSpacing:s=0}){return o.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(o,e,{fontSize:i,top:s,left:n,letterSpacing:r=0}){return s+=o.ascender/o.unitsPerEm*i,o.getPath(e,n,s,i,{letterSpacing:r/i}).toPathData(2)}};function xt({width:t,height:o,content:e},i){return`<svg width="${t}" height="${o}" viewBox="0 0 ${t} ${o}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var $t=new WeakMap;function kt(t,o){let e=M();if(!e)throw new Error("Satori is not initialized.");let i;$t.has(o.fonts)?i=$t.get(o.fonts):$t.set(o.fonts,i=new st(o.fonts));let s=e.Node.create();s.setWidth(o.width),s.setHeight(o.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let n=nt(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:o.embedFont,debug:o.debug,graphemeImages:o.graphemeImages});n.next(),s.calculateLayout(o.width,o.height,e.DIRECTION_LTR);let r=n.next([0,0]).value;return xt({width:o.width,height:o.height,content:r})}export{kt as default,Yt as init}; | ||
//# sourceMappingURL=index.wasm.js.map |
{ | ||
"name": "satori", | ||
"version": "0.0.13", | ||
"version": "0.0.14-beta.0", | ||
"description": "Satori converts HTML JSX to SVG string.", | ||
@@ -5,0 +5,0 @@ "module": "./dist/esm/index.js", |
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
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
226171
209