sone
Version:
A declarative Canvas layout engine for JavaScript with advanced rich text support.
3 lines (2 loc) • 44.9 kB
JavaScript
"use strict";var $e=Object.create;var O=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var Ve=(e,t)=>{for(var o in t)O(e,o,{get:t[o],enumerable:!0})},be=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Oe(t))!Fe.call(e,a)&&a!==o&&O(e,a,{get:()=>t[a],enumerable:!(r=Ee(t,a))||r.enumerable});return e};var G=(e,t,o)=>(o=e!=null?$e(Ge(e)):{},be(t||!e||!e.__esModule?O(o,"default",{value:e,enumerable:!0}):o,e)),Ye=e=>be(O({},"__esModule",{value:!0}),e);var Gt={};Ve(Gt,{Column:()=>Nt,DEFAULT_TEXT_PROPS:()=>se,Font:()=>Ot,Path:()=>Mt,Photo:()=>At,Row:()=>Wt,Span:()=>Lt,Table:()=>Dt,TableCell:()=>It,TableRow:()=>Ht,Text:()=>qt,TextDefault:()=>Bt,applySpanProps:()=>I,calculateLayout:()=>de,compile:()=>Q,createLayoutNode:()=>le,createMetadata:()=>Ne,defaultLineBreakerIterator:()=>Z,drawDebugBBox:()=>We,drawLayoutNode:()=>U,drawOnCanvas:()=>he,drawPathNode:()=>Ae,drawTableNode:()=>Me,findFonts:()=>ue,fontBuilder:()=>te,getYogaLayout:()=>qe,makeTransforms:()=>ge,pathPropsBuilder:()=>De,qrcode:()=>zt,render:()=>pe,renderWithMetadata:()=>fe,renderer:()=>$,sone:()=>Et});module.exports=Ye(Gt);var Ie=require("buffer"),D=G(require("skia-canvas"));var K=null,je="\u17D4\u17D5)]?!\xBB\u17D6",Xe="([\xAB";function*Z(e){K==null&&(K=new Intl.Segmenter(void 0,{granularity:"word"}));for(let t of K.segment(e)){if(t.segment.endsWith("\u17D2"))continue;let o=e[t.index];if(o!==void 0&&je.indexOf(o)!==-1)continue;let r=e[t.index-1];r!==void 0&&Xe.indexOf(r)!==-1||(yield t.index)}}var J=require("gradient-parser"),ae=require("klona"),Le=G(require("object.pick")),ve=G(require("p-memoize")),Be=G(require("svg-path-bounds")),N=require("yoga-layout/load");var Te={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};var _e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,Je=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/,Ue=/^hsl\(\s*(\d+)\s*,\s*(\d*(?:\.\d+)?%)\s*,\s*(\d*(?:\.\d+)?%)\)$/,Qe=/^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*(\d*(?:\.\d+)?)\)$/,Ke=/^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;function F(e){return e==="transparent"||e in Te?!0:_e.test(e)||Je.test(e)||Ue.test(e)||Qe.test(e)||Ke.test(e)}function Ze(e){switch(e.type){case"hex":return`#${e.value}`;case"literal":return e.value;default:return`${e.type}(${e.value.join(",")})`}}function et(e,t,o,r){let{length:a}=e;if(!a)return 1/(t-1)*o;if(a.type==="px")return Number.parseFloat(a.value);if(a.type==="%")return r?Number.parseFloat(a.value)*r/100:Number(a.value)/100}function ye(e,t){return e.reduce((o,r,a)=>{o.colors=[...o.colors,Ze(r)];let s=et(r,e.length,a,t);return o.locations=[...o.locations,s],o},{colors:[],locations:[]})}function tt(e,t){let{width:o}=t,{colors:r,locations:a}=ye(e,o),s=a.slice(-1)[0],i=typeof s=="number"?s:Number.parseFloat(s),n=i/o,u=Math.round(o/i),l=[];for(let g=0;g<u;g++)for(let p of a)l.push(p/o+n*g);return{colors:l.map((g,p)=>r[p%r.length]),locations:l}}function rt(e){return Math.round(e*1e4)/1e4}function nt(e){return e*Math.PI/180}var ot=e=>e==null?A(180):e.type==="directional"?it(e.value):A(Number(e.value));function A(e){let t=nt(e),o=rt(Math.abs(Math.sin(t))+Math.abs(Math.cos(t))),r={x:.5,y:.5},a=Math.sin(t-Math.PI/2)*o/2,s=Math.cos(t-Math.PI/2)*o/2;return{start:{x:r.x-s,y:r.y-a},end:{x:r.x+s,y:r.y+a}}}function it(e){switch(e){case"top":return A(0);case"right":return A(90);case"bottom":return A(180);case"left":return A(270);case"left top":return A(315);case"left bottom":return A(225);case"right top":return A(45);case"right bottom":return A(135)}}function at(e,t){let o=[];for(let{type:r,colorStops:a,orientation:s}of e){if(r==="radial-gradient"||r==="repeating-radial-gradient")continue;let i=r==="linear-gradient"?ye(a):tt(a,t),n=ot(s),u={...i,...n};o.push(u)}return o}function V(e,t,o,r,a,s){let i=at(t,{width:a,height:s}),n=[];for(let u of i){let l=e.createLinearGradient(o+u.start.x*a,r+u.start.y*s,o+u.end.x*a,r+u.end.y*s);for(let d=0;d<u.colors.length;d++){let g=u.colors[d],p=u.locations[d];p<0&&(p=0),p>1&&(p=1),l.addColorStop(p,g)}n.push(l)}return n}var E=require("yoga-layout/load");function Y(e,t,o,r,a,s){let i=t.getComputedBorder(E.Edge.Left),n=t.getComputedBorder(E.Edge.Top),u=t.getComputedBorder(E.Edge.Right),l=t.getComputedBorder(E.Edge.Bottom);i===n&&n===u&&u===l&&i>0&&(e.save(),e.translate(a,s),e.strokeStyle=o.borderColor,e.lineJoin="round",e.lineWidth=i*2,e.clip(r),e.stroke(r),e.translate(-a,-s),e.restore())}var we=require("figma-squircle");function j(e,t){for(let o=0;o<e.length;o++)e[o]=Math.max(0,Math.min(e[o],t/2));return e}function X(e,t,o,r,a=0,s="round"){let i=a;i>1&&(i=1),i<0&&(i=0);let n={topLeftCornerRadius:0,topRightCornerRadius:0,bottomRightCornerRadius:0,bottomLeftCornerRadius:0};if(r.length===1&&(n.topLeftCornerRadius=r[0],n.topRightCornerRadius=r[0],n.bottomRightCornerRadius=r[0],n.bottomLeftCornerRadius=r[0]),r.length===2&&(n.topLeftCornerRadius=r[0],n.bottomRightCornerRadius=r[0],n.topRightCornerRadius=r[1],n.bottomLeftCornerRadius=r[1]),r.length>2&&(n.topLeftCornerRadius=r[0],n.topRightCornerRadius=r[1]??0,n.bottomRightCornerRadius=r[2]??0,n.bottomLeftCornerRadius=r[3]??0),s==="round"){let l=(0,we.getSvgPath)({cornerSmoothing:i,width:t,height:o,preserveSmoothing:!0,...n});return new e.Path2D(l)}let u=new e.Path2D;return u.moveTo(n.topLeftCornerRadius,0),u.lineTo(t-n.topRightCornerRadius,0),u.lineTo(t,n.topRightCornerRadius),u.lineTo(t,o-n.bottomRightCornerRadius),u.lineTo(t-n.bottomRightCornerRadius,o),u.lineTo(n.bottomLeftCornerRadius,o),u.lineTo(0,o-n.bottomLeftCornerRadius),u.lineTo(0,n.topLeftCornerRadius),u.closePath(),u}function ee(e,t,o,r,a,s){let i=o.props;if(i.image==null)return;let n=i.image,u=r.getComputedWidth(),l=r.getComputedHeight(),d=o.props.scaleType??"fill",g=n.width,p=n.height,T=a,c=s,m=u,b=l,w=n.width/n.height,P=u/l,R=i.scaleAlignment??1/2;switch(d){case"cover":if(w>P){let k=n.width*l/n.height;g=n.width,p=n.height,m=k,b=l,T=a+(u-k)*R}else{let k=n.height*u/n.width;g=n.width,p=n.height,m=u,b=k,c=s+(l-k)*R}break;case"contain":w>P?(m=u,b=u/w,c=s+(l-b)*R):(b=l,m=l*w,T=a+(u-m)*R);break}t.save();let y=X(e,u,l,j(i.cornerRadius??[0],Math.min(u,l)),i.cornerSmoothing);if(t.translate(a,s),t.clip(y),t.translate(-a,-s),i.background)for(let k of i.background)typeof k=="string"&&(t.fillStyle=k,t.fillRect(a,s,u,l));let x=i.flipHorizontal??!1,q=i.flipVertical??!1;if(x||q){let k=T+m/2,C=c+b/2;t.translate(k,C),t.scale(x?-1:1,q?-1:1),t.translate(-k,-C)}t.drawImage(n,0,0,g,p,T,c,m,b),t.restore(),(i.borderWidth!=null||i.borderTopWidth!=null||i.borderLeftWidth!=null||i.borderRightWidth!=null||i.borderBottomWidth!=null)&&Y(t,r,i,y,a,s)}var f=require("yoga-layout/load");function Re(e,t){for(let o of Object.keys(e))switch(o){case"alignContent":t.setAlignContent(st(e.alignContent));break;case"alignItems":t.setAlignItems(Pe(e.alignItems));break;case"alignSelf":t.setAlignSelf(Pe(e.alignSelf));break;case"aspectRatio":t.setAspectRatio(e.aspectRatio);break;case"borderBottomWidth":t.setBorder(f.Edge.Bottom,e.borderBottomWidth);break;case"borderEndWidth":t.setBorder(f.Edge.End,e.borderEndWidth);break;case"borderLeftWidth":t.setBorder(f.Edge.Left,e.borderLeftWidth);break;case"borderRightWidth":t.setBorder(f.Edge.Right,e.borderRightWidth);break;case"borderStartWidth":t.setBorder(f.Edge.Start,e.borderStartWidth);break;case"borderTopWidth":t.setBorder(f.Edge.Top,e.borderTopWidth);break;case"borderWidth":t.setBorder(f.Edge.All,e.borderWidth);break;case"borderInlineWidth":t.setBorder(f.Edge.Horizontal,e.borderInlineWidth);break;case"borderBlockWidth":t.setBorder(f.Edge.Vertical,e.borderBlockWidth);break;case"bottom":t.setPosition(f.Edge.Bottom,e.bottom);break;case"boxSizing":t.setBoxSizing(ut(e.boxSizing));break;case"direction":t.setDirection(lt(e.direction));break;case"display":t.setDisplay(dt(e.display));break;case"end":t.setPosition(f.Edge.End,e.end);break;case"flex":t.setFlex(e.flex);break;case"flexBasis":t.setFlexBasis(e.flexBasis);break;case"flexDirection":t.setFlexDirection(ft(e.flexDirection));break;case"rowGap":t.setGap(f.Gutter.Row,e.rowGap);break;case"gap":t.setGap(f.Gutter.All,e.gap);break;case"columnGap":t.setGap(f.Gutter.Column,e.columnGap);break;case"flexGrow":t.setFlexGrow(e.flexGrow);break;case"flexShrink":t.setFlexShrink(e.flexShrink);break;case"flexWrap":t.setFlexWrap(ht(e.flexWrap));break;case"height":t.setHeight(e.height);break;case"justifyContent":t.setJustifyContent(pt(e.justifyContent));break;case"left":t.setPosition(f.Edge.Left,e.left);break;case"margin":t.setMargin(f.Edge.All,e.margin);break;case"marginBottom":t.setMargin(f.Edge.Bottom,e.marginBottom);break;case"marginEnd":t.setMargin(f.Edge.End,e.marginEnd);break;case"marginLeft":t.setMargin(f.Edge.Left,e.marginLeft);break;case"marginRight":t.setMargin(f.Edge.Right,e.marginRight);break;case"marginStart":t.setMargin(f.Edge.Start,e.marginStart);break;case"marginTop":t.setMargin(f.Edge.Top,e.marginTop);break;case"marginInline":t.setMargin(f.Edge.Horizontal,e.marginInline);break;case"marginBlock":t.setMargin(f.Edge.Vertical,e.marginBlock);break;case"maxHeight":t.setMaxHeight(e.maxHeight);break;case"maxWidth":t.setMaxWidth(e.maxWidth);break;case"minHeight":t.setMinHeight(e.minHeight);break;case"minWidth":t.setMinWidth(e.minWidth);break;case"overflow":t.setOverflow(gt(e.overflow));break;case"padding":t.setPadding(f.Edge.All,e.padding);break;case"paddingBottom":t.setPadding(f.Edge.Bottom,e.paddingBottom);break;case"paddingEnd":t.setPadding(f.Edge.End,e.paddingEnd);break;case"paddingLeft":t.setPadding(f.Edge.Left,e.paddingLeft);break;case"paddingRight":t.setPadding(f.Edge.Right,e.paddingRight);break;case"paddingStart":t.setPadding(f.Edge.Start,e.paddingStart);break;case"paddingTop":t.setPadding(f.Edge.Top,e.paddingTop);break;case"paddingInline":t.setPadding(f.Edge.Horizontal,e.paddingInline);break;case"paddingBlock":t.setPadding(f.Edge.Vertical,e.paddingBlock);break;case"position":t.setPositionType(ct(e.position));break;case"right":t.setPosition(f.Edge.Right,e.right);break;case"start":t.setPosition(f.Edge.Start,e.start);break;case"top":t.setPosition(f.Edge.Top,e.top);break;case"insetInline":t.setPosition(f.Edge.Horizontal,e.insetInline);break;case"insetBlock":t.setPosition(f.Edge.Vertical,e.insetBlock);break;case"inset":t.setPosition(f.Edge.All,e.inset);break;case"width":t.setWidth(e.width);break}return t}function st(e){switch(e){case"flex-start":return f.Align.FlexStart;case"flex-end":return f.Align.FlexEnd;case"center":return f.Align.Center;case"stretch":return f.Align.Stretch;case"space-between":return f.Align.SpaceBetween;case"space-around":return f.Align.SpaceAround;case"space-evenly":return f.Align.SpaceEvenly}}function Pe(e){switch(e){case"flex-start":return f.Align.FlexStart;case"flex-end":return f.Align.FlexEnd;case"center":return f.Align.Center;case"stretch":return f.Align.Stretch;case"baseline":return f.Align.Baseline}}function ut(e){switch(e){case"border-box":return f.BoxSizing.BorderBox;case"content-box":return f.BoxSizing.ContentBox}}function lt(e){switch(e){case"ltr":return f.Direction.LTR;case"rtl":return f.Direction.RTL}}function dt(e){switch(e){case"none":return f.Display.None;case"flex":return f.Display.Flex;case"contents":return f.Display.Contents}}function ft(e){switch(e){case"row":return f.FlexDirection.Row;case"column":return f.FlexDirection.Column;case"row-reverse":return f.FlexDirection.RowReverse;case"column-reverse":return f.FlexDirection.ColumnReverse}}function ht(e){switch(e){case"wrap":return f.Wrap.Wrap;case"nowrap":return f.Wrap.NoWrap;case"wrap-reverse":return f.Wrap.WrapReverse}}function pt(e){switch(e){case"flex-start":return f.Justify.FlexStart;case"flex-end":return f.Justify.FlexEnd;case"center":return f.Justify.Center;case"space-between":return f.Justify.SpaceBetween;case"space-around":return f.Justify.SpaceAround;case"space-evenly":return f.Justify.SpaceEvenly}}function gt(e){switch(e){case"visible":return f.Overflow.Visible;case"hidden":return f.Overflow.Hidden;case"scroll":return f.Overflow.Scroll}}function ct(e){switch(e){case"absolute":return f.PositionType.Absolute;case"relative":return f.PositionType.Relative;case"static":return f.PositionType.Static}}var mt=/,(?![^(]*\))/,bt=/\s(?![^(]*\))/,Tt=/^[0-9]+[a-zA-Z%]+?$/;function yt(e){let t=e.split(bt),o=t.includes("inset"),r=t.slice(-1)[0],a=wt(r)?void 0:r,s=t.filter(d=>d!=="inset").filter(d=>d!==a).map(Pt),[i,n,u,l]=s;return{inset:o,offsetX:Number(i),offsetY:Number(n),blurRadius:Number(u),spreadRadius:l==null?void 0:Number(l),color:a}}function wt(e){return e==="0"||Tt.test(e)}function Pt(e){if(!/px$/.test(e)&&e!=="0")return e;let t=Number.parseFloat(e);return Number.isNaN(t)?e:t}var _=e=>e.split(mt).map(t=>t.trim()).map(yt);var xe=require("dequal"),Ce=require("klona"),M=require("yoga-layout/load");function te(e){let t=e.font!=null?e.font?.join(", "):"",o=e.size??"",r=e.weight??"";return`${e.style??""} ${r} ${o}px ${t}`.trim()}function I(e,t){e.font=te(t),t.letterSpacing!=null&&(e.letterSpacing=`${t.letterSpacing}px`),t.wordSpacing!=null&&(e.wordSpacing=`${t.wordSpacing}px`),t.color!=null&&typeof t.color=="string"&&(e.fillStyle=t.color)}function ke(e,t){let o=[],r=e.indexOf(t);for(;r!==-1;)o.push(r),r=e.indexOf(t,r+1);return o}var Rt=/^\s+$/;function re(e){return e.length===0?!1:Rt.test(e)}function kt(e,t,o,r,a){let s=r.lineHeight==null||Number.isNaN(r.lineHeight)?1:r.lineHeight,i=[],n={baseline:0,height:0,width:r.indentSize??0,segments:[],spacesCount:0};i.push(n);for(let p=0;p<e.length;p++){let T=e[p],c=typeof T=="string"?r:T.props,m=typeof T=="string"?T:T.children,b=t[p]||[];if(b.length===0){let P=a(m,c),R=P.width,y=P.fontBoundingBoxAscent+P.fontBoundingBoxDescent;if(n.width+R>o&&n.segments.length>0){n={baseline:0,height:0,width:0,segments:[],spacesCount:0},i.push(n);let q=m.trimStart();if(q!==m){let k=a(q,c);R=k.width,y=k.fontBoundingBoxAscent+k.fontBoundingBoxDescent;let C={metrics:k,props:c,text:q,width:R,height:y};n.segments.push(C),n.width+=R,n.height=Math.max(n.height,y),n.baseline=Math.max(n.baseline,k.fontBoundingBoxAscent);continue}}let x={metrics:P,props:c,text:m,width:R,height:y};n.segments.push(x),n.width+=R,n.height=Math.max(n.height,y),n.baseline=Math.max(n.baseline,P.fontBoundingBoxAscent);continue}let w=0;for(let P=0;P<b.length;P++){let R=b[P],y=m.substring(w,R);if(y.length===0){w=R;continue}let x=a(y,c),q=x.width,k=x.fontBoundingBoxAscent+x.fontBoundingBoxDescent;if(n.width+q>o&&n.segments.length>0){if(n.segments.length>0){let S=n.segments[n.segments.length-1],L=S.text.trimEnd();if(L!==S.text&&L.length>0){let v=a(L,S.props),W=v.width,z=v.fontBoundingBoxAscent+v.fontBoundingBoxDescent;S.text=L,S.metrics=v,S.width=W,S.height=z,n.width=n.segments.reduce((me,B)=>me+B.width,0)}}n={baseline:0,height:0,width:r.hangingIndentSize??0,segments:[],spacesCount:0},i.push(n);let h=y.trimStart();if(h!==y){if(h.length===0){w=R;continue}let S=a(h,c),L=S.width,v=S.fontBoundingBoxAscent+S.fontBoundingBoxDescent,W={metrics:S,props:c,text:h,width:L,height:v};n.segments.push(W),n.width+=L,n.height=Math.max(n.height,v),n.baseline=Math.max(n.baseline,S.fontBoundingBoxAscent),w=R;continue}}let C={metrics:x,props:c,text:y,width:q,height:k};n.segments.push(C),n.width+=q,n.height=Math.max(n.height,k),n.baseline=Math.max(n.baseline,x.fontBoundingBoxAscent),w=R}if(w<m.length){let P=m.substring(w),R=a(P,c),y=R.width,x=R.fontBoundingBoxAscent+R.fontBoundingBoxDescent;if(n.width+y>o&&n.segments.length>0){if(n.segments.length>0){let C=n.segments[n.segments.length-1],h=C.text.trimEnd();if(h!==C.text&&h.length>0){let S=a(h,C.props),L=S.width,v=S.fontBoundingBoxAscent+S.fontBoundingBoxDescent;C.text=h,C.metrics=S,C.width=L,C.height=v,n.width=n.segments.reduce((W,z)=>W+z.width,0)}}n={baseline:0,height:0,width:0,segments:[],spacesCount:0},i.push(n);let k=P.trimStart();if(k!==P){if(k.length===0)continue;let C=a(k,c),h=C.width,S=C.fontBoundingBoxAscent+C.fontBoundingBoxDescent,L={metrics:C,props:c,text:k,width:h,height:S};n.segments.push(L),n.width+=h,n.height=Math.max(n.height,S),n.baseline=Math.max(n.baseline,C.fontBoundingBoxAscent);continue}}let q={metrics:R,props:c,text:P,width:y,height:x};n.segments.push(q),n.width+=y,n.height=Math.max(n.height,x),n.baseline=Math.max(n.baseline,R.fontBoundingBoxAscent)}}for(let p of i){let T=[];for(let c=0;c<p.segments.length;c++){let m=p.segments[c];if(re(m.text)&&(c===p.segments.length-1||c===0)){p.width-=m.width;continue}T.push(m)}p.segments=T}let u=0;for(let p of i){p.baseline*=s,p.height*=s;let T=0,c=Number.POSITIVE_INFINITY;for(let m of p.segments){let b=m.props.offsetY??0;b>T&&(T=b),b<c&&(c=b)}if(p.baseline-=c,p.height-=c,p.height+=T,u<i.length-1)for(let m of p.segments){let b=m.text.match(/[ ]/);b&&(p.spacesCount+=b.length)}u++}let l=0,d=0;for(let p of i)l+=p.height,d=Math.max(d,p.width);let g=0;if(i.length>0&&r.lineHeight!=null&&!Number.isNaN(r.lineHeight)){let p=Math.max(0,r.lineHeight-1);for(let T of i[0].segments){let c=T.metrics,m=-((c.fontBoundingBoxAscent-c.fontBoundingBoxDescent)/2)*p;m<g&&(g=m)}}return{width:d,height:l,lines:i,offsetY:g}}function xt(e,t){let o=[[]];for(let a of e){let s=typeof a=="string"?a:a.children,i=ke(s,`
`);if(i.length===0){o[o.length-1].push(a);continue}i.length>0&&i[i.length-1]!==s.length&&i.push(s.length);let n=0;for(let u=0;u<i.length;u++){let l=i[u],d=s.slice(n,l);if(typeof a=="string")o[o.length-1].push(d);else{let g=(0,Ce.klona)(a);g.children=d,o[o.length-1].push(g)}u<i.length-1&&o.push([]),n=l+1}}let r=[];for(let a of o){let s=[];for(let i of a){let n=typeof i=="string"?i:i.children;s.push(Array.from(t(n)))}r.push(s)}return[o,r]}function ne(e,t,o,r,a){let[s,i]=xt(e,a),n=[];for(let u=0;u<s.length;u++){let l=i[u],d=s[u],g=kt(d,l,t,o,r);for(let p of g.lines){let T=[[]];for(let m of p.segments){let b=T[T.length-1];if(b.length>0){let w=b[b.length-1];if(o.align==="justify"&&re(m.text)){T.push([m]),T.push([]);continue}if(!(0,xe.dequal)(w.props,m.props)){T.push([m]);continue}}b.push(m)}let c=[];for(let m of T){if(m.length===0)continue;if(m.length===1){c.push(m[0]);continue}let b=m.slice(1).reduce((w,P)=>({metrics:w.metrics,text:w.text+P.text,height:Math.max(w.height,P.height),width:w.width+P.width,props:w.props}),m[0]);c.push(b)}p.segments=c}n.push({paragraph:g})}return n}function Se(e,t,o,r,a,s){let{props:i}=o,{blocks:n}=i;if(n==null)return;let u=r.getComputedBorder(M.Edge.Left)+r.getComputedBorder(M.Edge.Right)+r.getComputedPadding(M.Edge.Left)+r.getComputedPadding(M.Edge.Right),l=0;for(let{paragraph:d}of n){d.width=Math.max(r.getComputedWidth(),d.width)-u;let g=i.boxSizing==="content-box"?r.getComputedPadding(M.Edge.Left):0,p=i.boxSizing==="content-box"?r.getComputedPadding(M.Edge.Top):0,T=r.getComputedBorder(M.Edge.Left),c=r.getComputedBorder(M.Edge.Top),m=g+T,b=p+c,w=i.align;I(t,i);let P=d.offsetY+l;l+=d.height;for(let R=0;R<d.lines.length;R++){let y=d.lines[R],x=d.width-y.width,q=w==="justify"&&x>0&&y.spacesCount>0?x/y.spacesCount:0,k=0;switch(w){case"center":k=(d.width-y.width)/2;break;case"right":k=d.width-y.width;break;case"left":case"justify":R===0&&i.indentSize!=null&&(k+=i.indentSize),R>0&&i.hangingIndentSize!=null&&(k+=i.hangingIndentSize);break}for(let C=0;C<y.segments.length;C++){let h=y.segments[C],S=h.props.offsetY??0,L=h.width;w==="justify"&&/[ ]/.test(h.text)&&(L+=q);let v=a+m+k,W=s+y.baseline+b+P+S;if(typeof h.props.underline=="number"&&h.props.underline!==0){typeof h.props.color=="string"&&(t.fillStyle=h.props.underlineColor??h.props.color);let B=h.height*h.props.underline/18;t.fillRect(v,W+B,L,B)}if(typeof h.props.overline=="number"&&h.props.overline!==0){typeof h.props.color=="string"&&(t.fillStyle=h.props.overlineColor??h.props.color);let B=h.height*h.props.overline/18;t.fillRect(v,W-h.metrics.fontBoundingBoxAscent,L,B)}let z=W-h.height+h.metrics.fontBoundingBoxDescent;if(h.props.highlightColor!=null&&(t.fillStyle=h.props.highlightColor,t.fillRect(v,z,L,h.height)),I(t,h.props),h.props.dropShadows)for(let B of h.props.dropShadows)typeof B!="string"&&(t.save(),t.shadowOffsetX=B.offsetX,t.shadowOffsetY=B.offsetY,t.shadowBlur=B.blurRadius,B.color&&(t.shadowColor=B.color,t.fillStyle=B.color),t.fillText(h.text,v,W),t.restore());if(t.save(),h.props.strokeColor!=null&&h.props.strokeWidth!=null&&h.props.strokeWidth!==0&&(t.strokeStyle=h.props.strokeColor,t.lineJoin="round",t.miterLimit=2,t.lineWidth=h.props.strokeWidth,t.strokeText(h.text,v,W)),typeof h.props.color!="string"&&Array.isArray(h.props.color))for(let B of h.props.color){let[ze]=V(t,[B],a,s,h.width,h.height);t.fillStyle=ze}if(t.fillText(h.text,v,W),t.restore(),typeof h.props.lineThrough=="number"&&h.props.lineThrough!==0){typeof h.props.color=="string"&&(t.fillStyle=h.props.lineThroughColor??h.props.color);let B=h.height*h.props.lineThrough/18;t.fillRect(v,W-(h.metrics.fontBoundingBoxAscent-h.metrics.fontBoundingBoxDescent)/2,L,B)}e.debug().text&&(t.save(),t.lineWidth=e.dpr()*2,t.strokeStyle="cyan",t.strokeRect(v,z,L,h.height),t.restore()),k+=L}P+=y.height}}}var Ct=(0,N.loadYoga)();async function qe(){return Ct}var se={size:11,color:"black",font:["sans-serif"],style:"normal",weight:400,letterSpacing:0,nowrap:!1,lineHeight:Number.NaN,indentSize:0,hangingIndentSize:0,align:"left",strokeColor:"black",strokeWidth:0,wordSpacing:0,blocks:[],offsetY:0,underline:0,underlineColor:null,overline:0,overlineColor:null,lineThrough:0,lineThroughColor:null,highlightColor:null,dropShadows:[],autofit:!1};function oe(e){return Object.fromEntries(Object.entries(e).filter(([t,o])=>o!=null))}function ie(e,t){let o=e.props,r=t.width/t.height;o.preserveAspectRatio&&(typeof o.width=="number"&&typeof o.height!="number"&&(o.height=Math.round(o.width/r)),typeof o.height=="number"&&typeof o.width!="number"&&(o.width=Math.round(o.height*r))),o.width==null&&(o.width=t.width),o.height==null&&(o.height=t.height),o.image=t}async function Q(e,{defaultTextProps:t,loadImage:o,breakIterator:r,createId:a}){if(e==null)return;if(e.type!=="text-default"){if(e.id===-1&&(e.id=a()),e.props.shadows!=null&&Array.isArray(e.props.shadows)){let i=[];for(let n of e.props.shadows)typeof n=="string"?i.push(..._(n)):i.push(n);e.props.shadows=i}if(e.props.background!=null&&Array.isArray(e.props.background)){let i=[];for(let n of e.props.background){if(typeof n=="string"){if(!F(n)){let u=(0,J.parse)(n);i.push(...u);continue}}else n.type==="photo"&&(typeof n.props.src=="string"||Buffer.isBuffer(n.props.src))&&ie(n,await o(n.props.src));i.push(n)}e.props.background=i}}if(e.type==="table-row"&&e.props.flexDirection==null&&(e.props.flexDirection="row"),e.type==="text"){if(e.props.flexShrink==null&&(e.props.flexShrink=1),e.props.boxSizing==null&&(e.props.boxSizing="content-box"),e.props={...t,...oe(e.props)},e.props.dropShadows!=null&&Array.isArray(e.props.dropShadows)){let i=[];for(let n of e.props.dropShadows)typeof n=="string"?i.push(..._(n)):i.push(n);e.props.dropShadows=i}return typeof e.props.color=="string"&&(F(e.props.color)||(e.props.color=(0,J.parse)(e.props.color))),e.children.map(i=>{if(typeof i=="string")return i;let n=(0,Le.default)(e.props,["size","color","font","style","weight","letterSpacing","wordSpacing","strokeColor","strokeWidth","underline","underlineColor","overline","overlineColor","lineThrough","lineThroughColor","highlightColor","dropShadows"]);if(i.props={...oe(n),...i.props},i.props.dropShadows!=null&&Array.isArray(i.props.dropShadows)){let u=[];for(let l of i.props.dropShadows)typeof l=="string"?u.push(..._(l)):u.push(l);i.props.dropShadows=u}return typeof i.props.color=="string"&&(F(i.props.color)||(i.props.color=(0,J.parse)(i.props.color))),i}),e}if(e.type==="photo")return typeof e.props.src=="string"||Buffer.isBuffer(e.props.src)?(ie(e,await o(e.props.src)),e):void 0;if(e.type==="row"&&e.props.flexDirection==null&&(e.props.flexDirection="row"),e.type!=="text-default"&&e.props.background!=null){for(let i of e.props.background)if(typeof i!="string"&&i.type==="photo"&&(typeof i.props.src=="string"||Buffer.isBuffer(i.props.src)))return ie(i,await o(i.props.src)),e}if(e.type==="path")return e.props.d&&(e.props.bounds=(0,Be.default)(e.props.d)),e;let s=[];for(let i of e.children)if(i!=null){if(i.type==="text-default"){let n={...t,...oe(i.props)};for(let u of i.children)u!=null&&s.push(await Q(u,{defaultTextProps:n,loadImage:o,breakIterator:r,createId:a}));continue}s.push(await Q(i,{defaultTextProps:t,loadImage:o,breakIterator:r,createId:a}))}if(e.children=s.filter(i=>i!=null),e.type==="table"&&e.props.spacing!=null&&Array.isArray(e.props.spacing)){let[i,n]=e.props.spacing;n=n??i;for(let u of e.children)if(u!=null)for(let l of u.children){if(l==null)return;l.type!=="text-default"&&(l.props.paddingLeft==null&&(l.props.paddingLeft=i),l.props.paddingRight==null&&(l.props.paddingRight=i),l.props.paddingTop==null&&(l.props.paddingTop=n),l.props.paddingBottom==null&&(l.props.paddingBottom=n))}}return e}function ue(e){if(e==null||e.type==="photo"||e.type==="path")return;if(e.type==="text"){let o=new Set;for(let r of e.children)if(typeof r!="string"&&r.props.font!=null)for(let a of r.props.font)o.add(a);if(e.props.font!=null)for(let r of e.props.font)o.add(r);return o}let t=new Set;for(let o of e.children){let r=ue(o);if(r!=null)for(let a of r)t.add(a)}return t}function le(e,t,o){if(e==null)return;if(e.type==="text-default")throw new Error("The layout includes TextDefaut node which is illegal!");let r=o.Node.create();if(Re(e.props,r),e.type==="photo")return r;if(e.type==="text"){let a=(s,i,n,u)=>{let{props:l,children:d}=e,g=0,p=0,T=(0,ae.klona)(l),c=b=>{let w={...T,size:b},P=ne(d,s,w,t.measureText,t.breakIterator),R=0,y=0;for(let{paragraph:x}of P)x.width>R&&(R=x.width),y+=x.height;return{blocks:P,width:R,height:y}},m=ne(d,s,T,t.measureText,t.breakIterator);for(let{paragraph:b}of m)b.width>g&&(g=b.width),p+=b.height;if(l.autofit&&!Number.isNaN(n)&&u===N.MeasureMode.Exactly){let b=1,w=200,P=T.size||12;if(c(P).height<=n)for(;w-b>1;){let x=Math.floor((b+w)/2);c(x).height<=n?(b=x,P=x):w=x}else for(w=P;w-b>1;){let x=Math.floor((b+w)/2);c(x).height<=n?(b=x,P=x):w=x}let y=c(P);m=y.blocks,g=y.width,p=y.height,T.size=P}return i===N.MeasureMode.AtMost&&(g=Math.min(s,g)),e.props.blocks=m,{width:g,height:p}};return r.setMeasureFunc(a),r}if(e.type==="path"){if(e.props.bounds!=null){let[a,s,i,n]=e.props.bounds,u=e.props.scalePath??1;if(e.props.width==null){let l=i-a;r.setWidth(l*u)}if(e.props.height==null){let l=n-s;r.setHeight(l*u)}}return r}for(let a of e.children){if(a==null)continue;let s=le(a,t,o);s!=null&&r.insertChild(s,r.getChildCount())}if(e.type==="table"){let a=[];for(let s=0;s<r.getChildCount();s++){let i=0;for(let n=0;n<r.getChild(s).getChildCount();n++){a.length-1<n&&a.push(0);let u=r.getChild(s).getChild(n);u.calculateLayout(void 0,void 0);let l=u.getComputedWidth(),d=u.getComputedHeight();i<d&&(i=d),a[n]<l&&(a[n]=l)}for(let n=0;n<r.getChild(s).getChildCount();n++)r.getChild(s).getChild(n).setMinHeight(i)}for(let s=0;s<r.getChildCount();s++)for(let i=0;i<r.getChild(s).getChildCount();i++)r.getChild(s).getChild(i).setMinWidth(a[i])}return r}async function de(e,t,o){let r=await qe(),a=ue(e);if(a!=null)for(let d of a)d!=="serif"&&d!=="sans-serif"&&d!=="monospace"&&d!=="cursive"&&d!=="fantasy"&&d!=="system-ui"&&(t.hasFont(d)||console.warn(`${JSON.stringify(d)} font has not been registered!`));let s=o==null||o.cache==null?new Map:o.cache,i=0,n=()=>i++,u=await Q((0,ae.klona)(e),{defaultTextProps:t.getDefaultTextProps(),loadImage:(0,ve.default)(t.loadImage,{cache:s}),breakIterator:t.breakIterator,createId:n});(o==null||o.cache==null)&&s.clear();let l=le(u,t,r);if(l==null)throw new Error("Unable to create canvas!");return l.calculateLayout(o?.width,o?.height),{layout:l,compiledNode:u}}async function fe(e,t,o){let{compiledNode:r,layout:a}=await de(e,t,o),s=t.createCanvas(a.getComputedWidth(),a.getComputedHeight());he(s,r,t,a,o);let i=Ne(r,a);return{canvas:s,metadata:i}}function he(e,t,o,r,a){let s=e.getContext("2d");a?.background&&(s.fillStyle=a.background,s.fillRect(0,0,e.width,e.height));function i(n,u,l,d){if(n!=null)try{if(s.save(),n.type!=="text-default"&&ge(s,n,u,l,d),n.type==="text-default")return;if(n.type==="text"){U(o,s,n,u,l,d),Se(o,s,n,u,l,d);return}if(n.type==="photo"){ee(o,s,n,u,l,d);return}if(n.type==="path"){U(o,s,n,u,l,d),Ae(o,s,n,l,d);return}U(o,s,n,u,l,d);for(let g=0;g<n.children.length;g++){let p=u.getChild(g),T=n.children[g];i(T,p,l+p.getComputedLeft(),d+p.getComputedTop())}n.type==="table"&&Me(o,s,n,u,l,d)}finally{s.restore(),o.debug().layout&&We(o,s,n,u,l,d)}}i(t,r,0,0)}function Ne(e,t){function o(r,a,s,i){if(r==null||r.type==="text-default")return;let n=r.props,u=r.type,l={x:s,y:i,width:a.getComputedWidth(),height:a.getComputedHeight(),position:{top:a.getComputedTop(),bottom:a.getComputedBottom(),left:a.getComputedLeft(),right:a.getComputedRight()},padding:{top:a.getComputedPadding(N.Edge.Top),left:a.getComputedPadding(N.Edge.Left),right:a.getComputedPadding(N.Edge.Right),bottom:a.getComputedPadding(N.Edge.Bottom)},margin:{top:a.getComputedMargin(N.Edge.Top),left:a.getComputedMargin(N.Edge.Left),right:a.getComputedMargin(N.Edge.Right),bottom:a.getComputedMargin(N.Edge.Bottom)}};if(u==="text")return{type:u,children:r.children,props:r.props,...l};let d=[];if(u==="column"||u==="row"||u==="table"||u==="table-row"||u==="table-cell")for(let g=0;g<r.children.length;g++){let p=a.getChild(g),T=r.children[g];if(T==null)continue;let c=o(T,p,s+p.getComputedLeft(),i+p.getComputedTop());c!=null&&d.push(c)}return{type:u,props:n,children:d,...l}}return o(e,t,0,0)}async function pe(e,t,o){let{layout:r,compiledNode:a}=await de(e,t,o),s=t.createCanvas(r.getComputedWidth(),r.getComputedHeight());return he(s,a,t,r,o),r.freeRecursive(),s}function U(e,t,o,r,a,s){let i=r.getComputedWidth(),n=r.getComputedHeight(),u=o.props,l=X(e,i,n,j(u.cornerRadius??[0],Math.min(i,n)),u.cornerSmoothing,u.corner);if(u.background!=null&&u.shadows)for(let d of u.shadows)typeof d!="string"&&(t.save(),t.shadowOffsetX=d.offsetX,t.shadowOffsetY=d.offsetY,t.shadowBlur=d.blurRadius,d.color&&(t.shadowColor=d.color,t.fillStyle=d.color),t.translate(a,s),t.fill(l),t.restore());if(t.save(),t.translate(a,s),t.clip(l),t.translate(-a,-s),u.background!=null)for(let d of u.background){if(typeof d=="string"){t.fillStyle=d,t.fillRect(a,s,i,n);continue}if(d.type==="photo"){t.save(),ge(t,d,r,a,s),ee(e,t,d,r,a,s),t.restore();continue}let[g]=V(t,[d],a,s,i,n);t.fillStyle=g,t.fillRect(a,s,i,n)}return t.restore(),Y(t,r,u,l,a,s),l}function ge(e,t,o,r,a){if(t==null||t.type==="text-default")return;typeof t.props.opacity=="number"&&(e.globalAlpha=t.props.opacity);let{translateX:s,translateY:i}=t.props;e.translate(s??0,i??0);let n=r+o.getComputedWidth()/2,u=a+o.getComputedHeight()/2,l=t.props.rotation;typeof l=="number"&&l!==0&&(e.translate(n,u),e.rotate(l*Math.PI/180),e.translate(-n,-u));let d=t.props.scale;if(d!=null&&Array.isArray(d)&&(e.translate(n,u),e.scale(d[0],d[1]),e.translate(-n,-u)),t.props.filters!=null&&Array.isArray(t.props.filters)){let g=t.props.filters.join(" ");e.filter=g}}function We(e,t,o,r,a,s){if(o==null||o.type==="text-default")return;t.save(),t.lineWidth=2,t.strokeStyle="cyan",t.strokeRect(a,s,r.getComputedWidth(),r.getComputedHeight());let i=o.props.tag!=null?`${o.type}:${o.props.tag}`:o.type;t.font=`${20*e.dpr()}px monospace`;let n=t.measureText(i);t.fillStyle="rgba(0,255,255,.6)",t.fillRect(a,s,n.width,n.fontBoundingBoxAscent+n.fontBoundingBoxDescent),t.strokeStyle="cyan",t.strokeRect(a,s,n.width,n.fontBoundingBoxAscent+n.fontBoundingBoxDescent),t.fillStyle="black",t.textBaseline="top",t.fillText(i,a,s),t.restore()}function Ae(e,t,o,r,a){t.save();let{props:s}=o,{d:i}=s;if(!i){t.restore();return}let n=new e.Path2D(i);if(t.translate(r,a),s.bounds){let[u,l]=s.bounds;t.scale(s.scalePath??1,s.scalePath??1),t.translate(-u,-l)}if(s.fill!=null){if(t.fillStyle=s.fill,s.fillOpacity!=null){let u=t.globalAlpha;t.globalAlpha=u*s.fillOpacity}s.fillRule?t.fill(n,s.fillRule):t.fill(n),s.fillOpacity!=null&&(t.globalAlpha=t.globalAlpha/s.fillOpacity)}s.stroke!=null&&(t.strokeStyle=s.stroke,s.strokeWidth!=null&&(t.lineWidth=s.strokeWidth),s.strokeLineCap&&(t.lineCap=s.strokeLineCap),s.strokeLineJoin&&(t.lineJoin=s.strokeLineJoin),s.strokeMiterLimit!=null&&(t.miterLimit=s.strokeMiterLimit),s.strokeDashArray!=null&&t.setLineDash(s.strokeDashArray),s.strokeDashOffset!=null&&(t.lineDashOffset=s.strokeDashOffset),t.stroke(n)),t.restore()}function Me(e,t,o,r,a,s){t.save();let i=0;o.props.borderColor!=null&&(t.strokeStyle=o.props.borderColor),o.props.borderWidth!=null&&(t.lineWidth=o.props.borderWidth,i=o.props.borderWidth);let n=0,u=-1;t.beginPath();for(let l=0;l<r.getChildCount();l++){let d=r.getChild(l);(u===-1||d.getChildCount()>r.getChild(u).getChildCount())&&(u=l),l!==r.getChildCount()-1&&(t.moveTo(a,s+d.getComputedHeight()+n+i),t.lineTo(a+r.getComputedWidth(),s+d.getComputedHeight()+n+i),n+=d.getComputedHeight())}if(u!==-1){let l=r.getChild(u),d=0;for(let g=0;g<l.getChildCount();g++){let p=l.getChild(g);g>0&&(t.moveTo(a+d+i,s),t.lineTo(a+d+i,s+r.getComputedHeight())),d+=p.getComputedWidth()}}t.stroke(),t.restore()}function H(e={}){let t=r=>{e.filters==null&&(e.filters=[]),e.filters.push(r)},o=(...r)=>{e.background==null&&(e.background=[]),e.background.push(...r)};return{props:e,tag(r){return e.tag=r,this},apply(r){return Object.assign(e,r),this},alignContent(r){return e.alignContent=r,this},alignItems(r){return e.alignItems=r,this},alignSelf(r){return e.alignSelf=r,this},aspectRatio(r){return e.aspectRatio=r,this},corner(r){return e.corner=r,this},borderWidth(r,a,s,i){return a==null&&s==null&&i==null?(e.borderWidth=r,this):a!=null&&s==null&&i==null?(e.borderTopWidth=r,e.borderBottomWidth=r,e.borderLeftWidth=a,e.borderRightWidth=a,this):a!=null&&s!=null&&i==null?(e.borderTopWidth=r,e.borderBottomWidth=s,e.borderLeftWidth=a,e.borderRightWidth=a,this):(e.borderTopWidth=r,e.borderBottomWidth=s,e.borderLeftWidth=i,e.borderRightWidth=a,this)},borderColor(r){return e.borderColor=r,this},margin(r,a,s,i){return a==null&&s==null&&i==null?(e.margin=r,this):a!=null&&s==null&&i==null?(e.marginTop=r,e.marginBottom=r,e.marginLeft=a,e.marginRight=a,this):a!=null&&s!=null&&i==null?(e.marginTop=r,e.marginLeft=a,e.marginRight=a,e.marginBottom=s,this):(e.marginTop=r,e.marginLeft=i,e.marginRight=a,e.marginBottom=s,this)},marginTop(r){return e.marginTop=r,this},marginBottom(r){return e.marginBottom=r,this},marginLeft(r){return e.marginLeft=r,this},marginRight(r){return e.marginRight=r,this},padding(r,a,s,i){return a==null&&s==null&&i==null?(e.padding=r,this):a!=null&&s==null&&i==null?(e.paddingTop=r,e.paddingBottom=r,e.paddingLeft=a,e.paddingRight=a,this):a!=null&&s!=null&&i==null?(e.paddingTop=r,e.paddingLeft=a,e.paddingRight=a,e.paddingBottom=s,this):(e.paddingTop=r,e.paddingLeft=i,e.paddingRight=a,e.paddingBottom=s,this)},paddingTop(r){return e.paddingTop=r,this},paddingBottom(r){return e.paddingBottom=r,this},paddingLeft(r){return e.paddingLeft=r,this},paddingRight(r){return e.paddingRight=r,this},boxSizing(r){return e.boxSizing=r,this},display(r){return e.display=r,this},flex(r){return e.flex=r,this},basis(r){return e.flexBasis=r,this},direction(r){return e.flexDirection=r,this},rowGap(r){return e.rowGap=r,this},gap(r){return e.gap=r,this},columnGap(r){return e.columnGap=r,this},grow(r){return e.flexGrow=r,this},shrink(r){return e.flexShrink=r,this},wrap(r){return e.flexWrap=r,this},justifyContent(r){return e.justifyContent=r,this},left(r){return e.left=r,this},right(r){return e.right=r,this},bottom(r){return e.bottom=r,this},top(r){return e.top=r,this},start(r){return e.start=r,this},end(r){return e.end=r,this},size(r,a){return e.width=r,e.height=a??r,this},width(r){return e.width=r,this},height(r){return e.height=r,this},maxWidth(r){return e.maxWidth=r,this},maxHeight(r){return e.maxHeight=r,this},minWidth(r){return e.minWidth=r,this},minHeight(r){return e.minHeight=r,this},position(r){return e.position=r,this},inset(r){return e.inset=r,this},overflow(r){return e.overflow=r,this},rotate(r){return e.rotation=r,this},scale(r,a){return e.scale=[r,a??r],this},translateX(r){return e.translateX=r,this},translateY(r){return e.translateY=r,this},bg(...r){return o(...r),this},background(...r){return o(...r),this},opacity(r){return e.opacity=r,this},borderRadius(...r){return e.cornerRadius=r,this},borderSmoothing(r){return e.cornerSmoothing=r,this},rounded(...r){return e.cornerRadius=r,this},cornerRadius(...r){return e.cornerRadius=r,this},cornerSmoothing(r){return e.cornerSmoothing=r,this},shadow(...r){return e.shadows==null&&(e.shadows=[]),e.shadows.push(...r),this},blur(r){return t(`blur(${r}px)`),this},brightness(r){return t(`brightness(${r})`),this},contrast(r){return t(`contrast(${r})`),this},grayscale(r){return t(`grayscale(${r})`),this},huerotate(r){return t(`hue-rotate(${r})`),this},invert(r){return t(`invert(${r})`),this},saturate(r){return t(`saturate(${r})`),this},sepia(r){return t(`sepia(${r})`),this}}}function ce(e={}){return{props:e,underline(t){return e.underline=t??1,this},underlineColor(t){return e.underlineColor=t,this},overline(t){return e.overline=t??1,this},overlineColor(t){return e.overlineColor=t,this},lineThrough(t){return e.lineThrough=t??1,this},lineThroughColor(t){return e.lineThroughColor=t,this},highlight(t){return e.highlightColor=t,this},offsetY(t){return e.offsetY=t,this},color(t){return e.color=t,this},size(t){return e.size=t,this},font(...t){return e.font=t,this},style(t){return e.style=t,this},weight(t){return e.weight=t,this},letterSpacing(t){return e.letterSpacing=t,this},wordSpacing(t){return e.wordSpacing=t,this},strokeColor(t){return e.strokeColor=t,this},strokeWidth(t){return e.strokeWidth=t,this},dropShadow(...t){return e.dropShadows==null&&(e.dropShadows=[]),e.dropShadows.push(...t),this}}}function St(e={}){return{...H(e),...ce(e),nowrap(){return e.nowrap=!0,this},autofit(t){return e.autofit=t??!0,this},wrap(t){return e.nowrap=!t,this},lineHeight(t){return e.lineHeight=t,this},align(t){return e.align=t,this},indent(t){return e.indentSize=t,this},hangingIndent(t){return e.hangingIndentSize=t,this},props:e}}function Lt(e){return{type:"span",children:e,...ce()}}function vt(e){return{...ce(e),nowrap(){return e.nowrap=!0,this},wrap(t){return e.nowrap=!t,this},lineHeight(t){return e.lineHeight=t,this},align(t){return e.align=t,this},indent(t){return e.indentSize=t,this},props:e}}function Bt(...e){return{type:"text-default",children:e,...vt({})}}function qt(...e){return{id:-1,type:"text",children:e.filter(t=>t!=null),...St()}}function Nt(...e){return{id:-1,type:"column",children:e,...H()}}function Wt(...e){return{id:-1,type:"row",children:e,...H()}}function At(e){let t={src:e};return{id:-1,type:"photo",...H(t),scaleType(o,r){if(t.scaleType=o,typeof r=="string")switch(r){case"center":t.scaleAlignment=1/2;break;case"end":t.scaleAlignment=1;break;case"start":t.scaleAlignment=0;break}else t.scaleAlignment=r;return this},preserveAspectRatio(o=!0){return t.preserveAspectRatio=o,this},flipVertical(o=!0){return t.flipVertical=o,this},flipHorizontal(o=!0){return t.flipHorizontal=o,this},fill(o){return t.fill=o,this}}}function De(e){return{...H(e),props:e,stroke(t){return e.stroke=t,this},strokeWidth(t){return e.strokeWidth=t,this},strokeLineCap(t){return e.strokeLineCap=t,this},strokeLineJoin(t){return e.strokeLineJoin=t,this},strokeMiterLimit(t){return e.strokeMiterLimit=t,this},strokeDashArray(...t){return e.strokeDashArray=t,this},strokeDashOffset(t){return e.strokeDashOffset=t,this},fill(t){return e.fill=t,this},fillOpacity(t){return e.fillOpacity=t,this},fillRule(t){return e.fillRule=t,this},scalePath(t){return e.scalePath=t,this}}}function Mt(e){let t={d:e};return{id:-1,type:"path",...De(t),props:t}}function Dt(...e){let t={};return{id:-1,type:"table",children:e,...H(t),spacing(...o){return t.spacing=o,this}}}function Ht(...e){return{id:-1,type:"table-row",children:e,...H({})}}function It(...e){let t={};return{id:-1,type:"table-cell",children:e,...H(t),colspan(o){return t.colspan=o,this},rowspan(o){return t.rowspan=o,this},props:t}}var He=require("uqr");function zt(e,t={}){let o=(0,He.encode)(e,t),{pixelSize:r=10,whiteColor:a="white",blackColor:s="black"}=t,i=o.size*r,n=o.size*r,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n} ${i}" width="${n}" height="${i}">`,l=[];for(let d=0;d<o.size;d++)for(let g=0;g<o.size;g++){let p=g*r,T=d*r;o.data[d][g]&&l.push(`M${p},${T}h${r}v${r}h-${r}z`)}return u+=`<rect fill="${a}" width="${n}" height="${i}"/>`,u+=`<path fill="${s}" d="${l.join("")}"/>`,u+="</svg>",Buffer.from(u)}var $t=new D.default.Canvas(1,1),$={debug(){return{layout:!1,text:!1}},hasFont:e=>D.FontLibrary.has(e),Path2D:D.default.Path2D,breakIterator:Z,createCanvas(e,t){return new D.default.Canvas(e,t)},measureText(e,t){let o=$t.getContext("2d");return I(o,t),o.measureText(e)},async registerFont(e,t){D.default.FontLibrary.use(e,t)},async unregisterFont(){},resetFonts(){D.default.FontLibrary.reset()},async loadImage(e){return D.default.loadImage(typeof e=="string"?e:Ie.Buffer.from(e))},getDefaultTextProps(){return se},dpr(){return 1}};function Et(e,t){let o=async()=>pe(e,$,t);return{jpg:async(r=1,a)=>(await o()).toBuffer("jpg",{quality:r,...a}),png:async r=>(await o()).toBuffer("png",r),svg:async r=>(await o()).toBuffer("svg",r),pdf:async r=>(await o()).toBuffer("pdf",r),webp:async r=>(await o()).toBuffer("webp",r),raw:async r=>(await o()).toBuffer("raw",r),canvas:async()=>o(),canvasWithMetadata:async()=>fe(e,$,t)}}var Ot={async load(e,t){return $.registerFont(e,t)},async unload(e){return $.unregisterFont(e)},has(e){return $.hasFont(e)}};0&&(module.exports={Column,DEFAULT_TEXT_PROPS,Font,Path,Photo,Row,Span,Table,TableCell,TableRow,Text,TextDefault,applySpanProps,calculateLayout,compile,createLayoutNode,createMetadata,defaultLineBreakerIterator,drawDebugBBox,drawLayoutNode,drawOnCanvas,drawPathNode,drawTableNode,findFonts,fontBuilder,getYogaLayout,makeTransforms,pathPropsBuilder,qrcode,render,renderWithMetadata,renderer,sone});