satori 0.0.17 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@ Satori translates the layout and styles of HTML & CSS based elements into an SVG
9
9
  ```jsx
10
10
  import satori from 'satori'
11
11
 
12
- satori(
12
+ const svg = await satori(
13
13
  <div style={{ color: 'black' }}>hello, world</div>,
14
14
  {
15
15
  width: 600,
@@ -55,7 +55,7 @@ elements (see section below), or custom React components, but React APIs such as
55
55
  If you don't have JSX transpiler enabled, you can simply pass [React-elements-like objects](https://reactjs.org/docs/introducing-jsx.html) that have `type`, `props.children` and `props.style` (and other properties too) directly:
56
56
 
57
57
  ```js
58
- satori(
58
+ await satori(
59
59
  {
60
60
  type: 'div',
61
61
  props: {
@@ -82,7 +82,7 @@ You can find the list of supported HTML elements and their preset styles [here](
82
82
  You can use `<img>` to embed images but `src`, `width`, and `height` attributes are all required.
83
83
 
84
84
  ```jsx
85
- satori(
85
+ await satori(
86
86
  <img src="https://picsum.photos/200/300" width={200} height={300} />,
87
87
  options
88
88
  )
@@ -92,24 +92,6 @@ When using `background-image`, the image will be stretched to fit the element by
92
92
 
93
93
  If you want to render the generated SVG to another image format such as PNG, it would be better to use base64 encoded image data directly as `props.src` so no extra I/O is needed.
94
94
 
95
- #### Emojis
96
-
97
- To render custom images for specific graphemes, you can use `graphemeImages` option to map the grapheme to an image source:
98
-
99
- ```jsx
100
- satori(
101
- <div>Next.js is 🤯!</div>,
102
- {
103
- ...,
104
- graphemeImages: {
105
- '🤯': 'https://twemoji.maxcdn.com/v/13.1.0/svg/1f92f.svg',
106
- },
107
- }
108
- )
109
- ```
110
-
111
- The image will be resized to the current font-size (both width and height), so it must be a square.
112
-
113
95
  ### CSS Properties
114
96
 
115
97
  | Property | Supported Values |
@@ -131,7 +113,7 @@ The image will be resized to the current font-size (both width and height), so i
131
113
  | `align-content` | Supported |
132
114
  | `align-self` | Supported |
133
115
  | `justify-content` | Supported |
134
- | `font-family` | Support single value |
116
+ | `font-family` | Supported |
135
117
  | `font-size` | Supported |
136
118
  | `font-weight` | Supported |
137
119
  | `font-style` | Supported |
@@ -146,24 +128,72 @@ The image will be resized to the current font-size (both width and height), so i
146
128
  | `object-fit` | `contain`, `cover`, `none` |
147
129
  | `opacity` | Supported |
148
130
  | `background-color` | Supported |
149
- | `background-image` | Support `linear-gradient`, `url` |
131
+ | `background-image` | Support `linear-gradient`, `radial-gradient`, `url` |
150
132
  | `word-break` | Supported |
151
133
  | `text-shadow` | Supported |
152
134
  | `text-transform` | Support `lowercase`, `uppercase`, `capitalize` |
153
135
  | `background-position` | Supported |
154
136
  | `background-size` | Support two-value size string such as `10px 20%` |
155
- | `background-clip` | TBD |
156
- | `background-repeat` | TBD |
157
- | `background-origin` | TBD |
158
- | `text-decoration` | TBD |
159
- | `line-height` | TBD |
160
- | `white-space` | TBD |
137
+ | `white-space` | Support `normal`, `pre`, `pre-wrap` and `nowrap` |
138
+ | `text-overflow` | Support `clip` and `ellipsis` |
139
+ | `text-decoration` | Support line types `underline` and `line-through`, and styles `dotted`, `dashed`, `solid` |
140
+ | `line-height` | Supported |
141
+ | `background-clip` | Support `border-box` and `text` |
142
+ | `background-repeat` | Supported |
143
+ | `filter` | Supported |
161
144
 
162
145
  Note:
163
146
 
164
147
  1. Three-dimensional transforms are not supported.
165
148
  2. There is no `z-index` support in SVG. Elements that come later in the document will be painted on top.
166
149
  3. `box-sizing` is set to `border-box` for all elements.
150
+ 4. `calc` isn't supported.
151
+ 5. `overflow: hidden` and `transform` can't be used together.
152
+
153
+ ### Typography
154
+
155
+ Advanced typography features such as kerning, ligatures and other OpenType features are not currently supported.
156
+
157
+ RTL languages are not supported either.
158
+
159
+ #### Emojis
160
+
161
+ To render custom images for specific graphemes, you can use `graphemeImages` option to map the grapheme to an image source:
162
+
163
+ ```jsx
164
+ await satori(
165
+ <div>Next.js is 🤯!</div>,
166
+ {
167
+ ...,
168
+ graphemeImages: {
169
+ '🤯': 'https://twemoji.maxcdn.com/v/13.1.0/svg/1f92f.svg',
170
+ },
171
+ }
172
+ )
173
+ ```
174
+
175
+ The image will be resized to the current font-size (both width and height), so it must be a square.
176
+
177
+ #### Dynamically Load Emojis and Fonts
178
+
179
+ Satori supports an option to dynamically load emoji images (grapheme pictures) and fonts when they're used but missing:
180
+
181
+ ```jsx
182
+ await satori(
183
+ <div>👋 你好</div>,
184
+ {
185
+ // `code` will be the detected language code, or `unknwon` if not able to tell.
186
+ // `segment` will be the content to render.
187
+ loadAdditionalAsset: async (code: string, segment: string) => {
188
+ // if segment is an emoji
189
+ return `data:image/svg+xml;base64,...`
190
+
191
+ // if segment is normal text
192
+ return loadFontFromSystem(code)
193
+ }
194
+ }
195
+ )
196
+ ```
167
197
 
168
198
  ## Contribute
169
199
 
package/dist/esm/index.js CHANGED
@@ -1,2 +1,5 @@
1
- var ie=Object.defineProperty,je=Object.defineProperties,Ke=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertyNames,ve=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ce=(e,r,t)=>r in e?ie(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,H=(e,r)=>{for(var t in r||(r={}))Fe.call(r,t)&&Ce(e,t,r[t]);if(ve)for(var t of ve(r))Qe.call(r,t)&&Ce(e,t,r[t]);return e},Oe=(e,r)=>je(e,qe(r)),et=e=>ie(e,"__esModule",{value:!0});var Ne=(e,r)=>()=>(e&&(r=e(e=0)),r);var tt=(e,r)=>{for(var t in r)ie(e,t,{get:r[t],enumerable:!0})},rt=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Ze(r))!Fe.call(e,s)&&(t||s!=="default")&&ie(e,s,{get:()=>r[s],enumerable:!(i=Ke(r,s))||i.enumerable});return e};var nt=(e=>(r,t)=>e&&e.get(r)||(t=rt(et({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var u=Ne(()=>{});var ke={};tt(ke,{default:()=>it});import*as ot from"yoga-layout-prebuilt";var it,We=Ne(()=>{u();it=ot});u();u();u();var ae;{let e=(We(),nt(ke));e.default?ae=e.default:ae=e}function at(e){ae=e}function V(){return ae}u();u();import{LineBreaker as st}from"css-line-break";import{splitGraphemes as ft}from"text-segmentation";function me(e){let r=typeof e;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function Pe(e){return/^class\s/.test(Function.prototype.toString.call(e))}function ee(e,r){return[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]}function k(e,r,t){let i=r[e];return typeof i=="undefined"?t:i}var Ge=void 0,de=typeof Intl!="undefined"&&"Segmenter"in Intl,lt=de?new Intl.Segmenter(Ge,{granularity:"word"}):null,ut=de?new Intl.Segmenter(Ge,{granularity:"grapheme"}):null,pe=[32,160,4961,65792,65793,4153,4241].map(e=>String.fromCodePoint(e)),ct=e=>{let r=st(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],i;for(;!(i=r.next()).done;)if(i.value){let s=i.value.slice(),o="";for(let n=0;n<s.length;n++){let a=s[n];pe.includes(a)?(o.length&&t.push(o),t.push(a),o=""):o+=a}o.length&&t.push(o)}return t};function se(e,r){return de?r==="word"?[...lt.segment(e)].map(t=>t.segment):[...ut.segment(e)].map(t=>t.segment):r==="word"?ct(e):ft(e)}u();u();var De={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};u();var mt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function ge(e){let r={};for(let t in e)mt.has(t)&&(r[t]=e[t]);return r}u();import{getPropertyName as Me,getStylesForProperty as ht}from"css-to-react-native";import Ue from"parse-css-dimension";import{parseElementStyle as bt}from"css-background-parser";u();import dt from"postcss-value-parser";import pt from"parse-css-dimension";function gt(e,r){try{let t=new pt(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*r};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function he(e,r,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let i=gt(e,r);return i.absolute?{[t?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[t?"xRelative":"yRelative"]:i.relative}:{}}}function be(e,r){if(typeof e=="number")return{xAbsolute:e};let t;try{t=dt(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return t.length===1?he(t[0],r,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),H(H({},he(t[0],r,!0)),he(t[1],r,!1))):{}}var yt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Be=[1,0,0,1,0,0];function xt(e,r){return typeof r=="number"?yt.has(e)?String(r):r+"px":r}function Ye(e,r){if(typeof e=="number")return e;try{let t=new Ue(e);if(t.type==="length")switch(t.unit){case"em":return t.value*r;case"rem":return t.value*16;default:return t.value}else if(t.type==="angle")switch(t.unit){case"deg":return t.value;case"rad":return t.value*180/Math.PI;default:return t.value}}catch{}}function fe(e,r){let t=[];for(let o in e){let n=Me(o);t.push([n,xt(n,e[o])])}let i=t.reduce((o,n)=>{let a=Me(n[0]),f=n[1];return Object.assign(o,ht(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:o}=bt(i);i.backgroundImage=o}let s=i.fontSize||r.fontSize;if(typeof s=="string")try{let o=new Ue(s);switch(o.unit){case"em":s=o.value*r.fontSize;break;case"rem":s=o.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s),i.transformOrigin&&(i.transformOrigin=be(i.transformOrigin,s));for(let o in i){let n=i[o];if(typeof n=="string"){let a=Ye(n,s);typeof a!="undefined"&&(i[o]=a),n=i[o]}if(o==="opacity"&&(n=i[o]=n*r.opacity),o==="transform"){let a=[...Be],f=n;for(let c of f){let b=Object.keys(c)[0],p=c[b],d=typeof p=="string"?Ye(p,s):p,g=[...Be];switch(b){case"translateX":g[4]=d;break;case"translateY":g[5]=d;break;case"scaleX":g[0]=d;break;case"scaleY":g[3]=d;break;case"rotate":let m=d*Math.PI/180,x=Math.cos(m),I=Math.sin(m);g[0]=x,g[1]=I,g[2]=-I,g[3]=x;break;case"skewX":g[2]=Math.tan(d*Math.PI/180);break;case"skewY":g[1]=Math.tan(d*Math.PI/180);break}a=ee(g,a)}i.transform=a}}return i}function ye(e,r,t,i,s){let o=V(),n=H(H(H({},t),fe(De[r],t)),fe(i,t));if(r==="img"){let a=parseInt(s.width),c=parseInt(s.height)/a;n.width||(n.width=a),n.height||(n.height=c*n.width)}return e.setDisplay(k(n.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(k(n.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setAlignItems(k(n.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),e.setAlignSelf(k(n.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setJustifyContent(k(n.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),e.setFlexDirection(k(n.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),e.setFlexWrap(k(n.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&e.setFlexBasis(n.flexBasis),e.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),e.setFlexShrink(typeof n.flexShrink=="undefined"?1:n.flexShrink),typeof n.maxHeight!="undefined"&&e.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&e.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&e.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&e.setMinWidth(n.minWidth),e.setOverflow(k(n.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),e.setMargin(o.EDGE_TOP,n.marginTop||0),e.setMargin(o.EDGE_BOTTOM,n.marginBottom||0),e.setMargin(o.EDGE_LEFT,n.marginLeft||0),e.setMargin(o.EDGE_RIGHT,n.marginRight||0),e.setBorder(o.EDGE_TOP,n.borderWidth||0),e.setBorder(o.EDGE_BOTTOM,n.borderWidth||0),e.setBorder(o.EDGE_LEFT,n.borderWidth||0),e.setBorder(o.EDGE_RIGHT,n.borderWidth||0),e.setPadding(o.EDGE_TOP,n.paddingTop||0),e.setPadding(o.EDGE_BOTTOM,n.paddingBottom||0),e.setPadding(o.EDGE_LEFT,n.paddingLeft||0),e.setPadding(o.EDGE_RIGHT,n.paddingRight||0),e.setPositionType(k(n.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&e.setPosition(o.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&e.setPosition(o.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&e.setPosition(o.EDGE_LEFT,n.left),typeof n.right!="undefined"&&e.setPosition(o.EDGE_RIGHT,n.right),typeof n.height!="undefined"?e.setHeight(n.height):e.setHeightAuto(),typeof n.width!="undefined"?e.setWidth(n.width):e.setWidthAuto(),[n,ge(n)]}u();u();u();function re({left:e,top:r,width:t,height:i},s,o,n){var f,c,b,p;let a;if(o)a=s;else{let d=(c=n==null?void 0:n.xAbsolute)!=null?c:((f=n==null?void 0:n.xRelative)!=null?f:50)*t/100,g=(p=n==null?void 0:n.yAbsolute)!=null?p:((b=n==null?void 0:n.yRelative)!=null?b:50)*i/100,m=e+d,x=r+g;a=ee([1,0,0,1,m,x],ee(s,[1,0,0,1,-m,-x])),s.__parent&&(a=ee(s.__parent,a)),s.splice(0,6,...a)}return`matrix(${a.map(d=>d.toFixed(2)).join(",")})`}function Xe({left:e,top:r,width:t,height:i,isInheritingTransform:s},o){let n="",a=1;return o.transform&&(n=re({left:e,top:r,width:t,height:i},o.transform,s,o.transformOrigin)),o.opacity&&(a=+o.opacity),{matrix:n,opacity:a}}function xe({id:e,content:r,filter:t,left:i,top:s,width:o,height:n,matrix:a,opacity:f,image:c,debug:b},p){let d="";return b&&(d=`<rect x="${i}" y="${s}" width="${o}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),c?`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<image href="${c}" x="${i}" y="${s}" width="${o}" height="${n}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${t?"</g>":""}${d}`:`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<text x="${i}" y="${s}" width="${o}" height="${n}" fill="${p.color}" font-weight="${p.fontWeight}" font-style="${p.fontStyle}" font-size="${p.fontSize}" font-family="${p.fontFamily}" ${p.letterSpacing?`letter-spacing="${p.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${r}</text>${t?"</g>":""}${d}`}u();function Z({id:e,width:r,height:t},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-s,0),n=Math.max(i.shadowOffset.width+s+r,r),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+t,t);return`<defs><filter id="satori_s-${e}" x="${o/r*100}%" y="${a/t*100}%" width="${(n-o)/r*100}%" height="${(f-a)/t*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var $e=void 0;function*Ee(e,r){let t=V(),{parentStyle:i,parent:s,font:o,id:n,isInheritingTransform:a,debug:f,embedFont:c,graphemeImages:b}=r;i.textTransform==="uppercase"?e=e.toLocaleUpperCase($e):i.textTransform==="lowercase"?e=e.toLocaleLowerCase($e):i.textTransform==="capitalize"&&(e=se(e,"word").map(S=>se(S,"grapheme").map((L,M)=>M===0?L.toLocaleUpperCase($e):L).join("")).join(""));let p=k(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),d=se(e,p),g=t.Node.create();g.setAlignItems(t.ALIGN_BASELINE),i.textAlign==="left"?g.setJustifyContent(t.JUSTIFY_FLEX_START):i.textAlign==="center"?g.setJustifyContent(t.JUSTIFY_CENTER):i.textAlign==="right"?g.setJustifyContent(t.JUSTIFY_FLEX_END):i.textAlign==="justify"&&g.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),s.insertChild(g,s.getChildCount());let m=o.getFont(i),x=m.ascender/m.unitsPerEm*i.fontSize,I=-(m.descender/m.unitsPerEm)*i.fontSize,_=x+I,h=_*1.2,E=(i.fontSize-_)/2,{textAlign:v}=i,P=[],U=[],w=[],G=new Map,K=S=>{if(G.has(S))return G.get(S);let L=o.measure(m,S,i);return G.set(S,L),L};g.setMeasureFunc(S=>{let L=0,M="",B=0,F=0,Y=0,te=-1;P=[],U=[0];for(let X=0;X<d.length;X++){let z=d[X];if(pe.includes(z))M+=z,B=K(M),w[X]=null;else{let j=b&&b[z]?i.fontSize:K(z);F||(M="",B=0);let we=B||",.!?:-@)>]}%#".indexOf(z[0])<0,Ae=!F||!!B;we&&F+B+j>S?(P.push(F),L++,F=j,U.push(1),te=-1):(F+=B+j,Ae&&U[U.length-1]++),M="",B=0,Ae&&te++,Y=Math.max(Y,F),w[X]={y:L*h-E,x:F-j,width:j,line:L,lineIndex:te}}}return F&&(L++,P.push(F)),L>1&&(Y=S),{width:Y,height:L*h}});let[q,W]=yield,C="",{left:D,top:A,width:O,height:Q}=g.getComputedLayout(),l=q+D,y=W+A,{matrix:$,opacity:N}=Xe({left:D,top:A,width:O,height:Q,isInheritingTransform:a},i),J="";i.textShadowOffset&&(J=Z({width:O,height:Q,id:n},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let ce="";for(let S=0;S<d.length;S++){if(!w[S])continue;let L=d[S],M=null,B=null,F=w[S].y,Y=w[S].x,te=w[S].width,X=w[S].line;if(P.length>1){let z=O-P[X];if(v==="right"||v==="end")Y+=z;else if(v==="center")Y+=z/2;else if(v==="justify"&&X<P.length-1){let j=U[X];Y+=(j>1?z/(j-1):0)*w[S].lineIndex}}b&&b[L]?B=b[L]:c?M=o.getSVG(m,L,Oe(H({},i),{left:l+Y,top:y+F+x,letterSpacing:i.letterSpacing})):F+=x,M?ce+=M+" ":C+=xe({content:L,filter:J,id:n,left:l+Y,top:y+F,width:te,height:h,matrix:$,opacity:N,image:B,debug:f},i)}if(ce){let S="";f&&(S=`<rect x="${l}" y="${y}" width="${O}" height="${Q}" fill="transparent" stroke="#575eff" stroke-width="1" ${$?`transform="${$}"`:""}></rect>`),C+=`${J?`${J}<g filter="url(#satori_s-${n})">`:""}<path fill="${i.color}" ${$?`transform="${$}"`:""} ${N!==1?`opacity="${N}"`:""} d="${ce}"></path>${J?"</g>":""}${S}`}return C}u();u();import $t from"parse-css-dimension";u();var Se=Se||{};Se.parse=function(){var e={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function t(l){var y=new Error(r+": "+l);throw y.source=r,y}function i(){var l=s();return r.length>0&&t("Invalid input not EOF"),l}function s(){return E(o)}function o(){return n("linear-gradient",e.linearGradient,f)||n("repeating-linear-gradient",e.repeatingLinearGradient,f)||n("radial-gradient",e.radialGradient,p)||n("repeating-radial-gradient",e.repeatingRadialGradient,p)}function n(l,y,$){return a(y,function(N){var J=$();return J&&(O(e.comma)||t("Missing comma before color stops")),{type:l,orientation:J,colorStops:E(v)}})}function a(l,y){var $=O(l);if($){O(e.startCall)||t("Missing (");var N=y($);return O(e.endCall)||t("Missing )"),N}}function f(){return c()||b()}function c(){return A("directional",e.sideOrCorner,1)}function b(){return A("angular",e.angleValue,1)}function p(){var l,y=d(),$;return y&&(l=[],l.push(y),$=r,O(e.comma)&&(y=d(),y?l.push(y):r=$)),l}function d(){var l=g()||m();if(l)l.at=I();else{var y=x();if(y){l=y;var $=I();$&&(l.at=$)}else{var N=_();N&&(l={type:"default-radial",at:N})}}return l}function g(){var l=A("shape",/^(circle)/i,0);return l&&(l.style=D()||x()),l}function m(){var l=A("shape",/^(ellipse)/i,0);return l&&(l.style=W()||x()),l}function x(){return A("extent-keyword",e.extentKeywords,1)}function I(){if(A("position",/^at/,0)){var l=_();return l||t("Missing positioning value"),l}}function _(){var l=h();if(l.x||l.y)return{type:"position",value:l}}function h(){return{x:W(),y:W()}}function E(l){var y=l(),$=[];if(y)for($.push(y);O(e.comma);)y=l(),y?$.push(y):t("One extra comma");return $}function v(){var l=P();return l||t("Expected color definition"),l.length=W(),l}function P(){return w()||K()||G()||U()}function U(){return A("literal",e.literalColor,0)}function w(){return A("hex",e.hexColor,1)}function G(){return a(e.rgbColor,function(){return{type:"rgb",value:E(q)}})}function K(){return a(e.rgbaColor,function(){return{type:"rgba",value:E(q)}})}function q(){return O(e.number)[1]}function W(){return A("%",e.percentageValue,1)||C()||D()}function C(){return A("position-keyword",e.positionKeywords,1)}function D(){return A("px",e.pixelValue,1)||A("em",e.emValue,1)}function A(l,y,$){var N=O(y);if(N)return{type:l,value:N[$]}}function O(l){var y,$;return $=/^[\n\r\t\s]+/.exec(r),$&&Q($[0].length),y=l.exec(r),y&&Q(y[0].length),y}function Q(l){r=r.substr(l)}return function(l){return r=l.toString(),i()}}();var ze=Se;function Et(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function St(e,r){return typeof e=="string"&&e.endsWith("%")?r*parseFloat(e)/100:+e}function He(e,{x:r,y:t,defaultX:i,defaultY:s}){return(e?e.split(" ").map(o=>{try{let n=new $t(o);return n.type==="length"||n.type==="number"?n.value:n.value+n.unit}catch{return null}}).filter(o=>o!==null):[i,s]).map((o,n)=>St(o,[r,t][n]))}function Re({id:e,width:r,height:t},{image:i,size:s,position:o}){let n=He(s,{x:r,y:t,defaultX:r,defaultY:t}),a=He(o,{x:r,y:t,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=ze.parse(i)[0],c,b,p,d;if(f.orientation.type==="directional")[c,b,p,d]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let h=+f.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(h),v=Math.sin(h);c=0,b=0,p=E,d=v,p<0&&(c-=p,p=0),d<0&&(b-=d,d=0)}let g=r,m=[];for(let h of f.colorStops){let E=Et(h);if(!m.length&&(m.push({offset:0,color:E}),typeof h.length=="undefined"||h.length.value==="0"))continue;let v=typeof h.length=="undefined"?void 0:h.length.type==="%"?h.length.value/100:h.length.value/g;m.push({offset:v,color:E})}m.length||m.push({offset:0,color:"transparent"});let x=m[m.length-1];x.offset!==1&&(typeof x.offset=="undefined"?x.offset=1:m.push({offset:1,color:x.color}));let I=0,_=1;for(let h=0;h<m.length;h++)if(typeof m[h].offset=="undefined"){for(_<h&&(_=h);typeof m[_].offset=="undefined";)_++;m[h].offset=(m[_].offset-m[I].offset)/(_-I)*(h-I)+m[I].offset}else I=h;return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${c}" y1="${b}" x2="${p}" y2="${d}">${m.map(h=>`<stop offset="${h.offset*100}%" stop-color="${h.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${e}`,`<pattern id="satori_bi${e}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${n[0]}" height="${n[1]}"><image href="${f}" x="0" y="0" width="${n[0]}" height="${n[1]}"/></pattern>`]}}u();function le(e,r,t){return t<e+r&&(t/2<e&&t/2<r?e=r=t/2:t/2<e?e=t-r:t/2<r&&(r=t-e)),[e,r]}function ne({left:e,top:r,width:t,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:n,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return o=Math.min(o||0,t,i),n=Math.min(n||0,t,i),a=Math.min(a||0,t,i),f=Math.min(f||0,t,i),!o&&!n&&!a&&!f?"":([o,n]=le(o,n,t),[o,a]=le(o,a,i),[n,f]=le(n,f,i),[a,f]=le(a,f,t),`M${e+o},${r} h${t-o-n} a${n},${n} 0 0 1 ${n},${n} v${i-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-t} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function Te({id:e,left:r,top:t,width:i,height:s,isInheritingTransform:o,debug:n},a){if(a.display==="none")return"";let f="rect",c="transparent",b=0,p="",d="",g=[],m=1,x="";if(a.backgroundColor&&g.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,c=a.borderColor),a.opacity&&(m=+a.opacity),a.transform&&(p=re({left:r,top:t,width:i,height:s},a.transform,o,a.transformOrigin)),a.backgroundImage){let h=a.backgroundImage.map((E,v)=>Re({id:e+"_"+v,width:i,height:s},E)).filter(Boolean);for(let E of h)d+=E[1],g.push(`url(#${E[0]})`)}let I=ne({left:r,top:t,width:i,height:s},a);I&&(f="path");let _=Z({width:i,height:s,id:e},a);return g.length||g.push("transparent"),n&&(x=`<rect x="${r}" y="${t}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${d?`<defs>${d}</defs>`:""}${_?`${_}<g filter="url(#satori_s-${e})">`:""}${m!==1?`<g opacity="${m}">`:""}${g.map((h,E)=>h==="transparent"&&!(E===g.length-1&&b)?"":`<${f} x="${r}" y="${t}" width="${i}" height="${s}" fill="${h}" ${E===g.length-1&&b?`stroke="${c}" stroke-width="${b}"`:""} ${I?`d="${I}"`:""} ${p?`transform="${p}"`:""}></${f}>`).join("")}${m!==1?"</g>":""}${_?"</g>":""}${x}`}u();function _e({id:e,left:r,top:t,width:i,height:s,src:o,debug:n},a){if(a.display==="none")return"";let f="",c=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",p=ne({left:r,top:t,width:i,height:s},a);p&&(f=`<clipPath id="satori_c-${e}"><path x="${r}" y="${t}" width="${i}" height="${s}" d="${p}"></path></clipPath>`),a.opacity&&(c=+a.opacity);let d=Z({width:i,height:s,id:e},a);return`${d}${d?`<g filter="url(#satori_s-${e})">`:""}${f}<image href="${o}" x="${r}" y="${t}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${f?`clip-path="url(#satori_c-${e})"`:""} ${c!==1?`opacity="${c}"`:""}></image>${d?"</g>":""}`}function*oe(e,r){let t=V(),{id:i,inheritedStyle:s,parent:o,font:n,debug:a,embedFont:f=!0,graphemeImages:c}=r;if(e===null||typeof e=="undefined")return yield,"";if(!me(e)||typeof e.type=="function"){let C;if(!me(e))C=Ee(String(e),r);else{if(Pe(e.type))throw new Error("Class component is not supported.");C=oe(e.type(e.props),r)}C.next();let D=yield;return C.next(D).value}let{type:b,props:p}=e,{style:d,children:g}=p,m=t.Node.create();o.insertChild(m,o.getChildCount());let[x,I]=ye(m,b,s,d,p),_=x.transform===s.transform;_||(x.transform.__parent=s.transform);let h=typeof g=="undefined"?[]:[].concat(g),E=[],v=0;for(let C of h){let D=oe(C,{id:i*h.length+ ++v,parentStyle:x,inheritedStyle:I,isInheritingTransform:!0,parent:m,font:n,embedFont:f,debug:a,graphemeImages:c});D.next(),E.push(D)}let[P,U]=yield;x.position==="absolute"&&m.calculateLayout();let{left:w,top:G,width:K,height:q}=m.getComputedLayout();w+=P,G+=U;let W="";b==="img"?W=_e({id:i,left:w,top:G,width:K,height:q,src:p.src,isInheritingTransform:_,debug:a},x):W=Te({id:i,left:w,top:G,width:K,height:q,isInheritingTransform:_,debug:a},x);for(let C of E)W+=C.next([w,G]).value;return W}u();import Ve from"@shuding/opentype.js";var ue=class{constructor(r){this.fonts=new Map;for(let t of r){let i=t.data,s="buffer"in i?Ve.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Ve.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(t.name)||this.fonts.set(t.name,[]),this.fonts.get(t.name).push([s,t.weight,t.style])}}get({name:r,weight:t,style:i}){if(!this.fonts.has(r))return this.defaultFont;t==="normal"&&(t=400),t==="bold"&&(t=700);let s=[...this.fonts.get(r)];return s.sort(([o,n,a],[f,c,b])=>{if(n!==c)return n?!c||n===t?-1:c===t?1:t===400&&n===500||t===500&&n===400?-1:t===400&&c===500||t===500&&c===400?1:t<400?n<t&&c<t?c-n:n<t?-1:c<t?1:n-c:t<n&&t<c?n-c:t<n?-1:t<c?1:c-n:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:r,fontWeight:t=400,fontStyle:i="normal"}){return this.get({name:r,weight:t,style:i})}measure(r,t,{fontSize:i,letterSpacing:s=0}){return r.getAdvanceWidth(t,i,{letterSpacing:s/i})}getSVG(r,t,{fontSize:i,top:s,left:o,letterSpacing:n=0}){return r.getPath(t,o,s,i,{letterSpacing:n/i}).toPathData(1)}};u();function Ie({width:e,height:r,content:t},i){return`<svg width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}var Le=new WeakMap;function Je(e,r){let t=V();if(!t)throw new Error("Satori is not initialized.");let i;Le.has(r.fonts)?i=Le.get(r.fonts):Le.set(r.fonts,i=new ue(r.fonts));let s=t.Node.create();s.setWidth(r.width),s.setHeight(r.height),s.setFlexDirection(t.FLEX_DIRECTION_ROW),s.setFlexWrap(t.WRAP_WRAP),s.setAlignContent(t.ALIGN_AUTO),s.setAlignItems(t.ALIGN_FLEX_START),s.setJustifyContent(t.JUSTIFY_FLEX_START);let o=oe(e,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});o.next(),s.calculateLayout(r.width,r.height,t.DIRECTION_LTR);let n=o.next([0,0]).value;return Ie({width:r.width,height:r.height,content:n})}export{Je as default,at as init};
1
+ var At=Object.defineProperty,kt=Object.defineProperties;var Ot=Object.getOwnPropertyDescriptors;var dt=Object.getOwnPropertySymbols;var $t=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var ct=(e,r,t)=>r in e?At(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,G=(e,r)=>{for(var t in r||(r={}))$t.call(r,t)&&ct(e,t,r[t]);if(dt)for(var t of dt(r))Ft.call(r,t)&&ct(e,t,r[t]);return e},se=(e,r)=>kt(e,Ot(r));import{guessLanguage as pr}from"guesslanguage";import*as Pt from"yoga-layout-prebuilt";var pt=Pt;var Pe;Pe=pt.default;function Wt(e){Pe=e}function te(){return Pe}import{LineBreaker as Nt}from"css-line-break";import{splitGraphemes as Mt}from"text-segmentation";function We(e){let r=typeof e;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function mt(e){return/^class\s/.test(Function.prototype.toString.call(e))}function ge(e,r){return[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]}function q(e,r,t){let i=r[e];return typeof i=="undefined"?t:i}var gt=void 0,Ne=typeof Intl!="undefined"&&"Segmenter"in Intl&&process.env.NODE_ENV!=="test",Gt=Ne?new Intl.Segmenter(gt,{granularity:"word"}):null,Dt=Ne?new Intl.Segmenter(gt,{granularity:"grapheme"}):null,ye=[32,160,4961,65792,65793,4153,4241,10].map(e=>String.fromCodePoint(e)),Bt=e=>{let r=Nt(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],i;for(;!(i=r.next()).done;)if(i.value){let a=i.value.slice(),n="";for(let o=0;o<a.length;o++){let s=a[o];ye.includes(s)?(n.length&&t.push(n),t.push(s),n=""):n+=s}n.length&&t.push(n)}return t};function le(e,r){return Ne?r==="word"?[...Gt.segment(e)].map(t=>t.segment):[...Dt.segment(e)].map(t=>t.segment):r==="word"?Bt(e):Mt(e)}function y(e,r,t){let i="";for(let[a,n]of Object.entries(r))typeof n!="undefined"&&(i+=` ${a}="${n}"`);return t?`<${e}${i}>${t}</${e}>`:`<${e}${i}/>`}var ht={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 Yt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textAlign","textTransform","textShadowOffset","textShadowColor","textShadowRadius","textDecorationLine","textDecorationStyle","textDecorationColor","whiteSpace","transform","wordBreak","opacity","filter","_viewportWidth","_viewportHeight","_inheritedClipPathId","_inheritedBackgroundClipTextPath"]);function Me(e){let r={};for(let t in e)Yt.has(t)&&(r[t]=e[t]);return r}import{getPropertyName as rr,getStylesForProperty as nr}from"css-to-react-native";import{parseElementStyle as ir}from"css-background-parser";var xe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ht=xe((e,r)=>{r.exports=["em","ex","ch","rem","vh","vw","vmin","vmax","px","mm","cm","in","pt","pc","mozmm"]}),Xt=xe((e,r)=>{r.exports=["deg","grad","rad","turn"]}),Ut=xe((e,r)=>{r.exports=["dpi","dpcm","dppx"]}),zt=xe((e,r)=>{r.exports=["Hz","kHz"]}),Vt=xe((e,r)=>{r.exports=["s","ms"]}),jt=Ht(),bt=Xt(),yt=Ut(),xt=zt(),Et=Vt();function De(e){if(/\.\D?$/.test(e))throw new Error("The dot should be followed by a number");if(/^[+-]{2}/.test(e))throw new Error("Only one leading +/- is allowed");if(Jt(e)>1)throw new Error("Only one dot is allowed");if(/%$/.test(e)){this.type="percentage",this.value=Ge(e),this.unit="%";return}var r=Kt(e);if(!r){this.type="number",this.value=Ge(e);return}this.type=Qt(r),this.value=Ge(e.substr(0,e.length-r.length)),this.unit=r}De.prototype.valueOf=function(){return this.value};De.prototype.toString=function(){return this.value+(this.unit||"")};function fe(e){return new De(e)}function Jt(e){var r=e.match(/\./g);return r?r.length:0}function Ge(e){var r=parseFloat(e);if(isNaN(r))throw new Error("Invalid number: "+e);return r}var qt=[].concat(bt,xt,jt,yt,Et);function Kt(e){var r=e.match(/\D+$/),t=r&&r[0];if(t&&qt.indexOf(t)===-1)throw new Error("Invalid unit: "+t);return t}var Zt=Object.assign(Ce(bt,"angle"),Ce(xt,"frequency"),Ce(yt,"resolution"),Ce(Et,"time"));function Ce(e,r){return Object.fromEntries(e.map(t=>[t,r]))}function Qt(e){return Zt[e]||"length"}import er from"postcss-value-parser";function tr(e,r){try{let t=new fe(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*r};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function Be(e,r,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let i=tr(e,r);return i.absolute?{[t?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[t?"xRelative":"yRelative"]:i.relative}:{}}}function Ye(e,r){if(typeof e=="number")return{xAbsolute:e};let t;try{t=er(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return t.length===1?Be(t[0],r,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),G(G({},Be(t[0],r,!0)),Be(t[1],r,!1))):{}}var or=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),ar=new Set(["lineHeight"]),St=[1,0,0,1,0,0];function sr(e,r,t,i){return e==="border"&&!t.includes(r.borderColor)?r.borderColor=i:e==="textDecoration"&&!t.includes(r.textDecorationColor)&&(r.textDecorationColor=i),r}function _t(e,r){return typeof r=="number"?or.has(e)?ar.has(e)?r:String(r):r+"px":r}function lr(e,r){return e==="lineHeight"?{lineHeight:_t(e,r)}:e==="fontFamily"?{fontFamily:r.split(",").map(t=>t.trim().replace(/(^['"])|(['"]$)/g,"").toLocaleLowerCase())}:null}function He(e,r,t,{percentage:i}={percentage:!1}){if(typeof e=="number")return e;try{let a=new fe(e);if(a.type==="length")switch(a.unit){case"em":return a.value*r;case"rem":return a.value*16;case"vw":return~~(a.value*t._viewportWidth/100);case"vh":return~~(a.value*t._viewportHeight/100);default:return a.value}else if(a.type==="angle")switch(a.unit){case"deg":return a.value;case"rad":return a.value*180/Math.PI;default:return a.value}else if(a.type==="percentage"&&i)return a.value/100*r}catch{}}function Ie(e,r){let t={};for(let a in e){if(a.startsWith("_")){t[a]=e[a];continue}let n=rr(a);Object.assign(t,lr(n,e[a])||sr(n,nr(n,_t(n,e[a]),!0),e[a],e.color||r.color))}if(t.backgroundImage){let{backgrounds:a}=ir(t);t.backgroundImage=a}let i=t.fontSize||r.fontSize;if(typeof i=="string")try{let a=new fe(i);switch(a.unit){case"em":i=a.value*r.fontSize;break;case"rem":i=a.value*16;break}}catch{i=16}typeof t.fontSize!="undefined"&&(t.fontSize=i),t.transformOrigin&&(t.transformOrigin=Ye(t.transformOrigin,i));for(let a in t){let n=t[a];if(a==="lineHeight")typeof n=="string"&&(n=t[a]=He(n,i,r,{percentage:!0})/i);else if(typeof n=="string"){let o=He(n,i,r);typeof o!="undefined"&&(t[a]=o),n=t[a]}if(a==="opacity"&&(n=t[a]=n*r.opacity),a==="transform"){let o=[...St],s=n;for(let f of s){let h=Object.keys(f)[0],g=f[h],p=typeof g=="string"?He(g,i,r):g,l=[...St];switch(h){case"translateX":l[4]=p;break;case"translateY":l[5]=p;break;case"scale":l[0]=p,l[3]=p;break;case"scaleX":l[0]=p;break;case"scaleY":l[3]=p;break;case"rotate":let c=p*Math.PI/180,u=Math.cos(c),d=Math.sin(c);l[0]=u,l[1]=d,l[2]=-d,l[3]=u;break;case"skewX":l[2]=Math.tan(p*Math.PI/180);break;case"skewY":l[1]=Math.tan(p*Math.PI/180);break}o=ge(l,o)}t.transform=o}}return t}function Xe(e,r,t,i,a){let n=te(),o=G(G(G({},t),Ie(ht[r],t)),Ie(i,t));if(r==="img"){let s=parseInt(a.width),h=parseInt(a.height)/s;o.width||(o.width=s),o.height||(o.height=h*o.width)}return e.setDisplay(q(o.display,{flex:n.DISPLAY_FLEX,none:n.DISPLAY_NONE},n.DISPLAY_FLEX)),e.setAlignContent(q(o.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)),e.setAlignItems(q(o.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)),e.setAlignSelf(q(o.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)),e.setJustifyContent(q(o.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)),e.setFlexDirection(q(o.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)),e.setFlexWrap(q(o.flexWrap,{wrap:n.WRAP_WRAP,nowrap:n.WRAP_NO_WRAP,"wrap-reverse":n.WRAP_WRAP_REVERSE},n.WRAP_WRAP)),typeof o.flexBasis!="undefined"&&e.setFlexBasis(o.flexBasis),e.setFlexGrow(typeof o.flexGrow=="undefined"?0:o.flexGrow),e.setFlexShrink(typeof o.flexShrink=="undefined"?0:o.flexShrink),typeof o.maxHeight!="undefined"&&e.setMaxHeight(o.maxHeight),typeof o.maxWidth!="undefined"&&e.setMaxWidth(o.maxWidth),typeof o.minHeight!="undefined"&&e.setMinHeight(o.minHeight),typeof o.minWidth!="undefined"&&e.setMinWidth(o.minWidth),e.setOverflow(q(o.overflow,{visible:n.OVERFLOW_VISIBLE,hidden:n.OVERFLOW_HIDDEN},n.OVERFLOW_VISIBLE)),e.setMargin(n.EDGE_TOP,o.marginTop||0),e.setMargin(n.EDGE_BOTTOM,o.marginBottom||0),e.setMargin(n.EDGE_LEFT,o.marginLeft||0),e.setMargin(n.EDGE_RIGHT,o.marginRight||0),e.setBorder(n.EDGE_TOP,o.borderWidth||0),e.setBorder(n.EDGE_BOTTOM,o.borderWidth||0),e.setBorder(n.EDGE_LEFT,o.borderWidth||0),e.setBorder(n.EDGE_RIGHT,o.borderWidth||0),e.setPadding(n.EDGE_TOP,o.paddingTop||0),e.setPadding(n.EDGE_BOTTOM,o.paddingBottom||0),e.setPadding(n.EDGE_LEFT,o.paddingLeft||0),e.setPadding(n.EDGE_RIGHT,o.paddingRight||0),e.setPositionType(q(o.position,{absolute:n.POSITION_TYPE_ABSOLUTE,relative:n.POSITION_TYPE_RELATIVE},n.POSITION_TYPE_RELATIVE)),typeof o.top!="undefined"&&e.setPosition(n.EDGE_TOP,o.top),typeof o.bottom!="undefined"&&e.setPosition(n.EDGE_BOTTOM,o.bottom),typeof o.left!="undefined"&&e.setPosition(n.EDGE_LEFT,o.left),typeof o.right!="undefined"&&e.setPosition(n.EDGE_RIGHT,o.right),typeof o.height!="undefined"?e.setHeight(o.height):e.setHeightAuto(),typeof o.width!="undefined"?e.setWidth(o.width):e.setWidthAuto(),[o,Me(o)]}function ue({left:e,top:r,width:t,height:i},a,n,o){var f,h,g,p;let s;if(n)s=a;else{let l=(h=o==null?void 0:o.xAbsolute)!=null?h:((f=o==null?void 0:o.xRelative)!=null?f:50)*t/100,c=(p=o==null?void 0:o.yAbsolute)!=null?p:((g=o==null?void 0:o.yRelative)!=null?g:50)*i/100,u=e+l,d=r+c;s=ge([1,0,0,1,u,d],ge(a,[1,0,0,1,-u,-d])),a.__parent&&(s=ge(a.__parent,s)),a.splice(0,6,...s)}return`matrix(${s.map(l=>l.toFixed(2)).join(",")})`}function wt({left:e,top:r,width:t,height:i,isInheritingTransform:a},n){let o="",s=1;return n.transform&&(o=ue({left:e,top:r,width:t,height:i},n.transform,a,n.transformOrigin)),n.opacity&&(s=+n.opacity),{matrix:o,opacity:s}}function Ue({id:e,content:r,filter:t,left:i,top:a,width:n,height:o,matrix:s,opacity:f,image:h,clipPathId:g,debug:p,shape:l,decorationShape:c},u){let d="";if(p&&(d=y("rect",{x:i,y:a-o,width:n,height:o,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0})),h){let x={href:h,x:i,y:a,width:n,height:o,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0,style:u.filter?`filter:${u.filter}`:void 0};return[(t?`${t}<g filter="url(#satori_s-${e})">`:"")+y("image",se(G({},x),{opacity:f!==1?f:void 0}))+(c||"")+(t?"</g>":"")+d,""]}let b={x:i,y:a,width:n,height:o,"font-weight":u.fontWeight,"font-style":u.fontStyle,"font-size":u.fontSize,"font-family":u.fontFamily,"letter-spacing":u.letterSpacing||void 0,transform:s||void 0,"clip-path":g?`url(#${g})`:void 0,style:u.filter?`filter:${u.filter}`:void 0};return[(t?`${t}<g filter="url(#satori_s-${e})">`:"")+y("text",se(G({},b),{fill:u.color,opacity:f!==1?f:void 0}),r)+(c||"")+(t?"</g>":"")+d,l?y("text",b,r):""]}function de({id:e,width:r,height:t},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let a=i.shadowRadius*i.shadowRadius/4,n=Math.min(i.shadowOffset.width-a,0),o=Math.max(i.shadowOffset.width+a+r,r),s=Math.min(i.shadowOffset.height-a,0),f=Math.max(i.shadowOffset.height+a+t,t);return`<defs><filter id="satori_s-${e}" x="${n/r*100}%" y="${s/t*100}%" width="${(o-n)/r*100}%" height="${(f-s)/t*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}function ze({width:e,left:r,top:t,ascender:i,clipPathId:a},n){let{textDecorationColor:o,textDecorationStyle:s,textDecorationLine:f,fontSize:h}=n;if(!f||f==="none")return"";let g=Math.max(1,h*.1),p=f==="line-through"?t+i*.5:f==="underline"?t+i*1.1:t,l=s==="dashed"?`${g*1.2} ${g*2}`:s==="dotted"?`0 ${g*2}`:void 0;return y("line",{x1:r,y1:p,x2:r+e,y2:p,stroke:o,"stroke-width":g,"stroke-dasharray":l,"stroke-linecap":s==="dotted"?"round":"square","clip-path":a?`url(#${a})`:void 0})}var Ve=void 0;function*je(e,r){var lt;let t=te(),{parentStyle:i,inheritedStyle:a,parent:n,font:o,id:s,isInheritingTransform:f,debug:h,embedFont:g,graphemeImages:p,canLoadAdditionalAssets:l}=r;i.textTransform==="uppercase"?e=e.toLocaleUpperCase(Ve):i.textTransform==="lowercase"?e=e.toLocaleLowerCase(Ve):i.textTransform==="capitalize"&&(e=le(e,"word").map(C=>le(C,"grapheme").map((I,A)=>A===0?I.toLocaleUpperCase(Ve):I).join("")).join(""));let c=q(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),u=le(e,c),d=t.Node.create();d.setAlignItems(t.ALIGN_BASELINE),i.textAlign==="left"?d.setJustifyContent(t.JUSTIFY_FLEX_START):i.textAlign==="center"?d.setJustifyContent(t.JUSTIFY_CENTER):i.textAlign==="right"?d.setJustifyContent(t.JUSTIFY_FLEX_END):i.textAlign==="justify"&&d.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),n.insertChild(d,n.getChildCount());let{textAlign:b,textOverflow:x,whiteSpace:F,lineHeight:v,filter:N,_inheritedBackgroundClipTextPath:W}=i,M=i.fontSize,S=o.getEngine(M,v,i),H=l?u.filter(C=>!S.resolve(C)):[];yield H,H.length&&(S=o.getEngine(M,v,i));let _=[],T=[],X=[],K=[],Q=new Map,w=C=>{let I=0;for(let A of C){if(Q.has(A)){I+=Q.get(A);continue}let Y=S.measure(A,i);Q.set(A,Y),I+=Y}return I},$=0,R=[],m=0;for(let C of u){let I=!1,A=p&&p[C];F==="pre"?I=C[0]===`
2
+ `:F!=="nowrap"&&(A||ye.includes(C[0]))&&(I=!0),I?(F==="nowrap"?m+=w(R)+i.fontSize:($=Math.max($,w(R)),A&&($=Math.max($,i.fontSize))),R=[]):(!ye.includes(C[0])||!R.length)&&R.push(C===`
3
+ `?" ":C)}$=Math.max($,w(R)+m);let E=n.getMinWidth(),L=n.getMaxWidth(),Z=n.getWidth();isNaN(Z.value)&&(isNaN(E.value)||E.unit===1&&E.value>$)&&(isNaN(L.value)||L.unit===1&&($=Math.min($,L.value)),n.setMinWidth($)),typeof i.flexShrink=="undefined"&&n.setFlexShrink(1);let he=F==="pre-wrap"||F==="pre";d.setMeasureFunc(C=>{let I=0,A="",Y=0,U=0,z=0,V=-1,ie=0,P=0,oe=0;_=[],X=[0];for(let ne=0;ne<u.length;ne++){let D=u[ne];if(!he&&ye.includes(D[0]))A||(A=" "),Y=w([A]),K[ne]=null;else{let ae=he&&D===`
4
+ `,j=ae?0:p&&p[D]?i.fontSize:w([D]);U||(A="",Y=0);let B=Y||",.!?:-@)>]}%#".indexOf(D[0])<0,J=!U||!!Y;if(ae||ne&&B&&U+Y+j>C&&F!=="nowrap"&&F!=="pre")_.push(U),T.push(oe),I++,ie+=P,U=j,P=j?S.glyphHeight(D):0,oe=j?S.baseline(D):0,X.push(1),V=-1,ae||(z=Math.max(z,C));else{U+=Y+j;let me=S.glyphHeight(D);me>P&&(P=me,oe=S.baseline(D)),J&&X[X.length-1]++}A="",Y=0,J&&V++,z=Math.max(z,U),K[ne]={y:ie,x:U-j,width:j,line:I,lineIndex:V}}}return U&&(I++,_.push(U),T.push(oe),ie+=P),{width:z,height:ie}});let[Lt,Ct]=yield,Oe="",_e="",re=a._inheritedClipPathId,{left:nt,top:it,width:we,height:ot}=d.getComputedLayout(),$e=n.getComputedWidth()-n.getComputedPadding(t.EDGE_LEFT)-n.getComputedPadding(t.EDGE_RIGHT)-n.getComputedBorder(t.EDGE_LEFT)-n.getComputedBorder(t.EDGE_RIGHT),ce=Lt+nt,pe=Ct+it,{matrix:ee,opacity:Re}=wt({left:nt,top:it,width:we,height:ot,isInheritingTransform:f},i),be="";i.textShadowOffset&&(be=de({width:we,height:ot,id:s},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let ve="",Te="",at="",Fe=-1,st=x==="ellipsis"?w(["\u2026"]):0,It=x==="ellipsis"?w([" "]):0,Le={};for(let C=0;C<u.length;C++){if(!K[C])continue;let I=K[C],A=u[C],Y=null,U=p?p[A]:null,z=I.y,V=I.x,ie=I.width,P=I.line;if(P===Fe)continue;let oe=!1;if(_.length>1){let B=we-_[P];if(b==="right"||b==="end")V+=B;else if(b==="center")V+=B/2;else if(b==="justify"&&P<_.length-1){let J=X[P];V+=(J>1?B/(J-1):0)*I.lineIndex,oe=!0}}if(Le[P]||(Le[P]=[V,oe?we:_[P]]),x==="ellipsis"&&_[P]>$e&&I.x+ie+st+It>$e){let B=le(A,"grapheme"),J="",me=0;for(let ft of B){let ut=I.x+w([J+ft]);if(J&&ut+st>$e)break;J+=ft,me=ut}A=J+"\u2026",Fe=P,Le[P][1]=me}let ne=T[P],D=S.baseline(A),ae=S.glyphHeight(A),j=ne-D;if(U?z+=0:g?(Y=S.getSVG(A,se(G({},i),{left:ce+V,top:pe+z+D+j,letterSpacing:i.letterSpacing})),h&&(at+=y("rect",{x:ce+V,y:pe+z+j,width:I.width,height:ae,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:ee||void 0,"clip-path":re?`url(#${re})`:void 0})+y("line",{x1:ce+V,x2:ce+V+I.width,y1:pe+z+j+D,y2:pe+z+j+D,stroke:"#14c000","stroke-width":1,transform:ee||void 0,"clip-path":re?`url(#${re})`:void 0}))):z+=D+j,i.textDecorationLine&&(P!==((lt=K[C+1])==null?void 0:lt.line)||Fe===P)){let B=Le[P];B&&!B[2]&&(ve+=ze({left:ce+B[0],top:pe+ae*+P,width:B[1],ascender:S.baseline(A),clipPathId:re},i),B[2]=1)}if(Y!==null)Te+=Y+" ";else{let[B,J]=Ue({content:A,filter:be,id:s,left:ce+V,top:pe+z,width:ie,height:ae,matrix:ee,opacity:Re,image:U,clipPathId:re,debug:h,shape:!!W,decorationShape:ve},i);Oe+=B,_e+=J,ve=""}}if(Te){let C=i.color!=="transparent"&&Re!==0?y("path",{fill:i.color,d:Te,transform:ee||void 0,opacity:Re!==1?Re:void 0,"clip-path":re?`url(#${re})`:void 0,style:N?`filter:${N}`:void 0}):"";W&&(_e=y("path",{d:Te,transform:ee||void 0})),Oe+=(be?`${be}<g filter="url(#satori_s-${s})">`:"")+C+ve+(be?"</g>":"")+at}return _e&&(i._inheritedBackgroundClipTextPath.value+=_e),Oe}var Je=Je||{};Je.parse=function(){var e={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function t(m){var E=new Error(r+": "+m);throw E.source=r,E}function i(){var m=a();return r.length>0&&t("Invalid input not EOF"),m}function a(){return v(n)}function n(){return o("linear-gradient",e.linearGradient,f)||o("repeating-linear-gradient",e.repeatingLinearGradient,f)||o("radial-gradient",e.radialGradient,p)||o("repeating-radial-gradient",e.repeatingRadialGradient,p)}function o(m,E,L){return s(E,function(Z){var he=L();return he&&($(e.comma)||t("Missing comma before color stops")),{type:m,orientation:he,colorStops:v(N)}})}function s(m,E){var L=$(m);if(L){$(e.startCall)||t("Missing (");var Z=E(L);return $(e.endCall)||t("Missing )"),Z}}function f(){return h()||g()}function h(){return w("directional",e.sideOrCorner,1)}function g(){return w("angular",e.angleValue,1)}function p(){var m,E=l(),L;return E&&(m=[],m.push(E),L=r,$(e.comma)&&(E=l(),E?m.push(E):r=L)),m}function l(){var m=c()||u();if(m)m.at=b();else{var E=d();if(E){m=E;var L=b();L&&(m.at=L)}else{var Z=x();Z&&(m={type:"default-radial",at:Z})}}return m}function c(){var m=w("shape",/^(circle)/i,0);return m&&(m.style=Q()||d()),m}function u(){var m=w("shape",/^(ellipse)/i,0);return m&&(m.style=X()||d()),m}function d(){return w("extent-keyword",e.extentKeywords,1)}function b(){if(w("position",/^at/,0)){var m=x();return m||t("Missing positioning value"),m}}function x(){var m=F();if(m.x||m.y)return{type:"position",value:m}}function F(){return{x:X(),y:X()}}function v(m){var E=m(),L=[];if(E)for(L.push(E);$(e.comma);)E=m(),E?L.push(E):t("One extra comma");return L}function N(){var m=W();return m||t("Expected color definition"),m.length=X(),m}function W(){return S()||_()||H()||M()}function M(){return w("literal",e.literalColor,0)}function S(){return w("hex",e.hexColor,1)}function H(){return s(e.rgbColor,function(){return{type:"rgb",value:v(T)}})}function _(){return s(e.rgbaColor,function(){return{type:"rgba",value:v(T)}})}function T(){return $(e.number)[1]}function X(){return w("%",e.percentageValue,1)||K()||Q()}function K(){return w("position-keyword",e.positionKeywords,1)}function Q(){return w("px",e.pixelValue,1)||w("em",e.emValue,1)}function w(m,E,L){var Z=$(E);if(Z)return{type:m,value:Z[L]}}function $(m){var E,L;return L=/^[\n\r\t\s]+/.exec(r),L&&R(L[0].length),E=m.exec(r),E&&R(E[0].length),E}function R(m){r=r.substr(m)}return function(m){return r=m.toString(),i()}}();var qe=Je;function fr(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function ur(e,r){return typeof e=="string"&&e.endsWith("%")?r*parseFloat(e)/100:+e}function Rt(e,{x:r,y:t,defaultX:i,defaultY:a}){return(e?e.split(" ").map(n=>{try{let o=new fe(n);return o.type==="length"||o.type==="number"?o.value:o.value+o.unit}catch{return null}}).filter(n=>n!==null):[i,a]).map((n,o)=>ur(n,[r,t][o]))}function vt(e,r){let t=[];for(let o of r){let s=fr(o);if(!t.length&&(t.push({offset:0,color:s}),typeof o.length=="undefined"||o.length.value==="0"))continue;let f=typeof o.length=="undefined"?void 0:o.length.type==="%"?o.length.value/100:o.length.value/e;t.push({offset:f,color:s})}t.length||t.push({offset:0,color:"transparent"});let i=t[t.length-1];i.offset!==1&&(typeof i.offset=="undefined"?i.offset=1:t.push({offset:1,color:i.color}));let a=0,n=1;for(let o=0;o<t.length;o++)if(typeof t[o].offset=="undefined"){for(n<o&&(n=o);typeof t[n].offset=="undefined";)n++;t[o].offset=(t[n].offset-t[a].offset)/(n-a)*(o-a)+t[a].offset}else a=o;return t}function Ke({id:e,width:r,height:t},{image:i,size:a,position:n,repeat:o}){o=o||"repeat";let s=o==="repeat-x"||o==="repeat",f=o==="repeat-y"||o==="repeat",h=Rt(a,{x:r,y:t,defaultX:r,defaultY:t}),g=Rt(n,{x:r,y:t,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let p=qe.parse(i)[0],l,c,u,d;if(p.orientation.type==="directional")[l,c,u,d]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[p.orientation.value];else if(p.orientation.type==="angular"){let x=+p.orientation.value/180*Math.PI-Math.PI/2,F=Math.cos(x),v=Math.sin(x);l=0,c=0,u=F,d=v,u<0&&(l-=u,u=0),d<0&&(c-=d,d=0)}let b=vt(r,p.colorStops);return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${l}" y1="${c}" x2="${u}" y2="${d}">${b.map(x=>`<stop offset="${x.offset*100}%" stop-color="${x.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("radial-gradient(")){let p=qe.parse(i)[0],l=p.orientation[0],[c,u]=h,d="circle",b=c/2,x=u/2;if(l.type==="shape"){if(d=l.value,l.at)if(l.at.type==="position")b=l.at.value.x.value,x=l.at.value.y.value;else throw new Error("orientation.at.type not implemented: "+l.at.type)}else throw new Error("orientation.type not implemented: "+l.type);let F=vt(r,p.colorStops),v=`satori_radial_${e}`,N=`satori_pattern_${e}`,W={},M=Math.max(Math.abs(c-b),Math.abs(b)),S=Math.max(Math.abs(u-x),Math.abs(x));if(d==="circle")W.r=Math.sqrt(M*M+S*S);else if(d==="ellipse"){let T=S!==0?M/S:1;W.ry=Math.sqrt(M*M+S*S*T*T)/T,W.rx=W.ry*T}let H=y("pattern",{id:N,x:g[0],y:g[1],width:s?c:"100%",height:f?u:"100%",patternUnits:"userSpaceOnUse"},y("radialGradient",{id:v},F.map(T=>y("stop",{offset:T.offset,"stop-color":T.color})).join(""))+y(d,se(G({cx:b,cy:x,width:c,height:u},W),{fill:`url(#${v})`})));return[N,H]}if(i.startsWith("url(")){let p=i.slice(4,-1);return[`satori_bi${e}`,y("pattern",{id:`satori_bi${e}`,patternContentUnits:"userSpaceOnUse",patternUnits:"userSpaceOnUse",x:g[0],y:g[1],width:s?h[0]:"100%",height:f?h[1]:"100%"},y("image",{x:0,y:0,width:h[0],height:h[1],href:p}))]}}function Ae(e,r,t){return t<e+r&&(t/2<e&&t/2<r?e=r=t/2:t/2<e?e=t-r:t/2<r&&(r=t-e)),[e,r]}function Ee({left:e,top:r,width:t,height:i},a){let{borderTopLeftRadius:n,borderTopRightRadius:o,borderBottomLeftRadius:s,borderBottomRightRadius:f}=a;return n=Math.min(n||0,t,i),o=Math.min(o||0,t,i),s=Math.min(s||0,t,i),f=Math.min(f||0,t,i),!n&&!o&&!s&&!f?"":([n,o]=Ae(n,o,t),[n,s]=Ae(n,s,i),[o,f]=Ae(o,f,i),[s,f]=Ae(s,f,t),`M${e+n},${r} h${t-n-o} a${o},${o} 0 0 1 ${o},${o} v${i-o-f} a${f},${f} 0 0 1 ${-f},${f} h${f+s-t} a${s},${s} 0 0 1 ${-s},${-s} v${s+n-i} a${n},${n} 0 0 1 ${n},${-n}`)}function Ze({left:e,top:r,width:t,height:i,path:a,id:n},o){return o.overflow!=="hidden"?"":a?y("clipPath",{id:`satori_cp-${n}`,"clip-path":o._inheritedClipPathId?`url(#${o._inheritedClipPathId})`:void 0},y("path",{x:e,y:r,width:t,height:i,d:a})):y("clipPath",{id:`satori_cp-${n}`,"clip-path":o._inheritedClipPathId?`url(#${o._inheritedClipPathId})`:void 0},y("rect",{x:e,y:r,width:t,height:i}))}function Qe({id:e,left:r,top:t,width:i,height:a,isInheritingTransform:n,debug:o},s){if(s.display==="none")return"";let f="rect",h="transparent",g=0,p="",l="",c=[],u=1,d="";s.backgroundColor&&c.push(s.backgroundColor),s.borderWidth&&(g=s.borderWidth,h=s.borderColor),s.opacity&&(u=+s.opacity),s.transform&&(p=ue({left:r,top:t,width:i,height:a},s.transform,n,s.transformOrigin));let b="";if(s.backgroundImage){let H=s.backgroundImage.map((_,T)=>Ke({id:e+"_"+T,width:i,height:a},_)).filter(Boolean);for(let _ of H)c.push(`url(#${_[0]})`),l+=_[1],_[2]&&(b+=_[2])}let x=Ee({left:r,top:t,width:i,height:a},s);x&&(f="path");let F=Ze({left:r,top:t,width:i,height:a,path:x,id:e},s),v=s._inheritedClipPathId,N=de({width:i,height:a,id:e},s);o&&(d=y("rect",{x:r,y:t,width:i,height:a,fill:"transparent",stroke:"#ff5757","stroke-width":1,transform:p||void 0,"clip-path":v?`url(#${v})`:void 0})),c.length||c.push("transparent");let{backgroundClip:W,filter:M}=s,S=c.map((H,_)=>{if(H==="transparent"&&!(_===c.length-1&&g))return"";let T=_===c.length-1&&g&&W!=="text";return y(f,{x:r,y:t,width:i,height:a,fill:H,stroke:T?h:void 0,"stroke-width":T?g:void 0,d:x||void 0,transform:p||void 0,"clip-path":W==="text"?`url(#satori_bct-${e})`:v?`url(#${v})`:void 0,style:M?`filter:${M}`:void 0})}).join("");return W==="text"&&g&&(S=y(f,{x:r,y:t,width:i,height:a,fill:"transparent",stroke:h,"stroke-width":g,d:x||void 0,transform:p||void 0,"clip-path":v?`url(#${v})`:void 0})+S),(l?`<defs>${l}</defs>`:"")+F+(N?`${N}<g filter="url(#satori_s-${e})">`:"")+(u!==1?`<g opacity="${u}">`:"")+(b||S)+(u!==1?"</g>":"")+(N?"</g>":"")+d}function et({id:e,left:r,top:t,width:i,height:a,src:n,debug:o,isInheritingTransform:s},f){if(f.display==="none")return"";let h="",g=1,p="",l=f.objectFit==="contain"?"xMidYMid":f.objectFit==="cover"?"xMidYMid slice":"none",c=Ee({left:r,top:t,width:i,height:a},f),u=f._inheritedClipPathId;c&&(h=y("clipPath",{id:`satori_c-${e}`,"clip-path":u?`url(#${u})`:void 0},y("path",{x:r,y:t,width:i,height:a,d:c}))),f.opacity&&(g=+f.opacity);let d=de({width:i,height:a,id:e},f);return f.transform&&(p=ue({left:r,top:t,width:i,height:a},f.transform,s,f.transformOrigin)),d+(d?`<g filter="url(#satori_s-${e})">`:"")+h+y("image",{x:r,y:t,width:i,height:a,href:n,preserveAspectRatio:l,transform:p||void 0,"clip-path":h?`url(#satori_c-${e})`:u?`url(#${u})`:void 0})+(d?"</g>":"")}function*Se(e,r){let t=te(),{id:i,inheritedStyle:a,parent:n,font:o,debug:s,embedFont:f=!0,graphemeImages:h,canLoadAdditionalAssets:g}=r;if(e===null||typeof e=="undefined")return yield,yield,"";if(!We(e)||typeof e.type=="function"){let R;if(!We(e))R=je(String(e),r),yield R.next().value;else{if(mt(e.type))throw new Error("Class component is not supported.");R=Se(e.type(e.props),r),yield R.next().value}R.next();let m=yield;return R.next(m).value}let{type:p,props:l}=e,{style:c,children:u}=l,d=t.Node.create();n.insertChild(d,n.getChildCount());let[b,x]=Xe(d,p,a,c,l),F=b.transform===a.transform;if(F||(b.transform.__parent=a.transform),b.overflow==="hidden"&&(x._inheritedClipPathId=`satori_cp-${i}`),b.backgroundClip==="text"){let R={value:""};x._inheritedBackgroundClipTextPath=R,b._inheritedBackgroundClipTextPath=R}let v=typeof u=="undefined"?[]:[].concat(u),N=[],W=0,M=[];for(let R of v){let m=Se(R,{id:i+"-"+W++,parentStyle:b,inheritedStyle:x,isInheritingTransform:!0,parent:d,font:o,embedFont:f,debug:s,graphemeImages:h,canLoadAdditionalAssets:g});g?M.push(...m.next().value||[]):m.next(),N.push(m)}yield M;for(let R of N)R.next();let[S,H]=yield;b.position==="absolute"&&d.calculateLayout();let{left:_,top:T,width:X,height:K}=d.getComputedLayout();_+=S,T+=H;let Q="",w="",$="";p==="img"?w=et({id:i,left:_,top:T,width:X,height:K,src:l.src,isInheritingTransform:F,debug:s},b):w=Qe({id:i,left:_,top:T,width:X,height:K,isInheritingTransform:F,debug:s},b);for(let R of N)Q+=R.next([_,T]).value;return b._inheritedBackgroundClipTextPath&&($+=y("clipPath",{id:`satori_bct-${i}`,"clip-path":b._inheritedClipPathId?`url(#${b._inheritedClipPathId})`:void 0},b._inheritedBackgroundClipTextPath.value)),$+w+Q}import dr from"@shuding/opentype.js";function cr(e,r,[t,i],[a,n]){if(t!==a)return t?!a||t===e?-1:a===e?1:e===400&&t===500||e===500&&t===400?-1:e===400&&a===500||e===500&&a===400?1:e<400?t<e&&a<e?a-t:t<e?-1:a<e?1:t-a:e<t&&e<a?t-a:e<t?-1:e<a?1:a-t:1;if(i!==n){if(i===r)return-1;if(n===r)return 1}return-1}var ke=class{constructor(r){this.fonts=new Map;this.addFonts(r)}get({name:r,weight:t,style:i}){if(!this.fonts.has(r))return null;t==="normal"&&(t=400),t==="bold"&&(t=700);let a=[...this.fonts.get(r)],n=a[0];for(let o=1;o<a.length;o++){let[,s,f]=n,[,h,g]=a[o];cr(t,i,[s,f],[h,g])>0&&(n=a[o])}return n[0]}addFonts(r){for(let t of r){let i=t.data,a=dr.parse("buffer"in i?i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength):i,{lowMemory:!0});this.defaultFont||(this.defaultFont=a);let n=t.name.toLowerCase();this.fonts.has(n)||this.fonts.set(n,[]),this.fonts.get(n).push([a,t.weight,t.style])}}getEngine(r=16,t=1.2,{fontFamily:i,fontWeight:a=400,fontStyle:n="normal"}){i=Array.isArray(i)?i:[i];let o=i.map(l=>this.get({name:l,weight:a,style:n})).filter(Boolean);for(let l of this.fonts.keys())i.includes(l)||o.push(this.get({name:l,weight:a,style:n}));let s=new Map,f=(l,c=!0)=>{let u=l.charCodeAt(0);if(s.has(u))return s.get(u);let d=o.find((b,x)=>!!b.charToGlyphIndex(l)||c&&x===o.length-1);return d&&s.set(u,d),d},h=(l,c=!1)=>{var d,b;return((c?(b=(d=l.tables)==null?void 0:d.os2)==null?void 0:b.sTypoAscender:0)||l.ascender)/l.unitsPerEm*r},g=(l,c=!1)=>{var d,b;return((c?(b=(d=l.tables)==null?void 0:d.os2)==null?void 0:b.sTypoDescender:0)||l.descender)/l.unitsPerEm*r},p={resolve:l=>f(l,!1),baseline:(l,c=typeof l=="undefined"?o[0]:f(l))=>{let u=h(c,!0),d=g(c,!0),b=u-d,x=p.glyphHeight(l,c),F=(x-b)/2,{yMax:v,yMin:N}=c.tables.head,W=v/(v-N);return F+W*x},glyphHeight:(l,c=typeof l=="undefined"?o[0]:f(l))=>(h(c)-g(c))*t/1.2,measure:(l,c)=>{let u=f(l);return this.measure(u,l,c)},getSVG:(l,c)=>{let u=f(l);return this.getSVG(u,l,c)}};return p}measure(r,t,{fontSize:i,letterSpacing:a=0}){return r.getAdvanceWidth(t,i,{letterSpacing:a/i})}getSVG(r,t,{fontSize:i,top:a,left:n,letterSpacing:o=0}){return r.getPath(t,n,a,i,{letterSpacing:o/i}).toPathData(1)}};function tt({width:e,height:r,content:t}){return y("svg",{width:e,height:r,viewBox:`0 0 ${e} ${r}`,xmlns:"http://www.w3.org/2000/svg"},t)}var rt=new WeakMap;async function Tt(e,r){let t=te();if(!t)throw new Error("Satori is not initialized.");let i;rt.has(r.fonts)?i=rt.get(r.fonts):rt.set(r.fonts,i=new ke(r.fonts));let a=t.Node.create();a.setWidth(r.width),a.setHeight(r.height),a.setFlexDirection(t.FLEX_DIRECTION_ROW),a.setFlexWrap(t.WRAP_WRAP),a.setAlignContent(t.ALIGN_AUTO),a.setAlignItems(t.ALIGN_FLEX_START),a.setJustifyContent(t.JUSTIFY_FLEX_START),a.setOverflow(t.OVERFLOW_HIDDEN);let n=G({},r.graphemeImages),o=Se(e,{id:"id",parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1,whiteSpace:"normal",_viewportWidth:r.width,_viewportHeight:r.height},parent:a,font:i,embedFont:r.embedFont,debug:r.debug,graphemeImages:n,canLoadAdditionalAssets:!!r.loadAdditionalAsset}),s=o.next().value;if(r.loadAdditionalAsset&&s.length){s=Array.from(new Set(le(s.join(""),"grapheme")));let h={};s.forEach(l=>pr.detect(l,c=>{h[c]=h[c]||[],c==="unknown"?h[c].push(l):h[c][0]=(h[c][0]||"")+l}));let g=[],p={};await Promise.all(Object.entries(h).flatMap(([l,c])=>c.map(u=>r.loadAdditionalAsset(l,u).then(d=>{typeof d=="string"?p[u]=d:d&&g.push(d)})))),i.addFonts(g),Object.assign(n,p)}o.next(),a.calculateLayout(r.width,r.height,t.DIRECTION_LTR);let f=o.next([0,0]).value;return a.freeRecursive(),tt({width:r.width,height:r.height,content:f})}export{Tt as default,Wt as init};
2
5
  //# sourceMappingURL=index.js.map